/* v5.1.23 — final mobile hotfix: product image, category drawer click behavior and text fit */
@media (max-width: 782px) {
  html body.vlg-theme.single-product,
  html body.vlg-theme.single-product .site,
  html body.vlg-theme.single-product #page {
    overflow-x: hidden !important;
  }

  html body.vlg-theme.single-product .vlg-single-product-page {
    padding-left: 10px !important;
    padding-right: 10px !important;
    padding-bottom: calc(var(--vlg-mobile-appbar-h, 76px) + 32px + env(safe-area-inset-bottom)) !important;
  }

  html body.vlg-theme.single-product .vlg-product-main-grid,
  html body.vlg-theme.single-product .vlg-product-detail .vlg-product-main-grid {
    gap: 12px !important;
  }

  /* Fix giant blank gallery area on mobile. */
  html body.vlg-theme.single-product .vlg-product-gallery-card {
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    padding: 10px !important;
    margin: 0 0 12px !important;
    border-radius: 22px !important;
    overflow: visible !important;
  }

  html body.vlg-theme.single-product .vlg-product-gallery-media,
  html body.vlg-theme.single-product div.product div.images,
  html body.vlg-theme.single-product div.product div.woocommerce-product-gallery,
  html body.vlg-theme.single-product .woocommerce-product-gallery,
  html body.vlg-theme.single-product .flex-viewport,
  html body.vlg-theme.single-product .woocommerce-product-gallery__wrapper,
  html body.vlg-theme.single-product .woocommerce-product-gallery__image {
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    margin: 0 !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  html body.vlg-theme.single-product .flex-viewport {
    overflow: hidden !important;
  }

  html body.vlg-theme.single-product .woocommerce-product-gallery__wrapper {
    display: block !important;
  }

  html body.vlg-theme.single-product .woocommerce-product-gallery__image {
    width: 100% !important;
    float: none !important;
    text-align: center !important;
  }

  html body.vlg-theme.single-product .woocommerce-product-gallery__image:not(:first-child):not(.flex-active-slide) {
    display: none !important;
  }

  html body.vlg-theme.single-product .woocommerce-product-gallery__image a {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 220px !important;
    height: auto !important;
  }

  html body.vlg-theme.single-product .woocommerce-product-gallery__image img,
  html body.vlg-theme.single-product .woocommerce-product-gallery img.wp-post-image,
  html body.vlg-theme.single-product .vlg-product-gallery-card img {
    display: block !important;
    width: auto !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: min(44vh, 340px) !important;
    object-fit: contain !important;
    opacity: 1 !important;
    visibility: visible !important;
    margin: 0 auto !important;
    padding: 4px !important;
  }

  html body.vlg-theme.single-product .flex-control-thumbs {
    display: flex !important;
    position: static !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    gap: 8px !important;
    margin: 10px 0 0 !important;
    padding: 2px 2px 4px !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  html body.vlg-theme.single-product .flex-control-thumbs li {
    flex: 0 0 64px !important;
    width: 64px !important;
    height: 64px !important;
    margin: 0 !important;
    border-radius: 14px !important;
  }

  html body.vlg-theme.single-product .flex-control-thumbs img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    padding: 7px !important;
  }

  .vlg-mobile-gallery-zoom {
    position: absolute;
    right: 14px;
    top: 14px;
    z-index: 20;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid rgba(15, 23, 42, .12);
    border-radius: 999px;
    background: rgba(255,255,255,.94);
    color: #0f172a;
    font-weight: 900;
    font-size: 12px;
    box-shadow: 0 10px 24px rgba(15,23,42,.14);
  }

  html body.vlg-theme.single-product .vlg-product-summary-card,
  html body.vlg-theme.single-product div.product .summary {
    max-width: 100% !important;
    overflow: hidden !important;
    padding: 16px !important;
    border-radius: 22px !important;
  }

  html body.vlg-theme.single-product .vlg-pill {
    max-width: 100% !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: normal !important;
    line-height: 1.2 !important;
  }

  html body.vlg-theme.single-product .product_title,
  html body.vlg-theme.single-product div.product .product_title {
    max-width: 100% !important;
    font-size: clamp(24px, 6.1vw, 32px) !important;
    line-height: 1.12 !important;
    letter-spacing: -.035em !important;
    white-space: normal !important;
    overflow: visible !important;
    overflow-wrap: anywhere !important;
    word-break: normal !important;
  }

  /* User requested: add-to-cart must not travel with scroll and must not cover content/appbar. */
  html body.vlg-theme.single-product div.product form.cart,
  html body.vlg-theme.single-product form.cart,
  html body.vlg-theme.single-product .vlg-product-buybox form.cart {
    position: relative !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    top: auto !important;
    z-index: 2 !important;
    display: grid !important;
    grid-template-columns: 86px minmax(0, 1fr) !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 14px 0 0 !important;
    padding: 9px !important;
    border-radius: 20px !important;
    box-shadow: 0 12px 28px rgba(15, 23, 42, .12) !important;
    backdrop-filter: none !important;
  }

  html body.vlg-theme.single-product form.cart .single_add_to_cart_button {
    min-width: 0 !important;
    white-space: normal !important;
    line-height: 1.12 !important;
    font-size: 15px !important;
  }
}

