/* Olympian Holobeam Array — Master Chronometer.
   Atomic-age console: brushed steel, nixie tubes, warning lamps. 1964. */

:root {
  --bg: #0a0b0c;
  --steel-hi: #4c5054;
  --steel: #2c2f32;
  --steel-lo: #16181a;
  --engrave: #0c0d0e;
  --label: #c9cdd1;
  --nixie: #ff7a1e;
  --nixie-core: #ffe2bc;
  --nixie-glow: #ff6a00;
  --amber: #ffb347;
  --red: #ff3b30;
  --green: #46e06a;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body.screen {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: clamp(0.5rem, 3vw, 3rem);
  background:
    radial-gradient(120% 120% at 50% 30%, #15171a 0%, var(--bg) 70%);
  color: var(--label);
  font-family: "Helvetica Neue", Arial, system-ui, sans-serif;
  overflow: hidden;
}

/* --- the console body ----------------------------------------------------- */
.console {
  width: min(92vw, 880px);
}

.bezel {
  position: relative;
  padding: clamp(1rem, 3.5vw, 2.4rem);
  border-radius: 14px;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.035) 0 1px,
      transparent 1px 3px
    ),
    linear-gradient(180deg, var(--steel-hi) -20%, var(--steel) 45%, var(--steel-lo));
  border: 2px solid #0d0e0f;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.12),
    inset 0 -3px 8px rgba(0, 0, 0, 0.6),
    0 22px 60px rgba(0, 0, 0, 0.7);
}

/* corner screws */
.bezel::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 8px;
  pointer-events: none;
  background:
    radial-gradient(circle at 0 0, #555 1.5px, #1a1a1a 3px, transparent 4px) 6px 6px / 100% 100% no-repeat,
    radial-gradient(circle at 100% 0, #555 1.5px, #1a1a1a 3px, transparent 4px) -6px 6px / 100% 100% no-repeat,
    radial-gradient(circle at 0 100%, #555 1.5px, #1a1a1a 3px, transparent 4px) 6px -6px / 100% 100% no-repeat,
    radial-gradient(circle at 100% 100%, #555 1.5px, #1a1a1a 3px, transparent 4px) -6px -6px / 100% 100% no-repeat;
}

/* --- engraved plates ------------------------------------------------------ */
.plate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  letter-spacing: 0.18em;
  font-size: clamp(0.6rem, 1.6vw, 0.9rem);
  color: var(--label);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.8), 0 -1px 0 rgba(255, 255, 255, 0.06);
}
.stencil {
  font-weight: 800;
}
.subplate {
  margin: 0.35rem 0 1.1rem;
  text-align: center;
  letter-spacing: 0.3em;
  font-size: clamp(0.5rem, 1.3vw, 0.72rem);
  color: #8b9094;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.8);
}
.plate--bottom {
  margin-top: 1.2rem;
  justify-content: center;
  letter-spacing: 0.22em;
  font-size: clamp(0.45rem, 1.2vw, 0.66rem);
  color: #7d8286;
}
.rec {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  color: #9aa0a4;
}

/* --- nixie readout -------------------------------------------------------- */
.readout {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: clamp(0.15rem, 0.8vw, 0.5rem);
  padding: clamp(0.6rem, 2vw, 1.2rem) clamp(0.4rem, 2vw, 1rem);
  border-radius: 10px;
  background:
    radial-gradient(120% 160% at 50% 0%, #141312 0%, #070605 100%);
  border: 1px solid #000;
  box-shadow: inset 0 6px 18px rgba(0, 0, 0, 0.9), inset 0 -1px 0 rgba(255, 255, 255, 0.04);
}

.tube {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(2.6rem, 9vw, 5.2rem);
  padding: clamp(0.3rem, 1.5vw, 0.9rem) 0;
  border-radius: 40% 40% 38% 38% / 14% 14% 12% 12%;
  background:
    linear-gradient(180deg, rgba(80, 70, 55, 0.16), rgba(20, 16, 10, 0.05) 30%, rgba(0, 0, 0, 0.25));
  box-shadow:
    inset 0 2px 6px rgba(255, 200, 140, 0.06),
    inset 0 -8px 14px rgba(0, 0, 0, 0.6);
}
/* curvature vignette behind the digit */
.tube::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(120% 130% at 50% 45%, transparent 52%, rgba(0, 0, 0, 0.45) 100%);
}
/* curved-glass glare in front (offset to a corner so it doesn't wash the digit) */
.tube::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(55% 32% at 32% 15%, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.06) 45%, transparent 70%),
    radial-gradient(38% 22% at 72% 82%, rgba(255, 255, 255, 0.06), transparent 60%);
}

