/**
 * En-tete et pied de page communs a GeoRezo : grz_django (georezo.css),
 * forum (grz_georezov2, web/forum/css/grz-header-footer.css) et wiki
 * (grz_dokuwiki, tpl/georezo3/css/grz-header-footer.css).
 * Les deux copies de ce fichier doivent rester identiques ; les regles
 * viennent des sections "Header et menu principal" et "Footer" de
 * georezo.css (grz_django). A charger apres les feuilles historiques
 * (georezo_build.css / layout.css), dont elles remplacent la mise en page
 * du bandeau (positions absolues, largeurs minimales).
 * */

/* Texte reserve aux lecteurs d'ecran (equivalent de la classe Bootstrap,
   que le forum et le wiki ne chargent pas) */
.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;
}

/**
 * Header et menu principal (cf templates base.html et menu.html)
 * 100% CSS, sans JavaScript. Remplace la mise en page de georezo_build.css
 * (positions absolues, min-width 890px) :
 *  - 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).
 * */
.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; }

#wrapper #grz_header {
    display: grid;
    height: auto;
    min-width: 0;
}
#grz_header .grz-banner img {
    display: block;
    max-width: 100%;
    height: auto;
}
#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;
}
.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 actif : couleurs inversees, comme les anciens tabOn_* */
    .grz-nav-section:hover > .grz-nav-tab,
    .grz-nav-section:focus-within > .grz-nav-tab,
    #grz_nav .grz-nav-section:hover > 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";
        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;
        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;
    }

    /* Footer : le tableau passe en grille de 2 colonnes, chaque titre
       (th) reste au-dessus de ses liens (td de meme rang) */
    html body div#main-footer {
        height: auto;
        background: #f4f4f4 !important;
        padding: 10px 0;
    }
    html body div#main-footer table {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0 10px;
        width: auto !important;
        height: auto;
        margin: 0 10px;
        background: none !important;
    }
    #main-footer thead,
    #main-footer tbody,
    #main-footer tr {
        display: contents;
    }
    #main-footer thead td {
        display: none;
    }
    #main-footer th,
    body div#main-footer td {
        width: auto;
        height: auto;
    }
    #main-footer th {
        padding: 4px 6px;
        margin-top: 10px;
    }
    body div#main-footer td {
        padding: 4px 6px 0;
        line-height: 24px;
        font-size: 12px;
    }
    #main-footer th:nth-child(odd),
    #main-footer tbody td:nth-child(odd) { grid-column: 1; }
    #main-footer th:nth-child(even),
    #main-footer tbody td:nth-child(even) { grid-column: 2; }
    #main-footer th:nth-child(-n+2)                 { grid-row: 1; }
    #main-footer tbody td:nth-child(-n+2)           { grid-row: 2; }
    #main-footer th:nth-child(n+3):nth-child(-n+4)  { grid-row: 3; }
    #main-footer tbody td:nth-child(n+3):nth-child(-n+4) { grid-row: 4; }
    #main-footer th:nth-child(n+5):nth-child(-n+6)  { grid-row: 5; }
    #main-footer tbody td:nth-child(n+5):nth-child(-n+6) { grid-row: 6; }
    #main-footer th:nth-child(1) { background-color: #456baa; }
    #main-footer th:nth-child(2) { background-color: #54baba; }
    #main-footer th:nth-child(3) { background-color: #8fc002; }
    #main-footer th:nth-child(4) { background-color: #ef7103; }
    #main-footer th:nth-child(5) { background-color: #456baa; }
    #main-footer th:nth-child(6) { background-color: #999; }
    body div#main-footer td.logo {
        grid-column: 1 / -1;
        grid-row: 7;
        width: auto;
        margin-top: 15px;
        text-align: center;
    }
}

/**
 * Rubrique courante (forum et wiki : classe grz-nav-current posee sur la
 * rubrique de la page), affichee en couleurs inversees comme au survol.
 * */
@media (min-width: 769px) {
    #grz_nav .grz-nav-current > .grz-nav-tab {
        color: var(--grz-sec);
        background-color: #fff;
    }
}
