/* ============================================================
   bigderag — console
   Aesthetic: Serial Experiments Lain — black CRT, blood red,
   scanlines, glitch, terminal monospace.
   Zero 3D / zero WebGL. DOM + CSS + one 2D canvas.
   ============================================================ */

:root {
  --black: #000000;
  --ink: #050506;
  --snow: #E9E9EC;
  --muted: #9AA0AA;

  /* themeable accent — driven by the console: theme red|amber|green|cyan */
  --accent: #E5342B;
  --accent-deep: #8E1A14;
  --accent-rgb: 229, 52, 43;

  --cyan: #3BE8E0;             /* chromatic split partner */
  --up: #46E08A;               /* ticker: rising */
  --down: #FF5A4E;             /* ticker: falling */
  --line: rgba(233, 233, 236, 0.18);

  --s1: 8px;  --s2: 16px; --s3: 24px; --s4: 32px;
  --s5: 40px; --s6: 48px; --s8: 64px; --s12: 96px;

  --font: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --font-type: "Special Elite", "Courier New", monospace;
  --fs-label: 12px;
  --fs-body: 14px;
  --fs-lead: 16px;

  --dur-fast: 180ms;
  --dur: 240ms;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.6;
  color: var(--snow);
  background: var(--black);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul, dl, dd, dt { margin: 0; }
ul { list-style: none; padding: 0; }
a { color: inherit; text-decoration: none; }

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

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

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

.skip-link {
  position: fixed; top: -100px; left: var(--s2); z-index: 200;
  background: var(--accent); color: var(--black);
  padding: 12px 16px; font-size: var(--fs-label);
  transition: top var(--dur) var(--ease);
}
.skip-link:focus { top: var(--s2); }

.mono { font-size: var(--fs-label); line-height: 1.55; letter-spacing: 0.04em; }

/* ============ digital rain ============ */

#rain {
  position: fixed; inset: 0;
  z-index: 0; pointer-events: none;
  opacity: 0;
  transition: opacity 700ms var(--ease);
}
body.rain-on #rain { opacity: 0.34; }

/* ============ CRT / film overlays ============ */

.fx { position: fixed; inset: 0; pointer-events: none; }

.fx-scanlines {
  z-index: 60;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0)    0px,
    rgba(0, 0, 0, 0)    2px,
    rgba(0, 0, 0, 0.28) 3px,
    rgba(0, 0, 0, 0)    4px
  );
  mix-blend-mode: multiply;
  opacity: 0.75;
}

.fx-grain {
  z-index: 61;
  opacity: 0.16;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-shift 700ms steps(6) infinite;
}

.fx-vignette {
  z-index: 59;
  background: radial-gradient(120% 90% at 50% 50%, transparent 40%, rgba(0,0,0,0.78) 100%);
}

.fx-flicker {
  z-index: 58;
  background: linear-gradient(180deg, transparent 0%, rgba(255,255,255,0.035) 45%, transparent 55%);
  background-size: 100% 320px;
  background-repeat: no-repeat;
  animation: roll 7s linear infinite;
  opacity: 0.7;
}

@keyframes grain-shift {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-6%, 4%); }
  40%  { transform: translate(4%, -6%); }
  60%  { transform: translate(-4%, -4%); }
  80%  { transform: translate(6%, 6%); }
  100% { transform: translate(0, 0); }
}
@keyframes roll {
  from { background-position: 0 -320px; }
  to   { background-position: 0 100vh; }
}

.progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px;
  z-index: 62; background: rgba(233,233,236,0.1);
}
.progress span {
  display: block; height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent));
  transform: scaleX(0); transform-origin: left center;
}

/* ============ custom cursor ============ */

