/* ============================================================
   HEADER — struttura base
   ============================================================ */

.header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    transform: translateY(0);
    transition: transform 0.3s ease, background-color 1s ease, backdrop-filter 0.3s ease, -webkit-backdrop-filter 0.3s ease, box-shadow 0.3s ease;
    background-color: transparent;
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0);
}

.header.with-bg {
    background-color: var(--background-header);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.header.hidden {
    transform: translateY(calc(-100% - 8px));
}

.header-container {
    margin: 0 var(--lateral-margin);
    display: flex;
    align-items: center;
    height: var(--navbar-height);
    justify-content: space-between;
}

/* ============================================================
   LOGO
   ============================================================ */

.logo-img {
    width: 98px;
    height: 70px;
    margin-right: auto;
    transition: opacity 0.2s, transform 0.2s;
    display: inline-block;
}

.logo-mask {
    background-color: var(--primary-color);
    -webkit-mask-image: url('/images/icons/logo-nero.svg');
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    -webkit-mask-size: contain;
    mask-image: url('/images/icons/logo-nero.svg');
    mask-repeat: no-repeat;
    mask-position: center;
    mask-size: contain;
}

.logo-img:hover {
    transform: translateY(-1px);
}

/* ============================================================
   NAV DESKTOP
   ============================================================ */

.nav {
    display: flex;
    gap: 30px;
    margin: 0 auto;
}

.nav a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    transition: color 0.2s, transform 0.2s;
    font-size: 1.2rem;
}

.nav a:hover {
    transform: translateY(-1px);
}

.nav a:hover,
.nav a.active {
    color: var(--primary-color);
}

/* ============================================================
   HEADER ACTIONS (desktop)
   ============================================================ */

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* ============================================================
   HAMBURGER BUTTON — icona SVG, niente span
   ============================================================ */

.hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    color: var(--text-color);
    flex-shrink: 0;
    transition: color 0.2s;
}

.hamburger:hover {
    color: var(--primary-color);
}

.hamburger svg {
    display: block;
}

/* ============================================================
   MENU MOBILE FULL-PAGE (sale dal basso)
   ============================================================ */

.mobile-menu {
    position: fixed;
    inset: 0;
    z-index: 99;
    background-color: var(--surface);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;

    /* Nascosto: traslato completamente fuori dal basso */
    transform: translateY(100%);
    /* Transizione sempre attiva per animare sia l'apertura che la chiusura */
    transition: transform 0.38s cubic-bezier(0.4, 0, 0.2, 1);

    /* Solo su mobile */
    display: none;
}

.mobile-menu.open {
    transform: translateY(0);
}

/* ============================================================
   NAV INTERNA AL MENU MOBILE
   ============================================================ */

.mobile-menu-nav {
    display: flex;
    flex-direction: column;
    padding: 0 1.5rem 32px;
}

.mobile-menu-nav a {
    text-decoration: none;
    color: var(--text-color);
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 600;
    font-size: clamp(2rem, 8vw, 3.5rem);
    line-height: 1;
    padding: 20px 0;
    border-bottom: 2px solid var(--background-opaque);
    transition: color 0.2s, padding-left 0.2s;
    display: block;
}

.mobile-menu-nav a:first-child {
    border-top: 2px solid var(--background-opaque);
}

.mobile-menu-nav a:hover,
.mobile-menu-nav a.active {
    color: var(--primary-color);
    padding-left: 12px;
}

/* ============================================================
   FOOTER DEL MENU MOBILE (bottone contattaci)
   ============================================================ */

.mobile-menu-footer {
    padding: 24px 1.5rem 40px;
    border-top: 2px solid var(--background-opaque);
}

.mobile-menu-footer .button {
    display: block;
    width: 100%;
    text-align: center;
}

/* ============================================================
   MEDIA QUERIES
   ============================================================ */

/* —— Desktop grande (> 1280px) ————————————————————————————— */
@media (min-width: 1280px) {}

/* —— Desktop medio (1024px – 1279px) ————————————————————— */
@media (min-width: 1024px) and (max-width: 1279px) {}

/* —— Tablet (768px – 1023px): pannello laterale 50% ————————— */
@media (min-width: 768px) and (max-width: 1023px) {
    .mobile-menu {
        left: auto;
        right: 0;
        top: 0;
        bottom: 0;
        width: 50%;
        box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
        border-left: 2px solid var(--background-opaque);
        clip-path: inset(0 0 0 100%);
        transition: clip-path 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        transform: none;
    }

    .mobile-menu.open {
        clip-path: inset(0 0 0 0%);
        transition: clip-path 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .mobile-menu-nav a {
        font-size: clamp(1.2rem, 3vw, 1.6rem);
        padding: 16px 0;
    }
}


/* —— Mobile (< 900px): attiva hamburger + menu full-page ——— */
@media (max-width: 900px) {
    .header-container {
        margin: 0 1.5rem;
    }

    /* Nasconde nav e bottone desktop */
    .nav-desktop,
    .header-actions {
        display: none;
    }

    /* Mostra hamburger */
    .hamburger {
        display: flex;
    }

    /* Abilita il menu mobile (di default display:none) */
    .mobile-menu {
        display: flex;
    }
}

/* —— Mobile piccolo (< 480px) ————————————————————————————— */
@media (max-width: 480px) {}

/* —— Mobile minimo (< 360px) —————————————————————————————— */
@media (max-width: 360px) {}

/* Touch / tap highlight & focus handling for mobile interaction
   - disable native tap highlight which creates colored rectangles
   - keep keyboard focus-visible outlines intact for accessibility
*/
.hamburger,
.mobile-menu a,
.mobile-menu .button,
.mobile-menu .button * {
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* Hide focus ring for pointer/touch interactions but preserve for keyboard
   users via :focus-visible (only remove when element is focused but not
   focus-visible). */
.hamburger:focus:not(:focus-visible),
.mobile-menu a:focus:not(:focus-visible),
.mobile-menu .button:focus:not(:focus-visible) {
    outline: none !important;
    box-shadow: none !important;
}