/* ============================================================
   PetalMesh - wording and panel polish (UI/UX lane G).
   Loaded after app.css: targeted additions only. Everything uses tokens.css values.
   ============================================================ */

/* ---------- Panel buttons look like buttons ---------- */
/* A subtle fill and border, hover, active and a keyboard focus ring. Toggle state (.active / .on) and the special small
   buttons (remove, icon, chips inside layer rows, dock tabs) keep their own look. */
.dock .panel button:not(.remove):not(.icon):not(.chip):not(.active):not(.on):not(.primary),
button.panel-btn {
  background: var(--color-bg-overlay);
  border: 1px solid var(--color-border-strong);
  color: var(--color-text-primary);
  padding: 4px var(--space-2);
  box-shadow: var(--edge-highlight);
}

.dock .panel button:not(.remove):not(.icon):not(.chip):not(.active):not(.on):not(.primary):hover,
button.panel-btn:hover {
  background: color-mix(in srgb, var(--color-bg-overlay) 80%, white 12%);
  border-color: var(--color-text-muted);
}

.dock .panel button:not(.remove):not(.icon):not(.chip):not(.active):not(.on):not(.primary):active,
button.panel-btn:active {
  background: var(--color-bg-raised);
  box-shadow: none;
}

.dock button:focus-visible,
button.panel-btn:focus-visible,
.palette li:focus-visible {
  outline: none;
  box-shadow: var(--shadow-ring);
}

.dock .panel button:disabled {
  opacity: 0.45;
}

/* Layer-row chips: a visible edge as well. */
.layer .chip {
  border-color: var(--color-border-strong);
}

/* ---------- Dropdowns: never squeezed to a stub ---------- */
/* A select in a button row takes a fair share of the row and wraps to the next line instead of shrinking to "Ex". */
.dock .panel .row > select {
  flex: 1 1 7.5em;
  min-width: 6em;
  max-width: 100%;
}

#export-preset { flex-basis: 100%; }
#export-res { flex: 0 1 6em; }
#add-adjust-layer { flex: 1 1 6.5em; min-width: 6.5em; }
.dock .panel > select { width: 100%; }

/* Mask preset row inside a layer: the dropdown gets its own line, the buttons wrap below it. */
.mask-presets { flex-wrap: wrap; row-gap: var(--space-1); }
.mask-presets select { flex: 1 1 100%; min-width: 0; }
.mask-presets button { flex: 0 1 auto; }

/* ---------- Checkbox and dropdown fields (panel-widgets.js) ---------- */
.flag-field,
.choice-field {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
}
.choice-field > span { flex: 0 0 auto; min-width: 3.5em; }
.choice-field > select { flex: 1 1 auto; }

/* ---------- Sculpt > Groups rows ---------- */
.group-row { flex-wrap: wrap; align-items: center; row-gap: var(--space-1); }
.group-row .group-name {
  flex: 1 1 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.group-row button { flex: 0 1 auto; padding: 2px var(--space-2); }
.group-row.active .group-name { color: var(--color-accent); }

/* ---------- Modifier buttons: an even grid ---------- */
.dock .panel .row.modifier-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-1);
}
.dock .panel .row.modifier-grid > button { width: 100%; justify-content: center; }

/* ---------- Text contrast and size ---------- */
/* tokens.css raises the muted / secondary colours and --text-xs to 12px; the literal 10-11px sizes below follow. */
.shelf-btn-label { font-size: 11px; }
.empty-scene-hint,
#layer-list .empty-state { font-size: var(--text-xs); }
kbd { font-size: 11px; }
.statusbar .hint { color: var(--color-text-secondary); }
.dock-tabs button { font-size: var(--text-sm); }

/* ---------- Command palette ---------- */
.palette-heading {
  padding: var(--space-1) var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
}
.palette ul { max-height: 52vh; }
.palette li { align-items: flex-start; gap: var(--space-3); padding: 6px var(--space-3); }
.palette li .pal-main {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 var(--space-2);
  min-width: 0;
  flex: 1 1 auto;
}
.palette li .pal-title { color: var(--color-text-primary); }
.palette li kbd { margin-left: 0; }
.palette li .pal-desc {
  flex: 1 1 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.palette li.readonly .pal-title { color: var(--color-text-secondary); }
.palette li .modes { flex: none; white-space: nowrap; padding-top: 2px; }
.palette li.disabled .pal-title { color: var(--color-text-muted); }

/* ---------- Onboarding tour: a card next to the element it explains ---------- */
#tour-overlay.tour-anchored {
  display: block;
  background: none;
  padding: 0;
  pointer-events: none;
}
#tour-overlay.tour-anchored[hidden] { display: none; }
#tour-overlay.tour-anchored .tour-card {
  position: fixed;
  width: min(320px, 90vw);
  padding: var(--space-4);
  pointer-events: auto;
  border-color: var(--color-accent);
}
#tour-overlay.tour-anchored .tour-body p { line-height: 1.45; }
.tour-spot {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--color-accent-muted), 0 0 18px rgb(242 160 61 / 0.45);
  border-radius: var(--radius-sm);
}

/* Integration: an author `display` rule on a button (flex) must not defeat the hidden attribute (the readiness chip on an empty scene). */
[hidden] { display: none !important; }

/* ---------- Properties > Shading, and greyed quick-menu items ---------- */
#shading-fields .shading-count { align-items: center; justify-content: space-between; font-size: var(--text-sm); }
#shading-fields .shading-count .name { flex: 1 1 auto; }
#shading-fields .shading-count button { flex: 0 0 auto; }
#shading-fields button:disabled { opacity: 0.45; cursor: default; }
.quick-menu .quick-menu-item.disabled { opacity: 0.45; cursor: default; }
.quick-menu:has(.quick-menu-item.disabled) { width: 320px; }

/* UV "Groups" popover (uv-pack-panel.js) */
.uv-pack-panel {
  position: fixed;
  z-index: 60;
  min-width: 260px;
  max-width: 340px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--panel, #22252b);
  border: 1px solid var(--border, #3a3f48);
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}
.uv-pack-panel .uv-pack-title { font-weight: 600; margin-top: 4px; }
.uv-pack-panel .row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.uv-pack-panel input[type=number] { width: 64px; }
.layer .mask-editor .chip.source-invert { padding: 0 6px; }
