/* ============================================================
   HEADER / NAVIGATION — replaces the old .navbar rules
   Desktop: inline links + Services mega-menu
   Mobile:  full-height panel with an accordion for Services
   ============================================================ */

.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  padding: 14px;
  transition: padding var(--t-base) var(--ease);
}
.navbar.is-stuck { padding: 8px 14px; }

/* the whole header is one floating capsule, matching .shell / .ui-card.
   The glass/blur layer lives on ::before, not on .nav-inner itself:
   backdrop-filter (like transform) creates a new containing block for any
   position:fixed descendant — and the mobile slide-out panel (.nav-links)
   is nested right inside .nav-inner. With backdrop-filter on .nav-inner,
   that panel anchored to the small nav pill instead of the viewport,
   rendering as a tiny box instead of a full-height menu. */
.nav-inner {
  position: relative; isolation: isolate;
  max-width: var(--container); margin: 0 auto;
  padding: 9px 9px 9px 26px;
  display: flex; align-items: center; gap: var(--s-4);
  border-radius: var(--r-pill);
}
.nav-inner::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  pointer-events: none; border-radius: inherit;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(16, 24, 40, 0.07);
  box-shadow: 0 4px 20px rgba(16, 24, 40, 0.06);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  transition: background var(--t-base) var(--ease),
              box-shadow var(--t-base) var(--ease),
              border-color var(--t-base) var(--ease);
}
.navbar.is-stuck .nav-inner::before {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 8px 28px rgba(16, 24, 40, 0.10);
}

.logo {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 700; letter-spacing: -0.03em;
  color: var(--text); flex-shrink: 0;
  display: inline-flex; align-items: center;
}
.logo .dot { color: var(--brand); }
.logo-img { height: 30px; width: auto; display: block; }

/* ---------- links ---------- */
.nav-links { margin-left: auto; }
.nav-list { display: flex; align-items: center; gap: 2px; list-style: none; }

.nav-list > li > a,
.mega-toggle {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-body);
  font-size: 14px; font-weight: 500; color: var(--text-secondary);
  padding: 9px 14px; border-radius: var(--r-pill);
  background: none; border: none; cursor: pointer; white-space: nowrap;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav-list > li > a:hover,
.mega-toggle:hover { background: rgba(16, 24, 40, 0.05); color: var(--text); }

.nav-list > li > a.active,
.mega-toggle.active { color: var(--brand); font-weight: 600; background: var(--blue-50); }

.mega-caret { transition: transform var(--t-fast) var(--ease); opacity: 0.65; }
.has-mega:hover .mega-caret,
.mega-toggle[aria-expanded="true"] .mega-caret { transform: rotate(180deg); }

.nav-cta { flex-shrink: 0; font-size: 14px; padding: 11px 22px; }

/* ---------- mega menu ---------- */
.has-mega { position: relative; }
/* keeps :hover alive in the padding between the link text and the capsule edge */
.has-mega::after {
  content: ''; position: absolute; left: 0; right: 0; top: 100%; height: 14px;
}
.mega {
  position: absolute; top: calc(100% + 14px); left: 50%;
  transform: translateX(-50%) translateY(-8px);
  width: min(880px, calc(100vw - 48px));
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--s-5);
  display: grid; grid-template-columns: 1.9fr 1fr; gap: var(--s-5);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity var(--t-base) var(--ease),
              transform var(--t-base) var(--ease),
              visibility var(--t-base);
}
/* The panel floats below the header capsule. Without this bridge the pointer
   crosses a dead gap on the way down and the menu closes before you reach it. */
.mega::before {
  content: ''; position: absolute;
  left: 0; right: 0; top: -18px; height: 18px;
}

.has-mega:hover .mega,
.has-mega:focus-within .mega {
  opacity: 1; visibility: visible; pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.mega-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.mega-item {
  display: grid; grid-template-columns: auto 1fr; gap: 2px 12px;
  padding: 12px 14px; border-radius: var(--r-sm);
  transition: background var(--t-fast) var(--ease);
}
.mega-item:hover { background: var(--brand-tint); }
.mega-num {
  grid-row: 1 / 3; font-size: var(--fs-xs); font-weight: 600;
  color: var(--brand); padding-top: 3px;
}
.mega-name { font-size: 14px; font-weight: 600; color: var(--text); }
.mega-desc { font-size: var(--fs-sm); color: var(--text-secondary); line-height: 1.45; }

.mega-aside {
  background: var(--surface-dark); border-radius: var(--r-md);
  padding: var(--s-5); display: flex; flex-direction: column;
}
.mega-aside-label {
  font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--brand-light);
}
.mega-aside p {
  font-size: var(--fs-sm); color: var(--text-on-dark-2);
  line-height: 1.6; margin: 10px 0 auto;
}
.mega-aside-link {
  font-size: var(--fs-sm); font-weight: 600; color: var(--text-on-dark);
  margin-top: var(--s-4);
}
.mega-aside-link:hover { color: var(--brand-light); }

