/* ========================================
   Site Header & Navigation
   ======================================== */

/* Main header container - styles moved to styles.css for better control */

/* Navigation wrapper - constrains content width and centers */
.site-header__nav {
  position: relative;
  max-width: 80rem;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header bar - contains logo and navigation */
.site-header__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4rem;
}

/* Logo section */
.site-header__brand {
  flex-shrink: 0;
}

.site-header__logo-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  text-decoration: none;
}

.site-header__logo {
  height: 40px;
  width: auto;
}

.site-header__brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  align-items: center;
}

.site-header__brand-name {
  font-family: "Montserrat", sans-serif;
  color: var(--slate-900);
  margin: 0;
}

.site-header__brand-name--first {
  font-size: 1rem;
  font-weight: 700;
}

.site-header__brand-name--second {
  font-size: 0.775rem;
  font-weight: 500;
}


/* ========================================
   Responsive Utilities
   ======================================== */

/* Show/hide content based on screen size */
.desktop-only {
  display: none;
}

.mobile-only {
  display: flex;
}

@media (min-width: 1010px) {
  .desktop-only {
    display: flex;
    align-items: center;
  }
  .mobile-only {
    display: none;
  }
}

.hidden {
  display: none !important;
}

/* ========================================
   Desktop Navigation
   ======================================== */

/* Main navigation container */
.site-nav {
  display: flex;
  align-items: center;
  gap: 2rem;
}

/* Navigation list */
.site-nav__list {
  display: flex;
  gap: 2rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Individual navigation items */
.site-nav__item {
  position: relative;
}

/* Navigation links */
.site-nav__link {
  position: relative;
  display: inline-block;
  padding: 0.5rem 0.75rem;
  color: #334155;
  text-decoration: none;
  transition: color 200ms ease;
  font-weight: 600;
}

.site-nav__link:hover,
.site-nav__link:focus {
  color: #f43f5e;
}

.site-nav__link.is-active {
  color: #f43f5e;
}

/* Active and hover state underline */
.site-nav__link.is-active::after,
.site-nav__link:hover::after {
  content: "";
  position: absolute;
  left: 0.5rem;
  right: 0.5rem;
  bottom: -0.25rem;
  height: 2px;
  background: currentColor;
}

/* Call-to-action button styling */
.site-nav__link--cta {
  color: #ffffff;
  background: #f43f5e;
  border-radius: 0.375rem;
  padding: 0.5rem 0.875rem;
  transition: background-color 160ms ease, transform 160ms ease;
}

.site-nav__link--cta:hover,
.site-nav__link--cta:focus {
  background: #e11d48;
  color: #ffffff;
  transform: translateY(-1px);
}

/* Remove underline for CTA button */
.site-nav__link--cta::after {
  display: none !important;
}

/* ========================================
   Language Dropdown (Desktop)
   ======================================== */

.language-dropdown {
  position: relative;
  margin-left: 1rem;
  font-weight: 600;
}

.language-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  color: #334155;
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: color 200ms ease;
}

/* Hover and active states */
.language-dropdown.is-open .language-toggle,
.language-dropdown:hover .language-toggle {
  color: #f43f5e;
}

.language-dropdown.is-open .language-toggle__chevron {
  transform: rotate(180deg);
}

.language-toggle__chevron {
  width: 1rem;
  height: 1rem;
  transition: transform 200ms ease;
}

/* Dropdown menu */
.language-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 10rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 0.375rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  z-index: 60;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 200ms ease, visibility 200ms ease, transform 200ms ease;
}

/* Show menu on click */
.language-dropdown.is-open .language-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Menu items */
.language-menu__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  color: #334155;
  text-decoration: none;
}

.language-menu__item:hover {
  background: #f8fafc;
}

.language-menu__item.is-current {
  background: #fff1f2;
  color: #e11d48;
}

.language-menu__check {
  width: 1rem;
  height: 1rem;
  margin-left: auto;
  color: #f43f5e;
}

/* ========================================
   Mega Menu (Services Dropdown)
   ======================================== */

/* Allow full-width mega menu positioning */
.has-mega {
  position: static;
}

/* Hide link underline when mega menu is open */
.has-mega:hover > .site-nav__link::after,
.has-mega:focus-within > .site-nav__link::after {
  display: none;
}

/* Main mega menu container */
.mega-menu {
  position: absolute;
  left: 0; /* Positioned dynamically via JavaScript */
  width: 45rem;
  top: calc(100% + 12px);
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transform: translateY(-6px);
  transition: max-height 250ms ease, opacity 200ms ease, transform 200ms ease;
  visibility: hidden;
  pointer-events: none;
}

