/* =====================================================================
   AperoRoom — Effet "La montée de l'apéro" sur la dernière minute.
   Piloté par public/js/apero-finale.js (ajout/retrait de classes).
   100 % déco : AUCUN lien avec la sync vidéo (le JS ne fait que LIRE
   le texte du compte à rebours déjà affiché).
   Compat vieux Chrome TV : transform/opacity, left/top/right/bottom
   explicites (pas d'`inset`), préfixes -webkit- sur flex/filter.
   ===================================================================== */

/* ---------- Phase 1 : dernière minute (bulles + chrono qui respire) ---------- */
.apero-bubbles {
    position: absolute;
    left: 0; top: 0; right: 0; bottom: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
}
.apero-bubble {
    position: absolute;
    bottom: -8%;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%,
        rgba(255,255,255,0.92), rgba(255,176,0,0.30) 55%, rgba(232,62,107,0.06));
    box-shadow: 0 0 8px rgba(255,214,220,0.5);
    opacity: 0;
    animation: apfBubbleRise linear infinite;
}
@keyframes apfBubbleRise {
    0%   { transform: translate(0, 0) scale(0.6);                 opacity: 0; }
    12%  {                                                         opacity: 0.95; }
    82%  {                                                         opacity: 0.7; }
    100% { transform: translate(var(--apf-drift, 0px), -108vh) scale(1); opacity: 0; }
}

/* le chrono "respire" quand l'apéro approche (cible PC .jb-wait-timer + TV .countdown) */
[data-apero-finale].apero-finale-active .jb-wait-timer,
[data-apero-finale].apero-finale-active .countdown {
    animation: apfTimerPulse 1s ease-in-out infinite;
    will-change: transform;
}
@keyframes apfTimerPulse {
    0%, 100% { transform: scale(1);    text-shadow: 0 0 24px rgba(232,62,107,0.45); }
    50%      { transform: scale(1.07); text-shadow: 0 0 44px rgba(255,176,0,0.75), 0 0 18px rgba(232,62,107,0.6); }
}

/* garder le texte d'attente AU-DESSUS des bulles */
[data-apero-finale] .jb-wait-info,
[data-apero-finale] .waiting-content { position: relative; z-index: 3; }

/* ---------- Phase 2 : overlay plein écran + chiffre géant ---------- */
.apero-finale-overlay {
    position: fixed;
    left: 0; top: 0; right: 0; bottom: 0;
    z-index: 2147483000;
    /* IMPORTANT : display:none au repos (PAS opacity:0). Sur Chromecast, une
       couche raster plein ecran -- meme transparente -- "perce" le plan video
       hardware (ecran noir, audio OK). display:none la retire du compositing.
       Meme lecon que #waiting.is-hidden. */
    display: none;
    -webkit-box-align: center; -webkit-align-items: center; align-items: center;
    -webkit-box-pack: center; -webkit-justify-content: center; justify-content: center;
    pointer-events: none;
    opacity: 0;
    -webkit-transition: opacity 0.25s ease; transition: opacity 0.25s ease;
    overflow: hidden;
}
html.apero-finale-on .apero-finale-overlay {
    display: -webkit-box; display: -webkit-flex; display: flex;
    opacity: 1;
}

/* De-doublon : quand le chiffre geant s'affiche (10 dernieres s), on masque le
   compteur classique HH:MM:SS + ses textes DERRIERE. opacity (PAS display:none)
   -> le module continue de LIRE le texte du chrono. PC = .jb-wait-info ;
   TV = textes de #waiting. */
html.apero-finale-on .jb-wait-info,
html.apero-finale-on #waiting .wait-eyebrow,
html.apero-finale-on #waiting .countdown,
html.apero-finale-on #waiting .wait-sub {
    opacity: 0 !important;
    -webkit-transition: opacity 0.3s ease; transition: opacity 0.3s ease;
}

.apero-finale-overlay__bg {
    position: absolute;
    left: 0; top: 0; right: 0; bottom: 0;
    background:
        radial-gradient(60% 60% at 50% 50%, rgba(232,62,107,0.20), transparent 70%),
        rgba(10,4,8,0.55);
    animation: apfBgPulse 1s ease-in-out infinite;
}
@keyframes apfBgPulse {
    0%, 100% { opacity: 0.82; }
    50%      { opacity: 1; }
}

