/* ==========================================================================
   v3 header (+ mobile menu panel, dropdowns, consultation dialog)
   Figma: Header 10986:6970 (1440x62), mobile menu 11336:14312 (430x72). The opened mobile menu
   has no frame in the design: the panel below is built from the same tokens.
   ========================================================================== */

:root {
  --v3-header-h: 62px;          /* real height is synced by js/v3/parts/header.js */
  --v3-bottom-offset: 0px;      /* no fixed bottom bar in the design (Info manager is a static footer block) */
}
@media (max-width: 1024px) {
  :root { --v3-header-h: 72px; }
}

body.v3.v3-lock { overflow: hidden; }

.v3-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--v3-bg-light);
  transition: box-shadow 0.2s ease;
}
.v3-header::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("../../../images/v3/header/noise.webp") 0 0 / 256px 256px;
  opacity: 0.03;
  pointer-events: none;
}
.v3-header.is-scrolled { box-shadow: 0 1px 0 rgba(10, 10, 10, 0.08), 0 8px 24px -12px rgba(10, 10, 10, 0.12); }

/* Home / courier (first section is hero_home / hero_courier): the header has no fill and no texture over the hero at the top of the page (Figma 11827:33740).
   Scrolled or with the mobile menu open it is the regular header again. */
body:has(main > :is(.v3-hero-home, .v3-hero-courier):first-child) .v3-header:not(.is-scrolled):not(.is-menu-open) { background: transparent; }
body:has(main > :is(.v3-hero-home, .v3-hero-courier):first-child) .v3-header:not(.is-scrolled):not(.is-menu-open)::before { display: none; }

.v3-header__bar {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 62px;
  padding-block: 12px;
}
/* outer dashed guide lines: the header draws them on every page, the hero lines start below it */
.v3-header__bar::before {
  content: "";
  position: absolute;
  inset: 0 var(--v3-frame-line);
  pointer-events: none;
  background:
    repeating-linear-gradient(180deg, var(--v3-gray-50) 0 3px, transparent 3px 5px) 0 0 / 1px 100% no-repeat,
    repeating-linear-gradient(180deg, var(--v3-gray-50) 0 3px, transparent 3px 5px) 100% 0 / 1px 100% no-repeat;
}

/* ---- logo ---- */
.v3-header__logo {
  display: block;
  flex: none;
  width: 88px;
  padding-inline: 3px;
}
.v3-header__logo-img {
  display: block;
  width: 82px;
  height: 32px;
  background: var(--v3-dark);
  -webkit-mask: url("../../../images/v3/header/logo-mask.png") center / contain no-repeat;
  mask: url("../../../images/v3/header/logo-mask.png") center / contain no-repeat;
}

/* ---- desktop: logo | nav | tools | actions ---- */
.v3-header__panel { display: contents; }
.v3-header__nav { margin-inline: auto; order: 1; }
.v3-header__tools { order: 2; display: flex; align-items: center; gap: 24px; margin-right: clamp(24px, 8.75vw, 126px); }
.v3-header__actions { order: 3; display: flex; align-items: center; gap: 24px; }

.v3-header__list { display: flex; align-items: center; gap: 24px; margin: 0; padding: 0; list-style: none; }
.v3-header__item { position: relative; display: flex; align-items: center; gap: 4px; }

.v3-header__link,
.v3-header__phones-btn,
.v3-header__lang-btn,
.v3-header__login {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.3;
  color: var(--v3-dark);
  white-space: nowrap;
  transition: color 0.2s ease;
}
.v3-header__link:hover,
.v3-header__phones-btn:hover,
.v3-header__lang-btn:hover,
.v3-header__login:hover,
.v3-header__item.is-current > .v3-header__link,
.v3-dd.is-open > .v3-dd__trigger { color: var(--v3-primary); }

.v3-header__chev {
  width: 16px;
  height: 16px;
  flex: none;
  transition: transform 0.2s ease;
}
.v3-dd.is-open > .v3-dd__trigger .v3-header__chev { transform: rotate(180deg); }
.v3-header__sub-toggle { display: inline-flex; align-items: center; justify-content: center; }

/* dropdown surfaces: phones, language, sub menu */
.v3-dd { position: relative; }
.v3-dd__menu,
.v3-header__sub {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 5;
  min-width: 200px;
  margin: 0;
  padding: 8px;
  list-style: none;
  background: var(--v3-white);
  border-radius: var(--v3-radius-md);
  box-shadow: 0 12px 32px -12px rgba(10, 10, 10, 0.2);
  visibility: hidden;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
}
/* bridges the 8px gap so the pointer can travel from the trigger to the list */
.v3-dd__menu::before,
.v3-header__sub::before { content: ""; position: absolute; left: 0; right: 0; top: -8px; height: 8px; }
.v3-dd.is-open > .v3-dd__menu,
.v3-dd.is-open > .v3-header__sub {
  visibility: visible;
  opacity: 1;
  transform: none;
  transition-delay: 0s;
}
.v3-dd__menu a,
.v3-header__sub a {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--v3-radius-sm);
  font-size: 14px;
  line-height: 1.3;
  color: var(--v3-dark);
  white-space: nowrap;
}
.v3-dd__menu a:hover,
.v3-header__sub a:hover,
.v3-dd__menu a[aria-current],
.v3-header__sub .is-current > a { background: var(--v3-primary-10); }
.v3-header__dd-label { font-size: 12px; color: var(--v3-gray-100); }
.v3-header__dd-list--lang { min-width: 72px; right: 0; left: auto; }

/* phones: icon only on mobile */
.v3-header__phones-icon { display: none; }

