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

/* Base navigation styles */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  transition: all 0.3s ease;
}

/* Mobile Navigation (default - mobile first) */
@media (max-width: 1023px) {
  .nav {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--gray-200);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 60px;
  }

  .nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 1001;
  }

  .logo {
    font-weight: 800;
    font-size: 20px;
    letter-spacing: -0.02em;
    color: var(--primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .logo-icon {
    width: 28px;
    height: 28px;
    background: var(--accent);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--primary);
    flex-shrink: 0;
  }

  /* Hide desktop navigation items on mobile */
  .nav-items,
  .lang-switcher {
    display: none;
  }

  /* Mobile menu toggle button */
  .mobile-menu-toggle {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.3s ease;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    z-index: 1001;
  }

  .mobile-menu-toggle:hover {
    background: var(--gray-100);
  }

  .mobile-menu-toggle span {
    width: 24px;
    height: 2px;
    background: var(--primary);
    border-radius: 1px;
    transition: all 0.3s ease;
    transform-origin: center;
  }

  /* Hamburger animation states */
  .mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
  }

  .mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
  }

  .mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
  }

  /* Mobile menu overlay */
  .mobile-menu {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    transform: translateY(-100%);
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 999;
    padding: 32px 20px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
  }

  .mobile-menu.open {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
  }

  /* Mobile navigation items */
  .mobile-nav-items {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 40px;
  }

  .mobile-nav-item {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    padding: 20px 0;
    border-bottom: 1px solid var(--gray-100);
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    align-items: center;
    min-height: 60px;
    opacity: 0;
    transform: translateX(-20px);
    animation: slideInLeft 0.4s ease forwards;
  }

  .mobile-nav-item:nth-child(1) { animation-delay: 0.1s; }
  .mobile-nav-item:nth-child(2) { animation-delay: 0.15s; }
  .mobile-nav-item:nth-child(3) { animation-delay: 0.2s; }
  .mobile-nav-item:nth-child(4) { animation-delay: 0.25s; }
  .mobile-nav-item:nth-child(5) { animation-delay: 0.3s; }
  .mobile-nav-item:nth-child(6) { animation-delay: 0.35s; }
  .mobile-nav-item:nth-child(7) { animation-delay: 0.4s; }

  .mobile-nav-item:hover {
    color: var(--accent);
    transform: translateX(8px);
  }

  .mobile-nav-item:last-child {
    border-bottom: none;
  }

  /* Mobile language switcher */
  .mobile-lang-switcher {
    display: flex;
    gap: 12px;
    margin-top: auto;
    padding-top: 20px;
    border-top: 2px solid var(--gray-100);
    opacity: 0;
    transform: translateY(20px);
    animation: slideInUp 0.4s ease forwards;
    animation-delay: 0.5s;
  }

  .mobile-lang-toggle {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-600);
    background: var(--gray-100);
    border: none;
    cursor: pointer;
    padding: 16px 24px;
    border-radius: 30px;
    transition: all 0.3s ease;
    flex: 1;
    min-height: 50px;
  }

  .mobile-lang-toggle.active {
    background: var(--primary);
    color: var(--secondary);
    transform: scale(1.05);
  }

  .mobile-lang-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  }
}

/* Desktop Navigation (1024px and above) */
@media (min-width: 1024px) {
  .nav {
    top: 30px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    border: 1px solid var(--gray-200);
    border-radius: 50px;
    padding: 14px 28px;
    display: flex;
    align-items: center;
    gap: 32px;
    animation: navFloat 0.6s ease-out;
    min-width: 600px;
    width: auto;
  }

  /* Hide mobile elements on desktop */
  .mobile-menu-toggle,
  .mobile-menu,
  .mobile-nav-items,
  .mobile-lang-switcher {
    display: none !important;
  }

  .nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .logo {
    font-weight: 800;
    font-size: 18px;
    letter-spacing: -0.02em;
    color: var(--primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
  }

  .logo-icon {
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--primary);
    flex-shrink: 0;
  }

  /* Desktop navigation items */
  .nav-items {
    display: flex;
    gap: 24px;
    list-style: none;
    flex-wrap: nowrap;
  }

  .nav-item {
    font-size: 15px;
    font-weight: 500;
    color: var(--gray-600);
    cursor: pointer;
    transition: color 0.2s ease;
    position: relative;
    white-space: nowrap;
  }

  .nav-item > a {
    color: inherit;
    text-decoration: none;
    display: inline-block;
    padding: 8px 0;
  }

  .nav-item > a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
  }

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

  .nav-item::after {
    content: "";
    position: absolute;
    bottom: -4px;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--accent);
    transition: all 0.3s ease;
    transform: translateX(-50%);
  }

  .nav-item:hover::after {
    width: 100%;
  }

  /* Desktop language switcher */
  .lang-switcher {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
  }

  .lang-toggle {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 20px;
    transition: all 0.2s ease;
  }

  .lang-toggle:hover {
    background: var(--gray-100);
  }

  .lang-toggle.active {
    background: var(--primary);
    color: var(--secondary);
  }
}

/* ===========================================
   ANIMATIONS
   =========================================== */
@keyframes navFloat {
  from {
    transform: translateX(-50%) translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===========================================
   ACCESSIBILITY & INTERACTION
   =========================================== */
.mobile-menu-toggle:focus,
.mobile-nav-item:focus,
.mobile-lang-toggle:focus,
.nav-item:focus,
.lang-toggle:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Touch improvements for mobile */
.mobile-menu-toggle,
.mobile-nav-item,
.mobile-lang-toggle {
  -webkit-tap-highlight-color: rgba(0, 255, 148, 0.2);
  touch-action: manipulation;
}

/* Prevent body scroll when mobile menu is open */
body.menu-open {
  overflow: hidden;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .nav {
    border: 2px solid var(--primary);
  }
  
  .mobile-menu {
    border: 2px solid var(--primary);
  }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .nav,
  .mobile-menu,
  .mobile-menu-toggle span,
  .mobile-nav-item,
  .mobile-lang-switcher {
    animation: none !important;
    transition: none !important;
  }
}

/* Safe area support for notched devices */
@supports (padding: max(0px)) {
  @media (max-width: 1023px) {
    .nav {
      padding-left: max(16px, env(safe-area-inset-left));
      padding-right: max(16px, env(safe-area-inset-right));
    }
    
    .mobile-menu {
      padding-left: max(20px, env(safe-area-inset-left));
      padding-right: max(20px, env(safe-area-inset-right));
      padding-bottom: max(32px, env(safe-area-inset-bottom));
    }
  }
}
