/*
 * Clever Prep — header mega menu + mobile hamburger.
 *
 * The Bricks header template renders <section.cp-header-wrap><div.cp-header>…
 * with brand / nav / actions inside .cp-header. The megamenu JS wraps those
 * existing children in .cp-header__top and appends .cp-header__menu, then
 * controls visibility via [data-cp-active-menu] on .cp-header.
 */

/* ──────────────── Hover fade siblings (craft.do pattern) ──────────────── */
.cp-header__top:hover .cp-header__nav-link:not(:hover),
.cp-header__top:hover .cp-header__login:not(:hover) {
  opacity: 0.45;
}
.cp-header__nav-link, .cp-header__login {
  transition: color .15s ease, opacity .2s ease;
}

/* While a megamenu is open, dim non-active triggers — feels like the active
   one is "selected" */
.cp-header[data-cp-active-menu]:not([data-cp-active-menu=""])
  .cp-header__nav-link:not([data-cp-menu]) ,
.cp-header[data-cp-active-menu]:not([data-cp-active-menu=""])
  .cp-header__login {
  opacity: 0.4;
}
.cp-header[data-cp-active-menu="mcat"]      .cp-header__nav-link[data-cp-menu="mcat"],
.cp-header[data-cp-active-menu="optometry"] .cp-header__nav-link[data-cp-menu="optometry"],
.cp-header[data-cp-active-menu="services"]  .cp-header__nav-link[data-cp-menu="services"],
.cp-header[data-cp-active-menu="about"]     .cp-header__nav-link[data-cp-menu="about"] {
  opacity: 1;
}

/* ──────────────── Login dropdown ──────────────── */
.cp-login-dropdown {
  position: fixed;
  z-index: 200;
  /* `left` is set by JS as the center of the Login link; this translate
     centers the dropdown horizontally on that point */
  transform: translateX(-50%) translateY(-4px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .2s ease, visibility .2s ease, transform .2s ease;
  font-family: var(--cp-font-heading);
}
.cp-login-dropdown.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

/* The little triangular pointer between Login and the dropdown */
.cp-login-dropdown__pointer {
  position: absolute;
  top: -7px;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 8px;
  /* paint the triangle via clip-path; bg + border match the inner pill */
  background: var(--cp-nav-border);
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
}
.cp-login-dropdown__pointer::after {
  content: '';
  position: absolute;
  top: 1.5px; left: 50%;
  transform: translateX(-50%);
  width: 13px; height: 7px;
  background: #ffffff;     /* white to match inner */
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
}

.cp-login-dropdown__inner {
  background: #ffffff;
  border: 1px solid var(--cp-nav-border);
  border-radius: 14px;
  min-width: 280px;
  padding: 4px 14px;
  box-shadow: 0 12px 28px rgba(20, 14, 10, 0.06);
}

.cp-login-item {
  display: flex !important;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  text-decoration: none !important;
  color: var(--cp-text-primary);
  border-bottom: 1px solid var(--cp-nav-border);
  font-family: var(--cp-font-body);     /* Geist */
  font-size: 16px;
  font-weight: 400;
  letter-spacing: -0.2px;
  line-height: 1.2;
  transition: opacity .15s ease;
}
.cp-login-item:last-child { border-bottom: 0; }
.cp-login-item:hover { opacity: 0.85; }

.cp-login-item__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 8px;
  font-family: var(--cp-font-heading);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1;
}
.cp-login-item__icon--mcat {
  background: rgba(237, 134, 60, 0.16);
  color: var(--cp-orange);
}
.cp-login-item__icon--eyeq {
  background: rgba(55, 138, 221, 0.14);
  color: var(--cp-navy);
}
.cp-login-item__label { flex: 1; }
.cp-login-item__arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--cp-text-secondary);
  opacity: 0.55;
  transition: transform .15s, opacity .15s, color .15s;
  line-height: 0;
}
.cp-login-item__arrow svg { display: block; }
.cp-login-item:hover .cp-login-item__arrow {
  transform: translate(2px, -2px);
  opacity: 1;
  color: var(--cp-text-primary);
}

@media (max-width: 991px) {
  /* Login dropdown is desktop-only; hidden on mobile (Login is in the
     hamburger panel instead) */
  .cp-login-dropdown { display: none !important; }
}

/* No underline anywhere on header links (covers Reforma bundle defaults too) */
.cp-header__top a,
.cp-header__top a:hover,
.cp-header__panel a,
.cp-header__panel a:hover {
  text-decoration: none !important;
}

/* (Removed: blurred backdrop strip behind nav — was creating a progressive
   blur band over hero backgrounds.) */

/* ──────────────── Header pill — expands AS one element ──────────────── */
/* Override original 72px height + row flex with a column flex pill that grows
   when a menu is active. .cp-header__top holds the row layout at exactly 72px;
   the menu becomes the second flex child. */
