/* =========================================================================
   Barázda — reset + base element styling
   Layers: reset, base. Load after tokens.css.
   ========================================================================= */

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

  * {
    margin: 0;
  }

  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
    /* Anchored sections must not land under the sticky header. */
    scroll-padding-top: 5rem;
  }

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

    /* One kill switch rather than per-component overrides. Animations are
       reduced to a single frame rather than removed, so anything that
       depends on an animationend event still fires. */
    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
      scroll-behavior: auto !important;
    }
  }

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

  input,
  button,
  textarea,
  select {
    font: inherit;
    color: inherit;
  }

  p,
  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    overflow-wrap: break-word;
  }

  ul[class],
  ol[class] {
    list-style: none;
    padding: 0;
  }
}

@layer base {
  body {
    min-height: 100dvh;
    min-width: var(--size-min-viewport);
    margin: 0;
    background-color: var(--surface-page);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: var(--font-size-body);
    line-height: var(--leading-body);
    -webkit-font-smoothing: antialiased;
    /* Prevents the mobile nav disclosure from causing sideways scroll on
       narrow screens while it animates open. */
    overflow-x: hidden;
  }

  /* GRADIENT-MESH GROUND
     A fixed pseudo-element rather than `background-attachment: fixed` on
     body: iOS Safari mis-positions fixed attachment and visibly jumps as the
     address bar collapses, and it forces a full repaint on every scroll. */
  body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image: radial-gradient(130% 90% at 8% -12%, var(--mesh-a), transparent 62%),
      radial-gradient(95% 65% at 102% -4%, var(--mesh-b), transparent 58%);
  }

  ::selection {
    background-color: var(--selection-bg);
    color: var(--selection-fg);
  }

  h1,
  h2,
  h3,
  h4 {
    font-family: var(--font-display);
    color: var(--text-primary);
    text-wrap: balance;
  }

  h1 {
    font-size: var(--font-size-h1);
    font-weight: 640;
    line-height: 1.12;
    letter-spacing: -0.018em;
  }

  h2 {
    font-size: var(--font-size-h2);
    font-weight: 620;
    line-height: 1.2;
    letter-spacing: -0.012em;
  }

  h3 {
    font-size: var(--font-size-h3);
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.006em;
  }

  h4 {
    font-size: var(--font-size-h4);
    font-weight: 600;
    line-height: 1.35;
  }

  p {
    text-wrap: pretty;
  }

  a {
    color: var(--text-link);
    text-underline-offset: 0.18em;
    text-decoration-thickness: max(1px, 0.06em);
  }

  a:hover {
    color: var(--text-link-hover);
  }

  /* Colour is never the only cue that something is a link: body-copy links
     keep their underline at all times. Links that live inside a component
     (nav, cards, buttons) opt out via their own rules. */
  :focus-visible {
    outline: var(--focus-ring-width) solid var(--focus-ring);
    outline-offset: var(--focus-ring-gap);
    border-radius: var(--radius-xs);
  }

  strong,
  b {
    font-weight: 640;
  }

  small {
    font-size: var(--font-size-caption);
  }

  code,
  kbd,
  samp {
    font-family: var(--font-mono);
    font-size: 0.92em;
  }

  hr {
    height: 1px;
    border: 0;
    background-color: var(--border-subtle);
  }

  /* Skip link — the first focusable element on every page. Off-screen until
     focused, then pinned to the top-left in normal reading position. */
  .skip-link {
    position: absolute;
    top: var(--space-xs);
    left: var(--space-xs);
    z-index: var(--z-modal);
    padding: var(--space-xs) var(--space-md);
    background-color: var(--surface-raised);
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-control);
    box-shadow: var(--shadow-md);
    text-decoration: none;
    font-weight: 600;
    transform: translateY(-200%);
  }

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