/* Built to Move: page rules on top of style.css (house style). Same tokens, same drawing rules. */

/* ---------- Viewer ---------- */
.viewer-col { min-width: 0; }
.stage.viewer {
  aspect-ratio: 16 / 9; background: #121315; border: 1px solid var(--rule);
  touch-action: none;
}
.stage.viewer canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; display: block; }
.stage-wrap:fullscreen { background: #121315; display: grid; place-items: center; }
.stage-wrap:fullscreen .stage.viewer { width: 100%; height: 100%; aspect-ratio: auto; border: 0; }
.stage-badges { grid-area: badges; display: flex; gap: 7px; }
.glass-select select { max-width: 220px; }
.stage-play[hidden] { display: none; }
.stage-play { z-index: 2; }

.loading {
  position: absolute; inset: 0; z-index: 1; display: grid; place-content: center; justify-items: center; gap: 10px;
  pointer-events: none; transition: opacity 0.3s;
}
.loading p { margin: 0; font: 12px / 1.4 var(--mono); letter-spacing: 0.04em; color: var(--muted); }
.loading .track { display: block; width: min(260px, 60vw); height: 2px; background: var(--rule); overflow: hidden; }
.loading .fill { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.15s; }
.loading.done { opacity: 0; }

/* scrub: glass bar over the stage, bottom left (the badge sits bottom right) */
.stage-scrub {
  position: absolute; left: 18px; bottom: 16px; z-index: 3; width: min(42%, 420px);
  display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px;
  border: 1px solid var(--glass-line); border-radius: 4px; background: var(--glass); backdrop-filter: blur(10px);
}
.stage-scrub input { flex: 1; min-width: 0; accent-color: var(--accent); }
.stage-scrub output { font: 11px / 1 var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; min-width: 88px; text-align: right; }
.stage-badge { max-width: calc(58% - 46px); }

/* playing the pinball table */
.game-hud {
  position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; justify-content: space-between;
  padding: 16px 18px; pointer-events: none;
}
.game-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.game-hud button { pointer-events: auto; }
.score { margin: 0; font: 400 44px / 1 'Instrument Serif', serif; font-variant-numeric: tabular-nums; text-shadow: 0 1px 9px #000; }
.score small { display: block; margin-top: 4px; font: 500 11px / 1.4 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.game-side { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.game-help {
  margin: 0; max-width: 32ch; padding: 8px 10px; text-align: right;
  border: 1px solid var(--glass-line); border-radius: 4px; background: var(--glass); backdrop-filter: blur(10px);
  font-size: 11px; line-height: 1.5; color: var(--muted);
}
.game-over { margin: 0; align-self: center; text-align: center; font: 400 44px / 1 'Instrument Serif', serif; color: var(--accent); text-shadow: 0 1px 9px #000; }
.game-over small { display: block; margin-top: 8px; font: 12px / 1.4 'Instrument Sans', sans-serif; color: var(--ink); }
.glass-btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 14px;
  border: 1px solid var(--glass-line); border-radius: 4px; background: var(--glass); backdrop-filter: blur(10px);
  font-size: 12px; color: var(--ink); user-select: none; -webkit-user-select: none; touch-action: none;
}
.glass-btn:hover { border-color: var(--accent); }
.touch { display: flex; justify-content: space-between; gap: 8px; }
.touch .glass-btn { flex: 1; min-height: 52px; }
@media (hover: hover) and (pointer: fine) { .touch { display: none; } }
.playing .stage-badges, .playing #shortcuts, .playing #tools, .playing .stage-scrub, .playing .stage-badge { visibility: hidden; }

/* ---------- Model card under the stage ---------- */
.model-card { margin-top: 14px; padding: 24px; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px 36px; }
.model-card .mc-head { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.model-card .mc-head .count { font-size: 11px; color: var(--accent); }
.model-card .tag { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.model-card h2 { font-size: clamp(32px, 3vw, 44px); grid-column: 1 / -1; }
.model-card .blurb { margin: 0; font-size: 14px; line-height: 1.6; color: var(--ink); }
.model-card .label { margin: 0 0 8px; font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 16px 0 0; border-top: 1px solid var(--rule); }
.stats div { padding: 10px 0 8px; border-bottom: 1px solid var(--rule); min-width: 0; }
.stats b { display: block; font: 400 24px / 1.1 'Instrument Serif', serif; font-variant-numeric: tabular-nums; color: var(--ink); }
.stats span { font-size: 10px; color: var(--muted); }
.cliplist { margin: 0; padding: 0; list-style: none; font: 12px / 1.8 var(--mono); }
.cliplist li span { color: var(--muted); }
.notes { margin: 0; padding-left: 16px; font-size: 13px; line-height: 1.55; color: var(--muted); }
.notes li + li { margin-top: 6px; }
.notes li::marker { color: var(--accent); }
.mc-side { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.input-img { display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: center; }
.input-img img { width: 96px; height: auto; object-fit: contain; border: 1px solid var(--rule); display: block; }
.input-img p { margin: 0; font-size: 12px; line-height: 1.5; color: var(--muted); }
.model-card details { border-top: 1px solid var(--rule); padding-top: 12px; }
.model-card summary { cursor: pointer; font-size: 13px; font-weight: 600; }
.model-card summary:hover { color: var(--accent); }
.model-card details .prompt-excerpt { color: var(--ink); overflow-wrap: anywhere; }

/* ---------- Rail ---------- */
.rail { min-width: 0; }
.rail-label-2 { margin-top: 28px; }
.rail-item { padding: 12px 0; border-bottom: 0; }
.rail-item:last-of-type { border-bottom: 1px solid var(--rule); }
.rail-item .rail-thumb { margin-left: auto; width: 56px; height: 35px; flex: 0 0 56px; object-fit: contain; border: 1px solid var(--rule); opacity: 0.85; }
.rail-item.selected .rail-thumb, .rail-item:hover .rail-thumb { border-color: var(--accent); opacity: 1; }
.rail-item[aria-current='true'] { color: inherit; }

/* ---------- Sections ---------- */
.section { padding-top: 88px; }
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 26px; }
.section-title { margin: 0; font: 400 clamp(36px, 3.8vw, 52px) / 1 'Instrument Serif', serif; letter-spacing: -0.02em; }
.section-sub { margin: 14px 0 0; max-width: 70ch; font-size: 14px; line-height: 1.6; color: var(--muted); }
.toggle {
  display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 16px; flex: none;
  border: 1px solid var(--rule); background: var(--panel); font-size: 13px; font-weight: 600;
}
.toggle .icon { color: var(--accent); }
.toggle:hover, .toggle[aria-pressed='true'] { border-color: var(--accent); }

.vs { display: flex; flex-direction: column; gap: 16px; }
.vs-row { display: grid; grid-template-columns: minmax(0, 0.8fr) repeat(3, minmax(0, 1fr)); gap: 8px; align-items: start; }
.vs-row figure { margin: 0; border: 1px solid var(--rule); background: var(--panel); min-width: 0; }
.vs-row figure.win { border-color: var(--accent); }
.vs-row img { width: 100%; aspect-ratio: 16 / 9; object-fit: contain; display: block; background: #121315; }
.vs-row .vs-concept img { aspect-ratio: auto; height: auto; } /* the whole input picture, at its own shape */
.vs-row figcaption { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px 14px; font-size: 11px; color: var(--muted); }
.vs-row figcaption b { font-size: 13px; font-weight: 600; color: var(--ink); }
.vs-row .win figcaption b { color: var(--accent); }
.vs-row .win figcaption span { color: var(--ink); }

.strengths { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 40px; margin-top: 26px; }
.strengths article { padding: 20px 0 26px; border-top: 1px solid var(--rule); min-width: 0; }
.strengths .num { font-size: 10px; color: var(--accent); font-variant-numeric: tabular-nums; }
.strengths h3 { margin: 10px 0 10px; font: 400 28px / 1.05 'Instrument Serif', serif; letter-spacing: -0.01em; }
.strengths p { margin: 0; font-size: 13px; line-height: 1.65; color: var(--muted); }


/* How dialog: the house layout, plus the list in the first note */
.how-notes ul { line-height: 1.5; }
.how-chapters { flex-wrap: wrap; overflow: visible; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .rail { display: grid; grid-template-columns: 1fr 1fr; column-gap: 28px; align-items: start; }
  .rail-label { grid-column: 1 / -1; }
  .rail > div { display: contents; }
  .rail-item:last-of-type { border-bottom: 0; }
  .strengths { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .vs-row { grid-template-columns: 1fr 1fr; }
  .model-card { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .stage.viewer { aspect-ratio: 1 / 1; }
  .stage-top .shortcut-row { bottom: 0; }
  .stage-scrub { position: static; width: 100%; margin-top: 8px; }
  .stage-badge { max-width: 100%; }
  .section-head { flex-direction: column; align-items: flex-start; }
  .strengths { grid-template-columns: 1fr; }
  .how-chapters { flex-wrap: nowrap; overflow-x: auto; }
  .game-help { display: none; }
  .score { font-size: 34px; }
}
@media (max-width: 560px) {
  .rail { grid-template-columns: 1fr; }
  .glass-select select { min-width: 0; max-width: 150px; }
  .stage-tools { gap: 4px; }
  .model-card { padding: 18px; }
  .stats b { font-size: 20px; }
}
@media (max-width: 380px) {
  .glass-select select { max-width: 112px; }
  .stage-tools #zin, .stage-tools #zout { display: none; }
  .vs-row { grid-template-columns: 1fr; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .stage.viewer { aspect-ratio: auto; height: calc(100dvh - var(--bar-h) - 24px); }
}

/* Glossary tips take no room while closed (an invisible tip near the right edge would widen a phone's layout viewport) */
.term-tip { display: none; white-space: normal; }
.term:hover .term-tip, .term:focus-visible .term-tip, .term[aria-expanded='true'] .term-tip { display: block; }
.loading.done { visibility: hidden; transition: opacity 0.3s, visibility 0s 0.3s; }
@media (max-width: 800px) {
  .action-row > .action:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  /* on phones the tip opens as a sheet along the bottom edge */
  .term-tip { position: fixed; left: 16px; right: 16px; top: auto; bottom: 16px; width: auto; max-width: none; font-size: 13px; padding: 12px 14px; }
}
@media (max-width: 1100px) {
  /* one column: viewer, then the build list, then the selected build's card */
  .viewer-col { display: contents; }
  .stage-wrap { order: 1; }
  .rail { order: 2; }
  .model-card { order: 3; margin-top: 0; }
}
.nowrap { white-space: nowrap; }
summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 5px; }

/* ---------- Footer: the shared exploration runtime mounts its tools strip in [data-exploration-controls] ---------- */
.site-foot {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; margin-top: 72px; padding: 22px 4.2% 28px;
  border-top: 1px solid var(--rule); font-size: 12px; color: var(--muted);
}
.site-foot .foot-id { margin-right: auto; }
.site-foot .foot-link { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--rule); }
.site-foot .foot-link:hover { color: var(--accent); border-color: var(--accent); }
/* the footer draws the rule and background; the runtime's tool strip sits inside it without a second rule */
.site-foot [data-exploration-controls] { flex: 1 1 320px; display: flex; justify-content: flex-end; border-top: 0; background: none; }
:root { --exploration-footer-bg: var(--bg); --exploration-footer-ink: var(--ink); --exploration-footer-border: var(--rule); }

/* a lost GPU context: the view stops behind an explicit reload */
.loading.is-lost { pointer-events: auto; padding: 24px; text-align: center; }
.loading.is-lost p { max-width: 36ch; color: var(--ink); font: 14px / 1.5 'Instrument Sans', sans-serif; }
.loading.is-lost .glass-btn { display: flex; margin: 14px auto 0; }

/* where the chapter row scrolls sideways, the focus ring (2px, 5px out) stays inside its scroll box */
@media (max-width: 800px) {
  .how-chapters { padding: 8px; margin: 4px -8px 0; scroll-padding-inline: 8px; }
}
