/* Estilos */
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #000;
}
body {
  font-family: 'Bai Jamjuree', sans-serif;
  color: white;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: 70px; /* Espacio para el footer fijo */
}
.video-container {
  position: relative;
  width: 100vw;
  flex-shrink: 0;
  padding-bottom: 150px; /* Default padding for desktop/larger screens */
  /* padding-top will be added conditionally for mobile portrait */
}
.tv-frame {
  position: relative;
  width: 100%;
  padding-top: calc(1459 / 2881 * 100%);
  background: #000;
  z-index: 1;
}
.tv-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 2;
  pointer-events: none;
}
.tv-screen {
  position: absolute;
  top: calc(120 / 1459 * 100%);
  left: calc(705 / 2881 * 100%);
  width: calc(1372 / 2881 * 100%);
  height: calc(770 / 1459 * 100%);
  z-index: 1;
  background: #000;
  overflow: hidden;
}
.tv-screen iframe, .tv-screen video {
  position: absolute;
  width: 100%;
  height: 100%;
  border: none;
  top: 0;
  left: 0;
  object-fit: cover;
}

/* Keyframes para la animación de brillo de perillas */
@keyframes subtle-glow {
  0%, 100% {
    filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.3));
  }
  50% {
    filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.7));
  }
}

/* Keyframes para el brillo eléctrico combinado de la perilla de encendido */
@keyframes idle-power-knob-animation {
    /* Pulso suave */
    0% {
        filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.3));
    }
    50% {
        filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.6));
    }
    90% {
        filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.3));
    }
    /* Parpadeo eléctrico rápido y menos intenso */
    95% {
        filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.9)) brightness(1.3);
    }
    96% {
        filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.2));
    }
    97% {
        filter: drop-shadow(0 0 20px rgba(255, 255, 255, 1)) brightness(1.6);
    }
    98% {
        filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.2));
    }
    99% {
         filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.8)) brightness(1.4);
    }
    100% {
        filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.3));
    }
}


/* Keyframes para la animación de neón encendiéndose */
@keyframes neon-turn-on {
  0% {
    opacity: 0;
    filter: drop-shadow(0 0 2px rgba(165, 65, 226, 0.5)) brightness(0.5);
  }
  10% {
    opacity: 1;
    filter: drop-shadow(0 0 5px rgba(165, 65, 226, 0.7)) brightness(1);
  }
  15% {
    opacity: 0.3;
  }
  20% {
    opacity: 1;
    filter: drop-shadow(0 0 10px rgba(165, 65, 226, 1)) brightness(1.5);
  }
  100% {
    opacity: 1;
    filter: drop-shadow(0 0 8px rgba(165, 65, 226, 0.9));
  }
}

/* Keyframes para el efecto de cortocircuito */
@keyframes short-circuit-flicker {
  0%, 98%, 100% {
    opacity: 1;
  }
  98.5% {
    opacity: 0.3;
  }
  99% {
    opacity: 1;
  }
  99.5% {
    opacity: 0.2;
  }
}


/* Estilos para las perillas */
.tv-knob {
  position: absolute;
  width: calc(150 / 2881 * 100%);
  height: auto;
  z-index: 3;
  pointer-events: auto;
  transform: scale(0.6);
  transform-origin: center;
  transition: transform 0.4s ease-in-out, filter 0.3s ease-in-out;
  /* Reset button styles */
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.tv-knob img {
  width: 100%;
  height: auto;
  pointer-events: none; /* Para que el click lo reciba el botón */
}

#knob-channel {
  top: calc(130 / 1459 * 100%);
  left: calc(2019 / 2881 * 100%);
}

#knob-channel.active-glow {
    animation: subtle-glow 2.0s ease-in-out infinite;
}

#knob-on {
  top: calc(350 / 1459 * 100%);
  left: calc(2014 / 2881 * 100%);
  transition: transform 0.4s ease-in-out, top 0.4s ease-in-out, left 0.4s ease-in-out, filter 0.3s ease-in-out; 
  filter: drop-shadow(0 0 0px rgba(255, 255, 255, 0)); 
}

