/* Mega-menu navigation (desktop hover + mobile accordion), quantor-style */

.nav-header,
.nav-header .nav,
.nav-links,
.nav-mobile-list {
  overflow: visible;
}

/* ---- Desktop mega ---- */
.nav-mega-desktop {
  display: none;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.nav-mega-item {
  position: relative;
  flex: 0 0 auto;
  width: fit-content;
  min-width: 0;
  max-width: 100%;
}

.nav-mega-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  white-space: nowrap;
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 600;
  color: rgba(232, 234, 239, 0.72);
  background: transparent;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}

.nav-mega-trigger:hover,
.nav-mega-item:hover .nav-mega-trigger,
.nav-mega-item:focus-within .nav-mega-trigger {
  color: var(--accent);
  background: rgba(0, 200, 168, 0.08);
}

.nav-mega-chevron {
  opacity: 0.65;
  transition: transform 0.2s ease;
}

.nav-mega-item:hover .nav-mega-chevron,
.nav-mega-item:focus-within .nav-mega-chevron {
  transform: rotate(180deg);
}

/* Обёртка = ширина триггера; панель центрируется flex'ом (без transform на родителе) */
.nav-mega-popover {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 500;
  padding-top: 4px;
}

.nav-mega-bridge {
  width: 100%;
  height: 10px;
  flex-shrink: 0;
}

.nav-mega-panel {
  flex-shrink: 0;
  width: max-content;
  max-width: min(460px, calc(100vw - 24px));
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  pointer-events: none;
  transition:
    opacity 0.2s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0.2s;
}

.nav-mega-item:hover .nav-mega-panel,
.nav-mega-item:focus-within .nav-mega-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.nav-mega-panel-inner {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  min-width: min(360px, calc(100vw - 24px));
  max-width: 460px;
  box-sizing: border-box;
  padding: 10px;
  border-radius: 16px;
  background: linear-gradient(165deg, rgba(18, 20, 28, 0.98) 0%, rgba(10, 11, 16, 0.99) 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 28px 90px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(0, 200, 168, 0.06) inset;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.nav-mega-link {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: background 0.18s ease;
}

.nav-mega-link:hover {
  background: rgba(0, 200, 168, 0.1);
}

.nav-mega-icon {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(0, 200, 168, 0.1);
  color: var(--accent);
  border: 1px solid rgba(0, 200, 168, 0.22);
}

.nav-mega-icon svg {
  display: block;
}

.nav-mega-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.nav-mega-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  letter-spacing: -0.01em;
}

.nav-mega-desc {
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--text-muted);
}

/* ---- Auth CTAs (desktop, guest) ---- */
.nav-mega-auth-desktop {
  display: none;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.nav-mega-login-link {
  padding: 9px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  background: transparent;
  transition:
    border-color 0.2s ease,
    color 0.2s ease,
    background 0.2s ease;
}

.nav-mega-login-link:hover {
  border-color: rgba(0, 200, 168, 0.45);
  color: var(--accent);
  background: rgba(0, 200, 168, 0.06);
}

/* ---- Mobile accordion ---- */
.nav-mega-mobile {
  display: none;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.nav-mega-acc {
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  overflow: hidden;
}

.nav-mega-acc-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 16px 18px;
  font-family: var(--font);
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text);
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
}

.nav-mega-acc-btn .nav-mega-chevron {
  flex-shrink: 0;
  transition: transform 0.25s ease;
}

.nav-mega-acc-btn[aria-expanded='true'] .nav-mega-chevron {
  transform: rotate(180deg);
}

.nav-mega-acc-panel {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 8px;
  background: rgba(0, 0, 0, 0.2);
}

.nav-mega-acc-panel[hidden] {
  display: none !important;
}

.nav-mega-acc-link {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: background 0.18s ease;
}

.nav-mega-acc-link:hover {
  background: rgba(0, 200, 168, 0.1);
}

.nav-mega-icon--sm {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}

.nav-mega-icon--sm svg {
  width: 18px;
  height: 18px;
}

.nav-mega-acc-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.nav-mega-acc-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}

.nav-mega-acc-desc {
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--text-muted);
}

.nav-mega-mobile-cta {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
  padding-top: 8px;
}

.nav-mega-mobile-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  width: 100%;
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.nav-mega-mobile-login:hover {
  border-color: rgba(0, 200, 168, 0.4);
  color: var(--accent);
}

.nav-mega-mobile-reg {
  min-height: 52px;
  width: 100%;
  border-radius: 14px !important;
}

@media (min-width: 901px) {
  .nav-mega-desktop {
    display: flex;
  }

  .nav-mega-mobile {
    display: none !important;
  }

  .nav-mega-auth-desktop {
    display: flex;
  }

  .nav-mobile-list {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
  }

  /* Последний пункт (Аккаунт): панель по правому краю триггера — не уезжает за экран */
  .nav-mega-item:last-child .nav-mega-popover {
    align-items: flex-end;
  }
}

@media (max-width: 900px) {
  .nav-mega-desktop {
    display: none !important;
  }

  .nav-mega-mobile {
    display: flex;
  }

  .nav-mega-auth-desktop {
    display: none !important;
  }
}
