/* Shared nav + mobile behaviors (included on all pages) */

/* Base header and nav styles */
header {
  position: sticky;
  top: 0;
  z-index: 999;
  background: linear-gradient(135deg, rgba(3,80,162,0.98), rgba(33,52,72,0.98));
  backdrop-filter: blur(10px);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 0;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-cream);
  font-weight: 700;
}

.nav-logo small {
  font-weight: 400;
  opacity: 0.85;
  display: block;
}

.nav-logo-mark {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--text-cream), var(--text-white));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--primary-blue);
  font-weight: 800;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-size: 0.95rem;
  color: var(--text-cream);
}

.nav-menu a {
  position: relative;
  padding-bottom: 0.2rem;
}

.nav-menu a::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--text-cream);
  transition: width 0.2s ease;
}

.nav-menu a:hover::after,
.nav-menu a.active-link::after {
  width: 100%;
}

.nav-cta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-cta-btn {
  font-size: 0.85rem;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  background: transparent;
  border: none;
  padding: 0;
}

.nav-toggle span {
  width: 22px;
  height: 2px;
  background-color: var(--text-cream);
  border-radius: 999px;
}

/* Mobile slide-in panel and toggle animation */
@media (max-width: 768px) {
  .nav-menu {
    display: flex;
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 100%;
    transform: translateX(100%);
    transition: transform 0.36s cubic-bezier(.2,.9,.2,1);
    flex-direction: column;
    gap: 1.25rem;
    padding: 3.25rem 1.5rem 1.5rem;
    border-radius: 0;
    background: linear-gradient(180deg, rgba(3,80,162,0.98), rgba(3,80,162,0.96));
    box-shadow: -12px 0 30px rgba(0,0,0,0.6);
    z-index: 99999;
    align-items: flex-start;
    justify-content: flex-start;
    pointer-events: none;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .nav-menu.open {
    transform: translateX(0);
    pointer-events: auto;
  }

  .nav-menu a {
    width: 100%;
    padding: 0.9rem 0.5rem;
    font-size: 1.05rem;
    border-bottom: 1px solid rgba(236,239,202,0.06);
    color: var(--text-cream);
  }

  .nav-cta-btn {
    display: none;
  }

  .nav-toggle {
    display: flex;
    position: relative;
    z-index: 100001;
  }

  .nav-toggle span {
    display: block;
    transform-origin: center;
    transition: transform 0.28s cubic-bezier(.2,.9,.2,1), opacity 0.18s ease, background-color 0.18s ease;
  }

  .nav-toggle.active span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
  }

  .nav-toggle.active span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
  }

  .nav-toggle.active span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
  }
}

/* Ensure the toggle remains visible above desktop nav if nav included via other CSS */
.nav-toggle {
  position: relative;
  z-index: 100001;
}

.nav-toggle span {
  transition: transform 0.28s cubic-bezier(.2,.9,.2,1), opacity 0.18s ease, background-color 0.18s ease;
}

/* Dropdown / multi-level menu styles (desktop + mobile) */
.nav-item {
  position: relative;
}

.nav-item.has-children::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 0;
  right: 0;
  height: 10px;
  pointer-events: auto;
  z-index: 99999;
}

/* Desktop: make submenu expand downward across the navbar (mega-dropdown)
   On desktop the submenu will be part of the header flow so it pushes content down. */
@media (min-width: 769px) {
  /* Hide the original submenu inside the nav on desktop; we render submenu into
     the `.nav-mega-placeholder` instead to avoid duplicate menus. */
  .nav-item .submenu {
    display: none;
    position: static; /* keep in document flow so header expands */
    width: 100%; /* span full nav width */
  /* rotated + mirrored: invert the gradient direction and swap color stops */
  background: linear-gradient(315deg, rgba(33, 52, 72, 0.98), rgba(3, 80, 162, 0.98));
    padding: 1rem 1.25rem;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 10px 38px rgba(0,0,0,0.45);
    z-index: 100000;
  }
  /* On desktop the placeholder will show the submenu; keep original hidden. */

  .submenu-group {
    display: inline-block;
    vertical-align: top;
    width: 25%; /* equal columns for 4 groups */
    padding: 0 1rem;
  }

  .submenu-title {
    display: block;
    font-weight: 700;
    color: var(--text-cream) !important;
    margin-bottom: 0.5rem;
  }

  .sub-submenu {
    display: block;
  }

  .sub-submenu a {
    display: block;
    padding: 0.28rem 0;
    color: var(--text-cream) !important;
    font-size: 0.95rem;
  }
}

/* Placeholder inserted after header (desktop only) - used to show submenu directly below the Solutions item
   This element is part of the document flow so it pushes content down when opened. */
