/* Responsive navbar styles */

/* Button base for dropdown triggers */
.nav-button {
  position: relative;
}

/* Desktop nav link hover underline effect */
.nav-link {
  position: relative;
}

.nav-link::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: rgba(255, 255, 255, 0.5);
  transition: width 0.25s ease-out, left 0.25s ease-out;
  border-radius: 1px;
}

.nav-link:hover::after {
  width: 60%;
  left: 20%;
}

/* Smooth reveal animation for dropdown */
.user-dropdown {
  transform: translateY(-10px);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Invisible bridge covering the gap between trigger and menu */
.user-dropdown::before {
  content: "";
  position: absolute;
  top: -0.5rem;
  left: 0;
  right: 0;
  height: 0.5rem;
}

.user-dropdown.show {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
}

/* Enhanced mobile menu animations */
.mobile-menu {
  transform: translateY(-20px) scale(0.95);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-menu.show {
  transform: translateY(0) scale(1);
  opacity: 1 !important;
}

/* Staggered animation for mobile menu items */
.mobile-menu-item {
  transform: translateX(-20px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-menu.show .mobile-menu-item {
  transform: translateX(0);
  opacity: 1;
}

.mobile-menu.show .mobile-menu-item:nth-child(1) {
  transition-delay: 0.05s;
}
.mobile-menu.show .mobile-menu-item:nth-child(2) {
  transition-delay: 0.1s;
}
.mobile-menu.show .mobile-menu-item:nth-child(3) {
  transition-delay: 0.15s;
}
.mobile-menu.show .mobile-menu-item:nth-child(4) {
  transition-delay: 0.2s;
}
.mobile-menu.show .mobile-menu-item:nth-child(5) {
  transition-delay: 0.25s;
}
.mobile-menu.show .mobile-menu-item:nth-child(6) {
  transition-delay: 0.3s;
}

/* Enhanced focus styles for accessibility */
.nav-link:focus-visible,
.nav-button:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.1);
}

/* Enhanced hover effects for mobile menu items */
.mobile-menu-item {
  position: relative;
  overflow: hidden;
}

.mobile-menu-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  transition: left 0.6s ease;
  transform: translateZ(0);
}

.mobile-menu-item:hover::before {
  left: 100%;
}

/* Improved touch targets for mobile */
@media (max-width: 767px) {
  .mobile-touch-target {
    min-height: 48px;
    display: flex;
    align-items: center;
    touch-action: manipulation;
  }
}

/* Animated icon transitions */
.menu-icon-transition {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.menu-icon-transition.open {
  transform: rotate(90deg);
}

/* Rotate chevron when details is open */
details[open] .details-open-rotate {
  transform: rotate(180deg);
}

/* Accordion chevron transition */
.accordion-chevron {
  transition: transform 0.2s ease;
}

/* Ensure dropdown menu doesn't get cut off */
.user-dropdown {
  max-height: 80vh;
  overflow-y: auto;
  scrollbar-width: thin;
}

/* Enhanced user dropdown positioning */
.user-dropdown-container {
  position: relative;
}

.user-dropdown {
  top: calc(100% + 8px);
}

/* Brand logo hover effect */
.brand-logo {
  transition: transform 0.2s ease-out;
}

.brand-logo:hover {
  transform: scale(1.02);
}

/* Custom scrollbar for dropdown on webkit browsers */
.user-dropdown::-webkit-scrollbar {
  width: 4px;
}

.user-dropdown::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 2px;
}

.user-dropdown::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 2px;
}

.user-dropdown::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.2);
}

/* Sidebar active item entrance pulse */
@keyframes sidebar-active-pulse {
  0% { box-shadow: 0 0 0 0 currentColor; }
  50% { box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

[aria-current="page"] {
  animation: sidebar-active-pulse 0.6s ease-out;
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .mobile-menu,
  .mobile-menu-item,
  .user-dropdown,
  .mobile-menu-item::before,
  .menu-icon-transition,
  .brand-logo,
  .nav-link::after,
  [aria-current="page"] {
    animation: none !important;
    transition: none !important;
  }
}

/* Category nav scroll fade indicators */
.category-scroll-fade-left,
.category-scroll-fade-right {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2.5rem;
  pointer-events: none;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.25s ease;
}

/* The fade has to be the colour of the bar it fades INTO, not white. The bar is
   the storefront surface, so on a dark theme a hardcoded white gradient drew a
   bright smear across the right edge of a dark strip — readable, so the contrast
   test passed it, and the first thing the eye landed on. */
.category-scroll-fade-left {
  left: 0;
  background: linear-gradient(to right, var(--color-store-surface, white) 20%, transparent);
}

.category-scroll-fade-right {
  right: 0;
  background: linear-gradient(to left, var(--color-store-surface, white) 20%, transparent);
}

.category-scroll-fade-left.active,
.category-scroll-fade-right.active {
  opacity: 1;
}

/* Cart count badge bounce animation */
@keyframes cart-badge-bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

.cart-badge-bounce {
  animation: cart-badge-bounce 0.35s ease-in-out;
}
