/**
 * Desktop mega menus — ported from Navigation.astro scoped styles.
 *
 * Baseline (user-confirmed):
 *   .mega-menu-dropdown { z-index:100; background:transparent; position:fixed; }
 *
 * Contract with site.js — both files must ship together:
 *   JS owns top/left only, read from THAT dropdown's own trigger .group
 *   getBoundingClientRect (top = trigger bottom). Left is clamped to the
 *   page column (.xprss-mainbar__inner, 1200px), not the viewport. CSS owns
 *   width via the per-panel classes below; JS must not write width back onto
 *   the panel.
 *   Close on scroll, then re-anchor if still hovered (never sticky-follow).
 *
 * Open via CSS :hover/:focus-within AND JS .is-mega-open — a deploy once
 * shipped CSS gated only on .is-mega-open with a stale site.js that never set
 * it, leaving every panel display:none. Either path alone must still open it.
 * body.mega-menu-scrolling force-hides during scroll (overrides :hover).
 *
 * Visibility is owned here (display/visibility, not Tailwind utilities alone).
 *
 * Stacking scale (beats Tailwind z-* utilities via !important):
 *   1    — hero / page media (hero.css)
 *   100  — site header + mega dropdowns
 *   110  — mobile nav backdrop
 *   120  — mobile nav drawer
 */

/* Top-level desktop nav typography comes from chrome-appearance.css vars. */
[data-desktop-main-nav] > a,
[data-desktop-main-nav] > .group > a {
  text-transform: var(--xprss-header-text-transform, uppercase);
}

/* Header above hero on all viewports */
[data-xprss-header] {
  position: relative !important;
  z-index: 100 !important;
}

/* Mobile drawer + backdrop — above header and hero */
[data-xprss-nav-overlay] {
  display: none !important;
  position: fixed !important;
  z-index: 110 !important;
}

[data-xprss-nav-overlay].is-open,
[data-xprss-nav-overlay]:not(.hidden) {
  display: block !important;
}

[data-xprss-nav-drawer] {
  display: block !important;
  position: fixed !important;
  z-index: 120 !important;
  transform: translateX(-100%);
}

[data-xprss-nav-drawer].is-open,
[data-xprss-nav-drawer].translate-x-0 {
  transform: translateX(0);
}

@media (min-width: 1024px) {
  [data-xprss-nav-overlay],
  [data-xprss-nav-overlay].is-open,
  [data-xprss-nav-overlay]:not(.hidden),
  [data-xprss-nav-drawer],
  [data-xprss-nav-drawer].is-open {
    display: none !important;
  }
}

/*
 * Baseline + hide until hover/focus-within/JS open.
 * JS owns top/left via inline styles (clamped to the 1200px page column) —
 * do not lock top/left with !important here.
 *
 * Open via BOTH CSS :hover/:focus-within AND JS .is-mega-open so a stale or
 * failed site.js cannot leave panels permanently display:none. Scroll close is
 * forced below via body.mega-menu-scrolling (overrides :hover).
 *
 * Fixed panels leave the visual flow: this transparent padding-top bridge sits
 * inside the dropdown box, directly below the trigger (JS anchors top to the
 * trigger's bottom edge), so the pointer never crosses a dead gap on its way
 * into the panel — and the bridge never overlaps the trigger link itself.
 */
.mega-menu-dropdown {
  z-index: 100;
  background-color: transparent !important;
  position: fixed;
  right: auto;
  width: max-content;
  /* Match .xprss-mainbar__inner — never span the full viewport. */
  max-width: min(1200px, calc(100vw - 2rem));
  height: auto;
  margin: 0;
  padding-top: 12px;
  box-sizing: border-box;
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transition: none !important;
}

