/* --------------------------------------------
   Overall styles for Mega Menu layout
----------------------------------------------- */
main {
  font-family: "Inter", "SF Pro Display", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  nav {
    border-block-start: 1px solid light-dark(#e0e0e0, #333);
    margin: 0;
    padding-block-start: 32px;
    padding-block-end: 40px;
  }
}

h3 {
  font-weight: 650;
  font-size: 14px;
  line-height: 1.3;
  letter-spacing: 0.01em;
  margin: 0;
  margin-bottom: 0.75em;
  color: light-dark(#111, #f0f0f0);
}

ul {
  padding: 0;
  margin: 0;
}

li {
  display: block;
  pointer-events: auto;
  margin-bottom: 0.5em;
  a {
    color: light-dark(#3a3a3a, #cccccc);
    font-weight: 350;
    text-decoration: none;
    transition: color 0.15s ease;
    &:hover {
      color: light-dark(#0a8a6e, #2dd4a8);
    }
  }
}

nav section {
  padding-top: 28px;
}

/* Category images */
nav section img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 14px;
  transition: transform 0.2s ease, filter 0.2s ease;
}
nav section:hover img {
  transform: scale(1.03);
  filter: brightness(1.05);
}

/* --------------------------------------------
   Basic layout for Mega Menu
----------------------------------------------- */

main {
  padding-inline: calc(10vw + 1rem);
  padding-block-start: 0;
  background: light-dark(#fff, #222);
}
@media (max-width: 768px) {
  main {
    padding-inline: calc(4vw + 1rem);
  }
  .page-tail {
    padding-inline: calc(4vw + 1rem);
    margin-inline: calc(-1 * (4vw + 1rem));
  }
}
@media (max-width: 500px) {
  main {
    padding-inline: calc(2vw + 0.5rem);
  }
}

/* --------------------------------------------
   Variations on the layout
----------------------------------------------- */

/* ---- Multicolumn layout ---- */
body:has(option[value="one"]:checked) main nav {
  display: block;
  columns: 22ch;
  column-gap: 2.5lh;
  section {
    break-inside: avoid;
    margin-trim: block;
  }
}
@media (max-width: 500px) {
  body:has(option[value="one"]:checked) main nav {
    columns: 2;
  }
}

/* ---- CSS Grid level 1 (without Masonry) ---- */
body:has(option[value="two"]:checked) main nav {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18ch, 1fr));
  grid-template-rows: none;
  column-gap: 2.5lh;
  justify-content: center;
}
@media (max-width: 500px) {
  body:has(option[value="two"]:checked) main nav {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---- Classic Masonry layout ---- */
body:has(option[value="three"]:checked) main nav {
  display: grid-lanes;
  grid-template-columns: repeat(auto-fill, minmax(18ch, 1fr));
  column-gap: 2.5lh;
  justify-content: center;
}
@media (max-width: 500px) {
  body:has(option[value="three"]:checked) main nav {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* --------------------------------------------
   Page tail: cropped product grid above megamenu
----------------------------------------------- */

.page-tail {
  max-height: 120px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-block-end: 1rem;
  padding-inline: calc(10vw + 1rem);
  margin-inline: calc(-1 * (10vw + 1rem));
  background: light-dark(#1b2a4a, #0e1a33);
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
}
@media (max-width: 700px) {
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.product-card {
  opacity: 0.4;
  img {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 8px;
    display: block;
  }
  h4 {
    margin: 0.5em 0 0.15em;
    font-size: 13px;
    font-weight: 600;
    color: #e8e8e8;
  }
  .price {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    color: #8cc5a8;
  }
}

/* --------------------------------------------
   Store footer below the megamenu
----------------------------------------------- */

.store-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25em 1.5em;
  border-block-start: 1px solid light-dark(#e0e0e0, #333);
  padding: 1.25rem 0 1.5rem;
  font-size: 11px;
  color: light-dark(#666, #a6a6a6);
  a {
    color: light-dark(#555, #bcbcbc);
    text-decoration: none;
    &:hover {
      text-decoration: underline;
    }
  }
}

/* --------------------------------------------
   Counters marking items (when enabled)
----------------------------------------------- */

body {
  counter-reset: item-counter 0;
  background: light-dark(#1b2a4a, #0e1a33);
}
nav section {
  position: relative;
  counter-increment: item-counter;
}
body:has(input[type="checkbox"]:checked) {
  nav section::before,
  nav section::after {
    position: absolute;
    top: 0;
    left: 0;
    margin-top: 8px;
    width: 100%;
    height: calc(100% - 8px);
    align-content: center;
    text-align: center;
  }
  nav section::after {
    content: counter(item-counter);
    background: rgba(87, 111, 63, 0.45);
    color: white;
    font-family: var(--font-text);
    font-size: 4em;
    font-weight: bold;
    border-radius: 8px;
  }
  nav section {
    h3, li, img {
      opacity: 0.5;
    }
  }
}
