/* ============================================================
   Atmosphere — the room the field is observed from.

   A thin layer between the field canvas (z-index -1) and the
   content. It never takes a pointer and never covers text:

     sweep     a slow scanner band crossing the viewport, the way a
               projector beam crosses a dark hall
     scan      CRT scanlines, barely there
     grain     sensor noise, jittered in steps (one composited layer)
     vignette  the edges of the monitor

   Plus two small interactions driven by atmos.js:
     .atmos-spot  a red target glow under the cursor on cards
     [data-decrypt] mono labels that decode as they enter view

   Everything here is decoration; with this file gone the site is
   exactly what it was.
   ============================================================ */

.atmos {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
  contain: strict;
}

/* ── scanner sweep ────────────────────────────────────────── */
.atmos__sweep {
  position: absolute;
  top: -20%;
  bottom: -20%;
  left: 0;
  width: 42vw;
  min-width: 260px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgb(255 69 58 / 0.06) 36%,
    rgb(255 90 80 / 0.16) 49%,
    rgb(255 200 195 / 0.42) 50%,
    rgb(255 90 80 / 0.16) 51%,
    rgb(255 69 58 / 0.06) 64%,
    transparent 100%);
  transform: translateX(-60vw) skewX(-8deg);
  animation: atmos-sweep 7s cubic-bezier(0.45, 0, 0.55, 1) infinite;
  animation-delay: 0.6s;
  mix-blend-mode: screen;
  will-change: transform;
}

/* ── scanlines ────────────────────────────────────────────── */
.atmos__scan {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(180deg,
    rgb(255 255 255 / 0.045) 0 1px,
    transparent 1px 3px);
  opacity: 0.8;
}

/* ── grain ────────────────────────────────────────────────── */
.atmos__grain {
  position: absolute;
  inset: -50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.95' numOctaves='2' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.6 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.09;
  animation: atmos-grain 0.8s steps(5) infinite;
  will-change: transform;
}

/* ── vignette + a low red glow from below the fold ────────── */
.atmos__vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(60% 45% at 50% 108%, rgb(255 69 58 / 0.14), transparent 70%),
    radial-gradient(120% 90% at 50% 45%, transparent 50%, rgb(0 0 0 / 0.7) 100%);
}

/* ── light theme: keep the texture, drop the monitor ─────── */
[data-theme="light"] .atmos__sweep {
  mix-blend-mode: multiply;
  background: linear-gradient(90deg,
    transparent 0%,
    rgb(255 69 58 / 0.02) 40%,
    rgb(255 69 58 / 0.06) 50%,
    rgb(255 69 58 / 0.02) 60%,
    transparent 100%);
}
[data-theme="light"] .atmos__scan { display: none; }
[data-theme="light"] .atmos__grain { opacity: 0.035; filter: invert(1); }
[data-theme="light"] .atmos__vignette {
  background: radial-gradient(60% 45% at 50% 108%, rgb(255 69 58 / 0.05), transparent 70%);
}

/* Phones: lighter — no scanlines (they moiré on high-DPI panels),
   thinner grain, a slower sweep. */
@media (max-width: 720px) {
  .atmos__scan { display: none; }
  .atmos__grain { opacity: 0.07; }
  .atmos__sweep { width: 80vw; animation-duration: 9s; }
}

/* Paused while the tab is hidden (atmos.js toggles this). */
.atmos[data-paused="true"] * { animation-play-state: paused !important; }

/* ── cursor target glow on cards (mouse only) ─────────────── */
.atmos-spot {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 320ms ease;
  background:
    radial-gradient(300px circle at var(--sx, 50%) var(--sy, 50%), rgb(255 69 58 / 0.2), transparent 62%),
    radial-gradient(90px circle at var(--sx, 50%) var(--sy, 50%), rgb(255 150 140 / 0.12), transparent 70%);
  box-shadow: inset 0 0 0 1px rgb(255 69 58 / 0.35);
}
.atmos-spot--on { opacity: 1; }
[data-theme="light"] .atmos-spot {
  background: radial-gradient(260px circle at var(--sx, 50%) var(--sy, 50%), rgb(255 69 58 / 0.08), transparent 62%);
}

/* ── refresh line: a thin bright bar rolling down the screen ─ */
.atmos__roll {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 90px;
  background: linear-gradient(180deg, transparent, rgb(255 255 255 / 0.035) 70%, rgb(255 120 110 / 0.22) 98%, transparent);
  transform: translateY(-120px);
  animation: atmos-roll 9s linear infinite;
  animation-delay: 2s;
  will-change: transform;
}
[data-theme="light"] .atmos__roll { display: none; }

/* ── headline glitch: a short RGB split every few seconds ─── */
.hero__title.atmos-glitch {
  animation: atmos-glitch 420ms steps(2, end) both;
}
.hero__title.atmos-glitch .hero__line {
  text-shadow: -3px 0 rgb(255 69 58 / 0.85), 3px 0 rgb(64 220 255 / 0.7);
}

