/*
 * tech-storefront — "All categories" mega menu overlay (Balanced + Regular + Light only).
 *
 * Ported intent from the mega-menu.jsx prototype. No data-theme / data-dark /
 * data-density qualifiers are permitted in this file — strip them on any
 * future re-port. Mobile (≤900px) uses the drawer from T-098 and the mega
 * menu is removed entirely from the layout.
 */

/* ------------------------------------------------------------------
 * Overlay shell
 * ------------------------------------------------------------------ */

.mega-menu {
  position: fixed;
  inset: 0;
  z-index: 80;
  font-family: var(--font-sans);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}
.mega-menu.is-open {
  opacity: 1;
  pointer-events: auto;
}
.mega-menu[hidden] { display: none; }

.mega-bg {
  position: absolute;
  inset: 0;
  background: rgba(15, 16, 20, 0.4);
  cursor: pointer;
}

.mega-card {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  max-height: 70vh;
  overflow-y: auto;
  transform: translateY(-8px);
  transition: transform 200ms ease;
}
.mega-menu.is-open .mega-card { transform: translateY(0); }

.mega-card .wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.25rem 1rem 1.5rem;
}

/* ------------------------------------------------------------------
 * 3-column grid: 180px rail · 1fr panes · 200px brands/promo
 * ------------------------------------------------------------------ */

.mega-grid {
  display: grid;
  grid-template-columns: 180px 1fr 200px;
  gap: 1.5rem;
  align-items: start;
}

/* ------------------------------------------------------------------
 * Left rail — department buttons
 * ------------------------------------------------------------------ */

.mega-rail {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-right: 1px solid var(--line);
  padding-right: 0.75rem;
}

.mega-rail-item {
  appearance: none;
  border: 0;
  background: transparent;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}
.mega-rail-item:hover {
  background: var(--accent-soft);
  color: var(--accent);
}
.mega-rail-item.is-active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}
.mega-rail-item .ico {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex: 0 0 22px;
}
.mega-rail-item .lbl { flex: 1 1 auto; min-width: 0; }

/* ------------------------------------------------------------------
 * Center panes
 * ------------------------------------------------------------------ */

.mega-panes { min-width: 0; }

.mega-pane { display: none; }
.mega-pane.is-active { display: block; }

.mega-pane-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}
.mega-pane-head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.mega-pane-head h3 a {
  color: var(--ink);
  text-decoration: none;
}
.mega-pane-head h3 a:hover { color: var(--brand); text-decoration: none; }
.mega-pane-head .muted {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--ink-3);
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.mega-pane-head .muted:hover { color: var(--accent); text-decoration: none; }
.mega-pane-head .muted svg.tech-icon { width: 14px; height: 14px; }

.mega-grid-cols {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0 1.25rem;
}
.mega-grid-cols ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.mega-grid-cols li { margin: 0; }
.mega-grid-cols a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.4rem;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: 0.875rem;
  text-decoration: none;
  transition: background-color 140ms ease, color 140ms ease;
}
.mega-grid-cols a:hover {
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
}
.mega-grid-cols .ct {
  font-size: 0.75rem;
  color: var(--ink-3);
  background: var(--paper-2);
  border-radius: 999px;
  padding: 1px 8px;
  font-weight: 600;
  flex: 0 0 auto;
}

/* ------------------------------------------------------------------
 * Right rail — brands + featured promo
 * ------------------------------------------------------------------ */

.mega-side {
  border-left: 1px solid var(--line);
  padding-left: 1rem;
}
.mega-side h4 {
  margin: 0 0 0.6rem;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--ink-3);
}

.mega-brand-list {
  list-style: none;
  margin: 0 0 0.5rem;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.mega-brand-list li { margin: 0; }

.mega-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0.25rem;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  transition: border-color 140ms ease, color 140ms ease, background-color 140ms ease;
}
.mega-brand:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--paper);
  text-decoration: none;
}
.mega-brand img {
  max-height: 28px;
  width: auto;
  object-fit: contain;
}

.mega-allbrands {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--brand);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  margin-bottom: 1rem;
}
.mega-allbrands:hover { color: var(--accent); text-decoration: none; }
.mega-allbrands svg.tech-icon { width: 14px; height: 14px; }

.mega-promo {
  background: var(--accent-2-soft);
  border-radius: var(--radius);
  padding: 0.85rem 0.9rem;
}
.mega-promo-eyebrow {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--ink-3);
  margin-bottom: 0.25rem;
}
.mega-promo h5 {
  margin: 0 0 0.25rem;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}
.mega-promo p {
  margin: 0 0 0.6rem;
  font-size: 0.8125rem;
  color: var(--ink-2);
  line-height: 1.35;
}
.mega-promo .btn.ghost {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 140ms ease, color 140ms ease;
}
.mega-promo .btn.ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

/* ------------------------------------------------------------------
 * T-133: Compact mega menu — fit all depts in left rail without
 * internal scrolling, and switch rail items to anchor styling
 * (mega-menu.php now emits <a class="mega-rail-item">). Removes the
 * fixed `max-height: 70vh` on `.mega-card` and replaces with
 * `calc(100vh - 80px)` so only viewport-cramped layouts scroll.
 * ------------------------------------------------------------------ */

.mega-menu .mega-card {
  height: auto;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}

.mega-menu .mega-grid {
  grid-template-columns: 200px 1fr 220px;
  gap: 16px;
}

.mega-menu .mega-rail {
  max-height: none;
  overflow: visible;
  padding: 0;
}

.mega-menu .mega-rail-item {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--ink);
  cursor: pointer;
}

.mega-menu .mega-rail-item .ico {
  font-size: 16px;
  width: 20px;
  height: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 20px;
}

.mega-menu .mega-rail-item:hover,
.mega-menu .mega-rail-item.is-active,
.mega-menu .mega-rail-item[aria-selected="true"] {
  background: var(--paper-2);
  color: var(--brand);
}

.mega-menu .mega-panes {
  max-height: none;
  overflow: visible;
}

.mega-menu .mega-pane {
  padding: 0 16px;
}

.mega-menu .mega-pane .mega-pane-head {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.mega-menu .mega-pane .mega-pane-head h3 {
  font-size: 16px;
  margin: 0;
}

.mega-menu .mega-grid-cols ul {
  padding: 0;
  margin: 0;
  list-style: none;
}

.mega-menu .mega-grid-cols li {
  margin: 0;
}

.mega-menu .mega-grid-cols li a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 13px;
  color: var(--ink-2);
  text-decoration: none;
  border-radius: 4px;
  background: transparent;
}

.mega-menu .mega-grid-cols li a:hover {
  color: var(--brand);
  background: transparent;
}

.mega-menu .mega-grid-cols li .ct {
  font-size: 11px;
  color: var(--ink-3);
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  background: transparent;
  padding: 0;
  border-radius: 0;
}

.mega-menu .mega-side {
  padding-left: 16px;
  border-left: 1px solid var(--line);
}

.mega-menu .mega-brand-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 0;
  margin: 0 0 12px 0;
  list-style: none;
}

.mega-menu .mega-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 10px;
  background: var(--paper-2);
  border: 0;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--ink);
  text-decoration: none;
}

.mega-menu .mega-brand:hover {
  background: var(--brand);
  color: #fff;
  border-color: transparent;
}

/* ------------------------------------------------------------------
 * Mobile: drawer takes over from T-098; mega menu is removed entirely.
 * ------------------------------------------------------------------ */

@media (max-width: 900px) {
  .mega-menu { display: none !important; }
}
