/**
 * Header, main menu (mega menu) and header search.
 *
 * Place at css/header.css; loaded by plannera/global-styling after style.css.
 * Replaces the "Header", "Mega Menu" and "Search" sections of style.css.
 * Desktop only for now; the mobile header comes later.
 *
 * Sizes scale between the 992 and 1920 designs:
 *   clamp(SMALL, calc(SMALL + (LARGE - SMALL) * (100vw - 992px) / 928), LARGE)
 */

/* ---------------------------------------------------------------------------
 * Header bar
 * ------------------------------------------------------------------------ */

.site-header {
  position: fixed;
  top: calc(var(--drupal-displace-offset-top, 0px) + 1.5rem);
  left: 0;
  right: 0;
  z-index: 500;
  margin-inline: auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .1);
  transition: background-color .25s, box-shadow .25s;
}

@media (max-width: 768px) {
  .site-header {
    top: calc(var(--drupal-displace-offset-top, 0px) + 0.5rem);
  }
}

.site-header.is-scrolled {
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .1);
}

/* A panel (menu or search) hangs below the bar, so square off its bottom corners. */
.site-header.is-menu-open {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

body:not(.has-hero) main {
  padding-top: calc(var(--header-height, 72px) + 1.5rem);
}

/* No fixed height: padding + content set it, and global.js measures it. */
.site-header__nav {
  box-sizing: border-box;
  padding: 16px 24px;
}

.site-header__left {
  gap: clamp(20px, calc(20px + 20 * (100vw - 992px) / 928), 80px);
  height: 100%;
}

@media (max-width: 768px) {
  .site-header__nav {
    padding: 7px 16px;
  }

  .site-header__left {
    gap: clamp(10px, calc(10px + 10 * (100vw - 992px) / 928), 80px);
    height: 100%;
  }
}

.site-header__left img {
  display: block;
  max-height: 40px;
  width: auto;
}

.progress-bar {
  background-color: #7e61de;
  width: 0%;
  max-width: 100%;
  display: block;
  height: inherit;
}

@media (max-width: 1200px) {
  .site-header__left img {
    max-height: 30px;
  }
}

@media (max-width: 992px) {
  .site-header__left img {
    max-height: 25px;
  }

  .site-header__nav {
    padding: 16px 8px;
  }
}

/* ---------------------------------------------------------------------------
 * Top-level menu
 * ------------------------------------------------------------------------ */

/* Scoped to .site-header so it beats any leftover `.menu-wrapper ul` rule. */
.site-header .main-nav {
  display: flex;
  align-items: flex-end;
  gap: clamp(10px, calc(10px + 10 * (100vw - 992px) / 928), 32px);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Panels position against .site-header, so nothing between them may be
   positioned. Logged in, Drupal's .contextual-region adds position: relative
   to the menu block wrapper. */
.site-header__nav,
.site-header__left,
.site-header .menu-wrapper,
.site-header .menu-wrapper > *,
.main-nav,
.main-nav__item {
  position: static;
}

.main-nav__link {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  font-family: 'Inter', sans-serif;
  color: #24125f;
  text-decoration: none;
}

.main-nav__link:hover,
.main-nav__link:focus {
  color: #24125f;
  text-decoration: none;
}

/* Dropdown parent: page link + caret button, sharing one underline. */
.main-nav__parent {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 2px;
}

/* Same height as the label's line box, so the caret sits on the label's line. */
.main-nav__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: calc(16px * 1.55);
  padding: 0;
  border: 0;
  background: none;
  color: #24125f;
  cursor: pointer;
}

.main-nav__toggle:focus-visible,
.main-nav__link:focus-visible {
  outline: 2px solid #7e61de;
  outline-offset: 4px;
  border-radius: 4px;
}

.main-nav__eyebrow {
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: #5c5c5c;
}

@media (max-width: 992px) {
  .main-nav__eyebrow {
    font-size: 9px;
  }
}

.main-nav__label {
  position: relative;
  display: inline-block;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.55;
}

/* FA swaps the <i> for an <svg> that keeps its classes. */
.main-nav__caret {
  font-size: 12px;
}

/* Underline: grows in on hover, stays for the open panel and current section.
   Always sits under the label only, never the caret. On dropdown parents,
   hovering the caret or opening the panel still shows it. */
.main-nav__label::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -8px;
  border-bottom: 2px solid #7e61de;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 100ms ease-in-out;
}

.main-nav__link:hover .main-nav__label::after,
.main-nav__item.is-active-trail .main-nav__label::after,
.main-nav__parent:hover .main-nav__label::after,
.main-nav__parent:has(.main-nav__toggle[aria-expanded="true"]) .main-nav__label::after {
  transform: scaleX(1);
}

