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

/* ---- buttons ---- */

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

/* the one action that matters most when it goes wrong */
button.strong {
  font-weight: 600;
  border-color: var(--accent-line);
}

/* the step in use: the same wash as the one in use in a joined control */
.steps button.on {
  position: relative;
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: var(--accent-line);
  opacity: 1;
}

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

main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 236px 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 release controls ---- */

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

.steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 6px;
}

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

.steps button {
  padding: 5px 4px;
  font: 500 12.5px/1.4 var(--font-mono);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.marks {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 12px;
  color: var(--muted);
}

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

i.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

i.dot.read {
  background: var(--read);
}

i.dot.write {
  background: var(--write);
}

i.dot.flagged {
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 3.5px var(--ink);
}

i.mark {
  display: inline-block;
  width: 10px;
  height: 10px;
}

i.mark.ok {
  border: 2px solid var(--ok);
  border-radius: 50%;
}

i.mark.bad {
  background:
    linear-gradient(45deg, transparent 42%, var(--bad) 42%, var(--bad) 58%, transparent 58%),
    linear-gradient(-45deg, transparent 42%, var(--bad) 42%, var(--bad) 58%, transparent 58%);
}

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

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

.ticks.idle {
  opacity: 0.4;
}

/* 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 component 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 chosen region's router inverts its title bar. 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;
}

#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;
  text-anchor: end;
}

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

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

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

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

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

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

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

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

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

/* the chosen region's router: 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);
}

/* failing or down: a red border; no traffic: a dashed one */
#field .version.losing .box,
#field .node.down .box {
  stroke: var(--bad);
}

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

.zone {
  cursor: pointer;
}

.zone rect {
  fill: color-mix(in srgb, var(--level) 5%, transparent);
  stroke: color-mix(in srgb, var(--level) 45%, var(--line-strong));
  stroke-width: 0.75;
  stroke-dasharray: 6 6;
}

.zone text {
  fill: var(--muted);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.zone.selected rect {
  stroke: var(--focus);
  stroke-dasharray: none;
}

.zone.selected text {
  fill: var(--ink);
}

.dot {
  pointer-events: none;
  stroke: var(--panel);
  stroke-width: 1;
}

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

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

.dot.flagged {
  stroke: var(--ink);
  stroke-width: 1.25;
}

.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.served {
  stroke: var(--ok);
  animation-name: ring;
}

.fx.failed {
  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 readings ---- */

.signals {
  flex: none;
  padding: 10px 16px 12px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.signals-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
}

.signals-head h2 {
  margin: 0;
}

.signals-head .note {
  flex: 1 1 200px;
  min-width: 0;
}

/* the tabs for the readings may run onto a second line on a narrow screen */
.signals-head .joined {
  flex-wrap: wrap;
  row-gap: 4px;
}

.tag {
  padding: 0 6px;
  font: 500 11px/1.5 var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--sunken);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}

.signals-body {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) minmax(0, 1.4fr);
  gap: 12px;
  align-items: stretch;
}

.reading {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.reading.new {
  border-color: var(--ink);
}

.reading h3 span {
  text-transform: none;
}

.reading b {
  font: 600 18px/1.3 var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reading p {
  font: 12px/1.35 var(--font-mono);
  color: var(--muted);
  min-height: 2.7em;
  overflow-wrap: anywhere;
}

.chart-wrap {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* the chart with its scale: numbers down the left, time along the bottom */
.plot {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 6px;
}

.axis-y {
  position: relative;
  font: 10.5px/1 var(--font-mono);
  color: var(--muted);
}

.axis-y span {
  position: absolute;
  right: 0;
  transform: translateY(-50%);
  white-space: nowrap;
}

/* each number sits on its grid line: 8, 39 and 70 of the chart's 76 */
.axis-y span:nth-child(1) {
  top: 10.5%;
}

.axis-y span:nth-child(2) {
  top: 51.3%;
}

.axis-y span:nth-child(3) {
  top: 92.1%;
}

.axis-x {
  display: flex;
  justify-content: space-between;
  margin-left: 58px;
  font: 10.5px/1 var(--font-mono);
  color: var(--muted);
}

.chart {
  display: block;
  width: 100%;
  height: 104px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--paper);
}

/* grid in the hairline colour, a frame in the stronger one, lines 1.75 wide:
   the same as the charts of the other games */
.chart .grid {
  fill: none;
  stroke: var(--line);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.chart .line {
  fill: none;
  stroke-width: 1.75;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.chart .line.old {
  stroke: var(--muted);
  stroke-dasharray: 4 3;
}

.chart .line.new {
  stroke: var(--ink);
  stroke-width: 2.25;
}

.chart .line.before {
  stroke: var(--line-strong);
  stroke-width: 1.5;
  stroke-dasharray: 1 4;
  stroke-linecap: round;
}

.chart-key {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  font: 11.5px/1.4 var(--font-mono);
  color: var(--muted);
}

.chart-key .key {
  display: inline-block;
  width: 16px;
  height: 0;
  margin-right: 5px;
  padding: 0;
  vertical-align: middle;
  background: none;
  border: 0;
  border-top: 2px solid var(--ink);
}

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

.chart-key .key.before {
  border-top: 2px dotted var(--line-strong);
}

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

@media (max-width: 1079px) {
  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;
  }

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

  .marks {
    margin-top: 0;
  }
}

/* ---- 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 {
    overflow-y: visible;
  }

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

  .centre {
    order: 2;
  }

  .controls {
    order: 3;
    flex-direction: row;
    flex-wrap: wrap;
    border-bottom: 0;
    border-top: 1px solid var(--line);
  }

  .control {
    flex: 1 1 200px;
  }

  .marks {
    padding-top: 0;
    border-top: 0;
  }

  .field-wrap {
    flex: none;
    height: 70vw;
    min-height: 260px;
    max-height: 520px;
  }

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

  .chart-wrap {
    grid-column: 1 / -1;
  }
}
