:root {
  --bg: #000000;
  --fg: #f4f7f4;
  --dim: #8a9a8a;
  --green: #00ff66;
  --red: #ff2d2d;
  --amber: #ffc234;
  --glow: 0 0 6px rgba(244, 247, 244, 0.45), 0 0 22px rgba(0, 255, 102, 0.12);
}

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

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: "JetBrains Mono", monospace;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

/* ---------- Matrix rain ---------- */
#matrix {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0.28;
}

/* ---------- CRT overlays ---------- */
.scanlines {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.32) 3px,
    rgba(0, 0, 0, 0.32) 4px
  );
  mix-blend-mode: multiply;
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 49;
  pointer-events: none;
  background: radial-gradient(
    ellipse at center,
    rgba(0, 0, 0, 0) 45%,
    rgba(0, 0, 0, 0.75) 100%
  );
}

.flicker {
  position: fixed;
  inset: 0;
  z-index: 51;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.02);
  animation: flicker 4.5s infinite steps(60);
}

@keyframes flicker {
  0%, 96%, 100% { opacity: 0; }
  97% { opacity: 0.5; }
  98% { opacity: 0; }
  99% { opacity: 0.35; }
}

/* ---------- Terminal layout ---------- */
.terminal {
  position: relative;
  z-index: 10;
  max-width: 1000px;
  margin: 0 auto;
  padding:
    calc(clamp(1.25rem, 4vw, 3.5rem) + env(safe-area-inset-top))
    calc(clamp(1rem, 4vw, 3rem) + env(safe-area-inset-right))
    calc(6rem + env(safe-area-inset-bottom))
    calc(clamp(1rem, 4vw, 3rem) + env(safe-area-inset-left));
  text-shadow: var(--glow);
}

/* ---------- Seizure banner ---------- */
.seal {
  text-align: center;
  margin-bottom: clamp(2rem, 5vw, 3.5rem);
  opacity: 0;
  transform: translateY(-12px);
}

.seal.is-live {
  opacity: 1;
  transform: none;
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.seal__badge {
  display: inline-block;
  max-width: 100%;
  font-size: clamp(0.6rem, 1.6vw, 0.85rem);
  letter-spacing: clamp(0.12em, 1vw, 0.35em);
  color: var(--amber);
  border: 1px solid rgba(255, 194, 52, 0.5);
  padding: 0.45rem 0.85rem;
  margin-bottom: clamp(1rem, 3vw, 1.75rem);
  text-shadow: 0 0 8px rgba(255, 194, 52, 0.5);
  animation: badgePulse 2.2s ease-in-out infinite;
  overflow-wrap: break-word;
  line-height: 1.6;
}

@keyframes badgePulse {
  50% { border-color: rgba(255, 194, 52, 0.95); }
}

.seal__headline {
  font-family: "JetBrains Mono", monospace;
  font-weight: 800;
  font-size: clamp(1.05rem, 3.4vw, 2.2rem);
  line-height: 1.32;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  min-height: 1.32em;
}

/* glitch tail of the caret while the headline types */
.headline-caret {
  display: inline-block;
  width: 0.62ch;
  background: var(--fg);
  box-shadow: var(--glow);
  animation: caretBlink 0.85s steps(1) infinite;
  color: transparent;
}

@keyframes caretBlink {
  50% { opacity: 0; }
}

.seal.done .seal__headline {
  animation: headlineGlitch 3.5s infinite;
}

@keyframes headlineGlitch {
  0%, 92%, 100% { transform: none; text-shadow: var(--glow); }
  93% {
    transform: translate(-2px, 0) skewX(-1deg);
    text-shadow: -2px 0 var(--red), 2px 0 var(--green);
  }
  95% {
    transform: translate(2px, 0);
    text-shadow: 2px 0 var(--red), -2px 0 var(--green);
  }
  97% { transform: none; }
}

.seal__rule {
  height: 2px;
  width: 0;
  margin: clamp(1.25rem, 3vw, 2rem) auto 0;
  background: linear-gradient(90deg, transparent, var(--green), transparent);
  box-shadow: 0 0 12px rgba(0, 255, 102, 0.6);
}

.seal.done .seal__rule {
  width: 100%;
  transition: width 1.1s ease 0.2s;
}

/* ---------- Typed feed ---------- */
.feed {
  font-size: clamp(0.85rem, 2vw, 1.05rem);
  line-height: 1.85;
}

.line {
  white-space: pre-wrap;
  word-break: break-word;
}

.line .prompt { color: var(--green); }
.line .ok { color: var(--green); }
.line .warn { color: var(--amber); }
.line .crit { color: var(--red); font-weight: 700; }
.line .dim { color: var(--dim); }

.caret {
  display: inline-block;
  width: 0.6ch;
  height: 1.05em;
  vertical-align: text-bottom;
  background: var(--fg);
  box-shadow: var(--glow);
  animation: caretBlink 0.85s steps(1) infinite;
}

/* ---------- Evidence photo ---------- */
.evidence {
  margin: clamp(1.5rem, 4vw, 2.5rem) 0;
  border: 1px solid rgba(0, 255, 102, 0.35);
  padding: 0.75rem;
  background: rgba(0, 20, 8, 0.35);
  max-width: 540px;
  opacity: 0;
  transform: scale(0.97);
  box-shadow: 0 0 28px rgba(0, 255, 102, 0.18);
}

.evidence.is-live {
  opacity: 1;
  transform: none;
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.evidence__frame {
  position: relative;
  overflow: hidden;
}

.evidence img {
  display: block;
  width: 100%;
  height: auto;
  filter: contrast(1.05) saturate(0.9) brightness(0.96);
}

/* sweeping scan bar over the photo */
.evidence__scan {
  position: absolute;
  left: 0;
  right: 0;
  height: 40%;
  top: -40%;
  background: linear-gradient(
    to bottom,
    rgba(0, 255, 102, 0) 0%,
    rgba(0, 255, 102, 0.18) 50%,
    rgba(0, 255, 102, 0) 100%
  );
  animation: scan 3.4s linear infinite;
}

@keyframes scan {
  to { top: 140%; }
}

.evidence__caption {
  margin-top: 0.6rem;
  font-family: "VT323", monospace;
  font-size: clamp(0.95rem, 2.4vw, 1.25rem);
  letter-spacing: 0.04em;
  color: var(--green);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.evidence__caption .rec {
  color: var(--red);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.evidence__caption .rec::before {
  content: "";
  width: 0.6em;
  height: 0.6em;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 8px var(--red);
  animation: caretBlink 1s steps(1) infinite;
}

/* ---------- Phones ---------- */
@media (max-width: 600px) {
  #matrix { opacity: 0.2; }

  .feed { line-height: 1.7; }

  .seal__headline { line-height: 1.4; }

  /* avoid horizontal scroll from the GG line: let exhibit caption stack */
  .evidence__caption { flex-direction: column; gap: 0.2rem; }

  /* lighter scanlines so small text stays crisp */
  .scanlines {
    background: repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0) 0px,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, 0.22) 3px,
      rgba(0, 0, 0, 0.22) 4px
    );
  }
}

/* Coarse pointers (touch): kill hover-dependent glow flicker cost */
@media (hover: none) {
  .flicker { animation-duration: 7s; }
}

/* ============================================================
   JUMP SCARE
   ============================================================ */
.jumpscare {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: none;
  background: #000;
  overflow: hidden;
  pointer-events: none;
}

/* When armed, take over the whole screen instantly */
.jumpscare.is-active {
  display: block;
  pointer-events: auto;
  animation: jsShake 0.09s linear infinite;
}

.jumpscare__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* punch-in zoom + violent color flicker */
  animation:
    jsZoom 0.6s ease-out forwards,
    jsImgFlicker 0.12s steps(1) infinite;
  transform-origin: 60% 37%; /* the subject's face */
  will-change: transform, filter;
}

