/*! hl-foundations.css v0.5.0 · © 2026 Heathen Labs. All rights reserved. Licensed to the client for use and modification within the client's own sites; see LICENSE-HL.md. */
/* hl-foundations.css: the skin foundations for hl-grid (S2), v0.5.0.
   No dependencies, no JS. Strict-CSP-safe: ONE same-origin stylesheet.
   LOAD ORDER: hl-grid.css → hl-foundations.css → the site's theme file (layer hl.theme) → the site's own CSS (unlayered).

   WHAT IT GIVES
   - Color ROLE tokens (--hl-c-*): a neutral dark base, plus a light set that any element switches to with
     data-scheme="light" (the whole page on <html>, or one section). Every pair is measured (table below).
   - A type scale (--hl-t-*), font stacks (--hl-f-*), weights, line heights.
   - Radius, motion (with the reduced-motion rule), and the two-tone focus ring.
   - Base element styles that read ONLY these tokens, so a theme changes values and never rules.

   THE THEME CONTRACT (see TOKENS.md, "Themes")
   - A theme is one file: @layer hl.theme { :root, [data-scheme="dark"] { … } [data-scheme="light"] { … } }.
   - It sets values for the role names below, never new rules. A theme that sets colors sets BOTH schemes (or states
     "dark only" and never uses data-scheme="light").
   - Every theme carries its own contrast table: every text pair ≥ 4.5:1, lines and the focus ring ≥ 3:1.
   - A theme may also override hl-grid's layout tokens (frame, gutter, measure, target): its layer comes later, so it wins.

   CONTRAST of these defaults (WCAG 2.x, relative luminance; text needs ≥ 4.5, lines/rings/fills ≥ 3):
     DARK   page #111111 · raised #1e1e1e · alt #262626
            on-page #f2f2f2:   16.9 / 14.9 / 13.5
            muted #b3b3b3:      9.0 /  8.0 /  7.2
            highlight #8fb4ff:  9.1 /  8.1 /  7.3
            line #767676:       4.2 /  3.7 /  3.3
            accent fill #2f5fb3 vs page 3.1 · on-accent #fff on it 6.2 · focus #fff on page 18.9
     LIGHT  page #ffffff · raised #f4f4f4 · alt #ebebeb
            on-page #1a1a1a:   17.4 / 15.8 / 14.6
            muted #595959:      7.0 /  6.4 /  5.9
            highlight #2f5fb3:  6.2 /  5.6 /  5.2
            line #767676:       4.5 /  4.1 /  3.8
            accent fill #2f5fb3 vs page 6.2 · on-accent #fff on it 6.2 · focus #000 on page 21
     Lowest text pair: 5.2 (light highlight on alt). */

@layer hl.reset, hl.tokens, hl.theme, hl.base, hl.layout, hl.panel, hl.components, hl.enhance;