.cursor { position: fixed; inset: 0; z-index: 70; pointer-events: none; display: none; }
.cursor.is-live { display: block; }
.cursor-ring, .cursor-dot {
  position: absolute; top: 0; left: 0;
  transform: translate(-50%, -50%);
  will-change: transform;
}
.cursor-ring {
  width: 34px; height: 34px;
  border: 1px solid var(--accent);
  transition: width var(--dur) var(--ease), height var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.cursor-dot { width: 5px; height: 5px; background: var(--accent); }
.cursor.is-hot .cursor-ring { width: 54px; height: 54px; opacity: 0.5; }
body.has-cursor { cursor: none; }
body.has-cursor a, body.has-cursor button, body.has-cursor input { cursor: none; }
@media (hover: hover) and (pointer: fine) {
  .cursor.is-on { display: block; }
}

/* ============ boot sequence ============ */

#boot {
  position: fixed; inset: 0; z-index: 90;
  background: var(--black);
  display: grid; place-content: center; gap: var(--s2);
  padding: var(--s4);
  transition: opacity 500ms var(--ease), visibility 500ms var(--ease);
}
#boot.is-done { opacity: 0; visibility: hidden; }
.boot-log {
  margin: 0; font-family: var(--font); font-size: var(--fs-body);
  color: var(--accent); line-height: 1.7;
  max-width: 66ch; white-space: pre-wrap; word-break: break-word;
  text-shadow: 0 0 8px rgba(var(--accent-rgb), 0.55);
}
.boot-log .ok { color: var(--snow); }
.boot-status { color: var(--muted); letter-spacing: 0.18em; }
.no-js #boot { display: none; }

/* ============ HUD ============ */

.hud { position: fixed; z-index: 55; }

/* scrims so fixed HUD text never fights the content underneath */
body::before, body::after {
  content: "";
  position: fixed; left: 0; right: 0;
  z-index: 54; pointer-events: none;
}
body::before {
  top: 0; height: 150px;
  background: linear-gradient(180deg, rgba(0,0,0,0.92) 0%, rgba(0,0,0,0.6) 45%, transparent 100%);
}
body::after {
  bottom: 0; height: 130px;
  background: linear-gradient(0deg, rgba(0,0,0,0.92) 0%, rgba(0,0,0,0.6) 45%, transparent 100%);
}

.hud-tl { top: calc(var(--s3) + env(safe-area-inset-top)); left: calc(var(--s3) + env(safe-area-inset-left)); }
.hud-tr { top: calc(var(--s3) + env(safe-area-inset-top)); right: calc(var(--s3) + env(safe-area-inset-right)); }
.hud-bl { bottom: calc(var(--s3) + env(safe-area-inset-bottom)); left: calc(var(--s3) + env(safe-area-inset-left)); }
.hud-br { bottom: calc(var(--s3) + env(safe-area-inset-bottom)); right: calc(var(--s3) + env(safe-area-inset-right)); }

.logo {
  display: inline-block;
  font-family: var(--font); font-weight: 500;
  font-size: clamp(1.2rem, 2.6vw, 1.6rem);
  letter-spacing: 0.3em;
  color: var(--snow);
}

.nav { display: flex; gap: var(--s3); }
.nav a {
  display: inline-flex; align-items: center; gap: 6px;
  position: relative;
  font-size: var(--fs-label); letter-spacing: 0.1em;
  color: var(--muted); padding: 6px 2px;
  border-bottom: 1px solid transparent;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
  text-transform: uppercase;
}
.nav a:hover, .nav a.is-active { color: var(--accent); border-color: rgba(var(--accent-rgb), 0.45); }
.nav-num { color: inherit; }

