/* Layout: one white lab panel on a navy-to-cobalt ground. A gantry machine fills the panel; the generated sentence is the headline. */
:root {
  --ground-a: #0c0a1c; --ground-b: #2a45e0;
  --panel: #f7f8fb; --ink: #141a2e; --muted: #596177;
  --steel-1: #eef1f6; --steel-2: #cfd5e1; --steel-3: #9aa3b5;
  --cobalt: #2346e8; --pink: #d9166a; --on-accent: #fff;
  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --panel: #12151f; --ink: #e9ecf5; --muted: #8690a8;
  --steel-1: #1d2230; --steel-2: #343c50; --steel-3: #5a647c;
  --cobalt: #6c88ff; --pink: #ff5c9d; --on-accent: #0c0a1c; color-scheme: dark } }
:root[data-theme="dark"] {
  --panel: #12151f; --ink: #e9ecf5; --muted: #8690a8;
  --steel-1: #1d2230; --steel-2: #343c50; --steel-3: #5a647c;
  --cobalt: #6c88ff; --pink: #ff5c9d; --on-accent: #0c0a1c; color-scheme: dark }

html, body { height: 100% }
body { margin: 0 } [hidden] { display: none !important }
body {
  background: linear-gradient(var(--ground-a) 30%, var(--ground-b)); background-attachment: fixed;
  color: var(--ink); font-family: var(--display); box-sizing: border-box;
  padding-block: 16px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.panel { height: 100%; background: var(--panel); border-radius: 10px; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden }
.mono, button, label, .switch a { font: 500 11px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase }

.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; padding: 12px 20px; border-bottom: 1px solid var(--steel-2) }
.pill { color: var(--pink); border: 1px solid var(--pink); border-radius: 99px; padding: 5px 10px }
.group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px }
.group.right { margin-left: auto }
.switch a { color: var(--muted); text-decoration: none; padding: 6px 0 } .switch a[aria-current] { color: var(--ink); box-shadow: 0 1px var(--pink) }
button { background: none; border: 0; padding: 6px 0; color: var(--muted); cursor: pointer }
button:hover, button[aria-pressed="true"] { color: var(--ink) }
button.key { color: var(--on-accent); background: var(--cobalt); padding: 7px 12px; border-radius: 3px; min-width: 64px }
:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px }
label { display: flex; align-items: center; gap: 8px; color: var(--muted) }
input[type=range] { width: 90px; accent-color: var(--cobalt) }
#tval { color: var(--ink); min-width: 2.4em }

.mid { display: grid; grid-template-columns: 150px minmax(0, 1fr); min-height: 0; position: relative }
.side { display: flex; flex-direction: column; justify-content: space-between; gap: 16px; padding: 22px 0 18px 20px }
.transport { display: grid; gap: 8px; justify-items: start; color: var(--muted) }
.badge { color: var(--cobalt); border: 1px solid var(--cobalt); border-radius: 3px; padding: 6px 10px }
.stages { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; align-content: start; color: var(--muted) }
.stages [aria-current] { color: var(--ink) }
.stages [aria-current]::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 8px; background: var(--pink); border-radius: 50% }
svg { width: 100%; height: 100%; min-height: 200px; display: block; --k: 1 }

.foot { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 32px; padding: 0 20px 18px }
#sentence { flex: 1 1 420px; min-width: 0; margin: 0; min-height: 2.04em; font: 500 clamp(24px, 4.4vw, 60px)/1.02 var(--display); letter-spacing: -.035em; text-transform: uppercase; white-space: pre-wrap; text-wrap: balance }
#sentence .gen { color: var(--cobalt) } #sentence .gone { color: var(--muted) }
#sentence::after { content: ""; display: inline-block; width: .08em; height: .8em; margin-left: .08em; background: var(--pink); animation: blink 1s steps(2) infinite }
@keyframes blink { 50% { opacity: 0 } }
.note { flex: 0 1 300px; display: grid; gap: 8px }
.note p { margin: 0; font-size: 13px; line-height: 1.45; min-height: 8.7em }
.note small { color: var(--muted); font-size: 12px; line-height: 1.4 }
#count { color: var(--muted) }

