/* ===== BLOCK: header =====
   Шапка «плаває» над банером: прозорий фон, білі «пігулки».
   Висота в потоці стала (--header-h), при скролі зменшуються лише пігулки,
   тож контент під шапкою не стрибає. */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  pointer-events: none;
}
.header__inner {
  display: flex;
  align-items: center;
  gap: 20px;
  /* padding-top: 18px; */
  padding-top: 35px;
  padding-bottom: 18px;
  transition: padding .35s var(--ease-out);
}
.header__inner > * { pointer-events: auto; }

.header__logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  min-height: 56px;
  padding: 10px 26px;
  border-radius: var(--r-pill);
  background: var(--c-white);
  box-shadow: var(--sh-soft);
  transition: min-height .35s var(--ease-out), padding .35s var(--ease-out), box-shadow .35s ease;
}
.header__logo img { width: clamp(150px, 9vw, 176px); height: auto; }

/* ---- Навігація (десктоп) ---- */
.nav { margin: 0 auto; }
.nav__list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 2px;
  min-height: 56px;
  padding: 8px 12px;
  border-radius: var(--r-xl);
  /* background: rgba(255,255,255,.9); */
  background: #ffff;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: var(--sh-soft);
  transition: min-height .35s var(--ease-out), padding .35s var(--ease-out);
}
.nav__item {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: var(--r-pill);
  transition: background-color .2s ease;
}
.nav__link {
  display: block;
  padding: 14px 4px 14px 20px;
  border-radius: var(--r-pill);
  font-family: var(--ff-head);
  font-size: clamp(.875rem, .8rem + .15vw, .9375rem);
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  color: var(--c-ink);
}
.nav__toggle {
  display: grid;
  place-items: center;
  width: 28px; height: 32px;
  margin-right: 8px;
  border-radius: var(--r-pill);
  color: var(--c-ink-2);
}
.nav__toggle svg { width: 14px; height: 14px; transition: transform .25s var(--ease-out); }
.nav__item:hover,
.nav__item.is-open { background: var(--c-apricot-100); }
/* Активний пункт (на внутрішніх сторінках) — помаранчева «пігулка» */
.nav__item.is-current { background: var(--c-orange); }
.nav__item.is-current > .nav__link,
.nav__item.is-current > .nav__toggle { color: var(--c-ink); }

.nav__sub {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  min-width: 260px;
  padding: 10px;
  border-radius: var(--r-md);
  background: var(--c-white);
  box-shadow: var(--sh-float);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .25s var(--ease-out), visibility 0s linear .25s;
}
/* «Місток», щоб підменю не закривалося, поки курсор іде вниз */
.nav__sub::before { content: ""; position: absolute; left: 0; right: 0; top: -12px; height: 12px; }
.nav__sub a {
  display: block;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  font-family: var(--ff-body);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.35;
}
.nav__sub a:hover { background: var(--c-apricot-50); color: var(--c-orange-text); }

@media (hover: hover) and (min-width: 1200.02px) {
  .nav__item:hover > .nav__sub {
    opacity: 1; visibility: visible; transform: none;
    transition: opacity .2s ease, transform .25s var(--ease-out), visibility 0s;
  }
  .nav__item:hover > .nav__toggle svg { transform: rotate(180deg); }
}
.nav__item.is-open > .nav__sub {
  opacity: 1; visibility: visible; transform: none;
  transition: opacity .2s ease, transform .25s var(--ease-out), visibility 0s;
}
.nav__item.is-open > .nav__toggle svg { transform: rotate(180deg); }

/* CTA у шапці */
.header__cta {
  flex-shrink: 0;
  min-height: 56px;
  padding-inline: clamp(24px, 2.6vw, 52px);
  /* font-size: clamp(.9375rem, .8rem + .45vw, 1.375rem); */
  font-size: clamp(.875rem, .8rem + .15vw, .9375rem);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .01em;
  transition: --btn-angle .9s var(--ease-out), transform .25s var(--ease-out), box-shadow .3s ease, min-height .35s var(--ease-out);
}

.header__burger { display: none; }
/* Тимчасово під час вимірювання висоти (header.js) */
.header.no-anim, .header.no-anim * { transition: none !important; }

/* ---- Стан після прокрутки: компактніша шапка ---- */
.header.is-scrolled .header__inner { padding-top: 10px; padding-bottom: 10px; }
.header.is-scrolled .header__logo { min-height: 56px; padding-block: 6px; box-shadow: var(--sh-float); }
.header.is-scrolled .nav__list { min-height: 56px; padding-block: 4px; box-shadow: var(--sh-float); }
.header.is-scrolled .nav__link { padding-block: 10px; }
.header.is-scrolled .header__cta { min-height: 56px; }

