/* Hadrian's Wall, mile by mile — front-end styles. Tokens per docs/DESIGN.md. */
:root {
  --bg: #efe9de;
  --bg-raise: #f6f2e9;
  --ink: #20242a;
  --muted: #454a40;
  --line: #b9b2a3;
  --line-soft: #d3ccbc;
  --stone: #4f4b44;
  --turf: #3e6b34;
  --turf-strong: #2f5527;
  --survey: #86301c;
  --survey-ink: #86301c;
  --survey-soft: #f3ddd4;
  --card: #f6f2e9;
  --focus: #1d4fd7;
  --shadow: 0 1px 0 rgb(32 36 42 / 8%), 0 8px 28px -18px rgb(32 36 42 / 45%);
  --radius: 10px;
  --font-display: "Archivo", "Archivo Expanded", system-ui, sans-serif;
  --font-body: "Source Serif 4", Georgia, serif;
  --font-data: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
[data-theme="dark"] {
  --bg: #16191e;
  --bg-raise: #1d2126;
  --ink: #e9e4d6;
  --muted: #b7b2a4;
  --line: #3a4048;
  --line-soft: #2a2f36;
  --stone: #b5aea1;
  --turf: #9db380;
  --turf-strong: #b3c795;
  --survey: #e0684a;
  --survey-ink: #f2a48c;
  --survey-soft: #3a2320;
  --card: #1d2126;
  --focus: #8db4ff;
  --shadow: 0 1px 0 rgb(0 0 0 / 40%), 0 10px 30px -18px rgb(0 0 0 / 80%);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 1.075rem; line-height: 1.62;
}
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.08; letter-spacing: -0.01em; text-wrap: balance; }
h1 { font-size: clamp(2.1rem, 5.2vw + 1rem, 3.6rem); font-stretch: expanded; font-weight: 800; margin: 0.35em 0 0.3em; }
h2 { font-size: clamp(1.5rem, 2.6vw + 0.9rem, 2.2rem); font-stretch: expanded; font-weight: 750; margin: 0 0 0.5em; }
h3 { font-size: 1.18rem; font-weight: 700; margin: 0 0 0.35em; }
p { margin: 0 0 0.9em; }
a { color: inherit; text-decoration-color: var(--survey); text-decoration-thickness: 1.5px; text-underline-offset: 2.5px; }
a:hover { text-decoration-thickness: 2.5px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip:focus-visible { position: fixed !important; top: 0.6rem; left: 0.6rem; width: auto; height: auto; margin: 0; padding: 0.6rem 1rem; overflow: visible; clip: auto; white-space: normal; background: var(--ink); color: var(--bg); font-family: var(--font-data); font-size: 0.85rem; text-decoration: none; border-radius: 8px; z-index: 200; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 clamp(1rem, 4vw, 2.5rem); }
.wrap-narrow { max-width: 760px; }
section.block { padding: clamp(2.2rem, 5vw, 4rem) 0; }
.kicker { font-family: var(--font-data); font-size: 0.82rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 0 0 0.6em; }
.kicker .tick { color: var(--survey-ink); font-weight: 700; }
.lede { font-size: clamp(1.15rem, 1.6vw + 1rem, 1.42rem); line-height: 1.5; max-width: 62ch; }
.meta { font-family: var(--font-data); font-size: 0.85rem; color: var(--muted); }
hr.rule { border: 0; border-top: 2px solid var(--line-soft); margin: 0; }

/* Top bar (maintained pattern). */
.topbar { position: sticky; top: 0; z-index: 60; background: var(--bg); border-bottom: 1px solid var(--line-soft); }
.topbar-inner { display: flex; align-items: center; gap: 0.5rem; height: 52px; max-width: 1280px; margin: 0 auto; padding: 0 clamp(0.75rem, 3vw, 1.5rem); }
.brand { font-family: var(--font-display); font-weight: 800; font-size: 0.95rem; letter-spacing: 0.01em; text-decoration: none; white-space: nowrap; }
.brand small { font-weight: 500; color: var(--muted); }
.topbar-title { font-family: var(--font-data); font-size: 0.78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto; text-align: center; }
.topbar-actions { display: flex; align-items: center; gap: 0.35rem; margin-left: auto; }
.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; font-family: var(--font-data); font-size: 0.8rem; }
.lang-switch a { padding: 0.45rem 0.8rem; text-decoration: none; color: var(--muted); min-height: 44px; display: inline-flex; align-items: center; }
.lang-switch a[aria-current="true"] { background: var(--ink); color: var(--bg); font-weight: 700; }
.theme-btn { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.theme-btn:hover { border-color: var(--ink); }
.theme-btn svg { width: 20px; height: 20px; }

/* Masthead. */
.masthead { padding: clamp(1.6rem, 4vw, 3rem) 0 0.5rem; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; margin: 1.4rem 0; padding: 0; list-style: none; }
.facts li { border-top: 3px solid var(--survey); padding: 0.6rem 0.2rem 0; font-size: 1rem; line-height: 1.45; }
.facts strong { display: block; font-family: var(--font-data); font-size: 0.95rem; color: var(--survey-ink); margin-bottom: 0.25rem; }
.cta-row { display: flex; flex-wrap: wrap; gap: 0.7rem; margin: 1.2rem 0 0.5rem; }
.btn { display: inline-flex; align-items: center; min-height: 48px; padding: 0.65rem 1.3rem; border-radius: 999px; font-family: var(--font-display); font-weight: 700; font-size: 1rem; text-decoration: none; border: 2px solid var(--ink); }
.btn-solid { background: var(--ink); color: var(--bg); }
.btn-ghost { background: transparent; color: var(--ink); }
.btn:hover { text-decoration: none; filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }

/* Ribbon instrument. */
#ribbon { padding-bottom: 0; }
.ribbon-shell { max-width: 1280px; margin: 0 auto; padding: 0 clamp(0.5rem, 2vw, 1.5rem); }
.ribbon-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
@media (max-width: 980px) { .ribbon-grid { grid-template-columns: 1fr; } }
.ribbon-views { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.ribbon-profile { position: relative; }
#profileSvg { display: block; width: 100%; height: auto; touch-action: pan-y; cursor: crosshair; }
#profileSvg text { font-family: var(--font-data); }
.ribbon-strip { border-top: 1px solid var(--line-soft); padding: 0.4rem 0.6rem 0.2rem; }
#stripSvg { display: block; width: 100%; height: auto; }
.ribbon-controls { border-top: 1px solid var(--line-soft); padding: 0.7rem 0.9rem 0.9rem; display: grid; gap: 0.65rem; }
.search-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.search-box { flex: 1 1 220px; display: flex; gap: 0.4rem; }
.search-box input { flex: 1; min-height: 44px; font: inherit; font-size: 1rem; padding: 0.4rem 0.7rem; border: 1.5px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }
.search-results { position: relative; }
.search-results ul { list-style: none; margin: 0.35rem 0 0; padding: 0; display: grid; gap: 0.25rem; }
.search-results button { width: 100%; text-align: left; min-height: 44px; border: 1px solid var(--line-soft); background: var(--bg-raise); color: var(--ink); border-radius: 8px; padding: 0.4rem 0.7rem; font: inherit; font-size: 0.95rem; cursor: pointer; display: flex; justify-content: space-between; gap: 0.6rem; }
.search-results button:hover { border-color: var(--survey); }
.search-results .km { font-family: var(--font-data); font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.filters { display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; }
.filters label { display: inline-flex; align-items: center; gap: 0.45rem; min-height: 44px; font-family: var(--font-data); font-size: 0.86rem; cursor: pointer; }
.filters input { width: 1.25rem; height: 1.25rem; accent-color: var(--survey); }
.legend { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; font-family: var(--font-data); font-size: 0.78rem; color: var(--muted); }
.legend svg { vertical-align: -3px; margin-right: 0.25rem; }
.ribbon-status { font-family: var(--font-data); font-size: 0.82rem; color: var(--muted); display: flex; gap: 0.8rem; flex-wrap: wrap; align-items: center; }
.linklike { background: none; border: 0; padding: 0; color: inherit; font: inherit; text-decoration: underline; text-decoration-color: var(--survey); text-underline-offset: 3px; cursor: pointer; min-height: 44px; }

/* Panel. */
.panel { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.1rem 1rem; }
@media (min-width: 981px) { .panel-wrap { position: sticky; top: 64px; max-height: calc(100vh - 80px); overflow: auto; } }
.panel-wrap { display: grid; gap: 0.6rem; align-content: start; }
.panel-kind { font-family: var(--font-data); font-size: 0.76rem; letter-spacing: 0.07em; text-transform: uppercase; color: var(--survey-ink); margin: 0 0 0.3rem; font-weight: 700; }
.panel h3 { font-size: 1.35rem; margin-bottom: 0.15rem; }
.panel-latin { font-style: italic; color: var(--muted); margin: 0 0 0.6rem; }
.conf { display: inline-block; font-family: var(--font-data); font-size: 0.76rem; font-weight: 700; border: 1.5px solid currentColor; border-radius: 999px; padding: 0.1rem 0.6rem; margin: 0 0 0.6rem; }
.conf-visible { color: var(--turf-strong); }
[data-theme="dark"] .conf-visible { color: var(--turf); }
.conf-partial { color: var(--stone); }
.conf-earthworks { color: var(--stone); border-style: dashed; }
.conf-buried, .conf-none { color: var(--muted); border-style: dotted; }
.conf-reconstructed { color: var(--survey-ink); }
.conf-nominal { color: var(--muted); border-style: dashed; }
.panel dl { margin: 0; display: grid; gap: 0.45rem; font-size: 0.98rem; }
.panel dt { font-family: var(--font-data); font-size: 0.72rem; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.panel dd { margin: 0; }
.panel-nav { display: flex; gap: 0.5rem; margin-top: 0.9rem; }
.panel-nav button { flex: 1; min-height: 44px; border-radius: 8px; border: 1.5px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; font-size: 0.92rem; font-family: var(--font-data); cursor: pointer; }
.panel-nav button:hover { border-color: var(--survey); }
.ribbon-note { font-size: 0.92rem; color: var(--muted); max-width: 75ch; }

/* State blocks (loading / error / empty). */
.state-block { padding: 2rem 1.2rem; text-align: center; }
.state-block[hidden] { display: none; }
.spinner { width: 34px; height: 34px; margin: 0 auto 0.8rem; border-radius: 50%; border: 4px solid var(--line-soft); border-top-color: var(--survey); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Figures. */
figure { margin: 1.4rem 0; }
figure img { display: block; width: 100%; height: auto; border-radius: var(--radius); box-shadow: var(--shadow); }
figcaption { font-size: 0.92rem; color: var(--muted); margin-top: 0.5rem; max-width: 75ch; }
figcaption .credit { font-family: var(--font-data); font-size: 0.78rem; display: block; margin-top: 0.2rem; }

/* Contrast cards. */
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; margin-top: 1.2rem; }
@media (max-width: 760px) { .cards { grid-template-columns: 1fr; } }
.card { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.card img { width: 100%; height: auto; aspect-ratio: 16 / 8; object-fit: cover; display: block; }
.card-body { padding: 1rem 1.1rem 1.1rem; display: flex; flex-direction: column; gap: 0.4rem; flex: 1; }
.card-body p { margin: 0; font-size: 1rem; }
.card-credit { font-family: var(--font-data); font-size: 0.74rem; color: var(--muted); }
.card-link { margin-top: auto; padding-top: 0.5rem; font-family: var(--font-data); font-size: 0.9rem; font-weight: 700; }

/* Ledger (fort by fort). */
.ledger { display: grid; gap: 0.8rem; margin-top: 1.2rem; }
.record { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); scroll-margin-top: 70px; }
.record-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.3rem 0.8rem; margin-bottom: 0.3rem; }
.record-head h3 { margin: 0; font-size: 1.25rem; }
.record-head .latin { font-style: italic; color: var(--muted); }
.record-head .km { margin-left: auto; font-family: var(--font-data); font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.record-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem 1.2rem; font-size: 0.99rem; }
@media (max-width: 640px) { .record-grid { grid-template-columns: 1fr; } }
.record-grid dt { font-family: var(--font-data); font-size: 0.72rem; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.record-grid dd { margin: 0 0 0.3rem; }
.record-foot { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; margin-top: 0.5rem; font-family: var(--font-data); font-size: 0.84rem; }

/* Finder. */
.mc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(3.4rem, 1fr)); gap: 0.3rem; margin: 1rem 0; padding: 0; list-style: none; }
.mc-grid a, .mc-grid span { display: flex; align-items: center; justify-content: center; min-height: 44px; border-radius: 8px; border: 1.5px solid var(--line-soft); font-family: var(--font-data); font-size: 0.9rem; text-decoration: none; }
.mc-grid a.verified { border-color: var(--turf-strong); border-width: 2px; font-weight: 700; }
[data-theme="dark"] .mc-grid a.verified { border-color: var(--turf); }
.mc-grid span.nominal { color: var(--muted); border-style: dashed; }
.mc-grid a:hover { border-color: var(--survey); }
.finder-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 2rem; }
@media (max-width: 700px) { .finder-cols { grid-template-columns: 1fr; } }
.finder-list { list-style: none; margin: 0.6rem 0; padding: 0; display: grid; gap: 0.3rem; }
.finder-list a { display: flex; justify-content: space-between; gap: 0.8rem; padding: 0.5rem 0.2rem; border-bottom: 1px solid var(--line-soft); text-decoration: none; min-height: 44px; align-items: baseline; }
.finder-list a:hover .nm { text-decoration: underline; text-decoration-color: var(--survey); }
.finder-list .km { font-family: var(--font-data); font-size: 0.82rem; color: var(--muted); white-space: nowrap; }

/* Itineraries. */
.days { display: grid; gap: 0.9rem; margin-top: 1.2rem; }
.day { background: var(--card); border: 1px solid var(--line-soft); border-left: 6px solid var(--turf-strong); border-radius: var(--radius); padding: 1rem 1.2rem; box-shadow: var(--shadow); }
[data-theme="dark"] .day { border-left-color: var(--turf); }
.day h3 { font-size: 1.3rem; }
.day dl { display: grid; gap: 0.35rem; margin: 0.5rem 0 0; font-size: 0.99rem; }
.day dt { font-family: var(--font-data); font-size: 0.72rem; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.day dd { margin: 0; }
.stops { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.6rem; padding: 0; list-style: none; }
.stops a { font-family: var(--font-data); font-size: 0.82rem; border: 1px solid var(--line); border-radius: 999px; padding: 0.35rem 0.75rem; text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.stops a:hover { border-color: var(--survey); }

/* Honesty + method. */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 2.5rem; }
@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } }
table.data { width: 100%; border-collapse: collapse; font-size: 0.96rem; margin: 1rem 0; }
table.data caption { text-align: left; font-family: var(--font-data); font-size: 0.82rem; color: var(--muted); padding-bottom: 0.5rem; }
table.data th, table.data td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.data th { font-family: var(--font-data); font-size: 0.78rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
table.data td.num { font-family: var(--font-data); white-space: nowrap; }
.source-list { list-style: none; margin: 0.8rem 0; padding: 0; display: grid; gap: 0.35rem; font-size: 0.97rem; }
.source-list a { overflow-wrap: anywhere; }
.footer { border-top: 2px solid var(--line-soft); padding: 1.6rem 0 3rem; font-size: 0.95rem; color: var(--muted); }
.footer nav { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; margin-bottom: 0.8rem; }
.footer a { min-height: 44px; display: inline-flex; align-items: center; }

@media (max-width: 720px) {
  .facts { grid-template-columns: 1fr; }
  .topbar-title { display: none; }
  section.block { padding: 1.8rem 0; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .spinner { animation: none; border-top-color: var(--line-soft); }
}
