/* Treasure v1.10 mobile-only product and header layout.
   No desktop declarations. Do not touch order/cart/variation data. */
@media (max-width: 767px) {
  /* Blocksy mobile header: menu LEFT / brand CENTER / native tools RIGHT. */
  #header [data-device="mobile"] [data-row="middle"] .ct-container,
  #header [data-device="mobile"] [data-row="middle"] > .ct-container {
    position: relative !important;
    min-height: 62px;
  }
  #header [data-device="mobile"] [data-row="middle"] [data-column="start"],
  #header [data-device="mobile"] [data-row="middle"] [data-column="end"] {
    position: static !important;
  }
  #header [data-device="mobile"] [data-row="middle"] [data-id="logo"] {
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 5;
    width: auto !important;
    max-width: min(36vw, 140px) !important;
    margin: 0 !important;
    text-align: center !important;
  }
  #header [data-device="mobile"] [data-row="middle"] [data-id="logo"] img,
  #header [data-device="mobile"] [data-row="middle"] [data-id="logo"] .site-title {
    max-width: 100% !important;
    height: auto !important;
  }
  #header [data-device="mobile"] [data-row="middle"] [data-id="trigger"] {
    position: absolute !important;
    left: 13px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 6;
    margin: 0 !important;
  }
  #header [data-device="mobile"] [data-row="middle"] [data-column="end"] {
    margin-left: auto !important;
    justify-content: flex-end !important;
  }
  #header [data-device="mobile"] [data-row="middle"] [data-column="end"] > * {
    flex-shrink: 0;
  }

  /* On product pages, show bags immediately below the mobile header. */
  body.single-product .ct-breadcrumbs,
  body.single-product .ct-breadcrumbs-container,
  body.single-product nav.woocommerce-breadcrumb,
  body.single-product .woocommerce-breadcrumb,
  body.single-product .woocommerce-breadcrumbs,
  body.single-product .woocommerce-breadcrumb-wrapper,
  body.single-product .breadcrumb,
  body.single-product .breadcrumbs,
  body.single-product [data-type="breadcrumbs"] { display: none !important; }

  body.single-product #main,
  body.single-product #main .site-main,
  body.single-product #main > .ct-container,
  body.single-product #main > .ct-container-full,
  body.single-product #main > .ct-container-narrow,
  body.single-product #main .ct-product-content-block,
  body.single-product .product-entry-wrapper {
    padding-top: 0 !important;
    margin-top: 0 !important;
  }
  body.single-product .product-entry-wrapper { row-gap: 0 !important; }
  body.single-product .woocommerce-notices-wrapper:empty {display:none!important;}
  body.single-product .td-native-gallery {
    margin: 0 auto 7px !important;
    padding: 0 !important;
    width: 100% !important;
  }
  /* Preserve full, uncropped bag photos; remove the tall 4:5 letterbox. */
  body.single-product .td-native-gallery-track {
    border-radius: 12px !important;
    margin: 0 !important;
  }
  body.single-product .td-native-gallery-slide {
    aspect-ratio: auto !important;
    height: min(85vw, 42svh, 350px) !important;
    min-height: 218px !important;
    border-radius: 12px !important;
    background: #f8f9fb !important;
  }
  body.single-product .td-native-gallery-slide img {
    object-fit: contain !important;
    width:100%!important;
    height:100%!important;
    border-radius: 12px !important;
  }
  body.single-product .td-native-gallery-thumbs {
    gap: 7px !important;
    padding: 7px 2px 0 !important;
    margin: 0 !important;
  }
  body.single-product .td-native-gallery-thumb {
    flex: 0 0 54px !important;
    width: 54px !important;
    min-width: 54px !important;
    height: 56px !important;
    border-radius: 9px !important;
  }
  body.single-product .td-native-gallery-counter {
    margin-top: 1px !important;
    font-size: 10px !important;
    line-height: 14px !important;
  }
  body.single-product .summary.entry-summary,
  body.single-product .entry-summary {
    padding-top: 0 !important;
    margin-top: 0 !important;
  }

  /* Display PROXIES for the working product swatches above the product title.
     Source controls, form selects and variation handlers remain untouched. */
  body.single-product .td-layout-choices {
    display: block;
    margin: 4px 0 13px !important;
    padding: 0 0 10px;
    border-bottom: 1px solid #e8edf2;
    font-family: 'Manrope', system-ui, sans-serif;
  }
  body.single-product .td-layout-choices-header {
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:8px;
    margin-bottom:7px;
    font-size:12px;
    font-weight:750;
    color:#263850;
  }
  body.single-product .td-layout-choices-current {
    font-weight:550;
    font-size:11px;
    color:#687b8e;
    text-align:right;
  }
  body.single-product .td-layout-choice-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
  }
  body.single-product button.td-layout-option {
    appearance: none !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 6px !important;
    min-height: 38px !important;
    max-width: 100% !important;
    padding: 3px 9px 3px 4px !important;
    margin: 0 !important;
    border: 1px solid #d3dfeb !important;
    border-radius: 11px !important;
    background: #fff !important;
    box-shadow: none !important;
    color: #1c314a !important;
    font: 650 11px/1.3 'Manrope',system-ui,sans-serif !important;
    text-align: left;
    text-transform: none !important;
    letter-spacing: 0 !important;
    cursor: pointer;
  }
  body.single-product button.td-layout-option[aria-pressed="true"] {
    background: #edf4ff !important;
    border: 2px solid #2469e8 !important;
    box-shadow: 0 0 0 2px rgba(36,105,232,.13) !important;
    padding: 2px 8px 2px 3px !important;
  }
  body.single-product button.td-layout-option:focus-visible {
    outline: 2px solid #2469e8 !important;
    outline-offset: 3px;
  }
  body.single-product button.td-layout-option:disabled { opacity:.48!important; cursor:not-allowed!important; }
  body.single-product .td-layout-option-photo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex:0 0 28px;
    width:28px;
    height:28px;
    border-radius:50%;
    overflow:hidden;
    background:#f3f6fa;
    border:1px solid #dee5ed;
  }
  body.single-product .td-layout-option-photo img {
    display:block!important;
    width:100%!important;
    height:100%!important;
    object-fit:cover!important;
    border-radius:50%!important;
    margin:0!important;
    max-width:none!important;
  }
  body.single-product .td-layout-option-photo:empty::before {
    content:'';
    display:block;
    width:12px;
    height:12px;
    background:#c7d0da;
    border-radius:50%;
  }
  body.single-product .td-layout-option-name { overflow-wrap:anywhere; }
  body.single-product button.td-layout-reset {
    appearance:none!important;
    border:0!important;
    background:transparent!important;
    color:#2469e8!important;
    padding:3px 2px!important;
    min-height:28px!important;
    font-size:11px!important;
    box-shadow:none!important;
    font-weight:650!important;
  }
  /* Only hide native/original controls AFTER the portal is successfully built. */
  body.single-product form.variations_form.td-layout-has-portal .variations,
  body.single-product form.variations_form.td-layout-has-portal .trm-mobile-picker,
  body.single-product form.variations_form.td-layout-has-portal .t001-colors,
  body.single-product form.variations_form.td-layout-has-portal .t002-colors,
  body.single-product form.variations_form.td-layout-has-portal .t003-colors,
  body.single-product form.variations_form.td-layout-has-portal .t004-colors,
  body.single-product form.variations_form.td-layout-has-portal .t005-colors {
    display:none!important;
  }
  body.single-product form.variations_form.td-layout-has-portal .reset_variations {
    display:none!important;
  }
  /* Compress the remaining details without changing approved order. */
  body.single-product .entry-summary .product_title {margin-top:0!important;}
  body.single-product .entry-summary .woocommerce-product-details__short-description {margin-top:8px!important;padding-top:10px!important;}
}
@media(min-width:768px) {
  body.single-product .td-layout-choices {display:none!important;}
}

