/*
 * The studio's own component styles. Every colour, radius and measure comes
 * from tokens.css, which index.html links first — do not redeclare one here.
 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0.75rem 0.75rem 4rem;
  background: var(--page-bg);
  color: var(--text);
  font: 1rem/1.6 var(--font-body);
}

/* Content stays readable when text spacing is overridden (WCAG 1.4.12). */
p,
li,
dd {
  max-width: var(--measure);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  line-height: 1.25;
  margin: 0 0 0.5rem;
  font-family: var(--font-heading);
}

h1 {
  font-size: clamp(1.4rem, 1.1rem + 1.2vw, 2rem);
}

h2 {
  font-size: 1.2rem;
}

/* ---------------------------------------------------------------- focus --- */

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Available to assistive tech, invisible on screen. Not display:none, which
   would remove it from the accessibility tree entirely. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

#save-state {
  margin: 0;
  align-self: center;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--on-accent);
  padding: 0.75rem 1rem;
  z-index: 10;
}

.skip-link:focus {
  left: 0;
}

/* --------------------------------------------------------------- layout --- */

/*
 * The page is a stack of white cards on the brand-teal shell: header card,
 * phase-nav strip, step chips (edit phase only), then a grid of the content
 * card and the per-phase instructions panel.
 */
.site-header,
.phase-nav,
.step-chips,
.layout {
  max-width: var(--shell);
  margin-inline: auto;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  align-items: flex-start;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  background: var(--bg);
  border-radius: var(--radius-card);
}

.site-header__text {
  flex: 1 1 20rem;
}

.site-header__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  justify-content: flex-end;
}

.tagline {
  margin: 0;
  color: var(--text-muted);
}

/* ------------------------------------------------------------ phase nav --- */

.phase-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border-radius: var(--radius-card);
}

.phase-nav__btn {
  flex: 1 1 9rem;
  min-height: 44px;
  padding: 0.5rem 1rem;
  font: inherit;
  font-weight: 600;
  text-align: center;
  color: var(--on-brand);
  background: var(--brand);
  border: 2px solid var(--brand-border);
  border-radius: 9px;
  cursor: pointer;
}

.phase-nav__btn:hover:not(:disabled):not([aria-current="true"]) {
  background: var(--brand-hover);
}

/* The current phase is stated by aria-current; visually it flips to the pale
   tint AND gains an underline, so the state never rests on colour alone. */
