/**
 * Curelea TV — Moniteur Broadcast 16:9 STRICT (Résolution virtuelle verrouillée 1280×720)
 *
 * - Format 16:9 immuable sur TOUS les écrans (mobile, tablette, laptop, 16:10, 21:9, 4K).
 * - Proportions 100 % identiques entre petit écran et grand écran grâce au conteneur
 *   interne fixe 1280×720 mis à l'échelle par tv-engine.js (transform: scale(S)).
 * - En plein écran : fond noir mat pur, cadre 16:9 centré (letterboxing/pillarboxing exact).
 */

/* Cadre externe du téléviseur (toujours 16:9 en mode normal) */
.tv-monitor {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000000;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Fallback 16:9 pour navigateurs anciens */
@supports not (aspect-ratio: 16 / 9) {
  .tv-monitor::before {
    content: "";
    display: block;
    padding-top: 56.25%;
  }
}

/* Mode Plein Écran : fond noir pur, scène 16:9 centrée sans déformation */
.tv-monitor:fullscreen,
.tv-monitor:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  aspect-ratio: auto;
  border-radius: 0;
  border: none;
  box-shadow: none;
  background: #000000;
}

.tv-monitor:fullscreen.is-ui-idle,
.tv-monitor:-webkit-full-screen.is-ui-idle {
  cursor: none;
}

/* Fenêtre 16:9 exacte (calculée par CSS + affinée en JS au pixel près) */
.tv-stage {
  position: relative;
  width: 100%;
  height: 100%;
  aspect-ratio: 16 / 9;
  background: #000000;
  overflow: hidden;
  flex-shrink: 0;
}

.tv-monitor:fullscreen .tv-stage,
.tv-monitor:-webkit-full-screen .tv-stage {
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
}

/* ============================================================
   TOILE BROADCAST VERROUILLÉE 1280 × 720 (HD 16:9)
   Tout ce qui est à l'intérieur garde exactement les mêmes proportions
   sur un téléphone de 340px comme sur un téléviseur 4K !
   ============================================================ */
.tv-canvas-16x9 {
  position: absolute;
  top: 0;
  left: 0;
  width: 1280px;
  height: 720px;
  transform-origin: top left;
  background: #000000;
  overflow: hidden;
  will-change: transform;
}

/* COUCHE 1 : FLUX VIDÉO LINÉAIRE */
.tv-video {
  position: absolute;
  inset: 0;
  width: 1280px;
  height: 720px;
  object-fit: contain;
  background: #000000;
  display: block;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.65s ease;
  z-index: 1;
}

.tv-video.is-active {
  opacity: 1;
}

/* COUCHE 2 : HÔTE DES MODULES LONGS (/tv/modules/) */
.tv-module-stage {
  position: absolute;
  inset: 0;
  width: 1280px;
  height: 720px;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.75s ease;
  overflow: hidden;
}

.tv-module-stage.is-active {
  opacity: 1;
}

/* Vignette broadcast très discrète */
.tv-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 66%, rgba(0, 0, 0, 0.34) 100%);
  z-index: 4;
}

/* Rideau de fondu au noir broadcast (fin d'émission & pré-Ident :00) */
.tv-program-curtain {
  position: absolute;
  inset: 0;
  width: 1280px;
  height: 720px;
  background: #000000;
  opacity: 0;
  pointer-events: none;
  z-index: 5;
  transition: opacity 2s cubic-bezier(0.4, 0, 0.2, 1);
}

.tv-program-curtain.is-active {
  opacity: 1;
}

.tv-program-curtain.is-instant {
  transition: none !important;
}

/* Voile de démarrage */
.tv-boot-veil {
  position: absolute;
  inset: 0;
  z-index: 6;
  background: #05070b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "JetBrains Mono", monospace;
  font-size: 14px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
  opacity: 1;
  transition: opacity 0.6s ease, visibility 0.6s ease;
  pointer-events: none;
}

.tv-boot-veil.is-ready {
  opacity: 0;
  visibility: hidden;
}

/* ============================================================
   LOGO DE CHAÎNE DISCRET (TV BUG) — Coin supérieur droit (1280×720)
   Visible pendant les émissions (normal & plein écran),
   fade-out avant l'Ident :00 et pendant les génériques d'ouverture.
   ============================================================ */
.tv-channel-bug {
  position: absolute;
  top: 26px;
  right: 32px;
  z-index: 8;
  display: inline-flex;
  align-items: center;
  font-family: "CureleaVerdana", Verdana, Geneva, sans-serif;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.01em;
  line-height: 1;
  pointer-events: none;
  opacity: 0.66;
  filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.58));
  transition: opacity 1.15s cubic-bezier(0.4, 0, 0.2, 1),
              transform 1.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.tv-channel-bug.is-hidden {
  opacity: 0;
  transform: translateY(-3px);
}

