/* Шапка сайта (макет A1). Токены совпадают с Figma «ArtDveri / Color». */

.ad-header, .ad-drawer {
  --ad-primary: #FBB917;
  --ad-primary-hover: #EDB021;
  --ad-primary-soft: #FFF4D6;
  --ad-ink: #1C222A;
  --ad-dark: #393939;
  --ad-bar: #494D4E;
  --ad-muted: #6A655D;
  --ad-subtle: #959EA9;
  --ad-border: #E6E6E6;
  --ad-surface: #F5F5F3;
  --ad-white: #FFFFFF;
  --ad-sale: #FF5268;
  --ad-radius-sm: 6px;
  --ad-radius-md: 10px;
  --ad-radius-lg: 16px;
  --ad-focus: 0 0 0 3px rgba(251, 185, 23, .55);
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  line-height: 20px;
  color: var(--ad-ink);
}
.ad-header *, .ad-header *::before, .ad-header *::after,
.ad-drawer *, .ad-drawer *::before, .ad-drawer *::after { box-sizing: border-box; }
:where(.ad-header, .ad-drawer) ul { list-style: none; margin: 0; padding: 0; }
:where(.ad-header, .ad-drawer) p { margin: 0; }
:where(.ad-header, .ad-drawer) a { color: inherit; text-decoration: none; }
:where(.ad-header, .ad-drawer) button { font: inherit; color: inherit; background: none; border: 0; margin: 0; padding: 0; cursor: pointer; }
.ad-header :focus-visible, .ad-drawer :focus-visible { outline: none; box-shadow: var(--ad-focus); border-radius: var(--ad-radius-sm); }
.ad-header .ad-icon, .ad-drawer .ad-icon { flex-shrink: 0; display: block; }
.ad-header__sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.ad-header { position: relative; z-index: 1000; }
.ad-header__container { max-width: 1440px; margin: 0 auto; padding: 0 40px; }

/* верхняя полоса */
.ad-header__utility { background: var(--ad-dark); color: #E6E6E6; font-size: 12px; line-height: 16px; }
.ad-header__utility-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 32px; }
.ad-header__schedule { display: inline-flex; align-items: center; gap: 8px; }
.ad-header__links { margin-left: auto; }
.ad-header__links ul { display: flex; flex-wrap: wrap; gap: 4px 24px; }
.ad-header__link { display: inline-block; padding: 8px 0; transition: color .15s ease; }
.ad-header__link:hover, .ad-header__link[aria-current="page"] { color: var(--ad-white); }
.ad-header__link.is-accent { color: var(--ad-primary); font-weight: 600; }

/* основная строка */
.ad-header__main { background: var(--ad-bar); color: var(--ad-white); }
.ad-header__main-row { display: flex; align-items: center; gap: 24px; min-height: 76px; padding-top: 16px; padding-bottom: 16px; }
.ad-header__logo { display: flex; align-items: center; flex-shrink: 0; }
.ad-header__logo img { display: block; height: 42px; width: auto; max-width: 180px; object-fit: contain; }
.ad-header__logo-text { font-size: 22px; font-weight: 800; color: var(--ad-primary); }

.ad-header__catalog-btn {
  display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; height: 44px; padding: 0 20px;
  border-radius: var(--ad-radius-md); background: var(--ad-primary); color: var(--ad-ink) !important;
  font-weight: 600 !important; transition: background-color .15s ease;
}
.ad-header__catalog-btn:hover { background: var(--ad-primary-hover); }
.ad-header__catalog-icon--close, .ad-header__catalog-btn[aria-expanded="true"] .ad-header__catalog-icon--open { display: none; }
.ad-header__catalog-btn[aria-expanded="true"] .ad-header__catalog-icon--close { display: block; }

