/* Pipeline: 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 records and for state. See _doctrine/design.md. */

/* ---- this game's own labels and numbers, in the site's label and number styles ---- */

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

.tally dd {
  font: 600 13px/1.4 var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tally dd.warn {
  color: var(--bad-text);
}

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

/* ---- layout: knobs, picture and dashboard, stage ----
   Wide: knobs on the left, the picture and dashboard in the middle, the stage
   on the right. Medium: the picture and dashboard beside one column that holds
   the knobs and then the stage. 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 knobs ---- */

.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;
}

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

.field-wrap {
  position: relative;
  flex: 1 1 0;
  min-height: 260px;
  overflow: hidden;
  background-color: color-mix(in srgb, var(--level) var(--tint), var(--paper));
}

/* 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);
}

#field {
  position: absolute;
  inset: 10px 8px 8px;
  width: calc(100% - 16px);
  height: calc(100% - 18px);
  user-select: none;
}

#field text {
  font-family: var(--font-mono);
  text-anchor: middle;
}

/* ---- 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. */

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

.wire-line.idle {
  stroke-dasharray: 3 6;
}

/* chevrons along a wire, pointing the way records go */
.ticks {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 0.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.node {
  cursor: pointer;
}

.box {
  fill: var(--panel);
  stroke: var(--box-line);
  stroke-width: 0.75;
  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);
}

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

.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;
  text-transform: uppercase;
  text-anchor: start;
}

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

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

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

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

.node .sub {
  fill: var(--muted);
}

#field .node .sub {
  font-size: 9.5px;
  text-anchor: start;
}

.node .sub.warn {
  fill: var(--warn-text);
  font-weight: 600;
}

/* a short cell (one of several sources, the lookup source) keeps its words under it */
#field .node[data-short] .label,
#field .node[data-short] .sub {
  text-anchor: middle;
}

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

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

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

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

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

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

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

/* selected: the title bar inverts */
.node.selected .box {
  stroke: var(--ink);
  stroke-width: 1;
}

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

#field .node.selected:not([data-short]) .icon {
  stroke: var(--paper);
}

#field .node.selected:not([data-short]) .title {
  fill: var(--paper);
}

.node.idle .box {
  stroke-dasharray: 3 3;
}

.node.full .box {
  stroke: var(--write);
}

.node.down .box {
  stroke: var(--bad);
}

.node.tray,
.node.house {
  cursor: default;
}

.node.house .label {
  display: none;
}

/* the quarantine: a plain cell, its words centred under it */
.node.tray .box {
  rx: 2px;
  stroke-dasharray: 5 4;
}

.node.tray.holding .box {
  stroke: var(--bad);
}

#field .node.tray .label {
  fill: var(--ink-2);
  font-size: 10px;
  font-weight: 500;
  text-anchor: middle;
}

#field .node.house .value {
  fill: var(--muted);
  font-weight: 500;
}

/* the words under the warehouse's last rows */
#field .caption {
  fill: var(--muted);
  font-size: 9px;
  text-anchor: start;
}

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

.tile.good,
.tile.fixed {
  fill: var(--ok);
}

.tile.dup {
  fill: var(--flood);
}

.tile.bad {
  fill: var(--bad);
}

/* records: the colour says what kind, a square is a format the check has not been taught */
.dot {
  pointer-events: none;
  fill: var(--read);
  stroke: var(--panel);
  stroke-width: 1;
}

.dot.dup {
  fill: var(--flood);
}

.dot.late {
  fill: var(--write);
}

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

.dot.junk {
  fill: var(--bad);
}

.dot.poison {
  fill: var(--ink);
  stroke: var(--bad);
  stroke-width: 2;
}

.dot.odd,
.dot.history {
  fill: var(--box);
  stroke: var(--bad);
  stroke-width: 2.5;
}

.dot.history {
  stroke: var(--read);
}

.dot.ref {
  fill: var(--muted);
}

.dot.v2 {
  stroke: var(--ink);
  stroke-width: 1.5;
}

.dot.half {
  fill-opacity: 0.3;
  stroke: var(--bad);
  stroke-width: 1.5;
}

.fx {
  pointer-events: none;
  fill: none;
  stroke-width: 1;
  stroke-linecap: round;
  transform-box: fill-box;
  transform-origin: center;
  animation: fade 0.6s ease-out forwards;
}

.fx.land {
  stroke: var(--ok);
  animation-name: ring;
}

.fx.land.dup {
  stroke: var(--flood);
}

.fx.land.bad {
  stroke: var(--bad);
}

/* lost and landed: thin marks, as the rest of the cell */
.fx.lost {
  stroke: var(--bad);
  stroke-width: 1.25;
}

@keyframes ring {
  from {
    transform: scale(0.6);
    opacity: 0.9;
  }
  to {
    transform: scale(1.8);
    opacity: 0;
  }
}

@keyframes fade {
  from {
    opacity: 1;
  }
  to {
    transform: translateY(-12px);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fx {
    animation-duration: 0.01s;
  }
}

/* ---- the dashboard ---- */

.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: 8px;
}

.board-head h2 {
  margin: 0;
}

.board-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 16px;
  align-items: start;
}

.tally {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.tally div {
  min-width: 0;
  padding: 6px 10px 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

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

.tally dd {
  font-size: 18px;
  line-height: 1.3;
}

.arriving h3 {
  margin-bottom: 6px;
}

.mix {
  display: flex;
  gap: 2px;
  height: 10px;
  margin-bottom: 6px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--line);
}

.seg {
  flex: 1 1 0;
  min-width: 3px;
  background: var(--read);
}

.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;
}

/* the same colours as the dots, for the bar, its key and the dashboard */
.swatch {
  flex: none;
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--read);
}

.swatch.good,
.swatch.dup,
.swatch.junk,
.swatch.gone {
  border-radius: 2px;
}

.swatch.good {
  background: var(--ok);
}

.seg.dup,
.swatch.dup {
  background: var(--flood);
}

.seg.late,
.swatch.late {
  background: var(--write);
}

.seg.amend,
.swatch.amend {
  background: var(--static);
}

.seg.junk,
.swatch.junk {
  background: var(--bad);
}

.seg.odd {
  background: color-mix(in srgb, var(--bad) 45%, var(--panel));
}

.swatch.odd,
.swatch.history,
.swatch.gone {
  background: var(--panel);
  border: 2.5px solid var(--bad);
}

.seg.history {
  background: color-mix(in srgb, var(--read) 45%, var(--panel));
}

.swatch.history {
  border-color: var(--read);
}

.swatch.gone {
  border: 1.5px dashed var(--muted);
}

.seg.poison,
.swatch.poison {
  background: var(--ink);
}

.seg.v2,
.swatch.v2 {
  background: var(--read);
  border-radius: 1px;
  box-shadow: inset 0 0 0 1.5px var(--ink);
}

/* ---- 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;
  }

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

/* ---- 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 dashboard, then the knobs */
  .mission {
    order: 1;
    border-bottom: 1px solid var(--line);
  }

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

  .field-wrap {
    flex: none;
    height: 46vw;
    min-height: 200px;
  }

  .tally {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
