/*
 * Ajustements propres à l'app JS : les styles existants (css/*.css) visaient des
 * <div>, ici la modal, le dialog et le loader sont des <dialog> natifs et le
 * toaster un popover (top layer).
 */

/* #app ne doit pas casser la mise en page flex de body (html.game) */
#app {
    display: contents;
}

[hidden] {
    display: none !important;
}

/* Effet appli : pas de sélection de texte, ni de menu d'appui long ou de glisser sur les images
   (les champs de saisie restent sélectionnables). Le navigateur remet user-select: text
   sur les <dialog> modaux : on les cible aussi, comme le toaster (popover) */
body,
dialog,
[popover] {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

input,
textarea,
[contenteditable] {
    user-select: text;
    -webkit-user-select: text;
    -webkit-touch-callout: default;
}

img,
video {
    -webkit-user-drag: none;
}

/* <dialog> : on neutralise les styles du navigateur, css/modal.css et css/popup.css s'appliquent */
dialog.container-modal,
dialog.container-popup {
    margin: 0;
    border: 0;
    max-width: none;
    max-height: none;
    background: none;
    color: inherit;
    inset: 0;
    overflow: visible;
}

dialog.container-modal:not([open]),
dialog.container-popup:not([open]) {
    display: none;
}

dialog::backdrop {
    background: transparent;
}

/* Toaster en popover : on retire les styles par défaut du navigateur */
.toaster[popover] {
    margin: 0;
    border: 0;
    inset: auto;
    top: 2rem;
    right: 1rem;
    color: inherit;
    overflow: visible;
}

.toaster[popover].hide {
    right: -6rem;
}

/* Petit écran : toujours à droite (avec left et right posés, le popover, large comme son
   contenu, ignore right et part à gauche), sans dépasser de l'écran */
@media screen and (max-width: 768px) {
    .toaster[popover] {
        left: auto;
        max-width: calc(100vw - 2rem);
    }
}

/* Confettis au-dessus du contenu du dialog */
dialog .confetti-burst {
    z-index: 20;
    pointer-events: none;
}

/* Apparition en cascade des joueurs (classement, écrans) : masqué jusqu'à .in.
   Une animation et non une transition : le délai ne ralentit pas ensuite le survol */
.badge-enter:not(.in) {
    opacity: 0;
}

.badge-enter.in {
    animation: enter-up 0.4s ease-out 1s both;
}

/* Délai par rang (50 ms), plafonné au 20e (écran du classement), au 8e sur la page
   Classement ; le gagnant d'un tirage arrive tout de suite */
.badge-enter.in:nth-child(1) { animation-delay: 50ms; }
.badge-enter.in:nth-child(2) { animation-delay: 100ms; }
.badge-enter.in:nth-child(3) { animation-delay: 150ms; }
.badge-enter.in:nth-child(4) { animation-delay: 200ms; }
.badge-enter.in:nth-child(5) { animation-delay: 250ms; }
.badge-enter.in:nth-child(6) { animation-delay: 300ms; }
.badge-enter.in:nth-child(7) { animation-delay: 350ms; }
.badge-enter.in:nth-child(8) { animation-delay: 400ms; }
.badge-enter.in:nth-child(9) { animation-delay: 450ms; }
.badge-enter.in:nth-child(10) { animation-delay: 500ms; }
.badge-enter.in:nth-child(11) { animation-delay: 550ms; }
.badge-enter.in:nth-child(12) { animation-delay: 600ms; }
.badge-enter.in:nth-child(13) { animation-delay: 650ms; }
.badge-enter.in:nth-child(14) { animation-delay: 700ms; }
.badge-enter.in:nth-child(15) { animation-delay: 750ms; }
.badge-enter.in:nth-child(16) { animation-delay: 800ms; }
.badge-enter.in:nth-child(17) { animation-delay: 850ms; }
.badge-enter.in:nth-child(18) { animation-delay: 900ms; }
.badge-enter.in:nth-child(19) { animation-delay: 950ms; }
.scoreboard-container .badge-enter.in:nth-child(n+8) { animation-delay: 400ms; }
.badge-enter.in.winner-enter { animation-delay: 0ms; }

@keyframes enter-up {
    from {
        opacity: 0;
        transform: translateY(1.5rem);
    }
}

@media (prefers-reduced-motion: reduce) {
    .fade-in,
    .badge-enter.in {
        animation: none;
    }
}

/* Page "aucune quête" */
.container-erreur {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 1rem;
    width: 100%;
    height: 100%;
    padding: 1rem;
}

.container-erreur h1 {
    font-size: 1.25rem;
    margin: 0px;
    color: var(--ColorPrimary);
    font-family: var(--FontFocus);
}