.ad-header__search { position: relative; flex: 1 1 auto; min-width: 0; display: flex; align-items: center; }
.ad-header__search-input {
  width: 100%; height: 44px; padding: 0 52px 0 16px; border: 2px solid transparent; border-radius: var(--ad-radius-md);
  background: var(--ad-white); color: var(--ad-ink); font: inherit; font-size: 14px; outline: none; transition: border-color .15s ease;
  -webkit-appearance: none; appearance: none;
}
.ad-header__search-input::placeholder { color: var(--ad-subtle); }
.ad-header__search-input:focus { border-color: var(--ad-primary); }
.ad-header__search-input::-webkit-search-cancel-button { -webkit-appearance: none; }
.ad-header__search-btn {
  position: absolute; right: 4px; top: 4px; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--ad-radius-sm); background: var(--ad-primary) !important; color: var(--ad-ink) !important; transition: background-color .15s ease;
}
.ad-header__search-btn:hover { background: var(--ad-primary-hover) !important; }

.ad-header__phone { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; flex-shrink: 0; }
.ad-header__phone-number { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; white-space: nowrap; }
.ad-header__phone-number .ad-icon { color: var(--ad-primary); }
.ad-header__measure {
  font-size: 12px !important; line-height: 16px; font-weight: 600 !important; color: var(--ad-primary) !important;
  text-decoration: underline; text-underline-offset: 3px;
}
.ad-header__measure:hover { color: var(--ad-white) !important; }

.ad-header__actions { display: flex; align-items: center; gap: 24px; flex-shrink: 0; }
.ad-header__action { display: flex; flex-direction: column; align-items: center; gap: 4px; color: #E6E6E6 !important; font-size: 12px; line-height: 16px; transition: color .15s ease; }
.ad-header__action:hover { color: var(--ad-white) !important; }
.ad-header__action-icon { position: relative; display: block; color: var(--ad-white); }
.ad-header__badge {
  position: absolute; top: -7px; right: -10px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
  background: var(--ad-primary); color: var(--ad-ink); font-size: 11px; line-height: 18px; font-weight: 700; text-align: center;
}
.ad-header__badge[data-count="0"] { display: none; }

.ad-header__icon-btn { display: none; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: var(--ad-radius-md); color: var(--ad-white); }
.ad-drawer .ad-header__icon-btn { display: inline-flex; color: var(--ad-ink); }

/* мега-меню */
.ad-mega {
  position: absolute; top: 100%; left: 0; right: 0;
  background: linear-gradient(90deg, var(--ad-surface) 50%, var(--ad-white) 50%);
  box-shadow: 0 24px 48px -12px rgba(28, 34, 42, .25);
  animation: ad-mega-in .16s ease-out;
}
.ad-mega[hidden] { display: none; }
.ad-mega__inner { display: grid; grid-template-columns: 296px minmax(0, 1fr); max-width: 1440px; margin: 0 auto; }
.ad-mega__aside, .ad-mega__panels { max-height: calc(100vh - 108px); }
.ad-mega__aside { display: flex; flex-direction: column; gap: 4px; padding: 24px 16px; background: var(--ad-surface); overflow-y: auto; }
.ad-mega__tabs { display: flex; flex-direction: column; gap: 4px; }
.ad-mega__tab {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 16px; border-radius: var(--ad-radius-md);
  font-size: 15px; font-weight: 500; transition: background-color .15s ease;
}
.ad-mega__tab-label { flex: 1; min-width: 0; }
.ad-mega__tab .ad-icon--chevron-right { color: var(--ad-subtle); }
.ad-mega__tab:hover { background: var(--ad-white); }
.ad-mega__tab.is-active { background: var(--ad-primary); font-weight: 600; }
.ad-mega__tab.is-active .ad-icon--chevron-right { color: var(--ad-ink); }
.ad-mega__extra { margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--ad-border); }
.ad-mega__extra-link { display: block; padding: 6px 16px; font-size: 15px; font-weight: 500; }
.ad-mega__extra-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.ad-mega__extra-link.is-accent { color: var(--ad-sale); }
.ad-mega__promo { display: flex; flex-direction: column; gap: 16px; margin-top: 12px; padding: 24px; border-radius: var(--ad-radius-lg); background: var(--ad-primary-soft); }
.ad-mega__promo-icon { display: flex; align-items: center; justify-content: center; width: 48px; height: 48px; border-radius: 50%; background: var(--ad-primary); }
.ad-mega__promo-title { font-size: 18px; line-height: 24px; font-weight: 700; }
.ad-mega__promo-text { font-size: 12px; line-height: 16px; color: var(--ad-muted); }
.ad-mega__promo-btn {
  height: 44px; border-radius: var(--ad-radius-md); background: var(--ad-dark) !important; color: var(--ad-white) !important;
  font-weight: 600 !important; transition: background-color .15s ease;
}
.ad-mega__promo-btn:hover { background: var(--ad-ink) !important; }

