/* ==========================================================================
   Overlay · Broadcast HUD
   Componente compartido: /video lo muestra a pantalla completa y /config
   lo monta dentro de la caja de vista previa.

   Paleta sacada del logo: hueso #FEF3D9 y carmesi #7C021C son los colores
   exactos del PNG; el rojo vivo es ese mismo carmesi subido de luminosidad
   manteniendo el tono (oklch H 20,2).
   ========================================================================== */

:root {
    --bone:       #FEF3D9;
    --dim:        #A49E8F;
    --faint:      #615D54;
    --line:       #201E19;
    --line-2:     #302E27;
    --surf:       #0C0B08;
    --surf-2:     #14130F;
    --bg:         #060504;
    --red:        #F32146;
    --red-hi:     #FF5B67;
    --red-mid:    #B1002A;
    --crimson:    #7C021C;
    --crimson-lo: #4E0009;
    --amber:      #F2A618;

    --ease-out:   cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in:    cubic-bezier(0.4, 0, 1, 1);
    --ease-back:  cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --------------------------------------------------------------------------
   Contenedor
   -------------------------------------------------------------------------- */

.ov {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Archivo', 'Segoe UI', system-ui, sans-serif;
    color: var(--bone);
    overflow: hidden;
}

.ov-card {
    position: relative;
    width: min(100%, 800px);
    aspect-ratio: 16 / 9;
    max-height: 100%;
    background: #000;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

/* Los Shorts son verticales: la tarjeta se adapta en vez de recortarlos. */
.ov.is-portrait .ov-card {
    aspect-ratio: 9 / 16;
    width: auto;
    height: min(100%, 900px);
}

.ov-player,
.ov-player iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* --------------------------------------------------------------------------
   Etiqueta de autor
   -------------------------------------------------------------------------- */

.ov-attr {
    position: absolute;
    left: 0;
    bottom: 0;
    z-index: 20;
    background: #000;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px 12px 14px;
    opacity: 0;
    max-width: 70%;
}

.ov-attr img { width: 30px; height: 30px; display: block; image-rendering: pixelated; flex: none; }
.ov-attr .txt { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.ov-attr .kicker {
    font-family: 'JetBrains Mono', Consolas, monospace;
    font-size: 9px;
    letter-spacing: 2.2px;
    text-transform: uppercase;
    color: var(--red);
}

.ov-attr .name {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -0.3px;
    color: var(--bone);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Contador de cola
   -------------------------------------------------------------------------- */

.ov-chip {
    position: absolute;
    right: 12px;
    top: 12px;
    z-index: 20;
    background: rgba(0, 0, 0, 0.9);
    border-radius: 4px;
    padding: 7px 11px;
    display: flex;
    align-items: center;
    gap: 7px;
    opacity: 0;
}

.ov-chip svg { display: block; }
.ov-chip span {
    font-family: 'JetBrains Mono', Consolas, monospace;
    font-size: 11px;
    letter-spacing: 0.4px;
    color: var(--bone);
}

/* Cola llena: el chip se invierte. Es la unica senal que necesita el chat. */
.ov-chip.is-full { background: var(--red); }
.ov-chip.is-full span { font-weight: 700; }
.ov-chip.is-full svg { stroke: var(--bone); }

/* Salta cuando entra alguien nuevo en la cola. */
.ov-chip.did-bump { animation: chipBump 320ms var(--ease-back); }
@keyframes chipBump {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.22); }
    100% { transform: scale(1); }
}

/* --------------------------------------------------------------------------
   Rail de progreso
   -------------------------------------------------------------------------- */

.ov-rail {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    z-index: 25;
    background: rgba(243, 33, 70, 0.22);
    opacity: 0;
}

.ov-rail i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--red); display: block; }

/* --------------------------------------------------------------------------
   Cargando
   -------------------------------------------------------------------------- */

.ov-loader {
    position: absolute;
    inset: 0;
    z-index: 15;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--bg);
}

.ov-loader.is-on { display: flex; }

.ov-loader i {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--red);
    display: block;
    animation: dotBounce 1.05s infinite ease-in-out;
}
.ov-loader i:nth-child(2) { animation-delay: 0.14s; }
.ov-loader i:nth-child(3) { animation-delay: 0.28s; }

@keyframes dotBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.35; }
    40%           { transform: scale(1);   opacity: 1; }
}

/* --------------------------------------------------------------------------
   Entrada y salida
   -------------------------------------------------------------------------- */

.ov .ov-card {
    border-radius: 10px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75), 0 0 0 1px var(--line-2);
}

/* Entrada orquestada: tarjeta, nombre a +240 ms, contador a +420 ms. */
.ov.is-in  .ov-card { animation: cardIn  600ms var(--ease-out) both; }
.ov.is-out .ov-card { animation: cardOut 480ms var(--ease-in)  both; }