/* Open state */
.mega-menu.is-open {
  max-height: 640px;
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
  pointer-events: auto;
}

/* Closing animation state */
.mega-menu.is-closing {
  max-height: 0;
  opacity: 0;
  transform: translateY(-6px);
  visibility: visible;
  pointer-events: none;
}

/* Inner container */
.mega-menu__inner {
  max-width: 45rem;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Three-column layout with services overview and categories */
.mega-menu__grid {
  display: grid;
  grid-template-columns: 0.6fr 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 1rem;
  margin-top: 0;
}

/* Category titles */
.mega-menu__title {
  font-size: 0.875rem;
  font-weight: 700;
  color: #334155;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 0 0 0.5rem 0;
}

/* Link lists */
.mega-menu__links {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Individual links */
.mega-menu__link {
  display: block;
  padding: 8px 12px;
  border-radius: 6px;
  color: #0f172a;
  text-decoration: none;
  transition: background-color 160ms ease;
}

.mega-menu__link:hover,
.mega-menu__link:focus {
  background: #fef2f2;
  color: #e11d48;
}

/* Services overview column */
.mega-menu__services-link {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  text-decoration: none;
  color: inherit;
  padding: 12px;
  border-radius: 8px;
  margin: 0;
  transition: background-color 160ms ease;
}

.mega-menu__services-link:hover {
  background: #fef2f2;
}

.mega-menu__services-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: #0f172a;
  margin: 0 0 0.5rem 0;
}

.mega-menu__services-desc {
  font-size: 0.875rem;
  color: #475569;
  line-height: 1.5;
  margin: 0;
}

/* Service categories */
.mega-menu__category {
  margin: 0;
  padding: 0;
}

/* Grid positioning for specific layout */
.mega-menu__services-link {
  grid-column: 1;
  grid-row: 1 / 3; /* Span both rows */
}

.mega-menu__category:nth-child(2) {
  /* Build & Ship - column 2, row 1 */
  grid-column: 2;
  grid-row: 1;
}

.mega-menu__category:nth-child(3) {
  /* Run & Operate - column 3, row 1 */
  grid-column: 3;
  grid-row: 1;
}

.mega-menu__category:nth-child(4) {
  /* How We Work - column 2, row 2 */
  grid-column: 2;
  grid-row: 2;
}

.mega-menu__category:nth-child(5) {
  /* Partner - column 3, row 2 */
  grid-column: 3;
  grid-row: 2;
}

.mega-menu__title--sub {
  margin-top: 0;
}

/* Featured service highlighting */
.mega-menu__link.is-featured {
  color: #f43f5e;
}

/* List spacing */
.mega-menu__links {
  margin: 0;
  padding: 0;
}

.mega-menu__links li {
  margin: 0;
}

/* Disabled state for future use */
.mega-menu__link.is-disabled {
  color: #94a3b8;
  pointer-events: none;
  cursor: default;
}

/* Responsive mega menu adjustments */
@media (max-width: 1200px) {
  .mega-menu {
    width: 48rem;
  }
  .mega-menu__inner {
    max-width: 48rem;
  }
  .mega-menu__grid {
    gap: 0;
  }
}

@media (max-width: 1024px) {
  .mega-menu {
    width: 44rem;
  }
  .mega-menu__inner {
    max-width: 44rem;
    padding: 1.25rem;
  }
  .mega-menu__grid {
    grid-template-columns: 0.5fr 1fr 1fr;
    gap: 0;
  }
}

@media (max-width: 900px) {
  .mega-menu {
    width: 40rem;
  }
  .mega-menu__inner {
    max-width: 40rem;
  }
  .mega-menu__grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
    gap: 0;
    min-height: 360px;
  }
  
  /* Reset grid positioning for mobile layout */
  .mega-menu__services-link,
  .mega-menu__category {
    grid-column: auto;
    grid-row: auto;
  }
}

/* Hide desktop navigation on mobile and tablets */
@media (max-width: 1009px) {
  .site-nav,
  .mega-menu {
    display: none !important;
  }
}

/* ========================================
   Mobile Menu
   ======================================== */

/* Mobile menu panel */
#mobile-menu {
  position: fixed;
  top: 4rem; /* Position below the header */
  left: 0;
  right: 0;
  width: 100%;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  z-index: 1001; /* Higher than fixed header */
  max-height: calc(100vh - 4rem); /* Limit height to leave space for header */
  overflow-y: auto; /* Allow scrolling if content is too long */
  
  /* Hidden by default - slides from top */
  transform: translateY(-100%);
  opacity: 0;
  visibility: hidden;
  transition: transform 300ms ease-out, opacity 300ms ease-out, visibility 300ms ease-out;
}

