/* Components on top of tokens.css: help/FAQ, cast gallery. */
.lead { font-size: 1.05rem; max-width: 60ch; color: var(--ink-2); }
.hud-label { font: 600 .75rem/1.2 var(--font-mono); text-transform: uppercase; letter-spacing: .14em; color: var(--muted); }

.help-head { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.help-toc ol { columns: 2 18rem; padding-left: 1.4rem; margin: .5rem 0 1.5rem; }
.help-toc li { margin: 0 0 .3rem; break-inside: avoid; }
.faq { display: grid; gap: .75rem; }
.faq-item { border: 1px solid var(--rule-soft); background: var(--bg-raised); scroll-margin-top: 1rem; }
.faq-item summary { cursor: pointer; padding: .75rem 1rem; list-style-position: inside; }
.faq-item summary h2 { display: inline; font-size: 1.05rem; margin: 0; }
.faq-item summary:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }
.faq-item[open] summary { border-bottom: 1px solid var(--rule-soft); }
.faq-item:target { border-color: var(--signal); }
.faq-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(12rem, 18rem); gap: 1.5rem; padding: .75rem 1rem 1rem; align-items: start; }
.faq-text p:first-child { margin-top: 0; max-width: 65ch; }
.faq-figure { margin: 0; }
.faq-figure figcaption { margin-top: .25rem; }
@media (max-width: 760px) {
  .help-head, .faq-body { grid-template-columns: 1fr; }
}

.cast-theme { background: var(--bg); color: var(--ink); padding: 1rem; margin: 0 0 1rem; border: 1px solid var(--rule-soft); }
.cast-grid, .scene-grid { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; }
.cast-grid { grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); }
.scene-grid { grid-template-columns: repeat(auto-fill, minmax(22rem, 1fr)); }
.cast-card { display: flex; flex-direction: column; justify-content: flex-end; }
.cast-card .il { max-height: 15rem; }
.cast-card p { margin: .25rem 0 0; font-size: .9rem; }

/* -- HUD components ---------------------------------------------------------------- */

/* chamfered card: 1px rule, one corner cut */
.card-hud {
  position: relative; border: 1px solid var(--rule-soft); background: var(--bg-raised);
  padding: 1rem 1.1rem;
  clip-path: polygon(0 0, calc(100% - var(--chamfer)) 0, 100% var(--chamfer), 100% 100%, 0 100%);
}
.card-hud::after, .panel::after { /* the cut edge, drawn */
  content: ""; position: absolute; top: 0; left: calc(100% - var(--chamfer)); width: calc(var(--chamfer) * 1.42);
  height: 1px; background: var(--rule); transform-origin: top left; transform: rotate(45deg);
}

/* state badge: ok / partial / down differ in lightness and in shape of the mark */
.state {
  display: inline-flex; align-items: center; gap: .4rem; padding: 0 .5rem;
  font: 600 .72rem/1.7 var(--font-mono); text-transform: uppercase; letter-spacing: .1em;
  border: 1px solid var(--rule); color: var(--ink);
}
.state::before { content: ""; width: .55rem; height: .55rem; background: var(--down); }
.state.ok { border-color: var(--ok); background: var(--ok-soft); }
.state.ok::before { background: var(--ok); border-radius: 50%; }
.state.partial { border-color: var(--partial); background: var(--partial-soft); }
.state.partial::before { background: var(--partial); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.state.down { color: var(--muted); }

/* receipt chip: hash prefix, kind, model; links to its receipt */
.chip {
  display: inline-flex; align-items: stretch; border: 1px solid var(--rule); text-decoration: none;
  font: .75rem/1.7 var(--font-mono); font-variant-numeric: tabular-nums slashed-zero; color: var(--ink);
  background: var(--bg-raised); white-space: nowrap;
}
.chip > span { padding: 0 .45rem; }
.chip > span + span { border-left: 1px solid var(--rule-soft); }
.chip .chip-hash { color: var(--link); font-weight: 600; }
.chip .chip-hash::before { content: "#"; color: var(--muted); }
.chip .chip-model { color: var(--muted); }
a.chip:hover { border-color: var(--signal); }

/* crosshair marker: a target on a number or a node */
.crosshair { position: relative; padding-left: 1.1rem; }
.crosshair::before {
  content: ""; position: absolute; left: 0; top: 50%; width: .8rem; height: .8rem; translate: 0 -50%;
  background:
    linear-gradient(var(--signal), var(--signal)) center / 100% 1.5px no-repeat,
    linear-gradient(var(--signal), var(--signal)) center / 1.5px 100% no-repeat;
  border-radius: 50%; outline: 1.5px solid var(--signal); outline-offset: -3px;
}

/* empty state: a small decorative drawing beside the sentence that says what to do */
.empty-state { display: grid; grid-template-columns: minmax(8rem, 14rem) minmax(0, 1fr); gap: 1.25rem; align-items: center; padding: .5rem 0; }
.empty-state .il { max-height: 10rem; }
@media (max-width: 600px) { .empty-state { grid-template-columns: 1fr; } .empty-state .il { max-width: 12rem; } }

/* index hero */
.hero { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; margin-bottom: 1rem; }
.hero p { max-width: 58ch; }
@media (max-width: 760px) { .hero { grid-template-columns: 1fr; } }

/* -- motion (all of it under prefers-reduced-motion: no-preference) ------------------ */

/* cross-document View Transitions between pages; the header stays put */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: var(--dur); animation-timing-function: var(--ease); }
  .top { view-transition-name: hud-top; }
  ::view-transition-group(*) { animation-duration: var(--dur); }
}
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after { transition-duration: 0s !important; animation: none !important; }
}

