/*
 * Element defaults. Everything is scoped to [data-theme], so a page that has not opted in
 * to a theme keeps the browser defaults.
 */
@layer reset {
  [data-theme] {
    box-sizing: border-box;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;

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

    :where(h1, h2, h3, h4, p, ul, ol, dl, dd, figure, blockquote) {
      margin: 0;
    }

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

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

    :where(form.button_to) {
      display: contents;
    }

    :where([hidden]) {
      display: none !important;
    }
  }

  body[data-theme] {
    margin: 0;
    min-height: 100dvh;
  }
}

@layer base {
  [data-theme] {
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: var(--text-body);
    font-weight: var(--weight-body);
    line-height: var(--leading-normal);
    -webkit-font-smoothing: antialiased;

    :where(h1, h2, h3, h4) {
      font-family: var(--font-display);
      font-weight: var(--weight-display);
      line-height: var(--leading-tight);
      text-wrap: balance;
    }

    :where(h1) { font-size: var(--title-1); }
    :where(h2) { font-size: var(--title-2); }
    :where(h3) { font-size: var(--title-3); line-height: var(--leading-snug); }
    :where(h4) { font-size: var(--title-4); line-height: var(--leading-snug); }

    :where(p, dd) {
      max-width: var(--measure);
      text-wrap: pretty;
    }

    :where(strong, b) {
      font-weight: var(--weight-strong);
    }

    :where(small) {
      font-size: var(--text-sm);
    }

    :where(a) {
      color: var(--color-brand);
      font-weight: var(--weight-strong);
      text-decoration-thickness: 0.09em;
      text-underline-offset: 0.18em;

      &:hover {
        color: var(--color-brand-strong);
      }
    }

    :where(time) {
      color: var(--color-text-muted);
      font-size: var(--text-sm);
    }

    :focus-visible {
      outline: 3px solid var(--color-focus);
      outline-offset: 2px;
    }

    @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;
      }
    }
  }
}
