/* ==========================================================
   header-modern.css : à charger APRÈS header.css
   - Header collant, fond verre (flou), jamais caché
   - Navigation en pilule, les liens secondaires dans « Plus »
   - Menu mobile en panneau de tuiles dès 1100 px
   ========================================================== */

:root { --hdr-h: 64px; }
html { scroll-padding-top: calc(var(--hdr-h) + 1rem); } /* les ancres (#contact) ne passent plus sous le header */

/* ---------- Header : toujours collant, effet verre ---------- */
.header,
.header.is-sticky {
    position: sticky; top: 0; left: auto; right: auto;
    padding: env(safe-area-inset-top, 0) 0 0;
    background: rgba(255, 255, 255, .72);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    backdrop-filter: saturate(180%) blur(18px);
    border-bottom: 1px solid rgba(17, 17, 17, .08);
    box-shadow: none; animation: none; transform: none;
}
.header.is-sticky { box-shadow: 0 8px 30px rgba(17, 17, 17, .08); }
.header.is-hidden { transform: none !important; }

/* Mêmes marges que le contenu : max-width 1400 px (comme le hero) et mêmes gouttières.
   Ordinateur large : 2rem | portable : --gutter | tablette : 2rem | mobile : 1.25rem */
.header__container {
    box-sizing: border-box; width: 100%; max-width: 1400px; margin: 0 auto; min-height: var(--hdr-h);
    padding: 0 2rem; gap: 1rem;
}
@media (min-width: 1025px) and (max-width: 1700px) {
    :root { --gutter: clamp(2rem, 6vw, 6rem); }
    .header__container { padding: 0 var(--gutter); }
}
@media (max-width: 768px) {
    .header__container { padding: 0 1.25rem; }
}

/* Logo circulaire, jour et nuit */
.header__logo img,
.header.is-sticky .header__logo img,
[data-theme="dark"] .header__logo img,
[data-theme="dark"] .header.is-sticky .header__logo img {
    display: block; flex-shrink: 0; max-width: none; aspect-ratio: 1 / 1;
    width: 44px !important; height: 44px !important; padding: 4px !important;
    object-fit: contain !important;
    border-radius: 50% !important; background: #fff !important;
    border: 2px solid #1e3a5f !important;   /* anneau visible : le rond se voit même sur fond blanc */
    box-shadow: 0 2px 8px rgba(17, 17, 17, .12) !important;
}
.header__logo { display: flex; align-items: center; flex-shrink: 0; line-height: 0; }

/* ---------- Navigation en pilule ---------- */
.header__nav { flex: 1; justify-content: center; }
.header__menu {
    gap: .125rem; padding: .25rem; border-radius: 999px;
    background: rgba(30, 58, 95, .05); border: 1px solid rgba(30, 58, 95, .08);
}
.header__link {
    padding: .5rem .95rem; border-radius: 999px;
    font-size: .9rem; font-weight: 500; color: var(--text-secondary);
    transition: background .2s ease, color .2s ease;
}
.header__link::after, .header__link-icon { display: none; } /* chevrons et soulignement sans fonction */
.header__link:hover { background: rgba(30, 58, 95, .07); color: var(--text-primary); }
.header__link.active {
    background: #fff; color: var(--institutional-red);
    box-shadow: 0 1px 3px rgba(17, 17, 17, .12);
}

/* Bouton « Plus » (liens regroupés) */
.header__more { position: relative; }
.header__more summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .3rem; }
.header__more summary::-webkit-details-marker { display: none; }
.header__more-chevron { transition: transform .2s ease; }
.header__more[open] .header__more-chevron { transform: rotate(180deg); }
.header__more[open] > summary { background: rgba(30, 58, 95, .07); }
.header__more-panel {
    position: absolute; top: calc(100% + .6rem); right: 0; min-width: 220px;
    display: grid; gap: 2px; padding: .4rem;
    background: rgba(255, 255, 255, .97); border: 1px solid rgba(17, 17, 17, .08);
    border-radius: 16px; box-shadow: 0 20px 50px rgba(17, 17, 17, .16);
}
.header__more-link {
    padding: .7rem .9rem; border-radius: 10px; text-decoration: none;
    font-size: .92rem; font-weight: 500; color: var(--text-secondary);
}
.header__more-link:hover, .header__more-link.active {
    background: rgba(201, 37, 37, .07); color: var(--institutional-red);
}

/* ---------- Actions ---------- */
.header__actions { gap: .5rem; }
.header__theme-toggle { background: transparent; }
.header__theme-toggle:hover { transform: none; }

.header__cta { padding: .55rem 1.1rem; font-size: .88rem; }
.header__cta--login {
    color: var(--text-primary); border: 1px solid rgba(30, 58, 95, .22);
}
.header__cta--login:hover {
    background: rgba(30, 58, 95, .06); color: var(--text-primary);
    transform: none; box-shadow: none;
}
.header__cta--register { box-shadow: 0 6px 16px rgba(201, 37, 37, .25); }
.header__cta--register:hover { transform: none; box-shadow: 0 6px 16px rgba(143, 23, 23, .35); }

