/* ========================================
   DROPDOWNS.CSS - Dropdown Menu Styles
   ======================================== */

.dropdown {
  position: relative;
}

.dropdown-toggle {
  display: block;
  background-color: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  position: relative;
}

/* ===== DROPDOWN MENU ===== */
.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 200px;
  /* Glassmorphism effect - less transparent, more blur */
  background-color: var(--color-bg-card-alpha-96);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: var(--border-width) solid rgba(74, 198, 255, 0.3);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5),
              0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  padding: var(--spacing-sm) 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.95);
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              visibility 0.4s;
  z-index: var(--z-index-dropdown);
  overflow: visible;
}

/* Invisible bridge to prevent gap when tab moves up on hover */
.dropdown-menu::before {
  content: '';
  position: absolute;
  top: -20px;
  left: 0;
  right: 0;
  height: 20px;
  background: transparent;
}

.dropdown-menu--active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Show dropdown on hover with delay */
.navbar-item.dropdown:hover .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  transition-delay: 0.15s;
}

/* ===== CASCADE ANIMATION ===== */
@keyframes cascadeIn {
  from {
    opacity: 0;
    transform: translateY(-15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== DROPDOWN ITEMS ===== */
.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  color: var(--color-text);
  text-align: left;
  text-decoration: none;
  background-color: transparent;
  border: none;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: color var(--transition-fast);
  outline: none;
  /* Initial state for cascade animation */
  opacity: 0;
  transform: translateY(-15px);
}

/* Apply cascade animation when dropdown is visible (exclude nested items) */
.dropdown-menu--active > .dropdown-item,
.dropdown-menu--active > .dropdown-nested > .dropdown-item,
.navbar-item.dropdown:hover .dropdown-menu > .dropdown-item,
.navbar-item.dropdown:hover .dropdown-menu > .dropdown-nested > .dropdown-item {
  animation: cascadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Staggered animation delays for fluid cascade effect */
.dropdown-menu--active .dropdown-item:nth-child(1),
.navbar-item.dropdown:hover .dropdown-menu .dropdown-item:nth-child(1) {
  animation-delay: 0.05s;
}

.dropdown-menu--active .dropdown-item:nth-child(2),
.navbar-item.dropdown:hover .dropdown-menu .dropdown-item:nth-child(2) {
  animation-delay: 0.1s;
}

.dropdown-menu--active .dropdown-item:nth-child(3),
.navbar-item.dropdown:hover .dropdown-menu .dropdown-item:nth-child(3) {
  animation-delay: 0.15s;
}

.dropdown-menu--active .dropdown-item:nth-child(4),
.navbar-item.dropdown:hover .dropdown-menu .dropdown-item:nth-child(4) {
  animation-delay: 0.2s;
}

.dropdown-menu--active .dropdown-item:nth-child(5),
.navbar-item.dropdown:hover .dropdown-menu .dropdown-item:nth-child(5) {
  animation-delay: 0.25s;
}

.dropdown-menu--active .dropdown-item:nth-child(6),
.navbar-item.dropdown:hover .dropdown-menu .dropdown-item:nth-child(6) {
  animation-delay: 0.3s;
}

.dropdown-menu--active .dropdown-item:nth-child(7),
.navbar-item.dropdown:hover .dropdown-menu .dropdown-item:nth-child(7) {
  animation-delay: 0.35s;
}

.dropdown-menu--active .dropdown-item:nth-child(8),
.navbar-item.dropdown:hover .dropdown-menu .dropdown-item:nth-child(8) {
  animation-delay: 0.4s;
}

.dropdown-menu--active .dropdown-item:nth-child(9),
.navbar-item.dropdown:hover .dropdown-menu .dropdown-item:nth-child(9) {
  animation-delay: 0.45s;
}

.dropdown-menu--active .dropdown-item:nth-child(10),
.navbar-item.dropdown:hover .dropdown-menu .dropdown-item:nth-child(10) {
  animation-delay: 0.5s;
}

.dropdown-menu--active .dropdown-item:nth-child(11),
.navbar-item.dropdown:hover .dropdown-menu .dropdown-item:nth-child(11) {
  animation-delay: 0.55s;
}

.dropdown-menu--active .dropdown-item:nth-child(12),
.navbar-item.dropdown:hover .dropdown-menu .dropdown-item:nth-child(12) {
  animation-delay: 0.6s;
}

.dropdown-item-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Remove default focus styles */
.dropdown-item:focus,
.dropdown-item:focus-visible {
  outline: none;
  box-shadow: none;
}

/* Compact blue highlight background */
.dropdown-item::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 0%;
  height: 60%;
  background-color: rgba(74, 198, 255, 0.15);
  border-radius: var(--radius-sm);
  transition: width 0.2s ease-out;
  z-index: -1;
}

.dropdown-item:hover::before {
  width: 85%;
}

.dropdown-item:hover {
  color: var(--color-primary);
}

/* Click flash effect - compact */
.dropdown-item:active::before {
  animation: flash-compact 0.3s ease-out;
}

.dropdown-item:active,
.dropdown-item:focus {
  color: var(--color-primary);
}

/* Compact blue flash animation */
@keyframes flash-compact {
  0% {
    width: 85%;
    background-color: rgba(74, 198, 255, 0.15);
  }
  50% {
    width: 70%;
    background-color: rgba(74, 198, 255, 0.4);
    box-shadow: 0 0 8px rgba(74, 198, 255, 0.3);
  }
  100% {
    width: 85%;
    background-color: rgba(74, 198, 255, 0.15);
  }
}

/* Disabled/Coming Soon items */
.dropdown-item--disabled {
  color: var(--color-text-muted);
  opacity: 0.5;
  pointer-events: none;
  cursor: default;
  font-size: 0.85em;
}

.dropdown-item--disabled::before {
  display: none;
}

/* Coming Soon section header */
.dropdown-header--soon {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
}

/* Divider */
.dropdown-divider {
  height: var(--border-width);
  background-color: var(--color-border);
  margin: var(--spacing-sm) 0;
}

/* Header */
.dropdown-header {
  display: block;
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  pointer-events: none;
}

/* ===== NESTED DROPDOWN ===== */
.dropdown-nested {
  position: relative;
}

.dropdown-nested-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  background: transparent;
  border: none;
  color: var(--color-text);
  font-size: inherit;
  font-family: inherit;
  cursor: pointer;
  position: relative;
  transition: color var(--transition-fast);
}

.dropdown-nested-toggle::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 0%;
  height: 60%;
  background-color: rgba(74, 198, 255, 0.15);
  border-radius: var(--radius-sm);
  transition: width 0.2s ease-out;
  z-index: -1;
}