.hud-btn {
  display: inline-flex; align-items: center; gap: var(--s1);
  min-height: 44px; min-width: 44px; padding: 10px 14px;
  font: inherit; font-size: var(--fs-label);
  color: var(--snow); background: rgba(0,0,0,0.7);
  border: 1px solid var(--line); border-radius: 0;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.hud-btn:hover { border-color: var(--accent); color: var(--accent); }
.hud-btn[aria-pressed="true"] { border-color: rgba(var(--accent-rgb), 0.45); color: var(--accent); }
.ico { flex: none; }

#chapter-readout { color: var(--muted); letter-spacing: 0.14em; }

/* ============ glitch text ============ */

.glitch { position: relative; display: inline-block; }
.glitch::before, .glitch::after {
  content: attr(data-text);
  position: absolute; left: 0; top: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  opacity: 0;
}
.glitch::before { color: var(--accent); }
.glitch::after  { color: var(--cyan); }

.glitch.is-glitching::before {
  opacity: 0.9;
  animation: glitch-a 420ms steps(2, end) infinite;
}
.glitch.is-glitching::after {
  opacity: 0.9;
  animation: glitch-b 420ms steps(2, end) infinite;
}

@keyframes glitch-a {
  0%   { clip-path: inset(0 0 84% 0); transform: translate(-4px, -2px); }
  25%  { clip-path: inset(46% 0 32% 0); transform: translate(5px, 1px); }
  50%  { clip-path: inset(72% 0 8% 0);  transform: translate(-3px, 2px); }
  75%  { clip-path: inset(18% 0 62% 0); transform: translate(4px, -1px); }
  100% { clip-path: inset(0 0 90% 0);   transform: translate(-5px, 0); }
}
@keyframes glitch-b {
  0%   { clip-path: inset(66% 0 12% 0); transform: translate(4px, 2px); }
  25%  { clip-path: inset(10% 0 74% 0); transform: translate(-5px, -2px); }
  50%  { clip-path: inset(38% 0 44% 0); transform: translate(3px, -1px); }
  75%  { clip-path: inset(80% 0 4% 0);  transform: translate(-4px, 1px); }
  100% { clip-path: inset(24% 0 58% 0); transform: translate(5px, 0); }
}

@keyframes jolt {
  0%, 92%, 100% { transform: translate(0,0) skewX(0deg); }
  93%  { transform: translate(-6px, 1px) skewX(-1.5deg); }
  95%  { transform: translate(5px, -1px) skewX(1deg); }
  97%  { transform: translate(-3px, 0) skewX(-0.5deg); }
}

.blink { animation: blink 1s steps(2, end) infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }

/* ============ layout ============ */

main { position: relative; z-index: 5; }

.panel {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex; flex-direction: column; justify-content: center;
  padding:
    calc(150px + env(safe-area-inset-top))
    calc(var(--s4) + env(safe-area-inset-right))
    calc(170px + env(safe-area-inset-bottom))
    calc(var(--s4) + env(safe-area-inset-left));
}

.wrap { width: min(1120px, 100%); margin-inline: auto; min-width: 0; }

.kicker {
  font-family: var(--font-type);
  color: var(--accent);
  letter-spacing: 0.16em;
  font-size: 13px;
}

.display {
  font-size: clamp(2rem, 6vw, 4.25rem);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: var(--s2) 0 var(--s4);
  overflow-wrap: break-word;
  text-wrap: balance;
}

/* ============ hero ============ */

.hero { align-items: flex-start; }
.hero-title {
  font-size: clamp(2.75rem, 14vw, 10.5rem);
  font-weight: 500;
  line-height: 0.95;
  letter-spacing: -0.04em;
  text-transform: lowercase;
  margin: var(--s3) 0;
  animation: jolt 6s infinite;
  text-shadow: 0 0 30px rgba(var(--accent-rgb), 0.4);
}
.hero-sub { color: var(--snow); letter-spacing: 0.18em; }
.hero-sub .sep { color: var(--accent); }

.hero-foot {
  margin-top: auto;
  padding-top: var(--s8);
  display: flex; flex-wrap: wrap; gap: var(--s3);
  justify-content: space-between; align-items: flex-end;
  width: 100%;
}
.hero-coord { color: var(--muted); }

/* ============ marquee ============ */

.marquee {
  position: relative; z-index: 5;
  overflow: hidden;
  border-block: 1px solid rgba(var(--accent-rgb), 0.45);
  background: rgba(var(--accent-rgb), 0.07);
  padding: 10px 0;
}
.marquee-track {
  display: flex; width: max-content;
  animation: marquee 22s linear infinite;
}
.marquee-track span {
  font-size: var(--fs-label); letter-spacing: 0.3em;
  color: var(--accent); white-space: nowrap;
}
@keyframes marquee { to { transform: translateX(-50%); } }

/* ============ 01 · time — flip clock, calendars, usd ticker ============ */

.panel-time { justify-content: center; }

.time-head {
  display: flex; flex-wrap: wrap; align-items: baseline;
  justify-content: space-between; gap: var(--s2);
  margin-bottom: var(--s6);
}
.time-tz { color: var(--muted); letter-spacing: 0.14em; }

/* ---- flip clock ---- */

.clock-stage { position: relative; overflow: hidden; }

.clock {
  --dw: clamp(38px, 8.4vw, 112px);
  display: flex; align-items: center;
  gap: calc(var(--dw) * 0.14);
  filter: drop-shadow(0 22px 46px rgba(0, 0, 0, 0.72));
}

.dg {
  position: relative;
  width: var(--dw);
  height: calc(var(--dw) * 1.4);
  font-size: calc(var(--dw) * 1.16);
  font-weight: 500;
  line-height: 1;
  perspective: calc(var(--dw) * 5);
  border-radius: calc(var(--dw) * 0.07);
  background: #0b0b0e;
  box-shadow:
    inset 0 0 0 1px rgba(233, 233, 236, 0.11),
    inset 0 -16px 26px rgba(0, 0, 0, 0.55),
    0 16px 38px rgba(0, 0, 0, 0.6);
}

.dg::after {
  content: "";
  position: absolute; left: 0; right: 0; top: 50%;
  height: 1px; z-index: 5; pointer-events: none;
  background: rgba(0, 0, 0, 0.9);
  box-shadow: 0 1px 0 rgba(233, 233, 236, 0.08);
}

.h {
  position: absolute; left: 0;
  width: 100%; height: 50%;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.h.st, .h.ft { top: 0;    border-radius: calc(var(--dw) * 0.07) calc(var(--dw) * 0.07) 0 0; background: linear-gradient(180deg, #1b1b21, #121217); }
.h.sb, .h.fb { bottom: 0; border-radius: 0 0 calc(var(--dw) * 0.07) calc(var(--dw) * 0.07); background: linear-gradient(180deg, #0e0e12, #08080b); }
.h.st, .h.sb { z-index: 1; }
.h.ft { z-index: 3; transform-origin: 50% 100%; transform: rotateX(-90deg); }
.h.fb { z-index: 2; transform-origin: 50% 0%;   transform: rotateX(90deg); }

.h i {
  position: absolute; left: 0;
  width: 100%; height: 200%;
  display: flex; align-items: center; justify-content: center;
  font-style: normal;
  color: var(--snow);
  text-shadow: 0 0 calc(var(--dw) * 0.3) rgba(var(--accent-rgb), 0.55);
}
.h.st i, .h.ft i { top: 0; }
.h.sb i, .h.fb i { bottom: 0; }

.dg.is-flipping .ft { animation: flip-top 300ms cubic-bezier(0.42, 0, 0.78, 0.36) forwards; }
.dg.is-flipping .fb { animation: flip-bot 340ms 270ms cubic-bezier(0.24, 0.86, 0.34, 1) forwards; }

@keyframes flip-top { from { transform: rotateX(0deg); }   to { transform: rotateX(-90deg); } }
@keyframes flip-bot { from { transform: rotateX(90deg); }  to { transform: rotateX(0deg); } }

.csep {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: calc(var(--dw) * 0.3);
  width: calc(var(--dw) * 0.44);
  height: calc(var(--dw) * 1.4);
}
.csep i {
  display: block;
  width: calc(var(--dw) * 0.14);
  height: calc(var(--dw) * 0.14);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 calc(var(--dw) * 0.42) rgba(var(--accent-rgb), 0.95);
  animation: colon 1s ease-in-out infinite;
}
@keyframes colon {
  0%, 44%   { opacity: 1;    transform: scale(1); }
  56%, 100% { opacity: 0.16; transform: scale(0.66); }
}

/* long, slow light sweep across the whole clock */
.clock-stage::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  mix-blend-mode: screen;
  background: linear-gradient(105deg, transparent 34%, rgba(255, 255, 255, 0.11) 50%, transparent 66%);
  transform: translateX(-130%);
  animation: light-sweep 7.5s cubic-bezier(0.45, 0, 0.2, 1) infinite;
}
@keyframes light-sweep {
  0%      { transform: translateX(-130%); }
  46%,100% { transform: translateX(130%); }
}

/* ---- minute rail ---- */

.sec-row {
  display: flex; align-items: center; gap: var(--s3);
  margin-top: var(--s5, 40px);
  color: var(--muted); letter-spacing: 0.2em; font-size: 11px;
}
.sec-rail {
  position: relative; flex: 1 1 auto; height: 2px;
  background: rgba(233, 233, 236, 0.12);
  overflow: hidden;
}
.sec-rail span {
  position: absolute; inset: 0;
  transform-origin: left center;
  transform: scaleX(0);
  background: linear-gradient(90deg, var(--accent-deep), var(--accent), var(--snow));
  box-shadow: 0 0 14px rgba(var(--accent-rgb), 0.9);
}
#sec-pct { min-width: 4ch; text-align: right; font-variant-numeric: tabular-nums; }

/* ---- calendars ---- */

.dates {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--s3);
  margin-top: var(--s6);
}
.date-card {
  position: relative;
  padding: var(--s3) var(--s3) var(--s3) calc(var(--s3) + 4px);
  background: rgba(6, 6, 8, 0.84);
  border: 1px solid var(--line);
  overflow: hidden;
  transition: border-color var(--dur) var(--ease);
}
.date-card:hover { border-color: rgba(var(--accent-rgb), 0.5); }
.date-card::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--accent), transparent);
}
.db-label { color: var(--accent); letter-spacing: 0.18em; }
.db-dot { color: var(--muted); }
.db-value {
  font-size: clamp(1.1rem, 2.3vw, 1.65rem);
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: var(--s1) 0 var(--s2);
  overflow-wrap: anywhere;
}
/* the same day, plain digits — the loud readout under each calendar */
.db-num {
  font-size: clamp(1.25rem, 2.9vw, 2rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  text-shadow: 0 0 26px rgba(var(--accent-rgb), 0.45);
  margin-bottom: var(--s3);
}
.db-sub { color: var(--muted); letter-spacing: 0.1em; }
.year-bar {
  height: 3px; margin-bottom: var(--s2);
  background: rgba(233, 233, 236, 0.1);
  overflow: hidden;
}
.year-bar span {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent));
  box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.7);
  transition: width 1700ms var(--ease);
}

