:root {
    --bg: #f5f7fa;
    --ink: #0f172a;
    --muted: #6c757d;
    --border: #e5e7eb;
    --shadow: 0 6px 18px rgba(0, 0, 0, .08);
    --green: #3ba776;
    --link: #1a4f85;
    --header-h: 56px;
    --footer-h: 44px;
    --content-gap: 14px;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, system-ui, Segoe UI, Roboto, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* ===== Header ===== */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    height: var(--header-h);
    padding: 0 clamp(8px, 2vw, 16px);
    background: rgba(241, 241, 241, .9);
    backdrop-filter: saturate(1.1) blur(6px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, .05);
    box-sizing: border-box;
}

/* ✅ Correction : header en GRID (gauche | centre | droite) */
.header-inner {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
    width: 100%;
    height: 100%;
}

/* Zones */
.header-left {
    grid-column: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-right {
    grid-column: 3;
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Flyer actif : centré dans l'espace entre gauche et droite */
header nav[aria-label="Flyer actif"] {
    grid-column: 2;
    justify-self: center;
    text-align: center;
    pointer-events: none;
    /* ne bloque pas les clics des menus */
}

/* Capsule centrale */
.active-item {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 10px;
    border: 1.5px solid var(--green);
    background: rgba(59, 167, 118, .10);
    box-shadow: 0 0 6px rgba(59, 167, 118, .35);
    color: var(--link);
    font-weight: 700;
}

/* le contenu reste sélectionnable */
#activeFlyer {
    pointer-events: auto;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    max-width: min(90vw, 620px);
    /* évite de tout écraser sur petits écrans */
    text-align: center;
    line-height: 1.3;
}

.shimmer {
    background: linear-gradient(90deg, #1a4f85, var(--green), #1a4f85);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    background-size: 200% auto;
    animation: shimmer 6s linear infinite;
    font-weight: 800;
}

@keyframes shimmer {
    to {
        background-position: -200% center;
    }
}

@media (prefers-reduced-motion: reduce) {
    .shimmer {
        animation: none;
    }
}

.flyer-label {
    font-size: 1rem;
}

.flyer-desc {
    font-size: 12px;
    color: var(--muted);
}

/* ===== Dropdown & bouton Historique ===== */
.dropdown-wrap {
    position: relative;
}

/* style de base pour les boutons de menu */
.dropdown-btn {
    appearance: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 10px;
    padding: 6px 10px;
    font-weight: 700;
    font-size: 12px;
    /* même taille que les items */
    color: var(--link);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}

.dropdown-btn[aria-expanded="true"] {
    border-color: var(--green);
    background: rgba(59, 167, 118, .06);
}

.chev {
    transition: transform .2s;
}

.dropdown-btn[aria-expanded="true"] .chev {
    transform: rotate(180deg);
}

/* Sous-menu pour Décembre */
.dropdown li.has-sub {
    position: relative;
}

.dropdown .sub-menu {
    position: absolute;
    top: 0;
    left: 100%;
    margin-left: 0;
    /* pas de trou entre Décembre et le sous-menu */
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, .12);
    padding: 4px;
    list-style: none;
    width: max-content;
    max-width: 90vw;
    display: none;
    z-index: 20;
}

.dropdown li.has-sub:hover>.sub-menu,
.dropdown li.has-sub:focus-within>.sub-menu {
    display: block;
}

.dropdown .sub-menu a {
    font-size: 12px;
    padding: 6px 10px;
    white-space: nowrap;
}

/* Dropdown principal */
.dropdown {
    position: absolute;
    left: 0;
    top: calc(100% + 8px);
    width: max-content;
    max-width: 90vw;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, .10);
    padding: 6px;
    overflow: visible;
}

.dropdown[hidden] {
    display: none;
}

.dropdown ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.dropdown a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--ink);
    font-size: 12px;
    white-space: nowrap;
}

.dropdown a:hover,
.dropdown a:focus {
    background: rgba(245, 247, 250, .95);
    border: 1px solid rgba(59, 167, 118, .45);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .7) inset;
    outline: none;
}

/* Fix hover dropdown principal */
.dropdown>ul>li>a:hover,
.dropdown>ul>li>a:focus {
    background: rgba(245, 247, 250, .95);
    border: 1px solid rgba(59, 167, 118, .45);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .7) inset;
    -webkit-text-fill-color: var(--link);
    background-clip: border-box;
    font-weight: 700;
}

.dropdown a[aria-current="page"] {
    font-weight: 700;
    border: 1px solid var(--green);
    background: rgba(59, 167, 118, .10);
    color: var(--link);
}

