/* Header, mega-menu, footer — Metalvis structure */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-header-bg);
  box-shadow: 0 1px 0 var(--color-border);
  padding-top: var(--safe-top);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.header-top {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 42px;
  padding: 8px 16px;
  background: var(--color-header-top-bg);
  color: var(--color-header-top-text);
  font-size: 13px;
  line-height: 1.35;
}

.header-top a {
  color: var(--color-header-top-text);
  opacity: 0.92;
  margin-left: 14px;
  white-space: nowrap;
}

.header-top a:hover {
  opacity: 1;
  text-decoration: underline;
}

.header-top__hours {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 0;
}

.header-top__hours > span:not(.header-top__sep) {
  white-space: nowrap;
}

.header-top__sep {
  display: inline-block;
  width: 1px;
  height: 14px;
  margin: 0 12px;
  background: rgba(255, 255, 255, 0.45);
  vertical-align: middle;
}

.header-bottom {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  min-height: 56px;
}

.header-bottom--relative {
  max-width: none;
  position: relative;
}

.logo-block {
  display: flex;
  flex: 0 0 auto;
  max-width: min(160px, 46vw);
  background: var(--color-logo-bg);
  align-items: center;
  justify-content: center;
  padding: 8px 14px 8px 10px;
  min-height: 42px;
  border-radius: var(--radius-sm);
  overflow: visible;
}

.logo-block img {
  max-height: 32px;
  width: auto;
  height: auto;
  display: block;
}

.logo-block__text {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 22px;
  color: #fff;
  letter-spacing: 0.02em;
}

.mobile-toggle {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border: 0;
  background: var(--color-primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  border-radius: var(--radius);
  -webkit-appearance: none;
}

.header-search-cluster {
  flex: 1 1 auto;
  display: flex;
  align-items: stretch;
  min-width: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: #fff;
  overflow: visible;
  position: relative;
}

.search-form {
  flex: 1 1 auto;
  display: flex;
  min-width: 0;
  position: relative;
}

.search-form input {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 44px 0 12px;
  border: 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  background: transparent;
}

.search-form button {
  position: absolute;
  right: 0;
  top: 0;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  -webkit-appearance: none;
  appearance: none;
}

.search-form button svg {
  display: block;
  flex-shrink: 0;
}

.search-suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 120;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  max-height: 320px;
  overflow: auto;
  display: none;
}

.search-suggest.is-open {
  display: block;
}

.search-suggest a {
  display: block;
  padding: 8px 12px;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
}

.search-suggest a:hover {
  background: var(--color-bg);
  text-decoration: none;
}

.catalog-btn {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 16px;
  background: var(--color-catalog-btn);
  color: var(--color-catalog-btn-text);
  border: 0;
  border-right: 1px solid color-mix(in srgb, var(--color-catalog-btn) 70%, #000);
  border-radius: var(--radius) 0 0 var(--radius);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  -webkit-appearance: none;
  flex: 0 0 auto;
}

.catalog-btn__icon {
  font-size: 16px;
  line-height: 1;
}

.catalog-btn:hover {
  filter: brightness(0.96);
}

.action-menu {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.action-menu--header {
  display: none;
}

.action-link {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  padding: 4px;
  color: var(--color-secondary);
  text-decoration: none;
  font-size: 10px;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

.action-link:hover {
  color: var(--color-primary);
  text-decoration: none;
}

.action-link__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  line-height: 1;
}

.action-link__icon svg {
  display: block;
  width: 20px;
  height: 20px;
}

.action-menu--header .action-link__label {
  position: absolute;
  left: 50%;
  top: calc(100% - 2px);
  transform: translateX(-50%) translateY(4px);
  padding: 3px 6px;
  border-radius: 4px;
  background: var(--color-secondary);
  color: #fff;
  font-size: 10px;
  line-height: 1.2;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, visibility 0.15s ease, transform 0.15s ease;
  z-index: 5;
}

.action-menu--header .action-link:hover .action-link__label,
.action-menu--header .action-link:focus-visible .action-link__label {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.action-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--radius-pill);
  background: var(--color-danger);
  color: #fff;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
  font-weight: 700;
}

.mega-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 90;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease;
}

.mega-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.mega-menu {
  --mega-height: min(70vh, 560px);
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 110;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  display: none;
  height: var(--mega-height);
  max-height: var(--mega-height);
  overflow: hidden;
}

.mega-menu.is-open {
  display: block;
}

.mega-menu__inner {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100%;
  max-height: 100%;
  min-height: 0;
}

.mega-l1-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
  background: color-mix(in srgb, var(--color-bg) 70%, #fff);
  border-right: 1px solid var(--color-border);
}

