/* =========================================================================
   Perth Mega Menu — brand tokens
   Palette: signal red, charcoal, white, warm-grey neutrals. Typography is
   a clean system-font stack approximating Inter/Poppins — deliberately
   NOT loading Google Fonts here, since an extra render-blocking network
   request for a mega menu font isn't worth it against the performance
   requirements; the fallback stack renders near-identically on every OS.
   ========================================================================= */
.pmm {
  --pmm-red: #E23038;
  --pmm-red-dark: #B4202A;
  --pmm-red-tint: #FBE9E9;
  --pmm-charcoal: #1B1B1D;
  --pmm-charcoal-soft: #2A2A2D;
  --pmm-white: #FFFFFF;
  --pmm-grey-100: #F7F7F6;
  --pmm-grey-200: #EFEEEC;
  --pmm-grey-300: #E1DFDC;
  --pmm-grey-500: #8B8983;
  --pmm-font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, Helvetica, Arial, sans-serif;
  --pmm-radius: 6px;
  --pmm-speed: 180ms;
  --pmm-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --pmm-panel-max-height: 560px; /* JS overwrites per-open based on real viewport space */
  --pmm-panel-top: 60px;         /* JS overwrites per-open based on trigger position */

  position: relative;
  margin: 0; /* defensive — in case a theme/page-builder button reset elsewhere adds one */
  font-family: var(--pmm-font-body);
  color: var(--pmm-charcoal);
}

.pmm *, .pmm *::before, .pmm *::after { box-sizing: border-box; }

/* Defensive reset — theme global styles routinely beat scoped rules on
   specificity; forcing the handful of properties that matter for
   legibility rather than trusting cascade order. */
.pmm h1, .pmm h2, .pmm h3, .pmm h4, .pmm h5, .pmm h6 {
  margin: 0 !important; padding: 0 !important; line-height: 1.25 !important;
  font-family: var(--pmm-font-body) !important;
}
.pmm ul, .pmm ol { margin: 0 !important; padding: 0 !important; list-style: none !important; }
.pmm p { margin: 0 !important; }
.pmm a, .pmm button { text-decoration: none !important; box-shadow: none !important; font-family: var(--pmm-font-body); }

/* ---------- Trigger ---------- */
.pmm__trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  background: var(--pmm-trigger-bg, var(--pmm-red)) !important;
  color: var(--pmm-trigger-text, var(--pmm-white)) !important;
  border: none;
  padding: 7px 20px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  border-radius: 0;
  transition: filter var(--pmm-speed) var(--pmm-ease);
}
.pmm__trigger:hover,
.pmm__trigger[aria-expanded="true"] { filter: brightness(0.88); }
.pmm__trigger:focus-visible { outline: 3px solid var(--pmm-trigger-bg, var(--pmm-red)); outline-offset: 2px; }
.pmm__trigger-icon { display: inline-flex; flex-direction: column; gap: 4px; width: 16px; }
.pmm__trigger-icon span { display: block; height: 2px; background: currentColor; transition: opacity 120ms ease; }

/* Small inline spinner shown ON THE TRIGGER (never inside the panel)
   only if data genuinely isn't ready yet after a short delay — see
   showPanel()/openMobile() in mega-menu.js. Replaces the hamburger icon
   in place so the button doesn't change size or cause layout shift. */
.pmm__trigger.is-loading .pmm__trigger-icon span { opacity: 0; }
.pmm__trigger.is-loading .pmm__trigger-icon {
  position: relative;
}
.pmm__trigger.is-loading .pmm__trigger-icon::after {
  content: "";
  position: absolute; top: 50%; left: 50%;
  width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border: 2px solid color-mix(in srgb, var(--pmm-trigger-text, var(--pmm-white)) 35%, transparent);
  border-top-color: var(--pmm-trigger-text, var(--pmm-white));
  border-radius: 50%;
  animation: pmm-spin 700ms linear infinite;
}
@keyframes pmm-spin { to { transform: rotate(360deg); } }

/* ---------- Panel shell ----------
   Fixed + centered on the viewport (not anchored to the trigger's own
   x-position) so a wide, near-full-width panel can sit centered under a
   nav bar even though the trigger itself usually sits near the left. */
.pmm__backdrop {
  position: fixed; inset: 0; background: rgba(27,27,29,0.35);
  opacity: 0; pointer-events: none;
  transition: opacity var(--pmm-speed) var(--pmm-ease);
  z-index: 999998;
}
.pmm__backdrop.is-visible { opacity: 1; pointer-events: auto; }

