/* Shared mobile menu styles */
.burger {
  display: none;
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  padding: 0;
  position: relative;
  z-index: 1301;
  border-radius: 10px;
  transition: background-color 0.25s ease, transform 0.25s ease;
}

.burger:hover {
  background: rgba(31, 31, 31, 0.06);
}

.burger span {
  position: absolute;
  left: 8px;
  right: 8px;
  height: 3px;
  background: #3b3b3b;
  border-radius: 999px;
  transform-origin: center;
  transition:
    top 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
    transform 0.34s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.2s ease,
    width 0.28s ease,
    left 0.28s ease,
    right 0.28s ease;
}
.burger span:nth-child(1) {
  top: 12px;
}
.burger span:nth-child(2) {
  top: 18px;
}
.burger span:nth-child(3) {
  top: 24px;
}
.burger.active span:nth-child(1) {
  top: 18px;
  transform: rotate(45deg);
}

.burger.active {
  background: rgba(144, 0, 0, 0.08);
  transform: rotate(180deg);
}

.burger.active span {
  background: #900000;
}

.burger.active span:nth-child(2) {
  opacity: 0;
  left: 18px;
  right: 18px;
  transform: scaleX(0);
}
.burger.active span:nth-child(3) {
  top: 18px;
  transform: rotate(-45deg);
}

.mobile-nav {
  position: fixed;
  inset: 0 0 auto auto;
  top: 0;
  right: 0;
  width: 80vw;
  max-width: 360px;
  height: 100vh;
  background: #fff;
  color: #3b3b3b;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.15);
  opacity: 0;
  transform: translateX(104%);
  transition:
    transform 0.42s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.28s ease;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  padding: 16px;
  will-change: transform;
}
.mobile-nav.open {
  opacity: 1;
  transform: translateX(0);
}
.mobile-nav .mobile-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 16px;
}

.mobile-nav .mobile-close {
  display: none;
}
.mobile-nav .mobile-links {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.mobile-nav .mobile-search {
  display: flex;
  gap: 0;
  align-items: center;
  margin: 8px 0 16px;
}
.mobile-nav .mobile-search input {
  flex: 1;
  height: 40px;
  border: 2px solid rgba(59, 59, 59, 1);
  border-right: none;
  border-radius: 10px 0 0 10px;
  padding: 0 10px;
}
.mobile-nav .mobile-search button {
  height: 40px;
  background: #1F1F1F;
  color: #fff;
  border: none;
  padding: 0 14px;
  border-radius: 0 10px 10px 0;
}
.mobile-nav .mobile-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: auto;
}
.mobile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s ease, visibility 0.28s ease;
}
.mobile-overlay.show {
  opacity: 1;
  visibility: visible;
}

.catalog-dropdown {
  position: relative;
  display: inline-flex;
  z-index: 5;
}

.catalog-dropdown .catalog {
  position: relative;
  overflow: hidden;
  transition: background-color 0.25s ease, transform 0.25s ease;
}

.catalog-dropdown .catalog img {
  opacity: 0;
  width: 18px;
}

.catalog-dropdown .catalog::before,
.catalog-dropdown .catalog::after {
  content: "";
  position: absolute;
  left: 1.15rem;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: #fff;
  transform-origin: center;
  transition:
    top 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
    transform 0.34s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.24s ease;
}

.catalog-dropdown .catalog::before {
  top: calc(50% - 6px);
  box-shadow: 0 6px 0 #fff, 0 12px 0 #fff;
}

.catalog-dropdown .catalog::after {
  top: 50%;
  opacity: 0;
}

.catalog-dropdown.open .catalog {
  background: #900000;
}

.catalog-dropdown.open .catalog::before {
  top: 50%;
  transform: rotate(45deg);
  box-shadow: none;
}

.catalog-dropdown.open .catalog::after {
  opacity: 1;
  transform: rotate(-45deg);
}

.catalog-dropdown__menu {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  width: 260px;
  max-height: 60vh;
  overflow: auto;
  padding: 8px;
  border: 2px solid rgba(235, 235, 235, 1);
  border-radius: 10px;
  background: #fff;
  color: #1F1F1F;
  box-shadow: 0 12px 30px rgba(31, 31, 31, 0.14);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.98);
  transform-origin: top left;
  transition:
    opacity 0.28s ease,
    transform 0.34s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0.28s ease;
}

.catalog-dropdown.open .catalog-dropdown__menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.catalog-dropdown__menu a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: #1F1F1F;
  line-height: 1.2;
}

.catalog-dropdown__menu a:hover {
  background: rgba(205, 0, 0, 0.08);
  color: #900000;
}

@media (max-width: 900px) {
  /* hide desktop-only elements where applicable */
  .head2 .search {
    display: none;
  }
  .head2 nav {
    display: none;
  }
  .head2 .catalog {
    display: none;
  }
  .burger {
    display: block;
  }
}

body.menu-open {
  overflow: hidden;
}

/* Общая шапка: фиксируем при прокрутке */
header {
  position: sticky;
  top: 0;
  z-index: 1200;
  background: #fff;
}

header .head2_back {
  background: #fff;
}

/* Бейджи для количества в избранном и корзине */
header a[href="loves.html"],
header a[href="corzina.html"] {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

header a[href="loves.html"] img,
header a[href="corzina.html"] img {
  display: block;
}

.header-counter {
  position: absolute;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: #900000;
  color: #fff;
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
}

header a[href="loves.html"] .header-counter {
  top: -13px;
  right: -10px;
}

header a[href="corzina.html"] .header-counter {
  top: -8px;
  right: -10px;
}

.back-to-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: rgba(31, 31, 31, 0.92);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1300;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 0.25s ease, transform 0.25s ease, background-color 0.2s ease;
}

.back-to-top.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  background: #cd0000;
}
