/* Up Megamenu — structural CSS only. Colors/spacing are meant to be refined per theme. */

.up-menu-badge {
  display: inline-flex;
  align-items: center;
  padding: .1rem .4rem;
  font-size: .65rem;
  font-weight: 700;
  line-height: 1.4;
  border-radius: 3px;
  color: #fff;
  background-color: #d0021b;
  text-transform: uppercase;
}

/* Main nav */
.up-menu {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  position: relative;
}

.up-menu__list {
  display: flex;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 1.75rem;
}

.up-menu__item {
  position: relative;
}

.up-menu__link {
  display: flex;
  align-items: center;
  gap: .35rem;
  text-decoration: none;
  padding: .75rem 0;
  cursor: pointer;
}

.up-menu__caret {
  order: -1;
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform .15s ease;
}

.up-menu__item.is-active .up-menu__caret {
  transform: rotate(45deg);
}

.up-menu__mobile-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.up-menu__mobile-toggle-bar {
  display: block;
  height: 2px;
  width: 100%;
  background: currentColor;
}

/* Full width mega panels */
.up-menu-panels {
  position: static;
}

/* Fixed to escape the header overflow; the script aligns it on the header
   container so it spans the content width, not the viewport. */
.up-menu-panel {
  display: none;
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
  z-index: 500;
}

.up-menu-panel.is-visible {
  display: block;
}

.up-menu-panel__inner {
  padding: 1.75rem 1.5rem;
}

/* Cascade layout: branches / leaves / banner side by side */
.up-menu-panel__cascade {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(0, 2.2fr) minmax(0, 1.1fr);
  gap: 2rem;
  align-items: start;
}

.up-menu-branches {
  list-style: none;
  margin: 0;
  padding: 0;
}

.up-menu-branch a {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem 0;
  text-decoration: none;
}

.up-menu-branch__caret {
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform .15s ease;
}

.up-menu-branch.is-active .up-menu-branch__caret {
  transform: rotate(45deg);
}

.up-menu-branch.is-active a {
  font-weight: 700;
}

.up-menu-leaves {
  display: none;
}

.up-menu-leaves.is-visible {
  display: block;
}

.up-menu-panel__extra-links {
  list-style: none;
  margin: 1rem 0 0;
  padding: 1rem 0 0;
  border-top: 1px solid rgba(0, 0, 0, .1);
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.up-menu-panel__extra-links a {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  text-decoration: none;
  font-size: .8125rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.up-menu-banner {
  display: none;
}

.up-menu-banner.is-visible {
  display: block;
}

.up-menu-banner img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
}

.up-menu__link--button {
  border: 0;
  background: transparent;
  font: inherit;
  color: inherit;
}

.up-menu-panel__title {
  font-size: .8125rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin: 0 0 1rem;
}

.up-menu-panel__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1.5rem;
}

/* Some columns have a set width: flex keeps them at it, the others share what is left. */
.up-menu-panel__grid--sized {
  display: flex;
  flex-wrap: wrap;
}

.up-menu-panel__grid--sized > .up-menu-panel__cell {
  flex: 1 1 160px;
  min-width: 0;
}

.up-menu-panel__grid--sized > .up-menu-panel__cell--sized {
  flex: 0 0 var(--up-col-width);
  max-width: 100%;
}

/* Compact/sized panel: not full width, the script anchors it under its entry.
   --sized also gets an inline max-width (see mega-panel.tpl) capping it below
   the 100% here. */
.up-menu-panel--compact,
.up-menu-panel--sized {
  width: auto;
  max-width: 100%;
}

.up-menu-panel--compact .up-menu-panel__grid--sized {
  flex-wrap: nowrap;
}

.up-menu-panel__img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
  margin-bottom: .6rem;
}

.up-menu-panel__cell-title {
  display: block;
  font-weight: 600;
  text-decoration: none;
  margin-bottom: .25rem;
}

.up-menu-panel__sublist {
  list-style: none;
  margin: .25rem 0 0;
  padding: 0;
}

.up-menu-panel__sublist a {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  text-decoration: none;
  font-size: .875rem;
  padding: .15rem 0;
}

.up-menu-panel__desc {
  font-size: .8125rem;
  opacity: .75;
  margin: .25rem 0 0;
}

.up-menu-panel__section--blocks {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(0, 0, 0, .08);
}

.up-menu-panel__tiles-title {
  display: inline-block;
  margin: 0 0 1rem;
  padding-bottom: .4rem;
  font-size: .8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 2px solid currentColor;
}

