/* =================== hc-hdr.css =================== */
/* hc-hdr — sticky site header (the one shown on every page).
   Owns: header bar, brand logo, primary nav, mega-panel under "Каталог",
   right-rail icons with their badges and tooltips, phone link, CTA button,
   and the responsive collapse to burger ≤1024px. The drawer that the burger
   opens lives in its own block (hc-mobile-menu). Strictly .hc-hdr*. */

.hc-hdr {
position: sticky;
  top: 0;
  z-index: var(--hc-z-header);
  height: var(--hc-hdr-h);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--hc-dur-base), background var(--hc-dur-base), box-shadow var(--hc-dur-base);
}
.hc-hdr__in {
display: flex;
  align-items: center;
  gap: var(--hc-sp-4);
  min-width: 0;
  min-height: var(--hc-hdr-h);
  padding: var(--hc-sp-3) 0;
}
.hc-hdr__logo {
font-family: var(--hc-serif);
  font-size: var(--hc-fs-xl);
  font-weight: 500;
  color: var(--hc-ink);
  letter-spacing: var(--hc-ls-tight);
  white-space: nowrap;
  flex-shrink: 0;
}
.hc-hdr__logo b {
color: var(--hc-accent);
  font-weight: 500;
}

/* burger — hidden on desktop, shown ≤1024 (see @media block below). */
.hc-hdr__burger {
display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  background: transparent;
  border: 0.5px solid rgba(141, 109, 71, 0.18);
  border-radius: var(--hc-r-sm, 6px);
  color: var(--hc-ink, #1a1714);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.hc-hdr__burger:hover {
background: rgba(212, 184, 150, 0.10);
  border-color: rgba(141, 109, 71, 0.35);
}

/* primary nav */
.hc-hdr__nav {
display: flex;
  align-items: center;
  /* Never shrink: a shrinking nav let its nowrap links bleed under the icon
     rail (search icon landed on "Контакты"). Fixed width = links can't overlap;
     when the bar runs out of room the right rail collapses via breakpoints. */
  flex: 0 0 auto;
  gap: var(--hc-sp-1);
  margin: 0 0 0 var(--hc-sp-3);
  min-width: 0;
}
.hc-hdr__mega {
display: flex;
  align-items: center;
  position: relative;
}
.hc-hdr__link {
display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 37px;
  padding: var(--hc-sp-2) var(--hc-sp-3);
  border-radius: var(--hc-r-pill);
  font-size: var(--hc-fs-md);
  line-height: 1;
  white-space: nowrap;
  color: var(--hc-ink-soft);
  transition: color var(--hc-dur-fast), background var(--hc-dur-fast);
}
.hc-hdr__link:hover, .hc-hdr__link--active {
color: var(--hc-ink);
  background: var(--hc-accent-soft);
}

/* mega-panel — drops below "Каталог". Closed by default; opens on hover
   or when the trigger gets .hc-hdr__mega--open. No: closed-state
   selector is more specific than open-state, but we order rules so open wins. */
.hc-hdr__mega-panel {
position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 720px;
  max-height: min(78vh, 660px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--hc-sp-5);
  background: var(--hc-paper);
  border: 1px solid var(--hc-line);
  border-radius: var(--hc-r-lg);
  box-shadow: var(--hc-sh-3);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity var(--hc-dur-base), visibility var(--hc-dur-base), transform var(--hc-dur-base);
}
.hc-hdr__mega-panel.hc-hdr__mega--open {
opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
/* transparent hover-bridge over the 6px gap between trigger and panel, so
   moving the cursor down into the menu doesn't cross dead space and close it. */
.hc-hdr__mega-panel::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -10px;
  height: 10px;
}
.hc-hdr__mega-grid {
display: grid;
  grid-template-columns: minmax(720px, 1fr) 252px;
  gap: var(--hc-sp-4);
  min-width: 1000px;
}
.hc-hdr__mega-cats {
display: grid;
  grid-template-columns: 1fr 188px;
  gap: 24px;
  align-items: start;
}
/* left: categories WITH subcategories (2-up rich cards) */
.hc-hdr__mega-cats-rich {
  /* Multicol, not a 2-up grid: categories have wildly different sub-counts,
     so a grid left ragged row-gaps (the "кривой" look). Multicol flows the
     cards down each column and balances them. */
  column-count: 2;
  column-gap: 22px;
  min-width: 0;
}
/* right: categories WITHOUT subcategories (compact link column) */
.hc-hdr__mega-cats-plain {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 168px;
  padding-left: 20px;
  border-left: 1px solid var(--hc-line);
}
.hc-hdr__mega-plain-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--hc-ink-muted, rgba(26, 23, 20, 0.4));
  margin-bottom: 6px;
}
.hc-hdr__mega-plain-link {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--hc-r-md, 8px);
  text-decoration: none;
  color: var(--hc-ink, #1a1714);
  transition: background var(--hc-dur-fast), color var(--hc-dur-fast);
}
.hc-hdr__mega-plain-link:hover {
  background: var(--hc-accent-soft);
}
.hc-hdr__mega-plain-name {
  font-size: var(--hc-fs-md, 14px);
  font-weight: 500;
  line-height: 1.28;
  min-width: 0;
  overflow-wrap: anywhere;
}
.hc-hdr__mega-thumb--sm {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}
.hc-hdr__mega-cat {
display: flex;
  flex-direction: column;
  gap: 5px;
  break-inside: avoid;
  margin-bottom: 18px;
}
.hc-hdr__mega-cat-head {
  display: grid;
  grid-template-columns: 40px 1fr;
  align-items: center;
  gap: 10px;
  color: var(--hc-ink);
  text-decoration: none;
}
.hc-hdr__mega-cat-name {
  font-family: var(--hc-serif, "Playfair Display", Georgia, serif);
  font-weight: 500;
  font-size: 14.5px;
  line-height: 1.12;
}
.hc-hdr__mega-cat-head:hover .hc-hdr__mega-cat-name {
  color: var(--hc-accent-dark, #7a6548);
}
.hc-hdr__mega-subs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  padding-left: 50px;
}
.hc-hdr__mega-sub {
  font-size: 12px;
  line-height: 1.55;
  color: var(--hc-ink-soft, rgba(26, 23, 20, 0.62));
  text-decoration: none;
  white-space: normal;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.hc-hdr__mega-sub:hover {
  color: var(--hc-accent-dark, #7a6548);
}
.hc-hdr__mega-sub--more {
  color: var(--hc-accent, #8b7355);
  font-weight: 500;
}
.hc-hdr__mega-thumb {
width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  background: #f0ece7;
  border: 1px solid var(--hc-line);
}
.hc-hdr__mega-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* category covers are drawn at 55% inner-scale for the big cards; zoom the
     icon in the 40px mega thumb so it reads (transparent margins are clipped). */
  transform: scale(1.5);
}
.hc-hdr__mega-banner-wrap {
display: flex;
}
.hc-hdr__mega-banner {
position: relative;
  display: block;
  width: 280px;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--hc-line);
}
.hc-hdr__mega-banner img {
width: 100%;
  height: 100%;
  object-fit: cover;
}
.hc-hdr__mega-banner-text {
position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  display: grid;
  gap: 2px;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,.45);
}