.tv-bug-brand {
  background: rgba(0, 0, 0, 0.80);
  color: #ffffff;
  height: 0.94em;
  display: inline-flex;
  align-items: center;
  padding: 0 0.34em 0 0.14em;
  clip-path: polygon(0 0, calc(100% - 0.31em) 0, 100% 100%, 0 100%);
}

.tv-bug-brand span {
  display: inline-block;
  transform: translateY(-0.035em);
}

.tv-bug-orb {
  width: 0.46em;
  height: 0.46em;
  border-radius: 50%;
  margin-left: -0.33em;
  margin-right: -0.13em;
  z-index: 2;
  flex-shrink: 0;
  background: radial-gradient(
    circle at 22% 20%,
    #ffff00 0%,
    #ffd000 13%,
    #ff7b00 26%,
    #ff0800 39%,
    #7b0099 53%,
    #0011ff 67%,
    #0066aa 81%,
    #009e3c 96%,
    #009933 100%
  );
}

.tv-bug-tag {
  background: rgba(255, 255, 255, 0.92);
  color: #000000;
  height: 0.94em;
  display: inline-flex;
  align-items: center;
  padding: 0 0.20em 0 0.44em;
  margin-left: -0.31em;
}

.tv-bug-tag span {
  display: inline-block;
  transform: translateY(-0.035em);
}

/* ============================================================
   BANDEAU ÉPHÉMÈRE "CURELEA TV · LIVE" + HORLOGE TEMPS RÉEL
   S'affiche quelques secondes puis disparaît pour laisser l'image.
   ============================================================ */
.tv-live-hud {
  position: absolute;
  top: 26px;
  left: 32px;
  z-index: 9;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 15px;
  border-radius: 999px;
  background: rgba(4, 7, 12, 0.68);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #ffffff;
  pointer-events: none;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.tv-monitor.is-ui-idle .tv-live-hud,
.tv-monitor.is-ident-active .tv-live-hud,
.tv-monitor.is-intro-active .tv-live-hud {
  opacity: 0;
  transform: translateY(-5px);
}

.tv-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--live-red);
  box-shadow: 0 0 10px var(--live-red);
  flex-shrink: 0;
  animation: cureleaLivePulse 1.8s ease-in-out infinite;
}

@keyframes cureleaLivePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.38; transform: scale(0.84); }
}

.tv-live-sep {
  opacity: 0.35;
}

.tv-live-clock {
  font-weight: 600;
  color: rgba(255, 255, 255, 0.88);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   CARTOUCHE VIDÉOCLIP "NOW PLAYING" (Point 1a)
   Apparaît ~6.5 secondes quand une piste audio démarre (ambiance ou musique)
   ============================================================ */
.tv-nowplaying {
  position: absolute;
  left: 38px;
  bottom: 92px;
  z-index: 9;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  max-width: 540px;
  padding: 12px 20px 12px 16px;
  border-radius: 12px;
  background: rgba(6, 10, 18, 0.78);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-left: 3px solid #7dd3fc;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  opacity: 0;
  transform: translateX(-28px);
  transition: opacity 0.65s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}

.tv-nowplaying.is-visible {
  opacity: 1;
  transform: translateX(0);
}

.tv-monitor.is-ident-active .tv-nowplaying,
.tv-monitor.is-intro-active .tv-nowplaying {
  opacity: 0;
  transform: translateX(-28px);
}

.tv-np-eq {
  display: inline-flex;
  align-items: flex-end;
  gap: 3px;
  height: 22px;
  flex-shrink: 0;
}

.tv-np-eq span {
  display: block;
  width: 3px;
  border-radius: 2px;
  background: #7dd3fc;
  animation: tvEqBounce 0.9s ease-in-out infinite alternate;
}

.tv-np-eq span:nth-child(1) { height: 10px; animation-delay: 0s; }
.tv-np-eq span:nth-child(2) { height: 20px; animation-delay: 0.22s; }
.tv-np-eq span:nth-child(3) { height: 13px; animation-delay: 0.44s; }
.tv-np-eq span:nth-child(4) { height: 18px; animation-delay: 0.15s; }

@keyframes tvEqBounce {
  0% { transform: scaleY(0.32); opacity: 0.65; }
  100% { transform: scaleY(1); opacity: 1; }
}

.tv-np-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.tv-np-kicker {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #7dd3fc;
}

.tv-np-title {
  font-size: 17px;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tv-np-artist {
  font-size: 13px;
  font-weight: 500;
  color: rgba(241, 245, 249, 0.72);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   COUCHE 3 : IDENT HORAIRE CURELEA TV (À CHAQUE HEURE PILE :00)
   ============================================================ */
.tv-ident-layer {
  position: absolute;
  inset: 0;
  width: 1280px;
  height: 720px;
  z-index: 14;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.7s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.7s;
}

.tv-ident-layer.is-active {
  opacity: 1;
  visibility: visible;
}

.tv-ident-lockup {
  display: inline-flex;
  align-items: center;
  font-family: "CureleaVerdana", Verdana, Geneva, sans-serif;
  font-weight: 700;
  font-size: 72px;
  letter-spacing: -0.01em;
  line-height: 1;
}

.tv-ident-brand {
  background-color: #000000;
  color: #ffffff;
  height: 0.94em;
  display: inline-flex;
  align-items: center;
  padding: 0 0.34em 0 0.12em;
  clip-path: polygon(0 0, calc(100% - 0.31em) 0, 100% 100%, 0 100%);
}

.tv-ident-brand span {
  display: inline-block;
  transform: translateY(-0.035em);
}

.tv-ident-orb {
  width: 0.46em;
  height: 0.46em;
  border-radius: 50%;
  margin-left: -0.33em;
  margin-right: 0.02em;
  z-index: 2;
  flex-shrink: 0;
  background: radial-gradient(
    circle at 22% 20%,
    #ffff00 0%,
    #ffd000 13%,
    #ff7b00 26%,
    #ff0800 39%,
    #7b0099 53%,
    #0011ff 67%,
    #0066aa 81%,
    #009e3c 96%,
    #009933 100%
  );
  transform: scale(0.84);
  transition: transform 0.65s cubic-bezier(0.34, 1.45, 0.64, 1);
}

.tv-ident-layer.is-active .tv-ident-orb {
  transform: scale(1);
}

.tv-ident-window {
  height: 0.94em;
  overflow: hidden;
  display: inline-flex;
  align-items: flex-start;
}

.tv-ident-track {
  display: flex;
  flex-direction: column;
  will-change: transform;
}

.tv-ident-item {
  height: 0.94em;
  display: flex;
  align-items: center;
  color: #000000;
  white-space: nowrap;
}

.tv-ident-item span {
  display: inline-block;
  transform: translateY(-0.035em);
}

.tv-ident-meta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: "JetBrains Mono", monospace;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(0, 0, 0, 0.56);
}

.tv-ident-hour {
  color: #000000;
}

/* ============================================================
   INVITE D'ACTIVATION DU SON (Autoplay navigateur)
   ============================================================ */
.unmute-overlay {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.20);
  opacity: 1;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.unmute-overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.unmute-cta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 15px 28px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  color: #05070b;
  border: none;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.58);
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.unmute-cta:hover {
  transform: scale(1.04);
  background: #ffffff;
}

/* ============================================================
   OSD INFÉRIEUR ÉPHÉMÈRE (Programme en cours + Son + Plein écran)
   ============================================================ */
.tv-osd {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 13;
  padding: 52px 34px 24px;
  background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.80) 100%);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.55s ease, transform 0.55s ease;
}