/* ---- usd ticker ---- */

.ticker {
  display: flex; flex-direction: column; gap: var(--s2);
  margin-top: var(--s3);
  padding: var(--s3);
  background: rgba(6, 6, 8, 0.84);
  border: 1px solid var(--line);
  transition: border-color 600ms var(--ease), box-shadow 600ms var(--ease);
}
.ticker.is-up   { border-color: rgba(70, 224, 138, 0.55); }
.ticker.is-down { border-color: rgba(255, 90, 78, 0.55); }
.ticker.pulse-up   { animation: pulse-up 950ms ease-out 1; }
.ticker.pulse-down { animation: pulse-down 950ms ease-out 1; }
@keyframes pulse-up {
  0%   { box-shadow: inset 0 0 0 1px rgba(70, 224, 138, 0.95), 0 0 40px rgba(70, 224, 138, 0.3); }
  100% { box-shadow: inset 0 0 0 1px transparent, 0 0 0 rgba(0, 0, 0, 0); }
}
@keyframes pulse-down {
  0%   { box-shadow: inset 0 0 0 1px rgba(255, 90, 78, 0.95), 0 0 40px rgba(255, 90, 78, 0.3); }
  100% { box-shadow: inset 0 0 0 1px transparent, 0 0 0 rgba(0, 0, 0, 0); }
}

