/* ==========================================================================
   base — reset, typography primitives, shared atoms
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; min-width: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--house-3) var(--ground);
}

body {
  background: var(--ground);
  color: var(--fg);
  font-family: var(--f-sans);
  font-size: var(--t-body);
  font-weight: 300;
  line-height: 1.55;
  letter-spacing: 0.005em;
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

/* Lenis owns scrolling; the page must not also smooth-scroll natively. */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: hidden; }

body.is-loading { overflow: hidden; }

/* Custom cursor replaces the pointer on fine-pointer devices only. */
@media (hover: hover) and (pointer: fine) {
  body.has-cursor, body.has-cursor * { cursor: none !important; }
}

img, video, svg { display: block; max-width: 100%; }
video { object-fit: cover; }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; }

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

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

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

/* ── type primitives ───────────────────────────────────────────────────── */

.eyebrow,
.sectionmark {
  font-family: var(--f-mono);
  font-size: var(--t-meta);
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-3);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.7em;
}

.eyebrow__dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 0 0 rgba(232, 163, 61, 0.5);
  animation: pulse 2.8s var(--ease) infinite;
}

@keyframes pulse {
  0%, 70%, 100% { box-shadow: 0 0 0 0 rgba(232, 163, 61, 0.45); }
  35%           { box-shadow: 0 0 0 9px rgba(232, 163, 61, 0); }
}

.sectionmark {
  display: flex;
  align-items: baseline;
  gap: 1em;
}

.sectionmark span {
  color: var(--signal);
  font-variant-numeric: tabular-nums;
}

.sectionmark::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
  transform-origin: left;
}

/* Masked line reveal — the base unit of every text entrance on the site. */
.line {
  display: block;
  overflow: hidden;
  padding-bottom: 0.06em;
  margin-bottom: -0.06em;
}

.line__in {
  display: inline-block;
  will-change: transform;
}

/* Per-character wrapper produced by splitChars() in lib.js */
.ch {
  display: inline-block;
  white-space: pre;
  transform-origin: 50% 100%;
}

/* ── shared atoms ──────────────────────────────────────────────────────── */

.magnet {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1.35em 3.2em;
  border: 1px solid var(--line-strong);
  border-radius: 100px;
  overflow: hidden;
  isolation: isolate;
  font-family: var(--f-mono);
  font-size: var(--t-meta);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  will-change: transform;
}

.magnet__bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--signal);
  transform: translateY(101%);
  transition: transform 0.6s var(--ease);
}

.magnet__label {
  transition: color 0.4s var(--ease);
}

.magnet:hover .magnet__bg { transform: translateY(0); }
.magnet:hover .magnet__label { color: var(--ink); }

.ghostlink {
  position: relative;
  font-family: var(--f-mono);
  font-size: var(--t-meta);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-2);
  padding-bottom: 0.4em;
}

.ghostlink::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  width: 100%; height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.5s var(--ease);
}

.ghostlink:hover { color: var(--fg); }
.ghostlink:hover::after { transform: scaleX(1); transform-origin: left; }

/* ── grain + vignette ──────────────────────────────────────────────────── */

.grain {
  position: fixed;
  inset: -50%;
  z-index: 300;
  pointer-events: none;
  background-image: var(--grain-src);
  opacity: 0.038;
  mix-blend-mode: overlay;
  animation: grainShift 0.7s steps(1) infinite;
}

@keyframes grainShift {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-3%, 2%); }
  40%  { transform: translate(2%, -3%); }
  60%  { transform: translate(-2%, -2%); }
  80%  { transform: translate(3%, 1%); }
  100% { transform: translate(0, 0); }
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 299;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 45%, transparent 42%, rgba(0, 0, 0, 0.55) 100%);
}

/* ── reduced motion ────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; opacity: 0.03; }
  .eyebrow__dot { animation: none; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.08s !important;
  }
}