/* Hide brand text on very small screens */
@media (max-width: 480px) {
  .site-header__brand-text {
    display: none;
  }
}

/* Desktop styles for brand text */
@media (min-width: 768px) {
  .site-header__brand-name--first {
    font-size: 1.2rem;
  }
  
  .site-header__brand-name--second {
    font-size: 0.6rem;
  }
}

/* On desktop, revert to original positioning */
@media (min-width: 768px) {
  #mobile-menu {
    position: absolute;
    top: 100%;
    bottom: auto;
    border-bottom: none;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    max-height: none;
    
    /* Slides in from right on desktop */
    transform: translateX(100%);
  }
  
  #mobile-menu.mobile-menu--open {
    transform: translateX(0) !important;
  }
  
  #mobile-menu.mobile-menu--closing {
    transform: translateX(100%) !important;
  }
}

/* Animation states */
#mobile-menu.mobile-menu--open {
  transform: translateY(0) !important;
  opacity: 1 !important;
  visibility: visible !important;
}

#mobile-menu.mobile-menu--closing {
  transform: translateY(-100%) !important;
  opacity: 0 !important;
  visibility: hidden !important;
}

/* Add backdrop overlay for mobile menu */
#mobile-menu::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: -1;
  opacity: 0;
  transition: opacity 300ms ease-out;
  pointer-events: none;
}

#mobile-menu.mobile-menu--open::before {
  opacity: 1;
  pointer-events: auto;
}

/* Panel container */
.mobile-menu__panel {
  padding: 0.5rem 0; /* Add some vertical padding */
  background: #ffffff;
  width: 100%;
  border-radius: 0;
  position: relative;
  min-height: 100%;
}

/* Remove handle indicator for mobile since it's not a bottom sheet */
@media (max-width: 767.98px) {
  .mobile-menu__panel::before {
    display: none;
  }
}

/* Keep handle indicator only on desktop if needed */
@media (min-width: 768px) {
  .mobile-menu__panel {
    border-radius: 8px; /* Slight rounding on desktop */
  }
}

/* Mobile menu links */
.mobile-menu__link {
  display: block;
  padding: 0.75rem 1rem;
  color: #334155;
  text-decoration: none;
  border-bottom: 1px solid #f1f5f9;
  font-size: 1rem;
}

.mobile-menu__link:hover {
  background: #f8fafc;
  color: #f43f5e;
}

.mobile-menu__link.is-active {
  color: #f43f5e;
  background: #fff1f2;
}

/* Mobile services section */
.mobile-services {
  background: #fafbfc;
  border-top: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
}

.mobile-services__title {
  display: block;
  padding: 0.875rem 1rem;
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
  text-decoration: none;
  transition: all 200ms ease;
}

.mobile-services__title:hover {
  background: #e2e8f0;
  color: #f43f5e;
}

.mobile-services__category {
  margin-bottom: 0.5rem;
}

.mobile-services__category:last-child {
  margin-bottom: 0;
}

.mobile-services__category-title {
  padding: 0.5rem 1rem 0.25rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: #64748b;
  background: #f8fafc;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #f1f5f9;
}

.mobile-menu__link--sub {
  padding: 0.5rem 1rem 0.5rem 2rem;
  font-size: 0.875rem;
  background: #ffffff;
}

.mobile-menu__link--featured {
  color: #f43f5e;
  font-weight: 600;
}

/* Mobile language section */
.mobile-language {
  background: #fafbfc;
  border-top: 1px solid #e2e8f0;
}

.mobile-language__label {
  padding: 0.625rem 1rem;
  font-size: 0.6875rem;
  font-weight: 700;
  color: #64748b;
  background: #f1f5f9;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.mobile-language__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 1rem;
  color: #334155;
  text-decoration: none;
  background: #ffffff;
  border-bottom: 1px solid #f1f5f9;
}

.mobile-language__item:hover {
  background: #f8fafc;
}

.mobile-language__item.is-current {
  color: #e11d48;
  background: #fff1f2;
}

.mobile-language__check {
  width: 1rem;
  height: 1rem;
  margin-left: auto;
  color: #f43f5e;
}

/* Add bottom padding to last mobile menu section for safe area */
.mobile-language {
  padding-bottom: env(safe-area-inset-bottom, 1rem);
}

/* ========================================
   Mobile Menu Button
   ======================================== */

.site-header__menu-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  color: #334155;
  padding: 0.25rem;
  transition: color 200ms ease;
}

.site-header__menu-button:hover,
.site-header__menu-button:focus {
  color: #f43f5e;
}

.site-header__menu-button svg {
  width: 1.5rem;
  height: 1.5rem;
}
