/* Variant A: "Survey plate". A traffic-engineering report set in highway-sign type. */
@import url('https://fonts.googleapis.com/css2?family=Overpass:ital,wght@0,300..900;1,300..900&family=Source+Serif+4:ital,opsz,wght@0,8..60,300..700;1,8..60,300..700&display=swap');

:root {
  --paper: #f4f6f5;
  --sheet: #fbfcfb;
  --ink: #17253a;
  --graphite: #5a6577;
  --rule: #d6dee4;
  --grid: #e7ecef;
  --free: #12807f;     /* free-flowing traffic, also used for "current best route" */
  --amber: #e2a01b;    /* busy */
  --red: #c23a2c;      /* jammed, kinks */
  --asphalt: #c5cfd8;  /* road casing */
  --sans: 'Overpass', system-ui, sans-serif;
  --serif: 'Source Serif 4', Georgia, serif;
  --measure: 40rem;
  --wide: 68rem;
}

* { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); }
body { margin: 0; font: 400 1.125rem/1.7 var(--serif); font-optical-sizing: auto; -webkit-font-smoothing: antialiased; }

/* ---------- masthead ---------- */
.masthead { max-width: calc(var(--measure) + 3rem); margin: 0 auto; padding: 5rem 1.5rem 1rem; }
.masthead .venue { font: 600 .95rem/1.3 var(--sans); color: var(--graphite); margin: 0 0 1.25rem; }
.masthead h1 {
  font: 800 clamp(2.4rem, 6vw, 4.6rem)/0.98 var(--sans);
  letter-spacing: -0.02em; margin: 0; width: min(62rem, calc(100vw - 3rem));
}
.masthead .subtitle { font: 400 1.25rem/1.45 var(--serif); font-style: italic; color: var(--graphite); max-width: 36rem; margin: 1.25rem 0 0; }
.masthead .authors { font: 500 .95rem/1.5 var(--sans); margin: 1.5rem 0 0; }
.masthead .links { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; margin-top: .75rem; font: 600 .95rem var(--sans); }
.masthead .links a { color: var(--free); }

/* ---------- essay ---------- */
main { padding: 0 1.5rem 6rem; }
section { max-width: var(--measure); margin: 0 auto; }
section h2 { font: 750 1.75rem/1.2 var(--sans); letter-spacing: -0.01em; margin: 4.5rem 0 1rem; }
.prose p, .prose li { hyphens: auto; }
.prose a { color: var(--free); }
.prose strong { font-weight: 650; }
.prose ol { padding-left: 1.4rem; }
.prose li { margin: .2rem 0; }
.prose li::marker { font: 700 1rem var(--sans); color: var(--free); }
.prose table { width: 100%; border-collapse: collapse; font: 400 .95rem/1.4 var(--sans); margin: 1.5rem 0; font-variant-numeric: tabular-nums; }
.prose th { text-align: left; font-weight: 700; border-bottom: 2px solid var(--ink); padding: .4rem .5rem .4rem 0; }
.prose td { border-bottom: 1px solid var(--rule); padding: .5rem .5rem .5rem 0; vertical-align: top; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: .25rem 0; }
.katex { font-size: 1.04em; }

/* ---------- plates (interactive figures) ---------- */
figure.fig {
  /* break out of the reading column */
  width: min(var(--wide), calc(100vw - 2rem));
  margin: 2.5rem 0 2.5rem 50%;
  transform: translateX(-50%);
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: 3px;
  position: relative;
}
.plate-head { display: flex; align-items: baseline; gap: 1rem; padding: .9rem 1.25rem .6rem; border-bottom: 1px solid var(--rule); font-family: var(--sans); }
.plate-head .no { font-weight: 800; font-size: .95rem; color: var(--free); white-space: nowrap; }
.plate-head .title { font-weight: 700; font-size: 1.05rem; }
.plate-head .hint { margin-left: auto; color: var(--graphite); font-size: .9rem; text-align: right; }
.plate-body { display: grid; grid-template-columns: minmax(0, 1fr) 19rem; }
.plate-body.single { grid-template-columns: 1fr; }
.plate-canvas {
  position: relative; min-height: 22rem;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px; background-position: -1px -1px;
}
.plate-canvas svg { display: block; width: 100%; height: 100%; }
.plate-side { border-left: 1px solid var(--rule); padding: 1rem 1.25rem 1.25rem; font: 400 .92rem/1.45 var(--sans); display: flex; flex-direction: column; gap: 1rem; }
.plate-foot { border-top: 1px solid var(--rule); padding: .75rem 1.25rem; font: 400 .92rem/1.5 var(--serif); color: var(--graphite); }
@media (max-width: 860px) {
  .plate-body { grid-template-columns: 1fr; }
  .plate-side { border-left: 0; border-top: 1px solid var(--rule); }
  .plate-head .hint { display: none; }
  .plate-canvas { min-height: 0; }
  .plate-canvas .legend { position: static !important; padding: .5rem 1rem; }
}

