/* Waterfall: this game's own styles. The site's look, the same on every page
   (tokens for both themes, base, controls, top bar, floating panels, the stage
   panel and the end-of-level card), is ../site.css, loaded first. This file
   adds only what this game draws, using the site's tokens: it names no colour
   and no corner of its own. Colour is for the stretches of a request, the paints and state. See _doctrine/design.md. */

/* ---- this game's own labels, in the site's label style ---- */

.chart figcaption {
  font: 600 11px/1.4 var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

#field:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ---- layout: fixes, picture and waterfall, stage ----
   Wide: fixes on the left, the picture and waterfall in the middle, the stage
   on the right. Medium: the picture and waterfall beside one column that holds
   the stage and then the fixes. Narrow: one column, and the page scrolls. */

main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 304px;
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: 'controls centre mission';
}

.side {
  display: contents;
}

.controls,
.mission {
  padding: 16px;
  overflow-y: auto;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.controls {
  grid-area: controls;
  border-right: 1px solid var(--line);
}

.mission {
  grid-area: mission;
  border-left: 1px solid var(--line);
  gap: 12px;
}

.centre {
  grid-area: centre;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* ---- the fixes ---- */

.control {
  display: flex;
  flex-direction: column;
}

.knobs {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 -8px 8px;
}

.knob {
  padding: 6px 8px 7px;
  border-left: 3px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.knob h3 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 5px;
}

.knob.chosen {
  background: var(--sunken);
  border-left-color: var(--focus);
}

.knob.chosen h3 {
  color: var(--ink);
}

/* A knob's settings are a joined control, as the speed is. The panel is narrow,
   so unlike the ones in the top bar they may run onto a second line. */
.knob .joined {
  flex-wrap: wrap;
  row-gap: 4px;
}

/* what a fix costs, at the end of its heading */
.cost {
  margin-left: auto;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

/* a fix that is on, and so being paid for */
.knob.changed .cost {
  color: var(--accent-text);
}

.budget {
  font: 12.5px/1.4 var(--font-mono);
  color: var(--ink-2);
}

.budget.over {
  color: var(--bad-text);
}

/* ---- the picture ---- */

.field-wrap {
  position: relative;
  flex: 1 1 0;
  min-height: 340px;
  overflow: hidden;
  background-color: color-mix(in srgb, var(--level) var(--tint), var(--paper));
  background-image: radial-gradient(color-mix(in srgb, var(--level) 30%, var(--line-strong)) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* the rule in the level's colour, drawn over the picture */
.field-wrap::after {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: var(--level);
}

/* The picture reaches nearly to the foot: nothing is drawn in its lowest 50
   units, where the key floats, and every unit of height makes the cells' words
   bigger when the waterfall leaves the picture little room. */
#field {
  position: absolute;
  inset: 10px 8px 14px;
  width: calc(100% - 16px);
  height: calc(100% - 24px);
  user-select: none;
}

#field text,
#waterfall text,
.chart text {
  font-family: var(--font-mono);
}

.wire-line {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 0.75;
}

/* a wire nothing is sent down, and the link between the cache and the browser */
.wire-line.idle {
  stroke-dasharray: 3 6;
}

.node {
  cursor: pointer;
}

/* the line work of the story pictures */
.box {
  fill: var(--box);
  stroke: var(--box-line);
  stroke-width: 1.2;
  stroke-linejoin: round;
}

.detail {
  fill: none;
  stroke: var(--box-line);
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.glyph {
  fill: var(--box-line);
}

/* ---- the cells: the Panel look (chosen 2026-10-13) ----
   Every box an instrument cell: a title bar with an icon, the name and a lamp;
   the setting; one live number over an eight-step gauge; a short note. The
   selected cell's title bar inverts. Thin lines throughout. */

#field .box {
  fill: var(--panel);
  stroke: var(--box-line);
  stroke-width: 0.75;
}

#field .bar {
  fill: var(--sunken);
}

#field .rule {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 0.75;
}

#field .icon {
  fill: none;
  stroke: var(--ink-2);
  stroke-width: 1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#field .node .title {
  fill: var(--ink-2);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.08em;
}

#field .node .label {
  fill: var(--ink);
  font-size: 11.5px;
  font-weight: 500;
}

#field .node .label.tight {
  font-size: 9.5px;
}

#field .node .key {
  fill: var(--muted);
  font-size: 9.5px;
}

#field .node .value {
  fill: var(--ink-2);
  font-size: 9.5px;
}

#field .node .sub {
  fill: var(--muted);
  font-size: 9.5px;
}

