:root {
  --bg:      0 0% 4%;
  --surface: 0 0% 8%;
  --text:    0 0% 96%;
  --muted:   0 0% 53%;
  --stroke:  0 0% 12%;
  --accent-from: #89AACC;
  --accent-to:   #4E85BF;
  --grad: linear-gradient(90deg, #89AACC 0%, #4E85BF 100%);
}

html {
  background: hsl(var(--bg));
}
body {
  background: transparent;
  color: hsl(var(--text));
  font-family: 'Inter', system-ui, sans-serif;
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
}

/* Selection */
::selection { background: #4E85BF; color: #fff; }

/* Display utility */
.display { font-family: 'Instrument Serif', serif; font-style: italic; font-weight: 400; letter-spacing: -0.01em; }
.display-roman { font-family: 'Instrument Serif', serif; font-style: normal; font-weight: 400; letter-spacing: -0.01em; }

/* Mono utility */
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

/* Tighter headline tracking */
.h-tight { letter-spacing: -0.04em; line-height: 0.92; }

/* Gradient text */
.grad-text {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ── BUTTONS ─────────────────────────────────────── */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.95rem 1.4rem;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: transform .2s ease, color .2s ease, background .2s ease;
  will-change: transform;
}
.btn:active { transform: translateY(1px); }

/* Primary: solid white-on-dark */
.btn-primary {
  background: hsl(var(--text));
  color: hsl(var(--bg));
}
.btn-primary::before {
  content: "";
  position: absolute;
  inset: -1.5px;
  border-radius: 999px;
  padding: 1.5px;
  background: var(--grad);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  opacity: 0;
  transition: opacity .25s ease;
  pointer-events: none;
}
.btn-primary:hover::before { opacity: 1; }

/* Secondary: outline */
.btn-outline {
  background: transparent;
  color: hsl(var(--text));
  border: 1px solid hsl(var(--stroke));
}
.btn-outline:hover {
  border-color: transparent;
  background-image:
    linear-gradient(hsl(var(--bg)), hsl(var(--bg))),
    var(--grad);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  border: 1px solid transparent;
}

/* Nav pill button (smaller) */
.btn-pill {
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
}

/* ── NAV PILL ────────────────────────────────────── */
.navpill {
  background: hsl(var(--surface) / 0.6);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid hsl(var(--stroke));
}

/* ── CARDS ───────────────────────────────────────── */
.card {
  background: hsl(var(--surface));
  border: 1px solid hsl(var(--stroke));
  border-radius: 22px;
  position: relative;
  overflow: hidden;
}
.card-hairline::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, hsl(var(--text) / 0.18), transparent);
}

/* ── BACKGROUND GRID ─────────────────────────────── */
.bg-grid {
  background-image:
    linear-gradient(hsl(var(--stroke) / 0.45) 1px, transparent 1px),
    linear-gradient(90deg, hsl(var(--stroke) / 0.45) 1px, transparent 1px);
  background-size: 64px 64px;
  background-position: -1px -1px;
}
.bg-grid-fade {
  mask-image: radial-gradient(ellipse 65% 55% at 50% 30%, #000 30%, transparent 75%);
}

/* ── LOADING RING (accent) ───────────────────────── */
.ring-loader {
  width: 22px; height: 22px;
  border-radius: 999px;
  background: conic-gradient(from 0deg, transparent 0%, var(--accent-from) 35%, var(--accent-to) 70%, transparent 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 0);
          mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 0);
  animation: spin 1.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── BLINKING CARET ──────────────────────────────── */
.caret {
  display: inline-block;
  width: 0.55ch;
  height: 1em;
  background: hsl(var(--text));
  vertical-align: -0.12em;
  margin-left: 0.18em;
  animation: blink 1.05s steps(2, end) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ── DIVIDER LINE ────────────────────────────────── */
.hairline { height: 1px; background: hsl(var(--stroke)); width: 100%; }

/* Subtle hover lift on cards */
.card-hover { transition: border-color .25s ease, transform .25s ease; }
.card-hover:hover { border-color: hsl(var(--muted) / 0.35); }

/* Custom hide scrollbar where needed */
.no-scrollbar::-webkit-scrollbar { display: none; }

/* Marquee */
@keyframes marquee {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}
.marquee { animation: marquee 38s linear infinite; }

/* Reveal-on-load
   End-state is the BASE style (always visible) so capture/print/no-JS shows content.
   The animation only runs when html[data-anim-ready] is set by the inline script below. */
.reveal { opacity: 1; transform: none; }
@media (prefers-reduced-motion: no-preference) {
  html[data-anim-ready] .reveal {
    animation: reveal .9s ease both;
  }
  @keyframes reveal {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: none; }
  }
  html[data-anim-ready] .d1 { animation-delay: .05s; }
  html[data-anim-ready] .d2 { animation-delay: .15s; }
  html[data-anim-ready] .d3 { animation-delay: .25s; }
  html[data-anim-ready] .d4 { animation-delay: .35s; }
  html[data-anim-ready] .d5 { animation-delay: .45s; }
  html[data-anim-ready] .d6 { animation-delay: .55s; }
}

/* Placeholder bars (data visual) */
.databar {
  height: 6px; border-radius: 999px;
  background: hsl(var(--stroke));
  overflow: hidden; position: relative;
}
.databar > i {
  position: absolute; inset: 0;
  background: var(--grad);
  transform-origin: left;
}

/* Brief tag */
.tag {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .35rem .75rem;
  border: 1px solid hsl(var(--stroke));
  border-radius: 999px;
  font-size: .75rem;
  color: hsl(var(--muted));
  background: hsl(var(--surface));
}
.tag .dot {
  width: 6px; height: 6px; border-radius: 999px;
  background: #89AACC;
  box-shadow: 0 0 0 4px hsl(var(--surface)), 0 0 12px #89AACC;
}

/* Big number numeral display */
.num {
  font-family: 'Instrument Serif', serif;
  font-style: italic;
  color: hsl(var(--muted));
}

/* Pixel-perfect hairline grid for ascii audit card */
.audit-grid {
  background-image:
    linear-gradient(hsl(var(--stroke)) 1px, transparent 1px),
    linear-gradient(90deg, hsl(var(--stroke)) 1px, transparent 1px);
  background-size: 32px 32px;
}

/* ── DYNAMIC SITE BACKGROUND ─────────────────────────
   Aurora drift + cursor spotlight + faint noise.
   Fixed behind everything · pointer-events none · GPU-only. */
.site-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
  background: hsl(var(--bg));
  contain: strict;
}