.ad-mega__panels { background: var(--ad-white); overflow-y: auto; }
.ad-mega__panel { padding: 32px 40px 40px; }
.ad-mega__panel[hidden] { display: none; }
.ad-mega__head { display: flex; align-items: baseline; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.ad-mega__title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; }
.ad-mega__title > span:first-child { font-size: 28px; line-height: 32px; font-weight: 700; }
.ad-mega__meta { font-size: 14px; color: var(--ad-subtle); }
.ad-mega__all { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; font-weight: 600; }
.ad-mega__all:hover { text-decoration: underline; text-underline-offset: 3px; }
.ad-mega__columns { column-count: 4; column-gap: 32px; }
.ad-mega__group { break-inside: avoid; display: flex; flex-direction: column; gap: 4px; padding-bottom: 24px; }
.ad-mega__l2 { font-weight: 700; }
.ad-mega__l2:hover, .ad-mega__l3:hover { color: var(--ad-ink); text-decoration: underline; text-underline-offset: 3px; }
.ad-mega__l3 { display: inline-block; padding: 4px 0; color: var(--ad-muted); }
.ad-mega__count { margin-left: 6px; font-size: 11px; font-weight: 400; color: var(--ad-subtle); }
.ad-mega__more { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; font-size: 12px; font-weight: 700; }
.ad-mega__more:hover { text-decoration: underline; text-underline-offset: 3px; }
.ad-mega__section + .ad-mega__section { margin-top: 8px; padding-top: 24px; border-top: 1px solid var(--ad-border); }
.ad-mega__section-title { margin-bottom: 16px !important; font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ad-subtle); }
.ad-mega__section .ad-mega__columns { margin-bottom: -24px; }
.ad-mega__chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ad-mega__chip {
  display: inline-flex; align-items: center; height: 40px; padding: 0 16px; border: 1px solid var(--ad-border); border-radius: var(--ad-radius-md);
  font-weight: 600; transition: border-color .15s ease, background-color .15s ease;
}
.ad-mega__chip:hover { border-color: var(--ad-primary); background: var(--ad-primary-soft); }
.ad-mega__chip--brand { height: 48px; padding: 0 20px; font-size: 15px; }
.ad-mega__swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 16px; }
.ad-mega__swatch { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border-radius: 22px; transition: background-color .15s ease; }
.ad-mega__swatch:hover { background: var(--ad-surface); }
.ad-mega__swatch-dot {
  flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%; background: var(--ad-surface) center / cover no-repeat;
  box-shadow: inset 0 0 0 1px rgba(28, 34, 42, .12);
}
.ad-mega__swatch-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ad-muted); }
.ad-mega__swatch:hover .ad-mega__swatch-name { color: var(--ad-ink); }
.ad-mega__products { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.ad-mega__product { display: flex; flex-direction: column; gap: 10px; }
.ad-mega__product-media {
  display: flex; align-items: center; justify-content: center; aspect-ratio: 4 / 5; padding: 12px;
  border-radius: var(--ad-radius-md); background: var(--ad-surface); color: var(--ad-subtle); overflow: hidden;
}
.ad-mega__product-media img { display: block; width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; }
.ad-mega__product-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-weight: 500; }
.ad-mega__product:hover .ad-mega__product-title { text-decoration: underline; text-underline-offset: 3px; }
.ad-mega__backdrop { position: fixed; inset: 0; z-index: -1; background: rgba(28, 34, 42, .45); }
.ad-mega__backdrop[hidden] { display: none; }
@keyframes ad-mega-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* мобильное меню */
.ad-drawer { position: fixed; inset: 0; z-index: 1100; }
.ad-drawer[hidden] { display: none; }
.ad-drawer__backdrop { position: absolute; inset: 0; background: rgba(28, 34, 42, .45); }
.ad-drawer__panel {
  position: absolute; top: 0; bottom: 0; left: 0; width: min(380px, calc(100% - 48px));
  display: flex; flex-direction: column; gap: 4px; padding: 12px 16px 24px;
  background: var(--ad-white); overflow-y: auto; overscroll-behavior: contain;
  animation: ad-drawer-in .22s ease-out;
}
.ad-drawer__head { display: flex; align-items: center; justify-content: space-between; padding-bottom: 8px; }
.ad-drawer__title { font-size: 18px; line-height: 24px; font-weight: 700; }
.ad-drawer__section { padding: 16px 12px 6px; font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ad-subtle); }
.ad-drawer__list, .ad-drawer__sub { display: flex; flex-direction: column; gap: 2px; }
.ad-drawer__sub { padding: 2px 0 6px 12px; }
.ad-drawer__item {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 10px 12px; border-radius: var(--ad-radius-sm);
  font-weight: 500; cursor: pointer; list-style: none;
}
.ad-drawer__item::-webkit-details-marker { display: none; }
.ad-drawer__item:hover { background: var(--ad-surface); }
.ad-drawer__item--l1 { font-size: 15px; }
.ad-drawer__item--l3 { color: var(--ad-muted); font-weight: 400; }
.ad-drawer__item--all { font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.ad-drawer__item.is-accent { color: var(--ad-sale); }
.ad-drawer__label { flex: 1; min-width: 0; }
.ad-drawer__count { font-size: 12px; line-height: 16px; color: var(--ad-subtle); font-weight: 400; }
.ad-drawer__item .ad-icon--chevron-down { color: var(--ad-subtle); transition: transform .2s ease; }
.ad-drawer__group[open] > summary { background: var(--ad-surface); font-weight: 600; }
.ad-drawer__group[open] > summary .ad-icon--chevron-down { transform: rotate(180deg); color: var(--ad-ink); }
.ad-drawer__contacts { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; padding: 16px 12px 0; border-top: 1px solid var(--ad-border); }
.ad-drawer__phone { display: inline-flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 600; }
.ad-drawer__phone .ad-icon { color: var(--ad-primary); }
.ad-drawer__schedule { font-size: 12px; color: var(--ad-muted); }
.ad-drawer__measure {
  height: 44px; border-radius: var(--ad-radius-md); background: var(--ad-primary) !important; color: var(--ad-ink) !important; font-weight: 600 !important;
}
@keyframes ad-drawer-in { from { transform: translateX(-100%); } to { transform: none; } }

/* адаптив */
@media (max-width: 1279.98px) {
  .ad-header__container { padding: 0 24px; }
  .ad-header__main-row { gap: 16px; }
  .ad-header__actions { gap: 16px; }
  .ad-mega__columns { column-count: 3; }
}
@media (max-width: 1199.98px) {
  .ad-header__phone { display: none; }
  .ad-header__phone-mobile { display: inline-flex; }
}
@media (max-width: 1023.98px) {
  .ad-header__utility, .ad-header__catalog-btn, .ad-mega, .ad-mega__backdrop { display: none !important; }
  .ad-header__main-row { flex-wrap: wrap; gap: 8px 12px; min-height: 0; padding-top: 10px; padding-bottom: 12px; }
  .ad-header__burger { display: inline-flex; margin-left: -8px; }
  .ad-header__logo { margin-right: auto; }
  .ad-header__logo img { height: 34px; max-width: 150px; }
  .ad-header__action-label { display: none; }
  .ad-header__action { padding: 9px; }
  .ad-header__search { order: 10; flex-basis: 100%; }
}
@media (max-width: 767.98px) {
  .ad-header__container { padding: 0 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .ad-mega, .ad-drawer__panel { animation: none; }
  .ad-header *, .ad-drawer * { transition: none !important; }
}

/* окно заявки из footer.php (z-index: 1 в main.css) должно быть поверх новой шапки */
#overlayModal { z-index: 1150; }
#headerModal.modal { z-index: 1160; }
