/*
  Navigation & State Requirements Redesign
  Spec: CSI-style utility bar + Main Nav + Mega Menus
*/

:root {
  --nav-accent: #0B8A4B;
  --nav-accent-rgb: 11, 138, 75;
  --nav-utility-bg: #0B8A4B; /* Updated per QA: Dark navy replaced with Borealis Green */
  --nav-utility-text: #FFFFFF;
  --nav-main-bg: #FFFFFF;
  --nav-text-primary: #111827;
  --nav-text-secondary: #4B5563;
  --nav-text-muted: #9CA3AF;
  --nav-border: #E5E7EB;
}

/* Fix for "Pushed Down" Layout Issue */
/* Since new nav is sticky/block, we must remove the legacy padding intended for the fixed header */
html, body {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

.hero-section,
body > main,
.main-content {
    padding-top: 0 !important;
    margin-top: 0 !important;
}

/* QA Fix: 50% spacing for first section (48px vs 96px) */
main > .campaign-section:first-child,
main > .campaign-hero:first-child {
    padding-top: 48px !important;
    margin-top: 0 !important;
}

/* Ensure Nav bars hug the top */
.util-bar, .site-nav {
    margin-top: 0 !important;
}

/* =========================================
   2. Utility Bar
   ========================================= */
.util-bar {
  background-color: var(--nav-utility-bg) !important; /* Force green per QA */
  color: var(--nav-utility-text);
  height: 44px; /* Slightly taller for larger text */
  font-size: 14px;
  line-height: 1.4;
  width: 100%;
  position: relative;
  z-index: 1002; /* Above main nav */
}

.util-bar__inner {
  max-width: var(--container-width, 1120px);
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.util-bar__items {
  display: flex;
  align-items: center;
  gap: 24px;
}

.util-bar__item {
  color: var(--nav-utility-text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  transition: opacity 0.15s ease;
}

.util-bar__item:hover {
  opacity: 0.85;
}

.util-bar__tagline {
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* Utility Bar CTA Button */
.util-bar__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 16px;
  background: white;
  color: #111827;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.1s ease;
}

.util-bar__cta:hover {
  background: #F3F4F6;
}

/* Site Nav CTA Microcopy */
.site-nav__cta-micro {
  font-size: 12px;
  color: #6B7280;
  display: none;
}

@media (min-width: 1280px) {
  .site-nav__cta-micro {
    display: block;
  }
}

@media (max-width: 639px) {
  .util-bar {
    height: 48px;
  }
  .util-bar__tagline {
    display: none;
  }
  .util-bar__inner {
    justify-content: flex-end; /* Align icons to right */
  }
  .util-bar__item span:not(.icon) {
    display: none; /* Hide text labels */
  }
  .util-bar__item {
    font-size: 16px; /* Larger icons */
    padding: 8px;
    min-width: 40px;
    min-height: 40px;
    justify-content: center;
  }
  .util-bar__item--portal {
    border: none;
    padding: 8px;
  }
}

/* =========================================
   3. Main Nav
   ========================================= */
.site-nav {
  height: 72px;
  background: var(--nav-main-bg);
  position: sticky;
  top: 0; /* Or 36px if utility bar is fixed, spec says sticky top: 32px or 0. Let's assume utility scrolls away or sits above. */
  z-index: 1001;
  width: 100%;
  border-bottom: 1px solid transparent;
  transition: box-shadow 0.2s ease;
  overflow: visible !important;
}

.site-nav.scrolled {
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
}

.site-nav__inner {
  max-width: var(--container-width, 1120px);
  margin: 0 auto;
  padding: 0 24px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.site-nav__logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--nav-text-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
}
.site-nav__logo img {
  height: 32px;
  transform-origin: center;
  transition: transform 0.5s var(--ease-out, ease), filter 0.35s ease;
  filter: drop-shadow(0 0 6px rgba(var(--nav-accent-rgb, 11, 138, 75), 0.25));
}
.site-nav__logo:hover img {
  transform: rotate(180deg);
  filter: drop-shadow(0 0 12px rgba(var(--nav-accent-rgb, 11, 138, 75), 0.45));
}

.site-nav__links {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 100%;
}

.site-nav__link {
  position: relative;
  border: 0;
  background: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px; /* Increased from 14px for better readability */
  font-weight: 500; /* Added explicit weight */
  line-height: 1.4;
  letter-spacing: 0.01em; /* Adjusted spacing */
  color: var(--nav-text-primary);
  /* opacity: 0.9; Removed for better contrast */
  padding: 0 16px; /* Increased padding slightly */
  height: 72px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  transition: color 0.15s ease;
}

.site-nav__link span {
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
}

.site-nav__link:hover {
  color: var(--nav-accent);
}

.site-nav__link::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 0;
  height: 2px;
  background: transparent;
  transition: background 0.15s ease;
}

.site-nav__link:hover::after,
.site-nav__link--active::after {
  background: var(--nav-accent);
}

.site-nav__link--active {
  color: var(--nav-accent);
  font-weight: 600;
}

.site-nav__link:focus-visible {
  outline: 2px solid var(--nav-accent);
  outline-offset: -4px; /* Inside */
}

.site-nav__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: 999px;
  background: var(--nav-accent);
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.2s ease, transform 0.1s ease;
}

.site-nav__cta:hover {
  background: #09703d; /* Darker shade */
  color: white;
}

.site-nav__menu-toggle {
  display: none; /* Hidden on desktop */
  background: none;
  border: none;
  cursor: pointer;
  font-size: 24px;
  color: var(--nav-text-primary);
  padding: 8px;
}

/* Main Nav Responsive */
@media (min-width: 1024px) and (max-width: 1279px) {
  .site-nav__link {
    font-size: 14px;
    padding: 0 10px;
  }
  .label-full { display: none; }
  .label-short { display: inline; }
}
@media (min-width: 1280px) {
  .label-short { display: none; }
}

@media (max-width: 1023px) {
  .site-nav__links, .site-nav__cta {
    display: none;
  }
  .site-nav__menu-toggle {
    display: block;
  }
}

/* =========================================
   4 & 5. Mega Nav
   ========================================= */
.mega-nav {
  position: absolute;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  top: 72px;
  /* Hidden by default so closed mega-menus never contribute to mobile scrollWidth/overflow. */
  display: none;
  width: 90vw;
  max-width: 1100px;
  padding: 24px 32px 32px; /* More breathing room */
  background: #FFFFFF;
  border-radius: 16px; /* Smoother */
  border: 1px solid rgba(0,0,0,0.06); /* Crisp border */
  box-shadow: 0 24px 48px -12px rgba(15, 23, 42, 0.15), 0 0 0 1px rgba(0,0,0,0.02); /* Deep shadow + outline */
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  pointer-events: none;
  box-sizing: border-box;
  height: auto !important; /* Prevent stretching */
  max-height: 85vh;
  overflow-y: auto;
}

/* Force content to top and compact */
.mega-nav section,
.mega-nav p,
.mega-nav h2,
.mega-nav h3,
.mega-nav .mega-hero__eyebrow,
.mega-nav .mega-nav__header-label {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* Trigger logic handled via CSS hover for simplicity, OR JS for a11y.
   Implementing standard CSS hover for desktop, JS handles aria-expanded/visibility */
.site-nav__link--has-mega:hover ~ .mega-nav, /* Sibling approach logic usually requires specific DOM structure or JS. Using JS class toggling is safer for "Mega" menus. */
.site-nav__link--has-mega:focus ~ .mega-nav,
.mega-nav:hover,
.mega-nav:focus-within {
  /* This CSS-only hover is tricky if mega-nav isn't a child.
     We will assume JS toggles a class 'is-open' or we structure HTML so mega-nav is inside the list item/container if possible,
     but the spec put it outside. We will rely on the `navbar.php` structure.
     If using specific markup: */
}

/* Utility class for JS toggle */
.mega-nav.is-open {
  display: block;
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.mega-nav--services.is-open {
  display: grid;
  grid-template-columns: 28fr 24fr 24fr 24fr;
  gap: 16px;
  align-items: start;
  align-content: start; /* Fix vertical spread */
}

.mega-nav--insurance.is-open {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  align-items: start;
  align-content: start; /* Fix vertical spread */
}

/* NEW: Agency Governance Mega Nav */
.mega-nav--governance.is-open {
  display: grid;
  grid-template-columns: 280px 1fr 1fr;
  gap: 24px;
  align-items: start;
  align-content: start;
}

/* NEW: Resources Mega Nav (was State Solutions) */
.mega-nav--states.is-open {
  display: grid;
  grid-template-columns: 260px 1fr 1fr;
  gap: 24px;
  align-items: start;
  align-content: start;
}

/* Insurance State Grid Internals */
.mega-nav__states-col {
  height: auto !important;
}

.mega-nav__state-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
  align-content: start;
}

.mega-nav__state-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  justify-content: flex-start; /* Fix flex spread */
}

.mega-nav--resources.is-open {
  display: grid;
  grid-template-columns: 28fr 24fr 24fr 24fr;
  gap: 16px;
  align-items: start;
  align-content: start;
}
.mega-nav--resources__grid {
    display: contents; /* Allow children to sit on the parent grid */
}

/* Mega Hero (Col 1 of Insurance) */
.mega-hero {
    background: #F9FAFB; /* Subtle background for contrast */
    padding: 24px;
    border-radius: 12px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.mega-hero__eyebrow {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #4B5563; /* Darker for contrast */
  margin-bottom: 8px;
  font-weight: 700;
}
.mega-hero__headline {
  font-size: 18px !important; /* Force override */
  font-weight: 700;
  color: #111827;
  line-height: 1.3;
  margin-bottom: 12px;
}
.mega-hero__body {
  font-size: 14px !important; /* Force override of unified-design-system */
  color: #4B5563;
  margin-bottom: 20px;
  line-height: 1.5;
  flex-grow: 1; /* Pushes link down */
}
.mega-hero__link {
  font-size: 14px;
  font-weight: 600;
  color: var(--nav-accent);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
}
.mega-hero__link:hover {
    text-decoration: underline;
}

/* Mega Items */
.mega-nav__header-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #4B5563; /* Darker for contrast */
  margin-bottom: 12px !important;
  display: block;
  line-height: 1;
  border-bottom: 1px solid #F3F4F6;
  padding-bottom: 8px !important;
}

.mega-nav__item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  background: transparent;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  margin-bottom: 4px;
  height: auto; /* Prevent stretching */
  border: 1px solid transparent;
}