.pmm__panel {
  position: fixed;
  top: var(--pmm-panel-top);
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  width: calc(100vw - 40px);
  max-width: 1500px;
  background: var(--pmm-white) !important;
  border: 1px solid var(--pmm-grey-300);
  box-shadow: 0 20px 44px -14px rgba(27,27,29,0.22);
  border-radius: var(--pmm-radius);
  z-index: 999999;
  opacity: 0; visibility: hidden;
  display: flex; flex-direction: column;
  max-height: var(--pmm-panel-max-height);
  transition: opacity var(--pmm-speed) var(--pmm-ease),
              transform var(--pmm-speed) var(--pmm-ease),
              visibility 0s linear var(--pmm-speed);
}
.pmm__panel.is-open {
  opacity: 1; transform: translateX(-50%) translateY(0); visibility: visible;
  transition: opacity var(--pmm-speed) var(--pmm-ease), transform var(--pmm-speed) var(--pmm-ease);
}

.pmm__close {
  position: absolute; top: 10px; right: 10px; width: 32px; height: 32px;
  border: none; background: transparent; color: var(--pmm-grey-500);
  font-size: 22px; line-height: 1; cursor: pointer; z-index: 3;
}
.pmm__close:hover { color: var(--pmm-red); }

/* ---------- Breadcrumb ---------- */
.pmm__breadcrumb {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  padding: 12px 44px 12px 24px;
  border-bottom: 1px solid var(--pmm-grey-300);
  background: var(--pmm-grey-100);
  font-size: 12.5px; font-weight: 500;
  flex: 0 0 auto;
}
.pmm__breadcrumb:empty { display: none; }
.pmm__crumb {
  background: none; border: none; cursor: pointer; padding: 2px 4px;
  color: var(--pmm-grey-500) !important;
}
.pmm__crumb:hover { color: var(--pmm-red) !important; }
.pmm__crumb.is-current { color: var(--pmm-charcoal) !important; font-weight: 700; }
.pmm__crumb-sep { color: var(--pmm-grey-300); }

/* ---------- Stage: Level 1 (always) + landing extras OR browsing columns ----------
   Columns still stretch to the panel's shared height (needed so the
   internal-scroll bounding below actually has a definite height to work
   against) — but each column's CONTENT stays compact and top-aligned via
   its own inner flex structure (.pmm__level-scroll + .pmm__level-viewall),
   rather than stretching the category rows themselves to fill that height. */
.pmm__stage {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: contain;
}

.pmm__levels {
  display: flex;
  flex: 0 0 auto;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.pmm__levels::-webkit-scrollbar { display: none; }

/* Each column is its own small flex-column: a scrollable item list on top
   (only scrolls internally, and only if it's actually taller than the
   panel allows) plus a "View All" footer that's a SIBLING outside that
   scrollable area — so it can never be scrolled out of reach, and the
   items/footer never stretch to fill the column's full height even
   though the column itself matches its siblings' height. */
.pmm__level {
  display: flex; flex-direction: column;
  flex: 0 0 232px;
  width: 232px;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--pmm-grey-300);
}

.pmm__level-scroll {
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.pmm__level-scroll::-webkit-scrollbar { display: none; }

.pmm__level-viewall {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 6px;
  padding: 12px 20px;
  margin-top: 4px;
  border-top: 1px solid var(--pmm-grey-300);
  font-size: 13px; font-weight: 700;
  color: var(--pmm-red) !important; text-decoration: none !important;
}
.pmm__level-viewall:hover { color: var(--pmm-red-dark) !important; }

/* Level 1 is pinned: fixed width, sticky against the left edge of the
   scroll container, and always the first thing rendered by JS — it can
   never be pushed out of view by deeper navigation, however many levels
   deep the shopper goes, and it's what the landing view's other columns
   sit beside too. */
.pmm__level--pinned {
  background: var(--pmm-white);
  flex-basis: 240px;
  width: 240px;
  position: sticky;
  left: 0;
  z-index: 2;
}
.pmm__level--pinned .pmm__level-scroll { padding: 20px 0 12px; }

.pmm__level--error {
  padding: 28px 24px; width: 320px; flex-basis: 320px;
}
.pmm__error-message { color: var(--pmm-charcoal-soft) !important; font-size: 14px; margin-bottom: 14px !important; }
.pmm__retry-btn {
  display: inline-flex; align-items: center;
  padding: 9px 18px; border: none; border-radius: var(--pmm-radius);
  background: var(--pmm-red) !important; color: var(--pmm-white) !important;
  font-size: 13px; font-weight: 700; cursor: pointer;
  transition: background var(--pmm-speed) var(--pmm-ease);
}
.pmm__retry-btn:hover { background: var(--pmm-red-dark) !important; }
.pmm__retry-btn:disabled { opacity: 0.6; cursor: default; }

.pmm__level-header {
  padding: 6px 20px 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--pmm-grey-300);
  font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; font-weight: 700;
  color: var(--pmm-grey-500) !important;
}