[data-desktop-main-nav] .group:hover > .mega-menu-dropdown,
[data-desktop-main-nav] .group:focus-within > .mega-menu-dropdown,
[data-desktop-main-nav] .group.is-mega-open > .mega-menu-dropdown {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

/* Force closed while scrolling — overrides :hover / :focus-within / .is-mega-open */
body.mega-menu-scrolling [data-desktop-main-nav] .group > .mega-menu-dropdown,
body.mega-menu-scrolling [data-desktop-main-nav] .group:hover > .mega-menu-dropdown,
body.mega-menu-scrolling [data-desktop-main-nav] .group:focus-within > .mega-menu-dropdown,
body.mega-menu-scrolling [data-desktop-main-nav] .group.is-mega-open > .mega-menu-dropdown {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

[data-desktop-main-nav] .group {
  position: relative !important;
  overflow: visible !important;
}

[data-desktop-main-nav] {
  overflow: visible !important;
}

.mega-menu-panel {
  position: relative;
  width: fit-content;
  max-width: min(800px, 1200px, calc(100vw - 2rem));
  height: auto;
  min-height: 0;
  margin: 0;
  border-radius: 0.5rem;
  overflow: hidden;
  background-color: #ffffff;
  color: #111827;
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

.inventory-menu-panel {
  width: min(800px, 1200px, calc(100vw - 2rem));
  max-width: min(800px, 1200px, calc(100vw - 2rem));
  min-height: 0;
  height: auto;
}

.inventory-menu-content {
  width: 100%;
}

.inventory-menu-grid {
  width: 100%;
  min-height: 0;
  align-items: flex-start;
}

.inventory-promo-column {
  width: 250px;
  flex-shrink: 0;
}

.inventory-promo-image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.inventory-promo-link {
  border-radius: 4px;
  display: block;
  line-height: 0;
}

.inventory-top-tabs {
  grid-template-columns: repeat(var(--xprss-mega-tab-cols, 3), minmax(0, 1fr));
}

.inventory-top-tab {
  background: var(--xprss-mega-btn-bg, var(--brand-pri, #33414a));
  color: #ffffff;
  font-size: 0.95rem;
  line-height: 1.25rem;
  text-transform: uppercase;
  font-weight: 500;
  text-align: center;
  padding: 0.6rem 0.75rem;
  border-radius: 5px;
  transition: background-color 0.2s ease;
}

.inventory-top-tab:hover {
  background: var(--xprss-mega-btn-hover, var(--brand-sec, #2a353c));
}

.inventory-top-tab--special {
  background: var(--brand-pri, #33414a);
}

.inventory-top-tab--special:hover {
  background: var(--brand-sec, #2a353c);
}

.inventory-type-grid {
  grid-auto-rows: 1fr;
  grid-template-columns: repeat(var(--xprss-mega-type-cols, 3), minmax(0, 1fr));
}

.inventory-type-card {
  background: var(--xprss-mega-card-bg, var(--brand-pri, #33414a));
  color: #ffffff;
  border-radius: 4px;
  padding: 0.9rem 0.65rem 0.75rem;
  text-align: center;
  transition: background-color 0.2s ease;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.inventory-type-card:hover {
  background: var(--xprss-mega-card-hover, var(--brand-sec, #2a353c));
}

.inventory-type-card-image-wrap {
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.35rem;
}

.inventory-type-card-image-wrap.xprss-svg-fill {
  --xprss-svg-fill: var(--xprss-mega-card-icon-fill, #ffffff);
  color: var(--xprss-mega-card-icon-fill, #ffffff);
}

.inventory-type-card-image-wrap.xprss-svg-fill svg :is(path, polygon, rect, circle, ellipse) {
  fill: var(--xprss-mega-card-icon-fill, #ffffff) !important;
}

.inventory-type-card-image-wrap.xprss-svg-fill svg [fill="none"] {
  fill: none !important;
}

.inventory-type-card-image {
  width: 86%;
  height: 100%;
  object-fit: contain;
}

.inventory-type-card-image-wrap svg.inventory-type-card-image {
  object-fit: unset;
}

.inventory-type-card-title {
  font-size: 0.9rem;
  line-height: 1.1rem;
  font-weight: 500;
  text-transform: uppercase;
  color: #ffffff;
}

.inventory-show-all {
  display: block;
  background: var(--xprss-mega-btn-bg, var(--brand-pri, #33414a));
  color: #ffffff;
  text-align: center;
  font-weight: 500;
  text-transform: uppercase;
  padding: 0.6rem 0.75rem;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.inventory-show-all:hover {
  background: var(--xprss-mega-btn-hover, var(--brand-sec, #2a353c));
}

.inventory-tow-guide-link {
  display: block;
  margin-top: 0.75rem;
  background: var(--xprss-mega-btn-bg, var(--brand-pri, #33414a));
  color: #ffffff;
  text-align: center;
  text-transform: uppercase;
  font-weight: 500;
  padding: 0.6rem 0.5rem;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.inventory-tow-guide-link:hover {
  background: var(--xprss-mega-btn-hover, var(--brand-sec, #2a353c));
}

.inventory-brand-grid {
  min-height: 100px;
  grid-template-columns: repeat(var(--xprss-mega-brand-cols, 4), minmax(0, 1fr));
}

.inventory-brand-link {
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
}

.inventory-brand-link:hover {
  opacity: 0.75;
}

.inventory-brand-logo {
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
}

.inventory-brand-fallback {
  font-size: 0.75rem;
  line-height: 1rem;
  text-transform: uppercase;
  font-weight: 500;
  color: #1f2937;
  text-align: center;
}

.shop-parts-menu-panel {
  width: min(1100px, 1200px, calc(100vw - 2rem));
  min-width: min(640px, 100%);
  max-width: min(1200px, calc(100vw - 2rem));
}

.lifestyle-menu-panel {
  width: min(760px, 1200px, calc(100vw - 2rem));
  min-width: min(680px, 100%);
  padding: 0.85rem;
}

.lifestyle-mega-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  margin: 0 0 0.75rem;
  align-items: stretch;
}

.lifestyle-mega-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: #ffffff;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid #f3f4f6;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.lifestyle-mega-card-body {
  display: flex;
  flex: 1 1 auto;
  gap: 0.75rem;
  padding: 0.75rem 0.75rem 0;
  min-height: 0;
  align-items: flex-start;
}

.lifestyle-mega-card-copy {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.lifestyle-mega-card-title {
  margin: 0 0 0.4rem;
  font-size: 1.15rem;
  font-weight: 900;
  line-height: 1.15;
  color: #111827;
  text-transform: uppercase;
}

.lifestyle-mega-card-desc {
  margin: 0;
  flex: 1 1 auto;
  color: #4b5563;
  font-size: 0.75rem;
  line-height: 1.35;
  text-transform: uppercase;
}

.lifestyle-mega-card-image {
  width: 5.5rem;
  height: 5.5rem;
  flex-shrink: 0;
  border-radius: 0.25rem;
  overflow: hidden;
  background: #f3f4f6;
}

.lifestyle-mega-card-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.lifestyle-mega-card-actions {
  padding: 0.6rem 0.75rem 0.75rem;
  margin-top: auto;
}

.lifestyle-mega-card-btn,
.lifestyle-mega-cta {
  display: block;
  width: 100%;
  color: #ffffff;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  transition: background-color 0.2s ease;
}

.lifestyle-mega-card-btn {
  background: var(--xprss-mega-btn-bg, var(--brand-pri, #33414a));
  font-size: 0.875rem;
  line-height: 1.25;
  padding: 0.6rem 1rem;
  border-radius: 0.25rem;
}

.lifestyle-mega-card-btn:hover {
  background: var(--xprss-mega-btn-hover, var(--brand-sec, #2a353c));
  color: #ffffff;
}

.lifestyle-mega-cta {
  background: var(--xprss-mega-btn-bg, var(--brand-pri, #33414a));
  font-size: 1rem;
  line-height: 1.25;
  padding: 0.7rem 1rem;
  border-radius: 0.5rem;
}

.lifestyle-mega-cta:hover {
  background: var(--xprss-mega-btn-hover, var(--brand-sec, #2a353c));
  color: #ffffff !important;
}

@media (max-width: 1023.98px) {
  .inventory-menu-panel {
    min-height: auto;
  }

  .lifestyle-menu-panel {
    width: min(95vw, 760px);
    min-width: 0;
  }

  .lifestyle-mega-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .inventory-menu-grid {
    flex-direction: column;
  }

  .inventory-promo-column {
    width: 100%;
    max-width: none;
  }

  .inventory-brand-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 1rem;
  }
}

.shop-parts-card-with-bg {
  background-image: linear-gradient(to bottom, rgba(17, 24, 39, 0.65), rgba(17, 24, 39, 0.65)), var(--shop-parts-card-bg);
  background-size: cover, cover;
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
}

.shop-parts-cards-grid,
.shop-parts-cta {
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.shop-parts-menu-content {
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

.shop-parts-card-with-bg:hover {
  filter: brightness(1.08);
}

