/* ─────────────────────────────
   PROJECT STYLES
   ─────────────────────────────

   Project-specific styles. Prefer the design system;
   add here only what it can't express.

   Sections:
     1. Token extensions   — tokens the framework doesn't ship
     2. Dark mode toggle   — icon swap re-homed from the framework
     3. Global helpers     — spacing/state utilities used by pages
     4. Idea Studio        — tool layout, scoped under .idea-studio
   ───────────────────────────── */


/* ------ 1. TOKEN EXTENSIONS ------ */

:root {
  /* WCAG 2.5.5 minimum touch target */
  --tap-target-min: 44px;
}


/* ------ 2. DARK MODE TOGGLE (icon swap) ------ */

/* Icons injected by assets/js/theme-toggle.js; the framework no
   longer ships these rules, so they live here alongside the script. */
.dark-mode-toggle .dark-mode-icon-dark {
  display: none;
}

[data-theme="dark"] .dark-mode-toggle .dark-mode-icon-light {
  display: none;
}

[data-theme="dark"] .dark-mode-toggle .dark-mode-icon-dark {
  display: flex;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .dark-mode-toggle .dark-mode-icon-light {
    display: none;
  }

  :root:not([data-theme]) .dark-mode-toggle .dark-mode-icon-dark {
    display: flex;
  }
}


/* ------ 3. GLOBAL HELPERS ------ */

/* -- Spacing helpers (token-only, replace JS inline styles) -- */
.mb-s { margin-bottom: var(--space-s); }
.mt-s { margin-top: var(--space-s); }
.mt-m { margin-top: var(--space-m); }
.mt-l { margin-top: var(--space-l); }
.mt-xl { margin-top: var(--space-xl); }

/* -- Clipboard helper: transient off-viewport textarea used by the
      execCommand copy fallback in idea-studio.js -- */
.clipboard-helper { position: fixed; top: -100vh; left: 0; opacity: 0; }

/* -- State helpers -- */
.is-ok { color: var(--status-success) !important; border-color: var(--status-success) !important; }
.is-error { color: var(--status-danger) !important; border-color: var(--status-danger) !important; }
/* Contrast-checked (WCAG AA) against text-primary in both themes */
.is-dim { opacity: .8; }

/* -- Visible keyboard focus for .button (the framework's
      focus-visible rules target a/[role=button]/inputs; it falls
      through that selector list) -- */
.button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--input-focus), var(--alpha-75));
}


/* ------ 4. IDEA STUDIO (docs/idea-studio.md → docs/site/idea-studio.html) ------ */

/* Tool layout only, scoped under the .idea-studio wrapper on the docs
   page. Everything visual comes from the design system; this block
   just arranges the wizard, the brief, and the sticky step-status
   rail. The docs chrome stacks TWO sticky bars at every width - the
   top nav (--top-nav-height) with the breadcrumb sticky-bar
   (--sticky-bar-height) tucked under it (both owned by docs-kit
   docs.css) - so every sticky offset and scroll target below must
   clear the sum of both. The 0px fallbacks keep the maths safe if
   the tool ever renders outside that chrome. */

.idea-studio { display: grid; grid-template-areas: "main rail"; grid-template-columns: 1fr 280px; gap: var(--space-2xl); align-items: start; }
.idea-studio .studio-main { grid-area: main; min-width: 0; }

/* docs-kit's .docs-main ships overflow: hidden (a grid-blowout guard),
   which quietly becomes the rail's sticky scrollport - and since
   .docs-main itself never scrolls, position: sticky never engages and
   the rail just scrolls away. On the studio page only, swap the guard
   for min-width: 0: same 1fr-track containment, no overflow context.
   (:has - fine here, this tool only targets evergreen browsers.) */
.docs-main:has(.idea-studio) { overflow: visible; min-width: 0; }

/* -- Rail: the sticky step-status column (rendered by renderRail() in
      assets/js/idea-studio.js) -- */
.idea-studio .studio-rail {
  grid-area: rail; position: sticky; top: calc(var(--top-nav-height, 0px) + var(--sticky-bar-height, 0px) + var(--space-l));
  /* A top-stuck sticky taller than the viewport never reveals its
     bottom — cap it and scroll inside, or Start over is unreachable
     on short windows */
  max-height: calc(100vh - var(--top-nav-height, 0px) - var(--sticky-bar-height, 0px) - 2 * var(--space-l));
  overflow: auto;
}
.idea-studio .rail { display: flex; flex-direction: column; gap: var(--space-xs); }
.idea-studio .rail-phase { font-size: var(--label-size); letter-spacing: var(--letter-spacing-m); text-transform: uppercase; color: var(--text-faded); margin: var(--space-l) 0 var(--space-xs); }
.idea-studio .rail-phase:first-child { margin-top: 0; }
/* Rows sized to read like the docs sidebar (nav-link scale, one size
   down so all 13 rows fit the sticky viewport cap) */
