/* ============================================================
   Cove Parish — Tabbed Mega Menu
   The panel is chrome only — its items use the shared .dd-item /
   .dd-label styles from nav.css, so a panel item reads exactly the
   same as a normal dropdown item. Tokens come from tokens.css —
   never hardcode hex.
   ============================================================ */

/* ── Trigger (top-level menu item that opens the panel) ── */
.cp-mm-trigger-item { position: relative; }

.cp-mm-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

/* Chevron sizing + rotation handled in nav.css alongside .nav-chevron
   so the dropdown indicator and the mega-menu trigger indicator render
   identically. Don't duplicate here. */

/* ── Panel — full-width below the header ──
   `position: fixed` anchors to the viewport so the panel always spans
   edge-to-edge regardless of where the trigger sits. The JS sets
   `--cp-mm-top` to the trigger's bottom edge so the panel sits flush
   below the header at any header height. */
.cp-mm-panel {
  position: fixed;
  top: var(--cp-mm-top, 70px);
  left: 0;
  right: 0;
  width: 100%;
  /* No background/border/shadow of its own — this outer div only
     positions things full-width so .cp-mm-panel-inner can centre
     itself below the header. It used to carry a solid fill (first
     var(--wh), then var(--cr)), which read as an unwanted colour
     bar spanning the entire page behind the actual menu card. The
     card itself (.cp-mm-panel-inner) already has its own opaque
     background, border and shadow — same as .nav-dropdown, which
     has no full-width backdrop either. */
  z-index: 90;
  /* Horizontal padding matters below ~1220px (.cp-mm-panel-inner's
     max-width:1180px + this gutter): once the viewport is narrower
     than that, auto-margin centring stops adding any side space of
     its own, so without this the card would sit flush against the
     browser edges — e.g. any desktop-nav width between the ~960px
     hamburger cutoff and ~1220px, which includes standard tablet
     landscape (1024px). */
  padding: 16px 20px 24px;
}
.cp-mm-panel[hidden] { display: none; }
/* Never taller than the screen below the header: on short laptop screens
   (e.g. a MacBook Air) a long panel would otherwise run off the bottom
   with no way to reach the last items. Scrolls inside instead. */
.cp-mm-panel {
  max-height: calc(100vh - var(--cp-mm-top, 70px));
  max-height: calc(100dvh - var(--cp-mm-top, 70px));
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.cp-mm-panel-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 0;
  background: #fafaf7; /* off-white panel bg */
  border-radius: 8px;
  border: 0.5px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 6px 30px rgba(31, 58, 95, 0.12);
  overflow: hidden;
}

/* ── Tablist (left rail) — "Browse" column ── */
.cp-mm-tablist {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 14px 0;
  background: #f1efe8; /* warm cream rail bg */
  border-right: 0.5px solid rgba(0, 0, 0, 0.08);
  position: relative;
}
.cp-mm-tablist::before {
  content: 'Browse';
  display: block;
  padding: 12px 22px 14px;
  font-family: var(--fb);
  font-size: 11px; font-weight: 500;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: #6b6b66;
}

.cp-mm-tab {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 22px;
  background: transparent;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 0;
  font-family: var(--fb);
  font-size: 14.5px;
  font-weight: 400;
  color: #2c2c2a;
  text-align: left;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.cp-mm-tab:hover { background: rgba(255, 255, 255, .55); }
.cp-mm-tab:focus-visible {
  outline: 2px solid var(--py);
  outline-offset: -2px;
}
/* Active — white card + Parish Gold left bar */
.cp-mm-tab[aria-selected="true"] {
  background: var(--wh);
  color: var(--pb);
  font-weight: 500;
  border-left-color: var(--py);
}

/* Tab icon = an emoji from the tab item's Title Attribute. */
.cp-mm-tab-icon {
  flex: 0 0 auto;
  font-size: 1rem;
  line-height: 1;
}
.cp-mm-tab-label { line-height: 1.3; }

/* ── Tabpanels (right content area) ──
   Each panel lays its .dd-item children out in a 2-column grid. The
   .dd-item / .dd-label styling itself lives in nav.css, so panel items
   match standard dropdown items exactly. */
.cp-mm-tabpanels {
  min-height: 240px;
  padding: 22px 24px;
}
.cp-mm-tabpanel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 24px;
  align-items: start;
}
/* Explicit `hidden` override — `display: grid` above otherwise wins
   over the UA stylesheet's `[hidden] { display: none }`. */
.cp-mm-tabpanel[hidden] { display: none !important; }
.cp-mm-tabpanel:focus-visible {
  outline: 2px solid var(--py);
  outline-offset: 4px;
  border-radius: 6px;
}

/* ── Active nav-item styling when the mega menu is open ── */
.cp-mm-trigger[aria-expanded="true"] {
  background: #f1efe8;
  border-radius: 4px;
}

/* ── Mobile / accordion mode (≤767px) ──
   Panel stays fixed + full width; the inner layout collapses to a
   single stack and tabs behave as independent disclosure buttons (JS
   handles the ARIA shift to aria-expanded + role="region"). */
@media (max-width: 767px) {
  .cp-mm-panel {
    max-height: calc(100vh - var(--cp-mm-top, 70px));
    overflow-y: auto;
  }
  .cp-mm-panel-inner {
    padding: 12px 16px 20px;
    grid-template-columns: 1fr;
    gap: 0;
  }

  .cp-mm-tablist {
    flex-direction: column;
    border-right: 0;
    padding-right: 0;
    gap: 0;
  }

  .cp-mm-tab {
    width: 100%;
    border-radius: 0;
    border-bottom: 1px solid rgba(30, 58, 82, .08);
    padding: 14px 12px;
    justify-content: space-between;
  }
  .cp-mm-tab[aria-selected="true"] { /* not used in accordion mode */
    background: transparent;
    color: var(--db);
  }
  .cp-mm-tab[aria-expanded="true"] {
    background: var(--cr);
    color: var(--pb);
  }
  /* Chevron-style accordion indicator after the label. */
  .cp-mm-tab::after {
    content: '';
    width: 10px;
    height: 10px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform .2s var(--ease);
    margin-left: auto;
  }
  .cp-mm-tab[aria-expanded="true"]::after {
    transform: rotate(-135deg);
  }

  .cp-mm-tabpanels {
    min-height: 0;
    display: contents; /* let panels stack between tabs in source order */
  }
  .cp-mm-tabpanel {
    grid-template-columns: 1fr;
    gap: 2px;
    padding: 8px 12px 16px;
    border-bottom: 1px solid rgba(30, 58, 82, .08);
  }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .cp-mm-chevron,
  .cp-mm-tab,
  .cp-mm-tab::after {
    transition: none !important;
  }
}