#knob-on.idle-glow {
    animation: idle-power-knob-animation 8s ease-in-out infinite;
}

#knob-on:hover, #knob-channel:hover {
    filter: drop-shadow(0 0 18px rgba(255, 255, 255, 1));
}

#knob-on.rotated {
  transform: scale(0.6) rotate(90deg);
  top: calc(348 / 1471 * 100%);
  left: calc(2013 / 2872 * 100%);
}

/* Estilo para el poster de neón */
#poster-neon {
  position: absolute;
  top: calc(77 / 1459 * 100%);
  left: calc(190 / 2881 * 100%);
  width: calc(509 / 2881 * 100%);
  z-index: 2;
  pointer-events: none;
  display: none;
  opacity: 0;
}

#poster-neon.visible {
  display: block;
  animation: neon-turn-on 1s 1 ease-in-out forwards;
}

#poster-neon.flickering {
    animation: short-circuit-flicker 10s infinite linear;
}

/* Contenedor de controles, incluyendo el slider, los iconos y el nuevo texto */
.controls-wrapper {
  position: absolute;
  top: calc(900 / 1459 * 100%); /* Movido 30px hacia arriba (originalmente 930px) */
  left: 0;
  width: 100%;
  z-index: 4;
  display: flex;
  flex-direction: column; 
  align-items: center; 
}

/* Contenedor del Slider y los íconos sociales */
#main-controls {
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: opacity 0.5s ease-out, transform 0.5s ease-out, visibility 0s 0.5s;
}

#main-controls.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition-delay: 0s;
}

/* Texto de instrucción para encender la TV */
#power-on-prompt {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    text-align: center;
    color: #99999980;
    opacity: 1;
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
    font-size: 1.2em;
    letter-spacing: 1px;
    z-index: 2; /* Para que esté dentro de la pantalla pero debajo de los videos */
    pointer-events: none; /* Para no interferir con otros elementos */
}

#power-on-prompt.hidden {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 20px));
}

.slider-container {
  max-width: 1200px;
  padding: 34px 0 10px 0; /* Restaurado para dar espacio a los títulos */
  overflow-x: auto;
  white-space: nowrap;
  background: none;
  pointer-events: auto;
}
.slider-container::-webkit-scrollbar {
  height: 8px;
}
.slider-container::-webkit-scrollbar-thumb {
  background: #555;
  border-radius: 4px;
}

.thumb-wrapper {
  position: relative;
  display: inline-block;
  vertical-align: top;
  margin: 0 10px;
}

.video-thumb {
  display: inline-block;
  width: 120px; /* Reducido de 140px */
  height: 68px; /* Reducido de 79px para mantener la proporción */
  margin: 0; 
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.3s, box-shadow 0.3s, border 0.3s;
  border: 2px solid transparent;
}
.video-thumb:hover {
  transform: scale(1.05);
  box-shadow: 0 0 12px #ff8ab4;
}
.video-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-title {
    position: absolute;
    bottom: 100%; 
    left: 50%;
    padding-bottom: 18px; 
    color: #ccc;
    font-size: 14px;
    opacity: 0; 
    transform: translate(-50%, 10px);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
    pointer-events: none; 
}

.thumb-wrapper.active .video-thumb {
    border-color: #ff8ab4;
    transform: scale(1.1); /* Aumentado de 1.05 para que destaque más */
    box-shadow: 0 0 7px #ff8ab4;
}

.thumb-wrapper.active .thumb-title {
    opacity: 1;
    transform: translate(-50%, 0);
}

.social-icons {
  display: flex;
  justify-content: center;
  gap: 20px;
  pointer-events: auto; 
}
.social-icons a svg {
  fill: #7e7d7d;
  width: 22px;
  height: 22px;
  transition: fill 0.3s;
}
.social-icons a:hover svg {
  fill: #ffffff;
}

footer {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100%;
  background-color: #000;
  padding: 15px 20px;
  color: #7e7d7d;
  font-size: 14px;
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 30px;
  box-sizing: border-box;
}