.idea-studio .rail-step { display: flex; gap: var(--space-m); align-items: center; font-size: var(--font-s); color: var(--text-secondary); padding: var(--space-s) var(--space-m); border-radius: var(--radius-s); line-height: var(--line-height-l); }
.idea-studio .rail-step .n { font-family: var(--font-quaternary); font-size: var(--font-xs); color: var(--text-faded); width: 1.2em; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; }
/* Completed steps carry the chrome check icon (injected by renderRail) */
.idea-studio .rail-step .n svg { width: 100%; height: auto; }
.idea-studio .rail-step.is-done { color: var(--text-primary); }
.idea-studio .rail-step.is-done .n { color: var(--text-primary); }
.idea-studio .rail-step.is-current { background: var(--text-primary); color: var(--text-inverted); }
.idea-studio .rail-step.is-current .n { color: var(--text-inverted); }
.idea-studio .rail-step.is-handoff { color: var(--text-faded); font-style: italic; }
/* Start over is destructive; give it air below the rail so it doesn't
   read as just another rail row. Colour (data-color="danger") is
   applied only once armed — see the two-stage confirm in
   assets/js/idea-studio.js. */
.idea-studio #reset { margin-top: var(--space-l); }

/* -- The idea box -- */
.idea-studio #shape-idea { margin-bottom: var(--space-xl); }
.idea-studio #shape-idea textarea { min-height: 90px; }

/* -- "Something else" custom-problem box (revealed on the problem step when
      the "Something else" tile is selected) -- */
.idea-studio .custom-problem-label { display: block; font-size: var(--label-size); letter-spacing: var(--letter-spacing-m); text-transform: uppercase; color: var(--text-faded); margin: var(--space-m) 0 var(--space-xs); }
.idea-studio .custom-problem-input { width: 100%; max-width: var(--line-length-medium); }

/* -- Steps -- */
.idea-studio .step { border: var(--border-s) solid var(--border-faded); background: var(--background-primary); padding: var(--space-xl) var(--space-2xl); margin-bottom: var(--space-l); border-radius: var(--radius-m); }
/* FLAG (DESIGN.md): --black-alpha-5 is a primitive — the semantic layer
   ships no shadow/elevation token yet (the framework's own .card hover
   shadow has the same gap). Swap to the semantic token when one lands. */
.idea-studio .step.is-current { border-color: var(--border-secondary); box-shadow: 0 2px 10px var(--black-alpha-5); }
.idea-studio .step-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-m); }
.idea-studio .step-eyebrow { font-size: var(--label-size); letter-spacing: var(--letter-spacing-m); text-transform: uppercase; color: var(--text-faded); }
/* Real <h2>: explicit line-height keeps it identical to the old
   plain-div rendering (the h1–h6 base rule would tighten it). */
.idea-studio .step-q { margin: var(--space-xs) 0 var(--space-l); font-size: var(--font-l); font-weight: 600; letter-spacing: -0.01em; line-height: var(--line-height-xl); }
.idea-studio .step-picked { font-size: var(--font-s); color: var(--text-primary); }
.idea-studio .step-picked .sub { color: var(--text-faded); font-size: var(--font-xs); }
/* Back/Next: real buttons, default size clears the 44px floor at every width */
.idea-studio .step-nav { display: flex; gap: var(--space-s); margin-top: var(--space-l); }

/* Next/Back scroll the revealed step to the top; both docs bars are
   sticky at every width, so the scroll target must clear their sum at
   every width or the step eyebrow lands hidden under the breadcrumb
   sticky-bar. */
.idea-studio .step.is-current, .idea-studio #brief-ready, .idea-studio #your-brief, .idea-studio #shape-idea { scroll-margin-top: calc(var(--top-nav-height, 0px) + var(--sticky-bar-height, 0px) + var(--space-l)); }