/* machine */
svg text { font-family: var(--mono); font-size: 11px; fill: var(--ink) }
svg * { transition-duration: calc(.45s / var(--k)); transition-timing-function: cubic-bezier(.6, 0, .2, 1) }
.s1 { fill: var(--steel-1); stroke: var(--steel-2) } .s2 { fill: var(--steel-2) } .s3 { fill: var(--steel-3) }
.cb { fill: var(--cobalt) } .pk { fill: var(--pink) } .dim { fill: var(--muted) }
.tag rect { fill: var(--cobalt) } .tag text { fill: var(--on-accent); font-size: 9.5px; letter-spacing: .1em }
.chip { fill: var(--panel); stroke: var(--steel-3) }
.row { transition-property: opacity } .row.hid { opacity: 0 }
.row.gen .chip { stroke: var(--cobalt) }
.id { fill: var(--muted); font-size: 9.5px; text-anchor: end }
.cell { opacity: 0; transition-property: opacity } .vec.on .cell { opacity: var(--o) }
.ln { fill: none; stroke: var(--cobalt); stroke-dasharray: 1; stroke-dashoffset: 1; opacity: var(--o); transition-property: stroke-dashoffset, opacity }
.ln.on { stroke-dashoffset: 0 } .ln.off { opacity: 0 }
.plate { fill: var(--panel); stroke: var(--steel-2); transition-property: fill } .plate.on { fill: var(--cobalt) }
.pt { font-size: 10.5px; letter-spacing: .08em } .ps { font-size: 9.5px; fill: var(--muted) } .pt, .ps, .st { transition-property: fill, opacity } .plate.on ~ text { fill: var(--on-accent) }
.ln-t { font-size: 9px; fill: var(--muted); opacity: 0; transition-property: opacity } .ln-t.on { opacity: 1 } .ln-t.off { opacity: 0 }
#out { stroke: var(--steel-3); stroke-width: 2; transition-property: stroke } #out.on { stroke: var(--pink) }
.cand { cursor: pointer; transition-property: opacity } .cand.none { opacity: 0; pointer-events: none }
.cand rect { fill: var(--steel-3); transform-box: fill-box; transform-origin: bottom; transform: scaleY(0); transition-property: transform, fill }
.cand.pick rect { fill: var(--cobalt) } .cand:hover rect { fill: var(--cobalt) }
.pos { fill: var(--pink); font-size: 9px; text-anchor: end } .vec .pos { opacity: 0; transition-property: opacity } .vec.on .pos { opacity: 1 }
.vc { transition-property: opacity, fill; transition-delay: calc(var(--d) / var(--k)) }
.cand .sc { fill: var(--muted); font-size: 9px }
.cand text { text-anchor: middle } .cand .pct { fill: var(--muted); font-size: 9.5px; transition-property: transform, opacity }
#car, #noz, #arm { transition-property: transform } #arm { transform-box: fill-box; transform-origin: top }
#held { transition-property: opacity; transition-duration: .1s }

/* hover detail: one sublayer explained with a looping mini diagram */
#plates g { cursor: help } #plates g:hover .plate, #plates g:focus-visible .plate { stroke: var(--cobalt) }
#detail { position: absolute; top: 14px; right: 20px; width: min(440px, calc(100% - 40px)); box-sizing: border-box; display: grid; gap: 10px; padding: 14px; background: var(--panel); border: 1px solid var(--cobalt); border-radius: 4px; pointer-events: none }
#detail h2 { margin: 0; font: 500 11px/1 var(--mono); letter-spacing: .08em; color: var(--cobalt) }
#detail svg { height: auto; min-height: 0; aspect-ratio: 280 / 130 }
#detail p { margin: 0; font-size: 12.5px; line-height: 1.45 }
.chip.q { stroke: var(--pink) } .wire { fill: none; stroke: var(--steel-3) }
.a-ln { fill: none; stroke: var(--cobalt); stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 4s infinite; animation-delay: calc(var(--i) * .25s) }
.a-out { animation: fillin 4s infinite }
.flow { fill: none; stroke: var(--cobalt); stroke-width: 1.5; stroke-dasharray: 4 4; animation: dash .8s linear infinite } .flow.skip { stroke: var(--pink) }
.nb { transform-box: fill-box; transform-origin: bottom; animation: norm 3s infinite }
.ff-r { animation: rowin 5s infinite backwards; animation-delay: calc(var(--i) * .6s) }
@keyframes draw { 20%, 85% { stroke-dashoffset: 0; opacity: 1 } 100% { stroke-dashoffset: 0; opacity: 0 } }
@keyframes fillin { 0%, 45% { opacity: .1 } 60%, 90% { opacity: 1 } 100% { opacity: .1 } }
@keyframes dash { to { stroke-dashoffset: -16 } }
@keyframes norm { 0%, 35% { transform: scaleY(1) } 55%, 100% { transform: scaleY(var(--s)) } }
@keyframes rowin { 0% { opacity: 0 } 10%, 85% { opacity: 1 } 100% { opacity: 0 } }

@media (max-width: 760px) {
  .panel { height: auto; min-height: 100% }
  .mid { grid-template-columns: minmax(0, 1fr) } .stages { display: none }
  .side { padding: 12px 16px 0 } .transport { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px }
  .group.right { margin-left: 0 }
}
@media (prefers-reduced-motion: reduce) { svg *, #sentence::after { transition: none !important; animation: none !important } .a-ln { stroke-dashoffset: 0 } }
