/* Style reset and base configuration */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-bg: #09090b;
  --color-card: #18181b;
  --color-border: #27272a;
  
  /* Glowing themes */
  --glow-1: #c084fc;
  --glow-2: #db2777;
  --glow-3: #4f46e5;
  
  --transition-speed: 0.4s;
  --tv-bezel-color: #1c1c1e;
  --tv-cabinet-color: #111112;
}

/* Ambient backlight themes */
body.theme-neon-purple {
  --glow-1: #8b5cf6;
  --glow-2: #ec4899;
  --glow-3: #3b82f6;
}

body.theme-sunset {
  --glow-1: #f97316;
  --glow-2: #ec4899;
  --glow-3: #eab308;
}

body.theme-cyberpunk {
  --glow-1: #06b6d4;
  --glow-2: #f43f5e;
  --glow-3: #10b981;
}

body.theme-emerald {
  --glow-1: #10b981;
  --glow-2: #06b6d4;
  --glow-3: #1e3a8a;
}

body.theme-warm {
  --glow-1: #ea580c;
  --glow-2: #ca8a04;
  --glow-3: #78350f;
}

/* Base Body Styling */
body {
  background-color: var(--color-bg);
  color: #f4f4f5;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

/* Fine grain background canvas */
.noise-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  opacity: 0.04;
  pointer-events: none;
}

/* Ambient Glow behind the TV */
.ambient-glow {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90vw;
  max-width: 1400px;
  height: 80vh;
  max-height: 800px;
  background: radial-gradient(circle, var(--glow-1) 0%, var(--glow-2) 40%, var(--glow-3) 80%, transparent 100%);
  opacity: 0.45;
  filter: blur(140px);
  z-index: 2;
  pointer-events: none;
  transition: background var(--transition-speed) ease, opacity 0.8s ease;
  animation: glowPulse 12s infinite alternate ease-in-out;
}

@keyframes glowPulse {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.4;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.15);
    opacity: 0.55;
  }
}

/* Main Container Layout */
.app-container {
  position: relative;
  z-index: 3;
  width: 100%;
  max-width: 1200px;
  min-height: 100vh;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
}

/* Header Design with Premium Typography */
.header-container {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.logo-text {
  font-family: 'Syncopate', sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  font-size: clamp(1.2rem, 3.5vw, 2.2rem);
  background: linear-gradient(135deg, #ffffff 0%, #a1a1aa 50%, #71717a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
  position: relative;
  animation: logoGlow 4s infinite alternate ease-in-out;
}

@keyframes logoGlow {
  0% {
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
  }
  100% {
    text-shadow: 0 0 25px rgba(255, 255, 255, 0.3), 0 0 5px var(--glow-1);
  }
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(239, 68, 68, 0.5);
  border-radius: 9999px;
  padding: 0.25rem 0.85rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
}

.live-dot {
  width: 8px;
  height: 8px;
  background-color: #ef4444;
  border-radius: 50%;
  box-shadow: 0 0 8px #ef4444;
  animation: liveBlink 1.5s infinite;
}

@keyframes liveBlink {
  0%, 100% { opacity: 0.3; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); }
}

.live-label {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  color: #ef4444;
}

/* Main Content Workspace */
.main-content {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 3rem;
  width: 100%;
  flex-grow: 1;
}

/* TV Cabinet/Chassis */
.tv-cabinet {
  background: linear-gradient(135deg, var(--tv-cabinet-color) 0%, #0d0d0f 100%);
  border: 14px solid var(--tv-bezel-color);
  border-top-color: #2c2c2e;
  border-left-color: #242426;
  border-right-color: #18181a;
  border-bottom-color: #151516;
  border-radius: 36px;
  box-shadow: 
    0 30px 70px rgba(0, 0, 0, 0.9),
    inset 0 4px 20px rgba(255, 255, 255, 0.05),
    inset 0 -4px 20px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: row;
  padding: 1.5rem;
  gap: 1.5rem;
  width: 100%;
  max-width: 960px;
  position: relative;
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.tv-cabinet::before {
  content: '';
  position: absolute;
  top: -8px;
  left: -8px;
  right: -8px;
  bottom: -8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 42px;
  pointer-events: none;
}

/* Bezel around the Screen */
.tv-screen-bezel {
  flex-grow: 1;
  background: #0d0d0e;
  padding: 12px;
  border-radius: 24px;
  box-shadow: 
    inset 0 0 15px rgba(0, 0, 0, 0.95),
    0 1px 3px rgba(255, 255, 255, 0.08);
  position: relative;
  aspect-ratio: 16/9;
}

.tv-screen-inner {
  width: 100%;
  height: 100%;
  background: #000;
  border-radius: 16px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 1);
}

/* Glass Screen CRT */
.tv-screen-glass {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  background-color: #0c0c0e;
  transition: filter 0.3s;
}

/* Dynamic CRT Scanlines */
.crt-scanlines {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    rgba(0, 0, 0, 0.18) 0px,
    rgba(0, 0, 0, 0.18) 1.5px,
    transparent 1.5px,
    transparent 3px
  );
  z-index: 10;
  pointer-events: none;
  opacity: 0.7;
}

/* Scanline scan roll animation */
.crt-scanlines::after {
  content: " ";
  display: block;
  position: absolute;
  top: 0; left: 0; bottom: 0; right: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
  z-index: 11;
  background-size: 100% 3px, 6px 100%;
  pointer-events: none;
}

/* Curved CRT Glass Glare Simulation */
.crt-glare {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(
    circle at 50% 15%,
    rgba(255, 255, 255, 0.08) 0%,
    rgba(255, 255, 255, 0.01) 50%,
    transparent 80%
  ),
  linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.07) 0%,
    transparent 35%,
    transparent 100%
  );
  z-index: 12;
  pointer-events: none;
}