/* ---------- hamburger ---------- */
.hamburger {
  display: none; flex-direction: column; justify-content: center; gap: 5px;
  width: 42px; height: 42px; border: none; background: none;
  cursor: pointer; padding: 0; flex-shrink: 0;
}
.hamburger span {
  display: block; height: 2px; width: 22px; margin: 0 auto;
  background: var(--text); border-radius: 2px;
  transition: transform var(--t-base) var(--ease), opacity var(--t-fast) var(--ease);
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.nav-overlay {
  position: fixed; inset: 0; background: rgba(10, 10, 15, 0.45);
  backdrop-filter: blur(2px); z-index: 90;
  opacity: 0; visibility: hidden;
  transition: opacity var(--t-base) var(--ease), visibility var(--t-base);
}
.nav-overlay.active { opacity: 1; visibility: visible; }
body.nav-open { overflow: hidden; }

/* ---------- mobile ---------- */
@media (max-width: 960px) {
  .hamburger { display: flex; }
  /* .btn's unconditional `display:inline-flex` (styles.css) loads after this
     file and ties on specificity with a bare `.nav-cta` — it would win and
     keep the button visible on mobile. Add .btn here so this rule wins
     regardless of stylesheet order. */
  .btn.nav-cta { display: none; }

  .nav-links {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: min(400px, 88vw);
    background: var(--surface); z-index: 95;
    padding: 88px var(--s-5) var(--s-6);
    overflow-y: auto; overscroll-behavior: contain;
    transform: translateX(100%);
    transition: transform var(--t-base) var(--ease);
    box-shadow: -20px 0 60px rgba(0, 0, 0, 0.16);
  }
  .nav-links.active { transform: translateX(0); }

  .nav-list { flex-direction: column; align-items: stretch; gap: 2px; }
  .nav-list > li > a,
  .mega-toggle {
    width: 100%; justify-content: space-between;
    font-size: 17px; font-weight: 500;
    padding: 15px 14px; border-radius: var(--r-sm);
  }

  /* Services becomes an accordion instead of a hover menu */
  .mega {
    position: static; transform: none; width: auto;
    box-shadow: none; padding: 0 0 0 14px;
    grid-template-columns: 1fr; gap: 0;
    display: block; opacity: 1; visibility: visible; pointer-events: auto;
    max-height: 0; overflow: hidden;
    transition: max-height var(--t-base) var(--ease);
  }
  .mega-toggle[aria-expanded="true"] + .mega { max-height: 640px; }
  /* accordion on mobile — the desktop hover bridges would add dead space */
  .mega::before, .has-mega::after { display: none; }
  .has-mega:hover .mega { transform: none; }
  .mega-grid { grid-template-columns: 1fr; }
  .mega-item { padding: 11px 12px; }
  .mega-desc { display: none; }
  .mega-aside { margin-top: var(--s-3); padding: var(--s-4); }

  .nav-mobile-cta {
    display: flex; justify-content: center; align-items: center; gap: 6px;
    background: var(--brand); color: var(--text-on-dark); font-weight: 600;
    padding: 15px 16px; border-radius: var(--r-sm);
    margin-top: var(--s-5); font-size: 16px;
  }
  .nav-mobile-meta {
    margin-top: var(--s-5); padding-top: var(--s-5);
    border-top: 1px solid var(--divider);
    display: flex; flex-direction: column; gap: 10px;
  }
  .nav-mobile-meta a { font-size: 14px; color: var(--text-secondary); }
  .nav-mobile-meta a:hover { color: var(--brand); }
}

@media (min-width: 961px) {
  .nav-mobile-cta, .nav-mobile-meta { display: none; }
}

/* ---------- nav over a blue hero panel ----------
   The capsule becomes glass so the gradient reads through it. */
.navbar.over-hero .nav-inner::before {
  background: rgba(255, 255, 255, 0.13);
  border-color: rgba(255, 255, 255, 0.24);
  box-shadow: none;
}
.navbar.over-hero .logo { color: #fff; }
.navbar.over-hero .logo .dot { color: #fff; opacity: 0.7; }
.navbar.over-hero .nav-list > li > a,
.navbar.over-hero .mega-toggle { color: rgba(255, 255, 255, 0.84); }
.navbar.over-hero .nav-list > li > a:hover,
.navbar.over-hero .mega-toggle:hover { background: rgba(255,255,255,0.16); color: #fff; }
.navbar.over-hero .nav-list > li > a.active,
.navbar.over-hero .mega-toggle.active { color: #fff; background: rgba(255,255,255,0.2); }
.navbar.over-hero .hamburger span { background: #fff; }
.navbar.over-hero .nav-cta { background: #fff; color: var(--text); }
.navbar.over-hero .nav-cta:hover { background: #EDF2FF; box-shadow: none; }
.navbar.over-hero .mega .mega-name { color: var(--text); }
.navbar.over-hero .mega .mega-num { color: var(--brand); }
