/* base.css: reset, element defaults, global utilities. */

/* ---------- Reset ---------- */

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

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

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

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

/* ---------- Document ---------- */

html {
  color-scheme: dark;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-750) var(--color-canvas);
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--color-canvas);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--step-0);
  font-weight: 380;
  line-height: 1.6;
  letter-spacing: 0.01em;
  font-feature-settings: 'tnum' 1, 'zero' 1, 'calt' 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100%;
}

main {
  display: block;
}

/* ---------- Headings ---------- */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-mono);
  color: var(--color-text-hi);
  font-weight: 640;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h1 {
  font-size: var(--step-4);
  line-height: 1.05;
  letter-spacing: -0.022em;
}

h2 {
  font-size: var(--step-3);
  line-height: 1.15;
  letter-spacing: -0.018em;
}

h3 {
  font-size: var(--step-2);
  line-height: 1.25;
  letter-spacing: -0.012em;
}

h4 {
  font-size: var(--step-1);
  line-height: 1.25;
}

h5,
h6 {
  font-size: var(--step-0);
  line-height: 1.25;
}

/* ---------- Links & focus ---------- */

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--dur-state) var(--ease-standard);
}

a:hover {
  color: var(--color-accent-bright);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

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

::selection {
  background: var(--color-accent);
  color: var(--color-on-accent);
}

/* ---------- Utilities ---------- */

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 9500;
  font-family: var(--font-mono);
  font-size: var(--step--1);
}

.skip-link:focus {
  position: fixed;
  left: var(--space-4);
  top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-3);
  color: var(--color-text-hi);
  border: 1px solid var(--color-accent);
  border-radius: 6px;
}

/* Static film grain: never animated. */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9000;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='140'%20height='140'%3E%3Cfilter%20id='g'%3E%3CfeTurbulence%20type='fractalNoise'%20baseFrequency='0.82'%20numOctaves='3'%20stitchTiles='stitch'/%3E%3C/filter%3E%3Crect%20width='140'%20height='140'%20filter='url(%23g)'/%3E%3C/svg%3E");
  background-repeat: repeat;
}

.dotted {
  background-image: radial-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* ---------- Scrollbar (WebKit) ---------- */

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--color-canvas);
}

::-webkit-scrollbar-thumb {
  background: var(--ink-750);
  border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--ink-600);
}

/* ---------- Scroll behaviour guard ---------- */

@supports (animation-timeline: scroll()) {
  html,
  body {
    overscroll-behavior-y: none;
  }
}

/* ---------- Reduced motion ---------- */

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

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .reveal {
    animation: none;
    animation-timeline: auto;
    opacity: 1;
    transform: none;
  }
}