/* Video Iframe Box */
.video-container {
  width: 100%;
  height: 100%;
  position: relative;
  background: #000;
  transform: scale(1.02); /* Slight scale to hide video frame edges */
  opacity: 1;
  transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

/* CRT Noise Static layer */
.crt-static {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #111;
  z-index: 8;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease-in-out;
}

/* CRT shutdown center dot overlay */
.crt-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  background-color: #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  box-shadow: 0 0 15px #fff, 0 0 30px #fff;
  z-index: 15;
  pointer-events: none;
  opacity: 0;
}

/* TV Cabinet Side Panel */
.tv-side-panel {
  width: 130px;
  background: #151517;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 0.75rem;
  position: relative;
}

/* Speaker Grill Mesh */
.speaker-grill {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  width: 100%;
  padding: 10px 5px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.speaker-grill span {
  height: 5px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 2px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* Dials and Knobs */
.control-dials {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  width: 100%;
  align-items: center;
}

.dial-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.dial-label {
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #71717a;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
}

.dial {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle, #3f3f46 0%, #1f1f23 70%, #09090b 100%);
  border: 3px solid #27272a;
  box-shadow: 
    0 4px 6px rgba(0,0,0,0.6), 
    inset 0 1px 2px rgba(255,255,255,0.1),
    inset 0 -1px 2px rgba(0,0,0,0.8);
  position: relative;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.1, 0.8, 0.1, 1);
}

.dial:hover {
  border-color: #52525b;
}

.dial-notch {
  width: 4px;
  height: 14px;
  background: #ffe600;
  border-radius: 2px;
  position: absolute;
  top: 2px;
  left: calc(50% - 2px);
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
}

/* Status Indicator LED */
.status-led-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.led-label {
  font-size: 0.55rem;
  font-weight: 800;
  color: #52525b;
}

.status-led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.2);
  transition: background-color 0.3s, box-shadow 0.3s;
}

.led-green {
  background-color: #22c55e;
  box-shadow: 0 0 8px #22c55e, inset 0 1px 2px rgba(255, 255, 255, 0.2);
  animation: ledPulseGreen 2s infinite alternate ease-in-out;
}

.led-red {
  background-color: #ef4444;
  box-shadow: 0 0 8px #ef4444, inset 0 1px 2px rgba(255, 255, 255, 0.2);
  animation: ledPulseRed 1s infinite alternate ease-in-out;
}

