/*
 * Mega menu: a promo panel on the left, grouped link columns on the right.
 * Markup: templates/layout/includes/navbar.html (+ nav_icon.html).
 */

.dropdown-megamenu .dropdown-menu.mm {
  --ec-dropdown-padding-x: 0;
  --ec-dropdown-padding-y: 0;
  --ec-dropdown-border-color: var(--ec-border-color);
  --ec-dropdown-box-shadow: 0 1.5rem 3rem -1rem rgba(15, 23, 42, .14);
  overflow: hidden;
}

.mm__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

/* Promo panel (desktop only) */
.mm__promo {
  display: none;
}

.mm__cols {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: minmax(0, 1fr);
}

.mm__label {
  display: block;
  margin: 0 0 .5rem;
  padding: 0 .75rem .625rem;
  border-bottom: 1px solid var(--ec-border-color);
  font-size: .75rem;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ec-secondary-color);
}

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

.mm__link {
  display: flex;
  align-items: flex-start;
  gap: .875rem;
  padding: .75rem;
  border-radius: var(--ec-border-radius-lg);
  color: var(--ec-body-color);
  text-decoration: none;
  transition: background-color .15s ease-in-out;
}

.mm__link:hover,
.mm__link:focus-visible {
  background-color: var(--ec-tertiary-bg);
  color: var(--ec-body-color);
}

.mm__icon {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--ec-border-radius);
  background-color: var(--ec-tertiary-bg);
  color: var(--ec-emphasis-color);
  transition: background-color .15s ease-in-out, color .15s ease-in-out;
}

.mm__icon svg {
  width: 1.125rem;
  height: 1.125rem;
}

.mm__link:hover .mm__icon,
.mm__link:focus-visible .mm__icon {
  background-color: var(--ec-primary);
  color: #fff;
}

.mm__title {
  display: flex;
  align-items: center;
  gap: .375rem;
  margin-bottom: .125rem;
  font-size: .9375rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--ec-emphasis-color);
}

.mm__title .ei-arrow-up-right {
  font-size: .75rem;
  color: var(--ec-secondary-color);
}

.mm__desc {
  display: block;
  font-size: .8125rem;
  line-height: 1.45;
  color: var(--ec-secondary-color);
}

@media (min-width: 992px) {
  .mm__grid {
    grid-template-columns: 19rem minmax(0, 1fr);
  }

  .mm__promo {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 2.25rem 2rem 0;
    overflow: hidden;
    background: #0f1115;
    color: rgba(255, 255, 255, .72);
  }

  .mm__promo::after {
    content: "";
    position: absolute;
    right: -6rem;
    bottom: -6rem;
    width: 16rem;
    height: 16rem;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 78, 2, .45), rgba(255, 78, 2, 0) 70%);
    pointer-events: none;
  }

  .mm__promo-title {
    margin-bottom: .75rem;
    font-size: 1.375rem;
    font-weight: 500;
    line-height: 1.3;
    color: #fff;
  }

  .mm__promo-text {
    margin-bottom: 1.5rem;
    font-size: .875rem;
    line-height: 1.55;
  }

  .mm__promo-cta {
    position: relative;
    z-index: 1;
    align-self: flex-start;
  }

  .mm__promo-media {
    position: relative;
    z-index: 1;
    margin-top: auto;
    padding-top: 1.75rem;
  }

  .mm__promo-media img {
    display: block;
    width: 100%;
    border-radius: var(--ec-border-radius-lg) var(--ec-border-radius-lg) 0 0;
  }

  .mm__promo--guide .mm__promo-media {
    margin-top: 0;
    padding: 0 0 1.25rem;
  }

  .mm__promo--guide .mm__promo-media img {
    border-radius: var(--ec-border-radius-lg);
  }

  .mm__promo--guide {
    padding-bottom: 2rem;
  }

  .mm__promo--guide .mm__promo-title a {
    color: #fff;
    text-decoration: none;
  }

  .mm__promo--guide .mm__promo-title a:hover {
    color: var(--ec-primary);
  }

  .mm__body {
    padding: 2.25rem 2rem;
  }

  .mm__cols {
    gap: 2rem;
    grid-template-columns: repeat(var(--mm-cols, 2), minmax(0, 1fr));
  }
}

/* Light glass header once the page is scrolled (class set in navbar.html) */
.navbar.sticky-top {
  transition: background-color .2s ease, box-shadow .2s ease;
}