/* Option buttons: DS .button, laid out as rich left-aligned tiles, full width + stacked, capped for readability on desktop */
.idea-studio .step .button-group { gap: var(--space-s); flex-direction: column; max-width: var(--line-length-medium); }
.idea-studio .opt { flex-direction: column; align-items: flex-start; justify-content: flex-start; text-align: left; gap: var(--space-xs); padding: var(--space-l) var(--space-xl); height: auto; line-height: var(--line-height-l); white-space: normal; }
.idea-studio .opt .opt-title { font-weight: 600; display: flex; align-items: center; gap: var(--space-s); flex-wrap: wrap; }
.idea-studio .opt .opt-sub { font-size: var(--font-xs); opacity: .8; font-weight: 400; line-height: var(--line-height-l); }

.idea-studio .subgroup-label { font-size: var(--label-size); letter-spacing: var(--letter-spacing-m); text-transform: uppercase; color: var(--text-faded); margin: var(--space-m) 0 var(--space-xs); }
/* Plain-language one-liner under a step question, before the options */
.idea-studio .step-hint { margin: 0 0 var(--space-s); }
.idea-studio .beats { margin: var(--space-s) 0 0; padding-left: var(--space-l); }
.idea-studio .beats li { margin: 0 0 var(--space-2xs); }
.idea-studio .beats b { font-weight: 600; }

/* -- Brief -- */
.idea-studio #brief:empty { display: none; }
.idea-studio .brief { border: var(--border-m) solid var(--border-primary); background: var(--background-primary); border-radius: var(--radius-l); padding: var(--space-2xl); margin-top: var(--space-xl); }
.idea-studio .brief h2 { margin: 0 0 var(--space-l); font-size: var(--font-2xl); }
.idea-studio .brief .dl { display: grid; grid-template-columns: auto 1fr; gap: var(--space-2xs) var(--space-l); margin: 0 0 var(--space-l); }
.idea-studio .brief .dl dt { color: var(--text-faded); font-size: var(--font-xs); }
.idea-studio .brief .dl dd { margin: 0; font-weight: 500; }
.idea-studio .handoff pre { white-space: pre-wrap; margin: 0 0 var(--space-s); }
.idea-studio .handoff .copy-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-m); margin-top: var(--space-l); }
.idea-studio .handoff .copy-row h4 { margin: 0; font-size: var(--font-s); }
.idea-studio .brief details { margin-bottom: var(--space-s); border: var(--border-s) solid var(--border-faded); border-radius: var(--radius-s); }
.idea-studio .brief details .disclosure-content { padding-top: 0; }
.idea-studio .brief .src a { font-size: var(--font-xs); }

.idea-studio .copy-note { margin: var(--space-2xs) 0 var(--space-xs); }
.idea-studio .handoff .copy-note:last-child { margin-bottom: 0; }
/* Brief empty state, shown before every step is answered so #brief is
   never a silent blank box */
.idea-studio .brief-placeholder { color: var(--text-faded); }

/* Focus is moved deliberately by script after every pick/back/next/
   change/skip/reset (see focusCurrentStep()) — give the landing spots
   their own visible ring, and a selected-state signal for the
   hook-skip path. */
.idea-studio .step.is-current:focus-visible,
.idea-studio #brief-ready:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--input-focus), var(--alpha-75));
}

@media (max-width: 959px) {
  /* Single column, and drop the step rail entirely. On desktop the rail
     is a sticky orientation column; stacked above the wizard on small
     screens it reflowed into a ragged wrapping strip of variable-width
     pills and pushed the tool down the page. Each step's "Step X of 12"
     eyebrow already carries the "where am I", so the rail is redundant
     here. display: contents still dissolves the aside so its children
     split - the hidden rail leaves no gap, and Start over drops below
     the wizard: a destructive action must not be the first button on
     the page. */
  .idea-studio { grid-template-areas: "main" "reset"; grid-template-columns: 1fr; }
  .idea-studio .studio-rail { display: contents; }
  .idea-studio .rail { display: none; }
  .idea-studio #reset { grid-area: reset; margin-top: 0; }
  .idea-studio .step .button-group { max-width: none; }
  /* Card and tile padding step down one size on small screens */
  .idea-studio .step { padding: var(--space-l); }
  .idea-studio .opt { padding: var(--space-m) var(--space-l); }

  /* -- Touch targets: bring the remaining sub-44px control up to the
     WCAG 2.5.5 floor. .button already gets this from the framework;
     the brief's <details> summary is the one control that rule
     doesn't reach. -- */
  .idea-studio summary { min-height: var(--tap-target-min); box-sizing: border-box; }
}
