/* =========================================================
   OnlineRME Marketing Header + Mega Nav (FINAL LOCKED)
   - Mobile: hamburger + click open (JS adds .is-open)
   - Desktop: hover/focus open + click still supported
   - Mega panels: inset 15px from viewport edges
   - No hover gap: panel hover bridge
   - Alignment: compact LEFT-packed columns (not spread out)
   - Radius standard: 0.7rem
   ========================================================= */

/* =========================
   Header shell
   ========================= */

.site-header {
  background: linear-gradient(90deg, var(--blue-dark-1), var(--blue-dark-2));
  color: var(--text-light);
  border-bottom: 1px solid rgba(148, 163, 184, 0.35);
  position: relative;
  z-index: 40;
}

.header-bar {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1rem var(--pad-inline) 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
}

/* =========================
   Logo
   ========================= */

.logo {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  color: var(--text-light);
  text-decoration: none;
}

.logo:focus-visible {
  outline: 2px solid var(--blue-accent-hover);
  outline-offset: 4px;
  border-radius: 0.7rem;
}

.logo-mark {
  width: 70px;
  height: 70px;
}

.logo-text-main {
  display: block;
  font-family: "Inter Tight", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: none;
  margin-bottom: 0.15rem;
}

.logo-text-sub {
  display: block;
  font-size: 0.82rem;
  color: #e5e7eb;
}

/* =========================
   Mobile nav toggle
   ========================= */

.nav-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 999rem;
  padding: 0.35rem 0.85rem;
  border: 1px solid rgba(248, 250, 252, 0.55);
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.nav-toggle:focus-visible {
  outline: 2px solid var(--blue-accent-hover);
  outline-offset: 4px;
  border-radius: 999rem;
}

.nav-toggle-bar {
  width: 16px;
  height: 2px;
  border-radius: 999rem;
  background: currentColor;
  position: relative;
}

.nav-toggle-bar::before,
.nav-toggle-bar::after {
  content: "";
  position: absolute;
  left: 0;
  width: 16px;
  height: 2px;
  border-radius: 999rem;
  background: currentColor;
  transition: transform 150ms ease-out, opacity 150ms ease-out;
}

.nav-toggle-bar::before { top: -5px; }
.nav-toggle-bar::after  { top:  5px; }