@media (max-width: 390px) {
  html body.vlg-theme.single-product .product_title,
  html body.vlg-theme.single-product div.product .product_title {
    font-size: clamp(22px, 5.7vw, 28px) !important;
  }
  html body.vlg-theme.single-product div.product form.cart,
  html body.vlg-theme.single-product form.cart {
    grid-template-columns: 76px minmax(0, 1fr) !important;
  }
}

@media (max-width: 900px) {
  /* Mobile category drawer: click-controlled, readable long names. */
  html body.vlg-theme .vlg-nav.is-open .vlg-category-menu,
  html body.vlg-theme .vlg-nav.is-open .vlg-category-dropdown,
  html body.vlg-theme .vlg-nav.is-open .vlg-cat-list,
  html body.vlg-theme .vlg-nav.is-open .vlg-cat-submenu {
    touch-action: pan-y !important;
    pointer-events: auto !important;
  }

  html body.vlg-theme .vlg-nav.is-open .vlg-category-dropdown.is-open,
  html body.vlg-theme .vlg-nav.is-open .vlg-category-menu.is-open > .vlg-category-dropdown {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    max-height: calc(100dvh - 230px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
  }

  html body.vlg-theme .vlg-nav.is-open .vlg-cat-row {
    display: grid !important;
    grid-template-columns: 30px minmax(0, 1fr) 44px !important;
    align-items: center !important;
    gap: 8px !important;
    min-height: 58px !important;
    height: auto !important;
    padding: 9px 10px !important;
  }

  html body.vlg-theme .vlg-nav.is-open .vlg-cat-link,
  html body.vlg-theme .vlg-nav.is-open .vlg-cat-name,
  html body.vlg-theme .vlg-nav.is-open .vlg-cat-title,
  html body.vlg-theme .vlg-nav.is-open .vlg-cat-row a {
    min-width: 0 !important;
    max-width: 100% !important;
    width: auto !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    overflow-wrap: anywhere !important;
    word-break: normal !important;
    line-height: 1.16 !important;
    font-size: clamp(13px, 3.3vw, 15px) !important;
    text-align: left !important;
  }

  html body.vlg-theme .vlg-nav.is-open .vlg-cat-count,
  html body.vlg-theme .vlg-nav.is-open .count {
    min-width: 34px !important;
    width: auto !important;
    max-width: 46px !important;
    padding: 0 6px !important;
    justify-self: end !important;
  }

  html body.vlg-theme .vlg-nav.is-open .vlg-cat-submenu {
    margin: 6px 0 8px 10px !important;
    padding-left: 8px !important;
  }

  html body.vlg-theme .vlg-nav.is-open .vlg-cat-submenu .vlg-cat-row {
    grid-template-columns: 22px minmax(0, 1fr) 38px !important;
    min-height: 52px !important;
  }
}