.mega-nav__title {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  line-height: 1.2;
  margin: 0 !important; /* Zero margins */
  transition: color 0.15s ease;
}

.mega-nav__desc {
  font-size: 14px;
  color: #4B5563; /* Darker for contrast */
  line-height: 1.5;
  display: block;
  white-space: normal;
  margin: 0 !important; /* Zero margins */
}

.mega-nav__item:hover {
  background: rgba(11,138,75,0.04);
  border-color: rgba(11,138,75,0.1);
  /* transform: translateY(-1px); REMOVED to prevent scroll jitter */
}
.mega-nav__item:hover .mega-nav__title {
  color: var(--nav-accent);
}

.mega-nav__item:focus-visible {
  outline: 2px solid var(--nav-accent);
  outline-offset: 3px;
  background: rgba(11,138,75,0.06);
}

/* =========================================
   6. State Requirements Panel
   ========================================= */
.state-nav__header {
  margin-bottom: 24px;
}
.state-nav__header .eyebrow {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #4B5563; /* Darker */
  margin-bottom: 4px;
  display: block;
  font-weight: 600;
}
.state-nav__header h2 {
  font-size: 22px; /* Slightly larger */
  font-weight: 700;
  color: #111827;
  margin-bottom: 8px;
  margin-top: 0;
}
.state-nav__header .body {
  font-size: 16px;
  color: #374151; /* Darker */
  margin-top: 0;
  line-height: 1.5;
}

