/**
 * Module Sélection, mode classement (« Votre Ballon d'Or ») : podium, liste à ordonner, états du glisser-déposer.
 * Chargé après selection.css, uniquement sur les pages d'un classement.
 * Mobile d'abord : cibles de 44 px au moins, animations limitées à transform et opacity.
 * Seule exception au bleu du site : les trois couleurs de médaille du podium (validé avec le dev).
 */

.page-section[data-selection-page] {
    --classement-or: #d4a72c;
    --classement-argent: #a9b0b8;
    --classement-bronze: #c27c43;
}

/* ── Podium ───────────────────────────────────────────────────────────────── */

.classement-podium {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: end;
    gap: 0.5rem;
    max-width: 30rem;
    margin-left: auto;
    margin-right: auto;
}

.classement-marche {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    color: inherit;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
}

.classement-podium--jeu .classement-marche {
    cursor: pointer;
}

.classement-marche__photo {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 4.25rem;
    height: 4.25rem;
    border-radius: 999px;
    border: 2px dashed var(--color-gray-300);
    background-color: var(--color-gray-50);
    overflow: hidden;
    transition: transform 0.2s ease;
}

.classement-marche--1 .classement-marche__photo {
    width: 5.5rem;
    height: 5.5rem;
}

.classement-marche__photo img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.classement-marche__vide {
    color: var(--color-gray-400);
    font-size: 1rem;
}

.classement-marche--pleine .classement-marche__vide {
    display: none;
}

.classement-marche--pleine .classement-marche__photo {
    border-style: solid;
    border-width: 3px;
    background-color: #ffffff;
    box-shadow: 0 2px 6px rgb(0 0 0 / 0.15);
}

.classement-marche--1.classement-marche--pleine .classement-marche__photo { border-color: var(--classement-or); }
.classement-marche--2.classement-marche--pleine .classement-marche__photo { border-color: var(--classement-argent); }
.classement-marche--3.classement-marche--pleine .classement-marche__photo { border-color: var(--classement-bronze); }

/* Un joueur qui vient de monter : léger rebond. */
.classement-marche--arrivee .classement-marche__photo {
    animation: classement-arrivee 0.3s ease-out;
}

