/* =========================================================
   v2.5.3 — Click-only category menu + mobile product categories
   ---------------------------------------------------------
   - Parent categories no longer open on hover/focus. Subcategories open only
     after the customer taps/clicks the arrow button.
   - Mobile drawer shows product categories only, not normal page navigation.
   - Mobile drawer is fitted inside the viewport so it cannot disappear above
     the screen or overflow behind the browser chrome.
   ========================================================= */

/* Desktop/tablet: disable every old hover/focus rule that opened children. */
@media (min-width: 783px) {
  body.vlg-theme .vlg-cat-submenu-mode-accordion .vlg-cat-item.has-children:hover > .vlg-cat-submenu,
  body.vlg-theme .vlg-cat-submenu-mode-accordion .vlg-cat-item.has-children:focus-within > .vlg-cat-submenu {
    display: none !important;
    position: static !important;
    left: auto !important;
    top: auto !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: 100% !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  body.vlg-theme .vlg-cat-submenu-mode-accordion .vlg-cat-item.has-children:hover > .vlg-cat-row .vlg-cat-link,
  body.vlg-theme .vlg-cat-submenu-mode-accordion .vlg-cat-item.has-children:focus-within > .vlg-cat-row .vlg-cat-link {
    background: transparent !important;
    color: #172033 !important;
  }

  body.vlg-theme .vlg-cat-item:hover > .vlg-cat-row .vlg-cat-subtoggle span {
    transform: none !important;
  }

  body.vlg-theme .vlg-cat-item.is-sub-open > .vlg-cat-row .vlg-cat-subtoggle span {
    transform: rotate(180deg) !important;
  }

  body.vlg-theme .vlg-cat-submenu-mode-accordion .vlg-cat-item.is-sub-open > .vlg-cat-submenu,
  body.vlg-theme .vlg-cat-item.is-sub-open > .vlg-cat-submenu {
    position: static !important;
    display: grid !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: 100% !important;
    max-height: none !important;
    gap: 5px !important;
    margin: 5px 0 7px 12px !important;
    padding: 0 0 0 10px !important;
    border: 0 !important;
    border-left: 2px solid rgba(242, 138, 0, .20) !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    overflow: visible !important;
  }
}

/* Mobile: drawer as a real viewport-fitted panel. */
@media (max-width: 900px) {
  body.vlg-theme.vlg-menu-open,
  body.vlg-menu-open {
    overflow: hidden !important;
  }

  body.vlg-theme .vlg-mobile-backdrop:not([hidden]) {
    position: fixed !important;
    inset: 0 !important;
    z-index: 100000 !important;
  }

  body.vlg-theme .vlg-nav:not(.is-open) {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  body.vlg-theme .vlg-nav.is-open,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open {
    position: fixed !important;
    left: 8px !important;
    right: 8px !important;
    top: max(8px, env(safe-area-inset-top)) !important;
    bottom: max(8px, env(safe-area-inset-bottom)) !important;
    display: block !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    border: 1px solid rgba(218, 228, 240, .98) !important;
    border-radius: 24px !important;
    background: rgba(255,255,255,.99) !important;
    box-shadow: 0 22px 80px rgba(7, 18, 36, .34) !important;
    transform: none !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 100010 !important;
  }

  body.admin-bar.vlg-theme .vlg-nav.is-open,
  body.admin-bar.vlg-theme.vlg-menu-open .vlg-nav.is-open {
    top: calc(var(--wp-admin--admin-bar--height, 46px) + 8px) !important;
  }

  body.vlg-theme .vlg-nav.is-open::before {
    content: "" !important;
    display: block !important;
    width: 46px !important;
    height: 5px !important;
    margin: 10px auto 6px !important;
    border-radius: 999px !important;
    background: #d7e1ed !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-nav-inner,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-nav-inner {
    display: grid !important;
    grid-template-columns: 1fr !important;
    grid-template-rows: auto minmax(0, 1fr) !important;
    align-items: stretch !important;
    gap: 10px !important;
    width: 100% !important;
    height: calc(100% - 21px) !important;
    max-height: none !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 12px 12px !important;
    overflow: hidden !important;
    overscroll-behavior: contain !important;
  }

  /* Mobile menu should be product-category only. */
  body.vlg-theme .vlg-nav.is-open .vlg-mobile-quick-links,
  body.vlg-theme .vlg-nav.is-open .vlg-primary-menu {
    display: none !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-mobile-nav-head {
    display: flex !important;
    flex: 0 0 auto !important;
    min-height: 50px !important;
    padding: 4px 2px 8px !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-mobile-nav-head strong::after {
    content: " — tootekategooriad";
    color: #64748b;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-category-menu,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-category-menu {
    display: grid !important;
    grid-template-rows: auto minmax(0, 1fr) !important;
    gap: 8px !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: hidden !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-category-button,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-category-button {
    display: flex !important;
    flex: 0 0 auto !important;
    width: 100% !important;
    min-height: 50px !important;
    height: auto !important;
    margin: 0 !important;
    pointer-events: auto !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-category-dropdown,
  body.vlg-theme .vlg-nav.is-open .vlg-category-menu .vlg-category-dropdown,
  body.vlg-theme .vlg-nav.is-open .vlg-category-menu.is-open .vlg-category-dropdown,
  body.vlg-theme .vlg-nav.is-open .vlg-category-button[aria-expanded="true"] + .vlg-category-dropdown,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-category-dropdown {
    position: static !important;
    display: block !important;
    grid-template-rows: none !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    pointer-events: auto !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-category-dropdown > ul,
  body.vlg-theme .vlg-nav.is-open .vlg-category-dropdown > .vlg-cat-dropdown-list,
  body.vlg-theme .vlg-nav.is-open .vlg-cat-tree {
    display: grid !important;
    align-content: start !important;
    gap: 7px !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 8px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    border: 1px solid #dbe5f1 !important;
    border-radius: 18px !important;
    background: #f8fafc !important;
    list-style: none !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-cat-tree .vlg-cat-row {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 44px !important;
    align-items: center !important;
    gap: 8px !important;
    min-width: 0 !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-cat-tree .vlg-cat-item:not(.has-children) .vlg-cat-row {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-cat-tree .vlg-cat-link {
    min-height: 48px !important;
    min-width: 0 !important;
    max-width: 100% !important;
    padding: 10px 12px 10px 14px !important;
    border: 1px solid #e4edf6 !important;
    border-radius: 15px !important;
    background: #fff !important;
    color: #172033 !important;
    overflow: hidden !important;
    text-decoration: none !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-cat-tree .vlg-cat-title {
    color: inherit !important;
    white-space: normal !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
    hyphens: auto !important;
    line-height: 1.18 !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-cat-tree .vlg-cat-count {
    flex: 0 0 auto !important;
    min-width: 28px !important;
    text-align: right !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-cat-subtoggle {
    width: 42px !important;
    min-width: 42px !important;
    height: 42px !important;
    border-radius: 14px !important;
  }

  /* Mobile subcategories: never on hover; only .is-sub-open from JS click. */
  body.vlg-theme .vlg-nav.is-open .vlg-cat-submenu,
  body.vlg-theme .vlg-nav.is-open .vlg-cat-submenu-mode-inline .vlg-cat-submenu,
  body.vlg-theme .vlg-nav.is-open .vlg-cat-submenu-mode-accordion .vlg-cat-item.has-children:hover > .vlg-cat-submenu,
  body.vlg-theme .vlg-nav.is-open .vlg-cat-submenu-mode-accordion .vlg-cat-item.has-children:focus-within > .vlg-cat-submenu {
    display: none !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-cat-item.is-sub-open > .vlg-cat-submenu {
    position: static !important;
    display: grid !important;
    gap: 6px !important;
    width: auto !important;
    max-width: 100% !important;
    max-height: none !important;
    margin: 7px 0 7px 14px !important;
    padding: 0 0 0 10px !important;
    border: 0 !important;
    border-left: 2px solid rgba(242, 138, 0, .24) !important;
    background: transparent !important;
    box-shadow: none !important;
  }
}

@media (max-width: 430px) {
  body.vlg-theme .vlg-nav.is-open,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open {
    left: 6px !important;
    right: 6px !important;
    top: max(6px, env(safe-area-inset-top)) !important;
    bottom: max(6px, env(safe-area-inset-bottom)) !important;
    border-radius: 22px !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-nav-inner,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-nav-inner {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }
}
