/**
 * Header et menu principal (cf inc/menu.php)
 * Repris du menu de grz_django (static_src/georezo.css, section
 * "Header et menu principal") pour garder le meme fonctionnement.
 * 100% CSS, sans JavaScript. Remplace le menu en tableaux de menu-v3.css /
 * menuBar.js et la mise en page en positions absolues de layout.css :
 *  - ordinateur : barre d'onglets, sous-menu deroulant sous l'onglet
 *    survole ou ayant le focus clavier ;
 *  - mobile (<= 768px) : burger (case #grz_nav_toggle) et sous-menus en
 *    accordeon (une case par rubrique).
 * Fichier charge apres georezo_build.css (cf inc/header.php) : il n'est pas
 * inclus dans le build de scripts/compressor.sh.
 * */
.grz-nav-communaute  { --grz-sec: #456baa; }
.grz-nav-ressources  { --grz-sec: #54baba; }
.grz-nav-emploi      { --grz-sec: #8fc002; }
.grz-nav-marche      { --grz-sec: #ef7103; }
.grz-nav-association { --grz-sec: #456baa; }

/* Pas de Bootstrap sur le site legacy : equivalent de sa classe */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

#wrapper #grz_header {
    display: grid;
    height: auto;
    min-width: 0;
}
#grz_header .grz-banner img {
    display: block;
    max-width: 100%;
    height: auto;
    border: 0;
}
#grz_header h1 {
    grid-area: title;
    position: static;
    width: auto;
}
#grz_header #form {
    grid-area: form;
    position: static;
    float: none;
    height: auto;
}
#grz_header .grz-banner { grid-area: banner; }
#grz_nav { grid-area: nav; }

#grz_nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
}
#grz_nav a,
#grz_nav a:hover {
    text-decoration: none;
}
.grz-nav-tab {
    display: block;
    font: bold 11px arial, sans-serif;
    text-transform: uppercase;
    color: #fff;
    background-color: var(--grz-sec);
}
#grz_nav a.grz-nav-tab:hover {
    color: #fff;
}
.grz-nav-sub a {
    display: block;
    font: bold 12px arial, sans-serif;
    color: var(--grz-sec);
}
#grz_nav .grz-nav-sub a:hover,
#grz_nav .grz-nav-sub a:focus {
    color: var(--grz-sec);
    background-color: #f4f4f4;
}
.grz-nav-social {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
    background-color: #ddd;
}
.grz-nav-social img {
    display: block;
    border: 0;
}
.grz-nav-check {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

@media (min-width: 769px) {
    #wrapper #grz_header {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "banner form"
            "title  form"
            "nav    nav";
    }
    #grz_header h1 {
        padding: 0 0 10px 180px;
    }
    #grz_header #form {
        padding: 10px;
    }
    .grz-nav-check,
    .grz-nav-burger,
    .grz-nav-subtoggle {
        display: none;
    }

    #grz_nav {
        display: flex;
        background-color: #ddd;
    }
    .grz-nav-sections {
        display: flex;
        flex: 1;
    }
    .grz-nav-section {
        position: relative;
        flex: 1;
    }
    .grz-nav-tab {
        line-height: 31px;
        text-align: center;
    }
    /* Onglet survole et rubrique courante : couleurs inversees, comme les
       anciens tabOn_* */
    .grz-nav-section:hover > .grz-nav-tab,
    .grz-nav-section:focus-within > .grz-nav-tab,
    .grz-nav-current > .grz-nav-tab,
    #grz_nav .grz-nav-section:hover > a.grz-nav-tab:hover,
    #grz_nav .grz-nav-current > a.grz-nav-tab:hover {
        color: var(--grz-sec);
        background-color: #fff;
    }
    .grz-nav-sub {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        z-index: 300;
        min-width: 100%;
        width: max-content;
        padding: 4px 0;
        background-color: #fff;
        border: 1px solid #ccc;
        border-top: 3px solid var(--grz-sec);
        box-shadow: 0 4px 8px rgba(0, 0, 0, .15);
    }
    .grz-nav-section:last-child .grz-nav-sub {
        left: auto;
        right: 0;
    }
    .grz-nav-section:hover > .grz-nav-sub,
    .grz-nav-section:focus-within > .grz-nav-sub {
        display: block;
    }
    .grz-nav-sub a {
        padding: 7px 16px;
    }
}

@media (max-width: 768px) {
    #wrapper {
        width: 100%;
    }
    #wrapper #grz_header {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "banner burger"
            "title  title"
            "nav    nav"
            "form   form";
        min-height: 0 !important; /* annule le min-height de layout.css */
        border-left: 0;
        border-right: 0;
        background-color: #f4f4f4;
    }
    #grz_header .grz-banner {
        padding: 5px;
    }
    #grz_header .grz-banner img {
        max-height: 70px;
    }
    #grz_header h1 {
        padding: 0 10px 5px;
        font-size: 14px;
    }
    #grz_header #form {
        text-align: left;
        padding: 5px 10px;
        font-size: 1em;
    }
    #gr_googlesearch {
        margin-top: 5px;
        width: auto;
    }

    .grz-nav-burger {
        grid-area: burger;
        align-self: center;
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 5px;
        box-sizing: border-box;
        width: 44px;
        height: 40px;
        margin: 0 10px;
        padding: 0 9px;
        border: 1px solid #b7b6b6;
        border-radius: 4px;
        background: #fff;
        cursor: pointer;
    }
    .grz-nav-burger > span:not(.visually-hidden) {
        display: block;
        height: 3px;
        background: #456baa;
        border-radius: 2px;
    }
    .grz-nav-check:focus-visible + label {
        outline: 2px solid #ef7103;
        outline-offset: -2px;
    }

    #grz_nav {
        display: none;
    }
    #grz_nav_toggle:checked ~ #grz_nav {
        display: block;
    }
    .grz-nav-section {
        display: flex;
        flex-wrap: wrap;
        background-color: var(--grz-sec);
        border-bottom: 1px solid rgba(255, 255, 255, .4);
    }
    .grz-nav-tab {
        flex: 1;
        padding: 0 12px;
        line-height: 44px;
        font-size: 13px;
    }
    .grz-nav-subtoggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 48px;
        margin: 0;
        border-left: 1px solid rgba(255, 255, 255, .4);
        cursor: pointer;
    }
    .grz-nav-subtoggle::before {
        content: "";
        width: 9px;
        height: 9px;
        margin-top: -4px;
        border-right: 2px solid #fff;
        border-bottom: 2px solid #fff;
        transform: rotate(45deg);
    }
    .grz-nav-check:checked + .grz-nav-subtoggle::before {
        margin-top: 4px;
        transform: rotate(-135deg);
    }
    .grz-nav-sub {
        display: none;
        flex-basis: 100%;
        background-color: #fff;
    }
    .grz-nav-check:checked ~ .grz-nav-sub {
        display: block;
    }
    .grz-nav-sub a {
        padding: 10px 24px;
        border-top: 1px solid #eee;
    }
    .grz-nav-social {
        justify-content: center;
        padding: 8px;
    }

    #content {
        min-width: 0;
    }
}
