.menu-panels {
  --mp-maroon: var(--e-global-color-primary, #8d2041);
  --mp-black: var(--e-global-color-text, #231f20);
  --mp-red: #d02a2a;
  --mp-gray: #3d3935;
  --mp-surface: #fff;

  --mp-column-width: 250px;
  --mp-column-gap: 30px;
  --mp-bracket-offset: 14px;

  font-family: Inter, system-ui, sans-serif;
}

/* ---------------------------------------------------------------- shared bits */

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

/* Elementor's kit restyles buttons on hover above a plain class, so the reset claims those states too */
.menu-panels .menu-panels__control,
.menu-panels .menu-panels__control:is(:hover, :focus, :focus-visible, :active) {
  appearance: none;
  border: 0;
  border-radius: 0;
  background: none;
  background-color: transparent;
  box-shadow: none;
  padding: 0;
  min-height: 0;
  text-align: left;
  text-transform: none;
  cursor: pointer;
}

.menu-panels .menu-panels__control {
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
}

.menu-panels .menu-panels__link,
.menu-panels .menu-panels__link:is(:hover, :focus, :focus-visible) {
  text-decoration: none;
  background: none;
  padding: 0;
}

.menu-panels .menu-panels__link {
  color: inherit;
}

.menu-panels :focus-visible {
  outline: 2px solid var(--mp-red);
  outline-offset: 3px;
}

/* the parent theme may already ship this, but the SR-only spans can't depend on that */
.menu-panels .screen-reader-text {
  position: absolute;
  clip-path: inset(50%);
  width: 1px;
  height: 1px;
  overflow: hidden;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- the columns */

.menu-panels__columns {
  display: block;
}

.menu-panels__column {
  display: none;
  position: relative;
  min-width: 0;
}

/* only the deepest open level, until there is room for more than one column */
.menu-panels__column[data-active='true'] {
  display: block;
}

.menu-panels__eyebrow {
  position: relative;
  margin: 0 0 24px;
  color: var(--mp-red);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.33;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* the red corner bracket marking a list, on the eyebrow so the back control above can't shift it */
.menu-panels__eyebrow::before,
.menu-panels__column[data-labeled='false']::before {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  border-top: 2px solid var(--mp-red);
  border-left: 2px solid var(--mp-red);
  transform: translate(calc(var(--mp-bracket-offset) * -1), -16px);
}

/* color is set on the list so items inherit it, and any active-state rule below always wins */
.menu-panels__column > .menu-panels__list {
  color: var(--mp-gray);
}

.menu-panels__column > .menu-panels__list > .menu-panels__item > * {
  display: block;
  font-size: 16px;
  line-height: 1.625;
}

.menu-panels__nested-list {
  padding-left: var(--mp-bracket-offset);
}

.menu-panels :is(.menu-panels__trigger, .menu-panels__link):is(:hover, :focus, :focus-visible, :active) {
  color: inherit;
}

.menu-panels .menu-panels__trigger.is-open,
.menu-panels .menu-panels__trigger.is-current-branch,
.menu-panels .menu-panels__link[aria-current='page'] {
  color: var(--mp-maroon);
}

/* last at matching specificity, so hovering the open item still reads as hover */
.menu-panels :is(.menu-panels__trigger, .menu-panels__link):is(:hover, :focus-visible) {
  color: var(--mp-red);
}

.menu-panels__link--external::after {
  content: '↗';
  margin-left: 0.35em;
}

.menu-panels .menu-panels__back {
  display: block;
  margin-bottom: 40px;
  font-size: 16px;
  text-decoration: underline;
}

/* color only, so the breakpoint rules that hide this stay free to win on display */
.menu-panels .menu-panels__back,
.menu-panels .menu-panels__back:is(:hover, :focus, :focus-visible) {
  color: var(--mp-red);
}

.menu-panels__back::before {
  content: '← ';
}

/* the first panel is reached straight from the level above, so it has nothing to go back to */
.menu-panels .menu-panels__column[data-depth='1'] .menu-panels__back {
  display: none;
}

/* ----------------------------------------------------------------- the image */

.menu-panels__figure {
  display: none;
  position: relative;
  overflow: hidden;
  margin: 0;
  pointer-events: none;
}

.menu-panels__figure[data-open='true'] {
  display: flex;
  flex-direction: column;
}

/* grown to fill, because a percentage height on a replaced element falls back to the file's own size */
.menu-panels__image {
  flex: 1;
  min-height: 0;
  width: 100%;
  object-fit: cover;
}

.menu-panels__caption {
  position: absolute;
  left: 20px;
  bottom: 20px;
  border-radius: 2px;
  background: var(--mp-surface);
  padding: 5px 8px;
  color: var(--mp-maroon);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
}

/* ----------------------------------------------------- tablet (1024px and up) */

@media (min-width: 1024px) {
  .menu-panels {
    --mp-column-width: 226px;
  }

  .menu-panels__columns {
    display: flex;
    align-items: flex-start;
    gap: var(--mp-column-gap);
  }

  .menu-panels__column {
    flex: 0 0 var(--mp-column-width);
  }

  /* level one is always there, and the deepest open level swaps into the second slot */
  .menu-panels__column[data-depth='1'][data-open='true'],
  .menu-panels__column[data-active='true'] {
    display: block;
  }

  /* column one stays on screen, so only a column that has replaced another one needs a way back */
  .menu-panels .menu-panels__column:is([data-depth='1'], [data-depth='2']) .menu-panels__back {
    display: none;
  }
}

/* ----------------------------------------------------- desktop (1200px and up) */

@media (min-width: 1200px) {
  .menu-panels {
    --mp-column-width: clamp(240px, 20vw, 324px);
  }

  /* no swapping up here, every open level keeps its own column */
  .menu-panels__column[data-open='true'] {
    display: block;
  }

  .menu-panels .menu-panels__back {
    display: none;
  }
}

/* ------------------------------------------------------------------ motion */

@media (prefers-reduced-motion: reduce) {
  .menu-panels * {
    transition: none !important;
    animation: none !important;
  }
}
