/* =============================================================================
   LA COLLECTION
   Un tiroir qui vient du bord droit, ouvert par une languette. Volontairement
   dans son propre fichier : rien ici ne touche aux styles de la table, et
   retirer la balise <link> suffit à revenir à l'état d'avant.

   Tout est repris du vocabulaire existant : papier #f8f9fa à pois de 24 px,
   Lora pour les titres, micro-labels en Outfit 0.7rem espacés, filets à 8 %
   de noir, rayon 12, et l'élan cubic-bezier(0.34, 1.56, 0.64, 1).
   ========================================================================== */

:root {
    --col-largeur: 460px;
    --col-elan: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- La languette ---------------------------------------------------------
   Une carte qu'on aurait glissée sous le bord de la table. Elle n'apparaît
   qu'au deuxième paquet : avant, le visiteur n'a rien à y ranger. */

.col-tab {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translate(100%, -50%);
    z-index: 1200;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 18px 11px;
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
    border-right: none;
    border-radius: 12px 0 0 12px;
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.07);
    cursor: pointer;
    /* texte à la verticale, comme la tranche d'un classeur */
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-family: 'Outfit', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: #8a8a8a;
    transition: transform 0.45s var(--col-elan), color 0.25s, box-shadow 0.25s;
}

.col-tab.is-ready { transform: translate(0, -50%); }

