/* Mega-menu — навигация с выпадающими разделами (рамка + жирный текст) */
.megamenu {
  position: relative;
  background: var(--surface, #fff);
  border: 2px solid var(--accent, #b8651a);
  border-radius: 6px;
  margin: 10px 16px;
  z-index: 50;
  box-shadow: 0 4px 16px rgba(184,101,26,0.10);
}
.topbar__inner--minimal {
  justify-content: space-between;
}
.topbar__inner--minimal .lang-switch { margin-left: auto; }
.megamenu__inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0;
  display: flex;
  align-items: stretch;
  gap: 0;
  font-family: var(--font-display, system-ui);
}
.megamenu__item {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

/* Sticky header: logo + language + menu всегда сверху при прокрутке */
header.topbar { position: sticky; top: 0; z-index: 1100; background: #fff5e6; }
nav.megamenu { position: sticky; top: 64px; z-index: 1099; background: #fff5e6; border-top: 2px solid var(--accent, #b8651a); }
.megamenu__btn {
  font-size: 13px;
  padding: 16px 10px;
  letter-spacing: 0;
}
@media (min-width: 1100px) {
  .megamenu__btn { font-size: 14px; padding: 16px 14px; }
}
@media (min-width: 1300px) {
  .megamenu__btn { font-size: 15px; padding: 16px 18px; }
}
.megamenu__btn {
  appearance: none;
  background: transparent;
  border: 0;
  border-right: 1px solid rgba(184,101,26,0.20);
  padding: 16px 18px;
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  color: #000;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  width: 100%;
  text-transform: none;
  letter-spacing: 0.01em;
  transition: color .15s ease, background .15s ease;
}
.megamenu__item:last-child .megamenu__btn { border-right: 0; }
.megamenu__btn:hover,
.megamenu__btn[aria-expanded="true"] {
  color: #000;
  background: rgba(184,101,26,0.10);
  border-radius: 4px;
}
.megamenu__caret {
  display: inline-block;
  font-size: 20px;
  font-weight: 800;
  color: #000;
  margin-left: 4px;
  transition: transform .15s ease;
  line-height: 1;
}
.megamenu__btn[aria-expanded="true"] .megamenu__caret { transform: rotate(45deg); }

.megamenu__btn--home {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #000;
}
.megamenu__btn--home:hover { color: #000; background: rgba(184,101,26,0.10); }
.megamenu__item--home .megamenu__btn { padding: 16px 18px; }

.megamenu__panel {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 280px;
  background: #fff;
  border: 2px solid var(--accent, #b8651a);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 12px 28px rgba(184,101,26,0.18);
  padding: 8px;
  display: none;
  z-index: 60;
}
.megamenu__item--right .megamenu__panel { left: auto; right: 0; }
.megamenu__item--wide .megamenu__panel { min-width: 360px; }
.megamenu__item.is-open .megamenu__panel { display: block; }

.megamenu__link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border: 2px solid #1a1a1a;
  border-radius: 6px;
  background: #fff;
  color: #000;
  text-decoration: none;
  font-size: 14px;
  font-weight: 800;
  transition: background .15s ease, color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.megamenu__link:hover,
.megamenu__link:focus-visible {
  background: #b8651a;
  color: #fff;
  border-color: #1a1a1a;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(184,101,26,0.30);
}
.megamenu__link:hover .megamenu__count {
  background: #fff;
  color: #b8651a;
}
.megamenu__count {
  font-size: 13px;
  font-weight: 800;
  color: var(--accent, #b8651a);
  background: rgba(184,101,26,0.10);
  padding: 2px 10px;
  border-radius: 999px;
}
.megamenu__link:hover .megamenu__count {
  background: var(--accent, #b8651a);
  color: #fff;
}
.megamenu__link--strong { color: var(--accent, #b8651a); font-weight: 800; }
.megamenu__divider {
  height: 1px;
  margin: 6px 8px;
  background: rgba(184,101,26,0.25);
}

/* Archive nested list (year → months) */
.megamenu__year {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  border: 2px solid #1a1a1a;
  border-radius: 6px;
  background: #fff;
  color: #000;
  list-style: none;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.megamenu__year::-webkit-details-marker { display: none; }
.megamenu__year:hover,
.megamenu__year:focus-visible { background: #b8651a; color: #fff; border-color: #1a1a1a; transform: translateY(-1px); }
.megamenu__year:hover .megamenu__year-total { background: #fff; color: #b8651a; }
.megamenu__year-total {
  font-size: 12px;
  font-weight: 800;
  color: var(--accent);
  background: rgba(184,101,26,0.10);
  padding: 2px 8px;
  border-radius: 999px;
}
.megamenu__months {
  padding: 0 0 8px 18px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px 4px;
}
.megamenu__month {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  border: 2px solid #1a1a1a;
  border-radius: 6px;
  background: #fff;
  color: #000;
  text-decoration: none;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.megamenu__month:hover,
.megamenu__month:focus-visible {
  background: #b8651a;
  color: #fff;
  border-color: #1a1a1a;
  transform: translateY(-1px);
}
.megamenu__month:hover .megamenu__month-count {
  background: #fff;
  color: #b8651a;
}
.megamenu__month-count {
  font-size: 11px;
  color: var(--accent);
  font-weight: 800;
  background: rgba(184,101,26,0.08);
  padding: 1px 6px;
  border-radius: 999px;
}

/* Mobile: hide desktop, show accordion */
@media (max-width: 980px) {
  /* На мобиле megamenu скрыт по умолчанию — открывается только по клику на hamburger */
  .megamenu {
    display: none;
    margin: 8px 8px;
    position: fixed;
    top: 56px;
    left: 8px;
    right: 8px;
    z-index: 70;
    max-height: calc(100vh - 70px);
    overflow-y: auto;
    background: #fff5e6;
    border: 2px solid var(--accent, #b8651a);
    border-radius: 6px;
    box-shadow: 0 12px 28px rgba(0,0,0,0.20);
  }
  body.megamenu-mobile-open .megamenu { display: block; }
  body.megamenu-mobile-open::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.40);
    z-index: 55;  /* под панелью мегаменю (70) но над страницей */
    pointer-events: none;
  }
  .megamenu__inner { flex-direction: column; padding: 0; }
  .megamenu__btn {
    width: 100%;
    justify-content: space-between;
    border-bottom: 1px solid rgba(184,101,26,0.20);
    border-right: 0;
    border-radius: 0;
    padding: 14px 16px;
    font-size: 16px;
  }
  .megamenu__panel {
    position: static;
    box-shadow: none;
    border: 0;
    border-top: 1px dashed rgba(184,101,26,0.30);
    border-radius: 0;
    background: rgba(184,101,26,0.04);
    padding: 0;
    min-width: 0;
  }
  .megamenu__item.is-open .megamenu__panel { display: block; }
  .megamenu__months { grid-template-columns: repeat(2, 1fr); }
}

/* ===== v35b: кнопки в красивых квадратиках ===== */
.megamenu__inner {
  display: flex !important;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  align-items: stretch;
}
.megamenu__item {
  margin: 0 !important;
  flex: 1 1 auto;
  display: flex;
  min-width: 100px;
}
.megamenu__btn {
  border: 2px solid #1a1a1a !important;
  border-radius: 6px !important;
  background: #ffffff !important;
  margin: 0 !important;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px !important;
  transition: all .15s ease;
  font-size: 14px !important;
  display: flex;
  align-items: center;
  justify-content: center;
}
.megamenu__btn:hover,
.megamenu__btn[aria-expanded="true"] {
  background: #b8651a !important;
  color: #fff !important;
  border-color: #1a1a1a !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(184,101,26,0.3);
}
.megamenu__btn:hover .megamenu__caret,
.megamenu__btn[aria-expanded="true"] .megamenu__caret {
  color: #fff !important;
}

/* ===== Мобильная версия: квадратики в аккордеоне ===== */
@media (max-width: 980px) {
  body.megamenu-mobile-open .megamenu .megamenu__inner {
    display: flex !important;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 6px;
    padding: 8px;
  }
  body.megamenu-mobile-open .megamenu .megamenu__item {
    flex: 0 0 auto !important;
    width: 100% !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
  }
  body.megamenu-mobile-open .megamenu .megamenu__item.is-open {
    flex-direction: column !important;
  }
  body.megamenu-mobile-open .megamenu .megamenu__item.is-open .megamenu__panel {
    width: 100% !important;
    min-width: 0 !important;
  }
  body.megamenu-mobile-open .megamenu .megamenu__btn {
    border: 2px solid #1a1a1a !important;
    border-radius: 6px !important;
    background: #ffffff !important;
    margin: 0 !important;
    width: 100% !important;
    min-height: 48px;
    padding: 12px 14px !important;
  }
  body.megamenu-mobile-open .megamenu .megamenu__btn:hover,
  body.megamenu-mobile-open .megamenu .megamenu__btn[aria-expanded="true"] {
    background: #b8651a !important;
    color: #fff !important;
  }
}

/* ===== Login group (Регистрация + Войти) ===== */
.megamenu__login-group {
  display: flex;
  gap: 4px;
  align-items: center;
}
.megamenu__login-group .megamenu__btn {
  padding: 8px 12px !important;
  font-size: 13px !important;
  min-height: 44px;
  text-align: center;
}

/* Кнопка "Личный кабинет" — с иконкой пользователя */
.megamenu__btn--account { gap: 8px; }
.megamenu__btn--account .megamenu__btn-icon { flex-shrink: 0; opacity: 0.85; }
.megamenu__btn--account .megamenu__btn-text { font-weight: 800; }
.megamenu__btn--account:hover .megamenu__btn-icon { opacity: 1; }
@media (max-width: 720px) {
  .megamenu__btn--account .megamenu__btn-text { font-size: 14px; }
}

/* Личный кабинет: показ залогиненного пользователя */
.megamenu__btn--account .megamenu__btn-content { display:inline-flex; align-items:center; gap:8px; }
.megamenu__btn--account .megamenu__btn-avatar {
  width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--accent, #b8651a);
  object-fit: cover;
  flex-shrink: 0;
}
@media (max-width: 720px) {
  .megamenu__btn--account .megamenu__btn-avatar { width: 20px; height: 20px; }
  .megamenu__btn--account .megamenu__btn-text { font-size: 13px; max-width: 80px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
}

/* ===== Личный кабинет: dropdown с подразделами (по клику) ===== */
.megamenu__item--account { position: relative; }
.megamenu__item--account .megamenu__btn--caret { display: inline-flex; }
.megamenu__dropdown {
  position: absolute;
  top: 100%; right: 0;
  min-width: 220px;
  margin-top: 6px;
  background: #14110d;
  border: 1px solid #b8651a;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0,0,0,.55);
  padding: 6px;
  display: none;
  z-index: 50;
}
.megamenu__item--account.is-open .megamenu__dropdown { display: block; }
.megamenu__btn--account[aria-expanded="true"] { color: #fff; background: var(--accent, #b8651a); }
.megamenu__sublink {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 6px;
  color: #f4ece1;
  font-size: 14px;
  text-decoration: none;
  transition: background .15s;
}
.megamenu__sublink:hover { background: rgba(184,101,26,.18); color: #ffd28a; }
.megamenu__sublink-icon { font-size: 16px; line-height: 1; }
@media (max-width: 720px) {
  .megamenu__dropdown { right: auto; left: 0; min-width: 200px; }
}

/* Видео архив cascade: year → month → days */
.megamenu__item--wide .megamenu__panel { min-width: 520px; }
.megamenu__month-wrap { display: block; }
.megamenu__month-wrap > summary {
  list-style: none;
  cursor: pointer;
}
.megamenu__month-wrap > summary::-webkit-details-marker { display: none; }
.megamenu__days {
  padding: 4px 0 8px 16px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px 4px;
}
.megamenu__day {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 600;
  border: 1.5px solid #1a1a1a;
  border-radius: 5px;
  background: #fff8ee;
  color: #000;
  text-decoration: none;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.megamenu__day:hover,
.megamenu__day:focus-visible {
  background: #b8651a;
  color: #fff;
  border-color: #1a1a1a;
  transform: translateY(-1px);
}
.megamenu__day:hover .megamenu__day-count {
  background: #fff;
  color: #b8651a;
}
.megamenu__day-count {
  font-size: 10px;
  color: var(--accent);
  font-weight: 800;
  background: rgba(184,101,26,0.10);
  padding: 1px 5px;
  border-radius: 999px;
}
@media (max-width: 980px) {
  .megamenu__item--wide .megamenu__panel { min-width: 0; }
  .megamenu__days { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 540px) {
  .megamenu__days { grid-template-columns: repeat(2, 1fr); }
}
