/*
 * The panel of the mega menu (module mega-menu): the product categories as columns, each category with sub-categories a heading
 * with a short accent and its children under it. The categories come from the store (the block lists them, in the language of the
 * page, in the order of the catalog), so this file only sets the layout. Colours, spacing and shadow are the tokens of
 * theme.json, so a preset or the brand colours follow.
 */

.wp-block-navigation__submenu-container .wp-block-mega-menu .wc-block-product-categories-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* a category: the heading of its column */
.wp-block-navigation__submenu-container
  .wp-block-mega-menu
  .wc-block-product-categories-list--depth-0
  > .wc-block-product-categories-list-item {
  break-inside: avoid;
  margin: 0 0 var(--wp--preset--spacing--md, 1.5rem);
}

.wp-block-navigation__submenu-container
  .wp-block-mega-menu
  .wc-block-product-categories-list--depth-0
  > .wc-block-product-categories-list-item
  > a {
  color: var(--wp--preset--color--foreground, #1f2a24);
  display: inline-block;
  font-family: var(--wp--preset--font-family--heading, Georgia, serif);
  font-size: var(--wp--preset--font-size--md, 1.0625rem);
  font-weight: 600;
  line-height: 1.3;
  padding: 0;
  text-decoration: none;
}

/* the short accent under a heading that has children under it */
.wp-block-navigation__submenu-container
  .wp-block-mega-menu
  .wc-block-product-categories-list--depth-0
  > .wc-block-product-categories-list-item:has(> ul)
  > a::after {
  background: var(--wp--preset--color--primary, #2f5d46);
  content: '';
  display: block;
  height: 2px;
  margin: var(--wp--preset--spacing--2-xs, 0.25rem) 0 var(--wp--preset--spacing--xs, 0.5rem);
  width: 1.75rem;
}

/* the children: quiet, and they move a little towards the hand */
.wp-block-navigation__submenu-container
  .wp-block-mega-menu
  .wc-block-product-categories-list--depth-1 {
  border: 0;
  margin: 0;
  padding: 0;
}

.wp-block-navigation__submenu-container
  .wp-block-mega-menu
  .wc-block-product-categories-list--depth-1
  > .wc-block-product-categories-list-item
  > a {
  color: var(--wp--preset--color--muted, #5a645e);
  display: block;
  font-size: var(--wp--preset--font-size--sm, 0.9375rem);
  line-height: 1.9;
  padding: 0;
  text-decoration: none;
  transition:
    color 0.15s,
    padding-left 0.15s;
}

.wp-block-navigation__submenu-container
  .wp-block-mega-menu
  .wc-block-product-categories-list-item
  > a:hover,
.wp-block-navigation__submenu-container
  .wp-block-mega-menu
  .wc-block-product-categories-list-item
  > a:focus-visible {
  color: var(--wp--preset--color--primary, #2f5d46);
}

.wp-block-navigation__submenu-container
  .wp-block-mega-menu
  .wc-block-product-categories-list--depth-1
  > .wc-block-product-categories-list-item
  > a:hover {
  padding-left: 0.3rem;
}

@media (prefers-reduced-motion: reduce) {
  .wp-block-navigation__submenu-container
    .wp-block-mega-menu
    .wc-block-product-categories-list--depth-1
    > .wc-block-product-categories-list-item
    > a {
    transition: none;
  }
}

@media (min-width: 782px) {
  /* a surface under the header that spans it, with a soft shadow below and the categories in as many columns as fit */
  .wp-block-navigation__submenu-container:has(> .wp-block-mega-menu) {
    background: var(--wp--preset--color--base, #fbf9f4);
    border: 0;
    border-top: 1px solid var(--wp--preset--color--outline, #d8d2c2);
    box-shadow: 0 22px 32px -22px rgb(0 0 0 / 28%);
    padding: var(--wp--preset--spacing--lg, 3rem) var(--wp--preset--spacing--md, 1.5rem)
      var(--wp--preset--spacing--md, 1.5rem);
  }

  .wp-block-navigation__submenu-container
    .wp-block-mega-menu
    .wc-block-product-categories-list--depth-0 {
    column-gap: var(--wp--preset--spacing--lg, 3rem);
    column-width: 13rem;
    margin: 0 auto;
    max-width: 62rem;
  }
}

@media (max-width: 781px) {
  /* in the phone menu: one column, the children indented under their heading */
  .wp-block-navigation__submenu-container
    .wp-block-mega-menu
    .wc-block-product-categories-list--depth-1 {
    border-left: 2px solid var(--wp--preset--color--outline, #d8d2c2);
    margin-left: var(--wp--preset--spacing--2-xs, 0.25rem);
    padding-left: var(--wp--preset--spacing--xs, 0.5rem);
  }
}
