/* The tehas game view: the factory as a 16-bit overworld. See DESIGN.md.
   Colours, typefaces, outlines and shadows are the theme's tokens, from
   /fun/theme.css (theme-<name>.css), which every page loads before this file. */

:root {
  /* Height of the sticky header, for everything that sticks or scrolls under
     it. Each width band sets it, and a page whose menu wraps into rows sets a
     taller one: see the media blocks at the end of this file. */
  --header: 80px;
}

* { box-sizing: border-box; }

html { background: var(--field); }

body {
  margin: 0;
  background-color: var(--field);
  background-image: var(--field-pattern);
  color: var(--text);
  font: 16px/24px var(--font);
  font-synthesis: none;
  -webkit-font-smoothing: var(--font-smoothing);
  overflow-x: clip;
}

h1, h2, h3, p, ol, ul, dl, dd { margin: 0; padding: 0; }
h1, h2, h3 { font-size: inherit; font-weight: 400; }
h1, h2 { font-size: 32px; line-height: 32px; }
ol, ul { list-style: none; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
img { display: block; }
[hidden] { display: none !important; }

:focus-visible { outline: var(--focus); outline-offset: 4px; }

.skip {
  position: absolute;
  left: 16px;
  top: -80px;
  z-index: 10;
  padding: 8px 16px;
  background: var(--accent);
  border: var(--frame);
}
.skip:focus { top: 16px; }

/* Motion. Everything moves in steps, like sprite frames: nothing eases, nothing
   blurs. One-shot moves answer something the viewer did or mark data arriving.
   The only loops are a cursor and lamps that blink while a cycle really runs. */

@keyframes pop-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes row-in { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
@keyframes latch { from { background: var(--accent); color: var(--text); } to { background: transparent; } }
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes lamp { 0%, 49% { background: var(--accent-soft); } 50%, 100% { background: var(--text-warm); } }
@keyframes gate-shut { 0%, 49% { background: var(--accent); } 50%, 100% { background: var(--surface); } }

.station, .door, .monitor { animation: pop-in 240ms steps(3, end) backwards; }
.station:nth-child(2) { animation-delay: 60ms; }
.station:nth-child(3) { animation-delay: 120ms; }
.station:nth-child(4) { animation-delay: 180ms; }
.monitor { animation-delay: 240ms; }
.door:nth-child(1) { animation-delay: 300ms; }
.door:nth-child(2) { animation-delay: 340ms; }
.door:nth-child(3) { animation-delay: 380ms; }
.door:nth-child(4) { animation-delay: 420ms; }
.door:nth-child(5) { animation-delay: 460ms; }
.door:nth-child(6) { animation-delay: 500ms; }

.is-changed { animation: latch 320ms steps(2, end); }

/* A ticket number in flight from where it was pressed to the monitor. */
.flyer {
  position: fixed;
  z-index: 20;
  padding: 0 4px;
  margin: 0 0 0 -4px;
  background: var(--screen);
  color: var(--screen-text);
  transform-origin: 0 0;
  pointer-events: none;
}
/* While a number is on its way the screen is blank: the old ticket goes at once. */
.monitor.is-receiving .screen > * { visibility: hidden; }
.monitor.is-receiving { box-shadow: var(--ring), var(--shadow-sign); }
.rows.is-fresh li { animation: row-in 120ms steps(2, end) both; }
.rows.is-fresh li:nth-child(2) { animation-delay: 24ms; }
.rows.is-fresh li:nth-child(3) { animation-delay: 48ms; }
.rows.is-fresh li:nth-child(4) { animation-delay: 72ms; }
.rows.is-fresh li:nth-child(5) { animation-delay: 96ms; }
.rows.is-fresh li:nth-child(6) { animation-delay: 120ms; }
.rows.is-fresh li:nth-child(7) { animation-delay: 144ms; }
.rows.is-fresh li:nth-child(n + 8) { animation-delay: 168ms; }

.cursor { display: inline-block; width: 8px; height: 16px; margin-left: 8px; vertical-align: -2px; background: var(--screen-text); animation: blink 1s steps(1, end) infinite; }

.monitor-title { display: flex; justify-content: space-between; align-items: center; }
.monitor-led { width: 16px; height: 8px; background: var(--text-quiet); border: 0; box-shadow: 0 0 0 var(--edge) var(--line); margin-right: 4px; }
body[data-factory="live"] .monitor-led { animation: lamp 1.2s steps(1, end) infinite; }
body[data-factory="live"] .console-state::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  background: var(--text-warm);
  animation: blink 1.2s steps(1, end) infinite;
}
.gate[data-state="paused"] { animation: gate-shut 1.6s steps(1, end) infinite; }

/* Things you can press stand up off the field when pointed at. */
.door:hover, .button:hover:not(:disabled) { transform: var(--lift); }
.door:hover { box-shadow: var(--shadow-sign-up); }
.button:hover:not(:disabled) { box-shadow: var(--shadow-card-up); }

@media (prefers-reduced-motion: reduce) {
  .station, .door, .monitor, .is-changed, .rows.is-fresh li,
  .cursor, .monitor-led, .console-state::before, .gate[data-state="paused"] { animation: none !important; }
  body[data-factory="live"] .monitor-led { background: var(--accent-soft); }
}

/* Header band */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 0 16px;
  padding: 8px 24px;
  background: var(--surface-head);
  border-bottom: var(--frame);
  box-shadow: var(--stripe);
  margin-bottom: 8px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 32px;
  line-height: 32px;
  text-decoration: none;
}
.source {
  white-space: nowrap;
  padding: 4px 12px;
  background: var(--surface);
  border: var(--frame);
}
.source[data-kind="sample"], .source[data-kind="stale"] { background: var(--accent); }
/* The fresh live queue is the normal case and needs no tag. */
.source[data-kind="live"] { display: none; }
.menu { display: flex; align-items: center; gap: 0 16px; margin-left: auto; }
/* A typeface wider than Topaz would push the state tag past the edge: the
   menu gives way and scrolls instead, and the tag stays in view. */