.header__user-dropdown {
    background: rgba(255, 255, 255, .97); border-radius: 16px;
    border-top: 1px solid var(--border-color); box-shadow: 0 20px 50px rgba(17, 17, 17, .16);
}

/* ---------- Burger rond ---------- */
.header__burger {
    width: 42px; height: 42px; padding: 0; gap: 4px;
    align-items: center; justify-content: center;
    background: transparent; border: 1px solid var(--border-color); border-radius: 50%;
}
.header__burger span { width: 18px; height: 2px; }
.header__burger.active span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.header__burger.active span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ---------- Menu mobile : panneau flottant en tuiles ---------- */
.header__mobile-menu {
    top: calc(100% + .5rem); left: .75rem; right: .75rem;
    border: 1px solid rgba(17, 17, 17, .08); border-radius: 22px;
    background: rgba(255, 255, 255, .97); box-shadow: 0 24px 60px rgba(17, 17, 17, .2);
    transform: translateY(-8px);
    transition: max-height .4s ease, opacity .25s ease, transform .3s ease;
}
.header__mobile-menu.active { transform: none; max-height: calc(100vh - 6rem); }

.header__mobile-menu-content {
    display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; padding: .75rem;
}
.header__mobile-menu-content > * { min-width: 0; }
.header__mobile-divider, .header__mobile-cta,
.header__mobile-user-info, .header__mobile-menu-content form { grid-column: 1 / -1; }

.header__mobile-link {
    flex-direction: column; justify-content: center; gap: .4rem;
    padding: 1rem .5rem; text-align: center; font-size: .88rem;
    border: 1px solid var(--border-color); border-radius: 16px;
    background: rgba(30, 58, 95, .03);
}
.header__mobile-link:nth-child(7) { grid-column: 1 / -1; flex-direction: row; gap: .6rem; }
.header__mobile-link:hover, .header__mobile-link.active {
    background: rgba(201, 37, 37, .07); border-color: rgba(201, 37, 37, .25);
    color: var(--institutional-red);
}
.header__mobile-divider { margin: .25rem 0; }
.header__mobile-cta { padding: .9rem 1rem; border-radius: 14px; font-size: .95rem; }

/* ---------- Bascule en mode mobile dès 1100 px (avant : 768 px, trop tard avec 7 liens) ---------- */
@media (max-width: 1100px) {
    .header__nav, .header__cta, .header__user-menu { display: none; }
    .header__burger { display: flex; }
    .header__actions { margin-left: auto; }
}
@media (min-width: 1101px) {
    .header__mobile-menu { display: none; }
}
@media (max-width: 768px) {
    :root { --hdr-h: 60px; }
    .header__logo img, .header.is-sticky .header__logo img,
    [data-theme="dark"] .header__logo img,
    [data-theme="dark"] .header.is-sticky .header__logo img { width: 40px; height: 40px; }
}

/* ---------- Anti-débordement : le bouton de droite ne sort plus de la marge ---------- */
.header__nav { min-width: 0; }
.header__actions { flex-shrink: 0; }
@media (min-width: 1101px) and (max-width: 1360px) {
    .header__container { gap: .75rem; }
    .header__link { padding: .45rem .75rem; font-size: .86rem; }
    .header__cta { padding: .5rem .95rem; font-size: .84rem; }
}

/* ---------- Mode sombre ---------- */
[data-theme="dark"] .header,
[data-theme="dark"] .header.is-sticky {
    background: rgba(12, 14, 18, .66); border-bottom-color: rgba(255, 255, 255, .08);
}
[data-theme="dark"] .header__menu { background: rgba(255, 255, 255, .05); border-color: rgba(255, 255, 255, .08); }
[data-theme="dark"] .header__link:hover,
[data-theme="dark"] .header__more[open] > summary { background: rgba(255, 255, 255, .08); }
[data-theme="dark"] .header__link.active { background: rgba(255, 255, 255, .12); color: #ff7a7a; box-shadow: none; }
[data-theme="dark"] .header__more-panel,
[data-theme="dark"] .header__mobile-menu,
[data-theme="dark"] .header__user-dropdown {
    background: rgba(18, 20, 26, .97); border-color: rgba(255, 255, 255, .1);
}
[data-theme="dark"] .header__mobile-link { background: rgba(255, 255, 255, .04); }
[data-theme="dark"] .header__cta--login { border-color: rgba(255, 255, 255, .25); }
[data-theme="dark"] .header__more-link:hover, [data-theme="dark"] .header__more-link.active,
[data-theme="dark"] .header__mobile-link:hover, [data-theme="dark"] .header__mobile-link.active { color: #ff7a7a; }

@media (prefers-reduced-motion: reduce) {
    .header, .header * { transition-duration: .01ms !important; animation: none !important; }
}