/* SimReady test: a test cell. A pale concrete ground the robot stands on, ink
   type set like a spec sheet, and one accent: the robot's own orange, used
   for what is active. Heat (clay -> amber -> red) is reserved for strain. */

@font-face { font-family: "Newsreader"; src: url("/static/fonts/newsreader-roman.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url("/static/fonts/instrument-sans-roman.woff2") format("woff2"); font-weight: 400 700; font-stretch: 75% 100%; font-display: swap; }
@font-face { font-family: "Fragment Mono"; src: url("/static/fonts/fragment-mono-regular.woff2") format("woff2"); font-display: swap; }

:root {
  --ground: #d9d8d3;
  --panel: #e9e8e4;
  --ink: #161614;
  --ink-2: #47453f;
  --ink-3: #6f6c64;
  --rule: rgb(22 22 20 / 0.14);
  --rule-strong: rgb(22 22 20 / 0.36);
  --accent: #b8470c;
  --heat-0: #8c8b85;
  --heat-1: #f29a1f;
  --heat-2: #dc1a0c;
  --f-display: "Newsreader", "Iowan Old Style", Georgia, serif;
  --f-text: "Instrument Sans", ui-sans-serif, system-ui, sans-serif;
  --f-mono: "Fragment Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --m: clamp(16px, 2.6vw, 36px);
  --panel-w: 368px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-q: cubic-bezier(0.23, 1, 0.32, 1);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--ground);
  color: var(--ink);
  font: 420 15px/1.5 var(--f-text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#stage {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
  touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab;
}
#stage:active { cursor: grabbing; }
#stage:focus-visible { outline-offset: -6px; }

/* ── masthead: the title, hung from the top-left ── */
.masthead {
  position: fixed; top: var(--m); left: var(--m); max-width: min(34ch, calc(100vw - var(--panel-w) - 3 * var(--m)));
  pointer-events: none; z-index: 2;
}
.masthead > * { pointer-events: auto; }
.eyebrow, .label, .mono {
  font: 400 11px/1.3 var(--f-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.eyebrow { margin: 0 0 14px; }
/* the title, unadorned until the piece has a point of view */
h1 { margin: 0; font: 500 1.5rem/1.2 var(--f-display); letter-spacing: -0.01em; }
.intro {
  margin: 18px 0 0; font: 380 clamp(1rem, 0.9rem + 0.35vw, 1.2rem)/1.35 var(--f-display);
  font-variation-settings: "opsz" 24; color: var(--ink-2); text-wrap: pretty;
}
.home {
  display: inline-block; margin-top: 18px; font: 400 11px/1.3 var(--f-mono); letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--rule-strong);
  text-underline-offset: 0.25em;
}
.home:hover { color: var(--ink); text-decoration-color: var(--ink); }

/* ── panel: a fixed sheet on the right, scrolls on its own ── */
.panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: var(--panel-w); z-index: 3;
  background: var(--panel); border-left: 1px solid var(--rule);
  display: flex; flex-direction: column;
}
.drawer { display: none; }
.panel-body { overflow-y: auto; overscroll-behavior: contain; padding: var(--m) 22px 96px; scrollbar-width: thin; }
.panel section { padding: 18px 0; border-top: 1px solid var(--rule); }
.panel section:first-child { border-top: 0; padding-top: 4px; }
.panel h2 { margin: 0 0 12px; font: 400 11px/1.3 var(--f-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); display: flex; justify-content: space-between; gap: 8px; }
.panel h2 .src { text-transform: none; letter-spacing: 0; color: var(--ink-3); }
.panel p { margin: 0 0 10px; color: var(--ink-2); font-size: 13px; line-height: 1.45; text-wrap: pretty; }
.note { font-size: 12.5px; color: var(--ink-3); }

/* segmented text toggles */
.seg { display: flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--rule-strong); border-radius: 3px; overflow: hidden; }
.seg button {
  flex: 1 1 auto; min-height: 36px; padding: 6px 10px; border: 0; border-left: 1px solid var(--rule);
  background: transparent; color: var(--ink-2); font: 500 13px/1.1 var(--f-text); font-stretch: 90%; cursor: pointer;
  transition: background-color 150ms var(--ease-q), color 150ms var(--ease-q);
}
.seg button:first-child { border-left: 0; }
.seg button:hover { color: var(--ink); background: rgb(22 22 20 / 0.04); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--panel); }
.seg.big button { min-height: 44px; font-size: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 6px 12px;
  border: 1px solid var(--rule-strong); border-radius: 3px; background: transparent; color: var(--ink);
  font: 500 13px/1 var(--f-text); font-stretch: 90%; cursor: pointer;
  transition: background-color 150ms var(--ease-q), border-color 150ms var(--ease-q);
}
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.btn.primary:hover { background: #000; }
/* to the obstacle course, from the masthead */
.btn.go { margin-top: 18px; min-height: 44px; padding: 10px 18px; font-size: 15px; text-decoration: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* sliders */
.row { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 2px 10px; padding: 7px 0; }
.row label { font: 500 13px/1.2 var(--f-text); font-stretch: 90%; color: var(--ink); }
.row label.joint { text-transform: capitalize; }
.row output { font: 400 12px/1.2 var(--f-mono); font-variant-numeric: tabular-nums; color: var(--ink); }
.row input[type="range"] { grid-column: 1 / -1; width: 100%; margin: 4px 0 0; accent-color: var(--ink); height: 22px; }
.row .lim { grid-column: 1 / -1; font: 400 10.5px/1.2 var(--f-mono); color: var(--ink-3); display: flex; justify-content: space-between; gap: 6px; }
.row .lim button { all: unset; cursor: pointer; color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 0.2em; }
.row .lim button:hover, .row .lim button:focus-visible { color: var(--accent); }
details.group { border-top: 1px solid var(--rule); }
details.group summary {
  list-style: none; cursor: pointer; padding: 10px 0; display: flex; justify-content: space-between;
  font: 400 11px/1.3 var(--f-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2);
}
details.group summary::-webkit-details-marker { display: none; }
details.group summary::after { content: "+"; }
details.group[open] summary::after { content: "−"; }

/* strain readouts */
.strain { list-style: none; margin: 0; padding: 0; }
.strain li { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 6px 0; border-top: 1px solid var(--rule); font-size: 13px; }
.strain li:first-child { border-top: 0; }
.strain .name { text-transform: capitalize; font-weight: 500; font-stretch: 90%; }
.strain .pct { font: 400 12px/1.3 var(--f-mono); font-variant-numeric: tabular-nums; }
.strain .bar { grid-column: 1 / -1; height: 3px; background: var(--rule); position: relative; overflow: hidden; }
.strain .bar i { position: absolute; inset: 0; background: var(--heat-1); transform-origin: left; }
.strain li.over .pct { color: var(--heat-2); }
.strain li.over .bar i { background: var(--heat-2); }
.legend { display: flex; align-items: center; gap: 8px; font: 400 10.5px/1 var(--f-mono); color: var(--ink-3); margin-top: 10px; }
.legend .ramp { flex: 1; height: 6px; border-radius: 1px; background: linear-gradient(90deg, var(--heat-0), var(--heat-1) 55%, var(--heat-2)); }

/* the model list */
.model-tools { display: grid; gap: 6px; margin-bottom: 8px; }
.search {
  width: 100%; min-height: 36px; padding: 6px 10px; border: 1px solid var(--rule-strong); border-radius: 3px;
  background: transparent; color: var(--ink); font: 500 13px/1.2 var(--f-text);
}
.search::placeholder { color: var(--ink-3); }
.models { display: grid; gap: 0; max-height: 280px; overflow-y: auto; border: 1px solid var(--rule); border-radius: 3px; }
.model {
  display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: center; padding: 8px 10px; border: 0; border-top: 1px solid var(--rule);
  background: transparent; text-align: left; color: var(--ink); cursor: pointer; font: inherit;
}
.model:first-child { border-top: 0; }
.model:hover { background: rgb(22 22 20 / 0.04); }
.model[aria-current="true"] { background: var(--ink); color: var(--panel); }
.model[aria-current="true"] .meta { color: rgb(233 232 228 / 0.7); }
.model img, .model .ph { width: 44px; height: 44px; object-fit: cover; border-radius: 2px; background: #cfcec9; }
.model .t { font: 500 13px/1.2 var(--f-text); font-stretch: 90%; }
.model .meta { font: 400 10.5px/1.3 var(--f-mono); color: var(--ink-3); letter-spacing: 0.02em; }
.model[disabled] { opacity: 0.5; cursor: not-allowed; }
.models .more {
  min-height: 36px; border: 0; border-top: 1px solid var(--rule); background: transparent; color: var(--ink-2); cursor: pointer;
  font: 400 11px/1 var(--f-mono); letter-spacing: 0.04em; text-transform: uppercase;
}
.models .more:hover { color: var(--ink); background: rgb(22 22 20 / 0.04); }

/* status line and credit */
.status {
  position: fixed; left: var(--m); bottom: calc(var(--m) + 28px); margin: 0; z-index: 2; max-width: min(46ch, calc(100vw - var(--panel-w) - 3 * var(--m)));
  font: 400 11px/1.4 var(--f-mono); letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-2);
}
.status:empty { display: none; }
.status .alert { color: var(--heat-2); text-transform: none; letter-spacing: 0; font: 380 1.15rem/1.3 var(--f-display); display: block; margin-bottom: 8px; }
.credit {
  position: fixed; left: var(--m); bottom: var(--m); z-index: 2; margin: 0; max-width: calc(100vw - var(--panel-w) - 3 * var(--m));
  font: 400 10.5px/1.4 var(--f-mono); color: var(--ink-3); letter-spacing: 0.02em;
}
.credit a { color: var(--ink-2); text-underline-offset: 0.2em; text-decoration-color: var(--rule-strong); }
.credit button { all: unset; cursor: pointer; color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 0.2em; }
.credit button:hover, .credit a:hover { color: var(--ink); }

/* loading */
.progress { height: 2px; background: var(--rule); margin-top: 8px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--ink); transform-origin: left; transform: scaleX(var(--p, 0)); transition: transform 250ms var(--ease); }

/* about dialog: the full text description */
.about { border: 0; padding: 0; max-width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); background: var(--panel); color: var(--ink); border-radius: 3px; }
.about::backdrop { background: rgb(217 216 211 / 0.72); }
.about-inner { padding: 28px 32px 36px; }
.about header { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 18px; }
.about h2 { margin: 0; font: 320 2.2rem/1 var(--f-display); letter-spacing: -0.02em; }
.about h3 { margin: 26px 0 8px; font: 400 11px/1.3 var(--f-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }
.about p, .fallback p { max-width: 62ch; color: var(--ink-2); text-wrap: pretty; }
.about .close { all: unset; cursor: pointer; font: 400 11px/1 var(--f-mono); text-transform: uppercase; letter-spacing: 0.06em; padding: 8px 0; }
table.spec { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.spec th, table.spec td { text-align: left; padding: 6px 8px 6px 0; border-top: 1px solid var(--rule); vertical-align: top; }
table.spec th { font: 400 10.5px/1.3 var(--f-mono); color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 400; }
table.spec td.n { font-family: var(--f-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.spec td.src { color: var(--ink-3); font-size: 11.5px; }
.chosen { color: var(--accent); }

.fallback { padding: 8px var(--m) 96px; max-width: 980px; }
/* no WebGPU: the page becomes a document (title, a still, the specification) */
body.nogpu { overflow: auto; }
body.nogpu .masthead { position: static; max-width: 62ch; padding: var(--m) var(--m) 0; }
body.nogpu .credit, body.nogpu .status { position: static; padding: 0 var(--m); margin: 0 0 24px; max-width: none; }
.fallback h2 { margin: 0 0 12px; font: 320 2.4rem/1 var(--f-display); }
.fallback img { display: block; width: 256px; max-width: 100%; height: auto; margin: 18px 0; border-radius: 2px; }
.noscript { position: fixed; left: var(--m); bottom: 30%; font: 380 1.2rem/1.3 var(--f-display); }

.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ── phone: the panel becomes a drawer ── */
@media (max-width: 760px) {
  :root { --panel-w: 0px; }
  .masthead { max-width: calc(100vw - 2 * var(--m)); }
  h1 { font-size: 1.25rem; }
  .intro { font-size: 0.98rem; max-width: 30ch; }
  .intro .long { display: none; }
  .panel {
    top: auto; left: 0; right: 0; width: auto; height: 74vh; border-left: 0; border-top: 1px solid var(--rule);
    transform: translateY(calc(74vh - 112px)); transition: transform 450ms var(--ease);
    box-shadow: 0 -1px 0 var(--rule);
  }
  .panel.open { transform: translateY(0); }
  .drawer {
    display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; min-height: 44px; padding: 8px 0 4px;
    border: 0; background: transparent; color: var(--ink-2); font: 400 11px/1 var(--f-mono); text-transform: uppercase; letter-spacing: 0.06em; cursor: pointer;
  }
  .drawer-grip { width: 40px; height: 4px; border-radius: 999px; background: var(--rule-strong); }
  .panel-body { padding: 4px 16px 40px; }
  .status { bottom: calc(112px + 36px); max-width: calc(100vw - 2 * var(--m)); }
  .credit { bottom: calc(112px + 10px); max-width: calc(100vw - 2 * var(--m)); }
  .home { display: none; }
}

/* dev controls for a maker's walking policy (?policy=1) */
.policy-dev {
  position: fixed; left: var(--m); top: 50%; transform: translateY(-50%); z-index: 3; width: 168px;
  background: var(--panel); border: 1px solid var(--rule); border-radius: 3px; padding: 10px;
  font: 400 11px/1.4 var(--f-mono); color: var(--ink-2);
}
.policy-dev h2 { margin: 0 0 8px; font: 500 11px/1.2 var(--f-mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink); }
.policy-dev h2 .src { display: block; text-transform: none; letter-spacing: 0; color: var(--ink-3); font-weight: 400; margin-top: 2px; }
.policy-dev .pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.policy-dev button { font: 500 14px/1 var(--f-text); padding: 8px 0; background: var(--ground); color: var(--ink); border: 1px solid var(--rule-strong); border-radius: 2px; cursor: pointer; min-height: 32px; }
.policy-dev button:hover { border-color: var(--accent); }
.policy-dev button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.policy-dev button[data-c="shove"] { font: 400 10.5px/1 var(--f-mono); }
.policy-dev .readout { white-space: pre; margin: 8px 0 0; min-height: 4.2em; }
@media (max-width: 760px) { .policy-dev { top: calc(var(--m) + 96px); transform: none; } }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
