/**
 * header.css — BEM: header, header__*, header--modifier
 */

.header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background-color: var(--color-bg-primary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.85rem;
}

.header__logo {
  flex-shrink: 0;
  display: inline-flex;
}

.header__logo img {
  width: 130px;
  height: auto;
}

/* ── Desktop nav (hidden on mobile) ───────────────────────────────────── */
.header__nav {
  display: none;
}

.header__nav-list {
  display: flex;
  align-items: center;
  gap: 1.75rem;
}

.header__nav-item {
  position: relative;
}

.header__nav-item--mobile-only {
  display: none;
}

.header__nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--color-white);
  font-weight: var(--font-weight-medium);
  font-size: 0.9375rem;
  padding: 0.5rem 0.1rem;
  transition: color var(--transition-base);
}

.header__nav-link:hover,
.header__nav-link:focus-visible,
.header__nav-link--active {
  color: var(--color-heading-gold);
}

.header__nav-link--toggle {
  background: none;
  border: none;
}

.header__nav-arrow {
  transition: transform var(--transition-base);
}

/* ── Dropdown ──────────────────────────────────────────────────────────── */
.header__dropdown {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  min-width: 220px;
  background: var(--color-bg-dark);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 0.5rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-base), transform var(--transition-base), visibility var(--transition-base);
}

.header__nav-item--has-children:hover .header__dropdown,
.header__nav-item--has-children:focus-within .header__dropdown,
.header__nav-link--toggle[aria-expanded="true"] + .header__dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.header__nav-item--has-children:hover .header__nav-arrow,
.header__nav-item--has-children:focus-within .header__nav-arrow,
.header__nav-link--toggle[aria-expanded="true"] .header__nav-arrow {
  transform: rotate(180deg);
}

.header__dropdown-link {
  display: block;
  padding: 0.6rem 0.85rem;
  border-radius: 4px;
  color: var(--color-text-body);
  font-size: 0.9rem;
  white-space: nowrap;
  transition: background var(--transition-base), color var(--transition-base);
}

.header__dropdown-link:hover,
.header__dropdown-link:focus-visible {
  background: rgba(255, 179, 117, 0.1);
  color: var(--color-heading-gold);
}

/* ── Actions (right side) ─────────────────────────────────────────────── */
.header__actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.header__flag {
  display: none;
  font-size: 1.35rem;
  line-height: 1;
}

.header__login {
  display: none;
  padding: 0.6rem 1.1rem;
  font-size: 0.875rem;
}

.header__cta {
  display: none;
  padding: 0.6rem 1.1rem;
  font-size: 0.8125rem;
}

/* ── Burger (mobile) ───────────────────────────────────────────────────── */
.header__burger {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 32px;
  height: 32px;
  padding: 4px;
  order: 3;
}

.header__burger-line {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--color-white);
  border-radius: 2px;
  transition: transform var(--transition-base), opacity var(--transition-base);
}

.header__burger[aria-expanded="true"] .header__burger-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.header__burger[aria-expanded="true"] .header__burger-line:nth-child(2) {
  opacity: 0;
}

.header__burger[aria-expanded="true"] .header__burger-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ── Mobile menu panel (flat list, no dropdowns) ──────────────────────── */
.header__mobile-menu {
  display: grid;
  grid-template-rows: 0fr;
  background: var(--color-bg-primary);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  transition: grid-template-rows var(--transition-base);
}

.header__mobile-menu[data-open="true"] {
  grid-template-rows: 1fr;
}

.header__mobile-list {
  overflow: hidden;
  min-height: 0;
  padding-inline: 1.25rem;
}

.header__mobile-menu[data-open="true"] .header__mobile-list {
  padding-block: 0.75rem;
}

.header__mobile-link {
  display: block;
  padding: 0.75rem 0.25rem;
  color: var(--color-white);
  font-weight: var(--font-weight-medium);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.header__mobile-link--sub {
  padding-left: 1.25rem;
  color: var(--color-text-body);
  font-size: 0.9rem;
}

.header__mobile-link:hover,
.header__mobile-link:focus-visible {
  color: var(--color-heading-gold);
}

/* ── Fixed bottom action bar (mobile only — Accedi / Registrazione) ──────
   Always visible at the bottom of the viewport on mobile, per spec: these
   are the primary conversion actions and should stay reachable without
   opening the burger menu. Hidden ≥768px, where they live in the header. */
.mobile-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-header);
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  background: var(--color-bg-dark);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.25);
}

.mobile-bottom-bar__login,
.mobile-bottom-bar__cta {
  flex: 1 1 0;
}

/* ── Breakpoints ───────────────────────────────────────────────────────── */
@media (min-width: 768px) {
  .mobile-bottom-bar {
    display: none;
  }

  .header__nav {
    display: block;
    order: 2;
    min-width: 0;
  }

  .header__nav-list {
    gap: 1rem;
    flex-wrap: wrap;
  }

  .header__nav-link {
    font-size: 0.85rem;
  }

  .header__nav-item--mobile-only {
    display: none;
  }

  .header__flag {
    display: inline-flex;
  }

  .header__login,
  .header__cta {
    display: inline-flex;
    padding: 0.55rem 0.85rem;
    font-size: 0.8125rem;
  }

  .header__burger,
  .header__mobile-menu {
    display: none;
  }

  .header__logo img {
    width: 140px;
    height: auto;
  }

  .header__actions {
    order: 3;
  }
}

@media (min-width: 1024px) {
  .header__nav-list {
    gap: 1.75rem;
  }

  .header__nav-link {
    font-size: 0.9375rem;
  }

  .header__login,
  .header__cta {
    padding: 0.6rem 1.1rem;
  }

  .header__login {
    font-size: 0.875rem;
  }

  .header__cta {
    font-size: 0.8125rem;
  }

  .header__logo img {
    width: 180px;
  }
}