.up-menu-panel__tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
}

.up-menu-tile {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  text-decoration: none;
}

.up-menu-tile__icon {
  flex: 0 0 auto;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, .05);
  overflow: hidden;
}

/* An uploaded visual fills the round slot instead of a glyph. */
.up-menu-tile__icon--image {
  background: none;
}

.up-menu-tile__icon--image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.up-menu-link-img {
  width: 1.25rem;
  height: 1.25rem;
  object-fit: contain;
  vertical-align: middle;
}

.up-menu-tile__title {
  display: block;
  font-weight: 600;
  font-size: .875rem;
}

.up-menu-tile__desc {
  display: block;
  font-size: .8125rem;
  opacity: .75;
}

/* Mobile slide-in panel (theme side menu) */
.up-mobile-menu,
.up-mobile-sub,
.up-mobile-tiles {
  list-style: none;
  margin: 0;
  padding: 0;
}

.up-mobile-row {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid rgba(0, 0, 0, .08);
}

.up-mobile-link {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .85rem 1rem;
  text-decoration: none;
}

.up-mobile-toggle {
  flex: 0 0 auto;
  width: 48px;
  border: 0;
  border-left: 1px solid rgba(0, 0, 0, .08);
  background: transparent;
  cursor: pointer;
  position: relative;
}

.up-mobile-toggle::before,
.up-mobile-toggle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 2px;
  margin: -1px 0 0 -6px;
  background: currentColor;
  transition: transform .2s ease;
}

.up-mobile-toggle::after {
  transform: rotate(90deg);
}

.up-mobile-item.is-open > .up-mobile-row .up-mobile-toggle::after {
  transform: rotate(0);
}

.up-mobile-sub {
  display: none;
  padding-left: 1rem;
}

.up-mobile-item.is-open > .up-mobile-sub {
  display: block;
}

.up-mobile-sub--links .up-mobile-link {
  font-size: .8125rem;
  text-transform: uppercase;
  opacity: .75;
}

.up-mobile-tiles {
  display: none;
  padding: .5rem 1rem 1rem;
}

.up-mobile-item.is-open > .up-mobile-tiles {
  display: block;
}

.up-mobile-tiles a {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem 0;
  text-decoration: none;
  font-size: .875rem;
}

/* Sticky */
.up-menu--is-stuck {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 900;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .1);
}

/* Responsive: collapse to an off-canvas drawer */
@media (max-width: 991px) {
  /* The nav becomes a drawer: toggle on its own line, list and panels below. */
  .up-menu {
    flex-wrap: wrap;
    gap: 0;
  }

  .up-menu__mobile-toggle {
    display: flex;
    order: 1;
    margin-left: auto;
  }

  .up-menu__list {
    order: 2;
  }

  .up-menu-panels {
    order: 3;
    width: 100%;
  }

  /* Nothing from the panels may show while the drawer is closed. */
  .up-menu:not(.is-open) .up-menu-panel {
    display: none;
  }

  /* Cascade collapses to a single column accordion. */
  .up-menu-panel__cascade {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .up-menu-panel__col--banner {
    display: none;
  }

  .up-menu__list {
    display: none;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 0;
  }

  .up-menu.is-open .up-menu__list {
    display: flex;
  }

  .up-menu__item {
    border-bottom: 1px solid rgba(0, 0, 0, .08);
  }

  .up-menu-panels {
    position: static;
  }

  /* width/left/top set inline for the desktop dropdown must not leak here. */
  .up-menu-panel {
    display: none;
    position: static;
    width: auto !important;
    left: auto !important;
    top: auto !important;
    box-shadow: none;
  }

  .up-menu-panel.is-visible {
    display: block;
  }

  .up-menu-panel__img {
    width: auto !important;
    height: auto !important;
    max-width: 100%;
  }

  .up-menu-panel__inner {
    padding: 1rem 1.25rem;
  }

  .up-menu-panel__grid,
  .up-menu-panel__tiles {
    grid-template-columns: 1fr;
  }

  .up-menu-panel__grid--sized,
  .up-menu-panel--compact .up-menu-panel__grid--sized {
    flex-direction: column;
    flex-wrap: nowrap;
  }

  .up-menu-panel__grid--sized > .up-menu-panel__cell,
  .up-menu-panel__grid--sized > .up-menu-panel__cell--sized {
    flex: 0 0 auto;
  }
}
