/**
 * Core Metrics Consulting - Header Stylesheet
 * Authoritative Visual & Design System implementation from final Build Guide Page 52-53
 * White background, 76px tall desktop / 64px mobile, sticky shrink to 64px on 40px scroll with 1px Border gray line.
 * Menu text: 16px, 600 weight, Deep navy (#0F2F3A); hover: Primary teal (#135C68) with 2px teal underline 6px below text.
 * No top utility bar.
 */

/* ==========================================================================
   1. Prohibit Top Utility Bar (Build Guide Page 52: "No top utility bar.")
   ========================================================================== */
.utility-bar {
  display: none !important;
}

/* ==========================================================================
   2. Main Site Header (Build Guide Page 52)
   "Look: white background, 76 px tall on desktop, 64 px on mobile. Logo on the left, 36–40 px tall.
   Sticky: stays at the top on scroll; after 40 px of scroll it shrinks to 64 px and gains
   a 1 px Border gray bottom line. Transition 200 ms."
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background-color: var(--cmc-white, #FFFFFF);
  border-bottom: 1px solid transparent;
  transition: height 200ms ease, border-color 200ms ease, box-shadow 200ms ease;
  height: 76px;
  width: 100%;
}

.site-header.scrolled {
  height: 64px;
  border-bottom: 1px solid var(--cmc-gray, #D8E3E5);
  box-shadow: none;
}

.site-header .wrap {
  width: var(--wrap);
  max-width: var(--max-width);
  height: 100%;
  margin-left: auto;
  margin-right: auto;
}

.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-24);
  position: relative;
}

/* ==========================================================================
   3. Site Branding & Logo (Build Guide Page 52: "36–40 px tall")
   ========================================================================== */
.site-branding {
  display: flex;
  align-items: center;
  flex: none;
}

.site-logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  height: 48px;
}

.site-logo img {
  height: 46px;
  width: auto;
  max-width: 240px;
  object-fit: contain;
  display: block;
}

.site-header.scrolled .site-logo {
  height: 42px;
}

.site-header.scrolled .site-logo img {
  height: 40px;
}

/* ==========================================================================
   4. Desktop Navigation (Build Guide Page 52)
   "Desktop menu, left to right after the logo: Services ▾ · Who We Help · About ▾ · Contact Us,
   then the 'Book a 15-Minute Call' primary button on the far right. No 'Home' item.
   Menu text: 16 px, 600 weight, Deep navy. Hover and current page: Primary teal with a 2 px
   teal underline 6 px below the text."
   ========================================================================== */
.main-navigation {
  display: flex;
  align-items: center;
  height: 100%;
  gap: var(--space-32);
}

.desktop-nav {
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex;
  align-items: center;
  height: 100%;
  gap: var(--space-24);
}

