/* ==========================================================================
   Matthuset Mega Menu v1
   Custom mega panel for top-level menu items with class `mega-menu`.
   Loaded after header-redesign-v1.css so it can win specificity battles.
   ========================================================================== */

/* ----- Regular dropdowns: clean white card ----- */
.main-navigation ul.menu li.menu-item-has-children > ul.sub-menu {
  background: #fff;
  border: 1px solid #eee;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  border-radius: 2px;
  padding: 0.5rem 0;
  min-width: 220px;
}

.main-navigation ul.menu ul.sub-menu li a {
  padding: 0.6rem 1.25rem;
  font-size: 0.92rem;
  color: #333;
  transition: color 0.15s ease, background 0.15s ease;
}

.main-navigation ul.menu ul.sub-menu li a:hover {
  background: #faf7f2;
  color: #ef0000;
}

/* ==========================================================================
   Mega panel
   ========================================================================== */

.main-navigation,
.main-navigation .primary-navigation,
.main-navigation .menu {
  position: relative;
}

.main-navigation li.mega-menu {
  position: static; /* allow full-width panel relative to nav */
}

.mh-mega-panel {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  background: #fff;
  border-top: 1px solid #eee;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
  z-index: 1000;
}

.main-navigation li.mega-menu.is-open > .mh-mega-panel {
  display: block;
}

.mh-mega-panel__inner {
  display: flex;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem;
  gap: 2rem;
}

/* ----- Sidebar ----- */
.mh-mega-sidebar {
  flex: 0 0 240px;
  display: block !important;
  position: static !important;
  visibility: visible !important;
  opacity: 1 !important;
  background: transparent !important;
  box-shadow: none !important;
  border: none;
  border-right: 1px solid #eee;
  padding: 0 1.25rem 0 0;
  margin: 0;
}

.mh-mega-sidebar__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.75rem;
  margin: 0;
  font-size: 0.95rem;
  color: #333;
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.12s ease, color 0.12s ease;
}

.mh-mega-sidebar__item:hover,
.mh-mega-sidebar__item.is-active {
  background: #faf7f2;
  color: #ef0000;
}

.mh-mega-sidebar__chevron {
  flex-shrink: 0;
  opacity: 0.6;
}

.mh-mega-sidebar__viewall {
  list-style: none;
  margin-top: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-top: 1px solid #eee;
}

/* Storefront's customizer inline CSS sets `.main-navigation ul li a { color: #fffbf7 }`
   at specificity (0,0,3,0), which beats this rule's natural specificity.
   !important pins the brand-red color so the link doesn't go white on white. */
.mh-mega-sidebar__viewall a {
  font-size: 0.88rem;
  font-weight: 600;
  color: #ef0000 !important;
  text-decoration: none;
}

.mh-mega-sidebar__viewall a:hover {
  text-decoration: underline;
  color: #ef0000 !important;
}

/* ----- Content / grids ----- */
.mh-mega-content {
  flex: 1 1 auto;
  position: relative;
  min-height: 320px;
}

.mh-mega-grid {
  display: none;
  /* Match the simple-grid pattern: auto-fill so cards stay at a consistent
     ~200px (same as Heltäckningsmattor / Golv / Tillbehör), regardless of
     the panel width. The Mattor panel has a 240px sidebar so it fits ~5
     cards/row; the other menus fit ~4. Visual size + behavior match. */
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  grid-auto-rows: min-content;
  align-items: start;
  gap: 1.25rem;
}

.mh-mega-grid.is-active {
  display: grid;
}

/* .mh-mega-card now mirrors .mh-simple-card behavior — no card lift on hover,
   no inner-image scale. Same calm hover treatment as the other menus. */
.mh-mega-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: #333;
}

.mh-mega-card:hover {
  transform: none;
}

.mh-mega-card__media {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #faf7f2;
  border-radius: 3px;
}

.mh-mega-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.mh-mega-card:hover .mh-mega-card__media img {
  transform: none;
}

.mh-mega-card__placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #faf7f2 0%, #ede6d8 100%);
}

.mh-mega-card__label {
  margin-top: 0.55rem;
  font-size: 0.88rem;
  font-weight: 500;
  text-align: center;
  color: #333;
}

.mh-mega-card:hover .mh-mega-card__label {
  color: #ef0000;
}

/* ==========================================================================
   A–Z list panel — flat alphabetical text list, no images
   Activated when the sidebar's "A–Z" tab is selected. Rendered by the
   walker as <ul class="mh-mega-list__items">.
   The visibility rule uses both `.is-active` and `[aria-hidden="false"]`
   with !important — the alternate selector is a fallback if any browser-
   or plugin-injected rule wins on the class-only form, and !important
   short-circuits the cascade entirely. */

