/* ==========================================================================
   Main Navigation – main-menu-style.css
   Tema: hello-elementor-child | Nusef
   ========================================================================== */

/* ----------------------------------------
   Variabili locali menu
   ---------------------------------------- */
:root {
  --menu-bg: transparent;
  --menu-link-color: inherit;
  --menu-link-hover: var(--color-primary);
  --menu-dropdown-bg: #ffffff;
  --menu-dropdown-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  --menu-height: 70px;
  --menu-font-size: 0.95rem;
  --menu-font-weight: 700;
  --menu-transition: 0.25s ease;
  --menu-z-index: 1000;
  --hamburger-color: var(--color-text, #1a1a1a);
}

/* ----------------------------------------
   Header container fixed/sticky
   ---------------------------------------- */
#masthead {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 999;
  transition: all 0.35s ease;
}

#masthead.site-header--sticky {
  background: #ffffff !important;
  color: var(--color-text, #1a1a1a) !important;
  border-bottom: 1px solid #e2e2e282;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

#masthead.header-solid {
  background: #ffffff;
  position: sticky;
  border-bottom: 1px solid var(--color-border, #d1d1d6);
}

#masthead.header-transparent:not(.site-header--sticky) .main-navigation a {
  color: #ffffff;
}

#masthead.header-transparent:not(.site-header--sticky) .search-toggle,
#masthead.header-transparent:not(.site-header--sticky) .menu-toggle {
  color: #ffffff;
}

/* ----------------------------------------
   Header container layout
   ---------------------------------------- */
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--menu-height);
  padding: 0 20px;
  max-width: 1400px;
}

.site-header .site-branding {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.site-header .site-branding img {
  max-height: 50px;
  width: auto;
}

/* ----------------------------------------
   Wrapper navigazione
   ---------------------------------------- */
.main-navigation {
  display: flex;
  align-items: center;
  height: 100%;
  flex: 1;
  justify-content: flex-end;
  gap: 1.5rem;
}

.main-navigation ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  height: 100%;
}

.main-navigation li {
  height: 100%;
  position: relative;
}

.main-navigation a {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 0 1.2rem;
  height: 100%;
  color: var(--color-text, #1a1a1a);
  font-weight: var(--menu-font-weight);
  text-decoration: none;
  font-size: var(--font-size-md);
  transition: color var(--menu-transition);
  white-space: nowrap;
}

/* Sottolineatura animata desk */
.main-navigation a::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--color-secondary);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.35s ease;
}

.main-navigation a:hover {
  color: var(--color-secondary);
}

.main-navigation a:hover::after,
.main-navigation .current-menu-item > a::after,
.main-navigation .current-menu-ancestor > a::after {
  transform: scaleX(1);
}

/* ----------------------------------------
   Utilities
   ---------------------------------------- */
.header-utilities {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  height: 100%;
}

.search-toggle,
.menu-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  color: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border-radius: 4px;
  transition: background-color var(--menu-transition);
}

.search-toggle .dashicons {
  font-size: 22px;
  width: 22px;
  height: 22px;
}

.menu-toggle .hamburger-bar {
  display: block;
  width: 24px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: all 0.3s ease;
}

.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
}

/* Hamburger animation */
.menu-toggle[aria-expanded="true"] .hamburger-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] .hamburger-bar:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] .hamburger-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ----------------------------------------
   Mobile / Tablet (iPad and down)
   ---------------------------------------- */
@media (max-width: 1024px) {
  .menu-toggle {
    display: flex;
  }

  /* Nascondiamo il menu desktop su mobile */
  .main-navigation > ul {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: #ffffff;
    flex-direction: column;
    align-items: stretch;
    height: auto;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    box-shadow: 0 15px 30px rgba(0,0,0,0.1);
    border-top: 1px solid #eeeeee;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .main-navigation ul.menu--open {
    max-height: 85vh;
    opacity: 1;
    visibility: visible;
    padding: 1rem 0;
  }

  .main-navigation li {
    width: 100%;
    height: auto;
    border-bottom: 1px solid #f5f5f5;
  }

  .main-navigation a {
    color: var(--color-text, #1a1a1a) !important;
    width: 100%;
    padding: 1.2rem 1.5rem;
    height: auto;
    border-bottom: none;
  }

  .main-navigation a::after {
    display: none;
  }

  .main-navigation .current-menu-item > a {
    background-color: #f9f9f9;
    color: var(--color-primary) !important;
  }

  body.menu-is-open::after {
    content: "";
    position: fixed;
    inset: var(--menu-height) 0 0 0;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(2px);
    z-index: 998;
  }

  /* Force white navbar when mobile menu is open (even on transparent headers) */
  body.menu-is-open #masthead {
    background: #ffffff !important;
  }

  body.menu-is-open #masthead .menu-toggle,
  body.menu-is-open #masthead .search-toggle {
    color: var(--color-text, #1a1a1a) !important;
  }
}

/* ----------------------------------------
   Drop-down submenu (Desktop)
   ---------------------------------------- */
.main-navigation ul ul {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  background: var(--menu-dropdown-bg);
  box-shadow: var(--menu-dropdown-shadow);
  padding: 0.5rem 0;
  flex-direction: column;
  height: auto;
}

.main-navigation li:hover > ul {
  display: flex;
}

.main-navigation ul ul a {
  height: auto;
  padding: 0.6rem 1.5rem;
  border-bottom: none;
}

/* Accessibilità */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  z-index: 9999;
}
.skip-link:focus {
  top: 0;
}