.topbar > .menu { min-width: 0; overflow-x: auto; scrollbar-width: none; }
.topbar > .menu::-webkit-scrollbar { display: none; }
/* The factory state tag closes the header, at the far right. */
.topbar > .gate { flex: none; margin-left: 8px; white-space: nowrap; }
.menu a, .repo { padding: 12px 0; text-decoration: none; white-space: nowrap; }
.menu a:hover, .repo:hover { text-decoration: underline; text-underline-offset: 4px; }
.repo { text-decoration: underline; text-underline-offset: 4px; }

/* The stage, and the widths it is read at. The boundary is named once here and
   written where a rule needs it:
   1440px and up: wide. The floor, the doors and the board in one column with
     the work order monitor fixed beside them, so the first screen is the whole
     status. game-view.js asks for this same width before it centres the first
     screen, and energy-view.css gives the meter its column at it.
   below 1440px: one column, every panel filling it, the monitor a panel too.
   below 1280px: the stations stack, one sign per row.
   test/front_page_test.sh reads the width out of each place that writes one and
   fails where they disagree. */

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 336px;
  grid-template-areas:
    "head head"
    "line monitor"
    "doors monitor"
    "board monitor"
    "lab monitor"
    "console monitor"
    "epics epics"
    "energy energy"
    "host host"
    "break break";
  column-gap: 24px;
  max-width: 1488px;
  margin: 0 auto;
  padding: 0 24px;
}
/* Wide only: the floor and the desk are contents, so their children are the
   stage's items and the areas named below are theirs. A band that makes either
   one a panel of its own names that panel instead and those areas stand empty. */
.floor, .desk { display: contents; }
/* --fold-pad and --fold-gap are set by fitFold() in game-view.js, from the
   numbers in fold-fit.js, so the first screen sits centred in the window and
   the board starts below it. The fold offset is a margin, not padding: the
   panel's own spacing belongs to its face, and the panel's height is part of
   what fitFold measures. */
.floor-head { grid-area: head; margin-top: max(0px, var(--fold-pad, 32px)); }
.line { grid-area: line; }
.doors { grid-area: doors; }
.monitor-wrap { grid-area: monitor; }
.board-wrap { grid-area: board; margin-top: var(--fold-gap, 72px); }
.break-room { grid-area: break; margin-top: 96px; }

/* Drawn like the board so the page's own head reads as an object on the field.
   Its gutters live on the children, as they do there. */
