/* ============================================================
   GRINDHOUSE // OLD TV FRAME
   90s plastic television shell, CRT screen effects, GIF channels
   Palette: DWM blue (#005577) accents, period beige/grey plastic
   ============================================================ */

:root {
  --plastic: #d8d3c4;
  --plastic-dark: #b5ae9a;
  --plastic-shadow: #8a8470;
  --screen-bezel: #1a1a1a;
  --accent: #005577;
  --accent-glow: #00b3ff;
  --led-green: #33ff66;
  --led-red: #ff3333;
  --font-pixel: 'Press Start 2P', monospace;
  --font-mono: 'VT323', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  overflow: hidden;
  position: relative;
}

/* poster-art backdrop: the double-feature card, dimmed and blurred
   so it frames the room without fighting the TV for attention */
body::before {
  content: "";
  position: fixed;
  inset: -20px; /* overscan so the blur edge never shows */
  background: url('../img/df-poster.jpg') center center / cover no-repeat;
  filter: blur(6px) brightness(0.35) saturate(0.9);
  z-index: -2;
}

/* dark vignette between poster and TV, keeps focus centered */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.15) 0%, rgba(0,0,0,0.85) 100%);
  z-index: -1;
}

.room {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ============================================================
   TV SET SHELL
   ============================================================ */

.tv-set {
  position: relative;
  width: 640px;
  max-width: 92vw;
  background: linear-gradient(160deg, var(--plastic) 0%, var(--plastic-dark) 60%, var(--plastic-shadow) 100%);
  border-radius: 40px 40px 30px 30px;
  padding: 28px 28px 20px;
  box-shadow:
    0 30px 60px rgba(0,0,0,0.6),
    inset 0 2px 4px rgba(255,255,255,0.4),
    inset 0 -6px 10px rgba(0,0,0,0.25);
}

.tv-vents {
  position: absolute;
  top: 10px;
  right: 40px;
  width: 60px;
  height: 8px;
  background: repeating-linear-gradient(
    90deg,
    var(--plastic-shadow) 0px, var(--plastic-shadow) 3px,
    transparent 3px, transparent 7px
  );
  opacity: 0.7;
}

/* ============================================================
   SCREEN
   ============================================================ */

.tv-screen-frame {
  background: var(--screen-bezel);
  border-radius: 26px;
  padding: 22px;
  box-shadow:
    inset 0 0 0 3px #333,
    inset 0 10px 30px rgba(0,0,0,0.8);
}

.tv-screen {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: 50% / 8%;
  border-radius: 18px;
  overflow: hidden;
  box-shadow:
    inset 0 0 60px rgba(0,0,0,0.9),
    inset 0 0 10px #000;
}

.tv-content {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
  filter: saturate(1.15) contrast(1.05);
  animation: flicker-in 1.4s ease-out;
}

/* channel 1: live static noise canvas */
.tv-noise {
  display: none;
  image-rendering: pixelated;
  background: #000;
}

/* channel 1: occasional glitch gif punching through the static */
.tv-glitch {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
  z-index: 3;
  opacity: 0;
  pointer-events: none;
  display: none;
}

.tv-glitch.flash {
  animation: glitch-flash 0.25s steps(2) 1;
}

@keyframes glitch-flash {
  0%   { opacity: 0; transform: translateX(0); }
  20%  { opacity: 0.9; transform: translateX(-4px); }
  40%  { opacity: 0.2; transform: translateX(3px); }
  60%  { opacity: 0.85; transform: translateX(-2px); }
  100% { opacity: 0; transform: translateX(0); }
}

/* scanlines overlay */
.scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,0.0) 0px,
    rgba(0,0,0,0.0) 1px,
    rgba(0,0,0,0.25) 2px,
    rgba(0,0,0,0.0) 3px
  );
  pointer-events: none;
  mix-blend-mode: multiply;
}

/* CRT vignette / curvature illusion */
.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(0,0,0,0.55) 100%);
  box-shadow: inset 0 0 40px 10px rgba(0,0,0,0.6);
}

/* static noise, shown briefly on channel change */
.tv-static {
  position: absolute;
  inset: 0;
  z-index: 5;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.9" numOctaves="2" stitchTiles="stitch"/></filter><rect width="100%25" height="100%25" filter="url(%23n)" opacity="0.5"/></svg>');
  opacity: 0;
  pointer-events: none;
}

.tv-static.active {
  animation: static-burst 0.35s steps(6) 1;
}