.digit {
  position: relative;
  z-index: 2;
  font-size: clamp(2.4rem, 9vw, 5.4rem);
  font-weight: 400;
  line-height: 1;
  transform: scaleY(1.18);
  color: var(--nixie-core);
  text-shadow:
    0 0 4px var(--nixie),
    0 0 14px var(--nixie-glow),
    0 0 34px var(--nixie-glow),
    0 0 60px rgba(255, 90, 0, 0.55);
  /* per-tube flicker via vars, so the communion rupture can fully override it */
  animation: tube-flicker var(--flick-dur, 6s) var(--flick-delay, 0s) infinite steps(40);
}

/* afterglow: the outgoing numeral lingers and fades (neon de-ionization) */
.ghost {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  opacity: 0;
  font-size: clamp(2.4rem, 9vw, 5.4rem);
  font-weight: 400;
  line-height: 1;
  transform: scaleY(1.18);
  color: var(--nixie-core);
  text-shadow: 0 0 4px var(--nixie), 0 0 16px var(--nixie-glow);
  pointer-events: none;
}
@keyframes tube-flicker {
  0%, 97%, 100% { opacity: 1; }
  98% { opacity: 0.86; }
  99% { opacity: 0.95; }
}

.colon {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(0.5rem, 2vw, 1.2rem);
  padding: 0 clamp(0.05rem, 0.5vw, 0.3rem);
}
.colon i {
  width: clamp(0.3rem, 1vw, 0.6rem);
  height: clamp(0.3rem, 1vw, 0.6rem);
  border-radius: 50%;
  background: var(--nixie-core);
  box-shadow: 0 0 6px var(--nixie), 0 0 16px var(--nixie-glow);
}

.srtime {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* --- lamps ---------------------------------------------------------------- */
.lamps {
  margin-top: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(1rem, 5vw, 3rem);
}
.lampcell {
  display: flex;
  align-items: center;
  gap: 0.5em;
  letter-spacing: 0.16em;
  font-size: clamp(0.55rem, 1.4vw, 0.78rem);
  color: #8b9094;
}
.lamp {
  width: 0.85em;
  height: 0.85em;
  border-radius: 50%;
  background: #2a2a2a;
  box-shadow: inset 0 0 3px #000, 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: background 0.08s, box-shadow 0.08s;
}
.lamp--rec {
  width: 0.7em;
  height: 0.7em;
}
.lamp--on {
  background: var(--green);
  box-shadow: 0 0 8px var(--green), 0 0 16px rgba(70, 224, 106, 0.6);
}
/* REC indicator: steady recording lamp (flavor). */
.lamp--rec {
  background: var(--red);
  box-shadow: 0 0 5px var(--red);
}

/* --- pulse shudder --------------------------------------------------------- */
body.pulsing #cellPulse .lamp {
  background: var(--amber);
  box-shadow: 0 0 10px var(--amber), 0 0 24px rgba(255, 179, 71, 0.8);
}
body.pulsing .bezel {
  animation: shudder 0.45s ease-out;
}
body.pulsing .digit {
  text-shadow:
    0 0 6px var(--nixie-core),
    0 0 20px var(--nixie),
    0 0 50px var(--nixie-glow),
    0 0 90px rgba(255, 120, 0, 0.8);
}
@keyframes shudder {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-3px, 1px); }
  40% { transform: translate(3px, -2px); }
  60% { transform: translate(-2px, -1px); }
  80% { transform: translate(2px, 1px); }
}

/* --- dread wash (driven by --tension, 0..1) -------------------------------- */
.screen::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 120% at 50% 50%, transparent 38%, rgba(120, 0, 0, 0.6) 100%);
  opacity: calc(var(--tension, 0) * 0.95);
  z-index: 5;
}
/* once the menace is high, the wash starts to crawl */
body.agitated::before {
  animation: wash-flicker 0.4s infinite;
}
@keyframes wash-flicker {
  0%, 100% { opacity: calc(var(--tension, 0) * 0.95); }
  50% { opacity: calc(var(--tension, 0) * 0.7); }
}

/* --- communion: Azathoth breaks through ------------------------------------ */
/* A ~6s sequence over three layers: the void (roiling black), the flash (the
   blue-white detonation), plus a console quake and digit rupture. */
