/**
 * Ensoul Navigation
 * Floating Navigation Bar - Wrapper separato
 * v2.5.9 - Supporto menu a 3 livelli + Accessibilità WCAG 2.1 + Posizione top/bottom + Logo blend mode dinamico
 */

/* ==========================================================================
   NAVIGAZIONE HEADER ORIGINALE - Nascosta
   ========================================================================== */

header.wp-block-template-part .wp-block-navigation {
    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;
}

/* ==========================================================================
   LOGO HEADER ORIGINALE - Fade out quando scrolli
   ========================================================================== */

header.wp-block-template-part .wp-block-site-logo {
    transition: opacity 0.3s ease;
}

body.hm-scrolled header.wp-block-template-part .wp-block-site-logo {
    opacity: 0;
    pointer-events: none;
}

/* ==========================================================================
   NAV WRAPPER - Elemento separato dall'header
   ========================================================================== */

.hm-floating-nav {
    position: fixed;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 12px 24px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15),
                0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.6);
    max-width: calc(100vw - 30px);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: background-color 0.3s ease, padding 0.3s ease;
}

/* Quando espanso */
.hm-floating-nav.hm-expanded {
    background: rgba(255, 255, 255, 1);
    padding: 12px 32px 12px 32px;
}

/* Admin bar */
.admin-bar .hm-floating-nav {
    bottom: 15px;
}

.admin-bar .hm-floating-nav.hm-position-top {
    bottom: auto;
    top: 47px;
}

@media (max-width: 782px) {
    .admin-bar .hm-floating-nav.hm-position-top {
        top: 62px;
    }
}

/* ==========================================================================
   POSIZIONE TOP - Menu in alto con sottovoci verso il basso
   ========================================================================== */

.hm-floating-nav.hm-position-top {
    bottom: auto;
    top: 15px;
}