@keyframes static-burst {
  0%   { opacity: 0.95; }
  100% { opacity: 0; }
}

@keyframes flicker-in {
  0%   { opacity: 0; filter: brightness(3) saturate(0); }
  10%  { opacity: 1; filter: brightness(0.2); }
  15%  { opacity: 0.2; }
  20%  { opacity: 1; filter: brightness(2); }
  30%  { filter: brightness(0.8); }
  100% { opacity: 1; filter: saturate(1.15) contrast(1.05); }
}

/* ============================================================
   POWER OFF / ON — classic CRT collapse-to-a-dot + warm-up
   ============================================================ */

.tv-screen.powering-off {
  animation: crt-off 0.4s cubic-bezier(0.5, 0, 0.75, 0) forwards;
}

.tv-screen.is-off {
  background: #000;
}

.tv-screen.is-off .tv-content,
.tv-screen.is-off .tv-noise,
.tv-screen.is-off .tv-glitch,
.tv-screen.is-off .scanlines,
.tv-screen.is-off .vignette,
.tv-screen.is-off .rec-overlay,
.tv-screen.is-off .tv-static {
  visibility: hidden;
}

.tv-screen.powering-on {
  animation: crt-on 0.5s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes crt-off {
  0%   { transform: scale(1, 1);     opacity: 1; filter: brightness(1.5); }
  60%  { transform: scale(1, 0.02);  opacity: 1; filter: brightness(3); }
  80%  { transform: scale(0.05, 0.02); opacity: 1; filter: brightness(4); }
  100% { transform: scale(0, 0);     opacity: 0; filter: brightness(0); }
}

@keyframes crt-on {
  0%   { transform: scale(0, 0);     opacity: 0; filter: brightness(0); }
  30%  { transform: scale(0.05, 0.02); opacity: 1; filter: brightness(4); }
  55%  { transform: scale(1, 0.02);  opacity: 1; filter: brightness(3); }
  100% { transform: scale(1, 1);     opacity: 1; filter: brightness(1); }
}

/* channel readout, top-right of screen */
.rec-overlay {
  position: absolute;
  top: 10px;
  right: 14px;
  z-index: 6;
  font-family: var(--font-mono);
  font-size: 20px;
  color: var(--led-green);
  text-shadow: 0 0 6px var(--led-green);
  opacity: 0.85;
  letter-spacing: 1px;
}

/* ============================================================
   CONTROL PANEL
   ============================================================ */

.tv-panel {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 8px;
}

.tv-brand {
  font-family: var(--font-pixel);
  font-size: 11px;
  color: var(--accent);
  text-shadow: 1px 1px 0 rgba(255,255,255,0.4);
  letter-spacing: 1px;
}

.tv-controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

.tv-knob {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: radial-gradient(circle at 35% 30%, #f0ede4, var(--plastic-dark) 70%, var(--plastic-shadow) 100%);
  box-shadow:
    0 3px 5px rgba(0,0,0,0.4),
    inset 0 1px 2px rgba(255,255,255,0.6);
  color: #444;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.tv-knob:active {
  transform: scale(0.92) rotate(15deg);
}

.power-btn {
  border: none;
  background: none;
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.power-btn:active .power-light {
  transform: scale(0.85);
}

.power-light {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--led-green);
  box-shadow: 0 0 8px var(--led-green), 0 0 2px #fff;
  animation: led-pulse 2.4s ease-in-out infinite;
  transition: background 0.2s, box-shadow 0.2s;
}

.power-light.off {
  background: var(--led-red);
  box-shadow: 0 0 4px var(--led-red);
  animation: none;
  opacity: 0.6;
}

@keyframes led-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.tv-speaker {
  display: grid;
  grid-template-columns: repeat(5, 4px);
  grid-template-rows: repeat(2, 4px);
  gap: 4px;
  opacity: 0.6;
}

.tv-speaker div {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--plastic-shadow);
  box-shadow: inset 0 1px 1px rgba(0,0,0,0.5);
}

/* ============================================================
   FEET
   ============================================================ */

.tv-feet {
  display: flex;
  justify-content: space-between;
  width: 90%;
  margin: 0 auto;
}

.foot {
  width: 36px;
  height: 14px;
  background: linear-gradient(180deg, var(--plastic-dark), var(--plastic-shadow));
  border-radius: 0 0 8px 8px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 700px) {
  .tv-set { padding: 18px 18px 14px; border-radius: 28px; }
}