#field .node .sub.warn {
  fill: var(--warn-text);
}

.gauge {
  fill: var(--line);
}

.gauge.on {
  fill: var(--muted);
}

.lamp {
  fill: var(--ok);
}

.lamp.warn {
  fill: var(--write);
}

.lamp.idle {
  fill: var(--line-strong);
}

/* selected: the title bar inverts, and the screen's frame darkens */
#field .node.selected .box {
  stroke: var(--ink);
  stroke-width: 1;
}

#field .node.selected .bar {
  fill: var(--ink);
}

#field .node.selected .icon {
  stroke: var(--paper);
}

#field .node.selected .title {
  fill: var(--paper);
}

/* the screen has no title bar: its name, under it, stays as it is */
#field .node.page.selected .title {
  fill: var(--ink);
}

/* not in use: a dashed border */
#field .node.idle .box {
  stroke-dasharray: 3 3;
}

/* the little screen: a frame, the fold, and the blocks of the page as they paint */
.page .screen {
  fill: var(--panel);
}

.fold {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 1;
  stroke-dasharray: 4 3;
}

.fold-note {
  fill: var(--muted);
  font-size: 9px;
}

/* a click on a block is a click on the screen it is part of */
.blocks {
  pointer-events: none;
}

.block {
  fill: var(--line-strong);
  stroke: none;
}

/* room kept for something that has not arrived */
.block.held {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 1;
  stroke-dasharray: 3 2;
}

.block.nav {
  fill: var(--muted);
}

.block.hero.shown,
.block.tile.shown {
  fill: var(--static);
}

.block.title.shown {
  fill: var(--ink);
}

/* text in its fallback font */
.block.title.plain {
  fill: var(--muted);
}

.block.button.shown {
  fill: var(--accent);
}

/* painted, and not yet wired up */
.block.button.dead {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
}

.block.widget.shown {
  fill: var(--flood);
}

.block.widget.still {
  fill: none;
  stroke: var(--flood);
  stroke-width: 1.5;
}

.block-name {
  fill: var(--paper);
  font-size: 9.5px;
  font-weight: 600;
  pointer-events: none;
}

.tap {
  fill: none;
  stroke-width: 2;
  pointer-events: none;
}

.tap.waiting {
  stroke: var(--bad);
}

.tap.answered {
  stroke: var(--ok);
}

/* files in flight: a ring going out, a dot coming back */
.dot {
  pointer-events: none;
}

.dot.ask {
  fill: var(--box);
  stroke: var(--read);
  stroke-width: 1.5;
}

.dot.data {
  fill: var(--read);
}

.dot.kept {
  fill: var(--static);
}

/* what the marks are: the floating key of the site, in the corner where Scaling has its own */
.dot-key {
  position: absolute;
  left: 12px;
  bottom: 12px;
  gap: 4px 14px;
  max-width: calc(100% - 24px);
  min-height: 0;
  padding: 6px 12px;
  font: 12px/1.5 var(--font-sans);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  pointer-events: none;
}

/* ---- the waterfall: a row a request, time along the bottom from zero ---- */

.board {
  flex: none;
  padding: 10px 16px 12px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.board-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 12px;
  margin-bottom: 6px;
}

.board-head h2 {
  margin: 0;
}

/* drawn 720 units wide: it is not let past 960px, where its words would be 14px */
#waterfall {
  display: block;
  width: 100%;
  max-width: 960px;
  height: auto;
}

.row-name {
  fill: var(--ink-2);
  font-size: 10.5px;
}

/* the file that is the largest paint */
.row-name.lcp {
  fill: var(--ink);
  font-weight: 700;
}

/* once a stage is over, the file the debrief names */
.row-name.culprit {
  fill: var(--bad-text);
  font-weight: 700;
}

.row-size,
.row-tag {
  fill: var(--muted);
  font-size: 10px;
}

.bar {
  stroke: none;
}

.bar.queue {
  fill: var(--line-strong);
}

.bar.connect {
  fill: var(--write);
}

.bar.wait {
  fill: var(--flood);
}

.bar.download {
  fill: var(--read);
}

.bar.kept {
  fill: var(--static);
}

.bar.task {
  fill: var(--muted);
}

.bar.long {
  fill: var(--bad);
}

.bar.stop {
  fill: var(--write);
}

.tapped {
  fill: none;
  stroke: var(--ok);
  stroke-width: 1.5;
}

.tapped.slow {
  stroke: var(--bad);
}

/* from the file that asked for this one */
.chain {
  fill: none;
  stroke: var(--wire);
  stroke-width: 1;
}

.mark {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.25;
}