.brxe-container.cp-header {
  flex-direction: column !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  height: 72px !important;
  padding: 0 !important;
  overflow: hidden;
  transition: height .4s cubic-bezier(.22,.61,.36,1);
}
.brxe-container.cp-header[data-cp-active-menu="mcat"],
.brxe-container.cp-header[data-cp-active-menu="optometry"],
.brxe-container.cp-header[data-cp-active-menu="mobile"] {
  height: var(--cp-header-open-height, 460px) !important;
}
/* Services + About are column-list panels — much shorter than the rich
   MCAT/Optometry panels. Use a shorter pill height so there's no blank
   space below the last link. */
.brxe-container.cp-header[data-cp-active-menu="services"],
.brxe-container.cp-header[data-cp-active-menu="about"] {
  height: 280px !important;
}

/* Top row inside the pill — exactly 72px, restores original row layout */
.cp-header__top {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  width: 100% !important;
  height: 72px !important;
  flex: 0 0 72px !important;
  padding: 0 26px;
}

/* Menu fills the remaining height when the pill is expanded */
.cp-header__menu {
  flex: 1 1 auto;
  width: 100%;
  overflow: hidden;
  border-top: 1px solid var(--cp-nav-border);
}
.cp-header__menu-panels {
  display: grid;
  padding: 24px 24px 24px;   /* matched top/bottom, tighter overall */
}
/* Services + About are column-list panels (no media) — tighten their
   vertical padding so the dropdown isn't unnecessarily tall. The rich
   MCAT / Optometry panels keep the original padding because their image
   anchors the bottom edge. */
.cp-header[data-cp-active-menu="services"] .cp-header__menu-panels,
.cp-header[data-cp-active-menu="about"]    .cp-header__menu-panels {
  padding: 14px 24px 18px;
}
.cp-header__panel {
  grid-row: 1;
  grid-column: 1;
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity .25s ease, transform .25s ease, visibility .25s;
  pointer-events: none;
}
.cp-header[data-cp-active-menu="mcat"]      .cp-header__panel[data-panel="mcat"],
.cp-header[data-cp-active-menu="optometry"] .cp-header__panel[data-panel="optometry"],
.cp-header[data-cp-active-menu="services"]  .cp-header__panel[data-panel="services"],
.cp-header[data-cp-active-menu="about"]     .cp-header__panel[data-panel="about"],
.cp-header[data-cp-active-menu="mobile"]    .cp-header__panel[data-panel="mobile"] {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
  position: relative;
  z-index: 1;
}

/* ──────────────── Rich panel (MCAT / Optometry) ──────────────── */
.cp-header__panel-rich {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr);
  gap: 24px;
  align-items: stretch;
}

/* LEFT — intro column on the white nav bg, top-aligned */
.cp-header__rich-intro {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0;
  align-self: flex-start;
}

/* RIGHT — pastel block containing features + media. Image is the visual anchor,
   so we give it more width and let it sit at the bottom of the block. */
.cp-header__rich-right {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr);
  gap: 16px;
  align-items: stretch;
  border-radius: var(--cp-radius-md);
  padding: 24px 24px 0 28px;   /* image flushes the bottom edge */
  overflow: hidden;
}
.cp-header__rich-right--cream { background: var(--cp-bg-pastel-cream); }
.cp-header__rich-right--blue  { background: var(--cp-bg-pastel-blue); }
.cp-header__rich-right--sage  { background: var(--cp-bg-pastel-sage); }
.cp-header__rich-title {
  font-family: var(--cp-font-heading);
  font-weight: 400;
  font-size: var(--cp-text-h4);
  line-height: 1.05;
  letter-spacing: var(--cp-tracking-h4);
  color: var(--cp-text-headline);
  margin: 0;
}
.cp-header__rich-body {
  font-family: var(--cp-font-body);
  font-weight: 300;
  font-size: var(--cp-text-body);
  line-height: 1.45;
  color: var(--cp-text-secondary);
  margin: 0;
  max-width: 36ch;
}
.cp-header__rich-ctas {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
}
.cp-header__rich-cta {
  font-family: var(--cp-font-body);
  font-size: var(--cp-text-body);
  font-weight: 400;
  color: var(--cp-text-primary);
  white-space: nowrap;
  transition: color .15s, border-color .15s, background-color .15s, transform .15s;
}
.cp-header__rich-cta--button {
  display: inline-flex;
  align-items: center;
  padding: 10px 20px;
  border: 1px solid var(--cp-border-card);
  background: #ffffff;
  border-radius: var(--cp-radius-sm);
}
.cp-header__rich-cta--button:hover {
  border-color: var(--cp-text-primary);
  transform: translateY(-1px);
}
.cp-header__rich-cta--link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 4px;
  color: var(--cp-text-primary);
}
.cp-header__rich-cta--link::after {
  content: '\2192';   /* → */
  display: inline-block;
  transition: transform .15s;
}
.cp-header__rich-cta--link:hover::after { transform: translateX(3px); }

