/* ==========================================================================
   base.css — reset, typography, layout primitives
   Every value comes from tokens.css. A literal hex here is a bug.
   ========================================================================== */

@layer tokens, base, components, pages;

/* --------------------------------------------------------------------------
   Fonts — self-hosted. See assets/fonts/README.md for how to obtain the files.
   No runtime request to fonts.googleapis.com: it is a GDPR problem in Germany
   (LG München I, 3 O 17493/20) and a render-blocking third party.
   -------------------------------------------------------------------------- */

@font-face {
  font-family: "Familjen Grotesk";
  src: url("../assets/fonts/familjen-grotesk-latin-ext.woff2") format("woff2");
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0100-024F, U+0259, U+1E00-1EFF, U+2000-206F,
                 U+2074, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../assets/fonts/atkinson-hyperlegible-400-latin-ext.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0100-024F, U+0259, U+1E00-1EFF, U+2000-206F,
                 U+2074, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../assets/fonts/atkinson-hyperlegible-700-latin-ext.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0100-024F, U+0259, U+1E00-1EFF, U+2000-206F,
                 U+2074, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@layer base {

  /* ---- reset ---------------------------------------------------------- */

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

  html {
    color-scheme: only light;              /* DESIGN.md §2 — no dark mode */
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
  }

  @media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
  }

  body {
    margin: 0;
    background: var(--surface-page);
    color: var(--text-body);
    font-family: var(--font-body);
    font-size: var(--step-body);
    line-height: var(--leading-body);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }

  /* No image ever causes layout shift: width/height are required in markup
     and this keeps the aspect ratio when the CSS width overrides them. */
  img, picture, video, svg { max-width: 100%; height: auto; display: block; }

  /* ---- headings ------------------------------------------------------- */

  h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    color: var(--text-heading);
    font-weight: var(--weight-medium);
    margin: 0;
    text-wrap: balance;
  }

  h1 {
    font-size: var(--step-h1);
    line-height: 1.08;
    letter-spacing: var(--tracking-tight);
    max-width: var(--measure-display);
  }

  h2 {
    font-size: var(--step-h2);
    line-height: 1.15;
    letter-spacing: var(--tracking-snug);
  }

  h3 {
    font-size: var(--step-h3);
    line-height: 1.25;
    letter-spacing: var(--tracking-snug);
  }

  /* No italics anywhere. The display face has no true italic and the
     synthesised slant is ugly — DESIGN.md §3. Emphasis is weight or marker. */
  em, i, cite, dfn { font-style: normal; font-weight: var(--weight-bold); }

  p, li { max-width: var(--measure); }
  p { margin: 0 0 var(--space-5); }

  ul, ol { padding-inline-start: var(--space-6); }
  li { margin-bottom: var(--space-3); }

  /* ---- links ---------------------------------------------------------- */

  a {
    color: var(--forest);
    text-decoration: underline;
    text-underline-offset: 0.2em;
    text-decoration-thickness: 1.5px;
    transition: text-decoration-thickness var(--dur-fast) var(--ease-out);
  }

  a:hover { text-decoration-thickness: 3px; }

  /* ---- focus ---------------------------------------------------------- */
  /* Never removed. :focus-visible so mouse users are not shown rings —
     but test with the keyboard. ACCESSIBILITY.md §Beyond contrast. */

  :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
    border-radius: 2px;
  }

  .on-dark :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline-color: var(--focus-ring-alt);
  }

  /* ---- layout primitives ---------------------------------------------- */

  .wrap {
    max-width: var(--width-content);
    margin-inline: auto;
    padding-inline: var(--gutter);
  }

  .section { padding-block: var(--section-y); }

  /* Surfaces alternate white → mist → white → forest-tint.
     Never two coloured sections in a row, and never a coloured section
     directly above or below the band — DESIGN.md §4. */
  .section--alt     { background: var(--surface-alt); }
  .section--quiet   { background: var(--surface-quiet); }
  .section--soft    { background: var(--surface-soft); }
  .section--inverse { background: var(--surface-inverse); color: var(--text-on-dark); }

  .section--inverse :where(h1, h2, h3) { color: var(--text-on-dark); }
  .section--inverse a { color: var(--lemon); }

  .prose { max-width: var(--width-prose); }

  /* ---- type helpers ---------------------------------------------------- */

  .eyebrow {
    font-family: var(--font-display);
    font-size: var(--step-meta);
    letter-spacing: var(--tracking-meta);
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 var(--space-4);
  }

  .section--inverse .eyebrow { color: var(--lemon); }

  .lead {
    font-size: var(--step-lead);
    line-height: 1.5;
    max-width: 60ch;
  }

  .small { font-size: var(--step-small); }
  .muted { color: var(--text-muted); }

  /* ---- accessibility helpers ------------------------------------------ */

  .sr-only {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  /* First tab stop on every page. Visible on focus. */
  .skip-link {
    position: absolute;
    top: var(--space-3);
    left: var(--space-3);
    z-index: 200;
    padding: var(--space-4) var(--space-6);
    background: var(--forest);
    color: var(--white);
    font-family: var(--font-display);
    font-weight: var(--weight-medium);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transform: translateY(-200%);
  }

  .skip-link:focus-visible { transform: translateY(0); }

  /* ---- scroll reveal --------------------------------------------------- */
  /* Progressive enhancement only: js/reveal.js adds .is-revealed. Without JS
     the .reveal class is never applied by anything, so content is visible.
     The `js` class is set by the inline snippet in <head>. */

  .js .reveal {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity var(--dur-slow) var(--ease-out),
                transform var(--dur-slow) var(--ease-out);
  }

  .js .reveal.is-revealed { opacity: 1; transform: none; }

  @media (prefers-reduced-motion: reduce) {
    .js .reveal { opacity: 1; transform: none; transition: none; }
  }
}
