/* ===================================================================
   header.responsive.css
   Чистая, предсказуемая адаптация шапки без изменения HTML-порядка
   Подключать ПОСЛЕ текущего /css/header.css (или заменить его).
   =================================================================== */

/* ---------- БАЗОВЫЕ ПЕРЕМЕННЫЕ (необязательные, для консистентности) ---------- */
:root {
  --hdr-max: 1300px; /* базовая ширина контейнера header */
  --ink: #0f172a;
  --ink-muted: #475569;
  --line: #e2e8f0;
  --bg: #ffffff;
  --drop-bg: #ffffff;
  --shadow: 0 6px 24px rgba(2, 6, 23, 0.06), 0 2px 8px rgba(2, 6, 23, 0.04);
  --r-lg: 12px;
  --r-md: 10px;
  --r-sm: 8px;
  --tr: 0.18s ease;
}

/* ---------- БАЗОВАЯ СЕТКА ---------- */
header {
  box-sizing: border-box;
  max-width: var(--hdr-max);
  margin: 20px auto;
  padding: 0 10px;
}
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: relative;
  padding: 10px 16px;
}

/* ЛЕВЫЙ БЛОК: логотип */
.header-left {
  flex: 0 0 auto;
  min-width: 0;
}
.for__header__logotype {
  display: block;
  height: auto;
  max-width: 260px;
  cursor: pointer;
  transition: opacity 0.25s ease;
}
.for__header__logotype:hover {
  opacity: 0.7;
}

/* ЦЕНТР: навигация */
.nav-links.header-center {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  gap: 6px;
}
.header a {
  position: relative;
  margin: 0 10px;
  padding: 5px 0;
  color: #000;
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 2px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size 0.4s ease;
  white-space: nowrap;
}
.header a:hover {
  background-size: 100% 2px;
}

/* DROPDOWN (десктоп) */
.dropdown {
  position: relative;
  display: inline-block;
}
.dropdown-toggle {
  cursor: pointer;
}
.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  min-width: 220px;
  border-radius: var(--r-md);
  background: var(--drop-bg);
  box-shadow: var(--shadow);
  padding: 8px 0;
  z-index: 1002; /* поверх остальных */
  border: 1px solid var(--line);
}
.dropdown-menu a {
  display: block;
  padding: 10px 16px;
  color: var(--ink);
  font-size: 14px;
}
.dropdown-menu a:hover {
  background: #f5f7fb;
}
.dropdown:hover .dropdown-menu,
.dropdown.active .dropdown-menu {
  display: block;
}

/* ПРАВЫЙ БЛОК: поиск + иконки */
.header-right {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.header__block__input__search form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
}
.for__header__search__input {
  width: 280px;
  font-size: 16px;
  line-height: 1.2;
  opacity: 0.85;
  border: 0;
  outline: none;
  background: transparent;
}
.header__block__input__search button {
  background: none;
  border: 0;
  cursor: pointer;
  padding-left: 6px;
  display: inline-flex;
  align-items: center;
}

