/* =====================================================================
   HGN — Base: reset, typography, layout primitives, a11y
   ===================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  overflow-x: clip;            /* global guard against decorative-element overflow */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: var(--leading-body);
  font-feature-settings: "kern", "liga", "calt", "ss01";
  letter-spacing: -0.005em;
  overflow-x: clip;
  text-rendering: optimizeLegibility;
  transition: background-color var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out);
}

/* Smooth-scroll lock while custom scrolling runs */
body.is-locked { overflow: hidden; }

img, svg, video, canvas { display: block; max-width: 100%; height: auto; }
img { font-style: italic; background-size: cover; background-position: center; }

input, button, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; padding: 0; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}
::selection { background: var(--teal-500); color: #fff; }
.theme-dark ::selection { background: var(--lime); color: var(--teal-900); }

/* ---- Headings ---- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 460;
  line-height: var(--leading-head);
  letter-spacing: var(--tracking-tight);
  font-optical-sizing: auto;
  text-wrap: balance;
}
h1 { font-size: calc(var(--step-6) * 0.75); line-height: var(--leading-tight); letter-spacing: var(--tracking-tighter); }
h2 { font-size: calc(var(--step-4) * 0.75); }
h3 { font-size: var(--step-2); }
h4 { font-size: var(--step-1); }
p { text-wrap: pretty; }

strong { font-weight: 600; }

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

.section { padding-block: var(--section-y); position: relative; }
.section--tight { padding-block: clamp(3rem, 2rem + 5vw, 6rem); }
.section--flush-top { padding-top: 0; }

.bg-paper   { background: var(--paper); }
.bg-paper-2 { background: var(--paper-2); }
.bg-white   { background: var(--white); }
.bg-teal    { background: var(--teal-900); }
.bg-teal-700{ background: var(--teal-700); }

.stack > * + * { margin-top: var(--flow, 1.2em); }
.stack-lg > * + * { margin-top: clamp(1.5rem, 1rem + 2vw, 2.6rem); }

.grid { display: grid; gap: var(--gutter); }
.flex { display: flex; }
.center { display: grid; place-items: center; }

/* ---- Eyebrow / kicker ---- */
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--step--2);
  font-weight: 500;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 0.7em;
}
.eyebrow::before {
  content: "";
  width: 1.8em; height: 1px;
  background: currentColor;
  opacity: .6;
  display: inline-block;
}
.eyebrow--plain::before { display: none; }

/* ---- Display utilities ---- */
.display { font-family: var(--font-display); }
.text-mono { font-family: var(--font-mono); }
.text-balance { text-wrap: balance; }
.text-pretty { text-wrap: pretty; }
.measure { max-width: 46ch; }
.measure-wide { max-width: 62ch; }
.lead { font-size: var(--step-1); line-height: 1.5; color: var(--text-soft); font-weight: 400; }
.muted { color: var(--text-mute); }
.accent-text { color: var(--accent); }
.serif-italic { font-family: var(--font-display); font-style: italic; font-weight: 400; }

.u-hide { display: none !important; }
.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;
}

.skip-link {
  position: fixed; top: 0; left: 50%; transform: translate(-50%, -120%);
  z-index: var(--z-overlay);
  background: var(--teal-700); color: #fff;
  padding: .7rem 1.2rem; border-radius: 0 0 12px 12px;
  font-size: var(--step--1); font-weight: 600;
  transition: transform var(--dur-1) var(--ease-out);
}
.skip-link:focus { transform: translate(-50%, 0); }

/* ---- Cross-document View Transitions (progressive enhancement) ---- */
@view-transition { navigation: auto; }
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.5s;
  animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
}

/* Grain / noise texture overlay (applied to <body>) */
.grain::after {
  content: "";
  position: fixed; inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.035;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

:where(section, article)[id], .anchor { scroll-margin-top: 6.5rem; }

@media (max-width: 900px) {
  :root { --section-y: clamp(4rem, 3rem + 6vw, 7rem); }
}
