/* Element defaults. Everything here reads from tokens.css, so changing
   the palette or the typefaces changes the whole site from one file. */

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

  /* Anchor links on this one-pager glide instead of jumping. The
     reduced-motion reset at the bottom of this file turns it off
     again for anyone who asked for that. */
  @media (prefers-reduced-motion: no-preference) {
    html {
      scroll-behavior: smooth;
    }
  }

  body {
    margin: 0;
    background: var(--color-bg);
    color: var(--color-ink);
    font-family: var(--font-body);
    font-size: var(--step-0);
    line-height: var(--leading-body);
    -webkit-font-smoothing: antialiased;
  }

  h1,
  h2,
  h3,
  h4 {
    margin: 0;
    font-family: var(--font-display);
    line-height: var(--leading-heading);
    text-wrap: balance;
    /* A long compound word set at display size is wider than a
       phone. Breaking is ugly; overflowing is broken. */
    overflow-wrap: break-word;
  }

  /* The large sizes are set, not merely sized: leading pulled in,
     tracking slightly negative. Both stop being right somewhere
     around h3, which is why this rule ends there. */
  h1,
  h2 {
    line-height: var(--leading-display);
    letter-spacing: var(--tracking-display);
  }

  /* The jump from h1 to h2 skips a step on purpose -- a hierarchy
     with visible daylight in it beats four sizes a visitor has to
     compare. --step-4 and --step-6 are unspent: --step-6 is there
     for the one display moment a page is allowed. */
  h1 { font-size: var(--step-5); }
  h2 { font-size: var(--step-3); }
  h3 { font-size: var(--step-2); }
  h4 { font-size: var(--step-1); }

  p {
    margin: 0;
    max-width: var(--measure);
    text-wrap: pretty;
  }

  a {
    color: inherit;
    text-underline-offset: 0.2em;
  }

  /* Costs one rule, and its absence is one of the tells that a page
     was assembled rather than designed. */
  ::selection {
    background: var(--color-accent);
    color: var(--color-on-accent);
  }

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

  /* Keyboard users need to see where they are. Never remove this
     without putting something at least as visible in its place. */
  :focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 3px;
  }

  .skip-link {
    position: absolute;
    left: var(--space-s);
    top: var(--space-s);
    z-index: 10;
    padding: var(--space-2xs) var(--space-s);
    border-radius: var(--radius);
    background: var(--color-accent);
    color: var(--color-on-accent);
    transform: translateY(-200%);
  }

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

  /* Respecting this is not optional: for some people motion causes
     nausea and migraine. Animate freely, but leave this in place. */
  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
      scroll-behavior: auto !important;
    }
  }
}
