/* ==========================================================================
   mobile-nav.css  —  Menu mobile accessibile con drawer laterale

   Sezioni:
     1.  Accessibilità (.visually-hidden, .skiplink, :focus-visible)
     2.  Hamburger (#btn-menu-mobile)
     3.  Overlay (#nav-overlay)
     4.  Drawer (#nav-mobile-panel)
     5.  Header drawer (.drawer-header)
     6.  Voci menu (.navmenu-mobile)
     7.  Ricerca e social mobili
     8.  Body lock
     9.  Navbar desktop
    10.  Reset sistema precedente
    11.  Layout header mobile
    12.  Fix colore navbar desktop
    13.  Override ereditarietà colori
   ========================================================================== */


/* ── 1. ACCESSIBILITÀ ─────────────────────────────────────────────────────*/

.visually-hidden,
.visually-hidden-focusable:not(:focus):not(:focus-within) {
    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;
}

.skiplink {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 999999;
    margin: 0;
    padding: 0;
    list-style: none;
}

.skiplink ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.skiplink a {
    position: absolute;
    top: -120px;
    left: 8px;
    z-index: 999999;
    display: inline-block;
    padding: 10px 18px;
    background: #003882;
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: 0 0 6px 6px;
    white-space: nowrap;
    transition: top 0.15s ease;
}

.skiplink a:focus {
    top: 0;
}

/* Focus ring — WCAG 2.4.7 / 2.4.11 */
:focus-visible {
    outline: 3px solid #F5A623 !important;
    outline-offset: 2px !important;
    border-radius: 2px;
}

:focus:not(:focus-visible) {
    outline: none;
}


/* ── 2. HAMBURGER ─────────────────────────────────────────────────────────
   Min 44×44px (WCAG 2.5.5). Animazione → X tramite .is-active via JS.
   ─────────────────────────────────────────────────────────────────────────*/

#btn-menu-mobile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width:  48px;
    height: 48px;
    min-width:  44px;
    min-height: 44px;
    padding: 0;
    margin: 0;
    background: transparent;
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    color: #ffffff;
    transition: border-color 0.2s ease;
}

#btn-menu-mobile:focus-visible {
    border-color: #F5A623;
    outline: none !important;
}

@media (min-width: 992px) and (min-height: 761px),
       (min-width: 1441px) {
    #btn-menu-mobile {
        display: none !important;
    }
}

.navbar-toggler-icon {
    display: block;
    position: relative;
    width: 24px;
    height: 20px;
}

.icon-bar {
    display: block;
    position: absolute;
    left: 0;
    width: 24px;
    height: 3px;
    background-color: currentColor;
    border-radius: 2px;
    transition:
        opacity   0.25s ease,
        transform 0.3s  cubic-bezier(0.35, 0.085, 0.305, 1.005);
}

.icon-bar1 { top: 0; }
.icon-bar2 { top: 8px; }
.icon-bar3 { top: 16px; }

#btn-menu-mobile.is-active .icon-bar2 { opacity: 0; }
#btn-menu-mobile.is-active .icon-bar1 { transform: translateY(8px)  rotate(45deg); }
#btn-menu-mobile.is-active .icon-bar3 { transform: translateY(-8px) rotate(-45deg); }


/* ── 3. OVERLAY ───────────────────────────────────────────────────────────
   Il div deve essere fratello del drawer nel DOM, non figlio.
   ─────────────────────────────────────────────────────────────────────────*/

#nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 9997;
    cursor: pointer;
}

body.menu-mobile-open #nav-overlay {
    display: block;
}

@media (min-width: 992px) and (min-height: 761px),
       (min-width: 1441px) {
    #nav-overlay { display: none !important; }
}


/* ── 4. DRAWER ────────────────────────────────────────────────────────────
   Chiuso: translateX(-100%). Aperto: .expanded via JS.
   z-index 9998 > overlay 9997.
   ─────────────────────────────────────────────────────────────────────────*/

#nav-mobile-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 300px;
    max-width: 88vw;
    height: 100%;
    z-index: 9998;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    background: #ffffff;
    color: #1a3668;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.20);
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

#nav-mobile-panel.expanded {
    transform: translateX(0);
}

@media (prefers-reduced-motion: reduce) {
    #nav-mobile-panel { transition: none; }
}