@keyframes ledPulseGreen {
  0% { opacity: 0.6; box-shadow: 0 0 4px #22c55e; }
  100% { opacity: 1; box-shadow: 0 0 12px #22c55e; }
}

@keyframes ledPulseRed {
  0% { opacity: 0.6; box-shadow: 0 0 4px #ef4444; }
  100% { opacity: 1; box-shadow: 0 0 10px #ef4444; }
}

/* Physical wood-cabinet switch button */
.physical-power-btn {
  background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%);
  border: 1px solid #7f1d1d;
  color: #fff;
  font-family: 'VT323', monospace;
  font-size: 0.95rem;
  font-weight: bold;
  letter-spacing: 0.05em;
  padding: 0.35rem 0.85rem;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 
    0 3px 0 #7f1d1d,
    0 4px 6px rgba(0, 0, 0, 0.6);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  transition: transform 0.1s, box-shadow 0.1s;
}

.physical-power-btn:active {
  transform: translateY(3px);
  box-shadow: 0 0px 0 #7f1d1d, 0 1px 3px rgba(0, 0, 0, 0.6);
}

/* Floating Remote Control Chassis */
.remote-chassis {
  background: linear-gradient(180deg, #18181b 0%, #09090b 100%);
  border: 3px solid #27272a;
  border-top-color: #3f3f46;
  border-radius: 20px;
  width: 100px;
  padding: 1.25rem 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  box-shadow: 
    0 15px 35px rgba(0, 0, 0, 0.8),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  user-select: none;
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.remote-chassis:hover {
  transform: translateY(-5px) rotate(1deg);
}

.remote-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.remote-ir {
  width: 10px;
  height: 5px;
  background: #3f3f46;
  border-radius: 5px 5px 0 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.2);
}

.remote-brand {
  font-family: 'Syncopate', sans-serif;
  font-size: 0.45rem;
  font-weight: bold;
  letter-spacing: 0.1em;
  color: #71717a;
}

.remote-grid {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  width: 100%;
  align-items: center;
}

/* Interactive Remote Buttons */
.remote-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  color: #e4e4e7;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 
    0 4px 0 #18181b,
    0 4px 6px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255,255,255,0.1);
  transition: transform 0.1s, box-shadow 0.1s, background-color 0.2s;
  position: relative;
}

.remote-btn svg {
  width: 18px;
  height: 18px;
  transition: transform 0.2s;
}

.remote-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #18181b, 0 1px 3px rgba(0, 0, 0, 0.6);
}

.remote-btn:active svg {
  transform: scale(0.9);
}

/* Specific button styles */
.btn-power {
  background: radial-gradient(circle, #ef4444 0%, #dc2626 100%);
  color: #ffffff;
  box-shadow: 
    0 4px 0 #991b1b,
    0 4px 6px rgba(0, 0, 0, 0.6);
}

.btn-power:active {
  box-shadow: 0 1px 0 #991b1b, 0 1px 3px rgba(0, 0, 0, 0.6);
}

.btn-ambient {
  background: radial-gradient(circle, #8b5cf6 0%, #7c3aed 100%);
  box-shadow: 0 4px 0 #5b21b6, 0 4px 6px rgba(0, 0, 0, 0.6);
}

.btn-ambient:active {
  box-shadow: 0 1px 0 #5b21b6, 0 1px 3px rgba(0, 0, 0, 0.6);
}

.btn-scanline {
  background: radial-gradient(circle, #4b5563 0%, #374151 100%);
  box-shadow: 0 4px 0 #1f2937, 0 4px 6px rgba(0, 0, 0, 0.6);
}

.btn-scanline:active {
  box-shadow: 0 1px 0 #1f2937, 0 1px 3px rgba(0, 0, 0, 0.6);
}

.btn-fullscreen {
  background: radial-gradient(circle, #0ea5e9 0%, #0284c7 100%);
  box-shadow: 0 4px 0 #075985, 0 4px 6px rgba(0, 0, 0, 0.6);
}

.btn-fullscreen:active {
  box-shadow: 0 1px 0 #075985, 0 1px 3px rgba(0, 0, 0, 0.6);
}

.remote-foot {
  display: flex;
  justify-content: center;
  width: 100%;
}

.remote-model {
  font-family: 'VT323', monospace;
  font-size: 0.75rem;
  color: #3f3f46;
}

/* Footer Section with elegant typography */
.footer-container {
  text-align: center;
  padding: 1.5rem 0;
}

.family-dedication {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: clamp(1rem, 2.5vw, 1.4rem);
  font-weight: 400;
  color: rgba(255, 255, 255, 0.8);
  letter-spacing: 0.05em;
  position: relative;
  display: inline-block;
  animation: footerGlow 6s infinite alternate ease-in-out;
}

.family-dedication::before,
.family-dedication::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 30px;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.4), transparent);
}

.family-dedication::before {
  right: 105%;
}

.family-dedication::after {
  left: 105%;
}

@keyframes footerGlow {
  0% {
    color: rgba(255, 255, 255, 0.75);
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.1);
  }
  100% {
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.3), 0 0 8px var(--glow-2);
  }
}

