/* ============================================================================
   CCN Header — Mega-menu
   Thème WordPress CCN — header sans dépendance au plugin CCN Header.

   Mobile breakpoint : 1024px (max-width).
   Variante CSS : body.style-cana, body.style-14-18 (body_class hook).
   ============================================================================ */


/* ─────────────────────────────────────────────────────────────────────────────
   CSS Custom Properties (défauts = variation « base »)
   Définis sur .ccn-header afin d'être hérités par tous les descendants.
   Les overrides de variation sont appliqués via body.style-{variant} .ccn-header.
   ───────────────────────────────────────────────────────────────────────────── */
.ccn-header {
    --header-bg:                #ffffff;
    --header-text:              #000000;
    --header-text-muted:        var(--medium-grey-for-base, #555555);
    --header-border-color:      #e8e8e8;
    --header-underline-color:   #000000;
    --header-topbar-font-size:  0.78rem;
    --header-topbar-font-weight: 700;
    --header-menu-font-size:    0.82rem;
    --header-menu-font-weight:  600;
    --header-tooltip-bg:        #ffffff;
    --header-tooltip-shadow:    0 4px 16px rgba(0, 0, 0, 0.15);
    --header-megamenu-bg:       #ffffff;
    --header-megamenu-shadow:   0 8px 32px rgba(0, 0, 0, 0.10);
    --header-card-bg:           #ffffff;
    --header-card-bg-hover:     #f5f5f5;
    --header-card-border:       #e8e8e8;
    --header-card-radius:       8px;
    --header-mobile-bg:         #ffffff;
    --header-mobile-width:      340px;
    --header-overlay-bg:        rgba(0, 0, 0, 0.40);
}


/* ─────────────────────────────────────────────────────────────────────────────
   Header principal
   ───────────────────────────────────────────────────────────────────────────── */
.ccn-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border-color);
    font-family: var(--heading--font-family, 'Spartan', sans-serif);
}

/* Décalage admin bar */
.admin-bar .ccn-header {
    top: 32px;
}

@media screen and (max-width: 600px) {
    .admin-bar .ccn-header {
        top: 46px;
    }
}


/* ─────────────────────────────────────────────────────────────────────────────
   Barre supérieure (topbar)
   ───────────────────────────────────────────────────────────────────────────── */
.ccn-header__topbar {
    border-bottom: 1px solid var(--header-border-color);
}

.ccn-header__topbar-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    height: 38px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    box-sizing: border-box;
}

.ccn-header__topbar-item {
    position: relative;
    display: flex;
    align-items: center;
}

.ccn-header__topbar-sep {
    color: var(--header-text-muted);
    font-weight: 300;
    font-size: 1.1rem;
    line-height: 1;
    user-select: none;
}

.ccn-header__topbar-link {
    font-family: inherit;
    font-size: var(--header-topbar-font-size);
    font-weight: var(--header-topbar-font-weight);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--header-text);
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.15s ease;
    white-space: nowrap;
}

a.ccn-header__topbar-link:hover {
    opacity: 0.7;
}

/* Tooltip topbar */
.ccn-header__topbar-tooltip {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--header-tooltip-bg);
    border: 1px solid var(--header-border-color);
    box-shadow: var(--header-tooltip-shadow);
    padding: 12px 16px;
    min-width: 200px;
    max-width: 320px;
    font-family: var(--global--font-secondary, 'Roboto', sans-serif);
    font-size: 0.82rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--header-text);
    white-space: normal;
    text-transform: none;
    letter-spacing: normal;
    z-index: 200;
    /* Caché par défaut */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease, visibility 0.15s ease;
}

.ccn-header__topbar-tooltip a {
    color: var(--header-text);
    text-decoration: underline;
}

.ccn-header__topbar-tooltip a:hover {
    opacity: 0.7;
}

.ccn-header__topbar-item:hover .ccn-header__topbar-tooltip,
.ccn-header__topbar-item:focus-within .ccn-header__topbar-tooltip {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}


/* ─────────────────────────────────────────────────────────────────────────────
   Navigation desktop
   ───────────────────────────────────────────────────────────────────────────── */
.ccn-header__nav {
    /* containing block pour .ccn-header__megamenu (position: absolute) */
    position: relative;
}

.ccn-header__nav-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    box-sizing: border-box;
    height: 52px;
}

/* Liste de menu de 1er niveau */
.ccn-header__menu {
    display: flex;
    align-items: stretch;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 0;
    height: 100%;
}

