/* The Chinese Postman — site styles.
   Identity: street signage and postal routes. Overpass (Highway Gothic lineage) for interface and
   headings, Source Serif 4 for reading. Yellow = the postman's route, red = streets driven twice. */

:root {
  --paper: #ffffff;
  --panel: #f2f4f6;
  --ink: #1b2a41;
  --ink-soft: #4a5a70;
  --street: #9aa5b1;
  --street-faint: #d3d9df;
  --route: #f2b705;
  --repeat: #c8102e;
  --link: #2f6690;
  --rule: #dde2e7;
  --focus: #2f6690;
  --sans: "Overpass", "Segoe UI", system-ui, sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --measure: 68ch;
  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.563rem;
  --step-3: 1.953rem;
  --step-4: 2.441rem;
  --step-5: 3.052rem;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.5;
}

a { color: var(--link); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }

/* ---------- header and footer ---------- */
.site-header {
  border-bottom: 1px solid var(--rule);
}
.site-header .inner {
  max-width: 72rem; margin: 0 auto; padding: 0.9rem 1.25rem;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem 1.75rem;
}
.brand {
  font-weight: 800; font-size: var(--step-1); color: var(--ink); text-decoration: none;
  letter-spacing: -0.01em; margin-right: auto;
}
.brand::before {
  content: ""; display: inline-block; width: 0.9em; height: 0.28em; margin-right: 0.45em;
  background: var(--route); vertical-align: 0.18em; border-radius: 1px;
}
.site-nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; }
.site-nav a { color: var(--ink); text-decoration: none; font-weight: 600; padding: 0.15rem 0; }
.site-nav a:hover, .site-nav a[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--route); }