/* Screen CRT ON state details */
.tv-on {
  animation: tvWakeUp 0.8s cubic-bezier(0.15, 0.85, 0.35, 1) forwards;
}

/* Screen CRT OFF state details */
.tv-off {
  animation: tvShutDown 0.65s cubic-bezier(0.15, 0.85, 0.35, 1) forwards;
}

/* TV Screen Wake Up Keyframes */
@keyframes tvWakeUp {
  0% {
    filter: brightness(0) contrast(2);
    transform: scaleY(0.01) scaleX(0);
  }
  40% {
    filter: brightness(1) contrast(2);
    transform: scaleY(0.01) scaleX(1.02);
  }
  60% {
    filter: brightness(5) contrast(1.5);
    transform: scaleY(1.02) scaleX(1.02);
  }
  80% {
    filter: brightness(1.2) contrast(1.1);
  }
  100% {
    filter: brightness(1) contrast(1);
    transform: scaleY(1) scaleX(1);
  }
}

/* TV Screen Shut Down Keyframes */
@keyframes tvShutDown {
  0% {
    filter: brightness(1) contrast(1);
    transform: scaleY(1) scaleX(1);
  }
  30% {
    filter: brightness(5) contrast(1.5);
    transform: scaleY(0.01) scaleX(1.02);
  }
  70% {
    filter: brightness(10) contrast(3);
    transform: scaleY(0.01) scaleX(0.01);
  }
  100% {
    filter: brightness(0);
    transform: scaleY(0) scaleX(0);
  }
}

/* Static flickering overlay animation */
.static-flicker {
  animation: flickerNoise 0.15s infinite;
}

@keyframes flickerNoise {
  0% { transform: translate(0, 0) scale(1); }
  10% { transform: translate(-1%, -1%) scale(1.02); }
  30% { transform: translate(1%, 2%) scale(1.01); }
  50% { transform: translate(-2%, 0%) scale(1.03); }
  75% { transform: translate(2%, -1%) scale(0.99); }
  90% { transform: translate(-1%, 1%) scale(1.02); }
  100% { transform: translate(1%, -2%) scale(1.01); }
}

/* Scanline Toggle Class */
.hide-scanlines .crt-scanlines {
  display: none;
}

/* Cinema mode (TV fills screen) */
body.cinema-mode {
  --color-bg: #000;
}

body.cinema-mode .header-container,
body.cinema-mode .footer-container,
body.cinema-mode .remote-chassis,
body.cinema-mode .tv-side-panel {
  opacity: 0.1;
  pointer-events: none;
  filter: blur(4px);
  transition: opacity 0.5s ease, filter 0.5s ease;
}

body.cinema-mode .app-container:hover .header-container,
body.cinema-mode .app-container:hover .footer-container,
body.cinema-mode .app-container:hover .remote-chassis,
body.cinema-mode .app-container:hover .tv-side-panel {
  opacity: 1;
  pointer-events: all;
  filter: blur(0);
}

body.cinema-mode .tv-cabinet {
  transform: scale(1.1);
  box-shadow: 0 50px 100px rgba(0, 0, 0, 1);
}

/* Audio volume overlay notification */
.vol-toast {
  position: absolute;
  top: 10%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-family: 'VT323', monospace;
  font-size: 1.2rem;
  color: #ffe600;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
}

.vol-toast.show {
  opacity: 1;
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .main-content {
    flex-direction: column;
    gap: 2rem;
  }
  
  .tv-cabinet {
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
  }
  
  .tv-side-panel {
    width: 100%;
    height: auto;
    flex-direction: row;
    padding: 0.75rem 1.25rem;
    gap: 1.5rem;
  }

  .speaker-grill {
    display: none; /* Hide speakers on narrow screens to save space */
  }

  .control-dials {
    flex-direction: row;
    width: auto;
    justify-content: center;
    gap: 1.5rem;
  }

  .status-led-wrapper {
    flex-direction: row;
    gap: 8px;
  }

  .remote-chassis {
    flex-direction: row;
    width: 100%;
    max-width: 400px;
    height: auto;
    padding: 0.75rem 1.5rem;
    border-radius: 16px;
    justify-content: space-between;
  }

  .remote-head, .remote-foot {
    display: none;
  }

  .remote-grid {
    flex-direction: row;
    width: 100%;
    justify-content: space-around;
  }
}