.header-icons {
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-icons a img,
.header-icons a svg {
  display: block;
}

/* БУРГЕР */
.burger-menu {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  margin-left: 6px;
}
.burger-menu span {
  width: 24px;
  height: 3px;
  background: #000;
  border-radius: 2px;
}

/* МОБИЛЬНОЕ МЕНЮ */
.mobile-nav {
  display: none;
  flex-direction: column;
  position: absolute;
  right: 10px;
  top: 65px;
  width: 220px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 12px;
  box-shadow: var(--shadow);
  z-index: 1001;
}
.mobile-nav a {
  margin: 8px 0;
  color: #000;
  text-decoration: none;
}
.mobile-nav.active {
  display: flex;
}

.mobile-dropdown {
  position: relative;
  width: 100%;
}
.mobile-dropdown-menu {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: #fff;
  border-radius: var(--r-md);
  padding-left: 8px;
  margin-top: 6px;
}
.mobile-dropdown.active .mobile-dropdown-menu {
  display: flex;
}

/* ------------------- ТОЧКИ ЛОМА (много медиа-запросов) ------------------- */

/* 1) Очень маленькие телефоны (до 320px) */
@media (max-width: 319.98px) {
  header {
    padding: 0 6px;
  }
  .header {
    padding: 8px;
    gap: 8px;
  }
  .for__header__logotype {
    max-width: 120px;
    margin-left: 2px;
  }
  .burger-menu {
    display: flex;
  }
  .nav-links,
  .header__block__input__search {
    display: none !important;
  }
  .mobile-nav {
    right: 6px;
    top: 56px;
    width: 180px;
  }
}

/* 2) 320–359 */
@media (min-width: 320px) and (max-width: 359.98px) {
  .for__header__logotype {
    max-width: 130px;
    margin-left: 4px;
  }
  .burger-menu {
    display: flex;
  }
  .burger-menu span {
    width: 18px;
    height: 2px;
  }
  .nav-links,
  .header__block__input__search {
    display: none !important;
  }
  .mobile-nav {
    right: 6px;
    top: 56px;
    width: 190px;
  }
}

/* 3) 360–399 */
@media (min-width: 360px) and (max-width: 399.98px) {
  .for__header__logotype {
    max-width: 140px;
  }
  .burger-menu {
    display: flex;
  }
  .nav-links,
  .header__block__input__search {
    display: none !important;
  }
  .mobile-nav {
    width: 190px;
    top: 58px;
  }
}

/* 4) 400–479 */
@media (min-width: 400px) and (max-width: 479.98px) {
  .for__header__logotype {
    max-width: 150px;
  }
  .burger-menu {
    display: flex;
  }
  .nav-links,
  .header__block__input__search {
    display: none !important;
  }
  .mobile-nav {
    width: 200px;
    top: 58px;
  }
}

/* 5) 480–575 */
@media (min-width: 480px) and (max-width: 575.98px) {
  .for__header__logotype {
    max-width: 160px;
  }
  .burger-menu {
    display: flex;
  }
  .nav-links,
  .header__block__input__search {
    display: none !important;
  }
  .mobile-nav {
    width: 210px;
    top: 60px;
  }
}

/* 6) 576–639 */
@media (min-width: 576px) and (max-width: 639.98px) {
  .for__header__logotype {
    max-width: 170px;
  }
  .burger-menu {
    display: flex;
  }
  .nav-links,
  .header__block__input__search {
    display: none !important;
  }
  .mobile-nav {
    width: 220px;
    top: 60px;
  }
}

/* 7) 640–719 */
@media (min-width: 640px) and (max-width: 719.98px) {
  .for__header__logotype {
    max-width: 180px;
  }
  .burger-menu {
    display: flex;
  }
  .nav-links,
  .header__block__input__search {
    display: none !important;
  }
  .mobile-nav {
    width: 240px;
    top: 62px;
  }
}

/* 8) 720–767 */
@media (min-width: 720px) and (max-width: 767.98px) {
  .for__header__logotype {
    max-width: 190px;
  }
  .burger-menu {
    display: flex;
  }
  .nav-links,
  .header__block__input__search {
    display: none !important;
  }
  .mobile-nav {
    width: 250px;
    top: 62px;
  }
}

/* 9) 768–839 */
@media (min-width: 768px) and (max-width: 839.98px) {
  .for__header__logotype {
    max-width: 190px;
  }
  .burger-menu {
    display: flex;
  }
  .nav-links,
  .header__block__input__search {
    display: none !important;
  }
  .mobile-nav {
    width: 260px;
    top: 62px;
  }
}

/* 10) 840–899 */
@media (min-width: 840px) and (max-width: 899.98px) {
  .for__header__logotype {
    max-width: 200px;
  }
  .burger-menu {
    display: flex;
  }
  .nav-links,
  .header__block__input__search {
    display: none !important;
  }
}

/* 11) 900–959 */
@media (min-width: 900px) and (max-width: 959.98px) {
  .for__header__logotype {
    max-width: 200px;
  }
  .burger-menu {
    display: flex;
  }
  .nav-links,
  .header__block__input__search {
    display: none !important;
  }
}

/* 12) 960–991 */
@media (min-width: 960px) and (max-width: 991.98px) {
  .for__header__logotype {
    max-width: 210px;
  }
  .burger-menu {
    display: flex;
  }
  .nav-links,
  .header__block__input__search {
    display: none !important;
  }
}

/* 13) 992–1023 — включаем уже десктопную навигацию при достаточной ширине */
@media (min-width: 992px) and (max-width: 1023.98px) {
  .for__header__logotype {
    max-width: 200px;
  }
  .nav-links {
    display: flex !important;
  }
  .header__block__input__search {
    display: none !important;
  } /* поиск aún скрыт */
  .burger-menu {
    display: none;
  }
  .nav-links a {
    margin: 0 8px;
    font-size: 14px;
  }
}

/* 14) 1024–1199 */
@media (min-width: 1024px) and (max-width: 1199.98px) {
  .for__header__logotype {
    max-width: 220px;
  }
  .nav-links {
    display: flex !important;
  }
  .header__block__input__search {
    display: flex !important;
  }
  .for__header__search__input {
    width: 220px;
    font-size: 15px;
  }
  .nav-links a {
    margin: 0 8px;
    font-size: 14px;
  }
  .burger-menu {
    display: none;
  }
}

/* 15) 1200–1359 */
@media (min-width: 1200px) and (max-width: 1359.98px) {
  :root {
    --hdr-max: 1300px;
  }
  .for__header__logotype {
    max-width: 240px;
  }
  .for__header__search__input {
    width: 260px;
    font-size: 16px;
  }
  .nav-links a {
    font-size: 15px;
  }
}

/* 16) 1360–1439 */
@media (min-width: 1360px) and (max-width: 1439.98px) {
  :root {
    --hdr-max: 1360px;
  }
  .for__header__logotype {
    max-width: 260px;
  }
  .for__header__search__input {
    width: 300px;
    font-size: 16px;
  }
  .nav-links a {
    font-size: 16px;
  }
}

/* 17) 1440–1599 */
@media (min-width: 1440px) and (max-width: 1599.98px) {
  :root {
    --hdr-max: 1500px;
  }
  .for__header__logotype {
    max-width: 300px;
  }
  .for__header__search__input {
    width: 340px;
    font-size: 18px;
  }
  .nav-links a {
    font-size: 17px;
  }
}

/* 18) 1600–1919 */
@media (min-width: 1600px) and (max-width: 1919.98px) {
  :root {
    --hdr-max: 1600px;
  }
  .for__header__logotype {
    max-width: 320px;
  }
  .for__header__search__input {
    width: 380px;
    font-size: 19px;
  }
  .nav-links a {
    font-size: 18px;
  }
}

/* 19) 1920–2559 */
@media (min-width: 1920px) and (max-width: 2559.98px) {
  :root {
    --hdr-max: 1720px;
  }
  .for__header__logotype {
    max-width: 340px;
  }
  .for__header__search__input {
    width: 420px;
    font-size: 20px;
  }
  .nav-links a {
    font-size: 19px;
  }
}

/* 20) 2560+ */
@media (min-width: 2560px) {
  :root {
    --hdr-max: 1820px;
  }
  .for__header__logotype {
    max-width: 380px;
  }
  .for__header__search__input {
    width: 460px;
    font-size: 21px;
  }
  .nav-links a {
    font-size: 20px;
  }
}

/* ---------- НАВИГАЦИОННЫЕ МЕЛОЧИ И СЛОИ ---------- */
.dropdown,
.dropdown-menu,
.mobile-nav {
  will-change: transform, opacity;
}
.dropdown-menu {
  transform-origin: top left;
}
.dropdown:hover .dropdown-menu {
  animation: ddIn 0.16s var(--tr) both;
}
@keyframes ddIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Укрепляем слои, чтобы dropdown не прятался под мобильным меню и наоборот */
.header {
  z-index: 1000;
}
.dropdown-menu {
  z-index: 1002;
}
.mobile-nav {
  z-index: 1001;
}