/* Features column (now inside the pastel block) — top-aligned */
.cp-header__rich-features {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-self: flex-start;     /* don't stretch — keep at top */
  gap: 14px;
  padding: 0 0 24px 0;        /* match pastel block bottom padding */
}
.cp-header__rich-feature {
  display: flex;
  align-items: center;
  gap: 12px;
}
.cp-header__rich-feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--cp-text-primary);
  color: #ffffff;
  font-family: var(--cp-font-body);
  font-size: 13px;
  font-weight: 500;
}
/* The list/sparkle glyphs render bigger and outline-only */
.cp-header__rich-feature:nth-child(2) .cp-header__rich-feature-icon:not(.cp-header__rich-feature-icon--glass),
.cp-header__rich-feature:nth-child(3) .cp-header__rich-feature-icon:not(.cp-header__rich-feature-icon--glass) {
  background: transparent;
  color: var(--cp-text-primary);
  font-size: 18px;
}
/* Glass-icon variant — full-colour SVG, no navy circle. */
.cp-header__rich-feature-icon--glass {
  width: 26px;
  height: 26px;
  background: transparent !important;
  border-radius: 0 !important;
  object-fit: contain;
}
.cp-header__rich-feature-text {
  font-family: var(--cp-font-body);
  font-weight: 500;
  font-size: var(--cp-text-body);
  color: var(--cp-text-primary);
}

/* Media column — image anchored to bottom of the pastel block */
.cp-header__rich-media {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 240px;
  /* No bg — parent .cp-header__rich-right paints the pastel */
}
/* Cap image height for deterministic layout. object-fit: contain preserves
   aspect ratio; object-position: bottom keeps it flush with the bottom edge. */
.cp-header__rich-media-img {
  display: block;
  width: 100%;
  height: 280px;
  max-height: 280px;
  object-fit: contain;
  object-position: bottom center;
  user-select: none;
  pointer-events: none;
}

@media (max-width: 991px) {
  .cp-header__panel-rich { grid-template-columns: 1fr; gap: 16px; }
  .cp-header__rich-right { grid-template-columns: 1fr; padding: 20px; }
  .cp-header__rich-media { min-height: 160px; }
}

/* ──────────────── Megamenu panel layout (Services / About — link grid) ──────────────── */
.cp-header__panel-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 32px;
  align-items: start;
}
.cp-header__panel-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.cp-header__panel-heading {
  font-family: var(--cp-font-mono);
  font-size: var(--cp-text-small);
  font-weight: 300;
  letter-spacing: var(--cp-tracking-mono-sm);
  color: var(--cp-text-meta);
  text-transform: uppercase;
}
.cp-header__panel-link {
  font-family: var(--cp-font-heading);
  font-size: 22px;
  letter-spacing: -0.6px;
  line-height: 1.25;
  color: var(--cp-text-primary);
  text-decoration: none;
  transition: color .15s, transform .15s;
}
.cp-header__panel-link:hover {
  color: var(--cp-orange);
  transform: translateX(2px);
}
.cp-header__panel-link-desc {
  font-family: var(--cp-font-body);
  font-weight: 300;
  font-size: var(--cp-text-body);
  line-height: 1.45;
  color: var(--cp-text-secondary);
  margin-top: 2px;
}