@keyframes cardIn  { from { opacity: 0; transform: translateY(26px) scale(0.94); } to { opacity: 1; transform: none; } }
@keyframes cardOut { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-14px) scale(0.98); } }

/* Los distintivos entran al revelar el video, no al entrar la tarjeta:
   mientras carga solo se ven los tres puntos. */
.ov.is-live .ov-attr { animation: attrIn 600ms var(--ease-out) both; }
.ov.is-live .ov-chip { animation: chipIn 600ms var(--ease-out) 180ms both; }
.ov.is-live .ov-rail { animation: fadeIn 300ms ease both; }

.ov.is-out .ov-attr,
.ov.is-out .ov-chip,
.ov.is-out .ov-rail { animation: fadeOut 260ms ease both; }

@keyframes attrIn { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }
@keyframes chipIn { from { opacity: 0; transform: translateX(16px); }  to { opacity: 1; transform: none; } }
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

/* El gato parpadea. */
.ov-eyes { position: relative; width: 30px; height: 30px; flex: none; }
.ov-eyes img { position: absolute; inset: 0; width: 100%; height: 100%; }
.ov-eyes .shut { opacity: 0; }

.ov.is-visible .ov-eyes .open { animation: eyeOpen 3.4s steps(1) infinite; }
.ov.is-visible .ov-eyes .shut { animation: eyeShut 3.4s steps(1) infinite; }

@keyframes eyeOpen { 0%, 92% { opacity: 1; } 93%, 96% { opacity: 0; } 97%, 100% { opacity: 1; } }
@keyframes eyeShut { 0%, 92% { opacity: 0; } 93%, 96% { opacity: 1; } 97%, 100% { opacity: 0; } }

/* --------------------------------------------------------------------------
   Tarjeta de estado (F2 en OBS) — solo lectura, nunca sale en el directo
   salvo que la abras tu.
   -------------------------------------------------------------------------- */

.ov-status {
    position: fixed;
    left: 14px;
    top: 14px;
    z-index: 999;
    background: rgba(6, 5, 4, 0.96);
    border: 1px solid var(--line-2);
    border-radius: 8px;
    padding: 14px 16px;
    min-width: 240px;
    font-family: 'Archivo', 'Segoe UI', system-ui, sans-serif;
    display: none;
}
.ov-status.is-on { display: block; }

.ov-status .row { display: flex; align-items: center; gap: 9px; font-size: 12px; color: var(--dim); padding: 3px 0; }
.ov-status .row b { color: var(--bone); font-weight: 600; }
.ov-status .row .mono { font-family: 'JetBrains Mono', Consolas, monospace; font-size: 11px; }
.ov-status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.ov-status .dot[data-state="ok"]         { background: var(--red); animation: livePulse 2.2s ease-out infinite; }
.ov-status .dot[data-state="connecting"] { background: var(--amber); }
.ov-status .dot[data-state="error"]      { background: var(--amber); }
.ov-status .dot[data-state="off"]        { background: var(--faint); }
.ov-status hr { border: none; border-top: 1px solid var(--line); margin: 9px 0; }
.ov-status .hint { font-size: 10px; color: var(--faint); }

@keyframes livePulse {
    0%   { box-shadow: 0 0 0 0 rgba(243, 33, 70, 0.5); }
    70%  { box-shadow: 0 0 0 8px rgba(243, 33, 70, 0); }
    100% { box-shadow: 0 0 0 0 rgba(243, 33, 70, 0); }
}

/* --------------------------------------------------------------------------
   TikTok
   El embed de TikTok trae su propia franja con el autor y la descripcion
   debajo del video. No hay parametro para quitarla, asi que el iframe se hace
   mas alto que la tarjeta y el contenedor recorta lo que sobra.
   -------------------------------------------------------------------------- */

.ov-tt {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: none;
    overflow: hidden;
    background: #000;
}
.ov.is-tt .ov-tt {
    display: block;
    /* La tarjeta entera va con pointer-events:none para no robarle clics a
       nada en OBS, pero el reproductor de TikTok SI los necesita: si el
       navegador no le deja arrancar solo, un clic en «Interactuar» lo suelta.
       Un descendiente puede volver a activarlos. */
    pointer-events: auto;
}

/* Mientras suena TikTok, el reproductor de YouTube no pinta nada. */
.ov.is-tt .ov-player { visibility: hidden; }

/* El reproductor pinta SU interfaz pegada a los bordes (autor arriba,
   corazon y comentarios a la derecha) y no hay parametro que la quite. Lo
   agrandamos un pelin y lo centramos: esa cenefa se va fuera del recorte y
   dentro solo queda el video. */
.ov-tt iframe {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 124%;
    height: 124%;
    border: none;
    display: block;
}
