/* Mobile language selector beside the existing menu button. Desktop nav unchanged. */
.mobile-header-actions {
  display: none;
}

@media (max-width: 820px) {
  .mobile-header-actions {
    position: relative;
    z-index: 1003;
    display: flex;
    align-items: center;
    gap: 20px;
  }

  .mobile-language-switcher {
    position: relative;
    color: var(--yellow);
  }

  .mobile-language-switcher > summary {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 49px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--yellow);
    font-family: inherit;
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
    text-decoration: underline;
    text-underline-offset: 4px;
    list-style: none;
    cursor: pointer;
  }
  .mobile-language-switcher > summary::-webkit-details-marker {
    display: none;
  }
  .mobile-language-switcher > summary:focus-visible {
    outline: 2px solid var(--yellow);
    outline-offset: 5px;
  }

  .mobile-language-switcher__list {
    position: absolute;
    top: calc(100% + 5px);
    right: -6px;
    z-index: 1004;
    display: none;
    min-width: 82px;
    padding: 7px;
    border: 1px solid rgba(255, 204, 0, 0.6);
    border-radius: 10px;
    background: #170804;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
  }
  .mobile-language-switcher[open] .mobile-language-switcher__list {
    display: grid;
    gap: 3px;
  }
  .mobile-language-switcher__list a {
    display: block;
    padding: 9px 13px;
    border-radius: 7px;
    color: var(--yellow);
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
  }
  .mobile-language-switcher__list a:hover,
  .mobile-language-switcher__list a:focus-visible,
  .mobile-language-switcher__list a.is-active {
    background: var(--yellow);
    color: var(--brown);
  }

  /* This same selector is now in the header, not duplicated inside the opened mobile menu. */
  .main-nav .nav-item--language {
    display: none;
  }
}

/* Mobile menu: make submenu rows fully tappable, keeping desktop layout unchanged. */
.nav-item--mobile-catalogs,
.nav-item--mobile-brands {
  display: none;
}

@media (max-width: 820px) {
  .main-nav .nav-item--mobile-brands {
    display: block;
  }

  .main-nav .mega-menu__grid a {
    display: flex;
    align-items: center;
    box-sizing: border-box;
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    font-size: 18px;
    line-height: 1.25;
    white-space: normal;
  }

  .main-nav .mega-menu__grid li {
    margin-bottom: 0;
  }

  .main-nav .mega-menu__grid a:focus-visible {
    outline: 2px solid var(--yellow);
    outline-offset: -2px;
  }

  /* Three existing admin-managed PDF groups, displayed only in mobile navigation. */
  .main-nav .nav-item--mobile-catalogs {
    display: block;
    margin-top: 8px;
    padding: 0 14px;
  }

  .mobile-catalog-menu__group {
    margin: 0 0 22px;
  }

  .mobile-catalog-menu__heading {
    margin: 0 0 10px;
    color: var(--yellow);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    text-transform: uppercase;
    white-space: normal;
  }

  .mobile-catalog-menu__files {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 10px;
  }

  .mobile-catalog-menu__file {
    display: flex;
    flex: 0 0 56px;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    box-sizing: border-box;
    min-height: 66px;
    padding: 5px 2px;
    gap: 5px;
    color: var(--yellow);
    font-size: 12px;
    line-height: 1.15;
    text-align: center;
    text-decoration: none;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .mobile-catalog-menu__file img {
    width: 35px;
    height: 42px;
    object-fit: contain;
  }

  .mobile-catalog-menu__file:focus-visible {
    outline: 2px solid var(--yellow);
    outline-offset: 1px;
  }
}

/* When the mobile menu is open, scroll the header and menu as one surface.
   With the menu closed, the original fixed header remains unchanged. */
@media (max-width: 820px) {
  body.menu-open .site-header.is-open,
  body.menu-open .site-header.is-open:not(.is-scrolled) {
    height: 100svh;
    height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    /* Opaque fallback on the scroll viewport itself. The decorative image is
       painted on the scrolling content below to avoid repaint gaps on mobile. */
    background: #170804;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  body.menu-open .site-header.is-open .header-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: calc(var(--header-height) - 14px) auto;
    align-items: start;
    justify-content: normal;
    height: auto;
    min-height: 100%;
    padding: 14px 18px 0;
    background-color: #170804;
    background-image:
      linear-gradient(rgba(7, 1, 0, 0.68), rgba(7, 1, 0, 0.68)),
      url("../images/hero-chocolate.webp");
    background-position: center top;
    background-size: cover;
    background-repeat: no-repeat;
  }

  body.menu-open .site-header.is-open .brand--mobile {
    grid-column: 1;
    grid-row: 1;
  }

  body.menu-open .site-header.is-open .mobile-header-actions {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  body.menu-open .site-header.is-open .main-nav {
    position: static;
    grid-column: 1 / -1;
    grid-row: 2;
    width: calc(100% + 36px);
    height: auto;
    max-height: none;
    margin-inline: -18px;
    overflow: visible;
    background: transparent;
  }
}