/* ── targeting ring following the mouse (desktop only) ────── */
.atmos-reticle {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 200;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border: 1px solid rgb(255 69 58 / 0.75);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 250ms, width 200ms, height 200ms, margin 200ms, border-color 200ms;
  background:
    linear-gradient(rgb(255 69 58 / 0.9), rgb(255 69 58 / 0.9)) 50% 0 / 1px 6px no-repeat,
    linear-gradient(rgb(255 69 58 / 0.9), rgb(255 69 58 / 0.9)) 50% 100% / 1px 6px no-repeat,
    linear-gradient(rgb(255 69 58 / 0.9), rgb(255 69 58 / 0.9)) 0 50% / 6px 1px no-repeat,
    linear-gradient(rgb(255 69 58 / 0.9), rgb(255 69 58 / 0.9)) 100% 50% / 6px 1px no-repeat;
  will-change: transform;
}
.atmos-reticle--on { opacity: 1; }
/* Locks on (tightens) over anything clickable. */
.atmos-reticle--lock {
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-color: rgb(255 69 58);
}

/* ── keyframes ────────────────────────────────────────────── */
@keyframes atmos-roll {
  0%   { transform: translateY(-120px); }
  100% { transform: translateY(calc(100vh + 120px)); }
}
/* The real headline only jitters; the torn slices are the ::before/::after copies. */
@keyframes atmos-glitch {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-4px, 1px) skewX(-2deg); }
  40%  { transform: translate(4px, -1px); }
  60%  { transform: translate(-2px, 0) skewX(1deg); }
  80%  { transform: translate(2px, 1px); }
  100% { transform: translate(0, 0); }
}
@keyframes atmos-sweep {
  0%   { transform: translateX(-60vw) skewX(-8deg); opacity: 0; }
  6%   { opacity: 1; }
  64%  { opacity: 1; }
  70%  { transform: translateX(120vw) skewX(-8deg); opacity: 0; }
  100% { transform: translateX(120vw) skewX(-8deg); opacity: 0; }
}
@keyframes atmos-grain {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-6%, 4%); }
  40%  { transform: translate(5%, -5%); }
  60%  { transform: translate(-3%, 7%); }
  80%  { transform: translate(7%, 2%); }
  100% { transform: translate(-4%, -3%); }
}

@media (prefers-reduced-motion: reduce) {
  .atmos__sweep, .atmos__roll, .atmos-reticle { display: none; }
  .atmos__grain { animation: none; }
  .atmos-spot { transition: none; }
}

/* ============================================================
   Headline glitch: sliced red/cyan copies of each line tearing
   sideways. Colours tuned for dark and light mode.
   ============================================================ */

/* ── headline glitch, stronger: sliced red/cyan copies ────── */
.hero__line { position: relative; }
.hero__title.atmos-glitch .hero__line::before,
.hero__title.atmos-glitch .hero__line::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.hero__title.atmos-glitch .hero__line::before {
  color: rgb(255 69 58 / 0.9);
  animation: glitch-a 420ms steps(3, end) both;
}
.hero__title.atmos-glitch .hero__line::after {
  color: rgb(64 220 255 / 0.8);
  animation: glitch-b 420ms steps(3, end) both;
}
[data-theme="light"] .hero__title.atmos-glitch .hero__line::before { color: rgb(220 30 30 / 0.85); }
[data-theme="light"] .hero__title.atmos-glitch .hero__line::after { color: rgb(0 110 230 / 0.75); }
[data-theme="light"] .hero__title.atmos-glitch .hero__line {
  text-shadow: -3px 0 rgb(220 30 30 / 0.55), 3px 0 rgb(0 110 230 / 0.5);
}

@keyframes glitch-a {
  0%   { clip-path: inset(8% 0 72% 0);  transform: translate(-10px, 0); }
  33%  { clip-path: inset(46% 0 30% 0); transform: translate(12px, 0); }
  66%  { clip-path: inset(70% 0 8% 0);  transform: translate(-6px, 0); }
  100% { clip-path: inset(100% 0 0 0);  transform: none; }
}
@keyframes glitch-b {
  0%   { clip-path: inset(60% 0 18% 0); transform: translate(10px, 0); }
  33%  { clip-path: inset(20% 0 58% 0); transform: translate(-12px, 0); }
  66%  { clip-path: inset(0 0 82% 0);   transform: translate(7px, 0); }
  100% { clip-path: inset(100% 0 0 0);  transform: none; }
}

@media (prefers-reduced-motion: reduce) {
}

/* The hero used to sit on a solid veil, so it read as a dark block
   while every section below it was see-through. Drop it: the hero
   now shows the same field, sweep and grain as the rest of the page. */
.hero__veil { display: none; }

/* One continuous ground: no alternating tinted bands between
   sections, so hero and sections read as the same surface. */
.section--elev,
[data-theme="light"] .section--elev { background: transparent; }