/* right-rail: icons, badges, phone, CTA */
.hc-hdr__right {
margin-left: auto;
  display: flex;
  align-items: center;
  flex: 0 1 auto;
  gap: var(--hc-sp-3);
  min-width: 0;
  max-width: 100%;
}
.hc-hdr__phone {
font-family: var(--hc-serif);
  font-size: var(--hc-fs-md);
  color: var(--hc-ink);
  margin: 0 0 0 var(--hc-sp-2);
  padding-left: var(--hc-sp-4);
  border-left: 1px solid var(--hc-line);
  white-space: nowrap;
}
.hc-hdr__ico {
position: relative;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 0;
  border-radius: var(--hc-r-sm);
  background: transparent;
  color: var(--hc-ink, #1a1714);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.hc-hdr__ico:hover {
background: rgba(212, 184, 150, 0.10);
  color: var(--hc-accent-dark, #7a6548);
}
.hc-hdr__badge {
position: absolute;
  top: -6px;
  right: -6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--hc-accent);
  color: var(--hc-paper, #ffffff);
  border-radius: var(--hc-r-pill);
  font-size: 10px;
  font-weight: 600;
  box-shadow: 0 0 0 2px var(--hc-paper);
}
/* hide the badge when count is zero — JS sets data-count / data-cart-count */
.hc-hdr [data-count="0"] .hc-hdr__count, .hc-hdr [data-cart-count="0"] {
display: none;
}

/* tooltip on icon buttons that carry an aria-label */
.hc-hdr__icon-btn, .hc-hdr__nav a[aria-label] {
position: relative;
}
.hc-hdr__icon-btn[aria-label]:hover::after, .hc-hdr__nav a[aria-label]:hover::after {
content: attr(aria-label);
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 10px;
  background: var(--hc-ink, #1a1714);
  color: var(--hc-paper, #ffffff);
  font: 500 11px/1 var(--hc-sans, "Outfit", sans-serif);
  white-space: nowrap;
  border-radius: 6px;
  z-index: 100;
  pointer-events: none;
}

/* ≤1024px: collapse desktop nav, surface burger, drop phone + CTA so only
   the essential icons + cart stay in the right rail. Burger toggles
   .hc-mobile-menu (own block). */
/* Drop the CTA, then the phone, well before the rail can crowd the nav. */
@media (max-width: 1560px) {
  .hc-hdr__right .hc-btn { display: none; }
}

@media (max-width: 1440px) {
  .hc-hdr__phone { display: none; }
}

@media (max-width: 1280px) {
  .hc-hdr__link { padding-left: var(--hc-sp-2); padding-right: var(--hc-sp-2); }
  .hc-hdr__nav { gap: 2px; }
}

@media (max-width: 1024px) {
  .hc-hdr__burger { display: inline-flex; }
  .hc-hdr__nav    { display: none; }
  .hc-hdr__phone  { display: none; }
  .hc-hdr__right .hc-btn { display: none; }
  .hc-hdr__right { gap: var(--hc-sp-1); }
}

/* ≤480px: tighten the bar so a small viewport doesn't crush the logo. */
@media (max-width: 480px) {
  .hc-hdr__in   { gap: var(--hc-sp-2); }
  .hc-hdr__logo { font-size: var(--hc-fs-lg); }
  /* v8.6 — at ≤420px the four-icon right-rail used to spill past edge by ~12px.
     Shrink icons to 32px and zero out gap so all four still fit inside 375px. */
  .hc-hdr__right { gap: 0; }
  .hc-hdr__ico { width: 32px; height: 32px; }
}

.hc-hdr__mega:hover .hc-hdr__mega-panel {
opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Header CTA must never shrink below its text — flex right-rail was squeezing
   ".hc-btn" (overflow:hidden) and clipping "Подобрать материал →" on both ends. */
.hc-hdr__right .hc-btn { flex-shrink: 0; }
