/* ============================================================
   BASE — element resets, root typography, focus, page chrome
   ============================================================ */

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

/* Ensure the HTML `hidden` attribute always wins over utility classes
   (e.g. .flex setting display: flex would otherwise override it). */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv11";
  scroll-behavior: smooth;
}

/* Anchored sections clear the floating nav when jumped to */
[id] { scroll-margin-top: 6rem; }

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

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--leading-normal);
  letter-spacing: var(--tracking-tight);
  min-height: 100vh;
}

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

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}

button {
  font-family: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0;
  color: inherit;
}

p { margin: 0; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 500; }

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

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

/* Subtle grain texture overlay for atmospheric depth */
.grain::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