/* Séparateur (uniquement dans sous-menus) */
.dropdown .sub-menu .sub-sep {
    height: 1px;
    margin: 6px 8px;
    background: rgba(0, 0, 0, 0.12);
}

/* ===== Contenu ===== */
main {
    min-height: calc(100vh - var(--header-h) - var(--footer-h));
    padding-top: calc(var(--header-h) + var(--content-gap));
    padding-bottom: calc(var(--footer-h) + var(--content-gap));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
}

.flyer-box {
    width: 92vw;
    max-width: 820px;
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    content-visibility: auto;
}

/* Flyer intermédiaire (recto-verso) : format paysage */
.flyer-box--mid {
    width: min(96vw, 1120px);
    max-width: 1120px;
}

/* Par défaut (flyers) : images prennent toute la box */
.flyer-box picture,
.flyer-box img {
    width: 100%;
    height: 100%;
    display: block;
}

.flyer-box img {
    object-fit: contain;
    background: #fff;
}

/* ===== Footer (mêmes effets visuels que header, sans resize) ===== */
footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    min-height: var(--footer-h);
    padding: 8px clamp(8px, 2vw, 16px);
    background: rgba(241, 241, 241, .9);
    backdrop-filter: saturate(1.1) blur(6px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 6px rgba(0, 0, 0, .05);
}

footer .footer-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    text-align: center;
}

footer .communes {
    flex: 1;
    color: var(--muted);
    font-size: 13px;
    margin: 0;
}

footer .version {
    color: #9aa0a6;
    font-size: 9px;
    font-weight: 500;
    margin: 0;
    text-align: right;
    white-space: nowrap;
}

/* ===== Icônes dans le footer (Trombinoscope + Facebook) ===== */
.footer-icons {
    display: flex;
    align-items: center;
    gap: 0px;
}

.trombi-link,
.facebook-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .4);
    backdrop-filter: blur(4px);
    transition: all .3s ease;
    text-decoration: none;
    border: 1.5px solid transparent;
    cursor: pointer;
    font-family: inherit;
    position: relative;
    z-index: 1;
}

.trombi-link:hover,
.facebook-link:hover {
    background: rgba(255, 255, 255, .8);
    border-color: var(--green);
    box-shadow: 0 4px 12px rgba(59, 167, 118, .25);
    transform: translateY(-2px);
    z-index: 100;
}

.trombi-link:focus-visible,
.facebook-link:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 2px;
    z-index: 100;
}

.trombi-link:active,
.facebook-link:active {
    transform: translateY(0);
}

.trombi-icon,
.facebook-icon {
    width: 32px;
    height: 32px;
    display: block;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .1));
    transition: filter .3s ease;
}

.trombi-link:hover .trombi-icon,
.facebook-link:hover .facebook-icon {
    filter: drop-shadow(0 4px 8px rgba(59, 167, 118, .3));
}

@media (max-width: 640px) {
    .footer-icons {
        gap: 0;
    }
    
    .trombi-link,
    .facebook-link {
        padding: 0;
    }
    
    .trombi-icon,
    .facebook-icon {
        width: 28px;
        height: 28px;
    }
}

/* ===== Trombinoscope intégré ===== */
.trombi-box {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
}

/* En mode trombi : masquer le bouton trombi et décaler Facebook à gauche */
body.mode-trombi .trombi-link {
    display: none;
}

#trombiFrame {
    width: 100%;
    border: none;
    min-height: 600px;
    display: block;
    overflow: visible;
    /* ✅ laisse l’iframe gérer son contenu */
}

/* ===== Mode trombinoscope : main en pleine largeur ===== */
body.mode-trombi main {
    align-items: stretch;
}

/* ===== Effet graphique animé pour les items du dropdown ===== */
.dropdown a,
.dropdown .sub-menu a {
    background: linear-gradient(90deg, #1a4f85, var(--green), #1a4f85);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    background-size: 200% auto;
    animation: shimmer 6s linear infinite;
    font-weight: 700;
}

/* État sélectionné : lisible, sans shimmer */
.dropdown a[aria-current="page"] {
    -webkit-text-fill-color: var(--link);
    background: none;
    font-weight: 800;
}

/* Hover submenu : même style que le dropdown principal */
.dropdown .sub-menu li>a:hover,
.dropdown .sub-menu li>a:focus {
    background: rgba(245, 247, 250, .95);
    border: 1px solid rgba(59, 167, 118, .45);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .7) inset;
    -webkit-text-fill-color: var(--link);
    background-clip: border-box;
    font-weight: 700;
}

/* Icône hamburger : 3 lignes horizontales (Historique) */
.dropdown-btn .burger {
    display: none;
    flex-direction: column;
    gap: 3px;
}

