html,
body {
  margin: 0;
  padding: 0;
  background: #000;
  color: #fff;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  background: #000;
}

#player,
#player iframe,
#player-b,
#player-b iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Both players overlapping; inactive behind active via z-index. */
#player,
#player-b {
  pointer-events: none;
  opacity: 0;
}

#player {
  z-index: 1;
}

#player-b {
  z-index: 0;
}

#player.playing,
#player-b.playing {
  z-index: 2;
  pointer-events: auto;
  opacity: 1;
}

/* Debug mode: both players side-by-side at 50% */
#stage.debug-deck {
  display: flex;
}

#stage.debug-deck #player,
#stage.debug-deck #player-b {
  position: relative;
  width: 50%;
  height: 100vh;
  opacity: 1;
  z-index: 1;
  pointer-events: auto;
  border-right: 2px solid #333;
}

#stage.debug-deck #player-b {
  border-right: none;
  border-left: 2px solid #333;
}

#stage.debug-deck #player iframe,
#stage.debug-deck #player-b iframe {
  position: absolute;
}

#stage.debug-deck .overlay,
#stage.debug-deck #player-mask,
#stage.debug-deck #waiting-screen,
#stage.debug-deck #end-of-broadcast {
  display: none !important;
}

#stage.debug-deck #debug-info {
  display: block;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 36px;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  letter-spacing: 0.5px;
}

#debug-info {
  display: none;
}

#debug-info .dbg-active {
  color: #4caf50;
  font-weight: 700;
}

#debug-info .dbg-label {
  opacity: 0.5;
}

#debug-info .dbg-val {
  color: #c9a44d;
}

/* Cross-fade: source fades out, target fades in (only for non-zero xfade duration) */
.stage-xfade #player,
.stage-xfade #player-b {
  animation: none;
  transition: opacity 0.5s ease;
}

.stage-xfade .stage-xfade-out {
  opacity: 0 !important;
}

.stage-xfade .stage-xfade-in {
  opacity: 1 !important;
}

/* Cinematic letterbox bars — appear during video transitions */
#player-mask {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  overflow: hidden;
}

#player-mask::before,
#player-mask::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 5%;
  background: #000;
  transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Top bar — slides in from top */
#player-mask::before {
  top: 0;
  transform: translateY(0);
}

/* Bottom bar — slides in from bottom */
#player-mask::after {
  bottom: 0;
  transform: translateY(0);
}

/* .ready → bars retract back to the edges */
#player-mask.ready::before {
  transform: translateY(-100%);
}

#player-mask.ready::after {
  transform: translateY(100%);
}

/* .instant → bars snap without transition (used when showing mask before video load) */
#player-mask.instant::before,
#player-mask.instant::after {
  transition: none !important;
}

/* Local video player — shown when itemType === 'local' */
#player-local {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 3;
  background: #000;
}

#player-local.playing {
  display: block;
}

/* FTB (fade-to-black) — full-stage black overlay used between clips */
#ftb {
  position: absolute;
  inset: 0;
  background: #000;
  z-index: 7;
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms ease;
}

#ftb.on {
  opacity: 1;
}

#stage.debug-deck #ftb {
  display: none !important;
}




/* Mosca: permanent station bug in bottom-right corner */
#mosca {
  position: absolute;
  bottom: 28px;
  right: 22px;
  z-index: 6;
  width: 84px;
  height: 84px;
  background: rgba(0, 0, 0, .55);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

#mosca img {
  width: 38px;
  height: auto;
  display: block;
  opacity: .9;
}

#stage.debug-deck #mosca {
  display: none !important;
}

/* Player ident: tapa el icono de pausa de YouTube con efecto pixelado.
   Técnica: backdrop-filter blur fuerte (promedia colores en celdas grandes)
   + ::after con rejilla de gradients que dibuja bordes entre "píxeles".
   Funciona en Chrome/Chromium (OBS Browser Source). */
