/* Shared trapezoid menu with wide desktop layout and topbar-aware offset. */
:root {
  --trapezoid-outer-height: 88px;
}

#header.header.sticky-top {
  background: transparent;
}

#header .topbar {
  position: relative;
  z-index: 3;
}

.scrolled #header .topbar {
  height: 0;
  visibility: hidden;
  overflow: hidden;
}

#header .trapezoid-nav-row {
  min-height: var(--trapezoid-outer-height);
  position: relative;
  z-index: 1;
  background: transparent;
  transition: min-height 0.35s ease;
}

/* Home sections need a larger offset because the sticky trapezoid header is taller than default nav. */
body.has-trapezoid-nav section,
body.has-trapezoid-nav .section {
  scroll-margin-top: calc(var(--trapezoid-outer-height) + 16px);
}

.trapezoid-menu-host {
  width: 100%;
  height: var(--trapezoid-outer-height);
  position: relative;
  overflow: visible;
  display: flex;
  align-items: center;
  justify-content: center;
}

.trapezoid-menu-outer {
  position: relative;
  top: 0;
  left: 0;
  width: min(1320px, 99vw);
  height: var(--trapezoid-outer-height);
  min-height: var(--trapezoid-outer-height);
  margin: 0 auto;
  background: linear-gradient(90deg, #8fcfb3 0%, #76bf9e 45%, #63ad8b 100%);
  clip-path: polygon(3% 0, 97% 0, 94% 100%, 6% 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  box-shadow: 0 8px 22px rgba(26, 96, 65, 0.22);
  transition: box-shadow 0.25s ease;
  padding: 8px 36px;
}

.trapezoid-menu-container {
  display: flex;
  flex-wrap: nowrap;
  gap: 16px;
  width: 100%;
  justify-content: center;
  align-items: center;
}

.trapezoid-menu-item {
  background: none;
  color: #ffffff;
  font-size: 0.72rem;
  font-family: "Poppins", Arial, sans-serif;
  font-weight: 600;
  text-decoration: none;
  letter-spacing: 0.08em;
  border: none;
  padding: 2px 6px;
  transition: color 0.2s, transform 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-align: center;
  white-space: nowrap;
  line-height: 1.2;
}

.trapezoid-menu-item.interpretation span {
  line-height: 1.1;
}

.trapezoid-menu-item i {
  font-size: 1.08rem;
}

.trapezoid-menu-item:hover {
  color: #ecfff4;
  transform: scale(1.16) translateY(-2px);
}

.trapezoid-submenu-toggle {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.42);
  color: #ffffff;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.trapezoid-submenu-toggle:hover {
  background: rgba(255, 255, 255, 0.3);
}

.trapezoid-inline-tray {
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  transform: translateX(-50%) translateY(-8px);
  width: min(980px, 94vw);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border-radius: 14px;
  background: rgba(188, 229, 210, 0.97);
  border: 1px solid rgba(88, 152, 122, 0.38);
  box-shadow: 0 14px 24px rgba(29, 96, 68, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1200;
}

.trapezoid-inline-tray .tray-link {
  display: block;
  color: #123f2b;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(87, 145, 118, 0.34);
}

.trapezoid-inline-tray .tray-link:hover {
  background: rgba(255, 255, 255, 0.86);
}

.trapezoid-menu-host.is-interpretation-tray-open .trapezoid-inline-tray {
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: translateX(-50%) translateY(0) !important;
}

.trapezoid-menu-outer.is-interpretation-tray-open + .trapezoid-inline-tray,
.trapezoid-menu-outer.is-interpretation-tray-open .trapezoid-inline-tray {
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: translateX(-50%) translateY(0) !important;
}

.trapezoid-menu-host.is-interpretation-tray-open .interpretation-submenu-toggle {
  transform: rotate(180deg);
}

.trapezoid-menu-outer.is-interpretation-tray-open .interpretation-submenu-toggle {
  transform: rotate(180deg);
}

.sparkle {
  position: absolute;
  pointer-events: none;
  z-index: 2001;
}

.sparkle::before {
  content: "✨";
  font-size: 16px;
  color: #fff;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.9);
  animation: sparkleAnimation 1.2s ease-out forwards;
}

@keyframes sparkleAnimation {
  0% { opacity: 0; transform: scale(0) rotate(0deg); }
  30% { opacity: 1; transform: scale(1.2) rotate(180deg); }
  100% { opacity: 0; transform: scale(0.3) rotate(360deg) translateY(-30px); }
}

@media (max-width: 1360px) {
  .trapezoid-menu-outer {
    width: 99vw;
    padding-left: 26px;
    padding-right: 26px;
  }

  .trapezoid-menu-container {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    justify-content: flex-start;
    width: 100%;
    gap: 12px;
    padding: 0 8px;
    cursor: grab;
  }

  .trapezoid-menu-container.is-dragging {
    cursor: grabbing;
  }

  .trapezoid-menu-container::-webkit-scrollbar {
    display: none;
  }

  .trapezoid-menu-item {
    flex: 0 0 auto;
    min-width: 102px;
    background: rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    padding: 8px 6px;
  }

  .trapezoid-inline-tray {
    width: min(860px, 96vw);
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  :root {
    --trapezoid-outer-height: 84px;
  }

  #header .trapezoid-nav-row {
    min-height: var(--trapezoid-outer-height);
  }

  .trapezoid-menu-outer {
    width: 98vw;
    height: var(--trapezoid-outer-height);
    min-height: var(--trapezoid-outer-height);
    clip-path: polygon(2.5% 0, 97.5% 0, 95% 100%, 5% 100%);
    justify-content: center;
    padding-left: 16px;
    padding-right: 16px;
  }

  .trapezoid-menu-item {
    min-width: 92px;
    padding: 7px 6px;
    font-size: 0.64rem;
  }

  .trapezoid-menu-item i {
    font-size: 0.98rem;
  }

  .trapezoid-submenu-toggle {
    width: 26px;
    height: 26px;
  }

  .trapezoid-inline-tray {
    width: 98vw;
    grid-template-columns: 1fr;
    top: calc(100% + 6px);
  }
}