/* readouts */
.readout { display: grid; grid-template-columns: 1fr auto; gap: .15rem .75rem; font-variant-numeric: tabular-nums; }
.readout dt { color: var(--graphite); }
.readout dd { margin: 0; font-weight: 700; text-align: right; }
.big { font: 800 2.1rem/1 var(--sans); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.big-label { color: var(--graphite); font-size: .88rem; margin-top: .2rem; }
.delta.good { color: var(--free); }
.delta.bad { color: var(--red); }

/* controls */
button, select { font: 650 .92rem var(--sans); color: var(--ink); }
button {
  background: var(--sheet); border: 1.5px solid var(--ink); border-radius: 3px;
  padding: .45rem .9rem .35rem; cursor: pointer;
}
button.primary { background: var(--ink); color: var(--sheet); }
button:hover { background: var(--grid); }
button.primary:hover { background: #2a3c57; }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
.btns { display: flex; flex-wrap: wrap; gap: .5rem; }
select { border: 1.5px solid var(--ink); border-radius: 3px; padding: .35rem .5rem; background: var(--sheet); }
label.slider { display: grid; grid-template-columns: 1fr auto; gap: .1rem .5rem; align-items: baseline; }
label.slider span:last-of-type { font-weight: 700; font-variant-numeric: tabular-nums; }
label.slider input { grid-column: 1 / -1; width: 100%; accent-color: var(--ink); }
.seg { align-self: flex-start; display: inline-flex; border: 1.5px solid var(--ink); border-radius: 3px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: .4rem .75rem .3rem; }
.seg button + button { border-left: 1.5px solid var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--sheet); }

/* svg styling */
.road-casing { stroke: var(--asphalt); stroke-linecap: round; fill: none; }
.road-flow { stroke-linecap: round; fill: none; }
.road-hit { stroke: transparent; fill: none; }
.fig-hero .road-hit { cursor: ns-resize; touch-action: none; } /* dragging a road must not scroll the page */
.road:hover .road-casing, .road.selected .road-casing { stroke: #aebbc7; }
.road-hit:focus-visible { outline: none; stroke: rgba(226, 160, 27, .45); }
.node circle { fill: var(--sheet); stroke: var(--ink); stroke-width: 2; }
.node.od circle { fill: var(--ink); }
.node text { font: 700 13px var(--sans); fill: var(--ink); }
.node.od text { fill: var(--sheet); }
.lbl { font: 600 12px var(--sans); fill: var(--graphite); font-variant-numeric: tabular-nums; }
.lbl-strong { font: 800 13px var(--sans); fill: var(--ink); }
.axis text { font: 500 11px var(--sans); fill: var(--graphite); }
.axis line, .axis path { stroke: var(--rule); }
.car { fill: var(--ink); }

.legend { display: flex; flex-wrap: wrap; gap: .25rem 1rem; font: 500 .85rem var(--sans); color: var(--graphite); }
.legend i { display: inline-block; width: 1.6rem; height: .5rem; border-radius: 1rem; vertical-align: middle; margin-right: .35rem; }

.routes { display: flex; flex-direction: column; gap: .35rem; font-variant-numeric: tabular-nums; }
.route { display: grid; grid-template-columns: 1fr auto; font-size: .88rem; }
.route .bar { grid-column: 1 / -1; height: 5px; background: var(--grid); border-radius: 3px; overflow: hidden; }
.route .bar b { display: block; height: 100%; background: var(--free); }

footer { max-width: var(--measure); margin: 0 auto; padding: 2rem 1.5rem 5rem; font: 400 .9rem/1.6 var(--sans); color: var(--graphite); border-top: 1px solid var(--rule); }
footer pre { font-size: .78rem; background: var(--sheet); border: 1px solid var(--rule); padding: 1rem; overflow-x: auto; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