.dropdown-nested-toggle:hover::before {
  width: 85%;
}

.dropdown-nested-toggle:hover {
  color: var(--color-primary);
}

.dropdown-nested-arrow {
  transition: transform 0.3s ease;
  opacity: 0.7;
}

.dropdown-nested-toggle[aria-expanded="true"] .dropdown-nested-arrow {
  transform: rotate(90deg);
}

.dropdown-nested-menu {
  max-height: 0;
  overflow: hidden;
  padding-left: var(--spacing-md);
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
  opacity: 0;
}

.dropdown-nested-menu--active {
  max-height: 400px;
  opacity: 1;
}

/* Nested items - keep hidden until submenu opens */
.dropdown-nested .dropdown-nested-menu .dropdown-item {
  opacity: 0;
  transform: translateY(-15px);
  animation: none;
}

/* Nested items cascade animation when submenu is opened */
.dropdown-nested .dropdown-nested-menu--active .dropdown-item {
  animation: cascadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.dropdown-nested .dropdown-nested-menu--active .dropdown-item:nth-child(1) { animation-delay: 0.02s; }
.dropdown-nested .dropdown-nested-menu--active .dropdown-item:nth-child(2) { animation-delay: 0.06s; }
.dropdown-nested .dropdown-nested-menu--active .dropdown-item:nth-child(3) { animation-delay: 0.10s; }
.dropdown-nested .dropdown-nested-menu--active .dropdown-item:nth-child(4) { animation-delay: 0.14s; }
.dropdown-nested .dropdown-nested-menu--active .dropdown-item:nth-child(5) { animation-delay: 0.18s; }
.dropdown-nested .dropdown-nested-menu--active .dropdown-item:nth-child(6) { animation-delay: 0.22s; }

/* ===== MOBILE CONSIDERATIONS ===== */
@media (max-width: 767px) {
  .dropdown-menu {
    position: static;
    min-width: 100%;
    /* Maintain glassmorphism on mobile - less transparent, more blur */
    background-color: var(--color-bg-elevated-alpha-95);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4) inset;
    border: none;
    border-top: var(--border-width) solid rgba(74, 198, 255, 0.3);
    border-radius: 0;
    margin-top: var(--spacing-sm);
    padding-left: var(--spacing-lg);
  }

  .dropdown-item {
    /* Reset animation for mobile to avoid conflicts with navigation.css */
    opacity: 1;
    transform: none;
  }
}
