/* ============================================================
   Category menu (#792 §7): the v13 product page's single
   <nav id="category-menu" class="cat-menu">.
   One DOM for both layouts:
   - no JS: a block of L1 groups with their L2 links after the page
     (the "Alla kategorier" link's target);
   - JS (.cat-menu--js): hidden until opened; then a column of L1s
     with the open L1's L2/L3 beside it (desktop) or under it (mobile).
   ============================================================ */

.cat-menu {
  font-family: 'Inter', -apple-system, sans-serif;
  color: #1a1a1a;
  background-color: #f5f5f8;
  padding: 32px 50px;
}
.cat-menu *,
.cat-menu *::before,
.cat-menu *::after {
  box-sizing: border-box;
}
.cat-menu ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.cat-menu a {
  color: inherit;
  text-decoration: none;
}
.cat-menu a:hover {
  text-decoration: underline;
}
.cat-menu button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.cat-menu a:focus-visible,
.cat-menu button:focus-visible {
  outline: 2px solid #1a1a1a;
  outline-offset: 2px;
}

.cat-menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.cat-menu-title {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
}
.cat-menu-close {
  display: none;
  font-size: 28px;
  line-height: 1;
  padding: 4px 8px;
}

/* ---- no JS: every L1 with its L2 links, in a grid ---- */
.cat-menu-l1 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 24px 32px;
}
.cat-menu-l1-link {
  font-weight: 700;
  font-size: 16px;
}
.cat-menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.cat-menu-expand {
  display: none;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  position: relative;
}
.cat-menu-expand::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translate(-50%, -70%) rotate(45deg);
}
.cat-menu-expand[aria-expanded="true"]::before {
  transform: translate(-50%, -30%) rotate(-135deg);
}
.cat-menu-l2 {
  margin-top: 8px;
}
.cat-menu-l2-link {
  display: block;
  padding: 3px 0;
  font-size: 14px;
}

/* L3 (only ever inserted by the script) */
.cat-menu-l3 {
  margin: 6px 0 4px;
}
.cat-menu-l3 a {
  display: block;
  padding: 2px 0;
  font-size: 14px;
  color: #333;
}
.cat-menu-l3-item[hidden] {
  display: none;
}
.cat-menu-more {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
}

/* ---- with JS ---- */
.cat-menu--js {
  display: none;
}
.cat-menu--js.is-open {
  display: block;
}
.cat-menu--js .cat-menu-close,
.cat-menu--js .cat-menu-expand {
  display: inline-block;
}
.cat-menu--js .cat-menu-l1 {
  display: block;
}
.cat-menu--js .cat-menu-l2 {
  display: none;
}
.cat-menu--js .cat-menu-l2.is-open {
  display: block;
}
.cat-menu--js .cat-menu-l1-item {
  border-bottom: 1px solid #e0e0e0;
}
.cat-menu--js .cat-menu-row {
  padding: 10px 0;
}

/* Desktop: the L1 column, the open L1's subcategories beside it. */
@media only screen and (min-width: 993px) {
  .cat-menu--js .cat-menu-l1 {
    position: relative;
  }
  .cat-menu--js .cat-menu-l1-item {
    width: 300px;
  }
  .cat-menu--js .cat-menu-l1-item.active .cat-menu-row {
    background-color: #fff;
  }
  .cat-menu--js .cat-menu-row {
    padding: 8px 4px 8px 12px;
  }
  .cat-menu--js .cat-menu-l2.is-open {
    position: absolute;
    top: 0;
    left: 332px;
    right: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 24px;
    align-items: start;
  }
  .cat-menu--js .cat-menu-l2.is-open .cat-menu-l2-item {
    background-color: #fff;
    border-radius: 16px;
    padding: 20px 24px;
  }
  .cat-menu--js .cat-menu-l2.is-open .cat-menu-l2-link {
    font-size: 16px;
    font-weight: 700;
  }
}

/* Mobile: an accordion. */
@media only screen and (max-width: 992px) {
  .cat-menu {
    padding: 24px 20px;
  }
  .cat-menu--js .cat-menu-l2.is-open {
    padding: 0 0 12px 12px;
  }
  .cat-menu--js .cat-menu-l2-link {
    font-weight: 600;
    padding: 6px 0;
  }
  .cat-menu--js .cat-menu-l3 {
    padding-left: 12px;
  }
}