.floor-head {
  background: var(--surface);
  border: var(--frame);
  box-shadow: var(--shadow-sign);
  margin-bottom: 24px;
}
.floor-head h1 { padding: 12px 16px; background: var(--surface-head); border-bottom: var(--frame); }
/* What the page is, for a first visit: one line of words under the title. */
.floor-intro { margin: 16px 16px 0; max-width: 110ch; }
.floor-intro a { text-underline-offset: 4px; }
#floor-summary { margin: 8px 16px 16px; color: var(--text-quiet); }
.gate { padding: 0 8px; background: var(--surface); border: var(--frame); }
.gate[data-state="running"] { background: var(--good); color: var(--text-on-good); }
.gate[data-state="paused"], .gate[data-state="starved"] { background: var(--accent); }
.gate[data-state="failed"] { background: var(--bad); color: var(--text-on-bad); }

/* The floor: four stations side by side */

.line { position: relative; }

.stations {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.station { display: grid; }

.sign {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 8px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: var(--frame);
  box-shadow: var(--shadow-sign);
}
.station.is-filtered .sign { box-shadow: var(--ring), var(--shadow-sign); }
/* Content-box, so the border sits outside the picture and the 240:130 art fills its frame exactly. */
.scene { box-sizing: content-box; width: calc(100% - 2 * var(--edge)); height: auto; aspect-ratio: 240 / 130; border: var(--frame); }

.sign h2 {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.sign h2 b { font-weight: 400; color: var(--text-cool); }
.station[data-stage="running"] h2 b,
.station[data-stage="review"] h2 b { color: var(--text-warm); }

.slot-label { margin-top: 8px; padding-top: 8px; border-top: var(--edge) solid var(--rule); color: var(--text-quiet); }
.slot { flex: 1; min-height: 80px; }
.empty-slot { color: var(--text-quiet); }

.ticket {
  display: block;
  width: calc(100% + 8px);
  padding: 4px;
  margin: 0 -4px;
  text-align: left;
  background: none;
  border: 0;
  cursor: pointer;
}
.ticket b { font-weight: 400; color: var(--text-warm); }
/* Two lines keep every sign the same height; the monitor shows the full title. */
.ticket span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.ticket:hover, .ticket.is-current { background: var(--accent-soft); }

.see-all {
  min-height: 48px;
  margin-top: 8px;
  padding: 12px 0 4px;
  text-align: left;
  background: none;
  border: 0;
  color: var(--text-cool);
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}
.see-all:hover { color: var(--text); }

/* Doors: where everything else on the page is */

.doors {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 32px;
}
.door {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  padding: 4px 16px;
  background: var(--surface-head);
  border: var(--frame);
  box-shadow: var(--shadow-sign);
  text-decoration: none;
}
.door b, .door small { display: block; font: inherit; }
.door small { color: var(--text-quiet); }
.door i { font-style: normal; font-size: 32px; line-height: 32px; }
.door:hover { background: var(--surface); }
.door:active { transform: var(--press-sign); box-shadow: none; }
.door.is-alert { background: var(--accent); }
.door.is-alert small { color: var(--text); }
.door.is-alert:hover { background: var(--accent-soft); }

/* The work order on a monitor */

.monitor {
  position: sticky;
  top: calc(var(--header) + 16px);
  display: flex;
  flex-direction: column;
  min-height: var(--monitor-height, 0);
  padding: 0 16px 16px;
  background: var(--surface-quiet);
  border: var(--frame);
  box-shadow: var(--shadow-sign);
}
.monitor-title { padding: 12px 0; }
.screen {
  flex: 1;
  min-height: 336px;
  padding: 16px;
  background: var(--screen);
  border: var(--frame);
  color: var(--screen-text);
}
.order-title { margin-top: 16px; overflow-wrap: anywhere; }
.order-number { font-size: 32px; line-height: 32px; }
/* The labels share one column, as wide as the longest of them in the theme's
   typeface and never narrower than 64px. */
.order-facts { display: grid; grid-template-columns: minmax(64px, max-content) 1fr; column-gap: 8px; margin-top: 16px; color: var(--screen-quiet); }
.order-facts div { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; }
/* The four facts about the ticket's history stand apart from stage and labels. */
.order-facts div:nth-child(3) { margin-top: 16px; }
.order-facts dd { color: var(--screen-text); overflow-wrap: anywhere; }
.order-foot { margin-top: 16px; }
.order-link { color: var(--screen-quiet); }
.order-link a { color: var(--surface); text-underline-offset: 4px; }
.order-link a:focus-visible { outline-color: var(--screen-text); }
.monitor-base {
  position: absolute;
  left: 50%;
  top: 100%;
  width: 96px;
  height: 16px;
  margin: 4px 0 0 -48px;
  background: var(--line);
  box-shadow: -32px 16px 0 var(--line), 32px 16px 0 var(--line);
}

/* The issue board */

.board {
  scroll-margin-top: calc(var(--header) + 16px);
  background: var(--surface);
  border: var(--frame);
  box-shadow: var(--shadow-sign);
}
.board:focus-visible { outline-offset: 8px; }
.board-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0 24px;
  padding: 12px 16px;
  background: var(--surface-head);
  border-bottom: var(--frame);
}
.board-all { text-underline-offset: 4px; }
.board-all:hover { color: var(--text-cool); }
.board-tools { display: flex; flex-wrap: wrap; align-items: end; gap: 16px; padding: 16px; }
.board-tools label { display: grid; gap: 4px; color: var(--text-quiet); }
.board-tools label:first-child { flex: 1 1 240px; }
.board-tools input, .board-tools select {
  width: 100%;
  height: 48px;
  padding: 0 12px;
  background: var(--surface);
  border: var(--frame);
  border-radius: 0;
  color: var(--text);
}
.board-tools input::placeholder { color: var(--text-quiet); opacity: 1; }

.rows { border-top: var(--frame); }
.row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: 16px;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  text-align: left;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
}
.rows li:last-child .row { border-bottom: 0; }
.row b { font-weight: 400; color: var(--text-warm); }
.row .row-title { overflow-wrap: anywhere; }
.row .row-stage { color: var(--text-quiet); text-align: right; }
.row:hover { background: var(--surface-head); }
.row.is-current { background: var(--accent-soft); }
.row.is-current .row-stage { color: var(--text); }
.row:focus-visible { outline-offset: -4px; }
.rows-note { padding: 24px 16px; }