@media (min-width: 769px) {
  .nav-mega-placeholder {
    display: none;
    position: fixed;
    top: 70px;
    left: 0;
    right: 0;
    z-index: 998;
    /* full-width background that spans the viewport; inner content is centered */
    background: linear-gradient(315deg, rgba(33, 52, 72, 0.98), rgba(3, 80, 162, 0.98));
    /* reduce padding to 10px (top/bottom) and 10px (left/right) per request */
    padding: 10px 10px;
    box-shadow: 0 10px 28px rgba(0,0,0,0.35);
    border-radius: 0 0 8px 8px;
    transition: opacity 0.18s ease, transform 0.18s ease;
    opacity: 0;
  }

  .nav-mega-placeholder.open {
    display: block;
    opacity: 1;
  }

  /* Centered inner container that holds column groups */
  .nav-mega-placeholder .mega-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    gap: 10px; /* use 10px spacing between columns */
    justify-content: center; /* center the row of columns */
    /* Force a single horizontal row (no wrapping) */
    flex-wrap: nowrap;
    overflow-x: auto; /* allow scrolling if unavoidable */
    -webkit-overflow-scrolling: touch;
    padding: 0 10px; /* left/right 10px per request */
  }

  /* The script clones the original .submenu into the placeholder directly (no .mega-inner wrapper).
     Make sure the cloned .submenu renders as a horizontal flex row so columns (.submenu-group)
     sit side-by-side in a single line and can be scrolled horizontally. */
  .nav-mega-placeholder > .submenu {
    display: flex;
    gap: 10px; /* 10px gap between column groups */
    align-items: flex-start;
    /* keep everything on one row */
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: center; /* center the columns inside the cloned submenu */
    -webkit-overflow-scrolling: touch;
    padding: 0; /* submenu already has padding set on placeholder */
    margin: 0;
  }

  /* Ensure nested .submenu-group inside the cloned .submenu behave as vertical columns */
  .nav-mega-placeholder > .submenu .submenu-group {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px; /* small vertical gap inside each column */
    padding: 6px; /* reduce per-column padding to keep compact */
    min-width: 80px; /* reduced to 80px to help fit a single row */
    /* override global .submenu-group width:25% that may still apply */
    width: auto;
    box-sizing: border-box;
    flex-basis: auto;
  }

  /* Render each submenu group as a vertical column. The groups sit side-by-side
     in a single horizontal row; the row scrolls horizontally when it overflows. */
  .nav-mega-placeholder .submenu-group {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 6px; /* slightly reduced padding */
    min-width: 80px; /* ensure smaller columns to allow one-row layout */
    width: auto; /* ensure we don't inherit width:25% from generic rules */
    box-sizing: border-box;
    flex-basis: auto;
  }

  /* Group title stays above its items */
  .nav-mega-placeholder .submenu-group .submenu-title {
    display: block;
    font-weight: 700;
    color: var(--text-cream) !important;
    margin-bottom: 0.4rem;
    white-space: normal;
  }

  .nav-mega-placeholder .sub-submenu {
    display: block;
  }
  .nav-mega-placeholder .sub-submenu a {
    display: block;
    padding: 3px 0; /* tighter vertical padding */
    color: var(--text-cream) !important;
    font-size: 14px; /* slightly smaller font for submenu items */
  }

  .nav-mega-placeholder .submenu-group .submenu-title {
    font-size: 15px; /* slightly smaller title */
    margin-bottom: 6px;
  }
}

/* Mobile specifics: when nav-menu is full-screen, show submenus inline and collapsible */
@media (max-width: 768px) {
  .nav-item .submenu {
    position: static;
    display: block;
    background: transparent;
    padding: 0;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    transform: none;
    min-width: 0;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.28s ease, opacity 0.2s ease, padding 0.28s ease, margin 0.28s ease;
  }

  .nav-item.open > .submenu {
    max-height: 2000px; /* large enough to reveal content */
    background: rgba(0, 0, 0, 0.2);
    padding: 0.75rem 0;
    margin: 0.5rem 0 0.5rem 1rem;
    border-radius: 8px;
    opacity: 1;
  }

  .submenu-group {
    padding: 0.4rem 0 0.4rem 1rem;
  }

  .submenu-title {
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    opacity: 0.95;
  }

  .sub-submenu {
    display: block;
    padding-left: 1rem;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.24s ease;
  }

  .submenu-group.open > .sub-submenu {
    max-height: 800px;
  }

  .sub-submenu a {
    font-size: 0.9rem !important;
    padding: 0.65rem 0.5rem !important;
    opacity: 0.85;
    border-bottom: 1px solid rgba(236,239,202,0.03) !important;
  }
}