.apero-finale-ring {
    position: absolute;
    width: 38vmin; height: 38vmin;
    border-radius: 50%;
    border: 3px solid rgba(255,176,0,0.7);
    opacity: 0;
}
.apero-finale-ring.is-pop { animation: apfRingBurst 0.95s ease-out; }
@keyframes apfRingBurst {
    0%   { transform: scale(0.25); opacity: 0.85; border-color: rgba(255,176,0,0.9); }
    100% { transform: scale(2.6);  opacity: 0;    border-color: rgba(232,62,107,0.10); }
}

.apero-finale-num {
    position: relative;
    font-family: var(--font-display, 'Instrument Serif', Georgia, serif);
    /* DROIT (pas italique) : un chiffre italique penche à droite et paraît
       décalé dans son cercle. Droit, il se centre parfaitement dans l'overlay
       flex (justify/align center). C'est un compte à rebours, la lisibilité et
       le centrage priment sur le style. */
    font-style: normal; font-weight: 700; line-height: 1;
    font-size: 44vmin;
    background: linear-gradient(135deg, #FFD6DC 0%, #E83E6B 45%, #FFB000 100%);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
    -webkit-filter: drop-shadow(0 0 40px rgba(232,62,107,0.6));
    filter: drop-shadow(0 0 40px rgba(232,62,107,0.6));
}
.apero-finale-num.is-pop { animation: apfNumPop 0.55s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes apfNumPop {
    0%   { transform: scale(1.7); opacity: 0; -webkit-filter: blur(10px); filter: blur(10px); }
    60%  {                        opacity: 1; }
    100% { transform: scale(1);   opacity: 1; -webkit-filter: blur(0);    filter: blur(0); }
}

/* ---------- TV (Chromecast) : chiffre géant 10->0 allégé ----------
   GPU faible -> on retire ce qui est coûteux à repeindre CHAQUE seconde :
   gradient-clip du texte, drop-shadow, blur, l'anneau qui éclate, et le
   pulse du fond. On garde un "pop" net (scale + fondu) + une lueur cheap
   via text-shadow. Activé par html.apero-finale-tvmode (posé par le JS
   quand data-finale-tv="1" sur le receiver). */
html.apero-finale-tvmode .apero-finale-overlay__bg {
    -webkit-animation: none; animation: none; opacity: 0.92;
}
html.apero-finale-tvmode .apero-finale-ring { display: none; }
html.apero-finale-tvmode .apero-finale-num {
    background: none;
    -webkit-text-fill-color: #FFD6DC; color: #FFD6DC;
    -webkit-filter: none; filter: none;
    text-shadow: 0 0 18px rgba(232,62,107,0.55), 0 2px 10px rgba(0,0,0,0.45);
}
html.apero-finale-tvmode .apero-finale-num.is-pop {
    -webkit-animation: apfNumPopLite 0.4s ease-out; animation: apfNumPopLite 0.4s ease-out;
}
@-webkit-keyframes apfNumPopLite {
    0%   { -webkit-transform: scale(1.45); opacity: 0; }
    100% { -webkit-transform: scale(1);    opacity: 1; }
}
@keyframes apfNumPopLite {
    0%   { transform: scale(1.45); opacity: 0; }
    100% { transform: scale(1);    opacity: 1; }
}

/* ---------- Phase 3 : SANTÉ ! + confettis ---------- */
.apero-finale-cheers {
    position: relative;
    text-align: center;
    display: none;
    padding: 0 6vw;
}
.apero-finale-overlay.is-cheers .apero-finale-num   { display: none; }
.apero-finale-overlay.is-cheers .apero-finale-cheers {
    display: block;
    animation: apfCheersIn 0.7s cubic-bezier(0.2, 1.5, 0.4, 1);
}
.apero-finale-cheers__title {
    display: block;
    font-family: var(--font-display, 'Instrument Serif', Georgia, serif);
    font-style: italic; font-weight: 700; line-height: 1.02;
    font-size: 16vmin;
    background: linear-gradient(135deg, #FFD6DC, #E83E6B 55%, #FFB000);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
    -webkit-filter: drop-shadow(0 0 30px rgba(255,176,0,0.55));
    filter: drop-shadow(0 0 30px rgba(255,176,0,0.55));
}
.apero-finale-cheers__sub {
    display: block;
    margin-top: 1.6vmin;
    font-size: 5vmin; font-weight: 600;
    color: var(--pt-text, #FFD6DC);
    text-shadow: 0 2px 16px rgba(0,0,0,0.5);
}
@keyframes apfCheersIn {
    0%   { transform: scale(0.4);  opacity: 0; }
    60%  { transform: scale(1.12); opacity: 1; }
    100% { transform: scale(1);    opacity: 1; }
}

.apero-finale-flash {
    position: absolute;
    left: 0; top: 0; right: 0; bottom: 0;
    background: #fff;
    opacity: 0;
    pointer-events: none;
}
.apero-finale-flash.is-on { animation: apfFlash 0.6s ease-out; }
@keyframes apfFlash {
    0%   { opacity: 0; }
    12%  { opacity: 0.75; }
    100% { opacity: 0; }
}

.apf-confetti {
    position: absolute;
    top: -12vh;
    width: 12px; height: 18px;
    border-radius: 2px;
    opacity: 0;
    animation: apfConfettiFall var(--apf-dur, 1.6s) linear forwards;
    animation-delay: var(--apf-delay, 0s);
}
@keyframes apfConfettiFall {
    0%   { transform: translate(0, 0) rotate(0deg);                               opacity: 0; }
    8%   {                                                                         opacity: 1; }
    100% { transform: translate(var(--apf-x, 0px), 120vh) rotate(var(--apf-rot, 720deg)); opacity: 0.9; }
}

/* accessibilité : on coupe tout si l'utilisateur refuse les animations */
@media (prefers-reduced-motion: reduce) {
    .apero-bubble,
    .apero-finale-num.is-pop,
    .apero-finale-ring.is-pop,
    .apero-finale-overlay.is-cheers .apero-finale-cheers,
    .apf-confetti,
    .apero-finale-overlay__bg,
    [data-apero-finale].apero-finale-active .jb-wait-timer,
    [data-apero-finale].apero-finale-active .countdown { animation: none !important; }
}

/* =====================================================================
   Écran d'attente « On nettoie les verres » — Phone + PC + TV.
   Reprend le design de la page maintenance : cercle pointillé qui tourne
   + éponge qui « nettoie » de plus en plus vite. 100 % déco. Le compteur
   reste l'élément alimenté par les contrôleurs (.jb-wait-timer /
   .rm-wait-timer / .countdown) → sélecteurs data-finale-value INCHANGÉS.
   Tailles de base = phone/PC ; la TV (receiver) sur-dimensionne en inline.
   ===================================================================== */
.apero-clean {
    position: relative;
    z-index: 3;
    display: -webkit-box; display: -webkit-flex; display: flex;
    -webkit-box-orient: vertical; -webkit-box-direction: normal;
    -webkit-flex-direction: column; flex-direction: column;
    -webkit-box-align: center; -webkit-align-items: center; align-items: center;
    -webkit-box-pack: center; -webkit-justify-content: center; justify-content: center;
    gap: 13px;
    text-align: center;
    padding: 8px 18px;
    max-width: 560px;
    margin: 0 auto;
}
.apero-clean__pill {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.26em;
    text-transform: uppercase;
    color: #FFB000;
    padding: 5px 14px;
    border-radius: 999px;
    background: rgba(255,176,0,0.10);
    border: 1px solid rgba(255,176,0,0.35);
}

/* Sticker rond + cercle pointillé doré qui tourne (comme la page maintenance) */
.apero-clean__sticker {
    position: relative;
    width: 132px; height: 132px;
    display: -webkit-box; display: -webkit-flex; display: flex;
    -webkit-box-align: center; -webkit-align-items: center; align-items: center;
    -webkit-box-pack: center; -webkit-justify-content: center; justify-content: center;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(232,62,107,0.22) 0%, rgba(142,90,110,0.10) 50%, transparent 75%);
    border: 1.5px solid rgba(232,62,107,0.30);
    box-shadow: inset 0 0 36px rgba(232,62,107,0.20), 0 16px 40px rgba(232,62,107,0.20);
}
.apero-clean__sticker::before {
    content: '';
    position: absolute;
    left: -14px; top: -14px; right: -14px; bottom: -14px;
    border-radius: 50%;
    border: 1px dashed rgba(255,176,0,0.45);
    -webkit-animation: apfRingSpin 12s linear infinite;
    animation: apfRingSpin 12s linear infinite;
}
@-webkit-keyframes apfRingSpin { from { -webkit-transform: rotate(0); } to { -webkit-transform: rotate(360deg); } }
@keyframes apfRingSpin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

/* L'éponge « nettoie » : balaye gauche-droite + haut-bas de plus en plus vite
   (les % se resserrent vers la fin = accélération), puis repart tranquille. */
.apero-clean__sponge {
    font-size: 68px;
    line-height: 1;
    -webkit-animation: apfSpongeDance 3.4s ease-in-out infinite;
    animation: apfSpongeDance 3.4s ease-in-out infinite;
    -webkit-filter: drop-shadow(0 4px 10px rgba(0,0,0,0.4));
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.4));
    will-change: transform;
}
@-webkit-keyframes apfSpongeDance {
    0%{-webkit-transform:translate(-15px,-7px) rotate(-11deg)}
    14%{-webkit-transform:translate(15px,-5px) rotate(9deg)}
    28%{-webkit-transform:translate(-13px,7px) rotate(-9deg)}
    42%{-webkit-transform:translate(13px,8px) rotate(11deg)}
    54%{-webkit-transform:translate(-12px,-6px) rotate(-13deg)}
    63%{-webkit-transform:translate(12px,-4px) rotate(13deg)}
    71%{-webkit-transform:translate(-12px,6px) rotate(-13deg)}
    78%{-webkit-transform:translate(12px,5px) rotate(13deg)}
    84%{-webkit-transform:translate(-10px,-4px) rotate(-15deg)}
    89%{-webkit-transform:translate(10px,-4px) rotate(15deg)}
    93%{-webkit-transform:translate(-9px,4px) rotate(-15deg)}
    97%{-webkit-transform:translate(9px,4px) rotate(15deg)}
    100%{-webkit-transform:translate(-15px,-7px) rotate(-11deg)}
}
@keyframes apfSpongeDance {
    0%{transform:translate(-15px,-7px) rotate(-11deg)}
    14%{transform:translate(15px,-5px) rotate(9deg)}
    28%{transform:translate(-13px,7px) rotate(-9deg)}
    42%{transform:translate(13px,8px) rotate(11deg)}
    54%{transform:translate(-12px,-6px) rotate(-13deg)}
    63%{transform:translate(12px,-4px) rotate(13deg)}
    71%{transform:translate(-12px,6px) rotate(-13deg)}
    78%{transform:translate(12px,5px) rotate(13deg)}
    84%{transform:translate(-10px,-4px) rotate(-15deg)}
    89%{transform:translate(10px,-4px) rotate(15deg)}
    93%{transform:translate(-9px,4px) rotate(-15deg)}
    97%{transform:translate(9px,4px) rotate(15deg)}
    100%{transform:translate(-15px,-7px) rotate(-11deg)}
}

.apero-clean__title {
    font-family: var(--font-display, 'Instrument Serif', Georgia, serif);
    font-style: italic;
    font-weight: 400;
    font-size: clamp(32px, 5.4vw, 54px);
    line-height: 0.98;
    margin: 3px 0 0;
    background: linear-gradient(135deg, #FFD6DC, #E83E6B 60%, #FFB000);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
}
.apero-clean__sub {
    font-family: var(--font-display, 'Instrument Serif', Georgia, serif);
    font-style: italic;
    font-size: clamp(15px, 2.4vw, 20px);
    color: rgba(255,214,220,0.62);
    margin: 0;
    max-width: 440px;
}
.apero-clean__count {
    display: -webkit-box; display: -webkit-flex; display: flex;
    -webkit-box-orient: vertical; -webkit-box-direction: normal;
    -webkit-flex-direction: column; flex-direction: column;
    -webkit-box-align: center; -webkit-align-items: center; align-items: center;
    gap: 2px;
    margin-top: 4px;
}
.apero-clean__label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: rgba(255,214,220,0.55);
    margin: 0;
}
/* Compteur (élément contrôleur) : on neutralise le dégradé rose hérité côté
   PC/phone → blanc net façon « maintenance » (le titre porte déjà le dégradé). */
.apero-clean__timer {
    margin: 1px 0 0;
    font-family: var(--font-display, 'Instrument Serif', Georgia, serif);
    font-style: italic;
    font-weight: 400;
    line-height: 1.04;
    font-size: clamp(38px, 8.4vw, 68px);
    letter-spacing: 0.01em;
    background: none;
    -webkit-text-fill-color: #fff; color: #fff;
    -webkit-filter: none; filter: none;
    text-shadow: 0 0 26px rgba(255,255,255,0.22), 0 4px 22px rgba(0,0,0,0.45);
}

/* De-doublon : quand le gros chiffre plein écran s'affiche (10 dernières s),
   on masque tout le bloc « On nettoie les verres » DERRIÈRE (opacity, PAS
   display → le module continue de LIRE le compteur). Vaut pour les 3 écrans. */
html.apero-finale-on .apero-clean {
    opacity: 0 !important;
    -webkit-transition: opacity 0.3s ease; transition: opacity 0.3s ease;
}

@media (prefers-reduced-motion: reduce) {
    .apero-clean__sticker::before,
    .apero-clean__sponge { -webkit-animation: none !important; animation: none !important; }
}
