/* Shares tokens, HUD bezel, terminal panel and loop strip with martin-gomola/your-turn-loop site/style.css.
   Keep the two in step. The bezel and label voice come from the Deck (src/yourturn/static/app.css). */
:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--page);
  --page: #f4f6f4;
  --surface: #ffffff;
  --fill: #eceff0;
  --ink: #0f1712;
  --muted: #56605a;
  --line: #d8ded9;
  --line-strong: #aab5ad;
  --control-line: #818b98;
  --accent: #15803d;
  --accent-tint: rgba(22, 163, 74, .07);
  --glow: rgba(22, 163, 74, .3);
  --action-fill: #15803d;
  --action-hover: #166534;
  --on-action: #ffffff;
  --grid-dot: rgba(15, 23, 18, .13);
  /* The install panel is a terminal in both themes. */
  --term-bg: #0c110e;
  --term-bar: #121915;
  --term-surface: #141c17;
  --term-line: #26332c;
  --term-ink: #dbe5de;
  --term-muted: #7b8a81;
  --term-green: #4ade80;
  --term-cyan: #67e8f9;
  --term-amber: #fcd34d;
  --term-violet: #c4b5fd;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
  /* The Deck's HUD frame: top-right and bottom-left corners chamfered. A clip-path also cuts a CSS
     border, so the 1px line is an even-odd ring drawn on ::before. */
  --hud-shape: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
  --hud-ring: polygon(evenodd,
    0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px), 0 0,
    1px 1px, calc(100% - 8.41px) 1px, calc(100% - 1px) 8.41px, calc(100% - 1px) calc(100% - 1px),
    8.41px calc(100% - 1px), 1px calc(100% - 8.41px), 1px 1px);
  --hud-cut: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 6px 100%, 0 calc(100% - 6px));
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0a0d0c; --surface: #111614; --fill: #172019;
  --ink: #e3eae5; --muted: #919d96; --line: #222b27; --line-strong: #3b4a43; --control-line: #858585;
  --accent: #22c55e; --accent-tint: rgba(34, 197, 94, .08); --glow: rgba(34, 197, 94, .5);
  --action-fill: #22c55e; --action-hover: #4ade80; --on-action: #03140a;
  --grid-dot: rgba(170, 220, 195, .1);
  --term-bg: #070a09; --term-bar: #0d1310; --term-surface: #0f1512; --term-line: #20302a;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); }
header, main { max-width: 1100px; margin: auto; padding-inline: 24px; }
header { display: flex; align-items: center; gap: 16px; padding-block: 16px; border-bottom: 1px solid var(--line); }
header a { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 700; text-decoration: none; }
header .repo { margin-left: auto; font-weight: 400; color: var(--muted); }
header .repo:hover { color: var(--ink); }
.github-mark { width: 18px; height: 18px; flex: none; fill: currentColor; }
.brand-icon { width: 32px; height: 32px; flex: none; }
.brand-icon__tile { fill: var(--page); stroke: var(--line); stroke-width: 2; }
.brand-icon__queue { fill: var(--accent); opacity: .48; }
.brand-icon__route { fill: none; stroke: var(--accent); stroke-width: 4.5; stroke-linecap: round; stroke-linejoin: round; }
.brand-icon__active { fill: var(--accent); }
:root[data-theme="dark"] .brand-icon__queue { fill: var(--ink); opacity: .55; }
:root[data-theme="dark"] .brand-icon__route { stroke: var(--ink); }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
/* Inline links nudge their arrow in the direction it points. */
a span[aria-hidden] { display: inline-block; transition: transform .18s var(--ease); }
a:hover span[aria-hidden] { transform: translateX(3px); }
code { font: .92em var(--mono); }
main { padding-block: 40px 24px; }
h1 { margin: 0 0 16px; font-size: clamp(30px, 4.4vw, 44px); line-height: 1.05; letter-spacing: -.02em; }
.lead { max-width: 64ch; margin: 0 0 16px; color: var(--muted); font-size: 17px; line-height: 1.55; }
.lead strong { color: var(--ink); }
.trust { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 24px; padding: 0; list-style: none; }
.trust li { display: inline-flex; align-items: center; gap: 8px; padding: 4px 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: 600 11px/1.5 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.trust li::before { content: ""; width: 6px; height: 6px; background: var(--accent); box-shadow: 0 0 6px var(--glow); }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; gap: 24px; }

