/* ════════════════════════════════════════════════════════════════════════
   Marvel Snap — version mobile (chargée après snap.css et le CSS de la page)
   ════════════════════════════════════════════════════════════════════════ */

/* ── Header : sur ordinateur, le conteneur du menu s'efface ──────────────── */
.snap-header .header-menu { display: contents; }
.snap-header .site-logo   { order: 0; }
.snap-header .header-nav  { order: 1; }
.snap-header .snap-search { order: 2; }
.snap-header .header-auth { order: 3; }
.snap-header .menu-toggle { display: none; }

/* ── Header compact : logo · recherche · ☰ ─────────────────────────────────
   Classe is-compact posée par le script du header (_headersnap.php) quand l'écran
   fait 820px ou moins, ou quand la barre ne tient pas sur une ligne (liens admin…). */
.snap-header.is-compact {
    gap: 10px;
    height: 56px;
    padding: 0 12px 0 16px;
}

.snap-header.is-compact .site-logo { font-size: 16px; }
.snap-header.is-compact .snap-search { flex: 1; min-width: 0; order: 1; }
.snap-header.is-compact .snap-search input { height: 38px; font-size: 16px; } /* 16px : pas de zoom auto sur iOS */

/* Résultats de recherche : sur toute la largeur de l'écran */
.snap-header.is-compact .snap-search-results {
    position: fixed;
    top: 62px;
    left: 12px;
    right: 12px;
    width: auto;
    max-height: calc(100vh - 80px);
    transform: none;
}

.snap-header.is-compact .menu-toggle {
    order: 2;
    display: grid;
    place-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    padding: 0;
    background: rgba(255,255,255,.06);
    border: 1px solid #2e2e4d;
    border-radius: 10px;
    cursor: pointer;
}

.snap-header.is-compact .menu-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: #e8e6f5;
    transition: transform .25s, opacity .2s;
}

.snap-header.is-compact.menu-open .menu-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.snap-header.is-compact.menu-open .menu-toggle span:nth-child(2) { opacity: 0; }
.snap-header.is-compact.menu-open .menu-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Menu déroulant */
.snap-header.is-compact .header-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    max-height: calc(100vh - 56px);
    overflow-y: auto;
    padding: 6px 16px 18px;
    background: #0f0f1a;
    border-bottom: 1px solid #2e2e4d;
    box-shadow: 0 18px 40px rgba(0,0,0,.6);
}

.snap-header.is-compact.menu-open .header-menu { display: flex; }

.snap-header.is-compact .header-nav {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
}

.snap-header.is-compact .header-nav a {
    padding: 15px 4px;
    font-size: 15px;
    border-bottom: 1px solid #1f1e38;
    box-shadow: none;
}

.snap-header.is-compact .header-nav a.active { color: var(--snap-gold); padding-bottom: 15px; }

