/* =============================================================================
   SUGARLUMP DESIGN SYSTEM — Base
   Reset, root element styling, base typography, texture utilities.
   Depends on tokens.css.
   ============================================================================= */

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

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  text-underline-offset: 0.18em;
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: var(--lh-body);
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis: none;
  min-height: 100vh;
  position: relative;
  overflow-x: clip;
}

/* Grain overlay for warmth — sits above bg, below content, never intercepts clicks */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  /* No mix-blend-mode: on a position:fixed layer it forces a full-page
     recomposite every scroll frame. Plain low-opacity overlay is cheap. */
}
:root[data-theme="dark"] body::before { opacity: calc(var(--grain-opacity) * 1.6); }

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

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

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

:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-radius: var(--r-sm);
}

::selection { background: var(--primary); color: var(--c-white); }

/* --- Base typography --------------------------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 540;
  line-height: var(--lh-snug);
  letter-spacing: var(--tracking-tight);
  color: var(--text);
  font-optical-sizing: auto;
  text-wrap: balance;
}
p { text-wrap: pretty; }

strong, b { font-weight: 700; }

/* Fraunces "SOFT" and "opsz" niceties where supported */
.font-display { font-family: var(--font-display); }
.font-body    { font-family: var(--font-body); }
.font-mono    { font-family: var(--font-mono); }

/* --- Layout primitives ------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
  position: relative;
  z-index: var(--z-base);
}
.container--narrow { max-width: var(--container-narrow); }

.section { padding-block: clamp(3.5rem, 8vw, 7.5rem); position: relative; }
.section--tight { padding-block: clamp(2.5rem, 5vw, 4rem); }

.stack > * + * { margin-top: var(--sp-4); }
.stack-lg > * + * { margin-top: var(--sp-6); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Texture / blueprint utilities ------------------------------------ */
.bg-dots {
  background-image: radial-gradient(var(--grid-dot) 1.4px, transparent 1.4px);
  background-size: 22px 22px;
  background-position: -11px -11px;
}
.bg-grid {
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 44px 44px;
}
.bg-sunken { background-color: var(--bg-sunken); }
.bg-ink { background-color: var(--c-ink-900); color: var(--text-inverse); }
:root[data-theme="dark"] .bg-ink { background-color: #0f0b08; }