/* Aurora blobs — three slow-drifting radial gradients */
.site-bg__aurora {
  position: absolute;
  inset: -20%;
  filter: blur(60px) saturate(140%);
  opacity: 0.85;
  will-change: transform;
}
.site-bg__aurora::before,
.site-bg__aurora::after,
.site-bg__aurora > i {
  content: "";
  position: absolute;
  border-radius: 50%;
  mix-blend-mode: screen;
}
.site-bg__aurora::before {
  width: 55vmax; height: 55vmax;
  left: -10vmax; top: -10vmax;
  background: radial-gradient(circle at 50% 50%, rgba(78,133,191,0.75), transparent 65%);
  animation: aurora-a 32s ease-in-out infinite alternate;
}
.site-bg__aurora::after {
  width: 50vmax; height: 50vmax;
  right: -8vmax; top: 30vh;
  background: radial-gradient(circle at 50% 50%, rgba(137,170,204,0.65), transparent 65%);
  animation: aurora-b 38s ease-in-out infinite alternate;
}
.site-bg__aurora > i {
  width: 45vmax; height: 45vmax;
  left: 30%; bottom: -15vmax;
  background: radial-gradient(circle at 50% 50%, rgba(78,133,191,0.60), transparent 65%);
  animation: aurora-c 44s ease-in-out infinite alternate;
}

@keyframes aurora-a {
  0%   { transform: translate3d(0, 0, 0)        scale(1); }
  100% { transform: translate3d(8vw, 6vh, 0)    scale(1.15); }
}
@keyframes aurora-b {
  0%   { transform: translate3d(0, 0, 0)        scale(1.05); }
  100% { transform: translate3d(-10vw, -4vh, 0) scale(0.9); }
}
@keyframes aurora-c {
  0%   { transform: translate3d(0, 0, 0)        scale(0.95); }
  100% { transform: translate3d(6vw, -8vh, 0)   scale(1.1); }
}

/* Global animated grid — drifts + breathes */
.site-bg__grid {
  position: absolute;
  inset: -2px;
  background-image:
    linear-gradient(hsl(var(--text) / 0.045) 1px, transparent 1px),
    linear-gradient(90deg, hsl(var(--text) / 0.045) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 90% 80% at 50% 35%, #000 35%, transparent 85%);
  animation: grid-drift 28s linear infinite, grid-pulse 7s ease-in-out infinite;
  will-change: background-position, opacity;
}
@keyframes grid-drift {
  from { background-position: 0 0, 0 0; }
  to   { background-position: 56px 56px, 56px 56px; }
}
@keyframes grid-pulse {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}

/* Diagonal scan beam — sweeps across every ~14s */
.site-bg__beam {
  position: absolute;
  top: -50%;
  left: -30%;
  width: 60%;
  height: 200%;
  background: linear-gradient(
    100deg,
    transparent 0%,
    transparent 35%,
    rgba(137,170,204,0.08) 47%,
    rgba(137,170,204,0.18) 50%,
    rgba(137,170,204,0.08) 53%,
    transparent 65%,
    transparent 100%
  );
  filter: blur(2px);
  transform: translateX(-100%) rotate(8deg);
  animation: beam-sweep 14s ease-in-out infinite;
  mix-blend-mode: screen;
  will-change: transform, opacity;
}
@keyframes beam-sweep {
  0%   { transform: translateX(-30%) rotate(8deg); opacity: 0; }
  20%  { opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translateX(280%) rotate(8deg); opacity: 0; }
}

/* Cursor spotlight — driven by --mx / --my (set in JS) */
.site-bg__spot {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    700px circle at var(--mx, 50%) var(--my, 30%),
    rgba(180,210,240,0.16),
    rgba(137,170,204,0.06) 35%,
    transparent 60%
  );
  transition: background-position 0.2s ease;
  will-change: background;
}

/* Vignette to anchor the edges */
.site-bg__vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% 40%, transparent 40%, hsl(var(--bg)) 100%);
}

/* SVG noise overlay — kills banding on the aurora */
.site-bg__noise {
  position: absolute;
  inset: 0;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.6 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

@media (prefers-reduced-motion: reduce) {
  .site-bg__aurora,
  .site-bg__aurora::before,
  .site-bg__aurora::after,
  .site-bg__aurora > i,
  .site-bg__grid,
  .site-bg__beam { animation: none; }
}