@media (min-width: 992px) and (min-height: 761px),
       (min-width: 1441px) {
    #nav-mobile-panel { display: none !important; }
}

.nav-panel-inner {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    padding-bottom: 24px;
}


/* ── 5. HEADER DRAWER ─────────────────────────────────────────────────────*/

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px 12px 18px;
    border-bottom: 1px solid #e0e0e0;
    background: #f7f7f7;
    color: #1a3668;
    flex-shrink: 0;
}

.drawer-site-name {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex: 1;
    min-width: 0;
    margin-right: 12px;
    color: #003882;
}

.drawer-site-name:hover .drawer-site-label {
    text-decoration: underline;
}

.drawer-logo {
    width: auto;
    height: 44px;
    max-width: 48px;
    object-fit: contain;
    flex-shrink: 0;
}

.drawer-site-label {
    font-size: 0.875rem;
    font-weight: 700;
    color: #003882;
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Bottone chiudi: cerchio con solo icona X */
.close-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width:  44px;
    height: 44px;
    min-width:  44px;
    min-height: 44px;
    padding: 0;
    background: transparent;
    border: 2px solid #003882;
    border-radius: 50%;
    color: #003882;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.close-menu-btn:hover,
.close-menu-btn:focus {
    background: #003882;
    color: #ffffff;
}

.close-menu-btn .icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.close-menu-btn span:not(.icon):not(.icon-sm) {
    display: none;
}


/* ── 6. VOCI MENU MOBILE ──────────────────────────────────────────────────
   Target touch: min 44px per voce (WCAG 2.5.5).
   Gerarchia: lvl1 = voce radice, lvl2 = intestazione sezione, lvl3 = voce.
   ─────────────────────────────────────────────────────────────────────────*/

@media (max-width: 991px),
       (min-width: 992px) and (max-width: 1440px) and (max-height: 760px) {

    .menu-wrapper { flex: 1; }

    ul#menu-mobile,
    .navmenu-mobile {
        display: flex;
        flex-direction: column;
        margin: 0;
        padding: 0;
        list-style: none;
    }

    /* Livello 1 */
    .navmenu-mobile > li {
        border-bottom: 1px solid #ebebeb;
        margin: 0;
        padding: 0;
    }

    .navmenu-mobile > li > a {
        display: flex;
        align-items: center;
        min-height: 50px;
        padding: 10px 18px;
        font-size: 1rem;
        font-weight: 600;
        color: #1a3668;
        text-decoration: none;
        position: relative;
    }

    .navmenu-mobile > li > a:hover,
    .navmenu-mobile > li > a:focus {
        background: #f0f4fa;
        color: #003882;
    }

    /* Pagina home */
    .navmenu-mobile > li.menu-item-home > a {
        border-left: 4px solid #F5A623;
        padding-left: 14px;
        font-weight: 700;
    }

    /* Pagina corrente */
    .navmenu-mobile > li.current-menu-item > a {
        color: #003882;
        font-weight: 700;
        border-left: 4px solid #F5A623;
        padding-left: 14px;
        background: #fff9f0;
    }

    /* Ancestor della pagina corrente */
    .navmenu-mobile > li.current-menu-ancestor > a,
    .navmenu-mobile > li.current-page-ancestor > a {
        color: #003882;
        font-weight: 600;
        border-left: 3px solid #aec5e8;
        padding-left: 15px;
    }

    /* Corrente/ancestor ai livelli inferiori */
    .navmenu-mobile > li > ul > li.current-menu-item > a,
    .navmenu-mobile > li > ul > li.current-menu-ancestor > a,
    .navmenu-mobile > li > ul > li.current-page-ancestor > a {
        color: #001a4d;
        background: #dce6f5;
    }

    .navmenu-mobile > li > ul > li > ul > li.current-menu-item > a {
        color: #003882;
        font-weight: 600;
        background: #e8f0fa;
    }

    /* Livello 2: intestazione sezione */
    .navmenu-mobile > li > ul {
        display: none;
        list-style: none;
        margin: 0;
        padding: 0;
        background: #eef2f7;
        border-left: 4px solid #003882;
    }

    .navmenu-mobile > li.open > ul {
        display: block;
    }

    .navmenu-mobile > li > ul > li > a {
        display: flex;
        align-items: center;
        min-height: 48px;
        padding: 10px 18px 10px 20px;
        font-size: 0.95rem;
        font-weight: 700;
        color: #003882;
        text-decoration: none;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        background: #eef2f7;
        border-bottom: 1px solid #d8e2ef;
    }

    .navmenu-mobile > li > ul > li > a:hover,
    .navmenu-mobile > li > ul > li > a:focus {
        background: #dce6f5;
        color: #001a4d;
    }

    /* Livello 3: voci */
    .navmenu-mobile > li > ul > li > ul {
        display: none;
        list-style: none;
        margin: 0;
        padding: 0;
        background: #f8fafc;
        border-left: 4px solid #aec5e8;
    }

    .navmenu-mobile > li > ul > li.open > ul {
        display: block;
    }

    .navmenu-mobile > li > ul > li > ul > li > a {
        display: flex;
        align-items: center;
        min-height: 44px;
        padding: 8px 18px 8px 32px;
        font-size: 0.9rem;
        font-weight: 400;
        color: #1a3668;
        text-decoration: none;
    }

    .navmenu-mobile > li > ul > li > ul > li > a:hover,
    .navmenu-mobile > li > ul > li > ul > li > a:focus {
        background: #e2ebf5;
        color: #003882;
    }

    /* Livello 4+ */
    .navmenu-mobile ul ul ul {
        display: none;
        list-style: none;
        margin: 0;
        padding: 0;
        background: #f0f4fa;
        border-left: 4px solid #c5d5ea;
    }

    .navmenu-mobile ul ul li.open > ul { display: block; }

    .navmenu-mobile ul ul ul li a {
        display: flex;
        align-items: center;
        min-height: 44px;
        padding: 8px 18px 8px 44px;
        font-size: 0.875rem;
        font-weight: 400;
        color: #1a3668;
        text-decoration: none;
    }

    .navmenu-mobile ul ul ul li a:hover { background: #e2ebf5; }

    .navmenu-mobile li.open > ul { display: block; }

    /* Indicatore sottomenu (span iniettato da JS) */
    .navmenu-mobile li > a > span[tabindex] {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 28px;
        height: 28px;
        margin-left: auto;
        flex-shrink: 0;
        border-radius: 50%;
        background: rgba(0, 56, 130, 0.08);
        transition: transform 0.2s ease, background 0.15s ease;
    }

    .navmenu-mobile li.open > a > span[tabindex] {
        transform: rotate(90deg);
        background: rgba(0, 56, 130, 0.16);
    }

    .navmenu-mobile li > a > span[tabindex]:focus {
        outline: 2px solid #F5A623;
        outline-offset: 1px;
    }

    .navmenu-mobile .dropdown-toggle::after { display: none; }

    /* Frecce CSS per voci con figli (classe WordPress menu-item-has-children) */
    .navmenu-mobile li.menu-item-has-children > a::after {
        content: '';
        display: inline-block;
        width: 0;
        height: 0;
        border-left: 5px solid transparent;
        border-right: 5px solid transparent;
        border-top: 6px solid #003882;
        margin-left: auto;
        flex-shrink: 0;
        transition: transform 0.2s ease;
    }

    .navmenu-mobile li.menu-item-has-children.open > a::after {
        transform: rotate(180deg);
    }

    /* Intestazione unica (lvl2 senza fratelli): nascosta, aperta dal JS in automatico */
    .navmenu-mobile > li > ul > li:only-child > a {
        display: none !important;
    }
}


/* ── 7. RICERCA E SOCIAL MOBILI ───────────────────────────────────────────*/

.drawer-search {
    padding: 14px 18px 0;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
    background: #f4f6f9;
}

#nav-mobile-panel .drawer-search .cerca {
    display: flex !important;
    align-items: stretch !important;
    width: 100% !important;
    float: none !important;
    margin: 0 !important;
}

#nav-mobile-panel .drawer-search form.Form,
#nav-mobile-panel .drawer-search form {
    display: flex !important;
    align-items: stretch !important;
    width: 100% !important;
    float: none !important;
    gap: 0 !important;
    border: 1px solid rgba(255,255,255,0.5) !important;
    border-radius: 4px !important;
    background: rgba(255,255,255,0.15) !important;
    overflow: hidden !important;
}

