/**
 * Material Symbols Icon Font Loading Optimization
 * Hide icons until font is loaded to prevent FOUT (Flash of Unstyled Text)
 */
@font-face {
  font-family: 'Material Symbols Outlined';
  font-style: normal;
  font-weight: 400 500;
  font-display: block;
  src: url('https://fonts.gstatic.com/s/materialsymbolsoutlined/v227/kJEhBvYX7BgnkSrUwT8OhrdQw4iELd3yOwU.woff2') format('woff2');
}

/* Material Symbols icon styles - optimized for fast rendering */
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  /* Start visible but with minimal opacity to prevent FOUT */
  opacity: 0.01;
  transition: opacity 0.15s ease-in;
  /* Ensure icons take up space even when not fully visible */
  min-width: 1em;
  min-height: 1em;
}

/* Show icons immediately once font is detected as loaded */
.fonts-loaded .material-symbols-outlined,
.material-symbols-outlined.font-loaded {
  opacity: 1;
}

/* Fallback: Fade in icons after a very short delay */
/* This ensures icons appear quickly even if font detection has a slight delay */
.material-symbols-outlined {
  animation: iconFadeInQuick 0.2s ease-in 0.05s forwards;
}

@keyframes iconFadeInQuick {
  from {
    opacity: 0.01;
  }
  to {
    opacity: 1;
  }
}

/**
 * Navigation Skeleton Overlay Styles
 */

.nav-skeleton-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(2px);
  z-index: 1000;
  display: none;
  animation: skeletonFadeIn 0.2s ease-in;
}

.nav-skeleton-overlay::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.6),
    transparent
  );
  animation: skeletonShimmer 1.5s infinite;
}

@keyframes skeletonFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes skeletonShimmer {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

/* Ensure navigation container is positioned for overlay */
nav {
  position: relative;
}

/* Hide skeleton overlay when navigation is ready */
nav.ready .nav-skeleton-overlay {
  display: none !important;
}

/**
 * Mobile Menu Styles - Aesthetic & Tap-Based
 */

/* Mobile menu backdrop overlay */
.mobile-menu-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  /* No blur - just semi-transparent overlay to avoid content blurring */
  /* backdrop-filter: blur(1px); */
  /* -webkit-backdrop-filter: blur(1px); */
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  /* Ensure backdrop doesn't affect menu content */
  pointer-events: auto;
  /* Ensure backdrop stays behind menu */
  isolation: isolate;
}

.mobile-menu-backdrop.active {
  opacity: 1;
  visibility: visible;
}

/* Mobile menu container - white background only on mobile */
@media (max-width: 1023px) {
  #menu {
    position: fixed;
    top: 0;
    right: 0;
    width: 85%;
    max-width: 400px;
    height: 100vh;
    background: white;
    background-color: white;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    overflow-y: auto;
    overflow-x: hidden;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
    margin: 0;
    list-style: none;
    isolation: isolate;
    will-change: transform;
  }
}

#menu.mobile-open {
  transform: translateX(0);
}

/* Prevent body scroll when menu is open */
body.menu-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

/* Mobile menu header */
.mobile-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #e5e7eb;
  background: white !important;
  background-color: white !important;
  position: sticky;
  top: 0;
  z-index: 10;
  /* Ensure header is not blurred */
  isolation: isolate;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.mobile-menu-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0;
}

.mobile-menu-close {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 0.5rem;
  transition: background-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.mobile-menu-close:hover,
.mobile-menu-close:active {
  background: #f3f4f6;
}

.mobile-menu-close svg {
  width: 24px;
  height: 24px;
  stroke: #374151;
}

/* Mobile menu items - white background only on mobile */
@media (max-width: 1023px) {
  #menu li {
    border-bottom: 1px solid #f3f4f6;
    margin: 0;
    background: white;
    background-color: white;
  }

  #menu li:last-child {
    border-bottom: none;
  }

  #menu > li > a,
  #menu > li > button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 1rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    color: #1f2937;
    background: white;
    background-color: white;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    -webkit-tap-highlight-color: transparent;
    min-height: 56px; /* Better touch target */
    isolation: isolate;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  #menu > li > a:hover,
  #menu > li > a:active,
  #menu > li > button:hover,
  #menu > li > button:active {
    background: #f9fafb;
    color: #dc2626;
  }

  #menu > li > a:active,
  #menu > li > button:active {
    background: #f9fafb;
  }
}

/* Mobile dropdown arrows */
#menu .nav-arrow {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}

#menu .nav-arrow.rotate-180 {
  transform: rotate(180deg);
}

/* Mobile dropdown menus - white background only on mobile */
@media (max-width: 1023px) {
  #menu .insights-dropdown,
  #menu .services-dropdown,
  #menu .partner-dropdown {
    position: static;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    background: white;
    border: none;
    border-radius: 0;
    box-shadow: none;
    transform: none;
    opacity: 1;
    visibility: visible;
    display: none;
    animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
}

