/* SecretPicture · effects.css (Team B) — layers, masks, CRT lens, no-WebGL fallbacks.
   Tunables per host: --tvfx-opacity, --tvfx-mask, --tvfx-blend */

/* ---------- host + layer ---------- */
.tvfx-host { isolation: isolate; }
.tvfx-host.tvfx-as-bg { position: relative; }
.tvfx-host.tvfx-as-bg > .tvfx-layer { z-index: -1; }
.tvfx-layer {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  border-radius: inherit;
}
.tvfx-canvas { opacity: 0; transition: opacity 1.2s ease; }
.tvfx-host[data-tvfx-ready="true"] > .tvfx-canvas { opacity: 1; }

/* empty host = a positioned background layer (hero / CTA) */
.tvfx-as-layer[data-tv-fx="contour"],
.tvfx-as-layer[data-tv-fx="beam"],
.tvfx-as-layer[data-tv-fx="decode"],
.tvfx-as-layer[data-tv-fx="halftone"] {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  border-radius: inherit;
}

/* 1 · contour — hero background, masked so the copy column stays readable */
[data-tv-fx="contour"] {
  --tvfx-mask: radial-gradient(95% 115% at 72% 45%, #000 0%, rgba(0,0,0,.75) 40%, rgba(0,0,0,.28) 68%, transparent 92%);
}
.tvfx-as-layer[data-tv-fx="contour"] { opacity: var(--tvfx-opacity, .9); }
.tvfx-as-layer[data-tv-fx="contour"][data-tvfx-mode="light"] { opacity: var(--tvfx-opacity, .75); }
.tvfx-as-layer[data-tv-fx="contour"],
.tvfx-as-bg[data-tv-fx="contour"] > .tvfx-layer {
  -webkit-mask-image: var(--tvfx-mask);
  mask-image: var(--tvfx-mask);
}
@media (max-width: 900px) {
  [data-tv-fx="contour"] {
    --tvfx-mask: radial-gradient(130% 80% at 50% 70%, #000 0%, rgba(0,0,0,.5) 45%, transparent 85%);
  }
  .tvfx-as-layer[data-tv-fx="contour"] { opacity: var(--tvfx-opacity, .7); }
}

/* 3 · decode — analyzing screen */
.tvfx-as-layer[data-tv-fx="decode"] { background: #101313; }

/* 4 · halftone — report card paper */
.tvfx-as-layer[data-tv-fx="halftone"] { background-color: #F4F0E7; }
.tvfx-as-layer[data-tv-fx="halftone"][data-tvfx-mode="dark"] { background-color: #191E1D; }

/* 5 · beam — CTA, additive light on the dark panel */
.tvfx-as-layer[data-tv-fx="beam"] {
  opacity: var(--tvfx-opacity, .85);
  mix-blend-mode: var(--tvfx-blend, screen);
}

/* 6 · engrave — texture clipped to the wordmark (mask = its own img/svg) */
.tvfx-host[data-tvfx-preset="engrave"] { position: relative; display: block; }
.tvfx-host[data-tvfx-preset="engrave"] > .tvfx-layer {
  z-index: 1;
  -webkit-mask-size: 100% 100%; mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center;
  transition: opacity 1.2s ease;
}
/* let the footer reveal (app.js data-wordmark-motion) play first, then engrave fades in */
[data-wordmark-motion="playing"] > .tvfx-layer { opacity: 0 !important; transition: none; }
.tvfx-masked[data-tvfx-ready="true"] > img { opacity: 0; }

/* ---------- 2 · crt — loupe lens overlay (CSS only, stays crisp) ---------- */
.tvfx-crt {
  position: absolute;
  inset: 0;
  z-index: 5;
  border-radius: inherit;
  pointer-events: none;
  background:
    /* vignette */
    radial-gradient(circle at 50% 50%, transparent 58%, rgba(16,19,19,.16) 80%, rgba(16,19,19,.42) 100%),
    /* phosphor glare */
    radial-gradient(70% 45% at 34% 22%, rgba(253,253,253,.16), transparent 70%),
    /* scanlines: 1px dark every 3px, device-crisp */
    repeating-linear-gradient(to bottom, rgba(16,19,19,.16) 0 1px, transparent 1px 3px);
  /* chromatic fringe on the lens rim */
  box-shadow:
    inset 2px 0 0 rgba(254,91,69,.45),
    inset -2px 0 0 rgba(20,230,205,.45),
    inset 0 0 18px rgba(20,230,205,.18);
}
/* the evidence half reads as a surveillance feed: stronger lines + phosphor tint */
.tvfx-crt::before {
  content: "";
  position: absolute;
  inset: 0 50% 0 0;
  background:
    linear-gradient(rgba(20,230,205,.07), rgba(20,230,205,.07)),
    repeating-linear-gradient(to bottom, rgba(16,19,19,.14) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}
/* slow rolling refresh bar */
.tvfx-crt::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: -30%;
  height: 30%;
  background: linear-gradient(to bottom, transparent, rgba(20,230,205,.10) 60%, transparent);
  animation: tvfx-roll 3.8s linear infinite;
}
@keyframes tvfx-roll { to { transform: translateY(433%); } }
.tvfx-ca { filter: url(#tvfx-ca); }

/* ---------- no WebGL → CSS fallbacks ---------- */
.tvfx-fb { overflow: hidden; }
[data-tvfx-fallback][data-tv-fx="contour"] > .tvfx-fb {
  background:
    repeating-radial-gradient(ellipse 120% 90% at 70% 40%, transparent 0 22px, rgba(20,230,205,.22) 22px 23px),
    repeating-radial-gradient(ellipse 80% 120% at 20% 80%, transparent 0 30px, rgba(20,230,205,.12) 30px 31px),
    linear-gradient(160deg, #101313, #07231F);
}
[data-tvfx-fallback][data-tv-fx="contour"][data-tvfx-mode="light"] > .tvfx-fb {
  background:
    repeating-radial-gradient(ellipse 120% 90% at 70% 40%, transparent 0 22px, rgba(11,107,96,.22) 22px 23px),
    repeating-radial-gradient(ellipse 80% 120% at 20% 80%, transparent 0 30px, rgba(11,107,96,.12) 30px 31px),
    linear-gradient(160deg, #F2F5F4, #F4F0E7);
}
[data-tvfx-fallback][data-tv-fx="decode"] > .tvfx-fb {
  background:
    repeating-linear-gradient(to bottom, rgba(0,0,0,.35) 0 1px, transparent 1px 3px),
    repeating-conic-gradient(from 0deg at 50% 50%, rgba(20,230,205,.14) 0 8deg, transparent 8deg 24deg),
    radial-gradient(circle at 50% 50%, rgba(20,230,205,.35), #0A4A41 45%, #101313 75%);
  -webkit-mask-image: radial-gradient(circle, #000 40%, rgba(0,0,0,.6) 80%);
  mask-image: radial-gradient(circle, #000 40%, rgba(0,0,0,.6) 80%);
}
[data-tvfx-fallback][data-tv-fx="halftone"] > .tvfx-fb {
  background:
    radial-gradient(circle, rgba(16,19,19,.14) 0 1.6px, transparent 2.2px) 0 0 / 7px 7px,
    radial-gradient(120% 90% at 100% 0%, rgba(0,0,0,.05), transparent 60%),
    #F4F0E7;
  -webkit-mask-image: radial-gradient(140% 120% at 100% 0%, #000 20%, rgba(0,0,0,.35) 70%);
}
[data-tvfx-fallback][data-tv-fx="halftone"][data-tvfx-mode="dark"] > .tvfx-fb {
  background: radial-gradient(circle, rgba(242,245,244,.12) 0 1.6px, transparent 2.2px) 0 0 / 7px 7px, #191E1D;
}
[data-tvfx-fallback][data-tv-fx="beam"] > .tvfx-fb {
  background:
    radial-gradient(circle at 50% 45%, rgba(182,255,244,.22), transparent 18%),
    radial-gradient(circle at 50% 45%, transparent 15.5%, rgba(20,230,205,.35) 16%, transparent 17%),
    conic-gradient(from 160deg at 50% -5%, transparent 0deg, rgba(20,230,205,.18) 14deg, rgba(20,230,205,.26) 20deg, rgba(20,230,205,.18) 26deg, transparent 40deg);
}
[data-tvfx-fallback][data-tvfx-preset="engrave"] > .tvfx-fb {
  background:
    repeating-linear-gradient(0deg, rgba(20,230,205,.8) 0 1px, transparent 1px 5px),
    repeating-radial-gradient(circle at 50% 50%, rgba(20,230,205,.5) 0 1px, transparent 1px 6px),
    #0A4A41;
}
[data-tvfx-fallback][data-tvfx-preset="engrave"][data-tvfx-mode="light"] > .tvfx-fb {
  background:
    repeating-linear-gradient(0deg, rgba(242,245,244,.85) 0 1px, transparent 1px 5px),
    repeating-radial-gradient(circle at 50% 50%, rgba(242,245,244,.5) 0 1px, transparent 1px 6px),
    #0A4A41;
}

@media (prefers-reduced-motion: reduce) {
  .tvfx-crt::after { animation: none; opacity: 0; }
  .tvfx-canvas, .tvfx-host[data-tvfx-preset="engrave"] > .tvfx-layer { transition: none; }
}