/* Pannello sottovoci per posizione top */
.hm-floating-nav.hm-position-top .hm-submenu-panel {
    margin-bottom: 0;
    margin-top: 8px;
    padding: 10px 8px 0 8px;
    border-bottom: none;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

/* Freccia ruotata per posizione top */
.hm-floating-nav.hm-position-top .hm-nav-menu > li.hm-active .hm-arrow {
    transform: rotate(0deg);
}

.hm-floating-nav.hm-position-top .hm-nav-menu .hm-arrow {
    transform: rotate(180deg);
}

/* Animazione per posizione top (verso il basso) */
.hm-floating-nav.hm-position-top .hm-submenu-panel {
    animation: hm-fade-in-down 0.2s ease-out;
}

@keyframes hm-fade-in-down {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Body padding per posizione top */
body.hm-nav-top {
    padding-top: 90px;
    padding-bottom: 0;
}

/* ==========================================================================
   LOGO NELLA FLOATING NAV
   ========================================================================== */

.hm-floating-nav .hm-nav-logo {
    max-width: 0;
    height: 0;
    opacity: 0;
    overflow: hidden;
    margin: 0;
    transition: all 0.3s ease;
}

.hm-floating-nav .hm-nav-logo img {
    max-height: 28px;
    width: auto;
    display: block;
}

.hm-floating-nav.hm-logo-visible .hm-nav-logo {
    max-width: 100px;
    height: auto;
    opacity: 1;
    margin-right: 16px;
}

/* ==========================================================================
   CONTENUTO PRINCIPALE (logo + menu)
   ========================================================================== */

.hm-nav-main {
    display: flex;
    align-items: center;
    justify-content: center;
}

.hm-nav-menu {
    display: flex;
    align-items: center;
    gap: 4px;
    list-style: none;
    margin: 0;
    padding: 0;
}

/* ==========================================================================
   VOCI MENU PRIMO LIVELLO
   ========================================================================== */

.hm-nav-menu > li {
    position: relative;
}

.hm-nav-menu > li > a,
.hm-nav-menu > li > button {
    font-family: 'Playfair Display', var(--wp--preset--font-family--playfair-display), serif;
    font-weight: 500;
    font-size: 0.95rem;
    color: #1d1d1f;
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 25px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background-color 0.2s ease;
    white-space: nowrap;
}

.hm-nav-menu > li > a:hover,
.hm-nav-menu > li > button:hover {
    background: rgba(0, 0, 0, 0.06);
}

.hm-nav-menu > li.hm-active > button {
    background: rgba(0, 0, 0, 0.08);
}

/* Freccia dropdown */
.hm-nav-menu .hm-arrow {
    width: 10px;
    height: 10px;
    opacity: 0.5;
    transition: transform 0.3s ease;
}

.hm-nav-menu > li.hm-active .hm-arrow {
    transform: rotate(180deg);
}

/* ==========================================================================
   PANNELLO SOTTOVOCI - Sopra le voci principali
   ========================================================================== */

.hm-submenu-panel {
    display: none;
    width: 100%;
    padding: 0 8px 10px 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    animation: hm-fade-in 0.2s ease-out;
}

@keyframes hm-fade-in {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hm-submenu-panel.hm-visible {
    display: block;
}

/* ==========================================================================
   CONTENUTO SUBMENU - Layout a colonne
   ========================================================================== */

.hm-submenu-content {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 24px;
    align-items: stretch;
    justify-content: center;
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Singola colonna */
.hm-submenu-column {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 120px;
    padding-right: 24px;
    border-right: 1px solid rgba(0, 0, 0, 0.1);
}

.hm-submenu-column:last-child {
    border-right: none;
    padding-right: 0;
}

/* Link semplice (secondo livello senza figli) */
.hm-submenu-column.hm-simple-link {
    min-width: auto;
}

.hm-direct-link {
    font-family: 'Inter', var(--wp--preset--font-family--inter), sans-serif;
    font-weight: 400;
    font-size: 1rem;
    color: #1d1d1f;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 10px;
    display: inline-block;
    transition: background-color 0.15s ease;
    white-space: nowrap;
}

.hm-direct-link:hover {
    background: rgba(0, 0, 0, 0.06);
}

/* ==========================================================================
   DESKTOP - Colonne con terzi livelli sempre visibili
   ========================================================================== */

/* Header colonna (secondo livello con figli) */
.hm-column-header {
    font-family: 'Inter', var(--wp--preset--font-family--inter), sans-serif;
    font-weight: 700;
    font-size: 1rem;
    color: #1d1d1f;
    padding: 6px 12px;
    margin-bottom: 2px;
}

/* Terzi livelli sempre visibili */
.hm-column-items {
    display: flex;
    flex-direction: column;
}

.hm-column-items a {
    font-family: 'Inter', var(--wp--preset--font-family--inter), sans-serif;
    font-weight: 400;
    font-size: 0.9375rem;
    color: #1d1d1f;
    text-decoration: none;
    padding: 5px 12px;
    border-radius: 8px;
    display: block;
    transition: background-color 0.15s ease;
    white-space: nowrap;
}

.hm-column-items a:hover {
    background: rgba(0, 0, 0, 0.06);
}

/* ==========================================================================
   MOBILE - Colonne con terzi livelli sempre visibili
   ========================================================================== */

@media (max-width: 782px) {
    
    .hm-floating-nav {
        left: 10px;
        right: 10px;
        transform: none;
        width: auto;
        max-width: none;
        padding: 10px 18px;
        border-radius: 20px;
    }
    
    .hm-floating-nav.hm-expanded {
        padding: 10px 22px;
    }
    
    .hm-floating-nav.hm-logo-visible .hm-nav-logo {
        max-width: 80px;
        margin-right: 12px;
    }
    
    .hm-floating-nav .hm-nav-logo img {
        max-height: 24px;
    }
    
    .hm-nav-menu > li > a,
    .hm-nav-menu > li > button {
        font-size: 0.85rem;
        padding: 6px 10px;
    }
    
    /* Layout submenu mobile */
    .hm-submenu-content {
        flex-direction: column;
        gap: 4px;
        align-items: stretch;
    }
    
    .hm-submenu-column {
        flex: 0 0 auto;
        min-width: 0;
        padding-right: 0;
        border-right: none;
    }
    
    /* Accordion su mobile */
    .hm-accordion-trigger {
        font-family: 'Inter', var(--wp--preset--font-family--inter), sans-serif;
        font-weight: 600;
        font-size: 1rem;
        color: #1d1d1f;
        text-decoration: none;
        padding: 8px 12px;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        background: transparent;
        border: none;
        cursor: pointer;
        transition: background-color 0.15s ease;
        width: 100%;
        text-align: left;
    }

    .hm-accordion-trigger:hover {
        background: rgba(0, 0, 0, 0.06);
    }

    .hm-accordion-trigger[aria-expanded="true"] {
        background: rgba(0, 0, 0, 0.04);
    }

    /* Freccia accordion */
    .hm-accordion-arrow {
        width: 10px;
        height: 10px;
        opacity: 0.5;
        transition: transform 0.2s ease;
        flex-shrink: 0;
    }

    .hm-accordion-trigger[aria-expanded="true"] .hm-accordion-arrow {
        transform: rotate(180deg);
    }

    /* Contenuto accordion */
    .hm-accordion-content {
        display: flex;
        flex-direction: column;
        padding-left: 12px;
        margin-top: 4px;
        animation: hm-slide-down 0.2s ease-out;
    }

    .hm-accordion-content[hidden] {
        display: none;
    }

    @keyframes hm-slide-down {
        from {
            opacity: 0;
            transform: translateY(-5px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .hm-accordion-content a {
        font-family: 'Inter', var(--wp--preset--font-family--inter), sans-serif;
        font-weight: 400;
        font-size: 0.9375rem;
        color: #1d1d1f;
        text-decoration: none;
        padding: 8px 12px;
        border-radius: 8px;
        display: block;
        transition: background-color 0.15s ease;
    }

    .hm-accordion-content a:hover {
        background: rgba(0, 0, 0, 0.06);
    }
    
    /* Link diretto su mobile */
    .hm-direct-link {
        font-size: 1rem;
        padding: 8px 12px;
        width: 100%;
        display: block;
    }
    
    /* Posizione top su mobile */
    .hm-floating-nav.hm-position-top {
        top: 10px;
        bottom: auto;
    }
}

/* ==========================================================================
   ACCESSIBILITÀ
   ========================================================================== */

.hm-nav-menu > li > a:focus-visible,
.hm-nav-menu > li > button:focus-visible,
.hm-direct-link:focus-visible,
.hm-accordion-trigger:focus-visible,
.hm-accordion-content a:focus-visible,
.hm-column-items a:focus-visible,
.hm-nav-logo a:focus-visible {
    outline: 2px solid #007aff;
    outline-offset: 2px;
}

/* Rispetta preferenze utente per animazioni ridotte */
@media (prefers-reduced-motion: reduce) {
    .hm-floating-nav,
    .hm-floating-nav .hm-nav-logo,
    .hm-nav-menu .hm-arrow,
    .hm-accordion-arrow,
    .hm-submenu-panel,
    .hm-accordion-content,
    .hm-nav-menu > li > a,
    .hm-nav-menu > li > button,
    .hm-direct-link,
    .hm-accordion-trigger,
    .hm-accordion-content a,
    .hm-column-items a,
    header.wp-block-template-part .wp-block-site-logo {
        transition: none !important;
        animation: none !important;
    }
}

/* ==========================================================================
   SAFE AREA (iPhone)
   ========================================================================== */

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .hm-floating-nav.hm-position-bottom {
        bottom: calc(15px + env(safe-area-inset-bottom));
    }
    
    .hm-floating-nav.hm-position-top {
        top: calc(15px + env(safe-area-inset-top));
    }
}

/* Spazio in fondo/alto pagina */
body {
    padding-bottom: 90px;
}

/* Override per posizione top via JS */