#player-ident {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 60px;
  height: 60px;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, .40);
  /* background-image: url(../logo-white.png); */

  border-radius: 50%;
  backdrop-filter: blur(20px) contrast(1.2) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) contrast(1.2) saturate(1.3);
  transition: opacity 0.55s ease;
  pointer-events: none;
  overflow: hidden;
}
svg{
  display: none;
}
/* Rejilla de píxeles 6x6 px encima del blur para ilusión de mosaico */
#player-ident::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(0, 0, 0, .45) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 0, 0, .45) 1px, transparent 1px);
  background-size: 10px 10px;
  mix-blend-mode: multiply;
  pointer-events: none;
}

#player-mask.ready #player-ident {
  opacity: 0;
}

#stage.debug-deck #player-ident {
  display: none !important;
}


.overlay {
  position: absolute;
  pointer-events: none;
  z-index: 10;
}

/* Clock */
.clock {
  bottom: 40px;
  left: 0px;
  font-size: 36px;
  font-weight: 600;
  background: rgba(0, 0, 0, 1);
  padding: 8px 18px;
  padding-left: 20px;
  border-radius: 6px;
  letter-spacing: 1px;
  z-index: 99;
}

.fragment-info {
  bottom: 5px;
  left: 0px;
  font-size: 14px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.85);
  background: transparent;
  padding: 4px 20px;
  z-index: 99;
  letter-spacing: 0.5px;
}

/* Lower third */
.lower-third {
  left: 60px;
  bottom: 136px;
  display: flex;
  align-items: stretch;
  max-width: 60%;
  z-index: 10;
  animation: ltFadeIn 0.5s ease;
}

