/**
 * Dropdown Menu Styles
 * Handles hover dropdown menus for desktop navigation and accordion submenus for mobile burger menu
 */

/* ======================
   DESKTOP DROPDOWN MENU
   ====================== */

/* Nav item with dropdown */
.nav-item {
  position: relative;
}

.nav-item.has-dropdown {
  cursor: pointer;
}

/* Nav link wrapper with dropdown arrow */
.nav-link-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Dropdown arrow button - inherits nav text color */
.dropdown-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  color: var(--nav-text-color);
  transition: transform 0.3s ease, color 0.3s ease;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.dropdown-arrow:hover {
  opacity: 0.7;
}

.dropdown-arrow:focus {
  outline: none;
}

/* Rotate arrow to point up when dropdown is open (via click or hover) */
.nav-item.has-dropdown.dropdown-open .dropdown-arrow,
.nav-item.has-dropdown:hover:not(.dropdown-closed) .dropdown-arrow {
  transform: rotate(180deg);
}

.dropdown-arrow svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Remove focus outline on nav items and links */
.nav-item:focus,
.nav-item:focus-visible,
.nav-item.has-dropdown:focus,
.nav-item.has-dropdown:focus-visible,
.nav-item.has-dropdown:focus-within,
.nav-item .nav-link:focus,
.nav-item .nav-link:focus-visible {
  outline: none !important;
}

/* Dropdown menu container */
.dropdown-menu {
  position: fixed;
  left: 0;
  min-width: 200px;
  background-color: var(--dropdown-bg-color);
  visibility: hidden;
  transform: translateY(-10px);
  transition: opacity var(--dropdown-animation-speed) ease,
              transform var(--dropdown-animation-speed) ease,
              visibility 0s linear var(--dropdown-animation-speed);
  z-index: 1000;
  box-shadow: var(--dropdown-shadow);
  margin-top: 0;
  opacity: 0;
}

/* Show dropdown on hover (only if not manually closed) or when manually opened */
.nav-item.has-dropdown:hover:not(.dropdown-closed) .dropdown-menu,
.nav-item.has-dropdown:focus-within:not(.dropdown-closed) .dropdown-menu,
.nav-item.has-dropdown.dropdown-open .dropdown-menu {
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateY(0) !important;
  transition: opacity var(--dropdown-animation-speed) ease,
              transform var(--dropdown-animation-speed) ease,
              visibility 0s linear 0s;
}

/* Dropdown item */
.dropdown-item {
  display: flex;
  align-items: center;
  padding: 0 20px;
  height: var(--dropdown-item-height);
  color: var(--dropdown-text-color);
  text-decoration: none;
  font-size: var(--nav-menu-font-size);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: background-color 0.2s ease;
  white-space: nowrap;
}

/* Dropdown item hover */
.dropdown-item:hover,
.dropdown-item:focus {
  background-color: var(--dropdown-hover-bg);
  outline: none;
}

/* Divider lines between items */
.dropdown-menu[data-divided="true"] .dropdown-item:not(:last-child) {
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

/* Transparent background styling */
.dropdown-menu[data-bg-style="transparent"] {
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* ======================
   BURGER MENU ACCORDION
   ====================== */

/* Burger submenu wrapper */
.burger-menu__item-wrapper {
  width: 100%;
}

/* Parent item with toggle button */
.burger-menu__parent {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.burger-menu__parent .burger-menu__link {
  flex: 1;
}

/* Submenu toggle button */
.burger-submenu-toggle {
  background: none;
  border: none;
  color: inherit;
  font-size: 24px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  margin-left: 10px;
  transition: transform 0.3s ease;
}

.burger-submenu-toggle:hover {
  opacity: 0.7;
}

.burger-submenu-toggle .toggle-icon {
  display: block;
  line-height: 1;
  transition: transform 0.3s ease;
}

/* Rotate icon when open */
.burger-submenu-toggle[aria-expanded="true"] .toggle-icon {
  transform: rotate(45deg);
}

/* Submenu container */
.burger-submenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-in-out;
  background-color: rgba(0, 0, 0, 0.05);
}

.burger-submenu[aria-hidden="false"] {
  max-height: 500px; /* Large enough for most submenus */
}

/* Submenu links */
.burger-submenu__link {
  display: block;
  padding: 12px 20px 12px 40px; /* Extra left padding for indentation */
  color: inherit;
  text-decoration: none;
  font-size: var(--nav-menu-font-size);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: background-color 0.2s ease;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.burger-submenu__link:hover,
.burger-submenu__link:focus {
  background-color: rgba(0, 0, 0, 0.1);
  outline: none;
}

.burger-submenu__link:last-child {
  border-bottom: none;
}

/* ======================
   RESPONSIVE
   ====================== */

/* Hide desktop dropdown on mobile by default, but show when manually opened */
@media (max-width: 768px) {
  .dropdown-menu {
    display: none !important;
  }

  .nav-item.has-dropdown.dropdown-open .dropdown-menu {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
  }
}

/* Hide burger accordion on desktop */
@media (min-width: 769px) {
  .burger-submenu,
  .burger-submenu-toggle {
    display: none !important;
  }
}

/* ======================
   ACCESSIBILITY
   ====================== */

/* Remove all focus outlines - no active outline on this site */
.nav-item.has-dropdown:focus-within .nav-link {
  outline: none !important;
}

.dropdown-item:focus-visible {
  outline: none !important;
}

.burger-submenu-toggle:focus-visible {
  outline: none !important;
}

/* Ensure submenu is accessible when parent link is focused */
.nav-item.has-dropdown .nav-link:focus + .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