/* Treasure Premium Homepage plugin's persistent shopping header, if active.
   Keep its native hamburger and cart/wishlist handlers attached to the SAME
   elements. Only reposition them in the visible mobile header row. */
@media (max-width: 767px) {
  #thp2-global-header.td-layout-custom-header .td-layout-header-row {
    position:relative!important;
  }
  #thp2-global-header.td-layout-custom-header .td-layout-header-brand {
    position:absolute!important;
    left:50%!important;
    top:50%!important;
    transform:translate(-50%,-50%)!important;
    z-index:6!important;
    width:auto!important;
    max-width:min(36vw,140px)!important;
    margin:0!important;
    text-align:center!important;
  }
  #thp2-global-header.td-layout-custom-header .td-layout-header-menu {
    position:absolute!important;
    left:12px!important;
    top:50%!important;
    transform:translateY(-50%)!important;
    z-index:7!important;
    margin:0!important;
  }
  #thp2-global-header.td-layout-custom-header .td-layout-header-brand img {
    max-width:100%!important;
    height:auto!important;
  }
}

/* v1.11 correction: hamburger ONLY left, brand centered, original search,
   wishlist and cart controls grouped on RIGHT. Earlier v1.10 left their flex
   wrapper on the left, and positioned hamburger within that wrapper. */