.dropdown-btn .burger span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--link);
    border-radius: 2px;
}

/* Icône info pour "Plus d'informations…" */
.info-icon {
    display: none;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    border-radius: 999px;
    border: 1px solid var(--link);
    padding: 2px 6px;
}

/* Par défaut : texte + flèche visibles */
.dropdown-btn .btn-label {
    display: inline;
}

.dropdown-btn .chev {
    display: inline;
}

/* ===== Responsive : comportement différent selon le bouton ===== */
@media (max-width: 640px) {

    .dropdown-btn {
        padding: 6px 10px;
    }

    /* 1) Historique → burger seul */
    .dropdown-btn--historique .btn-label,
    .dropdown-btn--historique .chev {
        display: none;
    }

    .dropdown-btn--historique .burger {
        display: flex;
    }

    /* 2) Plus d'informations → icône "i" seule */
    .dropdown-btn--info .btn-label,
    .dropdown-btn--info .chev {
        display: none;
    }

    .dropdown-btn--info .info-icon {
        display: flex;
        align-items: center;
        justify-content: center;

        width: 18px;
        height: 12px;

        border: 0;
        padding: 0;
        border-radius: 0;
        background: transparent;

        color: var(--link);
        font-size: 14px;
        font-weight: 800;
        line-height: 1;
    }

    #activeFlyer {
        max-width: 70vw;
    }
}

/* ===== Scroll mobile compatible pull-to-refresh ===== */
html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
}

html {
    overflow-x: hidden;
    overflow-y: auto;
    /* ✅ important : réactive le pull-to-refresh */
}

body {
    overflow-x: hidden;
    overflow-y: auto;
    /* ok */
}

/* Correction : le menu "Plus d’informations…" doit s'ouvrir aligné à droite */
.header-right .dropdown {
    left: auto;
    right: 0;
}

/* ===== Flyers : conteneur centré ===== */
#flyersSection {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 22px;
}

/* =========================================================
   MODE PHOTO D'ÉQUIPE
   - image = référence (taille max dans la zone visible)
   - container = enveloppe (shrink-wrap)
   - pas de scrollbar
   ========================================================= */

body.mode-teamphoto {
    overflow: hidden;
    /* ✅ pas de scrollbar en mode photo */
}

body.mode-teamphoto #flyersSection {
    width: 100%;
    min-height: calc(100vh - var(--header-h) - var(--footer-h));
    display: flex;
    align-items: center;
    justify-content: center;
}

body.mode-teamphoto #rectoVersoBox,
body.mode-teamphoto #versoBox {
    display: none !important;
}

/* ✅ Container = enveloppe (calque sur l'image) */
body.mode-teamphoto #rectoBox.flyer-box {
    background: linear-gradient(135deg, #cde8c2, #f4f9ef, #cde8c2);
    /* 🔒 vert inchangé */
    border-radius: 34px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, .12);
    padding: 22px;
    box-sizing: border-box;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: fit-content;
    height: fit-content;

    max-width: calc(100vw - 2 * var(--content-gap));
    max-height: calc(100vh - var(--header-h) - var(--footer-h) - 2 * var(--content-gap));
}

/* picture = support neutre */
body.mode-teamphoto #rectoBox.flyer-box picture {
    display: block;
    line-height: 0;
}

/* ✅ L'image est la référence : taille max, proportions conservées */
body.mode-teamphoto #rectoBox.flyer-box img {
    display: block;

    width: auto;
    height: auto;

    /* Contrainte = zone visible moins padding du container (22px*2 = 44px) */
    max-width: calc(100vw - 2 * var(--content-gap) - 44px);
    max-height: calc(100vh - var(--header-h) - var(--footer-h) - 2 * var(--content-gap) - 44px);

    object-fit: contain;
    object-position: center;

    border-radius: 22px;
}

/* ===== Placeholder "Le Flyer" (Décembre) ===== */
.flyer-placeholder {
    width: min(92vw, 820px);
    min-height: 240px;
    display: grid;
    place-items: center;
    text-align: center;
    padding: 26px 18px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.92);
    border: 1.5px dashed rgba(59, 167, 118, .55);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.flyer-placeholder__title {
    font-weight: 800;
    font-size: 18px;
    margin-bottom: 6px;
    color: var(--link);
}

.flyer-placeholder__text {
    font-size: 13px;
    color: var(--muted);
    max-width: 52ch;
    line-height: 1.4;
}

/* ===== Flyer intermédiaire (recto-verso) : format paysage ===== */
.flyer-box--mid {
    width: 96vw;
    max-width: 1120px;
}