/* ---- Проміжні ширини ---- */
@media (max-width: 1440px) {
  .header__inner { gap: 14px; }
  .header__logo { padding-inline: 20px; }
  .nav__list { padding-inline: 8px; }
  .nav__link { padding-left: 14px; }
  .nav__toggle { margin-right: 4px; width: 24px; }
  .header__cta { padding-inline: 24px; font-size: .9375rem; }
}

/* ---- Мобільна навігація (бургер) ---- */
@media (max-width: 1200px) {
  :root { --header-h: 84px; }

  .header__inner { gap: 10px; padding-top: 12px; padding-bottom: 12px; }
  .header__logo { min-height: 60px; padding: 8px 18px; margin-right: auto; }
  .header__logo img { width: clamp(118px, 26vw, 160px); }
  .header__cta { min-height: 60px; }
  .header.is-scrolled .header__logo,
  .header.is-scrolled .header__cta { min-height: 52px; }

  .header__burger {
    position: relative;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 60px; height: 60px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--c-white);
    box-shadow: var(--sh-soft);
    color: var(--c-ink);
    transition: width .35s var(--ease-out), height .35s var(--ease-out);
  }
  .header.is-scrolled .header__burger { width: 52px; height: 52px; box-shadow: var(--sh-float); }
  .header__burger svg { width: 24px; height: 24px; }
  .header__burger-close { display: none; }
  .header__burger[aria-expanded="true"] .header__burger-open { display: none; }
  .header__burger[aria-expanded="true"] .header__burger-close { display: block; }

  .nav {
    position: fixed;
    inset: 0 0 0 auto;
    z-index: 1;
    width: min(420px, 100%);
    margin: 0;
    padding: calc(var(--header-h) + 8px) 16px 32px;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--c-white);
    box-shadow: -20px 0 60px rgba(31,26,23,.18);
    visibility: hidden;
    transform: translateX(100%);
    transition: transform .4s var(--ease-out), visibility 0s linear .4s;
    pointer-events: auto;
  }
  .nav.is-open {
    visibility: visible;
    transform: none;
    transition: transform .4s var(--ease-out), visibility 0s;
  }
  .nav__list,
  .header.is-scrolled .nav__list {
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    gap: 4px;
    min-height: 0;
    padding: 0;
    border-radius: 0;
    background: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    box-shadow: none;
  }
  .nav__item {
    flex-wrap: wrap;
    border-radius: var(--r-md);
  }
  .nav__item:hover { background: none; }
  .nav__item.is-open { background: var(--c-apricot-50); }
  .nav__link,
  .header.is-scrolled .nav__link {
    flex: 1;
    padding: 14px 16px;
    font-size: 1.0625rem;
    font-weight: 600;
    white-space: normal;
  }
  .nav__toggle { width: 48px; height: 48px; margin-right: 0; }
  .nav__toggle svg { width: 18px; height: 18px; }
  .nav__sub {
    position: static;
    display: none;
    width: 100%;
    min-width: 0;
    padding: 0 8px 10px;
    border-radius: 0;
    background: none;
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: none;
  }
  .nav__sub::before { display: none; }
  .nav__item.is-open > .nav__sub { display: block; }
  .nav__sub a { font-size: 1rem; }

  /* Затемнення сторінки під відкритим меню */
  .nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 49;
    background: rgba(31,26,23,.45);
    opacity: 0;
    visibility: hidden;
    transition: opacity .3s ease, visibility 0s linear .3s;
  }
  .nav-backdrop.is-visible { opacity: 1; visibility: visible; transition: opacity .3s ease, visibility 0s; }
  body.nav-open { overflow: hidden; }
}

@media (max-width: 576px) {
  :root { --header-h: 72px; }
  .header__inner { gap: 8px; padding-top: 10px; padding-bottom: 10px; }
  .header__logo { min-height: 52px; padding: 6px 14px; }
  .header__cta {
    min-height: 52px;
    padding: 6px 16px;
    font-size: .8125rem;
    line-height: 1.15;
    white-space: normal;
    max-width: 150px;
  }
  .header__burger { width: 52px; height: 52px; }
  .header.is-scrolled .header__logo,
  .header.is-scrolled .header__cta { min-height: 46px; }
  .header.is-scrolled .header__burger { width: 46px; height: 46px; }
}
@media (max-width: 390px) {
  .header__logo { padding: 6px 10px; }
  .header__logo img { width: 104px; }
  .header__cta { padding: 6px 12px; font-size: .75rem; max-width: 118px; letter-spacing: 0; }
  .header__burger { width: 46px; height: 46px; }
}
@media (max-width: 340px) {
  .header__inner { gap: 6px; }
  .header__logo img { width: 92px; }
  .header__cta { padding: 4px 10px; max-width: 104px; font-size: .6875rem; }
  .header__burger { width: 42px; height: 42px; }
  .header__burger svg { width: 20px; height: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .header__inner, .header__logo, .nav__list, .header__cta, .nav, .nav__sub, .header__burger { transition: none; }
}
/* ===== /BLOCK: header ===== */
