/* ============================================================================
   zz_studio_look.css — the Post studio LOOK settings-group card (plan stage
   C-4; docs/design/new_content_screen.md §6.1 + §6.3; decisions C4 / C5 / C10
   in docs/design/builder_v6_decisions.md; map rows A2 quick-theme-preset /
   quick-use-logos / cfg-color-mode / cfg-color-palette and B2 Canvas theme
   (layout-background-mode) in docs/new_content/studio_control_map.md).

   Scope: :is(#new-content-shell, #editor-workspace-root) .sp-studio-card--look. The shared card grammar
   (.sp-studio-card, -head, -eyebrow, -body, .sp-studio-row, .sp-studio-row-label,
   .sp-studio-segments incl. the lime [data-active] chip) lives in
   zz_studio_output.css (C-2) and is only USED here, not restated. The DS
   toggle geometry is restated from zz_studio_text.css (C-3) under this
   card's scope — that file is the TEXT card's and stays untouched.

   Rows (spec §6.3 LOOK):
   * Theme preset — the shipped quick-theme-preset Select in the DS input
     skin; quick-style-status (a callback Output) sits under it, hidden
     while empty.
   * Canvas theme — the shipped layout-background-mode SegmentedControl over
     its three values. v6 draws Dark / Light only: the "Custom" control is
     display:none unless it is the checked value (:has(input:checked) — the
     C-2 long-tail pattern), so a loaded custom profile shows its state; the
     Dark-first order is CSS `order`. The data list is unchanged.
   * Colors — the shipped cfg-color-mode segments (v6 does not draw them; a
     live value axis is kept visible).
   * Palette — cfg-color-palette as v6 swatch buttons: each control's label
     gets three color stripes (::before) keyed on input[value=…]. The stripe
     colors are the first three entries of figure_builder.CHART_COLOR_PALETTES
     (tests/new_content/test_studio_look.py asserts this file matches the
     registry — layout.py cannot import figure_builder, which imports layout);
     "auto" is a neutral swatch. Selected = the shared lime chip.
   * Player photos / logos — the shipped quick-use-logos Switch as the DS
     toggle (§4: 38×24, 18px knob, 3px inset, #2A2C33 → #FF6B2C on).
   * Saved presets (C-6a, map B7) — the LAST row: the shipped
     preset-modal-trigger (ex topbar) as the DS §1.5 ghost pill; its
     callback-written display:none (stats -> database mode only) hides the
     whole row (:has(), the C-5c pattern). The ≤640 topbar hide-list keys on
     its .sp-preview-preset-trigger class — re-shown inside the card at 2-id
     specificity, but ONLY while the gate does not hide it (a plain
     !important show would defeat the inline gate = a functional change).
     The modal it opens is a Mantine portal at z 200 — under the fixed ≤640
     sheet (z 2000) — so the modal's inner/overlay are lifted to 2100 on
     mobile (the zz_new_content.css:5602 dropdown pattern; CSS only, the
     modal component is untouched).

   The emptied Design tab: its TabsTab stays mounted (JS-frozen tab values
   until C-6, control map §C5) and only its trigger is hidden — the
   `sp-config-root-tab--parked` marker, matched at the Simple/Pro gate's
   specificity (2 ids + 3 classes) so it holds in both the desktop and the
   ≤640 bottom-bar band.

   Cascade: sorts after zz_new_content.css / zz_studio_chrome.css /
   zz_studio_output.css / zz_studio_text.css ("zz_studio_l" < "zz_studio_o"
   alphabetically — so the shared grammar this file only USES is never
   overridden here at equal specificity: every override below carries
   :is(#config-card, #editor-tools) and wins on ids, not on order). !important only where the
   older band being overridden is !important (the R3 density rules, the
   amber Switch rule, the inspector-panel Switch row rule, the mobile tab
   band). Nothing in styles.css / zz_new_content.css is edited.
   ========================================================================== */

:is(#new-content-shell, #editor-workspace-root) .sp-studio-card--look {
  --st-input-h: 34px;
  --st-toggle-w: 38px;
  --st-toggle-h: 24px;
  --st-toggle-knob: 18px;
  --st-toggle-inset: 3px;
  --st-swatch-h: 12px;
}

