@layer reset {
  html {
    box-sizing: border-box;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-h) + 2.5rem);
  }

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

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

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

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

  button {
    background: transparent;
    border: 0;
    padding: 0;
    cursor: pointer;
  }

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

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

@layer base {
  body {
    min-height: 100dvh;
    background-color: var(--bg);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: clip;
    transition: background-color 0.35s var(--ease), color 0.35s var(--ease);
  }

  /* Tactile fine-art paper grain (no glows, no grid lines) */
  body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 90;
    pointer-events: none;
    opacity: 0.032;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.88' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 180px 180px;
  }

  :root[data-surface='paper'] body::after {
    opacity: 0.04;
  }

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

  a {
    color: inherit;
    text-decoration: none;
  }

  :focus-visible {
    outline: 1.5px solid var(--brass);
    outline-offset: 3px;
    border-radius: 2px;
  }

  :root {
    scrollbar-color: var(--rule-strong) var(--bg);
    scrollbar-width: thin;
  }
}

@layer utilities {
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .skip-link {
    position: fixed;
    inset-block-start: -100%;
    inset-inline-start: 1rem;
    z-index: 200;
    padding: 0.55rem 0.9rem;
    background: var(--ink);
    color: var(--bg);
    font-family: var(--font-mono);
    font-size: 0.78rem;
  }

  .skip-link:focus {
    inset-block-start: 0.75rem;
  }

  .mono {
    font-family: var(--font-mono);
  }

  .tabular {
    font-variant-numeric: tabular-nums;
  }
}