/* Mensaje para rotar el teléfono */
.rotate-prompt {
  display: none; /* Oculto por defecto */
  position: fixed;
  bottom: 80px; /* Encima del footer */
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(5px);
  color: white;
  padding: 10px 20px;
  border-radius: 20px;
  z-index: 200;
  font-size: 14px;
  text-align: center;
  pointer-events: none;
}

/* --- Media Queries para Responsividad --- */

/* Estilos para móvil en orientación vertical */
@media (max-width: 768px) {
  .video-container {
    padding-top: 120px; /* Adjusted for new header height */
    padding-bottom: 70px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center; /* Centra el bloque de video y slider */
    box-sizing: border-box;
  }

  .tv-frame {
    padding-top: 0; /* No se necesita el padding-top de la imagen */
    background: none; /* No se necesita el fondo */
    padding-left: 5px;
    padding-right: 5px;
    box-sizing: border-box;
  }

  /* Ocultar solo las partes decorativas de la TV en móvil */
  .tv-frame .tv-image,
  .tv-frame .tv-knob,
  .tv-frame #poster-neon {
    display: none;
  }

  .tv-screen {
    position: relative;
    display: block;
    width: 100%;
    height: auto;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    top: auto;
    left: auto;
    transform: none;
    background: black;
    border-radius: 12px;
    overflow: hidden;
  }

  .tv-screen iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
  }

  .controls-wrapper {
    display: block;
    position: relative; /* Override absolute positioning */
    top: auto;
    left: auto;
    width: 100%;
    z-index: auto;
    margin-top: 40px; /* More space between video and slider */
  }

  #main-controls {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: none; /* Remove animations for mobile */
    position: relative;
    padding-top: 40px; /* Add space for the title */
  }

  .slider-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    padding: 10px;
    white-space: normal;
    overflow-x: hidden;
    max-width: 100%;
    box-sizing: border-box;
  }

  .thumb-wrapper {
    margin: 0; /* Reset margin as gap is used now */
  }

  #power-on-prompt{
    display: none;
  }

  .mobile-video-title {
    display: block;
  }
}

/* Estilos para móvil en orientación horizontal (landscape) */
@media (max-height: 500px) and (orientation: landscape) {
  body {
    overflow: hidden; /* Prevenir scroll en el body */
    padding-bottom: 0; /* Quitar espacio del footer */
  }

  .video-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    padding: 0; /* Eliminar padding */
  }

  .tv-frame {
    /* Solución robusta para escalar y posicionar la TV */
    position: absolute;
    top: 0; /* Al top */
    left: 0; /* A la izquierda */
    transform: none; /* Sin transformación */
    width: 77vw; /* Ocupa el 77% del ancho de la pantalla */
    height: 0; /* Necesario para el truco de padding */
    padding-top: calc(77vw * 1459 / 2881); /* Mantiene la proporción */
    max-height: 100vh; /* No debe ser más alto que la pantalla */
  }

  .controls-wrapper {
    /* El slider se superpone a la TV */
    position: absolute;
    top: 0;
    left: auto; /* Anulamos el 'left: 0' de la regla base */
    right: 0;
    width: 23vw; /* Ocupa el 23% del ancho a la derecha */
    height: 100%; /* Ocupar toda la altura */
    background: transparent; /* Fondo completamente transparente */
    backdrop-filter: none; /* Eliminar el efecto de desenfoque */
    -webkit-backdrop-filter: none; /* Para Safari */
    z-index: 10;
    display: flex;
    flex-direction: column; /* Apilar los elementos de control verticalmente */
    align-items: center; /* Centrar los elementos de control horizontalmente */
    justify-content: flex-start; /* Alinear los elementos de control al inicio (arriba) */
    padding: 20px 0;
    box-sizing: border-box;
    overflow-y: auto; /* Permitir scroll vertical para los thumbnails si hay muchos */
  }

  #main-controls {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .slider-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    white-space: normal;
    overflow-x: hidden;
    overflow-y: visible;
    padding: 0;
    width: 100%;
  }

  .thumb-wrapper {
    margin: 0 0 20px 0; /* Margen vertical entre thumbnails */
  }

  .video-thumb {
    width: 100px; /* Miniaturas un poco más pequeñas */
    height: 56px; /* Manteniendo la proporción 16:9 */
  }

  .thumb-title {
    display: none; /* Ocultar los títulos de las miniaturas en el slider */
  }

  .thumb-wrapper.active .thumb-title {
    display: none; /* Asegurar que no aparezcan incluso si están activos */
  }

  #active-video-title-display {
    display: flex;
    position: absolute;
    bottom: 12vh; /* Más arriba para mejor visibilidad */
    left: 0;
    width: 77%; /* Ocupa el espacio de la TV para no chocar con los controles */
    justify-content: center;
    font-size: 2.2em;
    color: white;
    z-index: 99; /* Z-index alto para asegurar que esté por encima de todo */
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
    pointer-events: none;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9); /* Sombra para legibilidad */
  }

  /* Ocultar elementos que no se necesitan en esta vista */
  .rotate-prompt, footer {
    display: none;
  }

   .rotate-prompt {
    display: block; /* Mostramos el mensaje */
  }
}

