@layer reset, base, site, layout;

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

  body,
  h1,
  h2,
  h3,
  p,
  ul,
  ol,
  dl,
  dd,
  figure {
    margin: 0;
  }

  ul,
  ol {
    padding-inline-start: 1.35rem;
  }
}

@layer base {
  html {
    min-height: 100%;
    scroll-behavior: smooth;
  }

  body {
    min-height: 100vh;
    font-family: var(--font-sans);
    line-height: 1.65;
    color: var(--text);
    background: var(--page-bg);
    background-attachment: fixed;
    text-rendering: optimizeLegibility;
  }

  a {
    color: var(--accent-strong);
    text-decoration-color: color-mix(in srgb, currentColor 42%, transparent);
    text-underline-offset: 0.18em;
    transition: color 160ms ease, text-decoration-color 160ms ease, transform 160ms ease;

    &:hover {
      color: var(--accent);
      text-decoration-color: currentColor;
    }
  }

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

  img {
    height: auto;
  }

  h1,
  h2,
  h3 {
    line-height: 1.15;
    text-wrap: balance;
  }

  h1 {
    font-size: clamp(2.35rem, 6vw, 4.8rem);
    letter-spacing: 0;
  }

  h2 {
    font-size: clamp(1.35rem, 3vw, 2rem);
  }

  h3 {
    font-size: 1.05rem;
  }

  p,
  li,
  dd {
    color: var(--text-muted);
  }

  strong,
  b,
  dt {
    color: var(--text);
  }

  code {
    font-family: var(--font-mono);
    font-size: 0.94em;
  }

  input,
  textarea,
  button {
    font: inherit;
  }

  input,
  textarea {
    width: 100%;
    color: var(--text);
    background: var(--surface-subtle);
    border: 1px solid var(--border-muted);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.85rem;

    &:focus {
      outline: 3px solid color-mix(in srgb, var(--focus) 30%, transparent);
      border-color: var(--focus);
    }
  }

  button {
    border: 0;
    border-radius: 999px;
    padding: 0.75rem 1.1rem;
    color: white;
    background: var(--accent-strong);
    cursor: pointer;
    transition: transform 160ms ease, background-color 160ms ease;

    &:hover {
      background: var(--accent);
      transform: translateY(-1px);
    }

    &:focus-visible {
      outline: 3px solid color-mix(in srgb, var(--focus) 36%, transparent);
      outline-offset: 3px;
    }
  }

  :focus-visible {
    outline: 3px solid color-mix(in srgb, var(--focus) 46%, transparent);
    outline-offset: 0.2rem;
  }

  ::selection {
    color: white;
    background: color-mix(in srgb, var(--accent-strong) 82%, black);
  }

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

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