/* run HUD: producer → copywriter → art director → reviewers → your signature */
.run-hud-wrap { margin: 0 0 1rem; }
.run-hud { list-style: none; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .5rem; padding: 0; margin: .4rem 0 0; counter-reset: step; }
.run-hud li {
  counter-increment: step; display: flex; align-items: center; gap: .5rem; padding: .45rem .6rem;
  border: 1px solid var(--rule-soft); background: var(--bg-raised); color: var(--muted);
  font: 600 .74rem/1.3 var(--font-mono); text-transform: uppercase; letter-spacing: .08em;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.run-hud li::before { content: counter(step, decimal-leading-zero); color: var(--muted); }
.run-hud .tick { width: .6rem; height: .6rem; flex: none; border: 2px solid var(--rule); transform: rotate(45deg); background: var(--bg); }
.run-hud li[data-state="active"] { color: var(--ink); border-color: var(--signal); box-shadow: inset 0 -2px 0 var(--signal); }
.run-hud li[data-state="active"] .tick { border-color: var(--signal); background: var(--signal); }
.run-hud li[data-state="done"] { color: var(--ink); }
.run-hud li[data-state="done"] .tick { border-color: var(--signal); background: var(--signal); }
.run-hud li[data-step="approval"][data-state="done"] { border-color: var(--ok); background: var(--ok-soft); }
.run-hud li[data-step="approval"][data-state="done"] .tick { border-color: var(--ok); background: var(--ok); }
@media (prefers-reduced-motion: no-preference) {
  .run-hud li[data-state="active"] .tick { animation: hud-pulse 1.2s var(--ease) infinite alternate; }
}
@keyframes hud-pulse { from { box-shadow: 0 0 0 0 var(--signal-soft); } to { box-shadow: 0 0 0 5px var(--signal-soft); } }
@media (max-width: 700px) { .run-hud { grid-template-columns: 1fr; } }

/* receipt tape: a link line from each receipt to the previous hash */
#ticker tr.linked td:first-child { position: relative; padding-left: 1rem; }
#ticker tr.linked td:first-child::before {
  content: ""; position: absolute; left: .35rem; top: -50%; height: 100%; width: 2px;
  background: var(--signal); transform-origin: top;
}
#ticker td:first-child { padding-left: 1rem; }

/* approval: the signature hash stamped onto the payload */
.stamp-host { position: relative; }
.stamp {
  position: absolute; right: .5rem; top: -.25rem; margin: 0; padding: .25rem .6rem;
  border: 2px solid var(--ok); background: var(--ok-soft); color: var(--ink);
  font: 700 .85rem/1.3 var(--font-mono); transform: rotate(-6deg); pointer-events: none;
}
.stamp .hud-label { color: var(--ok); }

/* counters: cost and tokens roll through @property integers */
@property --whole { syntax: "<integer>"; inherits: false; initial-value: 0; }
@property --frac { syntax: "<integer>"; inherits: false; initial-value: 0; }
@property --n { syntax: "<integer>"; inherits: false; initial-value: 0; }
@counter-style pad5 { system: extends decimal; pad: 5 "0"; }
.counter { display: none; font-family: var(--font-mono); font-variant-numeric: tabular-nums slashed-zero; color: var(--ink); }
.motion-ready .counter { display: inline; }
.motion-ready .counter-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* the counters live on the element (the properties do not inherit into ::after) */
.counter.cost { counter-reset: w var(--whole) f var(--frac); }
.counter.cost::after { content: "$" counter(w) "." counter(f, pad5); }
.counter.tokens { counter-reset: n var(--n); }
.counter.tokens::after { content: counter(n) " " attr(data-unit); }
@media (prefers-reduced-motion: no-preference) {
  .counter { transition: --whole 700ms var(--ease), --frac 700ms var(--ease), --n 700ms var(--ease); }
}

/* creatives waiting for their pixels */
.carousel figure.arriving { opacity: 0; }

/* login */
.login { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 26rem); gap: 2rem; align-items: center; max-width: 60rem; margin: 2rem 0; }
.login-art { max-width: 22rem; }
.logout-form { display: inline; margin: 0; }
.logout-form button { padding: .2rem .6rem; font-size: .7rem; }
@media (max-width: 760px) { .login { grid-template-columns: 1fr; } .login-art { max-width: 14rem; } }

/* header groups: navigation, viewer preferences */
.nav { display: flex; flex-wrap: wrap; gap: .25rem 1.1rem; align-items: baseline; }
.prefs { margin-left: auto; display: flex; flex-wrap: wrap; gap: .4rem .9rem; align-items: center; }
.lang-switch { display: inline-flex; gap: .15rem; }
.lang-switch a { padding: .1rem .35rem; }
.lang-switch a[aria-current="true"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--signal); }

/* display preferences */
.theme-form { display: inline-flex; flex-wrap: wrap; gap: .3rem .5rem; align-items: center; margin: 0; }
.theme-form label { font: 600 .7rem/1.2 var(--font-mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.theme-form select { padding: .15rem .3rem; font-size: .8rem; }
.theme-form .theme-apply { padding: .2rem .6rem; font-size: .7rem; }
.theme-form.auto .theme-apply { display: none; }
