/* ==============================================
   MEGA MENU - Apple-Inspired Modern Design
   ============================================== */

/* Base mega menu container */
.python-mega-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #ffffff;
  border-bottom: 1px solid rgba(0, 0, 0, 0);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-20px);
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1000;
  pointer-events: none;
}

/* Active state */
.python-mega-menu.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: all;
}

/* Backdrop for mobile overlay effect */
.mega-menu-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: rgba(0, 0, 0, 0);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: -1;
}

.python-mega-menu.active .mega-menu-backdrop {
  opacity: 1;
  visibility: visible;
}

/* Container wrapper */
.mega-menu-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Main content grid */
.mega-menu-content {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 60px;
  padding: 60px 0;
  position: relative;
}

/* Individual sections */
.mega-menu-section {
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.python-mega-menu.active .mega-menu-section {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered animation delay */
.mega-menu-section:nth-child(1) { transition-delay: 0.1s; }
.mega-menu-section:nth-child(2) { transition-delay: 0.2s; }
.mega-menu-section:nth-child(3) { transition-delay: 0.3s; }

/* Section titles */
.mega-menu-title {
  font-size: 14px;
  font-weight: 600;
  color: #1d1d1f;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 24px 0;
  padding-bottom: 12px;
  border-bottom: 2px solid #007aff;
  position: relative;
}

.mega-menu-title::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, #007aff, #5856d6);
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.python-mega-menu.active .mega-menu-title::after {
  width: 40px;
}

/* Links container */
.mega-menu-links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.mega-menu-links li {
  margin: 0 0 16px 0;
  transform: translateX(-10px);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.python-mega-menu.active .mega-menu-links li {
  transform: translateX(0);
  opacity: 1;
}

/* Staggered link animations */
.mega-menu-links li:nth-child(1) { transition-delay: 0.2s; }
.mega-menu-links li:nth-child(2) { transition-delay: 0.3s; }
.mega-menu-links li:nth-child(3) { transition-delay: 0.4s; }
.mega-menu-links li:nth-child(4) { transition-delay: 0.5s; }

/* Link styles */
.mega-menu-links a {
  display: flex;
  align-items: center;
  color: #1d1d1f;
  text-decoration: none;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  padding: 8px 0;
  border-radius: 8px;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.mega-menu-links a::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0, 122, 255, 0.1), transparent);
  transition: left 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.mega-menu-links a:hover::before {
  left: 100%;
}

.mega-menu-links a:hover {
  color: #007aff;
  transform: translateX(8px);
  background: rgba(0, 122, 255, 0.05);
  padding-left: 12px;
}

.mega-menu-links a:focus {
  outline: 2px solid #007aff;
  outline-offset: 2px;
  border-radius: 8px;
}

/* Navigation item active state */
.python-nav-item.active .python-nav-trigger {
  color: #007aff;
  background: rgba(0, 122, 255, 0.1);
  border-radius: 8px;
  padding: 8px 16px;
  margin: -8px -16px;
}

.python-nav-item.active .nav-arrow {
  transform: rotate(180deg);
}

/* Arrow animation */
.nav-arrow {
  display: inline-block;
  margin-left: 6px;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  font-size: 12px;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .mega-menu-content {
    grid-template-columns: repeat(2, 1fr);
    gap: 40px;
    padding: 40px 0;
  }
  
  .mega-menu-section:nth-child(3) {
    grid-column: 1 / -1;
  }
}

@media (max-width: 768px) {
  .python-mega-menu {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    transform: translateY(-100%);
    border: none;
    box-shadow: none;
  }
  
  .python-mega-menu.active {
    transform: translateY(0);
  }
  
  .mega-menu-backdrop {
    display: none;
  }
  
  .mega-menu-container {
    height: 100vh;
    display: flex;
    align-items: center;
    padding: 0 24px;
  }
  
  .mega-menu-content {
    grid-template-columns: 1fr;
    gap: 40px;
    padding: 0;
    width: 100%;
  }
  
  .mega-menu-section:nth-child(3) {
    grid-column: auto;
  }
  
  .mega-menu-title {
    font-size: 18px;
    margin-bottom: 20px;
  }
  
  .mega-menu-links a {
    font-size: 18px;
    padding: 12px 0;
  }
  
  /* Close button for mobile */
  .mega-menu-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    font-size: 24px;
    color: #1d1d1f;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
  }
  
  .mega-menu-close:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: rotate(90deg);
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .python-mega-menu {
    background: rgba(28, 28, 30, 0.8);
    border-bottom-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  }
  
  .mega-menu-title {
    color: #f2f2f7;
  }
  
  .mega-menu-links a {
    color: #f2f2f7;
  }
  
  .mega-menu-links a:hover {
    color: #007aff;
    background: rgba(0, 122, 255, 0.1);
  }
  
  .python-nav-item.active .python-nav-trigger {
    color: #007aff;
    background: rgba(0, 122, 255, 0.2);
  }
  
  @media (max-width: 768px) {
    .python-mega-menu {
      background: rgba(28, 28, 30, 0.95);
    }
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .python-mega-menu {
    background: #ffffff;
    border-bottom: 2px solid #000000;
    backdrop-filter: none;
  }
  
  .mega-menu-links a {
    border: 1px solid transparent;
  }
  
  .mega-menu-links a:hover,
  .mega-menu-links a:focus {
    border-color: #000000;
    background: #f0f0f0;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .python-mega-menu,
  .mega-menu-section,
  .mega-menu-links li,
  .mega-menu-links a,
  .nav-arrow,
  .mega-menu-title::after {
    transition: none;
  }
  
  .mega-menu-links a::before {
    display: none;
  }
}

/* Print styles */
@media print {
  .python-mega-menu {
    display: none;
  }
}