.tv-monitor.is-ui-idle .tv-osd,
.tv-monitor.is-ident-active .tv-osd {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

.osd-program-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.osd-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-emerald);
}

.osd-title {
  font-size: 22px;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.65);
}

.osd-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.osd-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(12, 16, 24, 0.68);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.osd-btn:hover {
  background: rgba(255, 255, 255, 0.24);
  border-color: rgba(255, 255, 255, 0.5);
  transform: scale(1.06);
}

.osd-btn svg {
  width: 20px;
  height: 20px;
}

@media (max-width: 768px) {
  .tv-monitor {
    border-radius: 14px;
  }

  /* Overlay agrandi sur téléphone (compense l'échelle ~0.28x de la toile 1280×720 sur petit écran) */
  .tv-live-hud {
    top: 30px;
    left: 34px;
    padding: 15px 30px;
    gap: 16px;
    font-size: 30px;
    border-width: 2px;
  }

  .tv-live-dot {
    width: 15px;
    height: 15px;
  }

  .tv-osd {
    padding: 94px 44px 36px;
    gap: 28px;
  }

  .osd-label {
    font-size: 26px;
    letter-spacing: 0.16em;
  }

  .osd-title {
    font-size: 50px;
  }

  .osd-actions {
    gap: 24px;
  }

  .osd-btn {
    width: 118px;
    height: 118px;
    border-width: 2.5px;
  }

  .osd-btn svg {
    width: 54px;
    height: 54px;
  }

  .unmute-cta {
    padding: 30px 54px;
    gap: 20px;
    font-size: 36px;
  }

  .unmute-cta svg {
    width: 44px;
    height: 44px;
  }
}

/* Téléphone en mode paysage plein écran : taille intermédiaire équilibrée */
@media (max-height: 520px) and (pointer: coarse) {
  .tv-live-hud {
    top: 24px;
    left: 28px;
    padding: 11px 22px;
    gap: 12px;
    font-size: 22px;
  }

  .tv-live-dot {
    width: 12px;
    height: 12px;
  }

  .tv-osd {
    padding: 68px 36px 26px;
    gap: 22px;
  }

  .osd-label {
    font-size: 20px;
  }

  .osd-title {
    font-size: 38px;
  }

  .osd-btn {
    width: 84px;
    height: 84px;
  }

  .osd-btn svg {
    width: 38px;
    height: 38px;
  }

  .unmute-cta {
    padding: 22px 40px;
    font-size: 26px;
  }
}