.mh-mega-list {
  display: none !important;
}

.mh-mega-list.is-active,
.mh-mega-list[aria-hidden="false"] {
  display: block !important;
}

/* Storefront's parent CSS includes a classic a11y sub-menu hide:
     .main-navigation ul ul { position: absolute; left: -9999px; ... }
   That selector matches our nested <ul class="mh-mega-list__items"> too,
   pushing the entire list off-screen by -9999px. Re-anchor it back into
   the panel with position: relative; left: 0. !important is needed because
   the Storefront rule's specificity (0,0,3,0) beats our (0,0,1,0). */
.mh-mega-list.is-active .mh-mega-list__items,
.mh-mega-list[aria-hidden="false"] .mh-mega-list__items {
  position: relative !important;
  left: 0 !important;
  top: 0 !important;
}

/* Grid layout for the actual list items. !important on display because
   Storefront's `.main-navigation ul ul { display: block }` would otherwise
   collapse the grid. */
.mh-mega-list__items {
  list-style: none;
  margin: 0 !important;
  padding: 0 !important;
  display: grid !important;
  grid-template-columns: repeat(3, 1fr) !important;
  gap: 0.4rem 2rem;
  width: 100%;
}

.mh-mega-list__items li {
  margin: 0 !important;
  display: block !important; /* override Storefront's `.main-navigation ul li { display: inline-block }` */
}

/* color !important pins this against Storefront's customizer rule
   `.main-navigation ul li a { color: #fffbf7 }` — without it, the list
   links render as white on white and the panel appears empty. */
.mh-mega-list__items a {
  display: inline-block;
  font-size: 0.95rem;
  font-weight: 500;
  color: #333 !important;
  text-decoration: none;
  padding: 0.2rem 0;
  transition: color 0.12s ease;
}

.mh-mega-list__items a:hover {
  color: #ef0000 !important;
}

@media (max-width: 1024px) {
  .mh-mega-list__items {
    columns: 2;
  }
}

/* ==========================================================================
   Alphabetical mega panel (Mattor)
   3 columns of category links sorted by Swedish locale, plus a featured
   product card on the right. Used only when the menu item resolves to
   the `mattor` product_cat term.
   ========================================================================== */

.mh-mega-panel--alpha .mh-mega-panel__inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 36px;
  padding: 32px 28px 36px;
  align-items: flex-start;
}

.mh-mega-alpha-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px;
  min-width: 0;
}

.mh-mega-alpha-col {
  min-width: 0;
}

.mh-mega-alpha-col__head {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
  color: #e3141b;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid #e5e0d5;
  line-height: 1.2;
}

/* Storefront ships .main-navigation ul ul { position:absolute; left:-9999px }
   to hide nested submenus. Our alphabetical lists are nested under the
   primary <ul class="menu"> so they'd inherit that off-screen position too.
   Force them back into normal flow. */
.mh-mega-panel--alpha .mh-mega-alpha-col__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex !important;
  flex-direction: column;
  position: static !important;
  left: auto !important;
  top: auto !important;
  float: none !important;
  z-index: auto !important;
  box-shadow: none !important;
  border: none !important;
  background: transparent !important;
  min-width: 0 !important;
}

.mh-mega-panel--alpha .mh-mega-alpha-col__list li {
  margin: 0 !important;
  padding: 0 !important;
  display: block !important;
  position: static !important;
}

.mh-mega-panel--alpha .mh-mega-alpha-col__list a {
  display: block !important;
  padding: 4px 0 !important;
  margin: 0 !important;
  font-size: 13px !important;
  font-weight: 400 !important;
  line-height: 1.35 !important;
  color: #1a1815 !important;
  background: transparent !important;
  text-decoration: none !important;
  text-transform: none !important;
  border: none !important;
  transition: color 0.12s ease;
}

.mh-mega-panel--alpha .mh-mega-alpha-col__list a:hover,
.mh-mega-panel--alpha .mh-mega-alpha-col__list a:focus {
  color: #e3141b !important;
  background: transparent !important;
}

/* Featured product card on the right */
.mh-mega-feature {
  display: flex;
  flex-direction: column;
  background: #faf7f2;
  border: 1px solid #e5e0d5;
  padding: 24px !important;
  text-decoration: none;
  color: #1a1815;
  transition: border-color 0.15s ease;
  box-sizing: border-box;
}