.tick-head {
  display: flex; flex-wrap: wrap;
  justify-content: space-between; align-items: center;
  gap: var(--s2);
  color: var(--muted); letter-spacing: 0.14em;
}
.tick-slash { color: var(--accent); }
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-size: 11px; letter-spacing: 0.22em; }
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(var(--accent-rgb), 1);
  animation: live-pulse 1.6s ease-in-out infinite;
}
@keyframes live-pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.25; transform: scale(0.6); } }

.tick-body {
  display: flex; flex-wrap: wrap;
  justify-content: space-between; align-items: flex-end;
  gap: var(--s3);
}
.tick-price {
  font-size: clamp(2.1rem, 7vw, 4.4rem);
  font-weight: 500; line-height: 0.98;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}
.tick-unit {
  font-size: 0.2em; color: var(--muted);
  letter-spacing: 0.16em; margin-inline-start: 0.5em;
  vertical-align: 0.55em;
}
.tick-note { color: var(--muted); font-size: 13px; letter-spacing: 0.06em; margin-top: 6px; }

.tick-change {
  display: flex; align-items: center; gap: var(--s2);
  font-size: clamp(1rem, 2.6vw, 1.6rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  padding-bottom: 0.35em;
  color: var(--muted);
}
.tick-change.up   { color: var(--up); }
.tick-change.down { color: var(--down); }
.tick-arrow-wrap { display: inline-flex; }
.tick-change.up .tick-arrow   { animation: bob-up 1.7s ease-in-out infinite; }
.tick-change.down .tick-arrow { animation: bob-down 1.7s ease-in-out infinite; }
@keyframes bob-up   { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes bob-down { 0%,100% { transform: rotate(180deg) translateY(0); } 50% { transform: rotate(180deg) translateY(-7px); } }
.tick-delta { font-weight: 500; }
.tick-pct { font-size: 0.72em; opacity: 0.85; }

.tick-foot {
  display: flex; flex-wrap: wrap;
  justify-content: space-between; align-items: center;
  gap: var(--s2);
  padding-top: var(--s2);
  border-top: 1px solid var(--line);
}
.tick-dir {
  display: inline-flex; align-items: center;
  padding: 5px 12px;
  font-size: 11px; letter-spacing: 0.24em;
  border: 1px solid currentColor;
  color: var(--muted);
}
.tick-dir.up   { color: var(--up); }
.tick-dir.down { color: var(--down); }
.tick-meta { color: var(--muted); letter-spacing: 0.1em; }
.tick-meta.err { color: #FF6B60; }

/* ---- world clock strip ---- */

.tz-strip {
  margin-top: var(--s6);
  padding-top: var(--s3);
  border-top: 1px solid var(--line);
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}
.tz-track {
  display: flex; width: max-content;
  gap: var(--s6);
  animation: tz-scroll 46s linear infinite;
}
.tz-item {
  display: flex; align-items: baseline; gap: var(--s1);
  font-size: var(--fs-label); letter-spacing: 0.16em;
  color: var(--muted); white-space: nowrap;
}
.tz-item b { color: var(--snow); font-weight: 500; }
.tz-time { color: var(--accent); font-variant-numeric: tabular-nums; }
@keyframes tz-scroll { to { transform: translateX(-50%); } }

/* ---- scroll-driven entrance ----
   time.js writes --n0 … --n3 on .panel-time every frame:
   1 = still below the fold, 0 = fully settled. The declarations
   below default to 0, so the section stays readable even if the
   script never runs. No transitions here on purpose — these must
   track the scrollbar exactly, with zero lag. */

.panel-time { --n0: 0; --n1: 0; --n2: 0; --n3: 0; }

/* head pulls apart sideways */
.time-head { opacity: calc(1 - var(--n0) * 0.7); }
.time-head .kicker { transform: translateX(calc(var(--n0) * -70px)); }
.time-tz { transform: translateX(calc(var(--n0) * 70px)); }

/* the clock rises out of the floor, un-tilting as it lands */
.clock-stage {
  transform-origin: 50% 100%;
  transform: perspective(1400px)
             rotateX(calc(var(--n0) * 34deg))
             translateY(calc(var(--n0) * 56px))
             scale(calc(1 - var(--n0) * 0.16));
  opacity: calc(1 - var(--n0) * 0.55);
}

/* digits fan outward from the centre while the board is arriving */
.clock { --spread: clamp(0px, 2.2vw, 30px); }
.clock > :nth-child(1) { transform: translateX(calc(var(--n0) * var(--spread) * -4)); }
.clock > :nth-child(2) { transform: translateX(calc(var(--n0) * var(--spread) * -2.6)); }
.clock > :nth-child(3) { transform: translateX(calc(var(--n0) * var(--spread) * -1.7)); }
.clock > :nth-child(4) { transform: translateX(calc(var(--n0) * var(--spread) * -0.85)); }
.clock > :nth-child(5) { transform: translateX(calc(var(--n0) * var(--spread) * 0.85)); }
.clock > :nth-child(6) { transform: translateX(calc(var(--n0) * var(--spread) * 1.7)); }
.clock > :nth-child(7) { transform: translateX(calc(var(--n0) * var(--spread) * 2.6)); }
.clock > :nth-child(8) { transform: translateX(calc(var(--n0) * var(--spread) * 4)); }

/* the minute rail draws itself out from the left edge */
.sec-row {
  opacity: calc(1 - var(--n0));
  transform: scaleX(calc(1 - var(--n0) * 0.55));
  transform-origin: left center;
}

/* the two calendars climb at different speeds — parallax */
.date-card:nth-child(1) {
  transform: translateY(calc(var(--n1) * 96px));
  opacity: calc(1 - var(--n1));
}
.date-card:nth-child(2) {
  transform: translateY(calc(var(--n2) * 172px));
  opacity: calc(1 - var(--n2));
}

/* the ticker lifts in on a hinge, then the world strip follows */
.ticker {
  transform-origin: 50% 0;
  transform: perspective(1200px)
             rotateX(calc(var(--n3) * 24deg))
             translateY(calc(var(--n3) * 120px));
  opacity: calc(1 - var(--n3));
}
.tz-strip {
  transform: translateY(calc(var(--n3) * 70px));
  opacity: calc(1 - var(--n3));
}

/* ============ console ============ */

.panel-console { justify-content: center; }

.console-head {
  display: flex; flex-wrap: wrap; align-items: baseline;
  justify-content: space-between; gap: var(--s2);
  margin-bottom: var(--s3);
}
.console-hint { color: var(--muted); letter-spacing: 0.1em; }

.inline-cmd {
  font: inherit; font-size: inherit;
  color: var(--accent); background: rgba(var(--accent-rgb), 0.12);
  border: 1px solid rgba(var(--accent-rgb), 0.45);
  padding: 2px 8px; cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.inline-cmd:hover { background: var(--accent); color: var(--black); }

.term {
  display: flex; flex-direction: column;
  height: min(64vh, 560px);
  min-height: 320px;
  background: rgba(0, 0, 0, 0.88);
  border: 1px solid rgba(var(--accent-rgb), 0.45);
  box-shadow: 0 24px 70px rgba(0,0,0,0.75), 0 0 40px rgba(var(--accent-rgb), 0.08);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.term:focus-within {
  border-color: var(--accent);
  box-shadow: 0 24px 70px rgba(0,0,0,0.75), 0 0 46px rgba(var(--accent-rgb), 0.2);
}

.term-bar {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(var(--accent-rgb), 0.07);
  flex: none;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: rgba(var(--accent-rgb), 0.85); }
.dot:nth-child(1) { opacity: 1; }
.dot:nth-child(2) { opacity: 0.55; }
.dot:nth-child(3) { opacity: 0.3; }
.term-title { color: var(--muted); margin-left: var(--s1); letter-spacing: 0.08em; }

.term-out {
  flex: 1 1 auto;
  overflow-y: auto; overflow-x: hidden;
  padding: 14px 16px;
  font-size: 13px; line-height: 1.65;
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--accent-rgb), 0.6) transparent;
  overscroll-behavior: contain;
}
.term-out::-webkit-scrollbar { width: 8px; }
.term-out::-webkit-scrollbar-thumb { background: rgba(var(--accent-rgb), 0.5); }

.l        { color: var(--snow); white-space: pre-wrap; overflow-wrap: anywhere; }
.l-dim    { color: var(--muted); }
.l-accent { color: var(--accent); }
.l-err    { color: #FF6B60; }
.l-ok     { color: var(--snow); }
.l-warn   { color: #FFC857; }
.l-gap    { height: 8px; }
.l-cmd    { color: var(--snow); }
.l-cmd::before { content: "bigderag@wired:~$ "; color: var(--accent); }

.term-out pre {
  margin: 6px 0;
  font-family: var(--font);
  font-size: 11px; line-height: 1.12;
  color: var(--accent);
  white-space: pre;
  overflow-x: auto;
  text-shadow: 0 0 12px rgba(var(--accent-rgb), 0.4);
}

.term-out .l-cmd-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 2px 16px; }
.term-out .l-cmd-list b { color: var(--accent); font-weight: 500; }

.term-in {
  flex: none;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  background: rgba(0,0,0,0.5);
}
.prompt { color: var(--accent); font-size: 13px; white-space: nowrap; flex: none; }
#term-input {
  flex: 1 1 auto; min-width: 0;
  background: transparent; border: 0; outline: none;
  color: var(--snow);
  font-family: var(--font); font-size: 13px;
  caret-color: var(--accent);
  padding: 0;
}

/* ============ contact ============ */

.cta-row { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s4); }
.socials { display: flex; flex-wrap: wrap; gap: var(--s3); margin-top: var(--s4); }
.socials a {
  display: inline-flex; align-items: center; min-height: 44px;
  color: var(--muted);
  transition: color var(--dur) var(--ease);
}
.socials a:hover { color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; gap: var(--s1);
  min-height: 44px; padding: 10px 16px;
  font: inherit; font-size: var(--fs-label);
  color: var(--snow); background: transparent;
  border: 1px solid var(--line); border-radius: 0;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(var(--accent-rgb), 0.08); }
.btn .ico { transition: transform var(--dur) var(--ease); }
.btn:hover .ico { transform: translate(2px, -2px); }
.btn-solid { background: var(--accent); border-color: var(--accent); color: var(--black); font-weight: 500; }
.btn-solid:hover { background: var(--snow); border-color: var(--snow); color: var(--black); }

.site-foot {
  display: flex; flex-wrap: wrap; justify-content: space-between;
  gap: var(--s2); margin-top: var(--s8);
  padding-top: var(--s3); border-top: 1px solid var(--line);
  color: var(--muted);
}
.site-foot a { display: inline-flex; align-items: center; min-height: 44px; }
.site-foot a:hover { color: var(--accent); }

/* ============ whole-page jolt (console: glitch) ============ */

body.glitching main {
  animation: page-glitch 460ms steps(3, end) 1;
}
@keyframes page-glitch {
  0%   { transform: translate(0, 0) skewX(0deg); filter: none; }
  30%  { transform: translate(-9px, 3px) skewX(-2deg); filter: hue-rotate(25deg) saturate(1.6); }
  60%  { transform: translate(8px, -4px) skewX(1.5deg); filter: invert(0.06); }
  100% { transform: translate(0, 0) skewX(0deg); filter: none; }
}

/* ============ reveal ============ */

.js [data-reveal] {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 520ms var(--ease), transform 520ms var(--ease);
  transition-delay: var(--d, 0ms);
}
.js [data-reveal].is-in { opacity: 1; transform: none; }

/* ============ responsive ============ */

@media (max-width: 900px) {
  /* keep navigation reachable on small screens: show section numbers only,
     while the full label stays in the accessibility tree for screen readers */
  .nav-word {
    position: absolute; top: 0; left: 0;
    width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%);
    white-space: nowrap;
  }
  .nav { gap: var(--s2); }
  .nav a { min-width: 34px; min-height: 44px; justify-content: center; padding: 6px 4px; }
  .panel {
    padding-inline:
      calc(var(--s3) + env(safe-area-inset-left))
      calc(var(--s3) + env(safe-area-inset-right));
    padding-top: calc(120px + env(safe-area-inset-top));
    padding-bottom: calc(150px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 768px) {
  .time-head { margin-bottom: var(--s4); }
  .dates { grid-template-columns: 1fr; margin-top: var(--s5); }
  .tick-body { align-items: flex-start; flex-direction: column; }
  .tick-change { padding-bottom: 0; }
  .sec-row { gap: var(--s2); }
  .tz-track { gap: var(--s4); }
  .term { height: min(70vh, 520px); min-height: 300px; }
  .term-in { padding: 10px 12px; }
  .prompt, #term-input, .term-out { font-size: 12px; }
  .term-out pre { font-size: 9px; }
  .site-foot { flex-direction: column; }
}

@media (max-width: 380px) {
  .hero-title { font-size: clamp(2.2rem, 16vw, 3rem); }
  .term-title { display: none; }
}

/* ============ reduced motion / motion-off ============ */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .fx-grain, .fx-flicker, .hero-title { animation: none; }
  .marquee-track, .tz-track, .csep i, .tick-arrow, .live-dot { animation: none; }
  .clock-stage::after { animation: none; opacity: 0; }
  .panel-time { --n0: 0 !important; --n1: 0 !important; --n2: 0 !important; --n3: 0 !important; }
  .js [data-reveal] { opacity: 1; transform: none; transition: none; }
  .year-bar span { transition: none; }
  .glitch.is-glitching::before, .glitch.is-glitching::after { animation: none; opacity: 0; }
  *, *::before, *::after { transition-duration: 0.001ms !important; }
}

body.no-motion .fx-grain,
body.no-motion .fx-flicker,
body.no-motion .hero-title,
body.no-motion .marquee-track,
body.no-motion .tz-track,
body.no-motion .csep i,
body.no-motion .tick-arrow,
body.no-motion .live-dot,
body.no-motion .ticker { animation: none; }
body.no-motion .clock-stage::after { animation: none; opacity: 0; }
body.no-motion .panel-time { --n0: 0 !important; --n1: 0 !important; --n2: 0 !important; --n3: 0 !important; }
body.no-motion .year-bar span { transition: none; }
body.no-motion .glitch.is-glitching::before,
body.no-motion .glitch.is-glitching::after { animation: none; opacity: 0; }
body.no-motion [data-reveal] { opacity: 1; transform: none; transition: none; }
body.no-motion .cursor { display: none; }
body.no-motion.has-cursor { cursor: auto; }
body.no-motion #rain { opacity: 0 !important; }
