/* ============================================
   Header — Sticky Nav, Mobile Menu
   ============================================ */

.header {
  position: fixed !important;
  top: 0 !important;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--color-bg);
  transition: all var(--transition-base);
  border-bottom: none;
  width: 100%;
}
.header--scrolled {
  box-shadow: var(--shadow-sm);
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--container-padding);
  max-width: var(--container-max);
  margin: 0 auto;
  gap: 15px;
}

/* Logo */
.header__logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}
.header__logo img {
  height: 40px;
  width: auto;
}
.header__logo-text {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: var(--fw-bold);
  color: var(--color-text);
  line-height: 1.1;
}
.header__logo-text span {
  display: block;
  font-size: var(--fs-caption);
  font-weight: var(--fw-regular);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Navigation */
.nav {
  position: fixed;
  top: 0;
  right: 0;
  width: 300px;
  height: 100vh;
  background: var(--color-bg);
  padding: var(--space-4xl) var(--space-xl) var(--space-xl);
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.55s cubic-bezier(0.77, 0, 0.175, 1);
  visibility: hidden;
  pointer-events: none;
}
.nav.nav--open {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
}
.nav__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}
.nav__link {
  display: block;
  padding: var(--space-sm) var(--space-md);
  font-family: 'Inter', sans-serif;
  font-size: var(--fs-body);
  font-weight: var(--fw-medium);
  pointer-events: auto;
  position: relative;
  z-index: 1;
  text-decoration: none;
  color: var(--color-primary);
  border-radius: 6px;
  transition: all var(--transition-fast);
}
.nav__link:hover,
.nav__link.active {
  color: var(--color-text);
  font-weight: var(--fw-bold);
  transform: scale(1.15);
  background: none;
}

/* Mobile toggle */
.nav-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  position: relative;
  z-index: 10001;
  pointer-events: auto;
  color: var(--color-text-strong);
}
.nav-toggle * {
  pointer-events: none;
}

/* SVG burger→X morph animation (burger-4 style) */
.nav-toggle__icon {
  display: block;
  overflow: visible;
}
.nav-toggle__icon path {
  d: path('M2,3 L5,3 L8,3 M2,5 L8,5 M2,7 L5,7 L8,7');
  transition: d 0.75s cubic-bezier(0.65, 0, 0.35, 1);
}
.nav-toggle.active .nav-toggle__icon path {
  d: path('M3,3 L5,5 L7,3 M5,5 L5,5 M3,7 L5,5 L7,7');
}

/* Header actions (favorites + phone) */
.header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

/* Favorites */
.header__favorites {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
  transition: color var(--transition-fast);
}
.header__favorites svg {
  width: 24px;
  height: 24px;
  border-radius: 0;
  fill: none;
  stroke: var(--color-primary);
}
.header__favorites:hover {
  color: var(--color-primary);
}
.header__favorites--active {
  color: var(--color-primary);
}
.header__favorites--active svg {
  fill: var(--color-primary);
  stroke: var(--color-primary);
}
.header__favorites-count {
  position: absolute;
  top: -6px;
  right: -8px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  background: rgba(255, 255, 255, 0.4);
  color: var(--color-primary);
  font-size: 11px;
  font-weight: var(--fw-bold);
  line-height: 18px;
  text-align: center;
  border-radius: 50%;
  border: 1px solid var(--color-primary);
}

/* Phone CTA */
.header__phone {
  display: none;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--fs-small);
  font-weight: var(--fw-regular);
  color: var(--color-text);
  white-space: nowrap;
}
.header__phone:hover {
  color: var(--color-primary);
}
.header__phone svg {
  width: 19px;
  height: 19px;
  color: var(--color-text-light);
  border-radius: 0;
  animation: phoneVibrate 3s ease-in-out infinite;
}

@keyframes phoneVibrate {
  0% { transform: rotate(0deg); }
  5% { transform: rotate(6deg); }
  10% { transform: rotate(-6deg); }
  15% { transform: rotate(6deg); }
  20% { transform: rotate(-6deg); }
  25% { transform: rotate(6deg); }
  30% { transform: rotate(-6deg); }
  35% { transform: rotate(0deg); }
  100% { transform: rotate(0deg); }
}

/* Nav overlay backdrop (mobile) */
.nav-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  background: transparent;
  backdrop-filter: blur(12px) saturate(110%);
  -webkit-backdrop-filter: blur(12px) saturate(110%);
  z-index: 998;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, backdrop-filter 0.4s ease;
  pointer-events: none;
}
.nav-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Desktop */
@media (min-width: 1024px) {
  .nav-toggle {
    display: none;
  }
  .nav-overlay {
    display: none !important;
  }
  .nav {
    display: flex;
    position: static;
    width: auto;
    height: auto;
    background: none;
    padding: 0;
    box-shadow: none;
    transform: none;
    overflow: visible;
    visibility: visible;
  }
  .nav__list {
    flex-direction: row;
    gap: 0;
  }
  .nav__link {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--fs-small);
    color: var(--color-primary);
  }
  .nav__link:hover,
  .nav__link.active {
    transform: scale(1.15);
  }
  .header__phone {
    display: flex;
  }
  .header__actions {
    gap: var(--space-xl);
  }
}

/* Offset body for fixed header */
body {
  padding-top: 72px;
}

@media (max-width: 1023px) {
  .header__inner {
    position: relative !important;
    padding-left: 16px !important;
    padding-right: 60px !important;
    justify-content: flex-start !important;
    gap: 0 !important;
  }
  .header__logo {
    margin-right: auto !important;
  }
  .header__favorites {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    margin: 0 auto !important;
  }
  .nav-toggle {
    position: absolute !important;
    right: 16px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    flex-shrink: 0 !important;
  }
}
@media (max-width: 767px) {
  .header__phone {
    display: none !important;
  }
}