.mh-mega-feature:hover {
  border-color: #cec7b8;
}

.mh-mega-feature__kicker {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
  color: #e3141b;
  margin-bottom: 14px;
}

.mh-mega-feature__media {
  position: relative;
  width: 100% !important;
  max-width: 100% !important;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #fff;
  margin: 0 0 14px 0 !important;
  box-sizing: border-box;
}

.mh-mega-feature__media img {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  object-fit: cover;
  display: block;
  margin: 0 !important;
  padding: 0 !important;
  transition: transform 0.4s ease;
}

.mh-mega-feature:hover .mh-mega-feature__media img {
  transform: scale(1.04);
}

.mh-mega-feature__title {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  color: #1a1815;
}

.mh-mega-feature__price {
  font-size: 14px;
  font-weight: 700;
  color: #e3141b;
  margin-bottom: 14px;
  line-height: 1.3;
}
.mh-mega-feature__price .woocommerce-Price-amount {
  color: inherit !important;
  font: inherit !important;
}

.mh-mega-feature__cta {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #1a1815;
  text-transform: none;
}
.mh-mega-feature:hover .mh-mega-feature__cta {
  color: #e3141b;
}

.mh-mega-feature--all {
  background: #faf7f2;
  border: 1px dashed #cec7b8;
  padding: 18px;
  font-size: 13px;
  color: #1a1815;
  text-align: center;
}
.mh-mega-feature--all a {
  color: inherit;
  text-decoration: none;
  font-weight: 600;
}

/* Mobile: stack everything */
@media (max-width: 767px) {
  .mh-mega-panel--alpha .mh-mega-panel__inner {
    grid-template-columns: 1fr;
    padding: 0.5rem 0 1rem;
    gap: 16px;
  }
  .mh-mega-alpha-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .mh-mega-feature {
    padding: 14px;
  }
}

/* ==========================================================================
   Simple image-grid dropdown (non-mega product_cat items)
   ========================================================================== */

.main-navigation li.mega-simple {
  position: relative;
}

.mh-simple-panel {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: #fff;
  border: 1px solid #eee;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
  border-radius: 2px;
  padding: 1.25rem;
  z-index: 1000;
  min-width: 720px;
  max-width: 920px;
}

.main-navigation li.mega-simple.is-open > .mh-simple-panel {
  display: block;
}

.mh-simple-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  grid-auto-rows: min-content;
  align-items: start;
  column-gap: 1.25rem;
  row-gap: 1.25rem;
}

.mh-simple-card,
.mh-simple-card * {
  margin: 0;
}

.mh-simple-card__label {
  margin-top: 0.55rem !important;
}

.mh-simple-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: #333;
  transition: transform 0.18s ease;
}

.mh-simple-card:hover {
  transform: none;
}

.mh-simple-card__media {
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 3px;
  background: #faf7f2;
}

.mh-simple-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.mh-simple-card:hover .mh-simple-card__media img {
  transform: none;
}

.mh-simple-card__placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #faf7f2 0%, #ede6d8 100%);
}

.mh-simple-card__label {
  margin-top: 0.55rem;
  font-size: 0.9rem;
  font-weight: 500;
  text-align: center;
  color: #333;
}

.mh-simple-card:hover .mh-simple-card__label {
  color: #ef0000;
}

/* ==========================================================================
   Mobile: panel collapses into accordion under the parent link
   ========================================================================== */
@media (max-width: 767px) {
  .mh-mega-panel {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border-top: none;
    display: none;
    transition: none;
  }

  .main-navigation li.mega-menu.is-open > .mh-mega-panel {
    display: block;
  }

  .mh-mega-panel__inner {
    flex-direction: column;
    padding: 0.5rem 16px 1rem;
    gap: 0.75rem;
  }

  .mh-mega-sidebar {
    flex: 1 1 auto;
    border-right: none;
    border-bottom: 1px solid #eee;
    padding-right: 0;
    padding-bottom: 0.5rem;
  }

  .mh-mega-content {
    min-height: 0;
  }

  .mh-mega-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .mh-mega-card__media {
    display: none; /* lighter mobile */
  }

  .mh-mega-card__label {
    text-align: left;
    padding: 0.5rem 0.75rem;
  }

  .mh-simple-panel {
    position: static;
    box-shadow: none;
    border: none;
    padding: 0.5rem 0;
    min-width: 0;
    max-width: none;
  }

  .mh-simple-grid {
    grid-template-columns: 1fr;
  }
}