/* ── tokens: the defaults a theme replaces ────────────────────────────────────────────────── */
@layer hl.tokens {
  :root, [data-scheme="dark"] {
    /* surfaces */
    --hl-c-page: #111111;        /* the page, and any element with data-scheme */
    --hl-c-raised: #1e1e1e;      /* cards, panels, menus */
    --hl-c-alt: #262626;         /* an alternate section, a selected row */
    /* text */
    --hl-c-on-page: #f2f2f2;     /* body text and headings, on every surface above */
    --hl-c-muted: #b3b3b3;       /* secondary text (≥ 4.5 on every surface) */
    --hl-c-highlight: #8fb4ff;   /* links, labels, active marks */
    /* lines and actions */
    --hl-c-line: #767676;        /* borders a user must see (≥ 3:1 on every surface) */
    --hl-c-accent: #2f5fb3;      /* the primary action's fill */
    --hl-c-on-accent: #ffffff;   /* text on the accent fill */
    /* focus: the ring, and the halo that keeps it visible on any color behind it */
    --hl-c-focus: #ffffff;
    --hl-c-focus-halo: #000000;
    color-scheme: dark;
  }
  [data-scheme="light"] {
    --hl-c-page: #ffffff;
    --hl-c-raised: #f4f4f4;
    --hl-c-alt: #ebebeb;
    --hl-c-on-page: #1a1a1a;
    --hl-c-muted: #595959;
    --hl-c-highlight: #2f5fb3;
    --hl-c-line: #767676;
    --hl-c-accent: #2f5fb3;
    --hl-c-on-accent: #ffffff;
    --hl-c-focus: #000000;
    --hl-c-focus-halo: #ffffff;
    color-scheme: light;
  }

  :root {
    /* fonts: system stacks only (no font downloads unless a theme self-hosts one) */
    --hl-f-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --hl-f-display: var(--hl-f-body);
    --hl-f-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --hl-f-label: var(--hl-f-mono);

    /* type scale: body 18 px (the phone rule); headings fluid, never below the body */
    --hl-t-small: .9375rem;                                   /* 15 px: notes, never body copy */
    --hl-t-body: 1.125rem;                                    /* 18 px */
    --hl-t-lead: clamp(1.125rem, 1rem + .6vw, 1.375rem);      /* 18–22 px */
    --hl-t-h3: clamp(1.25rem, 1.1rem + .5vw, 1.5rem);         /* 20–24 px */
    --hl-t-h2: clamp(1.625rem, 1.2rem + 1.6vw, 2.5rem);       /* 26–40 px */
    --hl-t-h1: clamp(2.125rem, 1.4rem + 3vw, 3.75rem);        /* 34–60 px */
    --hl-lh-body: 1.6;
    --hl-lh-tight: 1.15;
    --hl-w-body: 400;
    --hl-w-strong: 700;
    --hl-w-head: 800;

    /* shape */
    --hl-radius: 6px;                                         /* a theme sets 0 for square brands */
    --hl-ring: 3px;                                           /* focus ring width; the halo is twice it */

    /* motion: short and calm; all of it collapses under reduced motion */
    --hl-dur-fast: 120ms;
    --hl-dur: 200ms;
    --hl-ease: cubic-bezier(.2, 0, 0, 1);

    /* the side panel takes the raised surface (hl-grid's default is the system Canvas) */
    --hl-panel-bg: var(--hl-c-raised);
  }

  @media (prefers-reduced-motion: reduce) {
    :root { --hl-dur-fast: 0.01ms; --hl-dur: 0.01ms; }
  }
}

/* ── base: element styles, reading tokens only ────────────────────────────────────────────── */
@layer hl.base {
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  @media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
  }

  /* a scheme is a surface: the page, or any section that switches scheme, paints its own background and text */
  :root, [data-scheme] { background: var(--hl-c-page); color: var(--hl-c-on-page); }
  body {
    margin: 0;
    font: var(--hl-w-body) var(--hl-t-body)/var(--hl-lh-body) var(--hl-f-body);
  }

  h1, h2, h3, h4 {
    font-family: var(--hl-f-display);
    font-weight: var(--hl-w-head);
    line-height: var(--hl-lh-tight);
    margin: 0 0 .5em;
    text-wrap: balance;
  }
  h1 { font-size: var(--hl-t-h1); }
  h2 { font-size: var(--hl-t-h2); }
  h3 { font-size: var(--hl-t-h3); }
  h4 { font-size: var(--hl-t-body); }
  p, dl, :is(ul, ol):not(.hl-row, .hl-cluster, .hl-long) { margin: 0 0 1em; }   /* rows/clusters stay reset */
  p { text-wrap: pretty; }
  strong, b { font-weight: var(--hl-w-strong); }
  small { font-size: var(--hl-t-small); }
  code, kbd, samp, pre { font-family: var(--hl-f-mono); font-size: .9em; }

  a { color: var(--hl-c-highlight); text-underline-offset: .18em; text-decoration-thickness: .08em; }

  hr { border: 0; border-block-start: 1px solid var(--hl-c-line); margin-block: var(--hl-s-24); }

  /* the two-tone focus ring: a ring plus a halo, so it shows on any surface or image */
  :focus-visible {
    outline: var(--hl-ring) solid var(--hl-c-focus);
    outline-offset: 2px;
    box-shadow: 0 0 0 calc(var(--hl-ring) * 2) var(--hl-c-focus-halo);
  }

  /* helpers every site needs */
  .hl-vh {                                                    /* visually hidden, still read aloud */
    position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap;
  }
  .hl-skip { position: absolute; inset-inline-start: -9999px; }
  .hl-skip:focus {
    inset-inline-start: var(--hl-s-16); inset-block-start: var(--hl-s-16); z-index: 30;
    padding: var(--hl-s-12) var(--hl-s-16); background: var(--hl-c-page); color: var(--hl-c-on-page);
  }

  @media (forced-colors: active) {
    :focus-visible { outline-color: Highlight; box-shadow: none; }
  }
}