.navbar.sticky-top.is-scrolled {
  background-color: color-mix(in srgb, var(--ec-body-bg) 78%, transparent) !important;
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  backdrop-filter: blur(10px) saturate(140%);
  box-shadow: 0 1px 0 rgba(15, 23, 42, .06);
}

/* Latest guide in Resources: the same square cover as the guide cards */
@media (min-width: 992px) {
  .mm__promo--guide .mm__cover {
    display: block;
    aspect-ratio: 1 / 1;
    max-width: 13rem;
    margin-bottom: 1.25rem;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: var(--ec-border-radius-lg);
    background-color: rgba(255, 255, 255, .03);
    overflow: hidden;
  }

  .mm__promo--guide .mm__cover img {
    width: 100%;
    height: 100%;
    border-radius: 0;
  }
}

.mm__promo-title--sm {
  font-size: 1rem;
  line-height: 1.4;
}

/* Light veil with a soft blur over the page while a mega menu is open (desktop) */
@media (min-width: 992px) {
  body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 1010; /* under .sticky-top (1020) */
    background-color: rgba(255, 255, 255, .55);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    /* fade out only after a short pause, so moving from one menu to the
       next keeps the dim on instead of flashing off and on */
    transition: opacity .2s ease .15s, visibility 0s linear .35s;
  }

  body:has(.dropdown-megamenu .dropdown-menu.show)::after {
    opacity: 1;
    visibility: visible;
    transition: opacity .2s ease, visibility 0s;
  }
}

@media (prefers-reduced-motion: reduce) {
  body::after { transition: none; }
}

/* Chevron on mega menu toggles (desktop; mobile keeps the theme caret).
 * Two strokes that each turn a quarter around their own middle, so the
 * V folds into a caret when the menu opens. */
.nav-chevron {
  display: none;
}

@media (min-width: 992px) {
  .nav-chevron {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    margin-left: .125rem;
    vertical-align: -.1875rem;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
  }

  .nav-chevron path {
    transform-box: view-box;
    transition: transform .25s cubic-bezier(.6, 0, .2, 1);
  }

  .nav-chevron__l { transform-origin: 6px 8px; }
  .nav-chevron__r { transform-origin: 10px 8px; }

  .dropdown-toggle.show .nav-chevron__l { transform: rotate(-90deg); }
  .dropdown-toggle.show .nav-chevron__r { transform: rotate(90deg); }
}

@media (prefers-reduced-motion: reduce) {
  .nav-chevron path { transition: none; }
}

/* Current section: the submenu link of the page you are on */
.mm__link.is-active {
  background-color: var(--ec-tertiary-bg);
}

.mm__link.is-active .mm__icon {
  background-color: var(--ec-primary);
  color: #fff;
}

.mm__link.is-active .mm__title {
  color: var(--ec-primary);
}

/* Mobile menu (offcanvas, below lg) */
@media (max-width: 991.98px) {
  /* Pinned demo button under the scrolling list */
  .mm-offcanvas-cta {
    flex: none;
    padding: 1rem 1.25rem calc(1rem + env(safe-area-inset-bottom));
    border-top: 1px solid var(--ec-border-color);
    background-color: var(--ec-body-bg);
  }

  /* Bigger tap targets for the top items */
  .navbar-nav > .nav-item > .nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 3rem;
    font-size: 1.0625rem;
    font-weight: 500;
  }

  /* Stripe-style folding chevron replaces the theme caret */
  .dropdown-megamenu .dropdown-toggle::after {
    display: none;
  }

  .nav-chevron {
    display: inline-block;
    width: 1.125rem;
    height: 1.125rem;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
  }

  .nav-chevron path {
    transform-box: view-box;
    transition: transform .25s cubic-bezier(.6, 0, .2, 1);
  }

  .nav-chevron__l { transform-origin: 6px 8px; }
  .nav-chevron__r { transform-origin: 10px 8px; }

  .dropdown-toggle.show .nav-chevron__l { transform: rotate(-90deg); }
  .dropdown-toggle.show .nav-chevron__r { transform: rotate(90deg); }

  /* Compact lists: icon and title only, no descriptions */
  .mm__desc {
    display: none;
  }

  .mm__link {
    align-items: center;
    padding: .5rem .75rem;
  }

  .mm__icon {
    width: 2rem;
    height: 2rem;
  }

  .mm__title {
    margin-bottom: 0;
  }

  /* inset so hover/active fills don't run into the card edges */
  .mm__body {
    padding: .5rem;
  }

  .mm__cols {
    gap: 1rem;
    padding: .25rem 0;
  }

  .mm__label {
    padding-bottom: .5rem;
  }
}