/* ============================================
   Mobile Menu — Refined reveal
   ============================================ */
@media (max-width: 1023px) {
  .nav {
    width: min(420px, 86vw);
    padding: calc(72px + var(--space-xl)) var(--space-xl) var(--space-xl);
    box-shadow: -30px 0 80px rgba(45, 41, 38, 0.18);
    display: flex;
    flex-direction: column;
  }

  .nav__list {
    gap: 0;
  }
  .nav__list li {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    transition-delay: 0s;
  }
  .nav--open .nav__list li {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.5s ease, transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  }
  .nav--open .nav__list li:nth-child(1) { transition-delay: 0.18s; }
  .nav--open .nav__list li:nth-child(2) { transition-delay: 0.23s; }
  .nav--open .nav__list li:nth-child(3) { transition-delay: 0.28s; }
  .nav--open .nav__list li:nth-child(4) { transition-delay: 0.33s; }
  .nav--open .nav__list li:nth-child(5) { transition-delay: 0.38s; }
  .nav--open .nav__list li:nth-child(6) { transition-delay: 0.43s; }
  .nav--open .nav__list li:nth-child(7) { transition-delay: 0.48s; }

  .nav__link {
    padding: 18px var(--space-sm) 18px calc(var(--space-sm) + 14px);
    font-size: 1.2rem;
    letter-spacing: 0.01em;
    color: var(--color-text);
    font-weight: var(--fw-regular);
    position: relative;
    border-radius: 0;
  }
  .nav__link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 2px;
    height: 22px;
    background: var(--color-text);
    transform: translateY(-50%) scaleY(0);
    transform-origin: center;
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  }
  /* Override desktop scale hover — use left-accent + bold on mobile */
  .nav__link:hover,
  .nav__link.active {
    transform: none;
    background: transparent;
    color: var(--color-text);
    font-weight: var(--fw-semi);
  }
  .nav__link:hover::before,
  .nav__link.active::before {
    transform: translateY(-50%) scaleY(1);
  }
}

/* ============================================
   Global: dark translucent glass header
   ============================================ */
.header {
  background: rgba(0, 0, 0, 0.5);
  box-shadow: none;
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
}
.header .header__phone,
.header .header__favorites {
  color: var(--color-text-inverse);
}
.header .header__favorites svg {
  stroke: var(--color-text-inverse);
  color: var(--color-text-inverse);
}
.header .header__phone svg {
  fill: var(--color-text-inverse);
  stroke: none;
  color: var(--color-text-inverse);
}
.header .nav-toggle {
  color: var(--color-text-inverse);
}
.header .nav-toggle.active {
  color: var(--color-text-strong);
}
.header .header__favorites-count {
  background: var(--color-text-inverse);
  color: var(--color-text);
  border: none;
}
.header .header__favorites--active svg {
  fill: rgba(0, 0, 0, 0.65);
  stroke: rgba(0, 0, 0, 0.65);
}
/* Desktop inline nav links — white. Mobile drawer keeps default dark. */
@media (min-width: 1024px) {
  .header .nav__link {
    color: var(--color-text-inverse);
  }
}
/* Homepage: hero sits behind header — remove body top padding */
body[data-page="home"] {
  padding-top: 0;
}

/* ============================================
   Language Switcher (UA / RU pill)
   ============================================ */
.lang-switcher {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 12px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: #908E8E;
  user-select: none;
}
.lang-switcher__btn {
  background: none;
  border: none;
  padding: 4px 8px;
  cursor: pointer;
  color: #908E8E;
  font: inherit;
  border-radius: 3px;
  transition: color 0.15s ease;
}
.lang-switcher__btn:hover {
  color: #2D2926;
}
.lang-switcher__btn--active {
  color: #2D2926;
  font-weight: 700;
  cursor: default;
}
.lang-switcher__sep {
  color: #DDD7D2;
}

/* On desktop the switcher inherits the header's white text */
@media (min-width: 1024px) {
  .header .lang-switcher,
  .header .lang-switcher__btn {
    color: rgba(255, 255, 255, 0.6);
  }
  .header .lang-switcher__btn:hover {
    color: #fff;
  }
  .header .lang-switcher__btn--active {
    color: #fff;
  }
  .header .lang-switcher__sep {
    color: rgba(255, 255, 255, 0.3);
  }
}

/* Desktop: hide the mobile-only switcher entirely */
@media (min-width: 1024px) {
  .lang-switcher--mobile {
    display: none !important;
  }
}

/* Mobile: hide desktop switcher; mobile one lives inside .nav drawer */
@media (max-width: 1023px) {
  .header__inner .lang-switcher:not(.lang-switcher--mobile) {
    display: none;
  }
  /* Position the mobile switcher in the top-LEFT corner of the open
     drawer, mirroring the close (X) button which sits top-right. */
  .nav .lang-switcher--mobile {
    display: flex !important;
    position: absolute;
    top: 18px;
    left: 20px;
    margin: 0;
    padding: 0;
    border: none;
    font-size: 16px;
    z-index: 10;
    /* Hidden until the drawer opens — avoids flash before nav animation */
    opacity: 0;
    transition: opacity 0.2s ease 0.1s;
    pointer-events: none;
  }
  .nav.nav--open .lang-switcher--mobile {
    opacity: 1;
    pointer-events: auto;
  }
  .nav .lang-switcher__btn {
    padding: 6px 12px;
    color: #2D2926;
    font-size: 15px;
    font-weight: 600;
  }
  .nav .lang-switcher__btn--active {
    color: #2D2926;
    font-weight: 800;
    text-decoration: underline;
    text-underline-offset: 4px;
  }
  .nav .lang-switcher__sep {
    color: #DDD7D2;
  }
}