.mega-l1 {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.mega-l1__item--extra {
  display: none;
}

.mega-menu.is-expanded .mega-l1__item--extra {
  display: list-item;
}

.mega-l1__item > button,
.mega-l1__item > a.mega-l1__link {
  display: flex;
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  border: 0;
  background: transparent;
  color: var(--color-text);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  text-decoration: none;
  border-bottom: 1px solid var(--color-border);
}

.mega-l1__item.is-active > button,
.mega-l1__item > button:hover {
  background: var(--color-surface);
  color: var(--color-primary-dark);
}

.mega-l1__more {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: 0 0 auto;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border: 0;
  border-top: 1px solid var(--color-border);
  background: color-mix(in srgb, var(--color-primary) 12%, #fff);
  color: var(--color-primary-dark);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  position: relative;
  z-index: 2;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.06);
}

.mega-l1__more:hover,
.mega-l1__more:focus-visible {
  background: color-mix(in srgb, var(--color-primary) 20%, #fff);
  outline: none;
}

.mega-l1__more-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.mega-menu.is-expanded .mega-l1__more-icon {
  transform: rotate(45deg);
}

.mega-panels {
  padding: 16px 20px;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.mega-panel {
  display: none;
}

.mega-panel.is-active {
  display: block;
}

.mega-panel__title {
  margin: 0 0 12px;
  font-size: 16px;
  text-transform: uppercase;
}

.mega-panel__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px 20px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.mega-panel__grid a {
  color: var(--color-text);
  font-size: 14px;
}

.mega-panel__grid a:hover {
  color: var(--color-primary);
}

.mobile-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(88vw, 360px);
  z-index: 130;
  background: var(--color-surface);
  transform: translateX(-105%);
  transition: transform 0.3s var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1));
  padding: calc(12px + var(--safe-top)) 0 calc(16px + var(--safe-bottom));
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}

.mobile-drawer.is-open {
  transform: translateX(0);
}

.mobile-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 12px;
  border-bottom: 1px solid var(--color-border);
}

.mobile-drawer__actions {
  display: flex;
  justify-content: space-around;
  gap: 4px;
  padding: 12px 10px;
  border-bottom: 1px solid var(--color-border);
}

.mobile-drawer__actions .action-link {
  flex: 1 1 0;
  min-width: 0;
  max-width: 96px;
}

.mobile-drawer__actions .action-link__label {
  display: block;
  position: static;
  transform: none;
  padding: 0;
  background: transparent;
  color: inherit;
  opacity: 1;
  visibility: visible;
  font-size: 11px;
}

.mobile-drawer nav a {
  display: block;
  padding: 12px 16px;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
  text-decoration: none;
}

.mobile-drawer details {
  border-bottom: 1px solid var(--color-border);
}

.mobile-drawer summary {
  padding: 12px 16px;
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 13px;
  cursor: pointer;
  list-style: none;
}

.mobile-drawer summary::-webkit-details-marker {
  display: none;
}

.mobile-drawer details a {
  padding-left: 28px;
  font-size: 14px;
}

.scroll-top {
  position: fixed;
  right: max(16px, var(--safe-right));
  bottom: max(20px, var(--safe-bottom));
  z-index: 80;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px) scale(0.92);
  transition:
    opacity 0.25s var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1)),
    transform 0.25s var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1)),
    visibility 0.25s,
    box-shadow 0.2s ease;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
  cursor: pointer;
}

.scroll-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.scroll-top.is-visible:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
}

.scroll-top.is-visible:active {
  transform: translateY(0) scale(1);
}

@media (min-width: 768px) {
  .header-top {
    display: flex;
  }

  .logo-block {
    max-width: 176px;
    min-height: 44px;
  }

  .logo-block img {
    max-height: 36px;
  }
}

@media (min-width: 992px) {
  .mobile-toggle {
    display: none;
  }

  .logo-block {
    flex: 0 0 220px;
    max-width: none;
    padding: 8px 16px 8px 12px;
    min-height: 52px;
  }

  .logo-block img {
    max-height: 40px;
  }

  .catalog-btn {
    display: inline-flex;
  }

  .action-menu--header {
    display: flex;
    gap: 4px;
  }

  .header-bottom {
    padding: 6px 16px;
    gap: 12px;
    min-height: 52px;
  }
}

@media (max-width: 991px) {
  .header-bottom {
    gap: 8px;
    padding: 6px 10px;
    min-height: 52px;
  }

  .search-form input {
    height: 40px;
    font-size: 16px; /* iOS Safari: без zoom при фокусі */
  }

  .search-form button {
    width: 40px;
    height: 40px;
  }

  .mobile-toggle {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    margin-left: auto;
  }

  .mega-menu__inner {
    grid-template-columns: 1fr;
  }

  .mega-l1-wrap {
    display: none;
  }

  .mega-panel {
    display: block;
    margin-bottom: 20px;
  }
}