@media (max-width: 767px) {
  #thp2-global-header.td-layout-custom-header .td-layout-header-row {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 7px !important;
    width: 100% !important;
    min-height: 64px !important;
    padding-left: 48px !important;
    padding-right: 13px !important;
    box-sizing: border-box !important;
  }
  #thp2-global-header.td-layout-custom-header .td-layout-header-flatten {
    display: contents !important;
  }
  #thp2-global-header.td-layout-custom-header .td-layout-header-actions {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 7px !important;
  }
  #thp2-global-header.td-layout-custom-header .td-layout-header-row > *:not(.td-layout-header-brand):not(.td-layout-header-menu) {
    flex: 0 0 auto !important;
  }
  #thp2-global-header.td-layout-custom-header .td-layout-header-row > :not(button):not(a):not(.td-layout-header-brand):not(.td-layout-header-menu) {
    column-gap: 7px !important;
  }
  #thp2-global-header.td-layout-custom-header .td-layout-header-brand {
    max-width: min(33vw, 132px) !important;
  }
  #thp2-global-header.td-layout-custom-header .td-layout-header-menu {
    left: 13px !important;
  }
}

/* v1.13: return to the stable v1.11 layout and remove the mobile header
   search trigger only. No logo scaling, animations or resize calculations. */
@media (max-width: 767px) {
  #thp2-global-header .td-layout-hidden-search,
  #thp2-global-header .td-layout-search-only,
  #thp2-global-header button[aria-label*="search" i],
  #thp2-global-header a[aria-label*="search" i],
  #thp2-global-header [role="button"][aria-label*="search" i],
  #thp2-global-header button[title*="search" i],
  #thp2-global-header a[title*="search" i],
  #thp2-global-header button[data-thp2-toggle*="search" i],
  #thp2-global-header a[data-thp2-toggle*="search" i],
  #thp2-global-header .thp2-search-trigger,
  #thp2-global-header button:has(svg.lucide-search),
  #thp2-global-header a:has(svg.lucide-search),
  #thp2-global-header button:has(svg[data-lucide="search"]),
  #thp2-global-header a:has(svg[data-lucide="search"]),
  #header [data-device="mobile"] [data-id="search"],
  #header [data-device="mobile"] .ct-header-search {
    display: none !important;
  }
}


/* v1.21 — phone gallery width correction ONLY.
 * Previously the slide was capped at 350px tall, causing square and portrait
 * source photos to shrink horizontally and leave large empty side bars.
 * Each original photo now renders at the slide's full available width and its
 * natural height. No object-fit:cover, cropping, zoom or image replacement.
 * Preserve the v1.9 existing-slide navigation, swatches and all desktop rules.
 */
@media (max-width: 767px) {
  body.single-product .td-native-gallery-slide {
    height: auto !important;
    min-height: 0 !important;
    aspect-ratio: auto !important;
    background: transparent !important;
  }
  body.single-product .td-native-gallery-slide > img {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: none !important;
    object-fit: contain !important;
    flex: none !important;
  }
}


/* v1.25: FIRST-PAINT mobile header positioning.
   Previously the logo was in the native left position until mobile-header.js
   added td-layout-custom-header after DOMContentLoaded. Pre-style the existing
   homepage header's native row/brand classes, BEFORE JS initializes. The
   final JS styles are identical, so applying the classes causes no jump.
   No animation, scaling, layout measurement, or DOM rearrangement. */
@media (max-width: 767px) {
  #thp2-global-header :is(.thp2-head-bar, .thp2-header-row, .thp2-main-header-row, .thp2-header-inner) {
    position: relative !important;
  }
  #thp2-global-header :is(.thp2-head-bar, .thp2-header-row, .thp2-main-header-row, .thp2-header-inner)
  :is(.thp2-brand, .thp2-header-brand, .thp2-branding, .thp2-site-brand, .thp2-header-logo, .thp2-logo) {
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    transform-origin: center center !important;
    width: auto !important;
    max-width: min(33vw, 132px) !important;
    margin: 0 !important;
    z-index: 6 !important;
    text-align: center !important;
  }
  #thp2-global-header :is(.thp2-head-bar, .thp2-header-row, .thp2-main-header-row, .thp2-header-inner)
  :is(.thp2-brand, .thp2-header-brand, .thp2-branding, .thp2-site-brand, .thp2-header-logo, .thp2-logo) img {
    height: auto !important;
    max-width: 100% !important;
  }
}