.void {
  position: fixed;
  inset: 0;
  z-index: 21;
  pointer-events: none;
  opacity: 0;
  background: #000;
}
.flash {
  position: fixed;
  inset: 0;
  z-index: 22;
  pointer-events: none;
  opacity: 0;
  mix-blend-mode: screen;
  background: radial-gradient(circle at 50% 45%, #fff 0%, #dce9ff 12%, #6fb0ff 34%, #163a8f 68%, transparent 100%);
}

body.communion .console { animation: quake 2.3s cubic-bezier(0.36, 0.07, 0.19, 0.97) both; }
body.communion .void { animation: thevoid 6s ease-out forwards; }
body.communion .flash { animation: detonate 6s ease-out forwards; }
body.communion .digit { animation: digit-rupture 6s steps(60) forwards; }
body.communion .lamp { animation: panic-lamp 0.18s steps(1) 12; }

@keyframes quake {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  5% { transform: translate(-14px, 8px) rotate(-0.6deg); }
  10% { transform: translate(13px, -10px) rotate(0.5deg); }
  15% { transform: translate(-16px, -6px) rotate(0.4deg); }
  21% { transform: translate(15px, 11px) rotate(-0.5deg); }
  27% { transform: translate(-19px, 7px) rotate(0.7deg); }
  33% { transform: translate(18px, -9px) rotate(-0.6deg); }
  41% { transform: translate(-11px, 7px) rotate(0.3deg); }
  52% { transform: translate(8px, -5px) rotate(-0.2deg); }
  64% { transform: translate(-5px, 3px); }
  78% { transform: translate(3px, -2px); }
}
@keyframes detonate {
  0% { opacity: 0; }
  18% { opacity: 0.12; }
  22% { opacity: 0; }
  26% { opacity: 1; }
  30% { opacity: 0.7; }
  34% { opacity: 1; }
  44% { opacity: 0.2; }
  60% { opacity: 0.06; }
  78%, 100% { opacity: 0; }
}
@keyframes thevoid {
  0%, 30% { opacity: 0; }
  45% { opacity: 1; }
  86% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes digit-rupture {
  0% { color: var(--nixie-core); text-shadow: 0 0 4px var(--nixie), 0 0 14px var(--nixie-glow); }
  10% { color: #fff; text-shadow: -3px 0 #ff003c, 3px 0 #00e5ff, 0 0 18px #fff; }
  20% { text-shadow: 4px 0 #ff003c, -4px 0 #00e5ff, 0 0 22px #fff; }
  26% { color: #eaf3ff; text-shadow: -6px 0 #ff003c, 6px 0 #00e5ff, 0 0 30px #fff; }
  34% { opacity: 0.2; }
  40% { opacity: 1; color: #b9c6ff; text-shadow: -5px 0 #ff003c, 5px 0 #00e5ff; }
  55% { opacity: 0.5; text-shadow: -3px 0 #6a00ff, 3px 0 #00d0ff; }
  70% { opacity: 0.12; }
  82% { opacity: 0.04; }
  100% { opacity: 1; color: var(--nixie-core); text-shadow: 0 0 4px var(--nixie), 0 0 14px var(--nixie-glow); }
}
@keyframes panic-lamp {
  0% { background: var(--red); box-shadow: 0 0 10px var(--red); }
  50% { background: #1a0000; box-shadow: inset 0 0 3px #000; }
}

/* --- message overlay ------------------------------------------------------- */
.message {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 2rem;
  text-align: center;
  font-weight: 800;
  letter-spacing: 0.22em;
  font-size: clamp(1.6rem, 7vw, 4.5rem);
  color: #fff;
  text-shadow: 0 0 12px #6fb0ff, 0 0 40px #2a6bff;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s, visibility 0.4s;
}
.message.show {
  opacity: 1;
  visibility: visible;
}

/* --- offline -------------------------------------------------------------- */
body.offline .bezel {
  filter: saturate(0.5) brightness(0.85);
}

/* --- sound button --------------------------------------------------------- */
.sound {
  position: fixed;
  right: 0.8rem;
  bottom: 0.8rem;
  z-index: 40;
  padding: 0.4rem 0.8rem;
  font: inherit;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  color: #9aa0a4;
  background: #1b1d1f;
  border: 1px solid #000;
  border-radius: 6px;
  cursor: pointer;
}
.sound.on {
  color: var(--green);
  cursor: default;
}

@media (prefers-reduced-motion: reduce) {
  .digit,
  body.agitated::before,
  body.communion .console,
  body.communion .digit,
  body.communion .lamp {
    animation: none !important;
  }
}
