/* Project covers on the hero TV. The layer sits inside the video's box, behind the TV-frame PNG,
   so the bezel masks the edges and it lines up with the screen at every breakpoint. */
/* hide the old glitch video on the TV (also before the script runs) */
#hero video { opacity: 0 !important; }
#hero .tp-tv video { opacity: 1 !important; }

.tp-tv {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  background: #0d0d0f;
}

/* TV static, visible only in the gap between covers */
.tp-tv__noise {
  position: absolute;
  inset: -50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.1' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
  opacity: .55;
  animation: tp-tv-noise .25s steps(4) infinite;
}
@keyframes tp-tv-noise {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-12%, 7%); }
  50% { transform: translate(9%, -11%); }
  75% { transform: translate(-6%, -4%); }
  100% { transform: translate(4%, 10%); }
}

.tp-tv__slide {
  position: absolute;
  inset: 0;
  opacity: 0;
}
.tp-tv__slide img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--x, 50%) var(--y, 50%);
  transform: scale(var(--z, 1));
  transform-origin: var(--x, 50%) var(--y, 50%);
  display: block;
  /* slight CRT softness / warmth */
  filter: saturate(1.08) contrast(1.05);
}

.tp-tv__slide.is-on { opacity: 1; }
.tp-tv__slide.is-in { opacity: 1; animation: tp-tv-in .7s steps(7, end) both; }
.tp-tv__slide.is-out { opacity: 1; animation: tp-tv-out .55s steps(6, end) both; }

@keyframes tp-tv-in {
  0%   { opacity: 0; transform: translate(-8px, 0) skewX(10deg); clip-path: inset(40% 0 45% 0);
         filter: drop-shadow(-6px 0 rgba(255, 0, 70, .8)) drop-shadow(6px 0 rgba(0, 210, 255, .8)) brightness(1.8); }
  20%  { opacity: 1; transform: translate(6px, -2px) skewX(-6deg); clip-path: inset(8% 0 60% 0); }
  40%  { transform: translate(-4px, 2px); clip-path: inset(55% 0 5% 0);
         filter: drop-shadow(-4px 0 rgba(255, 0, 70, .7)) drop-shadow(4px 0 rgba(0, 210, 255, .7)) hue-rotate(40deg); }
  60%  { transform: translate(3px, 0) skewX(4deg); clip-path: inset(20% 0 25% 0); }
  80%  { transform: translate(-1px, 0); clip-path: inset(0 0 0 0);
         filter: drop-shadow(-2px 0 rgba(255, 0, 70, .5)) drop-shadow(2px 0 rgba(0, 210, 255, .5)); }
  100% { opacity: 1; transform: none; clip-path: inset(0 0 0 0); filter: none; }
}
@keyframes tp-tv-out {
  0%   { opacity: 1; transform: none; clip-path: inset(0 0 0 0); filter: none; }
  25%  { transform: translate(5px, 0) skewX(-8deg); clip-path: inset(15% 0 50% 0);
         filter: drop-shadow(-5px 0 rgba(255, 0, 70, .8)) drop-shadow(5px 0 rgba(0, 210, 255, .8)); }
  50%  { transform: translate(-7px, 2px); clip-path: inset(60% 0 10% 0); filter: brightness(2) hue-rotate(-50deg); }
  75%  { transform: translate(3px, -1px) skewX(10deg); clip-path: inset(35% 0 45% 0); opacity: .7; }
  100% { opacity: 0; transform: none; clip-path: inset(50% 0 50% 0); }
}

/* CRT overlay: scanlines, vignette, faint flicker */
.tp-tv__crt {
  position: absolute;
  inset: 0;
  z-index: 3;
  background:
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, .18) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, .45) 100%);
  mix-blend-mode: multiply;
  animation: tp-tv-flicker 4s steps(40) infinite;
}
.tp-tv__glare {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: linear-gradient(160deg, rgba(255, 255, 255, .14) 0%, transparent 35%);
}
@keyframes tp-tv-flicker {
  0%, 100% { opacity: .95; }
  50% { opacity: 1; }
  52% { opacity: .85; }
  54% { opacity: 1; }
}

/* channel label */
.tp-tv__label {
  position: absolute;
  z-index: 5;
  top: 9%;
  left: 8%;
  margin: 0;
  font-family: "Geist Mono", monospace;
  font-size: clamp(8px, 2.4cqw, 12px);
  line-height: 1;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: -1px 0 rgba(255, 0, 70, .7), 1px 0 rgba(0, 210, 255, .7), 0 0 6px rgba(255, 255, 255, .5);
  opacity: 0;
  transition: opacity .25s ease;
}
.tp-tv.has-label .tp-tv__label { opacity: .9; }
.tp-tv { container-type: inline-size; }

@media (prefers-reduced-motion: reduce) {
  .tp-tv__slide.is-in, .tp-tv__slide.is-out { animation: none; }
  .tp-tv__slide.is-out { opacity: 0; transition: opacity .4s ease; }
  .tp-tv__crt { animation: none; }
}

/* documentary channel: the teaser plays on the screen with a "press to watch" cue */
.tp-tv__slide video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--x, 50%) var(--y, 50%);
  display: block;
  filter: saturate(1.05) contrast(1.06);
}
.tp-tv__cue {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: 11%;
  transform: translateX(-50%);
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 5px;
  background: rgba(0, 0, 0, .55);
  border: 1px solid rgba(255, 255, 255, .5);
  font-family: "Geist Mono", monospace;
  font-size: clamp(8px, 2.6cqw, 13px);
  line-height: 1;
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
  color: #fff;
  text-shadow: -1px 0 rgba(255, 0, 70, .6), 1px 0 rgba(0, 210, 255, .6);
  opacity: 0;
  transition: opacity .3s ease;
}
.tp-tv__cue span { color: #ff3b3b; }
.tp-tv.has-film .tp-tv__cue { opacity: 1; animation: tp-tv-cue 1.6s steps(1) infinite; }
@keyframes tp-tv-cue { 0%, 70% { opacity: 1; } 71%, 100% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .tp-tv.has-film .tp-tv__cue { animation: none; } }