.pmm__item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left; padding: 10px 20px;
  border: none; background: transparent;
  border-left: 3px solid transparent;
  font-size: 14px; color: var(--pmm-charcoal) !important;
  cursor: pointer;
  transition: background var(--pmm-speed) var(--pmm-ease), color var(--pmm-speed) var(--pmm-ease);
}
.pmm__level--pinned .pmm__item { font-size: 14.5px; font-weight: 500; padding: 11px 24px; }
.pmm__item-icon { flex: 0 0 auto; width: 19px; height: 19px; color: var(--pmm-grey-500); transition: color var(--pmm-speed) var(--pmm-ease); }
.pmm__item-label { flex: 1 1 auto; min-width: 0; }
.pmm__item:hover, .pmm__item:focus-visible { background: var(--pmm-grey-100) !important; }
.pmm__item.is-active {
  background: var(--pmm-red-tint) !important;
  border-left-color: var(--pmm-red);
  color: var(--pmm-red-dark) !important;
  font-weight: 600;
}
.pmm__item.is-active .pmm__item-icon { color: var(--pmm-red); }
.pmm__item-arrow { opacity: 0.45; font-size: 14px; flex: 0 0 auto; margin-left: auto; }
.pmm__item.is-active .pmm__item-arrow { opacity: 1; color: var(--pmm-red); }

/* ---------- Landing view: Popular Categories / Top Brands / Promo ----------
   Visible by default; hidden the moment a Level 1 category with children
   is hovered (panel gets .pmm--browsing). Static server-rendered content
   — no JS build step, no extra request. */
.pmm__landing-extra {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none; -ms-overflow-style: none;
}
.pmm__landing-extra::-webkit-scrollbar { display: none; }
.pmm--browsing .pmm__landing-extra { display: none; }

.pmm__landing-col {
  flex: 20 1 0;
  min-width: 160px;
  padding: 24px 24px;
  border-right: 1px solid var(--pmm-grey-300);
}
.pmm__landing-heading {
  font-size: 13px; font-weight: 700; letter-spacing: 0.01em;
  color: var(--pmm-charcoal) !important; margin-bottom: 16px !important;
}
.pmm__landing-list li { margin-bottom: 14px; }
.pmm__landing-list a {
  font-size: 14px; color: var(--pmm-charcoal-soft) !important; text-decoration: none !important;
  transition: color var(--pmm-speed) var(--pmm-ease);
}
.pmm__landing-list a:hover { color: var(--pmm-red) !important; }
.pmm__landing-viewall {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; font-weight: 700; color: var(--pmm-red) !important;
  margin-top: 8px !important;
}
.pmm__landing-viewall:hover { color: var(--pmm-red-dark) !important; }

.pmm__landing-promo {
  flex: 35 1 0;
  min-width: 260px;
  position: relative;
  overflow: hidden;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 28px;
  background: linear-gradient(160deg, var(--pmm-charcoal) 0%, var(--pmm-charcoal-soft) 100%);
}
.pmm__landing-promo img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
.pmm__landing-promo-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(0deg, rgba(20,20,20,0.82) 0%, rgba(20,20,20,0.15) 55%, rgba(20,20,20,0.05) 100%);
}
.pmm__landing-promo-label {
  position: relative; z-index: 1;
  display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--pmm-red) !important; margin-bottom: 8px !important;
}
.pmm__landing-promo-heading {
  position: relative; z-index: 1;
  font-size: 24px; font-weight: 700; line-height: 1.2 !important;
  color: var(--pmm-white) !important; max-width: 320px;
}
.pmm__landing-promo-btn {
  position: relative; z-index: 1;
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 18px; padding: 12px 20px;
  background: var(--pmm-red) !important; color: var(--pmm-white) !important;
  font-size: 13px; font-weight: 700; border-radius: var(--pmm-radius);
  transition: background var(--pmm-speed) var(--pmm-ease);
}
.pmm__landing-promo-btn:hover { background: var(--pmm-red-dark) !important; }