#nav-mobile-panel .drawer-search .cerca input,
#nav-mobile-panel .drawer-search input[type="text"] {
    flex: 1 !important;
    height: 40px !important;
    padding: 0 12px !important;
    font-size: 0.9rem !important;
    color: #1a3668 !important;
    background: #ffffff !important;
    border: 1px solid #c8d4e0 !important;
    border-right: none !important;
    border-radius: 4px 0 0 4px !important;
    outline: none !important;
    box-shadow: none !important;
    float: none !important;
    width: auto !important;
}

#nav-mobile-panel .drawer-search .cerca input::placeholder {
    color: #94a3b8 !important;
    opacity: 1 !important;
}

#nav-mobile-panel .drawer-search .btn-cerca {
    flex-shrink: 0 !important;
    width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #003882 !important;
    border: none !important;
    border-radius: 0 4px 4px 0 !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    float: none !important;
    transition: background 0.15s !important;
}

#nav-mobile-panel .drawer-search .btn-cerca:hover {
    background: #002060 !important;
}

#nav-mobile-panel .drawer-search .btn-cerca svg.icon {
    width: 18px !important;
    height: 18px !important;
    fill: #ffffff !important;
}

#nav-mobile-panel .drawer-social {
    padding: 10px 18px 16px;
    background: #f4f6f9;
}

