: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);                      /* hauteur FIXE */
    padding: 0 clamp(8px, 2vw, 16px);            /* padding horizontal uniquement */
    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;
}

.header-inner {
    position: relative;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    text-align: center;
    width: 100%;
    height: 100%;    /* occupe toute la hauteur du header */
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Bloc titre dynamique : centré géométriquement dans le header */
header nav[aria-label="Flyer actif"] {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

/* 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;
}

#activeFlyer {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    max-width: 90vw;
    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;
}

.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;   /* ← comme le dropdown principal */
    max-width: 90vw;      /* sécurité si un label devient énorme */
    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;              /* ancré sous le bouton "Historique" */
    top: calc(100% + 8px);
    width: max-content;   /* largeur = texte le plus long */
    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;    /* pas de scrollbar interne */
}

.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; /* même taille que le bouton */
    white-space: nowrap;
}

.dropdown a:hover,
.dropdown a:focus {
    background: rgba(245, 247, 250, .95);
    border: 1px solid rgba(59, 167, 118, .45); /* léger cadre vert */
    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);  /* ← retrouve la couleur */
    background-clip: border-box;           /* ← désactive le gradient sur hover */
    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);
}

/* ===== Contenu ===== */
main {
    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-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;
}

/* ===== Trombinoscope intégré ===== */
.trombi-box {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
}

#trombiFrame {
    width: 100%;
    border: none;
    min-height: 0;
    display: block;
    overflow: hidden;
}

/* ===== 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);  /* texte lisible, comme dropdown */
    background-clip: border-box;
    font-weight: 700;
}

/* Style du bouton du menu (redondant mais clair) */
.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 12px;
    font-weight: 700;
    font-size: 12px;
    color: var(--link);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}

/* Icône hamburger : 3 lignes horizontales */
.dropdown-btn .burger {
    display: none;          /* Caché par défaut (desktop) */
    flex-direction: column;
    gap: 3px;
}

.dropdown-btn .burger span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--link);
    border-radius: 2px;
}

/* Par défaut : texte et flèche visibles */
.dropdown-btn .btn-label {
    display: inline;
}
.dropdown-btn .chev {
    display: inline;
}
.dropdown-btn .burger {
    display: none;
}

/* Mobile : icône hamburger seule */
@media (max-width: 640px) {

    .dropdown-btn {
        padding: 6px 10px;
    }

    /* Cacher texte + flèche */
    .dropdown-btn .btn-label,
    .dropdown-btn .chev {
        display: none;
    }

    /* Afficher hamburger */
    .dropdown-btn .burger {
        display: flex;
    }
}

/* ===== Responsif général / overflow ===== */

html,
body {
    margin: 0;
    padding: 0;
    overflow-x: hidden !important;
    overflow-y: auto !important;   /* scroll vertical rétabli */
}