/* ---- Theme preset: the Select in the DS input skin ------------------------
   Selector weight: the R3 inspector rules (zz_new_content.css:4796 turns every
   InputWrapper into a two-column label grid; :4742 sizes every Select input
   30px, !important) are 1 id + classes; these chains carry 2 ids and win. */
:is(#new-content-shell, #editor-workspace-root) :is(#config-card, #editor-tools) .sp-studio-card--look .sp-look-row .mantine-Select-root,
:is(#new-content-shell, #editor-workspace-root) :is(#config-card, #editor-tools) .sp-studio-card--look .sp-look-row .mantine-InputWrapper-root {
  display: block !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
}

:is(#new-content-shell, #editor-workspace-root) :is(#config-card, #editor-tools) .sp-studio-card--look .sp-look-row .mantine-Select-root > .mantine-Input-wrapper,
:is(#new-content-shell, #editor-workspace-root) :is(#config-card, #editor-tools) .sp-studio-card--look .sp-look-row .mantine-Input-wrapper {
  width: 100% !important;
}

:is(#new-content-shell, #editor-workspace-root) :is(#config-card, #editor-tools) .sp-studio-card--look .sp-look-row .mantine-Select-input,
:is(#new-content-shell, #editor-workspace-root) :is(#config-card, #editor-tools) .sp-studio-card--look .sp-look-row .mantine-Input-input {
  box-sizing: border-box;
  min-height: var(--st-input-h) !important;
  height: var(--st-input-h) !important;
  padding: 0 32px 0 10px !important;
  border: 1px solid var(--bc-border) !important;
  border-radius: 10px !important;
  background: var(--bc-raised) !important;
  color: var(--bc-text) !important;
  font-family: var(--st-ui) !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  line-height: 1.2 !important;
  box-shadow: none !important;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

:is(#new-content-shell, #editor-workspace-root) :is(#config-card, #editor-tools) .sp-studio-card--look .sp-look-row .mantine-Select-input::placeholder {
  color: var(--bc-faint) !important;
  opacity: 1;
}

:is(#new-content-shell, #editor-workspace-root) :is(#config-card, #editor-tools) .sp-studio-card--look .sp-look-row .mantine-Select-input:focus,
:is(#new-content-shell, #editor-workspace-root) :is(#config-card, #editor-tools) .sp-studio-card--look .sp-look-row .mantine-Select-input:focus-visible {
  border-color: var(--bc-accent) !important;
  outline: none;
}

:is(#new-content-shell, #editor-workspace-root) :is(#config-card, #editor-tools) .sp-studio-card--look .sp-look-row .mantine-Input-section {
  color: var(--bc-text2);
}

/* the quick-style-status Output: mounted always, visible only with content */
:is(#new-content-shell, #editor-workspace-root) .sp-studio-card--look .sp-look-status {
  min-height: 0;
  margin-top: -1px;
}

:is(#new-content-shell, #editor-workspace-root) .sp-studio-card--look .sp-look-status:empty {
  display: none;
}

:is(#new-content-shell, #editor-workspace-root) :is(#config-card, #editor-tools) .sp-studio-card--look .sp-look-status .mantine-Text-root {
  font-family: var(--st-ui);
  font-size: 11.5px !important;
  line-height: 1.3;
  color: var(--bc-text2) !important;
}

/* ---- Canvas theme: Dark / Light segments, Custom folded ------------------ */
:is(#new-content-shell, #editor-workspace-root) .sp-look-row--canvas-theme {
  --st-seg-cols: 2;
  --st-custom: none;
}

/* a loaded custom look shows its state (and the row grows to three chips) */
:is(#new-content-shell, #editor-workspace-root) .sp-look-row--canvas-theme:has(.sp-look-canvas-theme-segments input[value="custom"]:checked) {
  --st-seg-cols: 3;
  --st-custom: block;
}

:is(#new-content-shell, #editor-workspace-root) .sp-look-canvas-theme-segments .mantine-SegmentedControl-control:has(> input[value="custom"]) {
  display: var(--st-custom);
}

/* v6 order Dark, Light — presentation only; the data list stays light/dark/custom */
:is(#new-content-shell, #editor-workspace-root) .sp-look-canvas-theme-segments .mantine-SegmentedControl-control:has(> input[value="dark"]) {
  order: -1;
}

/* ---- Colors: Single color / Multicolor --------------------------------- */
:is(#new-content-shell, #editor-workspace-root) .sp-look-row--colors {
  --st-seg-cols: 2;
}

/* ---- Palette: swatch buttons (three stripes + name) --------------------- */
:is(#new-content-shell, #editor-workspace-root) .sp-look-row--palette {
  --st-seg-cols: 4;
}

:is(#new-content-shell, #editor-workspace-root) :is(#config-card, #editor-tools) .sp-studio-card--look .sp-look-palette-swatches .mantine-SegmentedControl-label {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  min-height: 0;
  padding: 7px 7px 6px !important;
  font-size: 11.5px !important;
  text-align: center;
}

:is(#new-content-shell, #editor-workspace-root) :is(#config-card, #editor-tools) .sp-studio-card--look .sp-look-palette-swatches .mantine-SegmentedControl-label::before {
  content: "";
  display: block;
  width: 100%;
  height: var(--st-swatch-h);
  border-radius: 4px;
  background: var(--st-swatch);
}

/* stripe colors = CHART_COLOR_PALETTES[name][:3] (figure_builder.py) — one
   rule per value, kept in sync by test_studio_look.py */
:is(#new-content-shell, #editor-workspace-root) .sp-look-palette-swatches .mantine-SegmentedControl-control:has(> input[value="vivid"]) .mantine-SegmentedControl-label { --st-swatch: linear-gradient(90deg, #FF6B6B 0 33.4%, #4ECDC4 33.4% 66.7%, #FFD93D 66.7% 100%); }
:is(#new-content-shell, #editor-workspace-root) .sp-look-palette-swatches .mantine-SegmentedControl-control:has(> input[value="sunset"]) .mantine-SegmentedControl-label { --st-swatch: linear-gradient(90deg, #FF9E3D 0 33.4%, #FF6B6B 33.4% 66.7%, #F94892 66.7% 100%); }
:is(#new-content-shell, #editor-workspace-root) .sp-look-palette-swatches .mantine-SegmentedControl-control:has(> input[value="ocean"]) .mantine-SegmentedControl-label { --st-swatch: linear-gradient(90deg, #00C2D1 0 33.4%, #1FAB89 33.4% 66.7%, #3FC1C9 66.7% 100%); }
:is(#new-content-shell, #editor-workspace-root) .sp-look-palette-swatches .mantine-SegmentedControl-control:has(> input[value="forest"]) .mantine-SegmentedControl-label { --st-swatch: linear-gradient(90deg, #2D6A4F 0 33.4%, #52B788 33.4% 66.7%, #95D5B2 66.7% 100%); }
:is(#new-content-shell, #editor-workspace-root) .sp-look-palette-swatches .mantine-SegmentedControl-control:has(> input[value="neon"]) .mantine-SegmentedControl-label { --st-swatch: linear-gradient(90deg, #39FF14 0 33.4%, #FF073A 33.4% 66.7%, #0FF0FC 66.7% 100%); }
:is(#new-content-shell, #editor-workspace-root) .sp-look-palette-swatches .mantine-SegmentedControl-control:has(> input[value="pastel"]) .mantine-SegmentedControl-label { --st-swatch: linear-gradient(90deg, #FFADAD 0 33.4%, #FFD6A5 33.4% 66.7%, #FDFFB6 66.7% 100%); }

/* "auto" (the legacy hash-derived colors): a neutral swatch */
:is(#new-content-shell, #editor-workspace-root) .sp-look-palette-swatches .mantine-SegmentedControl-control:has(> input[value="auto"]) .mantine-SegmentedControl-label {
  --st-swatch: linear-gradient(90deg, var(--bc-border) 0 33.4%, var(--bc-faint) 33.4% 66.7%, var(--bc-text2) 66.7% 100%);
}

/* ---- Player photos / logos: label left, DS toggle right ------------------ */
:is(#new-content-shell, #editor-workspace-root) .sp-studio-card--look .sp-look-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: var(--st-toggle-h);
}

/* DS toggle (§4) — geometry via Mantine's Switch vars. The
   .sp-inspector-root-panel rule (zz_new_content.css:5105) stretches every
   Switch root to 100% and reverses its body for label-left rows; this toggle
   has no label and sits in its own head row, so it shrinks back to its track. */
:is(#new-content-shell, #editor-workspace-root) .sp-studio-card--look .sp-studio-toggle.mantine-Switch-root {
  --switch-width: var(--st-toggle-w);
  --switch-height: var(--st-toggle-h);
  --switch-thumb-size: var(--st-toggle-knob);
  --switch-track-padding: var(--st-toggle-inset);
  --switch-radius: 999px;
  width: auto !important;
  min-height: 0;
  flex: 0 0 auto;
  margin: 0;
}

:is(#new-content-shell, #editor-workspace-root) .sp-studio-card--look .sp-studio-toggle .mantine-Switch-body {
  width: auto;
  gap: 0;
}

:is(#new-content-shell, #editor-workspace-root) .sp-studio-card--look .sp-studio-toggle .mantine-Switch-track {
  box-sizing: border-box;
  width: var(--st-toggle-w);
  min-width: var(--st-toggle-w);
  height: var(--st-toggle-h);
  border: 0;
  border-radius: 999px;
  background: var(--bc-border);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

:is(#new-content-shell, #editor-workspace-root) .sp-studio-card--look .sp-studio-toggle .mantine-Switch-thumb {
  width: var(--st-toggle-knob);
  height: var(--st-toggle-knob);
  border: 0;
  border-radius: 999px;
  background: var(--bc-text);
  inset-inline-start: var(--st-toggle-inset);
  transition: inset-inline-start 0.2s ease;
}

/* ON: orange track (DS §4 "Toggle" — the switch idiom stays orange, C5); the
   knob stays #F2EFE9 (the older amber rule at zz_new_content.css:4078 paints
   it ink — overridden here at higher specificity). */
:is(#new-content-shell, #editor-workspace-root) .sp-studio-card--look .sp-studio-toggle .mantine-Switch-input:checked + .mantine-Switch-track {
  background: var(--bc-accent) !important;
  border-color: var(--bc-accent) !important;
}

:is(#new-content-shell, #editor-workspace-root) .sp-studio-card--look .sp-studio-toggle .mantine-Switch-input:checked + .mantine-Switch-track .mantine-Switch-thumb {
  background: var(--bc-text) !important;
  border-color: var(--bc-text) !important;
  inset-inline-start: calc(100% - var(--st-toggle-knob) - var(--st-toggle-inset));
}

:is(#new-content-shell, #editor-workspace-root) .sp-studio-card--look .sp-studio-toggle .mantine-Switch-input:focus-visible + .mantine-Switch-track {
  outline: 2px solid var(--bc-accent);
  outline-offset: 2px;
}

/* logos off: the row label dims so the state reads without the toggle */
:is(#new-content-shell, #editor-workspace-root) .sp-studio-card--look .sp-look-row--logos:has(.sp-studio-toggle .mantine-Switch-input:not(:checked)) .sp-studio-row-label {
  color: var(--bc-faint);
}

/* ---- Saved presets row (C-6a, map B7): the SAME preset-modal-trigger ----
   DS §1.5 ghost pill: transparent, hairline border, text; hover border ->
   accent. The older topbar rules (zz_new_content.css:1801, scoped to
   .sp-editor-topbar-actions) no longer match. */
:is(#new-content-shell, #editor-workspace-root) :is(#config-card, #editor-tools) .sp-studio-card--look .sp-look-row--presets .sp-look-preset-trigger.mantine-Button-root {
  flex: 0 0 auto;
  height: var(--st-input-h) !important;
  min-height: var(--st-input-h) !important;
  min-width: 0 !important;
  padding-inline: 14px !important;
  border-radius: 999px !important;
  background: transparent !important;
  border: 1px solid var(--bc-border) !important;
  color: var(--bc-text) !important;
  font-size: 12.5px !important;
  font-weight: 600 !important;
  letter-spacing: 0 !important;
  box-shadow: none !important;
  transition: border-color 0.15s ease, color 0.15s ease;
}

:is(#new-content-shell, #editor-workspace-root) :is(#config-card, #editor-tools) .sp-studio-card--look .sp-look-row--presets .sp-look-preset-trigger.mantine-Button-root:hover {
  border-color: var(--bc-accent) !important;
  color: var(--bc-text) !important;
}

:is(#new-content-shell, #editor-workspace-root) :is(#config-card, #editor-tools) .sp-studio-card--look .sp-look-row--presets .sp-look-preset-trigger.mantine-Button-root:focus-visible {
  outline: 2px solid var(--bc-accent);
  outline-offset: 2px;
}

/* the row hides with its callback-gated trigger (manual / upload / question
   modes: `_toggle_data_mode_sections` writes display:none on it) */
:is(#new-content-shell, #editor-workspace-root) .sp-studio-card--look .sp-look-row--presets:has(:is(#preset-modal-trigger, #editor-preset-modal-trigger)[style*="display: none"]) {
  display: none;
}

/* ---- the emptied Design tab: trigger hidden, tab + panel stay mounted ----
   Same specificity as the Simple/Pro gate (zz_new_content.css:3755 / :5437,
   2 ids + 3 classes, !important) so it holds in the desktop tab strip and in
   the ≤640 bottom bar; later file wins the tie. */
:is(#new-content-shell, #editor-workspace-root) :is(#config-card, #editor-tools) .sp-config-root-tabs .mantine-Tabs-tab.sp-config-root-tab--parked {
  display: none !important;
}

/* ---- mobile ≤640 (the Setup sheet; DS §3.1 touch ladder) ---------------- */
@media (max-width: 640px) {
  :is(#new-content-shell, #editor-workspace-root) .sp-studio-card--look {
    --st-input-h: 42px;
    --st-swatch-h: 14px;
  }

  :is(#new-content-shell, #editor-workspace-root) :is(#config-card, #editor-tools) .sp-studio-card--look .sp-look-row .mantine-Select-input,
  :is(#new-content-shell, #editor-workspace-root) :is(#config-card, #editor-tools) .sp-studio-card--look .sp-look-row .mantine-Input-input {
    padding: 0 34px 0 12px !important;
    font-size: 14px !important;
  }

  :is(#new-content-shell, #editor-workspace-root) :is(#config-card, #editor-tools) .sp-studio-card--look .sp-look-palette-swatches .mantine-SegmentedControl-label {
    gap: 7px;
    padding: 8px 6px 7px !important;
    font-size: 12px !important;
  }

  /* Saved presets (C-6a): the ≤640 topbar hide-list (zz_new_content.css
     ~5507, `:is(#new-content-shell, #editor-workspace-root) .sp-preview-preset-trigger { display:none
     !important }`) still matches the moved trigger by class. Inside the card
     it is a row control: re-shown at 2 ids — but only while the callback
     gate does NOT hide it (an !important show would beat the inline
     display:none the gate writes). New mobile exposure, recorded in the plan. */
  :is(#new-content-shell, #editor-workspace-root) :is(#config-card, #editor-tools) .sp-studio-card--look .sp-preview-preset-trigger:not([style*="display: none"]) {
    display: inline-flex !important;
  }

  /* the preset modal opened from inside the sheet: Mantine's modal z-index
     (200, --mb-z-index on the portal root) sits UNDER the fixed sheet (2000)
     — lift its layers (the :5602 dropdown pattern). CSS only. */
  body:where([data-sp-has~="studio-or-editor"]):not(#sp-s) .sp-preset-modal .mantine-Modal-inner,
  body:where([data-sp-has~="studio-or-editor"]):not(#sp-s) .sp-preset-modal .mantine-Modal-overlay {
    z-index: 2100;
  }
}