/* ──────────────── Hamburger button (mobile only) ──────────────── */
.cp-header__hamburger {
  display: none;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 1px solid var(--cp-nav-border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
}
.cp-header__hamburger-bar {
  position: absolute;
  left: 50%;
  width: 16px;
  height: 1.5px;
  background: var(--cp-text-primary);
  border-radius: 1px;
  transform: translateX(-50%);
  transition: transform .25s ease, opacity .15s ease, top .25s ease;
}
.cp-header__hamburger-bar:nth-child(1) { top: 14px; }
.cp-header__hamburger-bar:nth-child(2) { top: 20px; }
.cp-header__hamburger-bar:nth-child(3) { top: 26px; }
.cp-header[data-cp-active-menu="mobile"] .cp-header__hamburger-bar:nth-child(1) {
  top: 20px;
  transform: translateX(-50%) rotate(45deg);
}
.cp-header[data-cp-active-menu="mobile"] .cp-header__hamburger-bar:nth-child(2) {
  opacity: 0;
}
.cp-header[data-cp-active-menu="mobile"] .cp-header__hamburger-bar:nth-child(3) {
  top: 20px;
  transform: translateX(-50%) rotate(-45deg);
}

/* ──────────────── Mobile menu panel ──────────────── */
.cp-header__panel--mobile { display: none; }

@media (max-width: 991px) {
  /* Slimmer pill on mobile — override the desktop !important height */
  .brxe-container.cp-header { height: 63px !important; }
  .brxe-container.cp-header[data-cp-active-menu="mcat"],
  .brxe-container.cp-header[data-cp-active-menu="optometry"],
  .brxe-container.cp-header[data-cp-active-menu="services"],
  .brxe-container.cp-header[data-cp-active-menu="about"],
  .brxe-container.cp-header[data-cp-active-menu="mobile"] {
    height: var(--cp-header-open-height, 460px) !important;
  }
  .cp-header__top { height: 63px !important; flex: 0 0 63px !important; padding: 0 18px; }

  .cp-header__hamburger { display: inline-flex; align-items: center; justify-content: center; }

  /* Hide desktop nav + login on mobile (already done by header css; safe to repeat) */
  .brxe-block.cp-header__nav { display: none !important; }
  .cp-header__login { display: none; }

  /* Mobile panel */
  .cp-header__panel--mobile { display: flex; flex-direction: column; gap: 4px; }
  .cp-header__panel-grid { grid-template-columns: 1fr; gap: 24px; }
  .cp-header__menu-panels { padding: 16px 20px 24px; grid-template-columns: minmax(0, 1fr); }

  /* Only the mobile panel is used at this breakpoint. Hide the desktop
     megamenu panels so they don't share the grid cell: their wide content was
     overflowing the container (eating the right padding) and inflating its
     height (clipping rows). */
  .cp-header__panel[data-panel="mcat"],
  .cp-header__panel[data-panel="optometry"],
  .cp-header__panel[data-panel="services"],
  .cp-header__panel[data-panel="about"] { display: none !important; }

  /* Pill height is sized to fit the content by JS (capped at the viewport);
     if it ever exceeds that cap the menu scrolls instead of clipping, so
     every row stays visible and tappable. */
  .cp-header__menu { overflow-y: auto; -webkit-overflow-scrolling: touch; }

  .cp-header__mobile-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 4px;
    border-top: 1px solid var(--cp-nav-border);
    cursor: pointer;
    font-family: var(--cp-font-heading);
    font-size: 20px;
    line-height: 1.2;
    color: var(--cp-text-primary);
    text-decoration: none;
    transition: color .15s;
  }
  .cp-header__mobile-row:first-child { border-top: 0; }

  /* Direct link row → ↗ */
  .cp-header__mobile-row--link::after {
    content: '↗';
    font-family: var(--cp-font-body);
    font-size: 16px;
    opacity: 0.6;
    transition: transform .2s, opacity .15s;
  }
  .cp-header__mobile-row--link:hover::after { transform: translate(2px, -2px); opacity: 1; }

  /* Expandable row → + that rotates to × on open */
  .cp-header__mobile-row--toggle::after {
    content: '+';
    font-family: var(--cp-font-body);
    font-size: 22px;
    line-height: 1;
    opacity: 0.65;
    transition: transform .2s, opacity .15s;
  }
  .cp-header__mobile-row--toggle.is-open::after {
    transform: rotate(45deg);
    opacity: 1;
  }

  /* Accordion children — collapsed by default. Uses max-height + visibility
     because the grid-template-rows:0fr trick leaked descendant text behind
     subsequent rows on some mobile browsers. */
  .cp-header__mobile-children {
    max-height: 0;
    overflow: hidden;
    visibility: hidden;
    transition: max-height .28s ease, visibility 0s linear .28s;
  }
  .cp-header__mobile-row--toggle.is-open + .cp-header__mobile-children {
    max-height: 600px;
    visibility: visible;
    transition: max-height .28s ease, visibility 0s linear 0s;
  }
  .cp-header__mobile-children-inner {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 0 12px 4px;
  }
  .cp-header__mobile-children-inner a {
    font-family: var(--cp-font-body);
    font-size: var(--cp-text-body);
    color: var(--cp-text-secondary);
    text-decoration: none;
    line-height: 1.4;
  }

  .cp-header__mobile-cta-row {
    display: flex; gap: 10px;
    margin-top: 12px;
    padding-top: 14px;
    border-top: 1px solid var(--cp-nav-border);
  }
  .cp-header__mobile-cta-row a {
    flex: 1;
    text-align: center;
    padding: 12px;
    border-radius: var(--cp-radius-sm);
    font-family: var(--cp-font-body);
    font-size: var(--cp-text-body);
    text-decoration: none;
  }
  .cp-header__mobile-cta-row a.is-primary {
    background: var(--cp-orange);
    color: #fff;
  }
  .cp-header__mobile-cta-row a.is-secondary {
    background: transparent;
    border: 1px solid var(--cp-nav-border);
    color: var(--cp-text-primary);
  }
}
