/* ============================
   Header Block
   ============================ */

/* --- Overlay при открытом mega-menu (как у ОДК) --- */
.header-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgb(255 255 255 / 38%);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.header-overlay--active {
  opacity: 1;
  pointer-events: auto;
}

/* --- Header offset for pages without full-screen hero --- */
body:not([data-hero]) {
  padding-top: 100px; /* 48px top bar + 52px nav bar */
}

@media (max-width: 767px) {
  body:not([data-hero]) {
    padding-top: 88px;
  }
}

/* --- Base: header starts hidden (hero.js controls via header--visible) --- */
.header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 100;
  background: var(--color-white, #ffffff);
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.4s ease, opacity 0.3s ease;
}

.header--visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* --- Container --- */
.header__container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 32px;
}

/* ============================
   Top Bar (Row 1)
   ============================ */
.header__top {
  border-bottom: 1px solid #e5e7eb;
}

.header__top .header__container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
}

/* Logo */
.header__logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}

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

/* Secondary nav */
.header__secondary-nav {
  display: flex;
  align-items: center;
  gap: 22px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.header__secondary-nav a {
  font-family: var(--font-body);
  font-size: 12.5px;
  color: #4b5563;
  text-decoration: none;
  transition: color 0.2s;
  white-space: nowrap;
  position: relative;
}

.header__secondary-nav a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background: #182d97;
  transition: width 0.3s ease;
}

.header__secondary-nav a:hover::after {
  width: 100%;
}