/* Epics: the open issues with sub-issues, one row each with a block per
   sub-issue, filled when it is closed. A row opens to list its sub-issues
   (epics-view.js). */

.epics {
  grid-area: epics;
  margin-top: 72px;
  scroll-margin-top: calc(var(--header) + 16px);
  background: var(--surface);
  border: var(--frame);
  box-shadow: var(--shadow-sign);
}
.epics-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0 24px;
  padding: 12px 16px;
  background: var(--surface-head);
  border-bottom: var(--frame);
}
.epics-intro { padding: 12px 16px; color: var(--text-quiet); border-bottom: var(--frame); }
.epic { border-bottom: 1px solid var(--rule); }
.epic:last-child { border-bottom: 0; }
.epic-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) minmax(128px, 320px) max-content;
  align-items: center;
  gap: 16px;
  min-height: 48px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
}
.epic-row::-webkit-details-marker { display: none; }
.epic-row:hover { background: var(--surface-head); }
.epic[open] > .epic-row { background: var(--accent-soft); }
.epic-row:focus-visible { outline-offset: -4px; }
.epic-number { font-weight: 400; color: var(--text-warm); white-space: nowrap; }
.epic-number::before { content: "+"; display: inline-block; width: 16px; color: var(--text-quiet); }
.epic[open] .epic-number::before { content: "-"; }
.epic-title { overflow-wrap: anywhere; }
.epic-bar { display: flex; gap: 4px; height: 16px; }
.epic-bar i { flex: 1; min-width: 4px; background: var(--surface); box-shadow: inset 0 0 0 2px var(--line); }
.epic-bar i.is-closed { background: var(--good); }
.epic-bar i.is-more { background: var(--rule); box-shadow: none; }
.epic-count { color: var(--text-quiet); text-align: right; white-space: nowrap; }
.epic-body { padding: 8px 16px 16px 104px; background: var(--surface-quiet); border-top: 1px solid var(--rule); }
.epic-subs { margin: 0; padding: 0; list-style: none; }
.epic-subs li { display: flex; align-items: start; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.epic-subs li:last-child { border-bottom: 0; }
.epic-state { flex: none; width: 72px; padding: 0 4px; text-align: center; text-transform: uppercase; background: var(--accent); border: 2px solid var(--line); }
.is-closed .epic-state { background: var(--good); color: var(--text-on-good); }
.is-closed .epic-sub { color: var(--text-quiet); }
.epic-sub { overflow-wrap: anywhere; text-underline-offset: 4px; }
.epic-sub:hover, .epic-link:hover { background: var(--accent-soft); }
.epic-foot { margin-top: 8px; color: var(--text-quiet); }
.epic-link { color: var(--text-cool); text-underline-offset: 4px; }
.epic-empty, .epic-none { padding: 24px 16px; }

/* The Protolab: tickets at the prototype stage, labelled tehas:prototype, beside the lab at work */

.lab {
  grid-area: lab;
  margin-top: 72px;
  scroll-margin-top: calc(var(--header) + 16px);
  background: var(--surface);
  border: var(--frame);
  box-shadow: var(--shadow-sign);
}
.lab-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0 24px;
  padding: 12px 16px;
  background: var(--surface-head);
  border-bottom: var(--frame);
}
.lab-body { display: grid; grid-template-columns: minmax(0, 1fr) 440px; }
.lab .rows { border-top: 0; }
.lab .has-link { display: grid; grid-template-columns: minmax(0, 1fr) auto; border-bottom: 1px solid var(--rule); }
.lab .has-link:last-child { border-bottom: 0; }
.lab .has-link .row { border-bottom: 0; }
.lab a.row { text-decoration: none; }
.row-open { display: grid; place-items: center; min-width: 72px; padding: 0 16px; color: var(--text-cool); text-underline-offset: 4px; }
.row-open:hover { background: var(--surface-head); color: var(--text); }
.row-open:focus-visible { outline-offset: -4px; }
.lab-scene { margin: 0; padding: 16px; background: var(--surface-quiet); }
.lab-scene img { box-sizing: content-box; width: 400px; height: 280px; border: var(--frame); }
.lab-scene figcaption { margin-top: 8px; color: var(--text-quiet); }

