/**
 * Modern Responsive Header
 * Mobile-First Approach
 */

/* ============================================
   HEADER BASE STYLES
   ============================================ */

.site-header {
  background: linear-gradient(
    135deg,
    var(--neutral-gray-900) 0%,
    var(--neutral-gray-800) 100%
  );
  padding: var(--space-4) 0;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  position: relative;
}

/* ============================================
   LOGO / BRANDING
   ============================================ */

.site-branding {
  flex-shrink: 0;
  z-index: 1001;
}

.site-title {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 700;
  line-height: 1.2;
}

.site-title a {
  color: var(--neutral-white);
  text-decoration: none;
  transition: opacity 0.3s ease;
}

.site-title a:hover {
  opacity: 0.8;
}

.site-description {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--neutral-gray-300);
  font-weight: 400;
  font-style: italic;
}

/* ============================================
   NAVIGATION - MOBILE FIRST
   ============================================ */

.main-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    135deg,
    rgba(15, 23, 42, 0.98) 0%,
    rgba(30, 41, 59, 0.98) 100%
  );
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 100px 24px 40px;
  z-index: 999;

  /* Hidden by default on mobile */
  opacity: 0;
  visibility: hidden;
  transform: translateY(-20px);
  transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;

  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Active state (menu aperto su mobile) */
.main-nav.is-active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Lista menu */
.nav-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 400px;
  margin: 0 auto;
}

.nav-list li {
  margin: 0;
  opacity: 0;
  animation: slideInNav 0.4s ease forwards;
}

.main-nav.is-active .nav-list li:nth-child(1) {
  animation-delay: 0.1s;
}
.main-nav.is-active .nav-list li:nth-child(2) {
  animation-delay: 0.15s;
}
.main-nav.is-active .nav-list li:nth-child(3) {
  animation-delay: 0.2s;
}
.main-nav.is-active .nav-list li:nth-child(4) {
  animation-delay: 0.25s;
}
.main-nav.is-active .nav-list li:nth-child(5) {
  animation-delay: 0.3s;
}
.main-nav.is-active .nav-list li:nth-child(6) {
  animation-delay: 0.35s;
}

@keyframes slideInNav {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.nav-list a {
  display: block;
  padding: 16px 24px;
  font-size: 18px;
  font-weight: 600;
  color: var(--neutral-white);
  text-decoration: none;
  text-align: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.12);
  transition: all 0.3s ease;
  letter-spacing: 0.3px;
}

.nav-list a:hover,
.nav-list a:focus {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateX(4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.nav-list a:active {
  transform: scale(0.98);
}

.nav-list .current-menu-item > a,
.nav-list .current_page_item > a {
  background: var(--primary-blue);
  border-color: var(--primary-blue);
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4);
}

/* ============================================
   HEADER ACTIONS (Search & Menu Toggle)
   ============================================ */

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  z-index: 1001;
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--neutral-white);
  cursor: pointer;
  transition: all 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.btn-icon:active {
  transform: scale(0.95);
}

/* Menu Toggle (Hamburger) */
.menu-toggle {
  display: flex;
}

.menu-icon {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 22px;
  height: 16px;
}

.menu-icon .line {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--neutral-white);
  border-radius: 2px;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Animazione hamburger → X */
.menu-toggle.is-active .menu-icon .line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.menu-toggle.is-active .menu-icon .line:nth-child(2) {
  opacity: 0;
  transform: translateX(-10px);
}

.menu-toggle.is-active .menu-icon .line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ============================================
   BODY SCROLL LOCK quando menu aperto
   ============================================ */

body.menu-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100vh;
}

/* iOS Safari fix */
@supports (-webkit-touch-callout: none) {
  body.menu-open {
    position: fixed;
    overflow: hidden;
  }
}

/* ============================================
   TABLET BREAKPOINT (768px+)
   ============================================ */

@media (min-width: 768px) {
  .site-header {
    padding: var(--space-5) 0;
  }

  .site-title {
    font-size: var(--text-2xl);
  }

  .site-description {
    font-size: var(--text-sm);
  }

  .btn-icon {
    width: 48px;
    height: 48px;
  }
}

/* ============================================
   DESKTOP BREAKPOINT (1024px+)
   ============================================ */

@media (min-width: 1024px) {
  /* Navigation diventa orizzontale */
  .main-nav {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    background: transparent;
    backdrop-filter: none;
    padding: 0;
    overflow: visible;
    flex: 1;
    display: flex;
    justify-content: center;
  }

  .nav-list {
    flex-direction: row;
    gap: 8px;
    max-width: none;
    margin: 0;
  }

  .nav-list li {
    opacity: 1;
    animation: none;
  }

  .nav-list a {
    padding: 10px 20px;
    font-size: 15px;
    font-weight: 500;
    background: transparent;
    border: 1px solid transparent;
    text-align: left;
  }

  .nav-list a:hover,
  .nav-list a:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
  }

  .nav-list .current-menu-item > a,
  .nav-list .current_page_item > a {
    background: var(--primary-blue);
    border-color: var(--primary-blue);
  }

  /* Nascondi hamburger su desktop */
  .menu-toggle {
    display: none;
  }

  body.menu-open {
    overflow: auto;
    position: static;
    width: auto;
    height: auto;
  }
}

/* ============================================
   LARGE DESKTOP (1280px+)
   ============================================ */

@media (min-width: 1280px) {
  .nav-list {
    gap: 12px;
  }

  .nav-list a {
    padding: 12px 24px;
    font-size: 16px;
  }
}