.header__secondary-nav a:hover {
  color: var(--color-primary, #182d97);
}

/* ============================
   Main Nav (Row 2)
   ============================ */
.header__main {
  border-bottom: 2.5px solid var(--color-primary, #182d97);
}

.header__main .header__container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
}

/* Main menu */
.header__menu {
  display: flex;
  align-items: center;
  gap: 0;
  list-style: none;
  margin: 0;
  padding: 0;
}

.header__menu-item {
  position: relative;
}

/* Первый пункт нижнего меню — выровнять по левому краю лого */
.header__menu-item:first-child .header__menu-link {
  padding-left: 0;
}

.header__menu-link {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 20px;
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  color: #374151;
  text-decoration: none;
  border: none;
  background: none;
  cursor: pointer;
  transition: color 0.2s;
  white-space: nowrap;
  position: relative;
  margin-bottom: -2.5px;
}

/* Подчёркивание при hover (как у severstalssc.com) */
.header__menu-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20px;
  right: 20px;
  height: 2.5px;
  background: #182d97;
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.header__menu-item:first-child .header__menu-link::after {
  left: 0;
}

.header__menu-link:hover::after,
.header__menu-link--active::after {
  transform: scaleX(1);
}

.header__menu-link:hover,
.header__menu-link--active {
  color: var(--color-primary, #182d97);
}

/* Chevron */
.header__chevron {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
  transform-origin: center center;
}

.header__menu-link--active .header__chevron {
  transform: rotate(180deg);
}

/* Right side: phone + CTA */
.header__right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.header__phone {
  text-align: right;
  text-decoration: none;
  display: block;
}

.header__phone-number {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  color: var(--color-bg-dark, #0a275d);
  display: block;
}

.header__phone-hours {
  font-family: var(--font-body);
  font-size: 11px;
  color: #6b7280;
  display: block;
  margin-top: 1px;
}

.header__cta {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: #ffffff;
  background: var(--color-accent, #9b1515);
  padding: 9px 22px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
  white-space: nowrap;
}

.header__cta:hover {
  background: #7a1010;
}

/* ============================
   Mega-menu
   ============================ */
.header__mega {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  opacity: 0;
  transform: translateY(-8px);
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease, visibility 0s 0.35s;
  z-index: 99;
}

/* Anchor mega-menu to header, not menu-item */
.header__main {
  position: relative;
}

.header__mega--open {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.35s ease, transform 0.35s ease, visibility 0s 0s;
}

.header__mega-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
}

/* Left column — categories */
.header__mega-left {
  width: 260px;
  flex-shrink: 0;
  background: #f8f9fb;
  border-right: 1px solid #e5e7eb;
  padding: 16px 0;
}

.header__mega-category {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 20px 13px 16px;
  width: 100%;
  border: none;
  background: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 14px;
  color: #374151;
  text-align: left;
  border-left: 3px solid transparent;
  transition: border-color 0.3s ease, background-color 0.2s ease, color 0.15s;
}

.header__mega-category:hover,
.header__mega-category--active {
  border-left-color: var(--color-accent, #9b1515);
  background: #ffffff;
  color: var(--color-primary, #182d97);
  font-weight: 500;
}

.header__mega-category--active .header__mega-icon {
  background: #eef1f8;
}

.header__mega-icon {
  width: 28px;
  height: 28px;
  background: #f3f4f6;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

.header__mega-icon svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.header__mega-category-text {
  flex: 1;
}

.header__mega-arrow {
  color: #9ca3af;
  font-size: 14px;
  flex-shrink: 0;
}

/* Right column — subcategories */
.header__mega-right {
  flex: 1;
  padding: 20px 32px;
}

.header__mega-title {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  color: var(--color-accent, #9b1515);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0 0 12px 0;
}

.header__mega-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 40px;
}

.header__mega-links a {
  font-family: var(--font-body);
  font-size: 14px;
  color: #374151;
  text-decoration: none;
  padding: 8px 0;
  transition: color 0.15s;
}

.header__mega-links a:hover {
  color: var(--color-primary, #182d97);
}

.header__mega-footer {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
}

.header__mega-footer a {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-primary, #182d97);
  text-decoration: none;
  transition: opacity 0.15s;
}

.header__mega-footer a:hover {
  opacity: 0.8;
}

/* Sub-panel: only show active */
.header__mega-panel {
  display: none;
}

.header__mega-panel--active {
  display: block;
}

/* ============================
   Burger button
   ============================ */
.header__burger {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  position: relative;
}

.header__burger-line {
  display: block;
  width: 22px;
  height: 2px;
  background: #374151;
  border-radius: 1px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.header__burger-line::before,
.header__burger-line::after {
  content: '';
  display: block;
  width: 22px;
  height: 2px;
  background: #374151;
  border-radius: 1px;
  position: absolute;
  left: 9px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.header__burger-line::before {
  top: 11px;
}

.header__burger-line::after {
  bottom: 11px;
}

/* Cross state */
.header__burger--open .header__burger-line {
  background: transparent;
}

.header__burger--open .header__burger-line::before {
  top: 19px;
  transform: rotate(45deg);
}

.header__burger--open .header__burger-line::after {
  bottom: 19px;
  transform: rotate(-45deg);
}

/* ============================
   Mobile menu
   ============================ */
/* Mobile menu lives in body (not inside header) to avoid transform+fixed conflict */
.header__mobile-menu {
  position: fixed;
  top: 48px; /* height of top bar */
  left: 0;
  right: 0;
  bottom: 0;
  background: #ffffff;
  z-index: 99;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  -webkit-overflow-scrolling: touch;
}

.header__mobile-menu--open {
  transform: translateX(0);
}

/* Mobile menu items */
.header__mobile-section {
  border-bottom: 1px solid #f3f4f6;
}

.header__mobile-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  font-family: var(--font-body);
  font-size: 15px;
  color: #374151;
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  cursor: pointer;
  text-align: left;
}

.header__mobile-link:hover {
  background: #f9fafb;
}

.header__mobile-chevron {
  width: 14px;
  height: 14px;
  transition: transform 0.2s;
  color: #9ca3af;
}

.header__mobile-link--open .header__mobile-chevron {
  transform: rotate(180deg);
  color: var(--color-primary, #182d97);
}

.header__mobile-link--open {
  color: var(--color-primary, #182d97);
  border-left: 3px solid var(--color-accent, #9b1515);
}

/* Mobile accordion content */
.header__mobile-accordion {
  display: none;
  background: #f9fafb;
}

.header__mobile-accordion--open {
  display: block;
}

.header__mobile-cat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px 10px 24px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  border: none;
  background: none;
  width: 100%;
  cursor: pointer;
  text-align: left;
  border-bottom: 1px solid #f3f4f6;
}

.header__mobile-cat--open {
  color: var(--color-primary, #182d97);
  border-left: 3px solid var(--color-accent, #9b1515);
}

.header__mobile-sub {
  display: none;
  padding: 0;
}

.header__mobile-sub--open {
  display: block;
}

.header__mobile-sub a {
  display: block;
  padding: 8px 16px 8px 48px;
  font-family: var(--font-body);
  font-size: 13px;
  color: #4b5563;
  text-decoration: none;
  transition: color 0.15s;
}

.header__mobile-sub a:hover {
  color: var(--color-primary, #182d97);
  background: #f3f4f6;
}

/* Mobile separator */
.header__mobile-separator {
  border-top: 2px solid #e5e7eb;
  margin-top: 8px;
}

/* Mobile secondary links */
.header__mobile-secondary a {
  display: block;
  padding: 12px 16px;
  font-family: var(--font-body);
  font-size: 14px;
  color: #4b5563;
  text-decoration: none;
  border-bottom: 1px solid #f3f4f6;
}

.header__mobile-secondary a:hover {
  color: var(--color-primary, #182d97);
  background: #f9fafb;
}

/* Mobile footer */
.header__mobile-footer {
  padding: 16px;
  border-top: 2px solid #e5e7eb;
  margin-top: 8px;
}

.header__mobile-phone {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 500;
  color: var(--color-bg-dark, #0a275d);
  text-decoration: none;
  display: block;
  margin-bottom: 4px;
}

.header__mobile-hours {
  font-family: var(--font-body);
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 12px;
}

.header__mobile-cta {
  display: block;
  width: 100%;
  text-align: center;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  color: #ffffff;
  background: var(--color-accent, #9b1515);
  padding: 12px 22px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
}

.header__mobile-cta:hover {
  background: #7a1010;
}

/* ============================
   Responsive
   ============================ */
@media (max-width: 1023px) {
  .header__container {
    padding: 0 16px;
  }

  .header__secondary-nav,
  .header__main,
  .header__mega {
    display: none;
  }

  .header__burger {
    display: flex;
  }

  .header__top .header__container {
    height: 48px;
  }
}

@media (min-width: 1024px) {
  .header__mobile-menu {
    display: none !important;
  }

  .header__burger {
    display: none !important;
  }
}

@media (max-width: 1200px) and (min-width: 1024px) {
  .header__phone {
    display: none;
  }

  .header__menu-link {
    padding: 14px 14px;
    font-size: 13px;
  }
}