/* The production console: the running cycle's output, live from the factory */

.console {
  grid-area: console;
  margin-top: 72px;
  scroll-margin-top: calc(var(--header) + 16px);
  background: var(--surface-quiet);
  border: var(--frame);
  box-shadow: var(--shadow-sign);
}
.console-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 24px;
  padding: 12px 16px;
  background: var(--surface-head);
  border-bottom: var(--frame);
}
.console-state { padding: 0 8px; background: var(--surface); border: var(--frame); }
.console-state[data-state="live"] { background: var(--accent); }
.console-body { padding: 16px; }
.console-cycle { overflow-wrap: anywhere; }
.console-step { min-height: 24px; color: var(--text-quiet); overflow-wrap: anywhere; }
/* One tab per cycle, shown when there is more than one to choose from. */
.console-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.console-tabs[hidden] { display: none; }
.console-tabs button {
  min-height: 48px; padding: 0 16px;
  font: inherit; color: inherit; text-transform: uppercase;
  background: var(--surface); border: var(--frame); cursor: pointer;
}
.console-tabs button[aria-selected="true"] { background: var(--accent); }
#console-out {
  height: 400px;
  margin: 8px 0 0;
  padding: 16px;
  overflow: auto;
  background: var(--screen);
  border: var(--frame);
  color: var(--screen-text);
  font: inherit;
  font-family: var(--font-code);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
#console-out:focus-visible { outline-offset: 4px; }
#console-out:empty::before { content: attr(data-empty); color: var(--screen-quiet); }
.console-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 24px; margin-top: 8px; }
.console-bar label { display: flex; align-items: center; gap: 12px; min-height: 48px; cursor: pointer; }
.console-bar input { width: 24px; height: 24px; margin: 0; accent-color: var(--text-cool); }
.console-bar span { color: var(--text-quiet); }

/* Buttons */