@media (max-width: 1200px) {
  .main-nav__label {
    font-size: 13px;
  }
}

@media (max-width: 992px) {
  .main-nav__label {
    font-size: 11px;
  }
}

/* Small-screen-only parts of the menu markup (shown in the hamburger section). */
.main-nav__toggle-text,
.mega-panel__mobile-head {
  display: none;
}

/* ---------------------------------------------------------------------------
 * Dropdown panel
 * Positioned against .site-header (fixed), so it never changes the measured
 * header height and the page doesn't shift when it opens.
 * ------------------------------------------------------------------------ */

.mega-panel {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  padding: clamp(24px, calc(24px + 16 * (100vw - 992px) / 928), 40px);
  background: #fff;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 8px 8px rgba(0, 0, 0, .1);
  /* Hide the shadow's top edge so the panel joins the bar seamlessly. */
  clip-path: inset(0 -16px -16px -16px);
}

.mega-panel__inner {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr) minmax(0, 7fr);
  grid-template-areas: "links intro media";
  column-gap: clamp(8px, calc(8px + 48 * (100vw - 992px) / 928), 80px);
  align-items: center;
}

/* Links column */
.site-header .mega-panel__links {
  grid-area: links;
  align-self: start;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Underline colours cycle through the site palette. */
.mega-panel__item:nth-child(5n + 1) { --underline: #a4d0c4; }
.mega-panel__item:nth-child(5n + 2) { --underline: #d1b27e; }
.mega-panel__item:nth-child(5n + 3) { --underline: #6784ff; }
.mega-panel__item:nth-child(5n + 4) { --underline: #5db1c9; }
.mega-panel__item:nth-child(5n + 5) { --underline: #fbb263; }

.mega-panel__link {
  display: block;
  padding: 24px 8px;
  border-radius: 6px;
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.5;
  color: #7e61de;
  text-decoration: none;
  transition: background-color 100ms ease-in-out, color 100ms ease-in-out;
}

.mega-panel__link-text {
  padding-bottom: 2px;
  border-bottom: 2px solid var(--underline, #7e61de);
}

.mega-panel__link:hover,
.mega-panel__link:focus-visible {
  background-color: #7e61de;
  color: #fff;
  text-decoration: none;
  outline: none;
}

.mega-panel__link:hover .mega-panel__link-text,
.mega-panel__link:focus-visible .mega-panel__link-text {
  border-color: #fff;
}

/* Intro column */
.mega-panel__intro {
  grid-area: intro;
  color: #24125f;
}

.mega-panel__title {
  margin: 0 0 .75em;
  font-family: 'Merriweather', serif;
  font-size: clamp(28px, calc(28px + 12 * (100vw - 992px) / 928), 40px);
  font-weight: 300;
  line-height: 1.3;
}

.mega-panel__text {
  font-family: 'Merriweather', serif;
  font-size: clamp(16px, calc(16px + 2 * (100vw - 992px) / 928), 18px);
  font-weight: 300;
  line-height: 1.55;
}

.mega-panel__text p:last-child {
  margin-bottom: 0;
}

/* Image column: fills a fixed-ratio box whatever wrappers Drupal adds. */
.mega-panel__media {
  grid-area: media;
  position: relative;
  aspect-ratio: 9 / 8;
  border-radius: 12px;
  overflow: hidden;
}

.mega-panel__media img {
  position: absolute;
  inset: 0;
  width: 100%;
  max-height: unset;
  height: 100%;
  object-fit: cover;
}

/* 1199–993px: two columns. Links stay on the left across both rows; the
   image drops under the intro text. A wider image ratio keeps the panel
   short enough to fit on laptop screens, since the fixed header can't scroll. */
@media (max-width: 1200px) {
  .mega-panel__inner {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    grid-template-areas:
      "links intro"
      "links media";
    row-gap: 24px;
    align-items: start;
  }

  .mega-panel__media {
    aspect-ratio: 16 / 9;
  }
}

/* ---------------------------------------------------------------------------
 * Right-hand buttons: hamburger (small screens only) then search.
 * ------------------------------------------------------------------------ */

.site-header__actions {
  gap: 8px;
}

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  background: none;
  color: #24125f;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.nav-toggle:focus-visible {
  outline: 2px solid #7e61de;
  outline-offset: 2px;
  border-radius: 4px;
}

/* FA swaps the <i> for an <svg> that keeps its classes. */
.nav-toggle[aria-expanded="false"] .nav-toggle__icon--close,
.nav-toggle[aria-expanded="true"] .nav-toggle__icon--open {
  display: none;
}

/* ---------------------------------------------------------------------------
 * Search toggle
 * Circle button at the right of the bar; the icon swaps to × while open.
 * ------------------------------------------------------------------------ */

.search-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid #24125f;
  border-radius: 50%;
  background: #fff;
  color: #24125f;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 100ms ease-in-out, color 100ms ease-in-out;
}

.search-toggle:hover {
  background: #24125f;
  color: #fff;
}

.search-toggle .search-toggle__icon {
  width: 16px;
  height: 16px;
}

.nav-toggle .nav-toggle__icon {
  width: 22px;
  height: 22px;
}

.search-toggle:focus-visible {
  outline: 2px solid #7e61de;
  outline-offset: 3px;
}

/* FA swaps the <i> for an <svg> that keeps its classes. */
.search-toggle[aria-expanded="false"] .search-toggle__icon--close,
.search-toggle[aria-expanded="true"] .search-toggle__icon--open {
  display: none;
}

/* ---------------------------------------------------------------------------
 * Search panel
 * Hangs below the bar like the mega menu panels.
 * ------------------------------------------------------------------------ */

.search-panel {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  padding:
           clamp(24px, calc(24px + 16 * (100vw - 992px) / 928), 40px)
           clamp(24px, calc(24px + 8 * (100vw - 992px) / 928), 32px);
  background: #fff;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 8px 8px rgba(0, 0, 0, .1);
  clip-path: inset(0 -16px -16px -16px);
}

.search-panel__inner {
  position: relative;
}

#views-exposed-form-acquia-search-page > div {
  display: unset !important;
}

/* Strip the exposed form's own spacing so the input is the whole pill.
   Bootstrap's mb-3 utility uses !important, so the reset has to as well. */
.search-panel .region,
.search-panel .block,
.search-panel form,
.search-panel .form--inline {
  display: block;
  margin: 0;
  padding: 0;
}

.search-panel .form-item,
.search-panel .form-actions {
  width: 100%;
  margin: 0 !important;
  padding: 0;
}

/* Label and submit stay for screen readers; Enter submits the form. */
.search-panel label,
.search-panel .form-actions {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.search-panel input[type="search"],
.search-panel input[type="text"] {
  display: block;
  width: 100%;
  height: clamp(48px, calc(48px + 8 * (100vw - 992px) / 928), 56px);
  padding: 0 96px 0 24px;
  border: 1.5px solid #5c5c5c;
  border-radius: 999px;
  background: #fff;
  box-shadow: none;
  font-family: 'Inter', sans-serif;
  font-size: clamp(16px, calc(16px + 2 * (100vw - 992px) / 928), 18px);
  color: #242935;
  appearance: none;
}

.search-panel input::placeholder {
  color: #242935;
  opacity: 1;
}

.search-panel input[type="search"]:focus,
.search-panel input[type="text"]:focus {
  border-color: #7e61de;
  outline: none;
  box-shadow: 0 0 0 3px rgba(126, 97, 222, .2);
}

/* The panel has its own Clear button, so hide the browser's. */
.search-panel input[type="search"]::-webkit-search-cancel-button {
  appearance: none;
}

.search-panel__clear {
  position: absolute;
  top: 50%;
  right: 24px;
  transform: translateY(-50%);
  padding: 0;
  border: 0;
  background: none;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: #24125f;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.search-panel__clear:hover {
  color: #7e61de;
}

.search-panel__clear:focus-visible {
  outline: 2px solid #7e61de;
  outline-offset: 3px;
  border-radius: 2px;
}


/* ---------------------------------------------------------------------------
 * Hamburger menu (992px and below)
 * The menu drops down from the header card like the other panels. Dropdown
 * rows swap the list for a second screen: Back, the parent's title (linking
 * to its landing page), the links, then the tagline and image.
 * ------------------------------------------------------------------------ */

@keyframes plannera-nav-slide-in {
  from { transform: translateX(100%); }
  to { transform: none; }
}

/* @media (max-width: 992px) { */
  /* @media (max-width: 768px) { */
  @media (max-width: 650px) {
  .nav-toggle {
    display: inline-flex;
    width: 36px;
    height: 36px;
  }

  .search-toggle {
    width: 36px;
    height: 36px;
  }

  .search-toggle .search-toggle__icon {
    width: 14px;
    height: 14px;
  }

  .nav-toggle .nav-toggle__icon {
    width: 20px;
    height: 20px;
  }

  /* Closed: the menu takes no room in the bar. Bootstrap's d-flex is !important. */
  .site-header .menu-wrapper {
    display: none !important;
  }

  /* Open: square off the bar's bottom corners so the dropdown joins it. */
  .site-header.is-nav-open {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }

  /* The dropdown: hangs below the bar, as wide as the header card, and
     scrolls inside itself if it's taller than the space left on screen. */
  .site-header.is-nav-open .menu-wrapper {
    display: block !important;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: calc(100vh - var(--drupal-displace-offset-top, 0px) - var(--header-height, 72px) - 3rem);
    max-height: calc(100dvh - var(--drupal-displace-offset-top, 0px) - var(--header-height, 72px) - 3rem);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #fff;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 8px 8px rgba(0, 0, 0, .1);
    /* Hide the shadow's top edge so the dropdown joins the bar seamlessly. */
    clip-path: inset(0 -16px -16px -16px);
  }

  /* Main list */
  .site-header .main-nav {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0 24px 16px;
  }

  .main-nav__item {
    border-bottom: 1px solid #ececf4;
  }

  .main-nav__item:last-child {
    border-bottom: 0;
  }

  .main-nav__link {
    padding: 18px 0;
  }

  .main-nav__label {
    font-size: 18px;
  }

  /* No hover underline in the list. */
  .main-nav__label::after {
    display: none;
  }

  /* Dropdown rows: the toggle becomes the whole row; the landing page is
     reached from the title on the second screen instead. */
  .main-nav__parent {
    display: block;
  }

  .main-nav__parent > .main-nav__link {
    display: none;
  }

  .main-nav__toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    width: 100%;
    height: auto;
    padding: 18px 0;
    font-family: 'Inter', sans-serif;
    text-align: left;
  }

  .main-nav__toggle-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  /* Down caret becomes a right arrow: "goes to another screen". */
  .main-nav__caret {
    font-size: 14px;
    transform: rotate(-90deg);
  }

  /* Second screen: the open item's panel replaces the list, so the dropdown
     grows or shrinks to fit it. */
  .main-nav:has(.main-nav__item.is-open) > .main-nav__item:not(.is-open),
  .main-nav__item.is-open > .main-nav__parent {
    display: none;
  }

  .main-nav__item.is-open {
    border-bottom: 0;
  }

  .mega-panel {
    position: static;
    min-width: 0;
    max-width: 100%;
    padding: 0 0 8px;
    border-radius: 0;
    box-shadow: none;
    clip-path: none;
    animation: plannera-nav-slide-in 200ms ease-out;
  }

  .mega-panel__mobile-head {
    display: block;
    margin-bottom: 12px;
    padding-bottom: 16px;
    border-bottom: 1px solid #ececf4;
  }

  .mega-panel__mobile-head p {
    margin: 0;
  }

  .mega-panel__back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 18px 0 20px;
    padding: 0;
    border: 0;
    background: none;
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    font-weight: 500;
    color: #7e61de;
    cursor: pointer;
  }

  .mega-panel__back:focus-visible,
  .mega-panel__heading:focus-visible {
    outline: 2px solid #7e61de;
    outline-offset: 4px;
    border-radius: 4px;
  }

  .mega-panel__mobile-head .main-nav__eyebrow {
    margin-bottom: 4px;
  }

  /* The parent's title, linking to its landing page. */
  .mega-panel__heading {
    display: inline-block;
    font-family: 'Inter', sans-serif;
    font-size: 24px;
    font-weight: 500;
    line-height: 1.33;
    color: #24125f;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-decoration-color: #7e61de;
    text-underline-offset: 6px;
  }

  .mega-panel__heading:hover {
    color: #7e61de;
  }

  /* Links, then the tagline, then the image, stacked. */
  .mega-panel__inner {
    display: block;
  }

  .site-header .mega-panel__links {
    gap: 4px;
  }

  .mega-panel__link {
    margin-inline: -16px;
    padding: 14px 16px;
    font-size: 18px;
  }

  .mega-panel__intro {
    margin-top: 28px;
  }

  .mega-panel__title {
    margin: 0;
    font-size: 26px;
  }

  /* Tagline only; the caption under it stays desktop-only. */
  .mega-panel__text {
    display: none;
  }

  .mega-panel__media {
    margin-top: 20px;
    aspect-ratio: 16 / 9;
  }
}

@media (max-width: 650px) and (prefers-reduced-motion: reduce) {
  .mega-panel {
    animation: none;
  }

  .site-header__left {
    gap: 20px;
  }
  
  .site-header .main-nav {
    gap: 10px;
  }
}

@media (min-width: 650px) and (max-width: 800px) {
  .site-header__left img {
    max-height: 32px;
  }
}