/* =============================================
   header.css — Header / Navigation Component
   Riparazioni Ricci — Component Library v7.0

   Dependencies: _tokens.css (design tokens)
   ============================================= */

/* ========== HEADER ========== */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: var(--header-height, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(16px, 4vw, 48px);
  background: var(--surface-glass);
  backdrop-filter: blur(var(--glass-blur, 16px)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--glass-blur, 16px)) saturate(180%);
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  transition: height 300ms ease,
              transform 300ms ease,
              background-color 300ms ease,
              box-shadow 300ms ease;
  will-change: transform;
}

/* Compact state (scroll > 50px) */
.header.is-compact {
  height: 52px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 1px 3px var(--surface-glass-border), 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* Hidden state (scrolling down) */
.header.is-hidden {
  transform: translateY(-100%);
}

/* ========== LOGO ========== */
.header-logo {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--color-foreground);
  text-decoration: none;
  flex-shrink: 0;
  transition: font-size 300ms ease;
}

.header.is-compact .header-logo {
  font-size: 16px;
}

/* ========== NAV ========== */
.header-nav {
  display: flex;
  align-items: center;
  gap: 32px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.header-nav a {
  position: relative;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-muted);
  text-decoration: none;
  padding: 4px 0;
  transition: color 200ms ease;
}

.header-nav a:hover {
  color: var(--color-foreground);
}

/* Underline */
.header-nav a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--color-primary);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 200ms ease;
}

.header-nav a:hover::after {
  transform: scaleX(1);
}

/* Active link */
.header-nav a.is-active {
  color: var(--color-primary);
  font-weight: 600;
}

.header-nav a.is-active::after {
  transform: scaleX(1);
}

/* ========== CTA BUTTON ========== */
.header-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-full, 9999px);
  padding: 8px 20px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 200ms ease,
              transform 200ms ease,
              box-shadow 200ms ease;
}

.header-cta:hover {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 0 20px rgba(var(--color-primary-rgb), 0.4), 0 4px 12px rgba(var(--color-primary-rgb), 0.25);
}

.header-cta svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* Phone icon shake on hover */
@keyframes phone-shake {
  0%, 100% { transform: rotate(0deg); }
  15% { transform: rotate(12deg); }
  30% { transform: rotate(-10deg); }
  45% { transform: rotate(8deg); }
  60% { transform: rotate(-6deg); }
  75% { transform: rotate(4deg); }
  90% { transform: rotate(-2deg); }
}

.header-cta:hover .cta-icon {
  animation: phone-shake 0.6s ease;
}

/* Icon-only CTA for tablet */
.header-cta-icon {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 200ms ease,
              transform 200ms ease,
              box-shadow 200ms ease;
}

.header-cta-icon:hover {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 0 20px rgba(var(--color-primary-rgb), 0.4), 0 4px 12px rgba(var(--color-primary-rgb), 0.25);
}

.header-cta-icon:hover .cta-icon {
  animation: phone-shake 0.6s ease;
}

.header-cta-icon svg {
  width: 18px;
  height: 18px;
}

/* ========== HAMBURGER ========== */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 1002;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--color-foreground);
  border-radius: 2px;
  transition: transform 300ms ease, opacity 300ms ease;
}

.hamburger span:nth-child(1) {
  transform: translateY(-6px);
}

.hamburger span:nth-child(3) {
  transform: translateY(6px);
}

/* Hamburger -> X morph */
.hamburger.is-open span:nth-child(1) {
  transform: translateY(0) rotate(45deg);
}

.hamburger.is-open span:nth-child(2) {
  opacity: 0;
}

.hamburger.is-open span:nth-child(3) {
  transform: translateY(0) rotate(-45deg);
}

/* ========== MOBILE OVERLAY ========== */
.mobile-nav {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1001;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease;
}

.mobile-nav.is-open {
  display: flex;
  opacity: 1;
  pointer-events: auto;
}

.mobile-nav a {
  font-size: 20px;
  font-weight: 500;
  color: var(--color-muted);
  text-decoration: none;
  opacity: 0;
  transform: translateX(-20px);
  transition: color 200ms ease;
}

.mobile-nav a.is-active {
  color: var(--color-primary);
  font-weight: 600;
}

.mobile-nav a:hover {
  color: var(--color-foreground);
}

.mobile-nav.is-open a {
  animation: mobile-link-in 400ms ease forwards;
}

.mobile-nav.is-open a:nth-child(1) { animation-delay: 0ms; }
.mobile-nav.is-open a:nth-child(2) { animation-delay: 80ms; }
.mobile-nav.is-open a:nth-child(3) { animation-delay: 160ms; }
.mobile-nav.is-open a:nth-child(4) { animation-delay: 240ms; }
.mobile-nav.is-open a:nth-child(5) { animation-delay: 320ms; }

@keyframes mobile-link-in {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.mobile-nav .mobile-cta {
  position: absolute;
  bottom: 48px;
  left: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-lg, 12px);
  padding: 16px 24px;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  opacity: 0;
  animation: mobile-link-in 400ms ease forwards;
  animation-delay: 400ms;
  transition: background-color 200ms ease;
}

.mobile-nav .mobile-cta:hover {
  background: var(--color-primary-dark);
}

.mobile-nav .mobile-cta svg {
  width: 18px;
  height: 18px;
}

/* ========== TABLET (768-1023) ========== */
@media (min-width: 768px) and (max-width: 1023px) {
  .header-nav {
    gap: 24px;
  }

  .header-nav a {
    font-size: 13px;
  }

  .header-cta {
    display: none;
  }

  .header-cta-icon {
    display: inline-flex;
  }
}

/* ========== MOBILE (<768) ========== */
@media (max-width: 767px) {
  .header-nav {
    display: none;
  }

  .header-cta {
    display: none;
  }

  .header-cta-icon {
    display: none;
  }

  .hamburger {
    display: flex;
  }
}