/* Estilos para el nuevo elemento de título activo */
#active-video-title-display {
  display: none; /* Oculto por defecto en todas las vistas */
  pointer-events: none;
}

.mobile-video-title {
  display: none; /* Oculto en desktop por defecto */
  color: #fff;
  font-size: 1.2rem;
  font-weight: bold;
  text-align: center;
  padding: 0 15px;
  opacity: 0;
  transition: opacity 0.4s ease-out, transform 0.4s ease-out;
  position: absolute;
  top: 0;
  left: 50%;
  width: 100%;
  transform: translate(-50%, 10px);
  margin-bottom: 0;
}

.mobile-video-title.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Esta clase se añade con JS para mostrar el título */
#active-video-title-display.visible {
  opacity: 1;
}

/* Ajustes finales para el footer en pantallas grandes */
@media (min-width: 769px) {
  footer {
    justify-content: center;
  }
  .mobile-header {
    display: none !important; /* Ocultar en desktop */
  }
}

/* Estilos para el menú de hamburguesa y la lista de videos en móvil */
.mobile-header {
  background-color: #000000;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1001;
  padding: 1rem 0;
  height: 120px; /* Increased height for larger logo */
  box-sizing: border-box;
}

.logo {
  position: absolute;
  top: 50%;
  left: 50%;
  height: 100px; /* Increased logo size */
  transform: translate(-50%, -50%);
  transition: all 0.4s ease-in-out;
}

.mobile-header.is-active .logo {
  left: 20px; /* Mover a la izquierda */
  height: 40px; /* Achicar */
  transform: translate(0, -50%); /* Resetear transform horizontal */
}

.hamburger-menu {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  position: absolute;
  top: 50%;
  right: 20px;
  transform: translateY(-50%);
  z-index: 1002; /* Asegurarse que esté sobre el logo */
}

.hamburger-menu span {
  display: block;
  width: 25px;
  height: 3px;
  background-color: #fff;
  transition: all 0.3s ease-in-out;
}

.hamburger-menu.is-active span:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

.hamburger-menu.is-active span:nth-child(2) {
  opacity: 0;
}

.hamburger-menu.is-active span:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

.video-list-mobile {
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
  list-style: none;
  margin: 0;
  padding: 20px 0;
  background-color: #000;
  position: fixed;
  top: 120px; /* Start below header */
  left: 0;
  width: 100%;
  height: calc(100% - 120px); /* Adjust height */
  z-index: 999;
  overflow-y: auto;
  box-sizing: border-box;
}

.video-list-mobile.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.video-list-mobile a {
  display: block;
  padding: 1rem;
  color: #fff;
  text-decoration: none;
}

.video-list-mobile a:hover,
.video-list-mobile a.active {
  background-color: #333;
}