/* ---------- Browsing: deeper category columns + image ---------- */
.pmm__feature { display: none; } /* shown/hidden by JS: layoutColumns() while browsing, forced off in landing */
.pmm__feature {
  flex: 0 0 360px; width: 360px; /* JS overrides via inline style based on actual available space */
  align-self: stretch; /* opts back into filling the panel's full height, unlike the nav columns beside it */
  position: relative; overflow: hidden;
  flex-direction: column; justify-content: flex-end;
  padding: 24px;
  color: var(--pmm-white) !important;
}
.pmm__feature-media {
  position: absolute; inset: 0;
  background: linear-gradient(160deg, var(--pmm-charcoal) 0%, var(--pmm-charcoal-soft) 100%);
}
.pmm__feature-media img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
.pmm__feature-media::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(27,27,29,0.15) 0%, rgba(27,27,29,0.75) 100%);
}
.pmm__feature-media.is-fallback {
  background:
    repeating-linear-gradient(135deg, rgba(226,48,56,0.10) 0 2px, transparent 2px 26px),
    linear-gradient(160deg, var(--pmm-charcoal) 0%, var(--pmm-charcoal-soft) 100%);
}
.pmm__feature-media.is-fallback::before {
  content: attr(data-initial);
  position: absolute; right: 8px; bottom: -18px;
  font-size: 140px; font-weight: 800; line-height: 1; color: rgba(255,255,255,0.06);
}

.pmm__feature-body { position: relative; z-index: 1; }
.pmm__feature-eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--pmm-red) !important; display: block; margin-bottom: 6px !important;
}
.pmm__feature-title {
  font-size: 21px; font-weight: 700;
  color: var(--pmm-white) !important;
}
.pmm__feature-desc {
  font-size: 12.5px; color: rgba(255,255,255,0.75) !important; margin-top: 6px !important;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.pmm__feature-cta {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 14px;
  color: var(--pmm-white) !important;
  font-size: 12.5px; font-weight: 700;
  border-bottom: 1px solid var(--pmm-red);
}
.pmm__feature-cta:hover { color: var(--pmm-red) !important; }

/* focus visibility everywhere inside the menu */
.pmm a:focus-visible, .pmm button:focus-visible {
  outline: 3px solid var(--pmm-red); outline-offset: -2px;
}

/* ---------- Mobile drill-down ---------- */
.pmm-mobile { display: none; }

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

  .pmm-mobile {
    position: fixed; inset: 0; z-index: 1000000;
    background: var(--pmm-white);
    transform: translateX(-100%);
    transition: transform var(--pmm-speed) var(--pmm-ease);
    display: flex; flex-direction: column;
  }
  .pmm-mobile.is-open { transform: translateX(0); }

  .pmm-mobile__header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 18px; background: var(--pmm-charcoal); color: var(--pmm-white);
    font-size: 15px; font-weight: 700;
    flex: 0 0 auto;
  }
  .pmm-mobile__header .pmm__close { position: static; color: var(--pmm-white); }

  .pmm-mobile__list { overflow-y: auto; flex: 1; min-height: 0; overscroll-behavior: contain; scrollbar-width: none; -ms-overflow-style: none; }
  .pmm-mobile__list::-webkit-scrollbar { display: none; }

  .pmm-drill-error { padding: 24px 18px; }
  .pmm-drill-error .pmm__error-message { font-size: 15px; }
  .pmm-drill-error .pmm__retry-btn { padding: 11px 20px; font-size: 14px; }

  .pmm-drill-header {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 18px 6px;
    animation: pmm-fade-in 180ms ease;
  }
  .pmm-drill-back {
    display: flex; align-items: center; gap: 2px;
    background: none; border: none; padding: 4px 6px 4px 0;
    color: var(--pmm-red) !important; font-size: 13px; font-weight: 700;
    cursor: pointer; flex: 0 0 auto;
  }
  .pmm-drill-title {
    font-size: 15px; font-weight: 700; color: var(--pmm-charcoal) !important;
  }
  .pmm-drill-viewall {
    display: block; margin: 0 18px 10px !important; padding-bottom: 6px;
    font-size: 12.5px; font-weight: 700;
    color: var(--pmm-red) !important; text-decoration: none !important;
    border-bottom: 1px solid var(--pmm-grey-300);
  }
  .pmm-drill-list { animation: pmm-fade-in 180ms ease; }
  .pmm-drill-row {
    width: 100%; display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; background: none; border: none; border-bottom: 1px solid var(--pmm-grey-300);
    text-align: left; font-size: 15px; font-weight: 500;
    color: var(--pmm-charcoal) !important; text-decoration: none !important; cursor: pointer;
  }
  .pmm-drill-arrow { color: var(--pmm-grey-500); font-size: 13px; }

  @keyframes pmm-fade-in {
    from { opacity: 0; } to { opacity: 1; }
  }
}

@media (prefers-reduced-motion: reduce) {
  .pmm-drill-header, .pmm-drill-list { animation: none !important; }
  .pmm * { transition-duration: 0.01ms !important; }
}
