/*
 * Base — element defaults, accessibility helpers and global motion policy.
 */
@layer base {
  html {
    scroll-behavior: smooth;
  }

  body {
    margin: 0;
    background: var(--color-cream);
    color: var(--color-ink);
    font-family: var(--font-body);
  }

  a {
    color: var(--color-ink);
  }

  a:hover {
    color: var(--color-violet);
  }

  a:focus-visible,
  button:focus-visible {
    outline: 2px solid var(--color-violet);
    outline-offset: 3px;
    border-radius: 8px;
  }

  strong {
    font-weight: 700;
  }

  /* Hidden visually, still announced by screen readers. */
  .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  /* First focusable element on every page. */
  .skip-link {
    position: absolute;
    inset-inline-start: 16px;
    top: -80px;
    z-index: 60;
    background: var(--color-ink);
    color: var(--color-cream);
    font-weight: 700;
    text-decoration: none;
    padding: 12px 20px;
    border-radius: var(--radius-pill);
  }

  .skip-link:focus {
    top: 12px;
    color: var(--color-cream);
  }

  /* Lenis smooth-scroll integration (https://github.com/darkroomengineering/lenis). */
  html.lenis,
  html.lenis body {
    height: auto;
  }

  .lenis:not(.lenis-autoToggle).lenis-stopped {
    overflow: clip;
  }

  .lenis.lenis-smooth iframe {
    pointer-events: none;
  }

  .lenis.lenis-smooth {
    scroll-behavior: auto !important;
  }

  /*
   * Reduced motion wins everywhere: !important inside the earliest layer that
   * sets it beats every later layer, including their own !important rules.
   */
  @media (prefers-reduced-motion: reduce) {
    html {
      scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
      animation: none !important;
    }
  }

  /*
   * Accessibility-menu preferences, applied as data-a11y-* attributes on <html>
   * (see assets/js/accessibility/preferences.js). Font sizes are rem-based, so
   * scaling the root scales all text.
   */
  html[data-a11y-text="large"] {
    font-size: 115%;
  }

  html[data-a11y-text="xlarge"] {
    font-size: 130%;
  }

  html[data-a11y-links="on"] a {
    text-decoration: underline !important;
    text-decoration-thickness: 2px !important;
    text-underline-offset: 3px !important;
  }

  html[data-a11y-motion="off"] {
    scroll-behavior: auto;
  }

  html[data-a11y-motion="off"] *,
  html[data-a11y-motion="off"] *::before,
  html[data-a11y-motion="off"] *::after {
    animation: none !important;
    transition: none !important;
  }

  html[data-a11y-dim="on"] { --a11y-filter-dim: brightness(0.75); }
  html[data-a11y-contrast="on"] { --a11y-filter-contrast: contrast(1.35); }
  html[data-a11y-grayscale="on"] { --a11y-filter-grayscale: grayscale(1); }

  /* The block currently being read aloud. */
  .a11y-reading {
    outline: 3px solid #F5B400 !important;
    outline-offset: 4px;
    border-radius: 6px;
  }
}