.state-nav__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 16px;
  margin-top: 24px;
}

@media (max-width: 1024px) {
  .state-nav__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .state-nav__grid { grid-template-columns: 1fr; }
}

.state-tile {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--nav-border);
  background: linear-gradient(135deg, rgba(249, 250, 251, 1), rgba(255, 255, 255, 1));
  text-decoration: none;
  transition: all 0.16s ease;
}

.state-tile__icon {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 0, rgba(11,138,75,0.30), rgba(11,138,75,0.05));
  border: 1px solid rgba(15, 23, 42, 0.06);
  flex-shrink: 0;
}

.state-tile__abbr {
  font-size: 14px;
  font-weight: 600;
  color: var(--nav-accent);
}

.state-tile__text {
    flex: 1;
}

.state-tile__row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.state-tile__state {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
}

.state-tile__badge {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(11,138,75,0.08);
  color: #065F46;
}

.state-tile__law {
  margin-top: 4px;
  font-size: 14px;
  color: #374151; /* Darker */
  margin-bottom: 0;
  line-height: 1.4;
}

.state-tile__hint {
  margin-top: 4px;
  font-size: 14px;
  color: #6B7280; /* Darker */
  margin-bottom: 0;
  line-height: 1.4;
}

.state-tile:hover,
.state-tile:focus-visible {
  border-color: rgba(11,138,75,0.35);
  background: linear-gradient(135deg, rgba(240,253,244,1), rgba(255,255,255,1));
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}
.state-tile:focus-visible {
  outline: 2px solid var(--nav-accent);
  outline-offset: 2px;
}