.lt-bar {
  width: 8px;
  background: linear-gradient(180deg, #c9a44d, #8b6914);
  margin-right: 16px;
}

.lt-text {
  background: rgba(0, 0, 0, 0.72);
  padding: 18px 28px;
}

.lt-title {
  font-size: 38px;
  font-weight: 700;
  line-height: 1.1;
  text-wrap: balance;
}

.lt-title .word {
  display: inline-block;
  white-space: nowrap;
}

.lt-subtitle {
  font-size: 22px;
  font-weight: 400;
  margin-top: 6px;
  opacity: 0.85;
}

@keyframes ltFadeIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes ltFadeOut {
  from {
    opacity: 1;
    transform: none;
  }

  to {
    opacity: 0;
    transform: translateX(-20px);
  }
}

@keyframes softBlurIn {
  from {
    opacity: 0;
    transform: translateY(16px);
    filter: blur(12px);
  }

  to {
    opacity: 1;
    transform: none;
    filter: blur(0);
  }
}

@keyframes softBlurOut {
  from {
    opacity: 1;
    transform: none;
    filter: blur(0);
  }

  to {
    opacity: 0;
    transform: translateY(16px);
    filter: blur(12px);
  }
}

.lt-title .char {
  display: inline-block;
  white-space: pre;
  opacity: 0;
  animation: softBlurIn 900ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.lower-third.fade-out .lt-title .char,
.lower-third.lt-chars-exit .lt-title .char {
  animation: softBlurOut 600ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.lower-third.fade-out {
  animation: ltFadeOut 0.5s ease forwards;
}

/* Localizador */
.localizador {
  display: flex;
  flex-direction: column;
  width: 200px;
  animation: locFadeIn 0.5s ease;
  z-index: 90;
}

.loc-row {
  display: flex;
  align-items: stretch;
}

.loc-right {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.loc-bar {
  width: 6px;
  background: linear-gradient(180deg, #c9a44d, #8b6914);
  margin-right: 12px;
  flex-shrink: 0;
}

.loc-text {
  background: rgba(0, 0, 0, 0.75);
  padding: 12px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.loc-arriba {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  color: #fff;
}

.loc-abajo {
  font-size: 18px;
  font-weight: 400;
  margin-top: 4px;
  opacity: 0.85;
  color: #c9a44d;
}

.directo {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.75);
  padding: 6px 14px 6px 12px;
  width: 100%;
  box-sizing: border-box;
  animation: locFadeIn 0.5s ease;
}

.directo-pulse {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #e10600;
  flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(225, 6, 0, 0.7);
  animation: directoPulse 1.4s ease-out infinite;
}

.directo-text {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #fff;
  text-transform: uppercase;
}

@keyframes directoPulse {
  0% {
    transform: scale(0.92);
    box-shadow: 0 0 0 0 rgba(225, 6, 0, 0.7);
  }

  70% {
    transform: scale(1);
    box-shadow: 0 0 0 12px rgba(225, 6, 0, 0);
  }

  100% {
    transform: scale(0.92);
    box-shadow: 0 0 0 0 rgba(225, 6, 0, 0);
  }
}

@keyframes locFadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* Gaceta */
.gaceta {
  left: 0;
  bottom: 96px;
  height: 40px;
  background: rgba(0, 0, 0, 0.75);
  z-index: 95;
  padding-right: 20px;
}

.gaceta-viewport {
  overflow: hidden;
  height: 100%;
  width: 100%;
  position: relative;
}

.gaceta-slide {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  position: absolute;
  left: 0;
  right: 0;
  height: 100%;
  will-change: transform;
}

.gaceta-time {
  font-size: 24px;
  font-weight: 700;
  color: #c9a44d;
  white-space: nowrap;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  flex-shrink: 0;
}

.gaceta-title {
  font-size: 22px;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
}

/* Crawl */
.crawl {
  left: 0;
  right: 64px;
  bottom: 40px;
  height: 56px;
  background: linear-gradient(to right, rgba(0,0,0,0.7) 85%, rgba(0,0,0,0.55) 100%);
  overflow: hidden;
  display: flex;
  align-items: center;
  -webkit-mask-image: radial-gradient(circle 42px at 100% 26px, transparent 41.5px, black 42px);
  mask-image: radial-gradient(circle 42px at 100% 26px, transparent 41.5px, black 42px);
}

.crawl-track {
  white-space: nowrap;
  padding-left: 100%;
  animation: crawlMove linear infinite;
}

.crawl-text {
  display: inline-block;
  font-size: 32px;
  font-weight: 500;
  color: #fff;
}

@keyframes crawlMove {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(-100%);
  }
}

#waiting-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: #000;
  color: #fff;
  z-index: 50;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}

#waiting-screen.hidden {
  display: none;
}

#waiting-screen .wait-label {
  font-size: 24px;
  letter-spacing: 6px;
  opacity: 0.6;
  margin-bottom: 16px;
}

#waiting-screen .wait-time {
  font-size: 140px;
  font-weight: 200;
  letter-spacing: -4px;
  line-height: 1;
}

#waiting-screen .wait-countdown {
  font-size: 48px;
  font-weight: 300;
  opacity: 0.7;
  margin-top: 20px;
  font-variant-numeric: tabular-nums;
}

#waiting-screen .wait-next {
  margin-top: 40px;
  font-size: 22px;
  opacity: 0.5;
  max-width: 70%;
  text-align: center;
}

#end-of-broadcast {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  z-index: 100;
}

#end-of-broadcast.hidden {
  display: none;
}

#end-of-broadcast img {
  width: 280px;
  height: auto;
  opacity: 0;
  animation: broadcastLogoFadeIn 0.8s ease forwards;
}

@keyframes broadcastLogoFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.qr-code {
  bottom: 130px;
  right: 22px;
  width: 120px;
  height: 120px;
  background: #fff;
  border-radius: 8px;
  padding: 5px;
  box-sizing: border-box;
  z-index: 12;
}
.qr-code img {
  width: 100%;
  height: 100%;
  display: block;
}

.hidden { display: none; }
