/* ==========================================================================
   Emotes en pantalla
   /emotes lo muestra a pantalla completa en OBS y /config lo monta dentro de
   su caja de vista previa.

   Dos capas por emote a proposito: `.em-trip` hace el viaje (cae o sube) y
   `.em-sway` el balanceo. Si compartieran transform se pisarian.
   ========================================================================== */

:root {
    --bone:  #FEF3D9;
    --red:   #F32146;
    --red-hi:#FF5B67;
    --faint: #615D54;
    --line-2:#302E27;
    --amber: #F2A618;

    --ease-out:  cubic-bezier(0.16, 1, 0.3, 1);
    --ease-back: cubic-bezier(0.34, 1.56, 0.64, 1);
}

.em {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    font-family: 'Archivo', 'Segoe UI', system-ui, sans-serif;
    --em-size: 64px;
}

.em-layer { position: absolute; inset: 0; }

/* --------------------------------------------------------------------------
   El viaje
   -------------------------------------------------------------------------- */

.em-trip {
    position: absolute;
    left: var(--x, 50%);
    top: 0;
    height: 100%;
    will-change: transform;
    animation-duration: var(--dur, 6s);
    animation-delay: var(--delay, 0s);
    animation-timing-function: linear;
    animation-fill-mode: both;
}

.em-sway {
    display: block;
    will-change: transform;
    animation: emSway var(--swaydur, 2.4s) ease-in-out infinite alternate;
}

.em-trip img {
    display: block;
    width: auto;
    height: var(--em-size);
    max-width: calc(var(--em-size) * 2.4);   /* los emotes anchos no revientan */
    /* Sombra corta: los emotes viven sobre gameplay claro tan a menudo como
       sobre uno oscuro, y sin esto se pierden. */
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.55));
}

@keyframes emSway {
    from { transform: translateX(calc(var(--drift, 20px) * -1)) rotate(calc(var(--spin, 10deg) * -1)); }
    to   { transform: translateX(var(--drift, 20px)) rotate(var(--spin, 10deg)); }
}

/* caen */
.em[data-mode="rain"] .em-trip { animation-name: emFall; }
@keyframes emFall {
    from { transform: translateY(calc(var(--em-size) * -1.2)); opacity: 0; }
    6%   { opacity: 1; }
    88%  { opacity: 1; }
    to   { transform: translateY(105%); opacity: 0; }
}

/* suben */
.em[data-mode="float"] .em-trip { animation-name: emRise; }
@keyframes emRise {
    from { transform: translateY(105%) scale(0.7); opacity: 0; }
    8%   { opacity: 1; transform: translateY(90%) scale(1); }
    85%  { opacity: 1; }
    to   { transform: translateY(calc(var(--em-size) * -1.2)) scale(0.92); opacity: 0; }
}

/* --------------------------------------------------------------------------
   Combo
   -------------------------------------------------------------------------- */

/* Dos capas: `.em-combo` coloca y escala (segun la esquina elegida) y `.box`
   hace la entrada. Si compartieran transform, mover el contador de esquina
   romperia la animacion. */
.em-combo {
    position: absolute;
    z-index: 30;
    display: none;
    transform-origin: top center;
    transform: scale(var(--combo-scale, 1));
}
.em-combo.is-on { display: block; }

.em-combo .box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px 12px 14px;
    background: rgba(6, 5, 4, 0.9);
    border: 1px solid var(--line-2);
    border-radius: 12px;
    box-shadow: 0 18px 46px rgba(0, 0, 0, 0.6);
}
.em-combo.is-on .box { animation: comboIn 520ms var(--ease-back) both; }

/* arriba centrado (por defecto) */
.em .em-combo,
.em[data-combopos="top"] .em-combo {
    left: 50%; top: 7%;
    transform: translateX(-50%) scale(var(--combo-scale, 1));
}
.em[data-combopos="tl"] .em-combo { left: 3%;  top: 5%;    right: auto; bottom: auto; transform-origin: top left;     transform: scale(var(--combo-scale, 1)); }
.em[data-combopos="tr"] .em-combo { right: 3%; top: 5%;    left: auto;  bottom: auto; transform-origin: top right;    transform: scale(var(--combo-scale, 1)); }
.em[data-combopos="bl"] .em-combo { left: 3%;  bottom: 5%; right: auto; top: auto;    transform-origin: bottom left;  transform: scale(var(--combo-scale, 1)); }
.em[data-combopos="br"] .em-combo { right: 3%; bottom: 5%; left: auto;  top: auto;    transform-origin: bottom right; transform: scale(var(--combo-scale, 1)); }

.em-combo img { display: block; height: 54px; width: auto; max-width: 120px; }

.em-combo .x {
    font-family: 'JetBrains Mono', Consolas, monospace;
    font-size: 20px;
    color: var(--faint);
}

.em-combo b {
    font-size: 38px;
    font-weight: 900;
    letter-spacing: -1.5px;
    line-height: 1;
    color: var(--bone);
    /* El numero es lo unico que crece: el resto de la tarjeta se queda quieta. */
    display: inline-block;
}

.em-combo.did-bump b { animation: comboBump 340ms var(--ease-back); }

@keyframes comboIn {
    from { opacity: 0; transform: translateY(16px) scale(0.86); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes comboBump {
    0%   { transform: scale(1); color: var(--bone); }
    45%  { transform: scale(1.25); color: var(--red-hi); }
    100% { transform: scale(1); color: var(--bone); }
}

/* --------------------------------------------------------------------------
   Tarjeta de estado (F2 en OBS)
   -------------------------------------------------------------------------- */

.em-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: 236px;
    font-family: 'Archivo', 'Segoe UI', system-ui, sans-serif;
    display: none;
}
.em-status.is-on { display: block; }

.em-status .row { display: flex; align-items: center; gap: 9px; font-size: 12px; color: #A49E8F; padding: 3px 0; }
.em-status .row b { color: var(--bone); font-weight: 600; }
.em-status .row .mono { font-family: 'JetBrains Mono', Consolas, monospace; font-size: 11px; }
.em-status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.em-status .dot[data-state="ok"]         { background: var(--red); animation: emPulse 2.2s ease-out infinite; }
.em-status .dot[data-state="connecting"] { background: var(--amber); }
.em-status .dot[data-state="error"]      { background: var(--amber); }
.em-status hr { border: none; border-top: 1px solid #201E19; margin: 9px 0; }
.em-status .hint { font-size: 10px; color: var(--faint); }

@keyframes emPulse {
    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); }
}