.col-tab:hover,
.col-tab:focus-visible {
    transform: translate(-5px, -50%);
    color: var(--text-main, #1a1a1a);
    box-shadow: -8px 0 26px rgba(0, 0, 0, 0.10);
}

.col-tab i { font-size: 0.85rem; color: #c4c4c4; transition: color 0.25s; }
.col-tab:hover i, .col-tab:focus-visible i { color: var(--accent-legendary, #d4af37); }

/* le compteur, dans le style des micro-labels */
.col-tab-count {
    font-variant-numeric: tabular-nums;
    color: #c0c0c0;
    letter-spacing: 1px;
}

/* pastille quand des cartes ont été découvertes depuis la dernière ouverture */
.col-tab.has-new::after {
    content: "";
    position: absolute;
    top: 8px;
    left: 8px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-legendary, #d4af37);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.22);
}

/* --- Le voile ------------------------------------------------------------- */

.col-scrim {
    position: fixed;
    inset: 0;
    z-index: 1300;
    background: rgba(26, 26, 26, 0.20);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}

.col-scrim.is-open { opacity: 1; pointer-events: auto; }

/* Le compteur de la table est en z-index 2000 et passait donc par-dessus le
   pied du tiroir, « Start over » compris. Il est de toute façon redondant : le
   tiroir affiche la même progression, en plus détaillé. */
body.col-open .collection-counter {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

/* --- Le tiroir ------------------------------------------------------------ */

.col-drawer {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1400;
    width: min(var(--col-largeur), 100vw);
    height: 100%;
    display: flex;
    flex-direction: column;
    /* le même papier que la table, pour ne pas donner l'impression
       d'avoir changé de page */
    background: #f8f9fa;
    background-image: radial-gradient(rgba(0, 0, 0, 0.07) 1px, transparent 1px);
    background-size: 24px 24px;
    border-left: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
    box-shadow: -20px 0 55px rgba(0, 0, 0, 0.11);
    transform: translateX(100%);
    transition: transform 0.5s var(--col-elan);
}

.col-drawer.is-open { transform: translateX(0); }

/* --- En-tête -------------------------------------------------------------- */

.col-head {
    flex-shrink: 0;
    padding: 22px 24px 16px;
    border-bottom: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
    background: rgba(248, 249, 250, 0.94);
    backdrop-filter: blur(6px);
}

.col-head-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.col-head h2 {
    font-family: 'Lora', serif;
    font-size: 1.45rem;
    font-weight: 600;
    color: var(--text-main, #1a1a1a);
    margin: 0;
}

.col-close {
    background: none;
    border: none;
    padding: 6px;
    margin: -6px -6px 0 0;
    font-size: 1rem;
    color: #bbb;
    cursor: pointer;
    line-height: 1;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
}

.col-close:hover, .col-close:focus-visible { color: var(--text-main, #1a1a1a); background: rgba(0, 0, 0, 0.04); }

.col-progress-label {
    margin-top: 3px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #bbb;
}

/* la jauge : un filet qui se remplit, pas une barre de chargement */
.col-progress {
    margin-top: 12px;
    height: 3px;
    border-radius: 2px;
    background: rgba(0, 0, 0, 0.07);
    overflow: hidden;
}

.col-progress span {
    display: block;
    height: 100%;
    width: 0;
    border-radius: 2px;
    background: var(--text-main, #1a1a1a);
    transition: width 0.7s var(--col-elan), background 0.4s;
}

.col-progress.is-complete span { background: var(--accent-legendary, #d4af37); }

/* --- Corps ---------------------------------------------------------------- */

.col-body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 8px 24px 28px;
}

.col-section { padding: 18px 0 4px; }
.col-section + .col-section { border-top: 1px solid rgba(0, 0, 0, 0.05); }

.col-section-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.col-section-head i { font-size: 0.78rem; color: #c4c4c4; flex-shrink: 0; }

.col-section-name {
    font-family: 'Outfit', sans-serif;
    font-size: 0.7rem
    ;font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #8a8a8a;
}

.col-section-count {
    margin-left: auto;
    font-family: 'Outfit', sans-serif;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: #c4c4c4;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.col-section.is-complete .col-section-count { color: var(--accent-legendary, #d4af37); }
.col-section.is-complete .col-section-head i { color: var(--accent-legendary, #d4af37); }

/* le lien vers /music, seulement quand la famille musicale est assez remplie */
.col-section-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.78rem;
    color: var(--accent-rare, #3498db);
    text-decoration: none;
    transition: gap 0.25s var(--col-elan);
}

.col-section-link:hover { gap: 10px; }

/* --- Les cases ------------------------------------------------------------ */

.col-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    gap: 10px;
}

.col-slot {
    position: relative;
    aspect-ratio: 1/1;
    border-radius: 6px;
    padding: 0;
    border: none;
    background: none;
    cursor: default;
}

/* case vide : l'emplacement d'une vignette qui n'a pas encore été collée */
.col-slot.is-empty::after {
    content: attr(data-num);
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.015);
    font-family: 'Outfit', sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    color: #d0d0d0;
    font-variant-numeric: tabular-nums;
}

/* case trouvée : la vignette, légèrement de travers, comme collée à la main */
.col-slot.is-found {
    cursor: pointer;
    overflow: hidden;
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
    background: #fafafa;
    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.07);
    transform: rotate(var(--tilt, 0deg));
    transition: transform 0.35s var(--col-elan), box-shadow 0.25s;
}

.col-slot.is-found:hover,
.col-slot.is-found:focus-visible {
    transform: rotate(0deg) scale(1.07);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
    z-index: 5;
}

.col-slot.is-found img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.col-slot.is-found.is-active {
    transform: rotate(0deg);
    box-shadow: 0 0 0 2px var(--text-main, #1a1a1a);
}

/* liseré de rareté, comme sur les cartes */
.col-slot.is-found.r-rare { border-color: var(--accent-rare, #3498db); border-width: 2px; }
.col-slot.is-found.r-legendary { border-color: var(--accent-legendary, #d4af37); border-width: 2px; }

/* la vignette qui vient d'être collée */
@keyframes colStick {
    0%   { transform: rotate(var(--tilt, 0deg)) scale(1.35); opacity: 0; }
    55%  { transform: rotate(var(--tilt, 0deg)) scale(0.96); opacity: 1; }
    100% { transform: rotate(var(--tilt, 0deg)) scale(1); }
}

.col-slot.is-new { animation: colStick 0.55s var(--col-elan); }

/* --- La fiche dépliée ----------------------------------------------------- */

.col-detail {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.4s var(--col-elan);
    margin-top: 0;
}

.col-detail.is-open { grid-template-rows: 1fr; margin-top: 12px; }
.col-detail > div { overflow: hidden; }

.col-detail-inner {
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
    border-radius: 12px;
    padding: 14px 16px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.05);
}

.col-detail h3 {
    font-family: 'Lora', serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main, #1a1a1a);
    margin: 0 0 4px;
}

.col-detail p {
    font-family: 'Outfit', sans-serif;
    font-size: 0.82rem;
    line-height: 1.45;
    color: #777;
    margin: 0;
}

.col-detail-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 11px;
    padding-top: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    font-family: 'Outfit', sans-serif;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: #bbb;
}

.col-detail-meta a {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-main, #1a1a1a);
    text-decoration: none;
    letter-spacing: 1px;
    transition: gap 0.25s var(--col-elan);
}

.col-detail-meta a:hover { gap: 10px; }

/* --- Pied ----------------------------------------------------------------- */

.col-foot {
    flex-shrink: 0;
    padding: 12px 24px 16px;
    border-top: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
    text-align: center;
}

.col-reset {
    background: none;
    border: none;
    padding: 4px 8px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: #cfcfcf;
    cursor: pointer;
    border-radius: 6px;
    transition: color 0.2s;
}

.col-reset:hover, .col-reset:focus-visible { color: #999; }

/* --- Mobile ---------------------------------------------------------------
   Une languette verticale au bord droit tomberait sous le pouce et par-dessus
   les cartes, qui occupent toute la largeur. Le tiroir devient donc une
   feuille qui monte du bas, et la languette une pastille posée au-dessus. */

@media (max-width: 768px) {
    /* Compacte : icône et compteur seulement. Avec le mot « Collection » la
       pastille faisait 191 px et masquait le texte de la carte sous elle, les
       cartes occupant toute la largeur. Le mot reste dans l'aria-label. */
    .col-tab {
        top: auto;
        bottom: 80px;
        right: 14px;
        writing-mode: horizontal-tb;
        border-right: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
        border-radius: 22px;
        padding: 11px 14px;
        gap: 7px;
        transform: translateY(160%);
        box-shadow: 0 6px 22px rgba(0, 0, 0, 0.12);
    }

    .col-tab > span:not(.col-tab-count) {
        position: absolute;
        width: 1px; height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
    }

    .col-tab.is-ready { transform: translateY(0); }
    .col-tab:hover, .col-tab:focus-visible { transform: translateY(-3px); }
    .col-tab.has-new::after { top: -2px; left: auto; right: -2px; }

    .col-drawer {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 86vh;
        border-left: none;
        border-top: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -18px 50px rgba(0, 0, 0, 0.16);
        transform: translateY(100%);
    }

    .col-drawer.is-open { transform: translateY(0); }
    .col-head, .col-body, .col-foot { padding-left: 18px; padding-right: 18px; }

    /* la poignée d'une feuille qu'on tire */
    .col-head::before {
        content: "";
        display: block;
        width: 38px;
        height: 4px;
        border-radius: 2px;
        background: rgba(0, 0, 0, 0.12);
        margin: -8px auto 14px;
    }
}

/* --- Réglage système respecté --------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .col-tab, .col-drawer, .col-scrim, .col-detail,
    .col-progress span, .col-slot.is-found {
        transition: none;
    }
    .col-slot.is-new { animation: none; }
}