#menu .insights-dropdown.mobile-open,
#menu .services-dropdown.mobile-open,
#menu .partner-dropdown.mobile-open {
  display: block;
}

@keyframes slideDown {
  from {
    opacity: 0;
    max-height: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    max-height: 2000px;
    transform: translateY(0);
  }
}

/* Mobile dropdown content - only apply on mobile */
@media (max-width: 1023px) {
  #menu .insights-dropdown .grid,
  #menu .services-dropdown .grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  #menu .insights-dropdown > div,
  #menu .services-dropdown > div {
    padding: 1rem 0;
  }

  #menu .insights-dropdown .px-5,
  #menu .services-dropdown .px-5 {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }

  #menu .insights-dropdown a,
  #menu .services-dropdown a,
  #menu .partner-dropdown a {
    padding: 0.875rem 1.5rem;
    min-height: 56px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #374151;
    transition: background-color 0.2s;
    -webkit-tap-highlight-color: transparent;
  }
}

/* Ensure "See all" buttons are legible - applies to both mobile and desktop */
#menu .insights-dropdown a.bg-red-600,
#menu .services-dropdown a.bg-red-600,
#menu .insights-dropdown a[class*="bg-red-600"],
#menu .services-dropdown a[class*="bg-red-600"] {
  background-color: #dc2626 !important;
  color: white !important;
}

#menu .insights-dropdown a.bg-red-600:hover,
#menu .services-dropdown a.bg-red-600:hover,
#menu .insights-dropdown a.bg-red-600:active,
#menu .services-dropdown a.bg-red-600:active,
#menu .insights-dropdown a[class*="bg-red-600"]:hover,
#menu .services-dropdown a[class*="bg-red-600"]:hover,
#menu .insights-dropdown a[class*="bg-red-600"]:active,
#menu .services-dropdown a[class*="bg-red-600"]:active {
  background-color: #b91c1c !important;
  color: white !important;
}

/* Mobile dropdown hover states */
@media (max-width: 1023px) {
  #menu .insights-dropdown a:hover,
  #menu .insights-dropdown a:active,
  #menu .services-dropdown a:hover,
  #menu .services-dropdown a:active,
  #menu .partner-dropdown a:hover,
  #menu .partner-dropdown a:active {
    background: white;
  }
}

/* Ensure "See all" button text and icons stay white - override any other rules */
#menu .insights-dropdown a.bg-red-600 span,
#menu .services-dropdown a.bg-red-600 span,
#menu .insights-dropdown a.bg-red-600 .material-symbols-outlined,
#menu .services-dropdown a.bg-red-600 .material-symbols-outlined,
#menu .insights-dropdown a[class*="bg-red-600"] span,
#menu .services-dropdown a[class*="bg-red-600"] span,
#menu .insights-dropdown a[class*="bg-red-600"] .material-symbols-outlined,
#menu .services-dropdown a[class*="bg-red-600"] .material-symbols-outlined {
  color: white !important;
}

/* Hamburger icon animation */
.hamburger-icon {
  width: 24px;
  height: 24px;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
}

.hamburger-icon span {
  display: block;
  width: 100%;
  height: 2px;
  background: white;
  border-radius: 2px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: center;
}

.hamburger-icon.active span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.hamburger-icon.active span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.hamburger-icon.active span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Desktop styles - keep existing */
@media (min-width: 1024px) {
  .mobile-menu-backdrop {
    display: none;
  }
  
  /* Hide mobile menu header on desktop */
  .mobile-menu-header {
    display: none !important;
  }
  
  #menu {
    position: static;
    width: auto;
    max-width: none;
    height: auto;
    background: transparent !important;
    background-color: transparent !important;
    box-shadow: none;
    transform: none;
    overflow: visible;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 2rem;
    /* Remove any white background from mobile styles */
    background-color: transparent !important;
  }
  
  #menu.mobile-open {
    transform: none;
  }
  
  #menu li {
    border-bottom: none;
    /* Ensure desktop menu list items have transparent background */
    background: transparent !important;
    background-color: transparent !important;
  }
  
  #menu > li > a,
  #menu > li > button {
    padding: 0.5rem 1rem;
    min-height: auto;
    /* Ensure desktop menu items have transparent background, not white */
    background: transparent !important;
    background-color: transparent !important;
  }
  
  #menu .insights-dropdown,
  #menu .services-dropdown,
  #menu .partner-dropdown {
    position: absolute;
    width: auto;
    max-width: 560px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    display: none;
  }
  
  #menu .insights-dropdown.mobile-open,
  #menu .services-dropdown.mobile-open,
  #menu .partner-dropdown.mobile-open {
    display: block;
  }
  
  #menu .insights-dropdown .grid,
  #menu .services-dropdown .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