.phase-nav__btn[aria-current="true"] {
  background: var(--brand-tint);
  color: var(--brand-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.phase-nav__btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ------------------------------------------------------------ step chips --- */

.step-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.step-chip {
  min-width: 44px;
  min-height: 44px;
  padding: 0.35rem 0.6rem;
  font: inherit;
  font-weight: 700;
  color: var(--text);
  background: var(--bg);
  border: 2px solid var(--brand-border);
  border-radius: 8px;
  cursor: pointer;
}

/* Selected chip: tint plus a heavier border — two cues, not colour alone,
   on top of aria-current for assistive tech. */
.step-chip[aria-current="true"] {
  background: var(--chip-active);
  border-width: 4px;
}

/* Chips sit directly on the teal shell, where the usual blue focus ring is
   invisible (accent-on-brand is ~1:1). White is 7:1 against the shell. */
.step-chips .step-chip:focus-visible {
  outline-color: var(--on-brand);
}

/* --------------------------------------------------- content + instructions --- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
  margin-top: 0.75rem;
  align-items: start;
}

@media (min-width: 68rem) {
  body[data-view="tabbed"] .layout {
    grid-template-columns: minmax(0, 1fr) minmax(16rem, 20rem);
  }
}

main {
  min-width: 0;
  background: var(--bg);
  border-radius: var(--radius-card);
  padding: 0.25rem 1.25rem 1.25rem;
}

.instructions {
  background: var(--bg);
  border-radius: var(--radius-panel);
  padding: 1.5rem 1.5rem 1.75rem;
  position: sticky;
  top: 0.75rem;
}

.instructions h2 {
  font-size: 1.05rem;
}

.instructions p {
  margin: 0;
}

/*
 * Phase visibility is applied by app.js at runtime, never in the markup:
 * without JavaScript (and under jsdom in the tests) the page stays fully
 * linear. `hidden` (content does not exist yet) and `.phase-off` (content
 * exists but belongs to another phase) are independent, and either hides.
 */
.phase-off {
  display: none !important;
}

[hidden] {
  display: none !important;
}

body[data-view="linear"] .step-chips {
  display: none;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-top: 1.5rem;
}

.panel--quiet {
  background: none;
}

.panel--warn {
  background: var(--warn-surface);
  border-color: var(--warn-border);
  color: var(--warn-text);
}

.panel--error {
  background: var(--error-surface);
  border-color: var(--error-border);
  color: var(--error-text);
}

/* --------------------------------------------------------------- inputs --- */

.button {
  min-height: 44px;
  padding: 0.5rem 1rem;
  font: inherit;
  color: var(--on-accent);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
}

.button--quiet {
  color: var(--accent);
  background: none;
}

.button--quiet:hover {
  background: var(--surface);
}

/* The header's Export shortcut — brand teal, like the phase pills.
   Explicit --on-brand: the base .button colour is --on-accent, which flips
   near-black in dark mode and measured 2.65:1 over the teal. */
.button--brand {
  font-weight: 600;
  color: var(--on-brand);
  background: var(--brand);
  border: 2px solid var(--brand-border);
}

.button--brand:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* The Tabbed/Linear pair. Pressed state is carried by aria-pressed and shown
   as the filled pill; the unpressed one stays an outline. */
.button--toggle {
  color: var(--text);
  background: none;
  border-color: var(--border);
}

.button--toggle[aria-pressed="true"] {
  color: var(--on-brand);
  background: var(--brand);
  border-color: var(--brand-border);
}

.button--toggle[aria-pressed="false"]:hover {
  background: var(--surface);
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  background: var(--bg);
}

/* Not colour alone — the border weight and label text change too. */
.dropzone.is-active {
  border-style: solid;
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.field-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

input[type="file"] {
  font: inherit;
  color: var(--text);
  max-width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.hint,
.status {
  color: var(--text-muted);
  margin: 0.75rem 0 0;
}

/*
 * NEVER `display: none` a live region, even when empty.
 *
 * display:none removes it from the accessibility tree, and a live region that
 * re-enters the tree at the same moment it gains content is not announced —
 * so the first message after every empty state would be silent. Collapse the
 * margin instead: no visual gap, but the region stays present and announcing.
 */
.status:empty,
#save-state:empty {
  margin-block: 0;
}

/* ----------------------------------------------------------------- data --- */

.meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 1rem;
  margin: 0;
}

.meta dt {
  font-weight: 600;
  color: var(--text-muted);
}

.meta dd {
  margin: 0;
}

.steps {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: grid;
  gap: 1.5rem;
}

/*
 * Tabbed layout shows one step at a time; the numbered chips choose which.
 * The other steps stay in the DOM — focus restore and the export gate depend
 * on every control existing — they are only not displayed.
 */
.steps--single > .step:not(.step--active) {
  display: none;
}

.step {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
}

/* Two columns only when there is genuinely room; stacks well below 320px. */
@media (min-width: 46rem) {
  .step {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    align-items: start;
  }

  .step__body {
    order: 2;
  }

  .step__figure {
    order: 1;
  }
}

.step__label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.step__text {
  margin: 0;
  font-size: 1.05rem;
}

.step__figure {
  margin: 0;
}

/* Each image and its "Replace image" control, stacked. */
.step__image {
  margin-bottom: 0.75rem;
}

.step__image:last-child {
  margin-bottom: 0;
}

.step__replace {
  margin-top: 0.35rem;
}

/* The file input is visually hidden but focusable; surface its focus on the
   label styled as a button, so keyboard focus is never invisible. */
.step__replace:focus-within .button {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.step img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  background: var(--bg);
}

.step__missing {
  font-style: italic;
  color: var(--text-muted);
}

/* ---------------------------------------------------------------- editor --- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1rem 0;
}

/*
 * The prose measure does not apply to a form.
 *
 * `p, li, dd { max-width: var(--measure) }` keeps reading lines short, and a
 * step is an <li>, so every step in the editor was capped at 68ch — 585px
 * inside an 869px column at 1280. That squeezed the two halves into roughly
 * half the space available and made the fields far narrower than the screenshot
 * beside them. The cap is right for prose and wrong here: these are labelled
 * controls, not text to read across.
 */
.steps > .step {
  max-width: none;
}

.step--editing {
  display: block;
  padding: 0;
}

.step__fields {
  border: none;
  margin: 0;
  padding: 1rem;
  display: grid;
  gap: 0.85rem;
}

/* The step editor's two halves: fields to fix on the left, the screenshot
   with its check/replace/delete controls on the right (mock-up slide 7).
   Below the breakpoint they simply stack, main first. */
.step__main,
.step__side {
  display: grid;
  gap: 0.85rem;
  align-content: start;
  min-width: 0;
}

.step__side .button {
  justify-self: start;
}

@media (min-width: 62rem) {
  /* Equal halves. The fields side carries step text, alt text and the
     explanations in both languages now, so the old 3:2 split in favour of the
     fields no longer reflects what is in each column — and the screenshot reads
     better with the extra room than it did cropped into two fifths. */
  .step--editing .step__fields {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
  }

  .step__duplicate {
    grid-column: 1 / -1;
  }
}

.step__fields legend {
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0 0.35rem;
}

.step__duplicate {
  margin: 0;
  padding: 0.6rem 0.75rem;
  background: var(--warn-surface);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
  border-radius: var(--radius);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.field {
  display: grid;
  gap: 0.3rem;
}

.field textarea,
.field input[type="text"] {
  font: inherit;
  width: 100%;
  min-height: 44px;
  padding: 0.5rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: vertical;
}

.field .hint {
  margin: 0;
  font-size: 0.875rem;
}

/* Radios share the checkbox's box, target size and accent — same control
   ergonomics, different semantics. */
.checkbox,
.choice {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
}

.checkbox input,
.choice input {
  width: 20px;
  height: 20px;
  flex: none;
}

/*
 * Everything the browser paints with accent-color, in one place.
 *
 * This used to be set on checkboxes and radios only, so a branded studio came
 * out magenta with two stubbornly blue range sliders. Found by looking at a
 * screenshot — no assertion would have noticed, because the sliders were
 * styled exactly as the stylesheet said.
 */
input[type="range"],
input[type="checkbox"],
input[type="radio"],
progress {
  accent-color: var(--accent);
}

.checkbox label,
.choice label {
  margin: 0;
}

/*
 * The Export page, per the 2026-08-01 mock-up: one row per output, with the
 * write-up left, the include control centre, and the downloads right.
 *
 * Three columns rather than a card grid, because the rows are a comparison —
 * an author is reading down the descriptions to decide what to hand over, and
 * cards would put each write-up in its own box to be read separately.
 */
.export-rows {
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.export-row {
  display: grid;
  gap: 0.5rem 1.5rem;
  align-items: start;
  padding: 1rem 0;
}

.export-row + .export-row {
  border-top: 1px solid var(--border-subtle);
}

/* The dashboard leads and is what the rows beneath it are made of, so it is
   set off rather than left to look like a fifth sibling. */
.export-row--bundle {
  padding-bottom: 1.25rem;
  border-bottom: 2px solid var(--border-subtle);
}

.export-row--bundle + .export-row {
  border-top: 0;
}

/*
 * Columns that line up DOWN the page, not just across each row.
 *
 * A grid per row resolves its own tracks from its own content, so every row
 * put its checkbox and its button somewhere slightly different — which defeats
 * the point of a comparison table. The tracks are defined once on the list and
 * each row borrows them with `subgrid`.
 *
 * Progressive, like the container query in the walkthrough: without subgrid
 * support each row falls back to its own three tracks, which is still readable,
 * just not aligned.
 */
@media (min-width: 52rem) {
  .export-rows {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(11rem, max-content) max-content;
  }

  .export-row {
    grid-column: 1 / -1;
    grid-template-columns: subgrid;
  }
}

.export-row__text > * {
  margin: 0 0 0.25rem;
  max-width: none;
}

.export-row__text h3 {
  font-size: 1rem;
}

/* Buttons stack and fill their column so the two Word downloads line up under
   each other rather than wrapping raggedly. */
.export-row__actions {
  display: grid;
  gap: 0.5rem;
  justify-items: stretch;
}

.export-row__include .hint {
  margin: 0.35rem 0 0;
  font-size: 0.875rem;
}

/* The source-language group. A bare fieldset carries a default border and
   padding that would read as a second card inside the Capture panel. */
.fieldset--plain {
  min-width: 0;
  margin: 1.25rem 0 0;
  padding: 0;
  border: 0;
}

.narrative-group {
  display: grid;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
}

/* Drafted text is called out in words, not by colour alone. */
.narrative-drafted {
  margin: 0;
  padding: 0.35rem 0.6rem;
  background: var(--warn-surface);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
}

.narrative-group textarea {
  font: inherit;
  width: 100%;
  min-height: 44px;
  padding: 0.5rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: vertical;
}

.alt-group {
  display: grid;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
}

.step--editing .step__figure img {
  max-width: min(100%, 30rem);
}

.readiness {
  margin: 0 0 0.5rem;
  font-weight: 600;
}

.readiness__list {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--text-muted);
}

.readiness__list li + li {
  margin-top: 0.25rem;
}

#warnings-list {
  margin: 0;
  padding-left: 1.25rem;
}

#warnings-list li + li {
  margin-top: 0.35rem;
}

/* ------------------------------------------------------------- motion ----- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