/* Item de menu — position: static ⟹ ne devient pas le containing block du megamenu */
.ccn-header__menu-item {
    position: static;
    height: 100%;
    display: flex;
    align-items: stretch;
}

/* Lien de menu */
.ccn-header__menu-link {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0 14px;
    text-decoration: none;
    color: var(--header-text);
    height: 100%;
    white-space: nowrap;
    transition: opacity 0.15s ease;
}

.ccn-header__menu-link:hover {
    opacity: 0.75;
}

.ccn-header__menu-item.is-open > .ccn-header__menu-link {
    opacity: 1;
}

.ccn-header__menu-label {
    font-family: inherit;
    font-size: var(--header-menu-font-size);
    font-weight: var(--header-menu-font-weight);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* Soulignement sur l'item actif (mega-menu ouvert) */
.ccn-header__menu-item.is-open > .ccn-header__menu-link .ccn-header__menu-label {
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1.5px;
    text-decoration-color: var(--header-underline-color);
}

/* Chevron */
.ccn-header__chevron {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    color: inherit;
    transition: transform 0.2s ease;
}

.ccn-header__menu-item.is-open > .ccn-header__menu-link .ccn-header__chevron {
    transform: rotate(180deg);
}


/* ─────────────────────────────────────────────────────────────────────────────
   Mega-menu (desktop)
   Positionné en absolu par rapport à .ccn-header__nav (position: relative).
   left: 0; right: 0 → pleine largeur de la nav.
   top: 100%         → juste sous la nav bar.
   ───────────────────────────────────────────────────────────────────────────── */
.ccn-header__megamenu {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    background: var(--header-megamenu-bg);
    box-shadow: var(--header-megamenu-shadow);
    border-top: 1px solid var(--header-border-color);
    z-index: 10;
    /* Caché par défaut */
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, visibility 0.18s ease;
}

.ccn-header__menu-item.is-open .ccn-header__megamenu {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

.ccn-header__megamenu-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
    box-sizing: border-box;
}

/* Grille de cartes */
.ccn-header__cards-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.ccn-header__cards-item {
    min-width: 0;
}

/* Carte de menu */
.ccn-header__menu-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: var(--header-text);
    background: var(--header-card-bg);
    border: 1px solid var(--header-card-border);
    border-radius: var(--header-card-radius);
    overflow: hidden;
    height: 100%;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.ccn-header__menu-card:hover {
    background: var(--header-card-bg-hover);
    border-color: var(--header-text-muted, #555);
}

/* Image 16:9 avec bords arrondis (haut seulement) */
.ccn-header__card-img-wrap {
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: var(--header-card-radius) var(--header-card-radius) 0 0;
    background: var(--header-border-color);
    flex-shrink: 0;
}

.ccn-header__card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.ccn-header__menu-card:hover .ccn-header__card-img {
    transform: scale(1.04);
}

.ccn-header__card-img--empty {
    width: 100%;
    height: 100%;
    background: #e0e0e0;
}

/* Corps de la carte */
.ccn-header__card-body {
    padding: 8px 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

/* Titre — 2 lignes max */
.ccn-header__card-title {
    font-family: var(--heading--font-family, 'Spartan', sans-serif);
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--header-text);
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Extrait — 3 lignes max */
.ccn-header__card-excerpt {
    font-family: var(--global--font-secondary, 'Roboto', sans-serif);
    font-size: 0.72rem;
    line-height: 1.45;
    color: var(--header-text-muted, #555);
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}


/* ─────────────────────────────────────────────────────────────────────────────
   Bouton hamburger (mobile uniquement)
   ───────────────────────────────────────────────────────────────────────────── */
.ccn-header__hamburger {
    display: none; /* affiché via media query mobile */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    box-sizing: border-box;
    margin-left: auto;
    -webkit-tap-highlight-color: transparent;
}

.ccn-header__hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--header-text);
    border-radius: 2px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Animation hamburger → X */
.ccn-header__hamburger[aria-expanded="true"] span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.ccn-header__hamburger[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}
.ccn-header__hamburger[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}


/* ─────────────────────────────────────────────────────────────────────────────
   Menu mobile (panel latéral)
   ───────────────────────────────────────────────────────────────────────────── */
.ccn-header__mobile {
    position: fixed;
    top: 0;
    right: 0;
    width: min(var(--header-mobile-width), 100vw);
    height: 100dvh;
    background: var(--header-mobile-bg);
    overflow-y: auto;
    z-index: 200;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    /* Caché hors écran par défaut */
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ccn-header__mobile.is-open {
    transform: translateX(0);
}

/* En-tête du panel mobile */
.ccn-header__mobile-top {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 12px 16px;
    border-bottom: 1px solid var(--header-border-color);
    flex-shrink: 0;
    min-height: 52px;
    box-sizing: border-box;
}

.ccn-header__mobile-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--header-text);
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

/* Liste des items mobiles */
.ccn-header__mobile-list {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
    overflow-y: auto;
}

.ccn-header__mobile-item {
    border-bottom: 1px solid var(--header-border-color);
}

.ccn-header__mobile-row {
    display: flex;
    align-items: stretch;
    min-height: 52px;
}

.ccn-header__mobile-link {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 14px 16px;
    font-family: var(--heading--font-family, 'Spartan', sans-serif);
    font-size: 0.80rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--header-text);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

/* Soulignement quand sous-menu ouvert */
.ccn-header__mobile-item.is-open > .ccn-header__mobile-row .ccn-header__mobile-link {
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: var(--header-underline-color);
}

/* Bouton chevron mobile (toggle sous-menu) */
.ccn-header__mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    min-height: 52px;
    background: transparent;
    border: none;
    border-left: 1px solid var(--header-border-color);
    cursor: pointer;
    color: var(--header-text);
    padding: 0;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.ccn-header__mobile-toggle svg {
    transition: transform 0.2s ease;
}

.ccn-header__mobile-item.is-open > .ccn-header__mobile-row .ccn-header__mobile-toggle svg {
    transform: rotate(180deg);
}

/* Sous-menu mobile (accordéon) */
.ccn-header__mobile-submenu {
    list-style: none;
    margin: 0;
    padding: 0;
    background: #f9f9f9;
}

.ccn-header__mobile-subitem {
    border-top: 1px solid var(--header-border-color);
}

.ccn-header__mobile-sublink {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 16px;
    text-decoration: none;
    color: var(--header-text);
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s ease;
}

.ccn-header__mobile-sublink:hover,
.ccn-header__mobile-sublink:focus {
    background: var(--header-card-bg-hover);
}

/* Miniature sous-item (16:9) — hauteur ≈ 2 lignes de texte */
.ccn-header__mobile-thumb-wrap {
    flex-shrink: 0;
    width: 80px;
    aspect-ratio: 16 / 9;
    border-radius: 4px;
    overflow: hidden;
    background: var(--header-border-color);
}

.ccn-header__mobile-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ccn-header__mobile-subtext {
    font-family: var(--heading--font-family, 'Spartan', sans-serif);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--header-text);
    padding-top: 2px;
    /* 2 lignes max */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}


/* ─────────────────────────────────────────────────────────────────────────────
   Overlay (backdrop mobile)
   ───────────────────────────────────────────────────────────────────────────── */
.ccn-header__overlay {
    position: fixed;
    inset: 0;
    background: var(--header-overlay-bg);
    z-index: 150;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.ccn-header__overlay.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Blocage du scroll body (mobile menu ouvert) */
body.ccn-no-scroll {
    overflow: hidden;
}


/* ─────────────────────────────────────────────────────────────────────────────
   Responsive — layout mobile (≤ 1024px)
   ───────────────────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {

    /* Masquer le menu desktop */
    .ccn-header__menu {
        display: none;
    }

    /* Afficher le hamburger */
    .ccn-header__hamburger {
        display: flex;
    }

    /* Nav inner : aligner à droite pour le hamburger */
    .ccn-header__nav-inner {
        justify-content: flex-end;
    }
}

/* Masquer la topbar sur très petit écran */
@media (max-width: 480px) {
    .ccn-header__topbar {
        display: none;
    }
}


/* ─────────────────────────────────────────────────────────────────────────────
   Overrides de variation — cana
   ───────────────────────────────────────────────────────────────────────────── */
body.style-cana .ccn-header {
    --header-underline-color: var(--red-for-cana, #bb2018);
}


/* ─────────────────────────────────────────────────────────────────────────────
   Overrides de variation — 14-18
   ───────────────────────────────────────────────────────────────────────────── */
body.style-14-18 .ccn-header {
    --header-underline-color: var(--yellow-for-14-18, #fbbe01);
}