/* State tile highlight from map hover */
.state-tile--map-hover {
  border-color: rgba(11,138,75,0.35);
  background: linear-gradient(135deg, rgba(240,253,244,1), rgba(255,255,255,1));
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

/* Mobile Menu Styles */
.mobile-menu-wrapper {
  position: fixed;
  inset: 0;
  z-index: 2000;
  overflow: hidden;
  pointer-events: none;
  visibility: hidden;
}
.mobile-menu-wrapper.mobile-menu-open {
  pointer-events: auto;
  visibility: visible;
}
.mobile-menu-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background: rgba(0,0,0,0.5);
  z-index: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s;
}
.mobile-menu-drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: 85%;
  max-width: 400px;
  height: 100vh;
  height: 100dvh;
  background: white;
  z-index: 1;
  /* Use transforms so the off-canvas drawer does not create horizontal overflow on small screens. */
  transform: translateX(105%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  padding: 24px;
  padding-top: calc(24px + env(safe-area-inset-top));
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.mobile-menu-open .mobile-menu-overlay { opacity: 1; visibility: visible; }
.mobile-menu-open .mobile-menu-drawer { transform: translateX(0); }

/* Prevent background scroll when the drawer is open */
body.mobile-menu-open { overflow: hidden; }

.mobile-nav-link {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    padding: 16px 0;
    border-bottom: 1px solid #E5E7EB;
    text-decoration: none;
}
.mobile-nav-subitem {
    display: block;
    font-size: 14px;
    color: #4B5563;
    padding: 12px 0 12px 16px;
    text-decoration: none;
}

/* Mobile Nav Section with sub-links */
.mobile-nav-section {
    padding: 8px 0;
    border-bottom: 1px solid #E5E7EB;
}
.mobile-nav-section-title {
    display: block;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6B7280;
    padding: 8px 0 4px;
}
.mobile-nav-link--sub {
    font-size: 15px;
    font-weight: 500;
    color: #374151;
    padding: 12px 0 12px 16px;
    border-bottom: none;
}
.mobile-nav-link--sub:last-child {
    padding-bottom: 8px;
}
.mobile-cta-container {
    margin-top: auto;
    padding-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.mobile-cta-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 14px;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    min-height: 48px;
}
.mobile-cta-btn--primary {
    background: var(--nav-accent);
    color: white;
}
.mobile-cta-btn--primary:hover {
    background: #097a42;
    color: white;
}
.mobile-cta-btn--secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.25);
}
.mobile-cta-btn--secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

/* ==========================================================================
   SIMPLE DROPDOWN (Contact/About)
   ========================================================================== */

.site-nav__link--has-dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.site-nav__dropdown-icon {
  font-size: 10px;
  opacity: 0.7;
  transition: transform 0.2s ease;
}

.site-nav__link--has-dropdown {
  position: relative;
}

.site-nav__link--has-dropdown:hover .site-nav__dropdown-icon {
  opacity: 1;
}

/* Show dropdown on hover */
.site-nav__link--has-dropdown:hover + .site-nav__dropdown,
.site-nav__dropdown:hover {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.site-nav__links {
  position: relative;
}

.site-nav__dropdown {
  position: absolute;
  top: 100%;
  right: 80px;
  background: white;
  border: 1px solid rgba(15, 23, 42, 0.10);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
  padding: 8px;
  min-width: 220px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
  z-index: 1000;
  margin-top: 8px;
}

.site-nav__dropdown.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.site-nav__dropdown-item {
  display: block;
  padding: 12px 16px;
  border-radius: 8px;
  text-decoration: none;
  transition: background-color 0.15s ease;
}

.site-nav__dropdown-item:hover {
  background-color: #F8FAFC;
}

.site-nav__dropdown-title {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 2px;
}

.site-nav__dropdown-desc {
  display: block;
  font-size: 13px;
  color: #6B7280;
  line-height: 1.4;
}