.mark.fcp {
  stroke: var(--ok);
}

.mark.lcp {
  stroke: var(--ink);
}

.mark-name {
  fill: var(--muted);
  font-size: 9px;
  font-weight: 600;
}

.mark-name.fcp {
  fill: var(--ok-text);
}

.mark-name.lcp {
  fill: var(--ink);
}

.cursor {
  fill: none;
  stroke: var(--focus);
  stroke-width: 1;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
  min-height: 18px;
  font: 12px/1.5 var(--font-mono);
  color: var(--muted);
}

.legend li {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.legend li.over {
  color: var(--bad-text);
}

/* the measures of the load, one to a line, beside the chart of bytes */
.board-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 260px);
  gap: 8px 20px;
  align-items: start;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.marks {
  flex-direction: column;
  gap: 1px;
  color: var(--ink-2);
}

.marks li {
  white-space: normal;
}

/* the same marks as on the wires, for the key at the foot of the picture */
.swatch {
  flex: none;
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--read);
}

.swatch.ask {
  background: var(--box);
  border: 1.5px solid var(--read);
}

.swatch.data {
  background: var(--read);
}

.swatch.kept {
  background: var(--static);
}

/* a piece of each bar or line, for the keys */
.key {
  flex: none;
  width: 12px;
  height: 0;
  border-top: 6px solid var(--muted);
}

.key.none {
  border-top-color: transparent;
}

.key.queue {
  border-top-color: var(--line-strong);
}

.key.connect {
  border-top-color: var(--write);
}

.key.wait {
  border-top-color: var(--flood);
}

.key.download {
  border-top-color: var(--read);
}

.key.task {
  border-top-color: var(--muted);
}

.key.long {
  border-top-color: var(--bad);
}

.key.stop {
  border-top: 3px solid var(--write);
}

.key.tapped {
  border-top: 2px solid var(--ok);
}

.key.ttfb,
.key.fcp,
.key.lcp {
  width: 0;
  height: 12px;
  margin: 0 5px;
  border-top: 0;
  border-left: 2px solid var(--muted);
}

.key.fcp {
  border-left-color: var(--ok);
}

.key.lcp {
  border-left-color: var(--ink);
}

.key.cls,
.key.inp,
.key.kb {
  border-top-color: transparent;
}

.key.line-now {
  border-top: 2px solid var(--read);
}

.key.line-before {
  border-top: 2px dashed var(--muted);
}

.key.limit {
  border-top: 1px dashed var(--ink);
}

/* ---- the chart: numbers on the axis from zero, time along the bottom, a key with the values now ---- */

.chart {
  min-width: 0;
  margin: 0;
}

.chart figcaption {
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart svg {
  display: block;
  width: 100%;
  max-width: 300px;
  height: auto;
}

.axis {
  fill: var(--muted);
  font-size: 9.5px;
}

.grid {
  fill: none;
  stroke: var(--line);
  stroke-width: 1;
}

.frame {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 1;
}

.limit {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1;
  stroke-dasharray: 5 3;
}

.line {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.75;
  stroke-linejoin: round;
}

.line.now {
  stroke: var(--read);
}

.line.before {
  stroke-dasharray: 4 3;
}

/* ---- the stage ---- */

.needs li.missed::before {
  border-color: var(--bad);
}

/* ---- medium screens: two columns ---- */

@media (max-width: 1279px) {
  main {
    grid-template-columns: minmax(0, 1fr) 304px;
    grid-template-areas: 'centre side';
  }

  .side {
    grid-area: side;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: var(--panel);
    border-left: 1px solid var(--line);
  }

  .controls,
  .mission {
    overflow-y: visible;
    border: 0;
  }

  .mission {
    order: 1;
    border-bottom: 1px solid var(--line);
  }

  .controls {
    order: 2;
  }

  .field-wrap {
    min-height: 320px;
  }
}

/* ---- narrow screens: one column, and the page scrolls ---- */

@media (max-width: 759px) {
  html,
  body {
    height: auto;
    min-height: 100%;
  }

  main {
    display: flex;
    flex-direction: column;
  }

  .side {
    display: contents;
  }

  .centre {
    order: 2;
    overflow-y: visible;
  }

  /* the story first, then the picture and waterfall, then the fixes */
  .mission {
    order: 1;
    border-bottom: 1px solid var(--line);
  }

  .controls {
    order: 3;
    border-top: 1px solid var(--line);
  }

  .field-wrap {
    flex: none;
    height: 56vw;
    min-height: 220px;
  }

  .board-body {
    grid-template-columns: minmax(0, 1fr);
  }
}