/* Panels wear the Deck bezel instead of rounded boxes. */
.panel { --hud-frame: var(--line); position: relative; min-width: 0; margin: 0; padding: 24px; border: 0; background: var(--surface); clip-path: var(--hud-shape); }
.panel::before { content: ""; position: absolute; inset: 0; z-index: 1; background: var(--hud-frame); pointer-events: none; clip-path: var(--hud-ring); }
.kicker { margin: 0; color: var(--accent); font: 600 12px/1.3 var(--mono); letter-spacing: .06em; text-transform: uppercase; }

/* Commands terminal: dark in both themes, so the commands read as something you run. */
.terminal { --hud-frame: var(--term-green); padding: 0; background: var(--term-bg); color: var(--term-ink); }
.term-bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--term-line); background: var(--term-bar); }
.term-bar h2 { margin: 0; color: var(--term-ink); font: 700 14px/1.4 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.term-dots { display: flex; gap: 6px; }
.term-dots i { width: 8px; height: 8px; background: var(--term-line); }
.term-dots i:first-child { background: var(--term-green); box-shadow: 0 0 8px rgba(74, 222, 128, .6); }
.term-path { margin-left: auto; color: var(--term-muted); font: 12px/1 var(--mono); }
.term-body { display: grid; gap: 12px; padding: 16px 16px 20px; }
.term-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.term-badges span { padding: 2px 8px; border: 1px solid var(--term-line); color: var(--term-muted); font: 600 11px/1.6 var(--mono); letter-spacing: .06em; text-transform: uppercase; transition: color .2s, border-color .2s, background-color .2s; }
.term-badges span[data-on] { border-color: rgba(74, 222, 128, .45); background: rgba(74, 222, 128, .07); color: var(--term-green); }
.terminal pre { max-width: 100%; margin: 0; padding: 14px; overflow-wrap: anywhere; border: 1px solid var(--term-line); background: var(--term-surface); color: var(--term-ink); font: 13px/1.7 var(--mono); white-space: pre-wrap; }
.line::before { content: "$ "; color: var(--term-muted); }
.tok-cmd { color: var(--term-ink); font-weight: 700; }
.tok-repo { color: var(--term-violet); }
.tok-arg { color: var(--term-green); }
.tok-flag { color: var(--term-amber); }
.tok-muted { color: var(--term-muted); }
.term-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
/* min-width fits "✓ Copied to clipboard", so the label swap never resizes the button. */
.terminal #copy { min-width: 28ch; background: var(--term-green); color: #03140a; }
.terminal #copy:hover, .terminal #copy[data-copied] { background: #86efac; }
.terminal #copy[data-copied] { animation: copied .6s var(--ease); }
@keyframes copied { from { background: #ecfdf5; } }
#commands .line:last-child::after { content: ""; display: inline-block; width: .6em; height: 1.15em; margin-left: 4px; vertical-align: text-bottom; background: var(--term-green); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
/* Dark mode: lift the terminal off the near-black page. */
:root[data-theme="dark"] .terminal { --term-bg: #0b100d; }
.terminal #status { margin: 0; color: var(--term-green); font: 13px/1.5 var(--mono); }
.terminal .help { margin: 0; color: var(--term-muted); }
.terminal .help code, .terminal .help b { color: var(--term-ink); }
.terminal .help p { margin: 0; }
.hook-shot { display: block; width: 100%; height: auto; margin: 10px 0; border: 1px solid var(--term-line); }
.terminal a { color: var(--term-green); }
.terminal :focus-visible { outline-color: var(--term-green); }

/* Setup choices */
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.field-group + .field-group { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 24px; }
.field-label { display: grid; grid-template-columns: 32px minmax(0, 1fr); align-items: center; gap: 10px; float: left; width: 100%; margin: 0 0 12px; padding: 0; color: var(--ink); font: 700 13px/1.4 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.field-label code { text-transform: none; letter-spacing: 0; }
.field-step { display: inline-grid; place-items: center; min-width: 28px; padding: 2px 4px; border: 1px solid var(--line-strong); color: var(--muted); font: 600 12px/1.4 var(--mono); font-variant-numeric: tabular-nums; letter-spacing: 0; transition: color .2s, border-color .2s; }
.field-group:has(:checked) .field-label .field-step { border-color: var(--accent); color: var(--accent); }
.options { clear: both; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; }
.options.single { grid-template-columns: minmax(0, 1fr); }
.options label { display: flex; align-items: flex-start; gap: 12px; min-height: 48px; padding: 12px; border: 1px solid var(--line); border-radius: 0; background: var(--surface); cursor: pointer; font-size: 15px; transition: border-color .15s, background-color .15s, box-shadow .15s; }
.options label:hover { border-color: var(--line-strong); background: var(--fill); }
.options label:has(:checked) { border-color: var(--accent); background: var(--accent-tint); box-shadow: inset 3px 0 0 var(--accent); }
.options label:has(:disabled) { opacity: .55; cursor: not-allowed; }
.options label:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.options input { flex: none; width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); cursor: inherit; }
.options small { display: block; margin-top: 4px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.related { margin: 24px 0 0; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; line-height: 1.5; }
.help { margin: 12px 0 0; color: var(--muted); font-size: 14px; line-height: 1.55; }

/* Primary actions are solid blocks with the HUD chamfer (no border, so nothing for the clip to cut). */
button, .button-link { min-height: 44px; padding: 8px 16px; border: 0; border-radius: 0; background: var(--action-fill); color: var(--on-action); font: 700 13px/1.2 var(--mono); letter-spacing: .06em; text-transform: uppercase; cursor: pointer; clip-path: var(--hud-cut); transition: background-color .15s, color .15s, transform .1s; }
button:hover, .button-link:hover { background: var(--action-hover); }
button:active { transform: translateY(1px); }
.button-link { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
button.theme-toggle { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; background: transparent; color: var(--ink); clip-path: none; }
button.theme-toggle:hover { background: var(--fill); }
.theme-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
button:focus-visible, pre:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* The loop this inbox closes: the same four stages as Your Turn Loop, with this one lit. */
.loop { margin-top: 24px; }
.loop-heading { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; }
.loop h2 { margin: 8px 0; font-size: 26px; line-height: 1.15; letter-spacing: -.015em; }
.loop-text { max-width: 62ch; margin: 0; color: var(--muted); font-size: 15px; line-height: 1.5; }
.loop-steps { display: grid; gap: 12px; margin: 24px 0 0; padding: 16px; border: 1px solid var(--line); list-style: none; background: radial-gradient(var(--grid-dot) 1px, transparent 1.5px) 0 0 / 16px 16px, var(--page); }
.loop-steps li { position: relative; display: grid; align-content: start; gap: 4px; padding: 12px; border: 1px solid var(--line-strong); background: var(--surface); }
.loop-steps li.is-here { border-color: var(--accent); box-shadow: 0 0 18px -8px var(--glow); }
.step-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.step-state { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font: 600 11px/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.step-state::before { content: ""; width: 6px; height: 6px; background: var(--line-strong); }
.is-here .field-step, .is-here .step-state { border-color: var(--accent); color: var(--accent); }
.is-here .step-state::before { background: var(--accent); box-shadow: 0 0 8px var(--glow); }
.loop-steps strong { font: 700 13px/1.4 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.loop-steps small { color: var(--muted); font-size: 14px; line-height: 1.5; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips code { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; box-shadow: inset 0 0 0 1px var(--line-strong); font-size: 13px; }
.chips code::before { content: ""; width: 6px; height: 6px; background: var(--line-strong); }
.is-here .chips code { background: var(--accent-tint); box-shadow: inset 0 0 0 1px var(--accent); }
.is-here .chips code::before { background: var(--accent); }
.loop-return { display: none; position: relative; height: 24px; margin: 0 calc((100% - 36px - 32px) / 8 + 16px); border: 1px dashed var(--accent); border-top: 0; }
.loop-return::before { content: ""; position: absolute; top: 0; left: -5px; border-inline: 4.5px solid transparent; border-bottom: 6px solid var(--accent); }
.loop-return span { position: absolute; bottom: 0; left: 50%; padding: 0 8px; transform: translate(-50%, 50%); background: var(--surface); color: var(--accent); font: 600 11px/1.4 var(--mono); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }

#status:empty { display: none; }
.shots { display: grid; gap: 24px; margin-top: 24px; }
.shots figure { padding: 12px; }
/* Same frame for every shot; the inbox loses its empty bottom, never its top. */
.shots img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; object-position: top; }
.shots-wide img { aspect-ratio: auto; }
.shots figcaption { margin-top: 10px; color: var(--muted); font-size: 14px; }
.app-footer { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 20px; margin-top: 24px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 14px; }
/* The release sits on the left in the Deck's label voice; the links stay on the right. */
.app-footer .version { margin-right: auto; color: var(--muted); font: 600 12px/1.6 var(--mono); letter-spacing: .04em; text-decoration: none; }
.app-footer .version:hover { color: var(--ink); }
[hidden] { display: none !important; }

@media (min-width: 768px) {
  .loop-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
  header, main { padding-inline: 16px; }
  main { padding-block: 24px 20px; }
  .panel { padding: 16px; }
  .terminal { padding: 0; }
  .loop-steps { padding: 12px; }
  /* One swipeable row instead of three full-height screenshots. */
  .shots { grid-auto-flow: column; grid-auto-columns: 85%; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; }
  .shots figure { scroll-snap-align: start; padding: 8px; }
  .shots-wide img { aspect-ratio: 16 / 10; }
  .shots figcaption { font-size: 13px; }
  header .repo span:not([aria-hidden]) { display: none; }
  .terminal #copy { flex: 1 1 100%; }
  /* Stacked stages read top to bottom, so the wire turns into a down arrow in the gap. */
  .loop-steps { gap: 24px; }
  .loop-steps li + li::before { content: "↓"; position: absolute; top: -21px; left: 50%; transform: translateX(-50%); color: var(--accent); font: 700 14px/18px var(--mono); }
}
@media (min-width: 900px) {
  .workspace { grid-template-columns: minmax(0, 1.3fr) minmax(340px, 1fr); }
  /* The commands and their Copy stay in view while the setup column scrolls. */
  .result { position: sticky; top: 24px; align-self: start; }
}
@media (min-width: 1024px) {
  .shots { grid-template-columns: 1fr 1fr; align-items: start; }
  .shots-wide { grid-column: 1 / -1; }
  .loop-steps { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 0; }
  .loop-steps li + li::before { content: ""; position: absolute; top: 50%; left: -13px; width: 12px; height: 1px; background: var(--accent); }
  .loop-steps li + li::after { content: ""; position: absolute; top: 50%; left: -6px; transform: translateY(-50%); border-block: 4px solid transparent; border-left: 5px solid var(--accent); }
  .loop-return { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  #commands .line:last-child::after, .terminal #copy[data-copied] { animation: none; }
  *, *::before, *::after { transition: none !important; }
}