#nav-mobile-panel .socialmobile {
    margin: 8px 0 0 0 !important;
}

#nav-mobile-panel .socialmobile .small {
    color: #555 !important;
    font-size: 0.8rem !important;
}

#nav-mobile-panel .socialmobile li:first-child {
    width: auto !important;
    margin-bottom: 0 !important;
    margin-right: 8px !important;
}

#nav-mobile-panel .socialmobile a svg.icon {
    fill: #003882 !important;
    width: 22px !important;
    height: 22px !important;
}

#nav-mobile-panel .socialmobile a:hover svg.icon {
    fill: #0052cc !important;
}

.drawer-social {
    padding: 10px 18px 14px;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
    color: #1a3668 !important;
    background: #ffffff;
}

.drawer-social:empty,
.drawer-social:not(:has(.social-icon)) {
    display: none;
}

.drawer-social .list-inline .small,
.drawer-social .small {
    color: #555 !important;
    font-size: 0.8rem;
    vertical-align: middle;
}

.drawer-social .social {
    margin: 0;
    padding: 4px 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

.drawer-social .social-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width:  44px;
    height: 44px;
    border-radius: 50%;
    color: #003882;
    transition: background 0.15s ease;
}

.drawer-social .social-icon .icon,
.drawer-social .social-icon svg {
    width: 24px;
    height: 24px;
    fill: #003882;
}

.drawer-social .social-icon:hover {
    background: rgba(0, 56, 130, 0.1);
}


/* ── 8. BODY LOCK ─────────────────────────────────────────────────────────*/

body.menu-mobile-open { overflow: hidden; }

@media (min-width: 992px) {
    body.menu-mobile-open { overflow: auto; }
}


/* ── 9. NAVBAR DESKTOP ────────────────────────────────────────────────────*/

@media (min-width: 992px) {

    .navbar-collapsable-desktop {
        display: flex !important;
        position: static;
        width: 100%;
        height: auto;
        overflow: visible;
        background: transparent;
        box-shadow: none;
        transform: none;
        transition: none;
        flex: 1;
    }

    .navbar-collapsable-desktop .close-div { display: block; }
    .navbar-collapsable-desktop .menu-wrapper { width: 100%; }
}


/* ── 10. RESET SISTEMA PRECEDENTE ─────────────────────────────────────────*/

.cbp-spmenu { display: none !important; }

.push-body-toright .push_container {
    left: 0 !important;
    transform: none !important;
}

.push-body-toright #mainheader .entesup,
.push-body-toright #mainheader .areariservata,
.push-body-toright #mainheader .comune,
.push-body-toright #mainheader .header-social,
.push-body-toright #mainheader .header-cerca,
.push-body-toright .sub_nav,
.push-body-toright #main_container,
.push-body-toright footer {
    opacity: 1 !important;
    visibility: visible !important;
}

.push-body-toright .body_wrapper { background: initial !important; }
.push-body-toright .body_wrapper .preheader { background: initial !important; }

