/* ============================================================================
   zz_studio_text.css — the Post studio TEXT settings-group card (plan stage
   C-3; docs/design/new_content_screen.md §6.1 + §6.3; decision C9 in
   docs/design/builder_v6_decisions.md; map rows A1 sec-text-title /
   sec-text-subtitle / layout-section-frame-label-prefix in
   docs/new_content/studio_control_map.md).

   Scope: :is(#new-content-shell, #editor-workspace-root) .sp-studio-card--text. The shared card grammar
   (.sp-studio-card, -head, -eyebrow, -body, .sp-studio-row, .sp-studio-row-label)
   lives in zz_studio_output.css (C-2) and is only USED here, not restated.

   Rows (spec §6.3 "label + visibility toggle + text input"):
   * Title / Subtitle — the shipped Textarea (autosize 2–4 rows; v6 drew a
     one-line input — kept, so multi-line titles stay possible) restyled as
     the DS input (bg #15161C, border #2A2C33, radius 10), plus the DS toggle
     (§4: 38×24 track, 18px knob, 3px inset, track #2A2C33 → #FF6B2C on).
   * Frame label — the shipped TextInput, same DS input skin. Always visible
     (map A1 says "animated output only"; hiding it in Static mode is a
     one-line CSS option the user decides on — see the plan's C-3 note).

   Cascade: sorts after zz_new_content.css / zz_studio_chrome.css /
   zz_studio_output.css ("zz_studio_t" > "zz_studio_o"); !important only where
   the older band being overridden is !important (the R3 density rules, the
   amber Switch rule, the inspector-panel Switch row rule). Nothing in
   styles.css / zz_new_content.css is edited.
   ========================================================================== */

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

/* ---- row head: label left, toggle right --------------------------------- */
:is(#new-content-shell, #editor-workspace-root) .sp-studio-card--text .sp-text-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--text .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;
  flex: 0 0 auto;
  margin: 0;
}

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

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

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

/* ---- DS input skin (§4 "Input": bg #15161C, border #2A2C33, radius 10) ----
   Selector weight: the R3 density rules (zz_new_content.css:4267, 2 ids + 3
   classes, !important) size every inspector input; these chains tie them at
   2 ids + 3 classes and win by file order. */
:is(#new-content-shell, #editor-workspace-root) :is(#config-card, #editor-tools) .sp-studio-card--text .sp-text-row .mantine-Textarea-root,
:is(#new-content-shell, #editor-workspace-root) :is(#config-card, #editor-tools) .sp-studio-card--text .sp-text-row .mantine-TextInput-root,
:is(#new-content-shell, #editor-workspace-root) :is(#config-card, #editor-tools) .sp-studio-card--text .sp-text-row .mantine-InputWrapper-root {
  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--text .sp-text-row .mantine-Input-input,
:is(#new-content-shell, #editor-workspace-root) :is(#config-card, #editor-tools) .sp-studio-card--text .sp-text-row .mantine-Textarea-input {
  box-sizing: border-box;
  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.35 !important;
  box-shadow: none !important;
  transition: border-color 0.15s ease;
}

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

/* title / subtitle: the autosize textarea keeps its 2–4 row behavior; only
   the 82px floor of the R3 band (zz_new_content.css:2448) is relaxed to two
   rows so the card stays compact */
:is(#new-content-shell, #editor-workspace-root) :is(#config-card, #editor-tools) .sp-studio-card--text .sp-text-row .mantine-Textarea-input {
  min-height: 56px !important;
  padding: 8px 10px !important;
  resize: none;
}

/* frame label: the one-line input at the DS height */
:is(#new-content-shell, #editor-workspace-root) :is(#config-card, #editor-tools) .sp-studio-card--text .sp-text-row .mantine-Input-input:not(.mantine-Textarea-input) {
  min-height: var(--st-input-h) !important;
  height: var(--st-input-h) !important;
  padding: 0 10px !important;
}

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

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

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

  /* 82px = the R3 band's floor, kept on mobile on purpose: the Setup sheet is
     closed at load, so Mantine's autosize measures the textarea while hidden
     and keeps the min-rows height until the next edit (pre-existing, JS-side);
     three lines of a 14px subtitle need ~80px to show without clipping. */
  :is(#new-content-shell, #editor-workspace-root) :is(#config-card, #editor-tools) .sp-studio-card--text .sp-text-row .mantine-Textarea-input {
    min-height: 82px !important;
    padding: 10px 12px !important;
  }

  :is(#new-content-shell, #editor-workspace-root) :is(#config-card, #editor-tools) .sp-studio-card--text .sp-text-row .mantine-Input-input:not(.mantine-Textarea-input) {
    padding: 0 12px !important;
  }
}
