/* ============================================================
   CIVIC GUIDE — Base: reset, typography, layout primitives
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--t-body);
  line-height: var(--lh-body);
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow-x: hidden;
  font-variant-numeric: tabular-nums;
}

/* Paper grain — atmosphere, not decoration for its own sake */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }

/* Icon SVGs default to the current text size; component rules
   override with explicit px. An SVG that declares its own width
   attribute (diagrams, charts) is left alone, and full-bleed
   SVGs opt in with .svg-fill. */
svg:not([width]) { width: 1em; height: 1em; flex: none; }
svg.svg-fill { width: 100%; height: 100%; }

input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }

/* ---- Headings ------------------------------------------- */
h1, h2, h3, h4, h5, h6 { font-weight: 600; line-height: var(--lh-snug); }

.display,
h1 {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  letter-spacing: var(--ls-display);
  line-height: var(--lh-tight);
  font-weight: 600;
}
.display { font-size: var(--t-display); font-variation-settings: "SOFT" 0, "WONK" 1; }
h1 { font-size: var(--t-h1); }

h2 {
  font-family: var(--font-display);
  font-size: var(--t-h2);
  letter-spacing: var(--ls-tight);
  line-height: 1.14;
  font-weight: 600;
}
h3 { font-size: var(--t-h3); letter-spacing: -0.011em; }
h4 { font-size: var(--t-h4); }

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--signal); }

p { text-wrap: pretty; }
h1, h2, h3, .display { text-wrap: balance; }

/* ---- Wayfinding eyebrow: the signage voice --------------- */
.eyebrow {
  font-size: var(--t-2xs);
  font-weight: 600;
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.eyebrow::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}
.eyebrow--plain::after { display: none; }
.eyebrow--brand { color: var(--brand-2); }

.mono { font-family: var(--font-mono); font-size: 0.92em; letter-spacing: -0.01em; }

/* Numbers, codes, coordinates and IDs stay left-to-right and are
   isolated from the surrounding paragraph, so "8 / 40" does not
   reorder to "40 / 8" under an RTL locale. */
.mono, .num, .stat__n, .rating__num, .index-row__dist,
.svc__p, .pipe-step__code, .register__rows .n, .cat-tile__count {
  direction: ltr;
  unicode-bidi: isolate;
}
.muted { color: var(--ink-3); }
.dim   { color: var(--ink-2); }
.lead  { font-size: clamp(1.0625rem, 1rem + 0.35vw, 1.25rem); color: var(--ink-2); line-height: 1.55; }

/* ---- Layout --------------------------------------------- */
.wrap      { width: 100%; max-width: var(--wrap);      margin-inline: auto; padding-inline: var(--gutter); }
.wrap-wide { width: 100%; max-width: var(--wrap-wide); margin-inline: auto; padding-inline: var(--gutter); }
.wrap-read { width: 100%; max-width: var(--wrap-read); margin-inline: auto; padding-inline: var(--gutter); }

.section     { padding-block: clamp(3rem, 6vw, 5.5rem); }
.section--sm { padding-block: clamp(2rem, 4vw, 3.5rem); }
.section--tight { padding-block: clamp(1.5rem, 3vw, 2.5rem); }

.stack > * + * { margin-block-start: var(--flow, var(--sp-4)); }
.row { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; min-width: 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; }
.grid { display: grid; gap: var(--sp-5); }
.grid > * { min-width: 0; }   /* tracks never widen past their share */

.rule-top { border-block-start: 1px solid var(--rule); }
.rule-bottom { border-block-end: 1px solid var(--rule); }

/* Section header pattern used across the whole product */
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-5);
  flex-wrap: wrap;
  margin-block-end: var(--sp-5);
}
.section-head__title { max-width: 46ch; }
.section-head__title h2 { margin-block-start: var(--sp-3); }
.section-head__title p { margin-block-start: var(--sp-3); color: var(--ink-2); }

/* ---- Accessibility -------------------------------------- */
.skip-link {
  position: absolute;
  inset-inline-start: var(--sp-4);
  inset-block-start: -100px;
  z-index: var(--z-toast);
  background: var(--ink);
  color: var(--ink-inv);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-sm);
  font-size: var(--t-sm);
  font-weight: 600;
  transition: inset-block-start var(--dur-2) var(--ease-out);
}
.skip-link:focus-visible { inset-block-start: var(--sp-4); }

:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---- Page-load choreography ------------------------------ */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  animation: reveal var(--dur-4) var(--ease-out) forwards;
  animation-delay: var(--delay, 0ms);
}
@keyframes reveal { to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* ---- Utilities ------------------------------------------- */
.hide { display: none !important; }
@media (max-width: 767px)  { .hide-sm { display: none !important; } }
@media (max-width: 1023px) { .hide-md { display: none !important; } }
@media (min-width: 1024px) { .only-md { display: none !important; } }

.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.full { width: 100%; }