/* Rapid black / white / red strobe layer over the image */
.jumpscare__strobe {
  position: absolute;
  inset: 0;
  mix-blend-mode: screen;
  animation: jsStrobe 0.1s steps(1) infinite;
}

@keyframes jsZoom {
  0%   { transform: scale(2.6); }
  100% { transform: scale(1.08); }
}

@keyframes jsShake {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-9px, 6px); }
  40%  { transform: translate(8px, -7px); }
  60%  { transform: translate(-7px, -6px); }
  80%  { transform: translate(7px, 8px); }
  100% { transform: translate(0, 0); }
}

@keyframes jsImgFlicker {
  0%   { filter: contrast(1.6) saturate(1.4) brightness(1.15); }
  33%  { filter: invert(1) contrast(2) hue-rotate(20deg) brightness(1.3); }
  66%  { filter: contrast(2.2) saturate(0) brightness(1.6); }
  100% { filter: contrast(1.5) saturate(1.2) brightness(1.05) hue-rotate(-15deg); }
}

@keyframes jsStrobe {
  0%   { background: rgba(255, 255, 255, 0.85); }
  25%  { background: rgba(0, 0, 0, 0); }
  50%  { background: rgba(255, 0, 0, 0.7); }
  75%  { background: rgba(0, 0, 0, 0); }
  100% { background: rgba(255, 255, 255, 0.55); }
}

@media (prefers-reduced-motion: reduce) {
  .flicker,
  .evidence__scan,
  .seal.done .seal__headline,
  .badgePulse { animation: none !important; }

  /* Still scary (instant full-screen image), but a gentle pulse
     instead of a seizure-risk strobe for motion-sensitive users. */
  .jumpscare.is-active { animation: none; }
  .jumpscare__img { animation: jsZoom 0.5s ease-out forwards; }
  .jumpscare__strobe { animation: jsStrobeCalm 0.6s ease-in-out infinite; }

  @keyframes jsStrobeCalm {
    0%, 100% { background: rgba(255, 0, 0, 0); }
    50%      { background: rgba(255, 0, 0, 0.35); }
  }
}
