/* ============================================================
   base.css — reset, typography, layout primitives, motion.
   Loaded after tokens.css. Contains no raw values.
   ============================================================ */

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

  html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
  }

  body {
    margin: 0;
    background: var(--c-bg);
    color: var(--c-ink);
    font-family: var(--font-body);
    font-size: var(--text-0);
    line-height: var(--lh-body);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }

  /* ---- headings ------------------------------------------- */
  h1, h2, h3, h4 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 700;
    line-height: var(--lh-tight);
    letter-spacing: var(--track-display);
    text-wrap: balance;
  }
  h1 { font-size: var(--text-4); }
  h2 { font-size: var(--text-3); }
  h3 { font-size: var(--text-1); }
  h4 { font-size: var(--text-0); }

  p, ul, ol { margin: 0; }
  p { text-wrap: pretty; }

  /* Running text never runs past a comfortable measure. */
  .prose > p, .lede { max-width: var(--measure); }

  a { color: var(--c-brand); text-underline-offset: 0.18em; }
  a:hover { color: var(--c-brand-bright); }

  strong { font-weight: 600; }

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

  /* ---- focus — one visible treatment everywhere ----------- */
  :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 3px solid var(--c-focus);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
  }

  /* ---- skip link ------------------------------------------ */
  .skip {
    position: absolute;
    left: var(--gutter);
    top: -4rem;
    z-index: 100;
    background: var(--c-brand);
    color: var(--c-on-brand);
    padding: var(--sp-1) var(--sp-2);
    border-radius: var(--radius-sm);
    font-weight: 600;
    transition: top var(--dur-fast) var(--ease);
  }
  .skip:focus { top: var(--sp-2); }

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

  /* ---- layout primitives ---------------------------------- */
  .wrap {
    width: min(100% - (var(--gutter) * 2), var(--page-max));
    margin-inline: auto;
  }

  /* Band padding, 17 Sep 2026. --sp-7 is 6rem, and at 6rem top AND bottom the
     desktop page read stretched -- especially now bands alternate tone, where
     the run between two colours is the thing you see. --sp-6 is 4rem: a third
     off, and an existing token rather than a new number.
     BELOW 768 IT STAYS AT --sp-7 ON PURPOSE. On a phone that same space reads
     as breathing room; on a 1440 desktop it read as emptiness. */
  .band { padding-block: var(--sp-6); }
  @media (max-width: 767px) { .band { padding-block: var(--sp-7); } }
  .band--tight { padding-block: var(--sp-5); }

  /* The dark band. Deliberately the same in both themes. */
  .band--dark {
    background: var(--c-dark);
    color: var(--c-dark-ink);
  }
  .band--dark a { color: var(--c-brand-on-dark); }
  .band--dark .eyebrow { color: var(--c-brand-on-dark); }
  .band--dark .lede { color: var(--c-dark-muted); }

  .band--raised { background: var(--c-surface-2); }

  /* Auto-fitting grid. Container queries handle the components
     inside; this only handles how many fit across. */
  .grid {
    display: grid;
    gap: var(--sp-2);
    grid-template-columns: repeat(auto-fit, minmax(min(15rem, 100%), 1fr));
  }

  /* Fixed-count grids. auto-fit lets the BROWSER choose the column count, and
     five items never divide into its choice cleanly: the last row orphans and
     stretches one card across the space of three. Where the count is known,
     say it. auto-fit stays only where the count genuinely varies. */
  .grid--5 { grid-template-columns: repeat(5, 1fr); }
  .grid--4 { grid-template-columns: repeat(4, 1fr); }
  .grid--3 { grid-template-columns: repeat(3, 1fr); }

  @media (max-width: 1099px) {
    /* 5 becomes 3 + 2. The track is six columns and each card spans two, so
       the trailing pair can be centred -- no empty slot beside a card. */
    .grid--5 { grid-template-columns: repeat(6, 1fr); }
    .grid--5 > * { grid-column: span 2; }
    .grid--5 > :nth-child(4) { grid-column: 2 / span 2; }
    .grid--5 > :nth-child(5) { grid-column: 4 / span 2; }
    .grid--4 { grid-template-columns: repeat(2, 1fr); }
  }
  @media (max-width: 899px) {
    .grid--3 { grid-template-columns: 1fr; }
  }
  @media (max-width: 699px) {
    .grid--5, .grid--4, .grid--3 { grid-template-columns: 1fr; }
    .grid--5 > *,
    .grid--5 > :nth-child(4),
    .grid--5 > :nth-child(5) { grid-column: auto; }
  }

  .stack { display: grid; gap: var(--sp-2); align-content: start; }
  .row   { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }

  .eyebrow {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: var(--track-label);
    text-transform: uppercase;
    color: var(--c-brand);
  }

  .lede {
    color: var(--c-muted);
    font-size: var(--text-1);
    margin-top: var(--sp-2);
  }

  /* Digits that sit in columns must line up. */
  .tnum { font-variant-numeric: tabular-nums; }

  /* ---- wide things get their own scroll, the page never does */
  .scroll-x { overflow-x: auto; }

  /* ---- cross-page transitions ----------------------------- */
  @view-transition { navigation: auto; }

  /* ---- scroll-driven reveal --------------------------------
     Starts VISIBLE and animates from a visible resting state,
     so the first paint and any screenshot show real content.
     No JavaScript, no IntersectionObserver. */
  @supports (animation-timeline: view()) {
    @media (prefers-reduced-motion: no-preference) {
      /* Section headings and every repeated box, 17 Sep 2026. Applied from CSS
         rather than by hanging a class on each element, and deliberately NOT
         nested: .reveal used to sit on the grid CONTAINERS, and if a container
         and its cards both animate the two opacities multiply -- 0.35 x 0.35 is
         0.12, which is parked-invisible, the one thing this must never do.
         The containers gave the class up; the cards animate themselves. */
      .reveal,
      .band h2,
      .band .card,
      .band .price,
      .band .feature,
      .band .report {
        animation: reveal-in linear both;
        animation-timeline: view();
        animation-range: entry 10% cover 28%;
      }
      /* TRANSFORM ONLY -- no opacity. Measured 17 Sep 2026: fading in from
         opacity 0.35 cost 4 points of Lighthouse accessibility on / and 5 on
         /pricing/, because axe computes the EFFECTIVE colour including every
         ancestor opacity. --c-ink at 0.35 over white resolves to
         rgb(173,173,181) and reads as 2.22:1; --c-muted resolved to
         rgb(198,198,208) at 1.69:1. (Written as rgb() and not as a hex pair on
         purpose: ship-check section 1 greps this file for six hex digits, and a
         comment that keeps that check permanently red teaches people to ignore
         it.) "Visible at
         rest" is not the same as "readable at rest", and a reveal is not worth
         a contrast failure on every heading below the fold. A slide with no
         fade keeps the motion and cannot affect contrast at any moment. */
      @keyframes reveal-in {
        from { transform: translateY(0.75rem); }
        to   { transform: none; }
      }
    }
  }

  /* ---- long pages stay smooth ----------------------------- */
  .band { content-visibility: auto; contain-intrinsic-size: auto 600px; }

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