/* Training data: 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 tasks and for state. See _doctrine/design.md. */

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

.tally dt,
.chart figcaption {
  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: 320px;
  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);
}

.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 tasks go */
.ticks {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 0.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.node {
  cursor: pointer;
}

.node.right,
.node.wrong,
.node.invalid,
.node.escalated,
.node.inbox {
  cursor: default;
}

/* 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 (three on the model);
   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;
}

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

/* the trays keep their colours: accepted green, bad red, rejected amber, leaked purple */
#field .node.right .icon {
  stroke: var(--ok);
}

#field .node.wrong .icon {
  stroke: var(--bad);
}

#field .node.invalid .icon {
  stroke: var(--warn);
}

#field .node.escalated .icon {
  stroke: var(--flood);
}

#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);
}

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

#field .caption {
  fill: var(--muted);
  font-size: 9px;
}

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

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

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

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

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

.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 */
#field .node.selected .box {
  stroke: var(--ink);
  stroke-width: 1;
}

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

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

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

/* down: a red border; not in use: a dashed one */
#field .node.down .box {
  stroke: var(--bad);
}

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

/* the last tickets to end, in their cell */
.tile {
  fill: var(--line);
}

.tile.right {
  fill: var(--ok);
}

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

.tile.invalid {
  fill: var(--warn);
}

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

/* tickets: the colour says what kind; a square once it has ended */
.dot {
  pointer-events: none;
  fill: var(--read);
  stroke: var(--panel);
  stroke-width: 1;
}

.dot.ambiguous,
.dot.tie,
.dot.long {
  fill: var(--write);
}

.dot.dup,
.dot.family,
.dot.local {
  fill: var(--static);
}

.dot.hard,
.dot.rl,
.dot.easy {
  fill: var(--flood);
}

.dot.bench,
.dot.scraped {
  fill: var(--box);
  stroke: var(--muted);
  stroke-width: 1.5;
}

.dot.pii {
  fill: var(--ink);
  stroke: var(--bad);
  stroke-width: 1.5;
}

.dot.right {
  fill: var(--ok);
}

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

.dot.invalid {
  fill: var(--warn);
}

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

.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.wrong {
  stroke: var(--bad);
}

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

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

.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, 2.2fr);
  gap: 16px;
  align-items: start;
}

.readout {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

/* four trays and the money: three a row */
.tally {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

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

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

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

.why h3,
.arriving h3 {
  margin-bottom: 5px;
}

.reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  min-height: 24px;
}

.reasons li {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 1px 8px;
  font: 12px/1.6 var(--font-mono);
  color: var(--ink-2);
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.reasons b {
  color: var(--bad-text);
}

.reasons li.none {
  color: var(--muted);
  background: none;
  border-color: transparent;
  padding-left: 0;
}

.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 tally */
.swatch {
  flex: none;
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--read);
}

.seg.ambiguous,
.swatch.ambiguous,
.seg.tie,
.swatch.tie,
.seg.long,
.swatch.long {
  background: var(--write);
}

.seg.dup,
.swatch.dup,
.seg.family,
.swatch.family,
.seg.local,
.swatch.local {
  background: var(--static);
}

.seg.hard,
.swatch.hard,
.seg.rl,
.swatch.rl,
.seg.easy,
.swatch.easy {
  background: var(--flood);
}

.seg.bench,
.swatch.bench,
.seg.scraped,
.swatch.scraped {
  background: var(--line-strong);
}

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

.swatch.right,
.swatch.wrong,
.swatch.invalid,
.swatch.escalated {
  border-radius: 2px;
}

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

.swatch.wrong {
  background: var(--bad);
}

.swatch.invalid {
  background: var(--warn);
}

.swatch.escalated {
  background: var(--flood);
}

/* ---- charts: a scale from zero with numbers, time along the bottom, a key ---- */

.charts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.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%;
  height: auto;
}

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

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

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

.mark {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1;
  stroke-dasharray: 2 3;
}

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

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

.line.right {
  stroke: var(--ok);
}

.line.wrong {
  stroke: var(--bad);
}

.line.invalid {
  stroke: var(--warn);
}

.line.escalated {
  stroke: var(--flood);
}

.line.took {
  stroke: var(--flood);
}

/* a short piece of each line, for the key under a chart */
.key {
  flex: none;
  width: 12px;
  height: 0;
  border-top: 2px solid var(--read);
}

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

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

.key.invalid {
  border-color: var(--warn);
}

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

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

.key.limit {
  border-top: 1px dashed 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);
  }

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

/* ---- 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: 56vw;
    min-height: 220px;
  }

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

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