@keyframes classement-arrivee {
    0% { transform: scale(0.6); }
    70% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

.classement-marche__nom {
    display: block;
    width: 100%;
    min-height: 1.25rem;
    margin-top: 0.375rem;
    padding: 0 0.125rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.25rem;
    color: var(--color-gray-800);
}

.classement-marche--1 .classement-marche__nom {
    font-size: 0.8125rem;
}

.classement-marche__info {
    display: block;
    font-size: 0.6875rem;
    line-height: 1rem;
    color: var(--color-gray-500);
}

.classement-marche__socle {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    width: 100%;
    margin-top: 0.375rem;
    padding-top: 0.375rem;
    border-radius: 0.5rem 0.5rem 0 0;
    background-color: var(--color-mif-blue);
    color: #ffffff;
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1;
}

.classement-marche--1 .classement-marche__socle { height: 4.5rem; font-size: 1.875rem; }
.classement-marche--2 .classement-marche__socle { height: 3.25rem; opacity: 0.85; }
.classement-marche--3 .classement-marche__socle { height: 2.25rem; opacity: 0.7; }

.classement-podium--jeu .classement-marche:focus-visible {
    outline: 2px solid var(--color-mif-blue);
    outline-offset: 2px;
    border-radius: 0.5rem;
}

@media (min-width: 40rem) {
    .classement-marche__photo { width: 5.5rem; height: 5.5rem; }
    .classement-marche--1 .classement-marche__photo { width: 7rem; height: 7rem; }
    .classement-marche__nom { font-size: 0.875rem; }
    .classement-marche--1 .classement-marche__nom { font-size: 0.9375rem; }
}

/* ── Consigne : bandeau voyant (les visiteurs ne lisent pas un paragraphe) ── */

.classement-consigne {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    background-color: var(--color-mif-blue);
    color: #ffffff;
    box-shadow: 0 4px 12px rgb(64 150 238 / 0.3);
    transition: background-color 0.2s ease;
}

.classement-consigne--ok {
    background-color: var(--color-mif-green);
    box-shadow: 0 4px 12px rgb(79 198 73 / 0.3);
}

.classement-consigne__icone {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 999px;
    background-color: rgb(255 255 255 / 0.2);
    font-size: 1.125rem;
    animation: classement-toucher 1.4s ease-in-out infinite;
}

.classement-consigne__icone--vertical {
    animation-name: classement-glisser;
}

.classement-consigne--ok .classement-consigne__icone {
    animation: none;
}

.classement-consigne__titre {
    display: block;
    font-size: 1.0625rem;
    font-weight: 800;
    line-height: 1.3;
}

.classement-consigne__detail {
    display: block;
    margin-top: 0.125rem;
    font-size: 0.8125rem;
    line-height: 1.35;
    opacity: 0.92;
}

@media (min-width: 40rem) {
    .classement-consigne__titre { font-size: 1.1875rem; }
    .classement-consigne__detail { font-size: 0.875rem; }
}

@keyframes classement-toucher {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    50% { transform: translate3d(0, 3px, 0) scale(0.92); }
}

@keyframes classement-glisser {
    0%, 100% { transform: translate3d(0, -3px, 0); }
    50% { transform: translate3d(0, 3px, 0); }
}

/* La prochaine marche à remplir pulse. */
.classement-marche--attente .classement-marche__photo {
    border-color: var(--color-mif-blue);
    background-color: rgb(64 150 238 / 0.08);
    animation: classement-attente 1.2s ease-out infinite;
}

.classement-marche--attente .classement-marche__vide {
    color: var(--color-mif-blue);
}

@keyframes classement-attente {
    0% { box-shadow: 0 0 0 0 rgb(64 150 238 / 0.5); }
    100% { box-shadow: 0 0 0 10px rgb(64 150 238 / 0); }
}

/* ── Étape podium : la grille « Votre top » ───────────────────────────────── */

.classement-choix-grille {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.5rem;
    min-height: 13rem; /* place réservée avant le dessin par le script : pas de saut de mise en page */
}

@media (min-width: 40rem) {
    .classement-choix-grille { grid-template-columns: repeat(5, minmax(0, 1fr)); min-height: 9rem; }
}

.classement-choix {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
    min-height: 6rem;
    padding: 0.5rem 0.25rem;
    border: 1px solid var(--color-gray-200);
    border-radius: 0.5rem;
    background-color: #ffffff;
    font: inherit;
    color: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 0.15s ease, border-color 0.15s ease;
}

.classement-choix__photo {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 999px;
    object-fit: cover;
    background-color: var(--color-gray-100);
    pointer-events: none;
}

.classement-choix__nom {
    display: block;
    width: 100%;
    margin-top: 0.375rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1rem;
    color: var(--color-gray-800);
}

.classement-choix__place {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    display: none;
    min-width: 1.375rem;
    height: 1.375rem;
    padding: 0 0.3rem;
    border-radius: 999px;
    color: #ffffff;
    font-size: 0.6875rem;
    font-weight: 800;
    line-height: 1.375rem;
}

/* Joueur déjà sur le podium : grisé, pastille à la couleur de sa médaille. */
.classement-choix[aria-pressed="true"] {
    opacity: 0.45;
}

.classement-choix[aria-pressed="true"] .classement-choix__place {
    display: block;
}

.classement-choix[data-place="1"] .classement-choix__place { background-color: var(--classement-or); }
.classement-choix[data-place="2"] .classement-choix__place { background-color: var(--classement-argent); }
.classement-choix[data-place="3"] .classement-choix__place { background-color: var(--classement-bronze); }

@media (hover: hover) {
    .classement-choix:hover { border-color: var(--color-mif-blue); }
}

/* ── Rappel du podium (étape d'ordre) : même podium, réduit ─────────────── */

/* Compact sur mobile pour laisser la liste à l'écran, plus grand dès 40rem. */
.classement-podium--rappel {
    max-width: 26rem;
}

.classement-podium--rappel .classement-marche__photo { width: 3.5rem; height: 3.5rem; }
.classement-podium--rappel .classement-marche--1 .classement-marche__photo { width: 4.25rem; height: 4.25rem; }
.classement-podium--rappel .classement-marche__nom { margin-top: 0.25rem; font-size: 0.75rem; }
.classement-podium--rappel .classement-marche__socle { margin-top: 0.25rem; padding-top: 0.25rem; font-size: 1rem; }
.classement-podium--rappel .classement-marche--1 .classement-marche__socle { height: 2.25rem; font-size: 1.25rem; }
.classement-podium--rappel .classement-marche--2 .classement-marche__socle { height: 1.625rem; }
.classement-podium--rappel .classement-marche--3 .classement-marche__socle { height: 1.125rem; }

@media (min-width: 40rem) {
    .classement-podium--rappel { max-width: 30rem; }
    .classement-podium--rappel .classement-marche__photo { width: 4.5rem; height: 4.5rem; }
    .classement-podium--rappel .classement-marche--1 .classement-marche__photo { width: 5.75rem; height: 5.75rem; }
    .classement-podium--rappel .classement-marche__nom { font-size: 0.875rem; }
    .classement-podium--rappel .classement-marche--1 .classement-marche__socle { height: 3.25rem; font-size: 1.5rem; }
    .classement-podium--rappel .classement-marche--2 .classement-marche__socle { height: 2.25rem; font-size: 1.25rem; }
    .classement-podium--rappel .classement-marche--3 .classement-marche__socle { height: 1.5rem; font-size: 1.125rem; }
}

/* ── Liste à ordonner ─────────────────────────────────────────────────────── */

.classement-liste {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    margin: 0;
    padding: 0;
    list-style: none;
    min-height: 3.5rem;
}

.classement-ligne {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    height: 3.5rem;
    padding-left: 0.5rem;
    border: 1px solid var(--color-gray-200);
    border-radius: 0.625rem;
    background-color: #ffffff;
    /* Appui long : ni menu contextuel, ni sélection de texte, ni loupe iOS. */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    will-change: transform;
}

.classement-ligne__rang {
    flex-shrink: 0;
    width: 1.75rem;
    text-align: center;
    font-size: 1.125rem;
    font-weight: 800;
    color: var(--color-mif-blue);
    font-variant-numeric: tabular-nums;
}

.classement-ligne__photo {
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 999px;
    object-fit: cover;
    background-color: var(--color-gray-100);
    pointer-events: none;
}

.classement-ligne__texte {
    flex: 1 1 auto;
    min-width: 0;
}

.classement-ligne__nom,
.classement-ligne__club {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.classement-ligne__nom {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--color-gray-800);
}

.classement-ligne__club {
    font-size: 0.6875rem;
    color: var(--color-gray-500);
}

/* Poignée : seule zone où le navigateur ne fait pas défiler la page, pour une prise immédiate. */
.classement-ligne__poignee {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 100%;
    padding: 0;
    border: 0;
    border-left: 1px solid var(--color-gray-100);
    border-radius: 0 0.625rem 0.625rem 0;
    background: none;
    color: var(--color-gray-400);
    font-size: 1.125rem;
    cursor: grab;
    touch-action: none;
}

.classement-ligne__poignee:focus-visible {
    outline: 2px solid var(--color-mif-blue);
    outline-offset: -2px;
}

@media (hover: hover) {
    .classement-ligne { cursor: grab; }
    .classement-ligne:hover { border-color: var(--color-gray-300); }
    .classement-ligne:hover .classement-ligne__poignee { color: var(--color-mif-blue); }
}

/* Pendant un tri, les autres lignes glissent pour faire place. */
.classement-liste--tri .classement-ligne {
    transition: transform 0.16s ease;
}

.classement-liste--tri,
.classement-liste--tri .classement-ligne {
    cursor: grabbing;
}

/* La ligne tenue : soulevée, au-dessus des autres, suit le doigt sans délai. */
.classement-liste--tri .classement-ligne--tenue {
    z-index: 2;
    transition: none;
    border-color: var(--color-mif-blue);
    box-shadow: 0 10px 24px rgb(0 0 0 / 0.18);
}

.classement-ligne--tenue .classement-ligne__poignee {
    color: var(--color-mif-blue);
}

/* La ligne relâchée rejoint sa place. */
.classement-liste--tri .classement-ligne--pose {
    z-index: 2;
    transition: transform 0.16s ease-out;
}

/* Échange au toucher : la première ligne touchée. */
.classement-ligne--choisie {
    border-color: var(--color-mif-blue);
    box-shadow: inset 0 0 0 1px var(--color-mif-blue);
    background-color: rgb(64 150 238 / 0.06);
}

/* Clavier : ligne prise. */
.classement-ligne__poignee[aria-pressed="true"] {
    color: #ffffff;
    background-color: var(--color-mif-blue);
}

.classement-ligne--echange {
    animation: classement-echange 0.35s ease-out;
}

@keyframes classement-echange {
    0% { background-color: rgb(64 150 238 / 0.18); }
    100% { background-color: #ffffff; }
}

/* Indice à la première visite : la première ligne esquisse un mouvement. */
.classement-ligne--indice {
    animation: classement-indice 1.1s ease-in-out 0.8s 3;
}

@keyframes classement-indice {
    0%, 100% { transform: translate3d(0, 0, 0); }
    30% { transform: translate3d(0, 16px, 0) scale(1.02); }
    60% { transform: translate3d(0, -4px, 0); }
}

/* Consigne adaptée au pointeur. */
.classement-consigne--souris { display: none; }

@media (hover: hover) and (pointer: fine) {
    .classement-consigne--tactile { display: none; }
    .classement-consigne--souris { display: inline; }
}

/* ── Page de résultat ─────────────────────────────────────────────────────── */

.classement-rang {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 1.625rem;
    height: 1.625rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 800;
    color: #ffffff;
    background-color: var(--color-gray-400);
}

.classement-rang--1 { background-color: var(--classement-or); }
.classement-rang--2 { background-color: var(--classement-argent); }
.classement-rang--3 { background-color: var(--classement-bronze); }
.classement-rang--4 { background-color: transparent; color: var(--color-gray-500); }

.classement-anneau--1 {
    box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px var(--classement-or);
}

@media (prefers-reduced-motion: reduce) {
    .classement-marche--arrivee .classement-marche__photo,
    .classement-marche--attente .classement-marche__photo,
    .classement-consigne__icone,
    .classement-ligne--indice,
    .classement-ligne--echange {
        animation: none;
    }

    .classement-liste--tri .classement-ligne,
    .classement-liste--tri .classement-ligne--pose {
        transition: none;
    }
}