.navbar-toggle.menu-active .icon-bar,
.navbar-toggle.menu-active .icon-bar1,
.navbar-toggle.menu-active .icon-bar2,
.navbar-toggle.menu-active .icon-bar3 { all: unset; }

.navbar-toggle.menu-btn.jPushMenuBtn { display: none !important; }

/* Offset admin bar WordPress */
.admin-bar #nav-mobile-panel {
    top: 46px;
    height: calc(100% - 46px);
}

@media (min-width: 783px) {
    .admin-bar #nav-mobile-panel {
        top: 32px;
        height: calc(100% - 32px);
    }
}


/* ── 11. LAYOUT HEADER MOBILE ─────────────────────────────────────────────*/

@media (max-width: 991px),
       (min-width: 992px) and (max-width: 1440px) and (max-height: 760px) {

    .hamburger-col {
        flex-shrink: 0;
        padding-right: 8px;
        padding-left: 12px;
    }

    #mainheader .row.header-tablet {
        display: flex !important;
        flex-wrap: nowrap;
        align-items: center !important;
        height: 86px;
        overflow: hidden;
    }

    #mainheader .container.header .comune {
        flex: 1 1 0;
        min-width: 0;
        max-width: none !important;
        padding-left: 4px;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    #mainheader .container.header {
        padding-left: 8px;
        padding-right: 8px;
    }

    .hamburger-col {
        padding-left: 4px;
        padding-right: 6px;
    }

    #mainheader .comune .logoimg {
        margin-top: 0 !important;
        display: flex;
        align-items: center;
        flex-shrink: 0;
        width: auto;
    }

    #mainheader .comune .logoimg a {
        display: flex;
        align-items: center;
    }

    #mainheader .comune .logoimg img {
        max-height: 54px !important;
        width: auto !important;
        max-width: 58px !important;
        object-fit: contain;
    }

    #mainheader .comune .logotxt {
        flex: 1 1 0;
        min-width: 0;
        margin-left: 0 !important;
        height: auto !important;
    }

    #mainheader .comune .logotxt h1 {
        margin: 0;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        line-clamp: 3;
        -webkit-box-orient: vertical;
    }

    #mainheader .comune .logotxt h1 a {
        font-size: 0.9rem !important;
        line-height: 1.3;
    }

    #mainheader .comune .logoprint { display: none !important; }
}

/* Header collassato (sticky) */
@media (max-width: 991px),
       (min-width: 992px) and (max-width: 1440px) and (max-height: 760px) {

    #mainheader.ridotto .row.header-tablet { height: 60px; }

    #mainheader.ridotto .comune .logoimg { margin-top: 0 !important; }

    #mainheader.ridotto .comune .logoimg img {
        max-height: 40px !important;
        max-width: 44px !important;
    }

    #mainheader.ridotto .comune .logotxt h1 a {
        font-size: 0.85rem !important;
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }
}


/* ── 12. FIX COLORE NAVBAR DESKTOP ───────────────────────────────────────*/

#sub_nav .navbar-nav .nav-link,
#sub_nav .navbar-nav .nav-link:focus,
#sub_nav .navbar-nav .nav-link:hover {
    color: #ffffff !important;
}

#sub_nav .navbar-nav .nav-link.active,
#sub_nav .navbar-nav .nav-item.active > .nav-link {
    color: #ffffff !important;
    opacity: 0.85;
}


/* ── 13. OVERRIDE EREDITARIETÀ COLORI NEL DRAWER ─────────────────────────
   L'header principale imposta color:#fff su tutti i discendenti.
   Il drawer è figlio dell'header → necessario ripristinare i colori.
   ─────────────────────────────────────────────────────────────────────────*/

#nav-mobile-panel .social a svg.icon,
#nav-mobile-panel .social-icon svg.icon,
#nav-mobile-panel .social-icon .icon {
    fill: #003882 !important;
    width: 24px !important;
    height: 24px !important;
}

#nav-mobile-panel .social a:hover svg.icon {
    fill: #00266a !important;
}

#nav-mobile-panel .social .list-inline-item.small {
    color: #555555 !important;
    font-size: 0.8rem !important;
}

#nav-mobile-panel .close-menu-btn svg.icon,
#nav-mobile-panel .close-menu-btn .icon {
    fill: currentColor !important;
}