/*
  effects.css
  Everything that makes the site feel like a haunted CRT:
  film grain, scanlines, the glitch "blip" transition, and the
  blood-splatter exit sting. Driven by js/effects.js.
*/

/* ---------- grain (canvas drawn + animated in js/effects.js) ---------- */
#grain-canvas{
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: var(--z-grain);
  pointer-events: none;
  opacity: 0.5;
  mix-blend-mode: overlay;
  image-rendering: pixelated;
}

/* ---------- scanlines (pure CSS, no JS needed) ---------- */
.scanlines{
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-grain) - 1);
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0.035) 0px,
    rgba(255,255,255,0.035) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: soft-light;
}
.scanlines::after{
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.55) 100%);
}

/* subtle ambient flicker on the whole viewport, never strobing */
body{
  animation: crt-flicker 6.5s infinite;
}
@keyframes crt-flicker{
  0%, 96%, 100%{ filter: none; }
  97%{ filter: brightness(1.04) contrast(1.02); }
  98%{ filter: brightness(0.97); }
}

/* ---------- glitch "blip" transition, toggled via body.glitching ---------- */
body.glitching #confession-overlay,
body.glitching #site-root{
  animation: glitch-jitter 0.55s steps(2, end);
}
body.glitching::before,
body.glitching::after{
  content: '';
  position: fixed;
  inset: 0;
  z-index: 8000;
  pointer-events: none;
  mix-blend-mode: screen;
}
body.glitching::before{
  background: rgba(255,0,90,0.12);
  transform: translateX(-4px);
  animation: glitch-shift-r 0.55s steps(2, end);
}
body.glitching::after{
  background: rgba(0,220,255,0.10);
  transform: translateX(4px);
  animation: glitch-shift-l 0.55s steps(2, end);
}

@keyframes glitch-jitter{
  0%   { clip-path: inset(0 0 0 0); transform: translate(0,0); }
  20%  { clip-path: inset(10% 0 60% 0); transform: translate(-6px,0); }
  40%  { clip-path: inset(70% 0 5% 0);  transform: translate(6px,0); }
  60%  { clip-path: inset(30% 0 40% 0); transform: translate(-3px,0); }
  80%  { clip-path: inset(5% 0 80% 0);  transform: translate(3px,0); }
  100% { clip-path: inset(0 0 0 0); transform: translate(0,0); }
}
@keyframes glitch-shift-r{
  0%, 100%{ transform: translateX(-4px); }
  50%{ transform: translateX(8px); }
}
@keyframes glitch-shift-l{
  0%, 100%{ transform: translateX(4px); }
  50%{ transform: translateX(-8px); }
}

/* ---------- blood splatter exit sting ---------- */
#blood-overlay{
  position: fixed;
  inset: 0;
  z-index: var(--z-blood);
  pointer-events: none;
  opacity: 0;
  transform: scale(1.15);
}
#blood-overlay svg{
  width: 100%;
  height: 100%;
}
#blood-overlay.show{
  opacity: 1;
  animation: blood-in 0.45s ease-out forwards;
}
#blood-overlay.show.fade{
  animation: blood-out 0.6s ease-in forwards;
}
@keyframes blood-in{
  0%{ opacity: 0; transform: scale(1.3); }
  100%{ opacity: 1; transform: scale(1); }
}
@keyframes blood-out{
  0%{ opacity: 1; }
  100%{ opacity: 0; }
}

/* ---------- "WHY??" word-wall background for the hate flow ---------- */
.bg-pattern{
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: var(--bg-black);
  opacity: 0;
  transition: opacity 0.6s ease;
  font-family: var(--font-display);
  font-size: 13px;
  line-height: 2.4;
  letter-spacing: 2px;
  color: rgba(255,45,120,0.16);
  word-spacing: 18px;
  padding: 2vh 1vw;
  user-select: none;
  -webkit-mask-image: repeating-linear-gradient(
    90deg,
    rgba(0,0,0,1) 0, rgba(0,0,0,1) 7%,
    rgba(0,0,0,0.35) 7%, rgba(0,0,0,0.35) 14%
  );
  mask-image: repeating-linear-gradient(
    90deg,
    rgba(0,0,0,1) 0, rgba(0,0,0,1) 7%,
    rgba(0,0,0,0.35) 7%, rgba(0,0,0,0.35) 14%
  );
}
.bg-pattern.active{
  opacity: 1;
}
.bg-pattern.calm{
  color: rgba(73,211,255,0.14);
}

.hate-hero{
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  text-align: center;
  pointer-events: none;
}
.hate-hero .hate-title{
  font-family: var(--font-display);
  font-size: 28px;
  color: #ffd9ec;
  text-shadow: 0 0 6px var(--accent-hate), 0 0 18px var(--accent-hate), 0 0 32px var(--accent-hate-glow);
  margin: 0 0 14px;
}
.hate-hero svg{
  width: 90px;
  height: 90px;
  margin: 0 auto;
  filter: drop-shadow(0 0 10px var(--accent-hate)) drop-shadow(0 0 22px var(--accent-hate-glow));
}
