/* =========================================================
   v2.6.3 — Mobile menu viewport fit + checkout shipping dedupe
   ---------------------------------------------------------
   - Phones show only the "Kõik kategooriad" button by default.
   - Category list opens only after the button tap or admin auto-open.
   - The opened list scrolls inside the sheet; the sheet cannot exceed viewport.
   - Checkout three-column mode hides stale shipping rows after moving delivery.
   ========================================================= */

@media (max-width: 900px) {
  body.vlg-theme.vlg-menu-open,
  body.vlg-menu-open {
    overflow: hidden !important;
    overscroll-behavior: none !important;
  }

  body.vlg-theme .vlg-mobile-backdrop:not([hidden]) {
    position: fixed !important;
    inset: 0 !important;
    display: block !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(7, 18, 36, .44) !important;
    z-index: 100000 !important;
  }

  @supports (height: 100dvh) {
    body.vlg-theme .vlg-mobile-backdrop:not([hidden]) {
      height: 100dvh !important;
    }
  }

  body.vlg-theme .vlg-nav:not(.is-open),
  body.vlg-theme:not(.vlg-menu-open) .vlg-nav {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
    opacity: 0 !important;
    visibility: hidden !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: max(8px, env(safe-area-inset-left)) !important;
    right: max(8px, env(safe-area-inset-right)) !important;
    top: auto !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: calc(100vh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    border: 1px solid rgba(218, 228, 240, .98) !important;
    border-radius: 24px !important;
    background: #fff !important;
    box-shadow: 0 22px 80px rgba(7, 18, 36, .34) !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    pointer-events: auto !important;
    z-index: 100010 !important;
  }

  @supports (height: 100dvh) {
    body.vlg-theme .vlg-nav.is-open,
    body.vlg-theme.vlg-menu-open .vlg-nav.is-open {
      max-height: calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
    }
  }

  body.admin-bar.vlg-theme .vlg-nav.is-open,
  body.admin-bar.vlg-theme.vlg-menu-open .vlg-nav.is-open {
    max-height: calc(100vh - var(--wp-admin--admin-bar--height, 46px) - 16px - env(safe-area-inset-bottom)) !important;
  }

  @supports (height: 100dvh) {
    body.admin-bar.vlg-theme .vlg-nav.is-open,
    body.admin-bar.vlg-theme.vlg-menu-open .vlg-nav.is-open {
      max-height: calc(100dvh - var(--wp-admin--admin-bar--height, 46px) - 16px - env(safe-area-inset-bottom)) !important;
    }
  }

  body.vlg-theme .vlg-nav.is-open::before,
  body.vlg-theme.vlg-menu-open .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 auto minmax(0, 1fr) !important;
    align-items: stretch !important;
    gap: 8px !important;
    width: 100% !important;
    height: auto !important;
    max-height: calc(100vh - 37px - 18px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 12px max(12px, env(safe-area-inset-bottom)) !important;
    overflow: hidden !important;
    overscroll-behavior: contain !important;
  }

  @supports (height: 100dvh) {
    body.vlg-theme .vlg-nav.is-open .vlg-nav-inner,
    body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-nav-inner {
      max-height: calc(100dvh - 37px - 18px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
    }
  }

  body.vlg-theme .vlg-nav.is-open .vlg-mobile-nav-head,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-mobile-nav-head {
    display: flex !important;
    flex: 0 0 auto !important;
    align-items: center !important;
    justify-content: space-between !important;
    min-height: 44px !important;
    max-height: 56px !important;
    padding: 0 2px 6px !important;
    overflow: hidden !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-mobile-nav-head strong,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-mobile-nav-head strong {
    font-size: 0 !important;
    line-height: 1 !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-mobile-nav-head strong::before,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-mobile-nav-head strong::before {
    content: "Tootekategooriad" !important;
    display: inline !important;
    color: #172033 !important;
    font-size: 18px !important;
    font-weight: 900 !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-mobile-nav-head strong::after,
  body.vlg-theme .vlg-nav.is-open .vlg-mobile-nav-head span,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-mobile-nav-head strong::after,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-mobile-nav-head span {
    display: none !important;
    content: "" !important;
  }

  body.vlg-theme.vlg-mobile-categories-only .vlg-nav.is-open .vlg-mobile-quick-links,
  body.vlg-theme.vlg-mobile-hide-quick-links .vlg-nav.is-open .vlg-mobile-quick-links,
  body.vlg-theme.vlg-mobile-categories-only .vlg-nav.is-open .vlg-primary-menu,
  body.vlg-theme.vlg-mobile-hide-primary-menu .vlg-nav.is-open .vlg-primary-menu {
    display: none !important;
  }

  body.vlg-theme.vlg-mobile-show-quick-links .vlg-nav.is-open .vlg-mobile-quick-links {
    display: grid !important;
    max-height: 96px !important;
    overflow: auto !important;
  }

  body.vlg-theme.vlg-mobile-show-primary-menu .vlg-nav.is-open .vlg-primary-menu,
  body.vlg-theme.vlg-mobile-full-menu .vlg-nav.is-open .vlg-primary-menu {
    display: block !important;
    max-height: 32vh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }

  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-columns: 1fr !important;
    grid-template-rows: auto minmax(0, 1fr) !important;
    gap: 8px !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: inherit !important;
    margin: 0 !important;
    overflow: hidden !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !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;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 48px !important;
    height: auto !important;
    margin: 0 !important;
    padding: 12px 15px !important;
    align-items: center !important;
    justify-content: space-between !important;
    border-radius: 17px !important;
    white-space: normal !important;
    pointer-events: auto !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-category-button::after,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-category-button::after {
    content: "⌄" !important;
    display: inline-flex !important;
    flex: 0 0 28px !important;
    align-items: center !important;
    justify-content: center !important;
    width: 28px !important;
    height: 28px !important;
    margin-left: 10px !important;
    border-radius: 999px !important;
    background: rgba(255, 255, 255, .22) !important;
    color: inherit !important;
    transform: rotate(0deg) !important;
    transition: transform .18s ease !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-category-menu.is-open .vlg-category-button::after,
  body.vlg-theme .vlg-nav.is-open .vlg-category-button[aria-expanded="true"]::after,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-category-menu.is-open .vlg-category-button::after,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-category-button[aria-expanded="true"]::after {
    transform: rotate(180deg) !important;
  }

  body.vlg-theme.vlg-mobile-categories-only:not(.vlg-mobile-auto-open-categories) .vlg-nav.is-open .vlg-category-menu:not(.is-open) .vlg-category-dropdown,
  body.vlg-theme.vlg-mobile-categories-only:not(.vlg-mobile-auto-open-categories) .vlg-nav.is-open .vlg-category-button[aria-expanded="false"] + .vlg-category-dropdown,
  body.vlg-theme.vlg-mobile-categories-only:not(.vlg-mobile-auto-open-categories) .vlg-nav.is-open .vlg-category-dropdown[aria-hidden="true"] {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  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-mobile-auto-open-categories .vlg-nav.is-open .vlg-category-dropdown,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-category-menu.is-open .vlg-category-dropdown,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-category-button[aria-expanded="true"] + .vlg-category-dropdown {
    position: static !important;
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: calc(100vh - 154px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !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;
  }

  @supports (height: 100dvh) {
    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-mobile-auto-open-categories .vlg-nav.is-open .vlg-category-dropdown,
    body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-category-menu.is-open .vlg-category-dropdown,
    body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-category-button[aria-expanded="true"] + .vlg-category-dropdown {
      max-height: calc(100dvh - 154px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
    }
  }

  body.vlg-theme .vlg-nav.is-open .vlg-category-menu.is-open .vlg-category-dropdown > ul,
  body.vlg-theme .vlg-nav.is-open .vlg-category-menu.is-open .vlg-category-dropdown > .vlg-cat-dropdown-list,
  body.vlg-theme .vlg-nav.is-open .vlg-category-menu.is-open .vlg-cat-tree,
  body.vlg-theme .vlg-nav.is-open .vlg-category-button[aria-expanded="true"] + .vlg-category-dropdown > ul,
  body.vlg-theme .vlg-nav.is-open .vlg-category-button[aria-expanded="true"] + .vlg-category-dropdown > .vlg-cat-dropdown-list,
  body.vlg-theme .vlg-nav.is-open .vlg-category-button[aria-expanded="true"] + .vlg-category-dropdown .vlg-cat-tree,
  body.vlg-theme.vlg-mobile-auto-open-categories .vlg-nav.is-open .vlg-cat-tree {
    display: grid !important;
    align-content: start !important;
    gap: 7px !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 130px !important;
    max-height: min(52vh, calc(100vh - 164px)) !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;
  }

  @supports (height: 100dvh) {
    body.vlg-theme .vlg-nav.is-open .vlg-category-menu.is-open .vlg-category-dropdown > ul,
    body.vlg-theme .vlg-nav.is-open .vlg-category-menu.is-open .vlg-category-dropdown > .vlg-cat-dropdown-list,
    body.vlg-theme .vlg-nav.is-open .vlg-category-menu.is-open .vlg-cat-tree,
    body.vlg-theme .vlg-nav.is-open .vlg-category-button[aria-expanded="true"] + .vlg-category-dropdown > ul,
    body.vlg-theme .vlg-nav.is-open .vlg-category-button[aria-expanded="true"] + .vlg-category-dropdown > .vlg-cat-dropdown-list,
    body.vlg-theme .vlg-nav.is-open .vlg-category-button[aria-expanded="true"] + .vlg-category-dropdown .vlg-cat-tree,
    body.vlg-theme.vlg-mobile-auto-open-categories .vlg-nav.is-open .vlg-cat-tree {
      max-height: min(52dvh, calc(100dvh - 164px)) !important;
    }
  }

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

  body.vlg-theme .vlg-nav.is-open .vlg-cat-tree .vlg-cat-item:not(.has-children) .vlg-cat-row,
  body.vlg-theme.vlg-menu-open .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,
  body.vlg-theme .vlg-nav.is-open .vlg-category-dropdown a,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-cat-tree .vlg-cat-link,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-category-dropdown a {
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 44px !important;
    padding: 9px 11px 9px 13px !important;
    white-space: normal !important;
    overflow: hidden !important;
    overflow-wrap: anywhere !important;
    word-break: normal !important;
    hyphens: auto !important;
  }

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

@media (max-width: 430px) {
  body.vlg-theme .vlg-nav.is-open,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open {
    left: max(6px, env(safe-area-inset-left)) !important;
    right: max(6px, env(safe-area-inset-right)) !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;
    gap: 7px !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-mobile-nav-head,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-mobile-nav-head {
    min-height: 40px !important;
    max-height: 48px !important;
    padding-bottom: 4px !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-mobile-nav-head strong::before,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-mobile-nav-head strong::before {
    font-size: 16px !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-category-button,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-category-button {
    min-height: 46px !important;
    padding: 11px 13px !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-category-menu.is-open .vlg-cat-tree,
  body.vlg-theme .vlg-nav.is-open .vlg-category-button[aria-expanded="true"] + .vlg-category-dropdown .vlg-cat-tree,
  body.vlg-theme.vlg-mobile-auto-open-categories .vlg-nav.is-open .vlg-cat-tree {
    max-height: min(50dvh, calc(100dvh - 150px)) !important;
    min-height: 120px !important;
  }
}

/* Checkout: when the three-column organiser has moved shipping into the
   delivery card, never show the original/stale order-review shipping row too. */
body.woocommerce-checkout form.checkout.fs-checkout-is-three-column #order_review tr.fs-shipping-row-moved,
body.woocommerce-checkout form.checkout.fs-checkout-is-three-column #order_review tr.woocommerce-shipping-totals.fs-shipping-row-moved,
body.woocommerce-checkout form.checkout.fs-checkout-is-three-column #order_review tr.shipping.fs-shipping-row-moved {
  display: none !important;
}

body.woocommerce-checkout form.checkout.fs-checkout-is-three-column .fs-shipping-methods-wrap > ul#shipping_method:not(:last-of-type),
body.woocommerce-checkout form.checkout.fs-checkout-is-three-column .fs-shipping-methods-wrap > .fs-shipping-static-note:not(:last-child) {
  display: none !important;
}

@media (max-width: 782px) {
  body.woocommerce-checkout form.checkout.fs-checkout-is-three-column .fs-shipping-column,
  body.woocommerce-checkout form.checkout.fs-checkout-is-three-column .fs-payment-column,
  body.woocommerce-checkout form.checkout.fs-checkout-is-three-column .fs-billing-column {
    min-width: 0 !important;
    max-width: 100% !important;
  }
}