/* Sous-menus : toujours dépliés, le bouton devient un titre de section */
.snap-header.is-compact .nav-group { border-bottom: 1px solid #1f1e38; padding-bottom: 6px; }
.snap-header.is-compact .nav-group::after { display: none; }

.snap-header.is-compact .nav-group-btn {
    padding: 16px 4px 4px;
    color: var(--snap-faint);
    font-size: 11px;
    letter-spacing: 1px;
    box-shadow: none;
    cursor: default;
    pointer-events: none;
}

.snap-header.is-compact .nav-caret { display: none; }

.snap-header.is-compact .nav-sub {
    position: static;
    min-width: 0;
    padding: 0;
    background: none;
    border: 0;
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: none;
}

.snap-header.is-compact .header-nav .nav-sub a {
    padding: 11px 4px 11px 14px;
    border-bottom: 0;
    border-radius: 0;
    font-size: 15px;
}

.snap-header.is-compact .header-nav .nav-sub a.active { padding-bottom: 11px; }

.snap-header.is-compact .header-nav a.nav-admin {
    border: 0;
    border-bottom: 1px solid #1f1e38;
    border-radius: 0;
    padding: 15px 4px;
}

.snap-header.is-compact .header-auth {
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px;
    padding-top: 16px;
    white-space: normal;
}

.snap-header.is-compact .header-user { flex-wrap: wrap; gap: 8px; }

/* ── Écrans tactiles : pas de survol ──────────────────────────────────────── */
@media (hover: none) {
    /* Bulles d'effet des grilles et infobulles des capacités : inutiles au doigt */
    .snap-grid .snap-card-effect,
    .ability-tip { display: none; }

    .snap-card-link:hover .card-canvas,
    .snap-card-link:hover .snap-card-img { transform: none; }
}

/* ── Téléphone ────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    /* Bulles et infobulles hors écran = défilement horizontal : on les retire */
    .snap-grid .snap-card-effect,
    .ability-tip { display: none; }

    /* En-têtes de page */
    .snap-hero { padding: 22px 0 18px; margin-bottom: 20px; }
    .snap-title { font-size: 32px; }
    .snap-subtitle { font-size: 14px; line-height: 1.5; }
    .snap-breadcrumb { font-size: 12px; }

    /* Grilles de cartes : 2 colonnes */
    .snap-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 10px; }
    .snap-card-name { margin-top: 8px; font-size: 14px; line-height: 1.25; }
    .snap-card-series { font-size: 10px; padding: 2px 8px; margin-bottom: 6px; }

    .snap-section { margin-top: 36px; }
    .snap-section-title { font-size: 21px; }

    /* ── All Cards / Officielles : barre d'outils ── */
    .toolbar { gap: 10px; margin-bottom: 22px; padding: 10px; }
    .toolbar .search-bar { flex: 1 1 100%; max-width: none; min-width: 0; }
    .toolbar .search-bar input { font-size: 16px; padding: 12px 0; }
    .toolbar .sort-wrap { flex: 1 1 0; min-width: 0; }
    .toolbar .sort-wrap select { width: 100%; }
    .toolbar .search-count { flex: 1 1 100%; white-space: normal; }
    .ability-desc.snap-panel { flex-direction: column; gap: 4px; margin: -10px 0 22px; }

    /* Filtres : panneau qui monte du bas de l'écran */
    .filter-popup,
    .filter-popup.open {
        top: auto;
        bottom: 0;
        left: 0;
        width: 100%;
        max-width: none;
        max-height: 88vh;
        overflow-y: auto;
        border-radius: 20px 20px 0 0;
        transform: none;
    }
    .filter-section, .filter-popup-header, .filter-popup-footer { padding-left: 18px; padding-right: 18px; }
    .filter-popup-footer { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
    .filter-popup-footer button { flex: 1; padding: 13px; }
    .cost-btn { width: 42px; height: 42px; }

    /* ── Extensions ── */
    .ext-header { gap: 10px; padding: 14px; }
    .ext-title { font-size: 19px; }
    .ext-count { font-size: 11px; padding: 3px 8px; }
    .ext-content .snap-grid { padding: 6px 12px 20px; }

    /* ── Fiche carte ── */
    .card-detail { gap: 22px; }
    #cardCanvas { max-width: 300px; }
    .card-nav { margin: -8px 0 14px; }
    .info-block { padding: 16px 16px 18px; }
    .info-block .snap-section-title { font-size: 18px; }
    .stat-panel { padding: 14px; }
    .stat-info { gap: 10px 14px; }
    .card-effect-text { font-size: 15px; }
    .section-head { flex-wrap: wrap; }
    .admin-edit { font-size: 12px; }

    /* Historique : chaque version devient un petit bloc (date · coût · puissance, puis l'effet) */
    .history-table thead { display: none; }
    .history-table, .history-table tbody { display: block; }
    .history-table tbody tr {
        display: grid;
        grid-template-columns: 1fr auto auto;
        align-items: center;
        gap: 4px 16px;
        padding: 12px 14px;
    }
    .history-table tbody th,
    .history-table tbody td { padding: 0; }
    .history-table td.num { font-size: 15px; }
    .history-table td.num::before {
        content: attr(data-label);
        margin-right: 5px;
        color: var(--snap-faint);
        font-size: 10px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .5px;
    }
    .history-table tbody td:last-child { grid-column: 1 / -1; font-size: 13px; }
    .history-table tbody tr.history-release > * { vertical-align: initial; }

    /* Modale des références : plein écran en bas */
    .ref-modal {
        top: auto;
        bottom: 0;
        left: 0;
        width: 100%;
        max-width: none;
        max-height: 90vh;
        border-radius: 20px 20px 0 0;
        transform: none;
    }

    /* Bouton retour */
    .snap-back { margin-top: 28px; }

    /* ── Accueil : les 3 tuiles côte à côte (la tuile entière est un lien) ── */
    .home-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 26px; }
    .home-tile { align-items: center; padding: 14px 6px 12px; text-align: center; }
    .home-tile-num { font-size: 32px; }
    .home-tile-label { font-size: 11px; letter-spacing: .4px; }
    .home-tile-go { display: none; }
    .snap-hero.home-hero { padding: 30px 0 24px; }

    /* ── Mots-clés ── */
    .kw-tools { margin-bottom: 24px; }
    .kw-toolbar { flex-basis: 100%; max-width: none; }
    .kw-toolbar input { font-size: 16px; }
    .kw-grid { grid-template-columns: 1fr; gap: 12px; }
    .kw-card { padding: 16px 18px 18px; }
    .kw-name { font-size: 21px; }
    .kw-group { margin-bottom: 30px; }
}