/* login + consultation */
.v3-header__login img { width: 16px; height: 16px; }
.v3-header__cta {
  --btn-bg: transparent;
  --btn-color: var(--v3-primary);
  --btn-border: var(--v3-primary);
  --btn-hover-bg: var(--v3-primary);
  --btn-hover-color: var(--v3-white);
  --btn-hover-border: var(--v3-primary);
  min-height: 0;
  padding: 8px 12px;
  border-radius: var(--v3-radius-sm);
  font-size: 14px;
  line-height: 1.3;
}

.v3-header__burger { display: none; }

@media (max-width: 1280px) {
  .v3-header__list { gap: 16px; }
  .v3-header__tools { gap: 16px; margin-right: clamp(16px, 3vw, 40px); }
  .v3-header__actions { gap: 16px; }
}

/* anchors must not land under the sticky header */
html { scroll-padding-top: var(--v3-header-h, 62px); }

/* 1025-1100: longer (Polish) labels would overflow the bar */
@media (min-width: 1025px) and (max-width: 1100px) {
  .v3-header__list, .v3-header__tools, .v3-header__actions { gap: 12px; }
}

/* ---- mobile / tablet: burger + panel ---- */
@media (max-width: 1024px) {
  .v3-header__bar { min-height: 72px; padding-block: 20px; justify-content: space-between; }
  .v3-header__logo { width: auto; padding-inline: 3px; }
  .v3-header__logo-img { width: 62px; height: 24px; }

  .v3-header__tools { order: 0; gap: 12px; margin-right: 0; }

  .v3-header__phones-btn,
  .v3-header__lang-btn {
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1.231px solid var(--v3-gray-50);
    border-radius: 16px;
  }
  .v3-header__phones { margin-right: 4px; }
  .v3-header__phones-btn .v3-header__chev,
  .v3-header__lang-btn .v3-header__chev { display: none; }
  /* phone number stays in the DOM as the button's accessible name (same as .v3-visually-hidden) */
  .v3-header__phones-text {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .v3-header__phones-icon { display: block; }
  .v3-header__phones-icon img { width: 16px; height: 16px; }
  .v3-dd__menu { left: auto; right: 0; }

  .v3-header__burger {
    position: relative;
    display: block;
    width: 32px;
    height: 32px;
  }
  .v3-header__burger-icon { width: 32px; height: 32px; }
  .v3-header__burger-x { position: absolute; inset: 0; opacity: 0; }
  .v3-header__burger-x::before,
  .v3-header__burger-x::after {
    content: "";
    position: absolute;
    left: 6px;
    top: 15px;
    width: 20px;
    height: 2px;
    border-radius: 1px;
    background: var(--v3-dark);
    transform: rotate(45deg);
  }
  .v3-header__burger-x::after { transform: rotate(-45deg); }
  .is-menu-open .v3-header__burger-icon { opacity: 0; }
  .is-menu-open .v3-header__burger-x { opacity: 1; }

  .v3-header__panel {
    position: fixed;
    top: var(--v3-header-h);
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 32px;
    padding: 8px var(--v3-gutter) 32px;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--v3-bg-light);
    visibility: hidden;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s linear 0.25s;
  }
  .is-menu-open .v3-header__panel {
    visibility: visible;
    opacity: 1;
    transform: none;
    transition-delay: 0s;
  }

  .v3-header__nav { margin: 0; }
  .v3-header__list { flex-direction: column; align-items: stretch; gap: 0; }
  .v3-header__item { flex-wrap: wrap; gap: 0; }
  .v3-header__list > .v3-header__item { border-bottom: 1px solid var(--v3-gray-50); }
  .v3-header__link { flex: 1; padding-block: 16px; font-size: 18px; font-weight: 500; }
  button.v3-header__link { justify-content: space-between; text-align: left; }
  .v3-header__sub-toggle { width: 48px; height: 48px; margin: 0; }
  .v3-header__chev { width: 20px; height: 20px; }

  .v3-header__sub {
    position: static;
    flex-basis: 100%;
    display: none;
    min-width: 0;
    padding: 0 0 12px 16px;
    background: none;
    box-shadow: none;
    visibility: visible;
    opacity: 1;
    transform: none;
  }
  .v3-header__sub::before { display: none; }
  .v3-dd.is-open > .v3-header__sub { display: block; }
  .v3-header__sub a { padding: 10px 0; font-size: 16px; }
  .v3-header__sub a:hover { background: none; color: var(--v3-primary); }

  .v3-header__actions { flex-direction: column; align-items: stretch; gap: 16px; }
  .v3-header__login { justify-content: center; min-height: 48px; font-size: 16px; font-weight: 500; }
  .v3-header__cta { min-height: 52px; padding: 0 30px; border-radius: var(--v3-radius-md); font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .v3-header__panel { transform: none; }
}

/* ---- consultation dialog ---- */
.v3-consult {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: var(--v3-radius-lg);
  background: var(--v3-white);
  color: var(--v3-dark);
  overflow: auto;
}
.v3-consult::backdrop { background: rgba(10, 10, 10, 0.6); }
.v3-consult__inner { position: relative; padding: 40px 32px 32px; }
.v3-consult__title { margin-right: 40px; margin-bottom: 24px; }
.v3-consult__close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  transition: background-color 0.2s ease;
}
.v3-consult__close:hover { background: var(--v3-bg-light); }
.v3-consult__close span::before,
.v3-consult__close span::after {
  content: "";
  position: absolute;
  left: 10px;
  top: 19px;
  width: 20px;
  height: 2px;
  border-radius: 1px;
  background: var(--v3-dark);
  transform: rotate(45deg);
}
.v3-consult__close span::after { transform: rotate(-45deg); }
@media (max-width: 480px) {
  .v3-consult__inner { padding: 40px 20px 24px; }
}
