/* ═══════════════════════════════════════════════════════════
   BASE — reset, typography, atmosphere, and the primitives
   shared by every part of the page (buttons, chips, reveal,
   cursor, preloader).
   ═══════════════════════════════════════════════════════════ */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 32px;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.6;
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
body.is-locked { overflow: hidden; }

img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; }
ul, ol { list-style: none; }
b, strong { font-weight: 600; color: var(--ink); }

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

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

.skip-link {
  position: fixed; top: 10px; left: 10px; z-index: 10000;
  padding: 10px 16px; background: var(--accent); color: var(--accent-ink);
  font: 500 var(--fs-mono)/1 var(--font-mono); letter-spacing: 0.06em;
  border-radius: var(--radius);
  transform: translateY(-180%); transition: transform var(--dur) var(--ease);
}
.skip-link:focus-visible { transform: none; }

/* ═══ SHARED TYPE PRIMITIVES ═══════════════════════════════ */

/* small mono label used as every section's eyebrow */
.tag {
  font: 500 var(--fs-micro)/1 var(--font-mono);
  letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--ink-3);
}
.tag--accent { color: var(--accent); }

/* pill status marker on cards */
.chip {
  justify-self: start;
  display: inline-flex; align-items: center;
  padding: 5px 10px; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  background: var(--accent-soft);
  color: var(--accent);
  font: 500 9.5px/1 var(--font-mono);
  letter-spacing: 0.1em; text-transform: uppercase;
  white-space: nowrap;
}
.chip.is-done {
  color: var(--ink-3); border-color: var(--line-2); background: transparent;
}

/* live status dot */
.live {
  display: inline-flex; align-items: center; gap: 8px;
  font: 500 var(--fs-mono)/1 var(--font-mono);
  letter-spacing: 0.04em; color: var(--accent);
}
.live i {
  width: 6px; height: 6px; border-radius: 50%; background: currentColor;
  box-shadow: 0 0 0 0 var(--accent-glow);
  animation: ping 2.4s var(--ease-in-out) infinite;
}
@keyframes ping {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50%      { box-shadow: 0 0 0 5px transparent; }
}

.prose { color: var(--ink-2); text-wrap: pretty; }
.prose + .prose, .prose p + p { margin-top: 0.85em; }
.prose b { color: var(--ink); }

em.serif,
.tile__title em, .block__title em, .hero__lede em, .cta__title em {
  font-family: var(--font-serif);
  font-style: italic; font-weight: 400;
  letter-spacing: 0.005em; text-transform: none;
  color: var(--accent);
}

/* ═══ ATMOSPHERE ═══════════════════════════════════════════ */

/* Film grain — one tiny inline SVG turbulence tile, no requests.
   Deliberately cheap: no mix-blend-mode (blending a viewport-sized
   layer every frame is expensive) and the drift is a stepped
   background-position, so it repaints a handful of times rather
   than continuously. */
.grain {
  position: fixed; inset: 0;
  z-index: 9000; pointer-events: none;
  opacity: var(--grain);
  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='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-shift 8s steps(1, end) infinite;
}
@keyframes grain-shift {
  0%   { background-position: 0 0; }
  20%  { background-position: -37px 22px; }
  40%  { background-position: 19px -48px; }
  60%  { background-position: -25px -17px; }
  80%  { background-position: 41px 33px; }
  100% { background-position: 0 0; }
}

/* ═══ PRELOADER ════════════════════════════════════════════ */
.preloader {
  position: fixed; inset: 0; z-index: 9800;
  display: grid; place-items: center;
  background: var(--bg);
  animation: preload-out 0.55s var(--ease) 0.72s forwards;
}
.preloader__inner { display: grid; gap: 22px; justify-items: center; }
.preloader__mark {
  font-family: var(--font-display); font-weight: 800; font-size: 2rem;
  letter-spacing: var(--tracking-tight);
  animation: preload-mark 0.7s var(--ease) both;
}
.preloader__bar {
  display: block; width: 180px; height: 1px; background: var(--line-2); overflow: hidden;
}
.preloader__bar i {
  display: block; height: 100%; width: 100%; background: var(--accent);
  transform-origin: left; transform: scaleX(0);
  animation: preload-bar 0.72s var(--ease-in-out) forwards;
}
@keyframes preload-bar  { to { transform: scaleX(1); } }
@keyframes preload-mark { from { opacity: 0; transform: translateY(14px); } }
@keyframes preload-out  { to { opacity: 0; visibility: hidden; transform: translateY(-100%); } }
html:not(.js) .preloader { display: none; }

/* ═══ CUSTOM CURSOR ════════════════════════════════════════ */
.cursor { display: none; }