.nav-toggle[aria-expanded="true"] .nav-toggle-bar {
  background: transparent;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar::before {
  transform: translateY(5px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar::after {
  transform: translateY(-5px) rotate(-45deg);
}

/* =========================
   Main nav layout
   ========================= */

.main-nav {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--pad-inline) 1.1rem;
  position: relative; /* desktop anchor for mega panels */
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;

  display: none;
  flex-direction: column;
  gap: 0.4rem;
}

.nav-list.is-open {
  display: flex;
}

/* Critical: keep static so mega panel anchors to .main-nav on desktop */
.nav-item {
  position: static;
}

/* =========================
   Top links / triggers
   ========================= */

.toplink {
  display: flex;
  align-items: center;
  justify-content: space-between;

  width: 100%;
  padding: 0.45rem 0.15rem;

  background: transparent;
  color: inherit;
  border: none;
  cursor: pointer;
  text-align: left;
  font: inherit;

  position: relative;
}

.toplink:focus-visible {
  outline: 2px solid var(--blue-accent-hover);
  outline-offset: 6px;
  border-radius: 0.7rem;
}

.toplink-label {
  font-size: 0.96rem;
  font-weight: 500;
}

.toplink-kicker {
  display: block;
  font-size: 0.75rem;
  color: #cbd5e1;
}

.toplink-chevron {
  font-size: 0.9rem;
  opacity: 0.7;
  transition: transform 150ms ease-out;
}

.toplink[aria-expanded="true"] .toplink-chevron {
  transform: rotate(180deg);
}

/* Underline accent */
.toplink::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -0.15rem;
  width: 0;
  height: 2px;
  background: var(--blue-accent-hover);
  opacity: 0.95;
  transition: width 150ms ease-out;
}

.toplink:hover,
.toplink:focus-visible {
  text-decoration: none;
}

.toplink:hover::after,
.toplink:focus-visible::after,
.toplink[aria-expanded="true"]::after {
  width: 100%;
}

/* Link-only variant (Search septic reports) */
.toplink--linkonly {
  text-decoration: none;
}

/* Emphasize search item */
.nav-item--search .toplink-label {
  color: var(--blue-accent-hover);
  font-weight: 600;
}

/* =========================
   Mega panels (base/mobile)
   ========================= */

.mega-panel {
  display: none;
  position: static; /* mobile stack */
  margin-top: 0.35rem;
  padding: 1rem 1.1rem;

  border-radius: 0.7rem;
  background: radial-gradient(circle at top left, #020617, var(--blue-surface));
  color: #e5e7eb;

  border: 1px solid var(--blue-border-soft);
  box-shadow: 0 18px 55px rgba(15, 23, 42, 0.7);
  z-index: 30;
}

.mega-panel.is-open {
  display: block; /* JS click-open */
}

/* Mega layout */
.mega-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.4rem;

  /* lock left alignment */
  justify-content: start;
  justify-items: start;
  text-align: left;
}

.mega-grid--two {
  grid-template-columns: 1fr;
}

.mega-col-title {
  font-size: 0.78rem;
  text-transform: none;
  letter-spacing: 0.13em;
  color: #9ca3af;
  margin: 0 0 0.4rem;
}

.mega-links {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mega-links li + li {
  margin-top: 0.5rem;
}

.mega-link {
  display: inline-block;
  font-size: 0.9rem;
  font-weight: 500;
  color: #e5e7eb;
  text-decoration: none;
}

.mega-link:hover,
.mega-link:focus-visible {
  color: var(--blue-accent-hover);
  text-decoration: none;
}

.mega-link:focus-visible {
  outline: 2px solid var(--blue-accent-hover);
  outline-offset: 4px;
  border-radius: 0.7rem;
}

.mega-link-desc {
  display: block;
  font-size: 0.82rem;
  color: #cbd5e1;
  margin-top: 0.18rem;
  max-width: 34rem;
}

/* Highlight card */
.mega-highlight {
  padding: 0.95rem 1.1rem;
  border-radius: 0.7rem;
  background: linear-gradient(145deg, #020617, #02081a);
  border: 1px solid var(--blue-border-soft);
  font-size: 0.86rem;
}

.mega-highlight p {
  margin: 0.4rem 0 0.35rem;
}

.mega-badge {
  display: inline-block;
  font-size: 0.7rem;
  text-transform: none;
  letter-spacing: 0.13em;
  padding: 0.12rem 0.65rem;
  border-radius: 999rem;
  background: rgba(56, 189, 248, 0.16);
  color: var(--blue-accent-hover);
}

.mega-highlight--small {
  margin-top: 0.85rem;
}

/* =========================
   Desktop behavior
   ========================= */

@media (min-width: 900px) {
  .nav-toggle {
    display: none;
  }

  .main-nav {
    padding-bottom: 1.2rem;
  }

  .nav-list {
    display: flex !important;
    flex-direction: row;
    gap: 1.2rem;
  }

  .nav-item {
    padding: 0.25rem 0;
    position: static; /* critical for mega anchoring */
  }

  .toplink {
    width: auto;
    padding-inline: 0;
  }

  .toplink::after {
    bottom: -0.35rem;
  }

  /* Mega panels become dropdown overlays */
  .mega-panel {
    position: absolute;
    top: calc(100% - 6px);

    /* Inset from viewport edges */
    left: 15px;
    right: 15px;

    /* Still cap to your design width */
    max-width: var(--max-width);
    margin-inline: auto;

    /* Keep close to trigger for easy hover */
    margin-top: 0;

    /* Ensure overlay sits above hero */
    z-index: 1000;
  }

  /* Hover bridge: prevents hover “fall through” */
  .mega-panel::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -24px;
    height: 24px;
    background: transparent;
  }

  /* Open on hover or keyboard focus */
  .nav-item:hover > .mega-panel,
  .nav-item:focus-within > .mega-panel {
    display: block;
  }

  /* Still honor click-open from JS */
  .mega-panel.is-open {
    display: block;
  }

  /* -------------------------------------------------
     Desktop mega grids: COMPACT LEFT-PACKED columns
     (prevents columns from spreading across the panel)
     ------------------------------------------------- */

  .mega-grid {
    grid-template-columns: max-content max-content max-content;
    column-gap: 3.75rem; /* ~60px */
  }

  .mega-grid--two {
    grid-template-columns: max-content max-content;
    column-gap: 3.75rem; /* ~60px */
  }

  /* Keep all mega content left-aligned */
  .mega-grid,
  .mega-grid--two {
    justify-content: start;
    justify-items: start;
    text-align: left;
  }
/* ============================================
   Services mega menu: prevent the highlight column
   from getting too wide (keeps layout clean)
   ============================================ */

@media (min-width: 900px) {
  /* Services menu only */
  #mega-services .mega-grid--two {
    /* Two columns, but bounded so the right card can't blow out */
    grid-template-columns: minmax(22rem, 40rem) minmax(18rem, 28rem);
    column-gap: 3rem; /* keeps it tidy without spreading */
    align-items: start;
  }

  /* Cap the highlight card width so it stays proportional */
  #mega-services .mega-highlight {
    max-width: 28rem;
  }

  /* Ensure long text wraps nicely instead of forcing width */
  #mega-services .mega-link-desc,
  #mega-services .mega-highlight p {
    max-width: 40rem;
  }
}

}