.button {
  display: inline-grid;
  place-items: center;
  min-height: 48px;
  padding: 0 16px;
  background: var(--surface);
  border: var(--frame);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  text-decoration: none;
}
.button-primary { background: var(--accent); }
.button:hover { background: var(--surface-head); }
.button-primary:hover { background: var(--accent-soft); }
.button:active { transform: var(--press); box-shadow: none; }
.button:disabled { color: var(--text-quiet); background: var(--surface-quiet); box-shadow: none; cursor: not-allowed; }
.file-button { position: relative; }
.file-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-button:focus-within { outline: var(--focus); outline-offset: 4px; }

/* Breakroom */

.break-room {
  scroll-margin-top: calc(var(--header) + 16px);
  background: var(--surface-quiet);
  border: var(--frame);
  box-shadow: var(--shadow-sign);
}
.break-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0 24px;
  padding: 12px 16px;
  background: var(--surface-head);
  border-bottom: var(--frame);
}
.cabinet {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  margin: 16px;
  background: var(--screen);
  border: var(--frame);
}
.cabinet canvas {
  display: block;
  width: calc(100% - 8px);
  height: auto;
  aspect-ratio: 480 / 272;
  margin: 4px;
  image-rendering: pixelated;
  touch-action: none;
  background: var(--screen);
}
.cabinet-side { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px 16px; background: var(--surface); }
.cabinet-help, .cabinet-word { color: var(--text-quiet); }
.readout { display: flex; gap: 24px; }
.readout dd { font-size: 32px; line-height: 32px; color: var(--text-cool); }
.cabinet-message { flex: 1; }
.cabinet-side .button { align-self: start; min-width: 120px; }

/* Footer: the data source, then the signature */

.footer {
  margin-top: 96px;
  padding: 32px 24px 40px;
  background: var(--surface-quiet);
  border-top: var(--frame);
}
.data-dock {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px 32px;
  max-width: 1440px;
  margin: 0 auto;
  scroll-margin-top: calc(var(--header) + 16px);
}
.data-dock p { max-width: 65ch; margin-top: 8px; }
.data-actions { display: flex; flex-wrap: wrap; gap: 16px; }
.footer-note { max-width: 1440px; margin: 24px auto 0; color: var(--text-quiet); }
.footer-note a { color: var(--text); text-underline-offset: 4px; }
.ascii { margin-top: 40px; display: grid; justify-content: center; }
.ascii pre { margin: 0; font: 16px/16px var(--font-code); }
.credit { max-width: 80ch; margin: 16px auto 0; text-align: center; color: var(--text-quiet); }
.credit a { color: var(--text); text-underline-offset: 4px; }

/* Below the width that fits four stations and the monitor side by side the
   stage is one column and every panel fills it. The work order gives up its
   column here; the stations keep their row until the narrower band below.
   The band is the negation of the width game-view.js asks for, so no width sits
   between the stylesheet and the script. */

@media not all and (min-width: 1440px) {
  /* The template names every row it draws, PROTOLAB and the console included.
     A panel that names no area is placed after the named ones, and on a host
     that shows the energy and host panels every row up to the breakroom is
     taken: lab and the console would be dropped below the breakroom. */
  .stage {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "floor" "doors" "desk" "lab" "console" "epics" "energy" "host" "break";
  }
  .floor { display: block; grid-area: floor; }
  /* Here the work order is a panel in the column: it scrolls away with the
     board instead of travelling under the header, and it fills the column as
     the board does. */
  .desk { display: block; grid-area: desk; padding-top: 72px; }
  .monitor { position: static; display: block; min-height: 0; }
  .screen { min-height: 0; }
  .monitor-base { display: none; }
}

/* Just above the width where the menu takes a row of its own the header is
   tight: close the gaps so it stays on one row. */
@media (min-width: 1280px) and (max-width: 1359px) {
  .topbar, .menu { gap: 0 12px; }
  .topbar > .gate { margin-left: 0; }
}