@media (hover: hover) and (pointer: fine) {
  html.cursor-on,
  html.cursor-on * { cursor: none !important; }

  .cursor {
    display: block; position: fixed; inset: 0; z-index: 9700; pointer-events: none;
    transition: opacity var(--dur) var(--ease);
  }

  .cursor__dot, .cursor__ring {
    position: absolute; top: 0; left: 0; border-radius: 50%; will-change: transform;
  }

  .cursor__dot {
    width: 6px; height: 6px; margin: -3px 0 0 -3px;
    background: var(--accent);
    transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  }

  .cursor__ring {
    width: 36px; height: 36px; margin: -18px 0 0 -18px;
    border: 1px solid var(--line-2);
    display: grid; place-items: center;
    transition: width var(--dur) var(--ease), height var(--dur) var(--ease),
                margin var(--dur) var(--ease), border-color var(--dur) var(--ease),
                background-color var(--dur) var(--ease), opacity var(--dur-fast) var(--ease);
  }

  .cursor__label {
    font: 500 9px/1 var(--font-mono);
    letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-ink);
    opacity: 0; transform: scale(0.7); white-space: nowrap;
    transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  }

  .cursor.is-hot .cursor__ring {
    width: 62px; height: 62px; margin: -31px 0 0 -31px;
    border-color: transparent; background: var(--accent);
  }
  .cursor.is-hot .cursor__dot { opacity: 0; transform: scale(0.3); }
  .cursor.is-hot .cursor__label { opacity: 1; transform: none; }

  .cursor.is-soft .cursor__ring {
    width: 50px; height: 50px; margin: -25px 0 0 -25px;
    border-color: var(--accent); background: var(--accent-soft);
  }

  .cursor.is-down .cursor__ring { transform: scale(0.82); }
  .cursor.is-idle { opacity: 0; }
}

/* ═══ REVEAL / SPLIT TEXT ══════════════════════════════════ */
html.js [data-reveal] {
  opacity: 0; transform: translateY(22px);
  transition: opacity 0.8s var(--ease) var(--d, 0ms), transform 0.8s var(--ease) var(--d, 0ms);
}
html.js [data-reveal].is-in { opacity: 1; transform: none; }

html.js [data-stagger] > * {
  opacity: 0; transform: translateY(16px);
  transition: opacity 0.7s var(--ease) var(--d, 0ms), transform 0.7s var(--ease) var(--d, 0ms);
}
html.js [data-stagger].is-in > * { opacity: 1; transform: none; }

.split .word {
  display: inline-block; vertical-align: top; overflow: hidden;
  padding-bottom: 0.14em; margin-bottom: -0.14em;
  /* In chars mode each glyph is its own inline-block, which the
     browser would happily treat as a break opportunity — this
     keeps a split word from wrapping through its own middle. */
  white-space: nowrap;
}
.split .char, .split .word > .inner {
  display: inline-block; transform: translateY(115%);
  transition: transform 1s var(--ease) var(--d, 0ms);
}
.split.is-in .char, .split.is-in .word > .inner { transform: none; }

/* ═══ BUTTONS ══════════════════════════════════════════════ */
.btn {
  position: relative; display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 24px; border-radius: var(--radius);
  border: 1px solid var(--line-2); color: var(--ink);
  font: 500 var(--fs-mono)/1 var(--font-mono);
  letter-spacing: 0.08em; text-transform: uppercase;
  overflow: hidden; isolation: isolate;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.btn::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: var(--accent); transform: translateY(101%);
  transition: transform 0.5s var(--ease);
}
.btn:hover { color: var(--accent-ink); border-color: var(--accent); }
.btn:hover::before { transform: none; }
.btn svg {
  width: 13px; height: 13px; fill: none; stroke: currentColor;
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
  transition: transform var(--dur) var(--ease);
}
.btn:hover svg { transform: translateY(3px); }

.btn--solid { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--solid::before { background: var(--ink); }
.btn--solid:hover { color: var(--bg); border-color: var(--ink); }

.theme-toggle {
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 1px solid var(--line-2); border-radius: var(--radius);
  color: var(--ink-2); flex-shrink: 0;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
              background var(--dur-fast) var(--ease);
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.theme-toggle svg {
  width: 15px; height: 15px; fill: none; stroke: currentColor;
  stroke-width: 1.6; stroke-linecap: round; grid-area: 1 / 1;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
:root[data-theme='dark']  .i-sun  { opacity: 0; transform: rotate(-70deg) scale(0.6); }
:root[data-theme='light'] .i-moon { opacity: 0; transform: rotate(70deg) scale(0.6); }

[data-magnetic] { will-change: transform; }

/* ═══ REDUCED MOTION ═══════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .preloader { display: none !important; }
  html.js [data-reveal],
  html.js [data-stagger] > * { opacity: 1 !important; transform: none !important; }
  .split .char, .split .word > .inner { transform: none !important; }
  .split .word { overflow: visible; }
  .grain { animation: none; }
  .cursor { display: none !important; }
  html.cursor-on, html.cursor-on * { cursor: auto !important; }
}
