/**
 * WeLUX Header, Mega-Menu, Burger Drawer & Cookie Banner
 * Pixel-perfect Figma adaptation (Desktop 1440px / Mobile 375px).
 */

/* ==========================================================
   1. HEADER BASE & OVERLAY
   ========================================================== */
.header {
  background: var(--color-beige, #f5f3e1);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background-color 0.25s ease;
}

.header--overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(
    180deg,
    rgba(245, 243, 225, 0.95) 0%,
    rgba(245, 243, 225, 0.7) 65%,
    rgba(245, 243, 225, 0) 100%
  );
  z-index: 100;
}

/* Главная: шапка всегда над героем. Ниже героя — сплошной фон, без сдвига контента. */
body.home .header.header--overlay {
  position: fixed;
  background: transparent;
  background-image: none;
  transition: background-color 0.25s ease;
}

body.home .header.header--overlay.is-stuck {
  background: var(--color-beige, #f4f4e1);
}

.header__inner {
  min-height: var(--header-h, 72px);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
}

.header__logo {
  justify-self: center;
  display: inline-flex;
  align-items: center;
}

.header__logo-img {
  display: block;
  height: 38px;
  width: auto;
}

/* ==========================================================
   2. DESKTOP PRIMARY NAVIGATION
   ========================================================== */
.header__nav {
  justify-self: start;
}

.header__nav .menu {
  display: flex;
  align-items: center;
  gap: clamp(14px, 1.8vw, 26px);
  list-style: none;
  margin: 0;
  padding: 0;
}

.header__nav .menu-item {
  position: relative;
  white-space: nowrap;
}

.header__nav .menu-item > a {
  display: inline-block;
  padding: 6px 0;
  font-size: 14px;
  color: var(--color-text, #2a2a2a);
  text-decoration: none;
  transition: color 0.2s ease;
}

.header__nav .menu-item > a:hover,
.header__nav .menu-item > a:focus-visible,
.header__nav .menu-item.current-menu-item > a {
  color: var(--color-olive, #565541);
}

.header__nav .menu-item--services.is-mega-active > a {
  color: var(--color-text, #2a2a2a);
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* ==========================================================
   3. HEADER ACTIONS (SEARCH, CALLBACK, ACCOUNT, BURGER)
   ========================================================== */
.header__actions {
  display: flex;
  align-items: center;
  gap: clamp(12px, 1.4vw, 22px);
  justify-self: end;
}

.header__services {
  display: flex;
  align-items: center;
  gap: clamp(12px, 1.4vw, 20px);
  list-style: none;
  margin: 0;
  padding: 0;
}

.header__action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  padding: 4px 0;
  font-family: inherit;
  font-size: 13px;
  color: var(--color-text, #2a2a2a);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity 0.2s ease, color 0.2s ease;
}

.header__action-btn:hover,
.header__action-btn:focus-visible {
  opacity: 0.85;
}

.header__action-btn:focus-visible,
.header__burger:focus-visible,
.header-cart:focus-visible {
  outline: 2px solid var(--color-olive, #565541);
  outline-offset: 3px;
  border-radius: 4px;
}

.header__action-underline {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.header__badge-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  line-height: 0;
}

.header__badge-arrow svg {
  display: block;
  width: 16px;
  height: 16px;
}

/* Корзина: компактный вид (только при наличии товаров) */
.header-cart {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--color-text, #2a2a2a);
  text-decoration: none;
  position: relative;
  padding: 4px;
  transition: color 0.2s ease;
}

.header-cart:hover {
  color: var(--color-olive, #565541);
}

.header-cart__count {
  min-width: 18px;
  height: 18px;
  padding-inline: 5px;
  border-radius: 999px;
  background: var(--color-text, #2a2a2a);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
}

/* Бургер (3 тонкие линии) */
.header__burger {
  width: 32px;
  height: 32px;
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  margin-left: 4px;
}

.header__burger span {
  display: block;
  width: 20px;
  height: 1.5px;
  background: var(--color-text, #2a2a2a);
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.header--overlay .header__burger span {
  background: var(--color-text, #2a2a2a);
}

/* ==========================================================
   4. DESKTOP MEGA-MENU («Услуги WeLUX»)
   ========================================================== */
.header-mega {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  width: 100%;
  background: #ffffff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.08);
  z-index: 95;
  display: none;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.header-mega.is-open {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.header-mega__inner {
  position: relative;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 48px;
  padding-top: 36px;
  padding-bottom: 48px;
  min-height: 360px;
}

.header-mega__close {
  position: absolute;
  top: 32px;
  right: 16px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  color: #565541;
  border-radius: 50%;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.header-mega__close:hover,
.header-mega__close:focus-visible {
  background: rgba(0, 0, 0, 0.05);
  color: #2a2a2a;
}

.header-mega__close:focus-visible {
  outline: 2px solid var(--color-olive, #565541);
}

.header-mega__sidebar {
  border-right: 1px solid #ebebeb;
  padding-right: 32px;
}

.header-mega__title {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--color-text, #2a2a2a);
  margin-bottom: 28px;
}

.header-mega__directions {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.header-mega__direction-item {
  position: relative;
}

.header-mega__direction-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 15px;
  color: #565541;
  text-decoration: none;
  transition: color 0.2s ease;
}

.header-mega__direction-link:hover,
.header-mega__direction-link:focus-visible,
.header-mega__direction-link.is-active {
  color: var(--color-text, #2a2a2a);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.header-mega__direction-link:focus-visible {
  outline: 2px solid var(--color-olive, #565541);
  outline-offset: 2px;
}

.header-mega__arrow {
  margin-left: 8px;
  opacity: 0.6;
  flex-shrink: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.header-mega__direction-link:hover .header-mega__arrow,
.header-mega__direction-link.is-active .header-mega__arrow {
  opacity: 1;
  transform: translate(2px, -2px);
}

.header-mega__content {
  position: relative;
  padding-right: 48px;
}

.header-mega__panel {
  display: none;
}

.header-mega__panel.is-active {
  display: block;
  animation: megaFadeIn 0.2s ease forwards;
}

@keyframes megaFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.header-mega__category-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
  color: var(--color-text, #2a2a2a);
  margin: 0 0 24px;
}

.header-mega__services-list {
  list-style: none;
  margin: 0;
  padding: 0;
  columns: 2;
  column-gap: 48px;
}

.header-mega__service-item {
  break-inside: avoid;
  margin-bottom: 14px;
}

.header-mega__service-link {
  font-size: 14px;
  line-height: 1.45;
  color: #565541;
  text-decoration: none;
  display: inline-block;
  transition: color 0.2s ease;
}

.header-mega__service-link:hover,
.header-mega__service-link:focus-visible {
  color: #ccaf83;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.header-mega__service-link:focus-visible {
  outline: 2px solid var(--color-olive, #565541);
  outline-offset: 2px;
}

.header-mega__empty {
  font-size: 14px;
  color: #888;
}

/* ==========================================================
   5. DRAWER / BURGER PANEL (DESKTOP & MOBILE)
   ========================================================== */
.welux-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(18, 18, 18, 0.4);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 998;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s ease;
}

.welux-drawer-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

.welux-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  background: #ffffff;
  color: var(--color-text, #2a2a2a);
  z-index: 999;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.32s ease;
  overflow: hidden;
}

.welux-drawer.is-open {
  transform: translateX(0);
  visibility: visible;
}

/* Крестик в шапке drawer */
.welux-drawer__header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 24px 24px 8px;
  flex-shrink: 0;
}

.welux-drawer__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: #565541;
  border-radius: 50%;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.welux-drawer__close:hover,
.welux-drawer__close:focus-visible {
  background: rgba(0, 0, 0, 0.05);
  color: #2a2a2a;
}

.welux-drawer__close:focus-visible {
  outline: 2px solid var(--color-olive, #565541);
}

.welux-drawer__body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 24px 32px;
  display: flex;
  flex-direction: column;
}

/* Разделители внутри drawer */
.welux-drawer__divider {
  height: 1px;
  background: #e8e6dc;
  border: none;
  margin: 18px 0;
  flex-shrink: 0;
}

/* Кнопка «Записаться на прием» */
.welux-drawer__cta {
  padding-top: 24px;
  margin-top: auto;
}

.welux-drawer__cta-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 20px;
  background: #565541;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.welux-drawer__cta-btn:hover,
.welux-drawer__cta-btn:focus-visible {
  background: #444333;
}

.welux-drawer__cta-btn:focus-visible {
  outline: 2px solid var(--color-olive, #565541);
  outline-offset: 2px;
}

/* Меню в drawer */
.welux-drawer__menu {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.welux-drawer__menu .menu-item > a {
  display: inline-block;
  font-size: 14px;
  color: var(--color-text, #2a2a2a);
  text-decoration: none;
  transition: color 0.2s ease;
}

.welux-drawer__menu .menu-item > a:hover,
.welux-drawer__menu .menu-item > a:focus-visible,
.welux-drawer__menu .menu-item.current-menu-item > a {
  color: var(--color-olive, #565541);
}

/* Раскрывающийся список подменю (направления Услуг) */
.welux-drawer__menu .menu-item-has-children {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

.welux-drawer__menu .menu-item-has-children > a {
  flex: 1;
}

.welux-drawer__menu .menu-item-has-children > a::after {
  display: none !important;
}

.welux-drawer__submenu-toggle {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  color: #565541;
  border-radius: 4px;
  transition: transform 0.25s ease, background-color 0.2s ease;
}

.welux-drawer__submenu-toggle:hover {
  background: rgba(0, 0, 0, 0.04);
}

.welux-drawer__menu .menu-item-has-children.is-expanded > .welux-drawer__submenu-toggle {
  transform: rotate(180deg);
}

.welux-drawer__menu .sub-menu {
  display: none;
  flex: 0 0 100%;
  width: 100%;
  list-style: none;
  padding: 8px 0 6px 14px;
  margin: 0;
  border-left: 1px solid #e8e6dc;
}

.welux-drawer__menu .menu-item-has-children.is-expanded > .sub-menu {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.welux-drawer__menu .sub-menu .menu-item > a {
  font-size: 13px;
  color: #565541;
}

/* ==========================================================
   ДЕСКТОПНЫЙ ВИД DRAWER (>1080px): Узкая панель ~280px (d/492-266.jpg)
   ========================================================== */
@media (min-width: 1081px) {
  /* d/492-266: шапка целиком, панель 272px начинается под ней, крестик в панели */
  .welux-drawer {
    top: var(--welux-header-h, var(--header-h, 80px));
    width: 272px;
    max-width: 272px;
    box-shadow: none;
    z-index: 999;
  }

  body.is-drawer-open .header {
    z-index: 1100;
  }

  body.home.is-drawer-open .header.header--overlay {
    background: #fff;
    background-image: none;
  }

  .welux-drawer__header {
    padding: 18px 12px 0 24px;
  }

  .welux-drawer__body {
    padding: 12px 24px 28px;
  }

  .welux-drawer__top-services,
  .welux-drawer__primary-nav,
  .welux-drawer__divider--mobile,
  .welux-drawer__bottom-contacts {
    display: none !important;
  }

  .welux-drawer__burger-nav .welux-drawer__menu {
    gap: 18px;
  }

  .welux-drawer__cta {
    padding-top: 24px;
  }

  .welux-drawer__cta-btn {
    width: auto;
    align-self: flex-start;
    min-height: 44px;
    padding: 12px 22px;
    border-radius: 8px;
  }

  /* В макете бургер в шапке остаётся тремя полосками, крестик только в панели */
  .header__burger[aria-expanded="true"] span:nth-child(1),
  .header__burger[aria-expanded="true"] span:nth-child(3) {
    transform: none;
  }

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

/* ==========================================================
   МОБИЛЬНЫЙ ВИД DRAWER (<=1080px): Панель ~313px (m/581-6220.jpg)
   ========================================================== */
@media (max-width: 1080px) {
  .header-mega {
    display: none !important;
  }
  .header__nav {
    display: none !important;
  }
  .header__services {
    display: none !important;
  }
  .header__inner {
    grid-template-columns: auto 1fr;
  }
  .header__logo {
    justify-self: start;
    grid-column: 1;
  }
  .header__actions {
    grid-column: 2;
    justify-self: end;
  }

  .welux-drawer {
    width: 313px;
    max-width: calc(100vw - 48px);
  }

  /* Верхние сервисные кнопки мобильного меню */
  .welux-drawer__top-services {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .welux-drawer__top-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    padding: 0;
    font-family: inherit;
    font-size: 14px;
    color: var(--color-text, #2a2a2a);
    cursor: pointer;
    text-decoration: none;
  }

  .welux-drawer__top-underline {
    text-decoration: underline;
    text-underline-offset: 3px;
  }

  /* Соцсети, часы, телефон, адрес внизу */
  .welux-drawer__bottom-contacts {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .welux-drawer__socials {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 4px;
  }

  .welux-drawer__social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #565541;
    transition: opacity 0.2s ease;
  }

  .welux-drawer__social-link:hover {
    opacity: 0.8;
  }

  .welux-drawer__hours {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 12px;
    color: #2a2a2a;
  }

  .welux-drawer__hours-row {
    display: flex;
    gap: 6px;
  }

  .welux-drawer__hours-label {
    color: #666;
  }

  .welux-drawer__phone-wrap {
    margin-top: 4px;
  }

  .welux-drawer__phone {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text, #2a2a2a);
    text-decoration: none;
  }

  .welux-drawer__address-text {
    font-size: 12px;
    color: #666;
    font-style: normal;
    line-height: 1.4;
  }
}

/* ==========================================================
   6. COOKIE BANNER (d/268-641.jpg & m/581-9701.jpg)
   ========================================================== */
.welux-cookie {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 850;
  width: min(701px, calc(100vw - 48px));
  max-width: 701px;
  animation: cookieFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes cookieFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.welux-cookie__card {
  background: #ffffff;
  border-radius: 12px;
  padding: 8px 10px 8px 16px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  box-sizing: border-box;
  height: 62px;
  min-height: 62px;
}

.welux-cookie__close {
  display: none;
}

.welux-cookie__text {
  font-size: 11px;
  line-height: 1.35;
  color: #666666;
  flex: 1;
  min-width: 0;
}

.welux-cookie__link {
  color: var(--color-text, #2a2a2a);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.welux-cookie__btn {
  background: #ccaf83;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 0 18px;
  height: 40px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.2s ease;
}

.welux-cookie__btn:hover,
.welux-cookie__btn:focus-visible {
  background: #bfa072;
}

.welux-cookie__btn:focus-visible {
  outline: 2px solid var(--color-olive, #565541);
  outline-offset: 2px;
}

/* Мобильный вид cookie (m/581-9701.jpg): карточка снизу на всю ширину с крестиком */
@media (max-width: 767px) {
  .welux-cookie {
    bottom: 16px;
    left: 16px;
    right: 16px;
    width: auto;
    max-width: none;
  }

  .welux-cookie__card {
    flex-direction: column;
    align-items: stretch;
    height: auto;
    min-height: 0;
    padding: 24px 20px 20px;
    gap: 16px;
  }

  .welux-cookie__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 14px;
    right: 14px;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    color: #565541;
    cursor: pointer;
    border-radius: 50%;
  }

  .welux-cookie__close:hover,
  .welux-cookie__close:focus-visible {
    background: rgba(0, 0, 0, 0.05);
  }

  .welux-cookie__close:focus-visible {
    outline: 2px solid var(--color-olive, #565541);
    outline-offset: 2px;
  }

  .welux-cookie__text {
    font-size: 12px;
    line-height: 1.5;
    padding-right: 20px;
  }

  .welux-cookie__btn {
    width: 100%;
    height: auto;
    padding: 12px 20px;
    font-size: 14px;
  }
}

/* ==========================================================
   7. ACCESSIBILITY & PREFERS-REDUCED-MOTION
   ========================================================== */
@media (prefers-reduced-motion: reduce) {
  .header,
  body.home .header.header--overlay,
  .welux-drawer,
  .welux-drawer-backdrop,
  .header-mega,
  .welux-cookie {
    transition: none !important;
    animation: none !important;
  }
}

/* Desktop: в макете бургер-панель без затемнения страницы (подложка остаётся для закрытия кликом) */
@media (min-width: 1025px) {
  .welux-drawer-backdrop {
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}