@media (max-width: 1279px) {
  /* One row of links beside the wordmark row: what the manual and Protolab
     headers, which hold four links, still make. */
  :root { --header: 128px; }
  /* The front page wraps its menu, so its band is the wordmark row plus two
     rows of links. Only this page has .desk. */
  :root:has(.desk) { --header: 174px; }
  .topbar { flex-wrap: wrap; }
  .menu { order: 3; flex-basis: 100%; margin-left: 0; }
  /* Wrapping, not a row that scrolls with its scrollbar hidden: below about
     870px the links past the edge could only be reached by an invisible swipe. */
  .topbar:not(.topbar-short) > .menu { flex-wrap: wrap; }
  .topbar-short > .menu { overflow-x: auto; scrollbar-width: none; }
  .topbar-short > .menu::-webkit-scrollbar { display: none; }
  .topbar > .gate { margin-left: auto; }
  .floor-head { margin-top: 24px; }
  /* The stack is read as one run of panels here, so the gaps between them close
     to one grid step under the wide stage's. */
  .board-wrap, .lab, .console, .doors, .epics { margin-top: 40px; }

  /* Four signs no longer fit side by side: each turns sideways, its scene at the
     native 240 by 130 beside the text. */
  .stations { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .sign {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    grid-template-rows: auto auto 1fr auto;
    column-gap: 16px;
  }
  .scene { grid-row: 1 / -1; width: 240px; align-self: start; }
  .sign h2 { margin-top: 0; }
  .slot { min-height: 0; }
}

@media (max-width: 899px) {
  .lab-body { grid-template-columns: minmax(0, 1fr); }
  .lab-scene img { width: calc(100% - 2 * var(--edge)); max-width: 400px; height: auto; aspect-ratio: 400 / 280; }
  .cabinet { grid-template-columns: minmax(0, 1fr); }
  .doors { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 699px) {
  #console-out { height: 320px; padding: 8px; }
  .stage { padding: 0 16px; }
  :root { --header: 120px; }
  /* A phone width wraps the front page menu into three rows. */
  :root:has(.desk) { --header: 204px; }
  .topbar { padding: 8px 8px 0; gap: 0 8px; }
  .source, .topbar > .gate { padding: 4px 8px; }
  .menu { padding: 0 8px; }
  .brand img { width: auto; height: 40px; }
  .brand span, .brand .wordmark, .brand small { display: none; }

  .sign { display: flex; }
  .scene { width: calc(100% - 2 * var(--edge)); }
  .sign h2 { margin-top: 8px; }

  .doors { gap: 16px 12px; }
  .door { padding: 8px; }

  .board-tools label { flex: 1 1 100%; }
  .row { grid-template-columns: 56px minmax(0, 1fr); row-gap: 0; }
  .row .row-stage { grid-column: 2; text-align: left; }
  .epic-row { grid-template-columns: max-content minmax(0, 1fr); row-gap: 8px; }
  .epic-bar, .epic-count { grid-column: 2; text-align: left; }
  .epic-body { padding-left: 16px; }
  .order-title, .order-facts, .order-foot { margin-top: 8px; }
  /* On a phone the monitor stays over the board, so the history facts pair up. */
  .order-facts { display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; }
  .order-facts div:nth-child(-n + 2) { grid-template-columns: minmax(64px, max-content) 1fr; column-gap: 8px; }
  .order-facts div:nth-child(3) { margin-top: 0; }
  .order-facts div:nth-child(n + 3) { grid-column: auto; grid-template-columns: 1fr; gap: 0; margin-top: 8px; }

  /* The logo is 77 columns wide: at half size it fits, and Topaz is at its native 8px. */
  .ascii pre { font: 8px/8px var(--font-code); }
  .footer { padding: 24px 16px 32px; }
}

/* A host's notes (host-bridge.js; the chips are in panels.css, and in
   manual.css for /dashboard). Under a sign's ticket, under a row's title with
   the row's rule below both, and on the monitor in the screen's colours. */
.slot > .host-notes { display: flex; margin-top: 4px; }
.rows li > .host-notes { display: flex; padding: 0 16px 12px calc(72px + 32px); }
.rows li:has(> .host-notes) { border-bottom: 1px solid var(--rule); }
.rows li:has(> .host-notes) .row { border-bottom: 0; }
.rows li:last-child:has(> .host-notes) { border-bottom: 0; }
.lab .has-link > .host-notes { grid-column: 1 / -1; }
.order-title .host-note { color: var(--screen-text); background: none; border-color: var(--screen-quiet); }
.order-title a.host-note { color: var(--surface); }