.desktop-nav > li {
  position: relative;
  list-style: none !important;
  margin: 0;
  padding: 0;
  height: 100%;
  display: flex;
  align-items: center;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 100%;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  color: var(--cmc-navy, #0F2F3A);
  text-decoration: none;
  transition: color 200ms ease;
  position: relative;
  cursor: pointer;
}

/* Hover and current page: Primary teal with a 2 px teal underline 6 px below the text (Page 52) */
.nav-link:hover,
.nav-link:focus,
.nav-item.current-menu-item > .nav-link,
.nav-item.current_page_item > .nav-link,
.desktop-nav > li.is-active > .nav-link {
  color: var(--cmc-teal, #135C68);
  text-decoration: underline;
  text-underline-offset: 6px;
  text-decoration-thickness: 2px;
  text-decoration-color: var(--cmc-teal, #135C68);
}

.nav-link .chevron {
  font-size: 12px;
  line-height: 1;
  transition: transform 150ms ease;
  display: inline-block;
}

.desktop-nav > li:hover .chevron,
.desktop-nav > li.is-active .chevron {
  transform: rotate(180deg);
}

/* ==========================================================================
   5. Dropdowns & Mega Menus (Build Guide Page 52-53)
   "Fade in 150 ms. Behavior: menus open on hover (150 ms delay) and on click or Enter;
   close on Esc, on click outside and when focus leaves. Use proper button elements with aria-expanded.
   Services mega menu: white panel, full content width, 1 px border, 12 px radius, 32 px padding,
   4 columns with 14 px Body slate group titles.
   About dropdown: a simple white list, 240 px wide: About Us · How We Work · Security & HIPAA."
   ========================================================================== */
.dropdown-menu,
.megamenu-panel {
  position: absolute;
  top: 100%;
  background-color: var(--cmc-white, #FFFFFF);
  border: 1px solid var(--cmc-gray, #D8E3E5);
  border-radius: var(--radius-pricing, 12px);
  box-shadow: 0 10px 30px rgba(15, 47, 58, 0.08);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 150ms ease, visibility 150ms ease;
  z-index: 1010;
  list-style: none;
  margin: 0;
}

/* Services Mega Menu: full content width of .header-inner.wrap */
.has-megamenu {
  position: static !important;
}

.megamenu-panel {
  left: 0;
  right: 0;
  width: 100%;
  padding: 32px;
  box-sizing: border-box;
}

.megamenu-inner {
  width: 100%;
}

.megamenu-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 32px;
}

.megamenu-col {
  display: flex;
  flex-direction: column;
}

.megamenu-heading {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  color: var(--cmc-slate, #2F4858);
  margin-top: 0;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--cmc-gray, #D8E3E5);
  text-transform: none;
  letter-spacing: normal;
}

.megamenu-list {
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.megamenu-list li {
  margin: 0;
  padding: 0;
  list-style: none;
}

.megamenu-list li a {
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 500;
  color: var(--cmc-navy, #0F2F3A);
  text-decoration: none;
  line-height: 1.4;
  display: inline-block;
  transition: color 150ms ease;
}

.megamenu-list li a:hover,
.megamenu-list li a:focus {
  color: var(--cmc-teal, #135C68);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.megamenu-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--cmc-gray, #D8E3E5);
}

.megamenu-all-link {
  font-size: 15px;
  font-weight: 600;
  color: var(--cmc-teal, #135C68);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: transform 150ms ease;
}

.megamenu-all-link:hover {
  text-decoration: underline;
  transform: translateX(2px); /* arrow moves 2px right on hover per Page 53 */
}

/* About dropdown: 240px wide */
.has-dropdown {
  position: relative !important;
}

.dropdown-menu--about {
  left: 0;
  width: 240px;
  padding: var(--space-8) 0;
}

.dropdown-menu--about li {
  margin: 0;
  padding: 0;
  list-style: none;
}

.dropdown-menu--about li a {
  display: block;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 500;
  color: var(--cmc-navy, #0F2F3A);
  text-decoration: none;
  transition: color 150ms ease, background-color 150ms ease;
}

.dropdown-menu--about li a:hover,
.dropdown-menu--about li a:focus {
  color: var(--cmc-teal, #135C68);
  background-color: var(--cmc-aqua, #EAF2F2);
  text-decoration: none;
}

/* Show Dropdowns on Hover, Active or Focus-within */
.has-megamenu:hover > .megamenu-panel,
.has-megamenu:focus-within > .megamenu-panel,
.has-megamenu.is-active > .megamenu-panel,
.has-dropdown:hover > .dropdown-menu,
.has-dropdown:focus-within > .dropdown-menu,
.has-dropdown.is-active > .dropdown-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Hide mobile navigation wrapper on desktop */
.mobile-nav-panel,
.mobile-nav-wrapper {
  display: none !important;
}

.main-navigation-backdrop {
  display: none;
}

/* ==========================================================================
   6. Header Right Actions (Phone & Primary CTA Button)
   "Phone: from 1280 px wide, show (302) 551-6591 as a 14 px text link just left
   of the button. Hide it below 1280 px.
   Button label: every contact button reads 'Book a 15-Minute Call' and goes to /contact."
   ========================================================================== */
.header-actions {
  display: flex;
  align-items: center;
  gap: 20px;
  flex: none;
}

.header-phone-link {
  font-size: 14px;
  font-weight: 600;
  color: var(--cmc-slate, #2F4858);
  text-decoration: none;
  transition: color 200ms ease;
  white-space: nowrap;
}

.header-phone-link:hover,
.header-phone-link:focus {
  color: var(--cmc-teal, #135C68);
  text-decoration: underline;
}

/* Hide phone below 1280px (Build Guide Page 52) */
@media (max-width: 1279px) {
  .header-phone-link {
    display: none !important;
  }
}

.header-actions .button {
  height: 48px;
  min-height: 48px;
  padding: 0 var(--space-24);
  background-color: var(--cmc-teal, #135C68);
  color: #FFFFFF !important;
  border-radius: var(--radius-button, 10px);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  transition: background-color 200ms ease;
}

.header-actions .button:hover {
  background-color: var(--cmc-navy, #0F2F3A);
  color: #FFFFFF !important;
}

/* ==========================================================================
   7. Mobile Navigation Drawer (Build Guide Page 53)
   "Mobile: logo left, menu icon right (Lucide menu, 44 px tap area).
   The icon opens a full-height drawer from the right (100% width below 640 px,
   400 px above). Services and About are accordions; every row is at least 48 px
   tall with a 1 px divider. The 'Book a 15-Minute Call' button is pinned at
   the bottom of the drawer, full width, with a tap-to-call phone link under it.
   Lock page scroll while the drawer is open; close with the X icon or Esc and
   return focus to the menu icon."
   ========================================================================== */
.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--cmc-navy, #0F2F3A);
  border-radius: var(--radius-sm, 8px);
}

.menu-toggle:focus {
  outline: 2px solid var(--cmc-teal, #135C68);
  outline-offset: 2px;
}

.menu-toggle svg {
  width: 24px;
  height: 24px;
  stroke: var(--cmc-navy, #0F2F3A);
}

/* Lock page scroll while drawer is open (Page 53) */
body.lock-scroll {
  overflow: hidden !important;
  touch-action: none;
}

@media (max-width: 1023px) {
  .site-header {
    height: 64px;
  }

  .site-logo {
    height: 38px;
  }

  .site-logo img {
    height: 36px;
    max-width: 180px;
  }

  .menu-toggle {
    display: flex;
  }

  .desktop-nav {
    display: none !important;
  }

  .header-actions {
    display: none !important;
  }

  /* Backdrop Overlay */
  .main-navigation-backdrop {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 47, 58, 0.45);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 250ms ease, visibility 250ms ease;
    pointer-events: none;
  }

  body.lock-scroll .main-navigation-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  /* Full-height drawer sliding from the right (100% width below 640px, 400px above) */
  .main-navigation {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 400px;
    max-width: 100%;
    height: 100vh;
    background-color: var(--cmc-white, #FFFFFF);
    z-index: 10000;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: 0;
    gap: 0;
    box-shadow: -6px 0 24px rgba(15, 47, 58, 0.15);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 250ms cubic-bezier(0.16, 1, 0.3, 1), visibility 250ms ease;
    overflow: hidden;
  }

  .main-navigation:not(.is-open) {
    display: none !important;
  }

  .main-navigation.is-open {
    display: flex !important;
    transform: translateX(0);
    visibility: visible;
  }

  /* Mobile Nav Panel structure */
  .mobile-nav-panel,
  .mobile-nav-wrapper {
    display: flex !important;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow: hidden;
  }

  /* Drawer Top Header */
  .mobile-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    min-height: 64px;
    padding: 0 20px;
    border-bottom: 1px solid var(--cmc-gray, #D8E3E5);
    background-color: var(--cmc-white, #FFFFFF);
    flex: none;
  }

  .mobile-drawer-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    background: none;
    border: none;
    font-size: 32px;
    line-height: 1;
    color: var(--cmc-navy, #0F2F3A);
    cursor: pointer;
    padding: 0;
    border-radius: var(--radius-sm, 8px);
  }

  .mobile-drawer-close:focus {
    outline: 2px solid var(--cmc-teal, #135C68);
    outline-offset: 2px;
  }

  /* Middle scrollable navigation list */
  .mobile-nav-list {
    flex: 1 1 auto;
    overflow-y: auto;
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .mobile-nav-item {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border-bottom: 1px solid var(--cmc-gray, #D8E3E5);
  }

  .mobile-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 48px;
    padding: 0 20px;
  }

  .mobile-top-link {
    font-size: 16px;
    font-weight: 600;
    color: var(--cmc-navy, #0F2F3A);
    text-decoration: none;
    display: flex;
    align-items: center;
    min-height: 48px;
    flex: 1;
  }

  .mobile-top-link:hover,
  .mobile-top-link:focus {
    color: var(--cmc-teal, #135C68);
    text-decoration: underline;
  }

  .mobile-accordion-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    background: none;
    border: none;
    font-size: 22px;
    font-weight: 600;
    color: var(--cmc-navy, #0F2F3A);
    cursor: pointer;
    padding: 0;
  }

  .mobile-accordion-toggle:focus {
    outline: 2px solid var(--cmc-teal, #135C68);
  }

  .mobile-accordion-panel {
    background-color: var(--cmc-aqua, #EAF2F2);
    padding: 8px 20px 16px;
    border-top: 1px solid var(--cmc-gray, #D8E3E5);
  }

  .mobile-subgroup-list,
  .mobile-sub-list,
  .mobile-sub-sub-list {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .mobile-group-title {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--cmc-slate, #2F4858);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 14px;
    margin-bottom: 4px;
  }

  .mobile-sub-sub-list li,
  .mobile-sub-list li {
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    border-bottom: 1px solid rgba(216, 227, 229, 0.7);
  }

  .mobile-sub-sub-list li a,
  .mobile-sub-list li a {
    display: flex;
    align-items: center;
    min-height: 48px;
    font-size: 15px;
    color: var(--cmc-navy, #0F2F3A);
    text-decoration: none;
    line-height: 1.4;
    padding: 2px 0;
  }

  .mobile-sub-sub-list li a:hover,
  .mobile-sub-list li a:hover,
  .mobile-sub-sub-list li a:focus,
  .mobile-sub-list li a:focus {
    color: var(--cmc-teal, #135C68);
    text-decoration: underline;
  }

  .mobile-all-link-item {
    padding-top: 12px;
    list-style: none !important;
  }

  .mobile-all-link {
    font-size: 15px;
    font-weight: 600;
    color: var(--cmc-teal, #135C68);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    min-height: 48px;
  }

  .mobile-all-link:hover {
    text-decoration: underline;
  }

  /* Pinned Bottom Actions: full-width button + tap-to-call phone link */
  .drawer-bottom-actions {
    flex: none;
    padding: 16px 20px 20px;
    border-top: 1px solid var(--cmc-gray, #D8E3E5);
    background-color: var(--cmc-white, #FFFFFF);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
  }

  .drawer-bottom-actions .button {
    width: 100% !important;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 52px;
    min-height: 52px;
    font-size: 16px;
    font-weight: 600;
    background-color: var(--cmc-teal, #135C68);
    color: #FFFFFF !important;
    border-radius: var(--radius-button, 10px);
    text-decoration: none;
  }

  .drawer-bottom-actions .button:hover {
    background-color: var(--cmc-navy, #0F2F3A);
  }

  .drawer-phone-link {
    font-size: 15px;
    font-weight: 600;
    color: var(--cmc-slate, #2F4858);
    text-decoration: underline;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .drawer-phone-link:hover,
  .drawer-phone-link:focus {
    color: var(--cmc-teal, #135C68);
  }
}

@media (max-width: 639px) {
  .main-navigation {
    width: 100% !important; /* 100% width below 640px */
  }
}
