/* ============================================================
   Mega menu — single shell with content slots stacked inside.
   See DESIGN-RULES.md §6
   ============================================================ */

/* ============== The shell — opens/closes once, persists across
   menu switches. Background, border, shadow all live here.    */
.mega-shell {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: var(--z-mega);
  background: var(--white);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-mega);

  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity var(--dur) var(--ease),
              transform var(--dur) var(--ease),
              visibility 0s linear var(--dur);
}

.mega-shell.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
  transition: opacity var(--dur) var(--ease),
              transform var(--dur) var(--ease),
              visibility 0s linear 0s;
}

/* Stack — all content slots share the same grid cell, so they
   physically overlap at the same position. The active one shows. */
.mega-shell__stack {
  display: grid;
  grid-template-areas: "stack";
}

/* ============== Slot — a single mega's content layer ==============
   No chrome (no bg/border/shadow). Only fades in/out.

   Sequential cross-fade: outgoing slot fades out in 110ms, then the
   incoming slot starts fading in after a 90ms delay. Eliminates the
   double-text "ghosting" window when switching menus. */
.mega {
  grid-area: stack;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 110ms var(--ease),
              visibility 0s linear 110ms;
}

.mega.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 140ms var(--ease) 90ms,
              visibility 0s linear 90ms;
}

.mega__inner {
  display: grid;
  gap: var(--sp-8);
  padding: var(--sp-8) 0 var(--sp-10);
}

/* Layout variants — column count of the main grid */
.mega--cols-3        .mega__grid   { grid-template-columns: repeat(3, 1fr); }
.mega--cols-4        .mega__grid   { grid-template-columns: repeat(4, 1fr); }
.mega--cols-2-plus   .mega__grid   { grid-template-columns: repeat(2, 1fr); }

.mega__inner {
  grid-template-columns: 1fr 320px;   /* main grid + featured card */
}

.mega--no-featured .mega__inner {
  grid-template-columns: 1fr;
}

.mega__grid {
  display: grid;
  gap: var(--sp-8);
}

/* ---- Column ---- */
.mega__col {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.mega__col-heading {
  font-size: var(--fs-11);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-eyebrow);
  color: var(--text-muted);
  margin-bottom: var(--sp-1);
}

.mega__list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ---- Single item row ---- */
.mega__item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: 10px 12px;
  margin: 0 -12px;
  border-radius: var(--r-2);
  color: var(--ink);
  transition: background var(--dur-fast) var(--ease);
  position: relative;
}

.mega__item:hover { background: var(--paper); }

.mega__item-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--r-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  color: var(--ink);
  transition: background var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease);
}

.mega__item:hover .mega__item-icon {
  background: var(--red-tint);
  color: var(--red);
}

.mega__item-icon svg { width: 16px; height: 16px; }

.mega__item-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.mega__item-title {
  font-size: var(--fs-14);
  font-weight: 500;
  color: var(--ink);
  line-height: 1.35;
}

.mega__item-desc {
  font-size: 12.5px;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Simple item (no icon, plain link) */
.mega__item--plain {
  padding: 8px 12px;
}

.mega__item--plain .mega__item-title { font-weight: 400; }
.mega__item--plain:hover .mega__item-title { color: var(--ink); }


/* ---- Current page indicator inside mega menu ----
   Auto-applied by main.js when href matches current pathname.
   Icon-based items: red title + red icon tint + paper bg.
   Plain (no-icon) items: red title + red left bar marker. */
.mega__item[aria-current="page"] {
  background: var(--paper);
}

.mega__item[aria-current="page"] .mega__item-title {
  color: var(--red);
}

.mega__item[aria-current="page"] .mega__item-icon {
  background: var(--red);
  color: var(--white);
}

/* Plain (no icon) variant — add a left red marker since no icon to tint */
.mega__item--plain[aria-current="page"] {
  position: relative;
  background: transparent;
}

.mega__item--plain[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -2px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--red);
  border-radius: 2px;
}

/* "View all" arrow link, anchored at column end */
.mega__view-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: var(--sp-2);
  padding: 8px 12px;
  margin-inline: -12px;
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--red);
  border-radius: var(--r-2);
  transition: background var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease);
  align-self: flex-start;
}

.mega__view-all svg {
  width: 12px; height: 12px;
  transition: transform var(--dur) var(--ease);
}

.mega__view-all:hover { color: var(--red-deep); background: var(--red-tint); }
.mega__view-all:hover svg { transform: translateX(2px); }

/* Inline tag (NEW / SOON) */
.mega__tag {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border-radius: var(--r-1);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--red-tint);
  color: var(--red-deep);
  margin-left: 6px;
  flex-shrink: 0;
}

/* ---- Featured card (right side, dark) ---- */
.mega__featured {
  background: var(--ink);
  color: var(--white);
  border-radius: var(--r-3);
  padding: var(--sp-6);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--sp-6);
  min-height: 280px;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.mega__featured::before {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 3px;
  background: var(--red);
}

.mega__featured-eyebrow {
  font-size: var(--fs-11);
  font-weight: 600;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--smoke);
}

.mega__featured-title {
  font-size: var(--fs-20);
  font-weight: 600;
  line-height: 1.25;
  color: var(--white);
  max-width: 22ch;
}

.mega__featured-stat {
  font-size: 56px;
  font-weight: 700;
  line-height: 1;
  color: var(--white);
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.mega__featured-stat-label {
  font-size: var(--fs-12);
  color: var(--smoke);
  max-width: 22ch;
  line-height: 1.4;
}

.mega__featured-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--white);
  align-self: flex-start;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255,255,255,.25);
  transition: border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease);
}

.mega__featured-cta svg {
  width: 12px; height: 12px;
  transition: transform var(--dur) var(--ease);
}

.mega__featured-cta:hover { border-color: var(--red); }
.mega__featured-cta:hover svg { transform: translateX(3px); }

/* Hide shell on mobile (drawer takes over) */
@media (max-width: 1279.98px) {
  .mega-shell { display: none; }
}
