/*
 * Steps to victory — home page §D: a city selector and six compact gauges.
 *
 * Each condition in src/engine/victory.ts is a round gauge in the signage
 * register: ink ring, white face, tick marks, a red band from NEEDED to the
 * end of the sweep, a blue tick at TODAY, an ink needle, the figure in Barlow
 * Condensed under the hub. The markup ships with one metro's figures and the
 * needle at needed, so the section is complete with scripts off; js/victory.js
 * re-runs the engine's arithmetic for the chosen metro and swings each needle
 * from today to needed once per change. The script writes one custom property
 * per gauge (--a, the needle angle) and the band/red-line geometry.
 *
 * prefers-reduced-motion: no swing; the needle is simply placed.
 */

/* The shared face (ring, ticks) every gauge <use>s. Zero-size, never display:none — that breaks <use> in Safari. */
.gauge-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

.victory { margin-top: 0.5rem; }

/* ── The selector: a station plate and a plate-styled <select> ─────────── */

.victory__pick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 0;
  margin-bottom: 1.75rem;
  transform-origin: 0 0;
}
.victory__label { min-height: 2.75rem; cursor: pointer; }
.victory__select {
  appearance: none;
  -webkit-appearance: none;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.125rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
  color: var(--ink);
  background-color: var(--surface);
  border: 2px solid var(--ink);
  border-radius: 0;
  min-height: 2.75rem;
  min-width: 16rem;
  max-width: 100%;
  padding: 0.5rem 2.4rem 0.45rem 0.9rem;
  cursor: pointer;
  /* The chevron, drawn: two gradient triangles, so it is ink in both themes. */
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 1.2rem) 50%, calc(100% - 0.85rem) 50%;
  background-size: 0.35rem 0.35rem;
  background-repeat: no-repeat;
}
.victory__select:hover { background-color: var(--ground-3); }
.victory__select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.victory__basis {
  flex-basis: 100%;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--ink-3);
  line-height: 1.5;
}
.victory__basis b { color: var(--ink); font-weight: 500; }
.victory__basis small { font-size: inherit; }
/* A metro with no NTD record: the basis line still reads as a sentence. */
.victory__basis[data-ntd="no"] b[data-victory-upt] { color: var(--ink-3); }

/* ── The six gauges ─────────────────────────────────────────────────────── */

.gauges {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 1.5rem 2rem;
  grid-template-columns: minmax(0, 1fr);
  border-top: 2px solid var(--ink);
  padding-top: 1.5rem;
}
@media (min-width: 680px) { .gauges { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1040px) { .gauges { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2rem 2.5rem; } }

/* The dial at the left, the words at the right: a specification row, not a card. */
.gauge {
  display: grid;
  grid-template-columns: 7.25rem minmax(0, 1fr);
  gap: 0 1rem;
  align-items: start;
  min-width: 0;
  transform-origin: 0 0;
}
.gauge__dial { display: block; width: 100%; height: auto; overflow: visible; margin-top: -0.4rem; }
.gauge__ring { fill: var(--ground); stroke: var(--ink); stroke-width: 6; }
.gauge__tick { stroke: var(--ink-2); stroke-width: 1.5; }
.gauge__tick--major { stroke: var(--ink); stroke-width: 2.5; }
/* The red band runs from needed to the end of the sweep: the zone you have to be in. */
.gauge__band { fill: none; stroke: var(--crit); stroke-width: 8; }
.gauge__redline { stroke: var(--crit); stroke-width: 2.5; }
/* Where the metro stands today, in the one accent. */
.gauge__today { stroke: var(--accent); stroke-width: 3.5; stroke-linecap: round; }
.gauge__today[hidden] { display: none; }

.gauge__needle {
  transform-box: view-box;
  transform-origin: 100px 100px;
  transform: rotate(var(--a, 72deg));
  will-change: transform;
}
.gauge__needle polygon { fill: var(--ink); }
.gauge__needle circle { fill: var(--ink); stroke: var(--ground); stroke-width: 2; }

.gauge__fig {
  font-family: var(--display);
  font-weight: 600;
  font-size: 34px;
  fill: var(--ink);
  text-anchor: middle;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.gauge__unit { font-family: var(--mono); font-size: 13px; font-weight: 500; fill: var(--ink-2); }

.gauge__text { min-width: 0; }
.gauge__cap {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 0.2rem;
}
.gauge__name {
  font-family: var(--display);
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1.05;
  color: var(--ink);
  margin: 0 0 0.45rem;
}
/* today → needed, as a mono ledger line. */
.gauge__path {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.5rem;
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--ink-3);
  margin: 0 0 0.45rem;
  line-height: 1.4;
}
.gauge__path b { color: var(--ink); font-weight: 500; }
.gauge__path [data-needed] { color: var(--crit); }
/* --ink-4 measured 2.02:1 here. The arrow is aria-hidden, so it is decoration
   by the letter of SC 1.4.3, but it is the only thing saying today -> needed
   and at that ratio it was barely visible. */
.gauge__arrow { color: var(--ink-3); }
.gauge__line { font-size: 0.875rem; color: var(--ink-2); line-height: 1.5; margin: 0; }
.gauge__line b { color: var(--ink); font-weight: 600; }

.victory__foot {
  font-size: 0.8125rem;
  color: var(--ink-3);
  line-height: 1.55;
  margin: 1.75rem 0 0;
  max-width: 78ch;
}
.victory__foot b { color: var(--ink-2); font-weight: 500; font-family: var(--mono); font-size: 0.75rem; }
/* Inside a method fold the note carries the fold's own top margin. */
.method .victory__foot { margin-top: 0.75rem; }

/* A phone: two gauges to a row, each a dial over its words, so six dials are
   three rows and not a column of six. */
@media (max-width: 679.98px) {
  .gauges { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.75rem 1rem; }
  .gauge { grid-template-columns: minmax(0, 1fr); gap: 0.4rem 0; }
  .gauge__dial { max-inline-size: 9.5rem; margin-top: 0; }
  .gauge__name { font-size: 1.25rem; }
}

/* Phones: the label and select on their own rows. */
@media (max-width: 479.98px) {
  .victory__label { width: 100%; }
  .victory__select { width: 100%; min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .gauge, .victory__pick, .gauge__needle { transform: none; }
  .gauge__needle { transform: rotate(var(--a, 72deg)); }
}