.site-footer {
  border-top: 1px solid var(--rule); margin-top: 5rem; color: var(--ink-soft); font-size: var(--step--1);
}
.site-footer .inner { max-width: 72rem; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.site-footer p { margin: 0.35rem 0; max-width: var(--measure); }

/* ---------- layout ---------- */
.wrap { max-width: 72rem; margin: 0 auto; padding: 0 1.25rem; }
.prose { max-width: var(--measure); }
section { margin-top: 4.5rem; }

h1, h2, h3 { font-family: var(--sans); line-height: 1.15; letter-spacing: -0.015em; }
h1 { font-size: var(--step-5); font-weight: 800; margin: 0 0 1rem; }
h2 { font-size: var(--step-3); font-weight: 800; margin: 0 0 1rem; }
h3 { font-size: var(--step-1); font-weight: 700; margin: 2rem 0 0.5rem; }
p { margin: 0 0 1rem; }
.lede { font-family: var(--serif); font-size: var(--step-1); line-height: 1.55; color: var(--ink); }
.reading p, .reading li { font-family: var(--serif); font-size: 1.0625rem; line-height: 1.65; }

/* ---------- hero ---------- */
.hero {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 2.5rem 3.5rem;
  align-items: center; padding: 3.5rem 0 1rem;
}
.hero h1 { max-width: 13ch; }
.hero .actions { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; align-items: center; margin-top: 1.75rem; }
.hero-figure { margin: 0; }
.hero-figure svg { width: 100%; height: auto; display: block; }
.hero-figure figcaption { font-size: var(--step--1); color: var(--ink-soft); margin-top: 0.5rem; display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; align-items: center; }

.button {
  display: inline-flex; align-items: center; gap: 0.5rem; font: inherit; font-weight: 700;
  background: var(--ink); color: #fff; border: 2px solid var(--ink); border-radius: 4px;
  padding: 0.55rem 1.1rem 0.45rem; text-decoration: none; cursor: pointer;
}
.button:hover { background: #24395a; }
.button.secondary { background: transparent; color: var(--ink); }
.button.secondary:hover { background: var(--panel); }
.button[disabled] { opacity: 0.45; cursor: not-allowed; }
.text-button {
  font: inherit; font-weight: 600; background: none; border: 0; padding: 0.2rem 0; color: var(--link);
  cursor: pointer; text-decoration: underline; text-underline-offset: 0.18em;
}

.key { display: inline-flex; align-items: center; gap: 0.4rem; }
.key i { display: inline-block; width: 1.4rem; height: 0.3rem; border-radius: 2px; }
.key .k-route { background: var(--route); }
.key .k-repeat { background: var(--repeat); }
.key .k-odd { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--ink); }
.key .k-street { background: var(--street); }
.key .k-optional { background: var(--street-faint); }
.key .k-depot { width: 0.75rem; height: 0.75rem; background: var(--ink); border-radius: 0; }
.routes { list-style: none; padding: 0; margin: 0.5rem 0 1rem; display: flex; flex-wrap: wrap; gap: 0.35rem 1.25rem; font-size: var(--step--1); }
.routes li { display: inline-flex; align-items: center; gap: 0.4rem; }
.routes i { display: inline-block; width: 1.4rem; height: 0.3rem; border-radius: 2px; }

/* ---------- network drawings ---------- */
.net .street { stroke: var(--street); stroke-width: 2.2; fill: none; stroke-linecap: round; }
.net .street.oneway { stroke-dasharray: none; }
.net .street.done { stroke: var(--route); stroke-width: 4; }
.net .street.twice { stroke: var(--repeat); stroke-width: 4; }
.net .node { fill: #fff; stroke: var(--ink); stroke-width: 1.4; }
.net .node.odd { fill: var(--ink); }
.net .label { font-family: var(--sans); font-size: 12px; fill: var(--ink-soft); }
.net .weight { font-family: var(--sans); font-size: 11px; fill: var(--ink-soft); }
.net .postman { fill: var(--ink); stroke: var(--route); stroke-width: 3; }
.net .postman.crew { stroke: #fff; stroke-width: 2; }
.net .street.optional { stroke: var(--street-faint); }
.net .street.optional.twice { stroke: var(--repeat); }
.net .depot { fill: var(--ink); stroke: #fff; stroke-width: 2; }
.net .arrow { fill: var(--street); }

/* ---------- tables, figures ---------- */
table { border-collapse: collapse; width: 100%; font-size: var(--step--1); margin: 1rem 0 1.5rem; }
th, td { text-align: left; padding: 0.5rem 0.75rem 0.4rem 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-weight: 700; border-bottom: 2px solid var(--ink); }
.table-scroll { overflow-x: auto; }
figure.chart { margin: 2.5rem 0; max-width: 52rem; }
figure.chart svg { width: 100%; height: auto; display: block; }
figure.chart figcaption { font-size: var(--step--1); color: var(--ink-soft); margin-top: 0.4rem; max-width: var(--measure); }

/* ---------- signposts (destinations) ---------- */
.signposts { list-style: none; padding: 0; margin: 1.5rem 0 0; border-top: 2px solid var(--ink); }
.signposts li { border-bottom: 1px solid var(--rule); padding: 1.1rem 0; display: grid; grid-template-columns: minmax(12rem, 18rem) 1fr; gap: 0.25rem 2rem; align-items: baseline; }
.signposts a { font-size: var(--step-1); font-weight: 800; text-decoration: none; color: var(--ink); }
.signposts a:hover { box-shadow: inset 0 -4px 0 var(--route); }
.signposts p { margin: 0; color: var(--ink-soft); }

/* ---------- report pages ---------- */
.report { max-width: var(--measure); margin: 0 auto; }
.report h1 { font-size: var(--step-4); margin-top: 3rem; }
.report h2 { font-size: var(--step-2); margin-top: 3.5rem; padding-top: 1rem; border-top: 2px solid var(--ink); }
.report h3 { font-size: var(--step-1); }
.report p, .report li { font-family: var(--serif); font-size: 1.0625rem; line-height: 1.65; }
.report td, .report th { font-family: var(--sans); }
.report pre { background: var(--panel); padding: 0.9rem 1rem; overflow-x: auto; border-radius: 4px; font-size: 0.9rem; }
.report code { font-size: 0.92em; }
.report .math-display { overflow-x: auto; margin: 1.25rem 0; }
.report .byline { color: var(--ink-soft); font-family: var(--sans); }
.report-layout { display: grid; grid-template-columns: 15rem minmax(0, 1fr); gap: 3rem; max-width: 72rem; margin: 0 auto; padding: 0 1.25rem; }
.toc { position: sticky; top: 1rem; align-self: start; font-size: var(--step--1); max-height: calc(100vh - 2rem); overflow-y: auto; padding-top: 3.2rem; }
.toc ol { list-style: none; padding: 0; margin: 0; }
.toc li { margin: 0.3rem 0; }
.toc a { color: var(--ink-soft); text-decoration: none; }
.toc a:hover { color: var(--ink); text-decoration: underline; }
.download-row { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; align-items: center; margin: 1rem 0 2rem; }

/* ---------- 1997 viewer ---------- */
.pdf-frame { width: 100%; height: 85vh; border: 1px solid var(--rule); border-radius: 4px; background: var(--panel); }
.chapters { columns: 2 18rem; column-gap: 2.5rem; padding-left: 1.2rem; }
.chapters li { break-inside: avoid; margin: 0.2rem 0; }

/* ---------- try page ---------- */
.app { display: grid; grid-template-columns: 21rem minmax(0, 1fr); gap: 1.5rem 2rem; margin-top: 1.5rem; }
.panel { background: var(--panel); border-radius: 6px; padding: 1.1rem 1.1rem 1.25rem; align-self: start; }
.panel h2 { font-size: var(--step-1); margin: 0 0 0.75rem; }
.field { display: grid; gap: 0.25rem; margin-bottom: 0.9rem; }
.field label, .field legend { font-weight: 700; font-size: var(--step--1); }
.field .hint { font-size: 0.8rem; color: var(--ink-soft); }
select, input[type="number"], input[type="file"] {
  font: inherit; font-size: var(--step--1); padding: 0.4rem 0.5rem; border: 1px solid var(--street);
  border-radius: 4px; background: #fff; color: var(--ink); width: 100%;
}
input[type="range"] { width: 100%; accent-color: var(--ink); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.stage { min-width: 0; }
.stage-frame { border: 1px solid var(--rule); border-radius: 6px; background: #fff; position: relative; min-height: 22rem; }
.stage-frame svg { width: 100%; height: auto; display: block; max-height: 72vh; }
.stage-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-soft); text-align: center; padding: 2rem; }
.player { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; margin: 0.75rem 0; font-size: var(--step--1); }
.player input[type="range"] { width: 9rem; }
.status { font-size: var(--step--1); color: var(--ink-soft); min-height: 1.5em; }
.status.error { color: var(--repeat); font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: 0.75rem 1.5rem; margin: 1rem 0; padding: 0; }
.stats div { border-top: 2px solid var(--ink); padding-top: 0.35rem; }
.stats dt { font-size: 0.8rem; color: var(--ink-soft); }
.stats dd { margin: 0; font-size: var(--step-1); font-weight: 800; font-variant-numeric: tabular-nums; }
#osm-map { height: 22rem; border-radius: 6px; border: 1px solid var(--rule); margin-bottom: 0.75rem; }
.hidden, [hidden] { display: none !important; }

/* ---------- responsive ---------- */
@media (max-width: 60rem) {
  .hero { grid-template-columns: 1fr; padding-top: 2rem; }
  .app { grid-template-columns: 1fr; }
  .report-layout { grid-template-columns: 1fr; }
  .toc { position: static; max-height: none; padding-top: 1rem; }
  h1 { font-size: var(--step-4); }
}
@media (max-width: 36rem) {
  .signposts li { grid-template-columns: 1fr; }
  .row { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

/* How to cite */
.citation {
  font-family: var(--serif); padding-left: 1.5em; text-indent: -1.5em;
  overflow-wrap: anywhere;
}

/* Solver page: service settings */
.panel h2.panel-sub { margin-top: 1.75rem; }
.field label.check { display: flex; gap: 0.5rem; align-items: center; font-weight: 400; font-size: var(--step-0); }
.panel > .hint { font-size: 0.85rem; color: var(--ink-soft); margin: 0 0 0.9rem; }
.panel > .hint:empty { display: none; }
.legend { font-size: 0.85rem; color: var(--ink-soft); }

/* Extensions page */
blockquote.quote1997 { margin: 1.25rem 0 0.25rem; padding: 0.25rem 0 0.25rem 1.25rem; border-left: 4px solid var(--route); }
blockquote.quote1997 p { font-family: var(--serif); font-style: italic; font-size: 1.125rem; margin: 0; }
.reading p.translation { font-family: var(--sans); font-size: var(--step--1); color: var(--ink-soft); margin-top: 0.4rem; }
.refs li { margin-bottom: 0.5rem; }

.table-note { font-size: var(--step--1); color: var(--ink-soft); margin-top: -0.75rem; }
