/**
 * Location: /assets/css/main.css
 * Purpose:
 * - Global base styles + Woo global grid + shared UI styling.
 * - IMPORTANT: Header system styles are NOT defined here to avoid conflicts.
 *   Header UI is handled only in: /assets/css/header.css
 *
 * Related CSS:
 *  - /assets/css/header.css (header system; enqueued by /inc/features/header/header.php)
 *  - /assets/css/sidebar.css (sidebar grid system; conditionally enqueued)
 *  - /assets/css/blog.css (blog loop/grid/card system; conditionally enqueued)
 *  - /assets/css/stm-woo-sidebar-balance.css (Woo container width; conditionally enqueued)
 *  - /assets/css/single-product-layout.css (single product layout module; enqueued only on is_product())
 *
 * Notes (THIS UPDATE):
 * - Performance-first: keep main.css render cost low.
 * - Adds safe below-the-fold rendering optimization using content-visibility where it does not break interactive overflow.
 * - Blog loop/grid rendering is intentionally excluded from content-visibility because hover lift/shadow must remain unclipped.
 * - Blog loop/grid styling is intentionally not defined here; it lives in /assets/css/blog.css to avoid conflicts.
 */

/* SuntechMall-VPro Main CSS (Clean + Conflict-Free) */

/* ==============================
   Base
============================== */
:root{
  --stm-radius:18px;

  /* Global page/container width (entire site) */
  --stm-container:1500px;

  --stm-primary:#111;
  --stm-surface:#fff;

  /* Global shop columns (Woo loop) */
  --stm-shop-cols:5;      /* Desktop */
  --stm-shop-cols-2:4;    /* <=1100 */
  --stm-shop-cols-3:3;    /* <=800  */
  --stm-shop-cols-m:2;    /* <=560  */
}

/* Small safe resets */
html{ -webkit-text-size-adjust:100%; }
body{
  background:var(--stm-surface,#fff);
  color:var(--stm-text,#111827);
  font-size:var(--stm-font,16px);
  margin:0;
}
img{max-width:100%;height:auto}

/* Headings scale */
h1{font-size:calc(28px * (var(--stm-hscale,120%) / 120));}
h2{font-size:calc(22px * (var(--stm-hscale,120%) / 120));}
h3{font-size:calc(18px * (var(--stm-hscale,120%) / 120));}

/* Skip link */
.stm-skip-link{position:absolute;left:-999px;top:auto;width:1px;height:1px;overflow:hidden}
.stm-skip-link:focus{left:16px;top:16px;width:auto;height:auto;padding:10px 14px;background:#fff;border:1px solid #ddd;z-index:99999}

/* Header/Footer shell (shell only — no header system rules here) */
.stm-site-header{border-bottom:1px solid #eee;background:#fff}
.stm-site-footer{border-top:1px solid #eee;padding:24px 0}
.stm-footer{display:var(--stm-footer,block);}

/* ======================================================
   Global Container Rule — follow global --stm-container
   (This is SAFE and does not conflict with header.css)
====================================================== */
.stm-container{
  max-width:var(--stm-container,1500px);
  margin-left:auto;
  margin-right:auto;
  width:100%;
}

/* ======================================================
   CWV: Reduce below-the-fold rendering cost (SAFE)
   - content-visibility skips paint/layout until near viewport
   - contain-intrinsic-size prevents layout jumps
   - Works only on supporting browsers (others ignore)
   - Do NOT apply to blog grids/cards that need hover overflow
====================================================== */
@supports (content-visibility:auto){
  /* Footer is almost always below fold */
  .stm-site-footer,
  .stm-footer{
    content-visibility:auto;
    contain-intrinsic-size:900px;
  }

  /* Single product heavy sections typically below fold */
  .woocommerce-tabs,
  .related.products,
  .up-sells.upsells{
    content-visibility:auto;
    contain-intrinsic-size:1200px;
  }

  /* Offcanvas drawer: expensive subtree; render when opened/needed */
  .stm-oc__drawer{
    content-visibility:auto;
    contain-intrinsic-size:700px;
  }
}

/* ==============================
   WooCommerce: Global Shop Grid (Clean System)
   - One source of truth: ul.products
   - No duplicate .products grid rules
============================== */
.woocommerce ul.products{
  margin:0;
  padding:0;
  list-style:none;
  display:grid !important;
  grid-template-columns:repeat(var(--stm-shop-cols,5), minmax(0,1fr));
  gap:16px;
}

/* Remove Woo clearfix pseudo */
.woocommerce ul.products::before,
.woocommerce ul.products::after{
  content:none !important;
  display:none !important;
}

/* Kill floats/width that other themes set */
.woocommerce ul.products li.product,
.woocommerce-page ul.products li.product{
  float:none !important;
  width:auto !important;
  margin:0 !important;
}

/* Responsive columns */
@media (max-width:1100px){
  .woocommerce ul.products{
    grid-template-columns:repeat(var(--stm-shop-cols-2,4), minmax(0,1fr));
  }
}
@media (max-width:800px){
  .woocommerce ul.products{
    grid-template-columns:repeat(var(--stm-shop-cols-3,3), minmax(0,1fr));
  }
}
@media (max-width:560px){
  .woocommerce ul.products{
    grid-template-columns:repeat(var(--stm-shop-cols-m,2), minmax(0,1fr));
  }
}
@media (max-width:420px){
  .woocommerce ul.products{
    grid-template-columns:1fr;
  }
}

/* Improve Woo loop top bar spacing */
.woocommerce-result-count{margin:0 0 14px}
.woocommerce-ordering{margin:0 0 14px}

/* ==============================
   Step 03 — Shop Product Card (V1)
   Premium, fast, consistent sizing
============================== */
.stm-product-card{
  border:1px solid #eee;
  border-radius:var(--stm-radius,18px);
  background:#fff;
  overflow:hidden;
  display:flex;
  flex-direction:column;
  min-height:100%;
  transition:transform .12s ease;
}
.stm-product-card:hover{transform:translateY(-2px)}

.stm-product-card__link{display:block}
.stm-product-card__media{
  position:relative;
  padding:14px 14px 0;
}
.stm-product-card__media img{
  width:100%;
  height:auto;
  aspect-ratio:1 / 1;
  object-fit:contain;
  background:#fafafa;
  border-radius:14px;
}
.stm-product-card .onsale{
  position:absolute;
  top:14px;
  left:14px;
  z-index:2;
  font-size:12px;
  padding:6px 10px;
  border-radius:999px;
  background:#111;
  color:#fff;
  border:0;
}
.stm-product-card__content{
  padding:12px 14px 10px;
  display:flex;
  flex-direction:column;
  gap:8px;
  flex:1 1 auto;
}
.stm-product-card__title{
  font-size:14px;
  line-height:1.35;
  margin:0;
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
  overflow:hidden;
  min-height:38px;
}
.stm-product-card__meta{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  flex-wrap:wrap;
}
.stm-product-card .star-rating{margin:0;font-size:12px}
.stm-product-card .price{
  font-weight:800;
  font-size:14px;
  color:#111;
}
.stm-product-card__actions{padding:0 14px 14px}
.stm-product-card__actions a.button,
.stm-product-card__actions button.button,
.stm-product-card__actions a.add_to_cart_button,
.stm-product-card__actions a.product_type_simple{
  width:100%;
  text-align:center;
  border-radius:14px;
  padding:10px 12px;
  border:1px solid #e6e6e6;
  background:#fff;
  color:#111;
  font-weight:700;
  transition:transform .12s ease, border-color .12s ease, background .12s ease;
}
.stm-product-card__actions a.button:hover,
.stm-product-card__actions button.button:hover{
  border-color:#dcdcdc;
  transform:translateY(-1px);
  background:#f7f7f7;
}

/* ======================================================
   Blog loop/grid styling lives in /assets/css/blog.css
   to avoid conflicts with hover, stacking, and archive/blog
   card behavior.
====================================================== */

/* ======================================================
   Single Product V1 — MEDIA (Woo Gallery) FINAL
====================================================== */
.woocommerce-product-gallery{
  width:100% !important;
  margin:0 !important;
}
.woocommerce-product-gallery__wrapper{
  border-radius:14px;
  overflow:hidden;
  background:#fafafa;
  border:1px solid #eee;
}
.woocommerce-product-gallery__image{
  margin:0 !important;
  background:#fafafa;
}
.woocommerce-product-gallery__image img{
  width:100%;
  height:auto;
  display:block;
  object-fit:contain;
  aspect-ratio:1 / 1;
  background:#fafafa;
}
.woocommerce-product-gallery .flex-control-nav{
  display:flex;
  gap:10px;
  margin:12px 0 0 !important;
  padding:0 !important;
  list-style:none;
  overflow-x:auto;
  overflow-y:hidden;
  -webkit-overflow-scrolling:touch;
  scrollbar-width:thin;
}
.woocommerce-product-gallery .flex-control-nav li{
  width:auto !important;
  margin:0 !important;
  flex:0 0 auto;
}
.woocommerce-product-gallery .flex-control-nav img{
  width:64px !important;
  height:64px !important;
  object-fit:contain;
  border:1px solid #e5e7eb;
  border-radius:12px;
  background:#fff;
  padding:6px;
  display:block;
  opacity:.86;
  transition:opacity .12s ease, border-color .12s ease, transform .12s ease;
}
.woocommerce-product-gallery .flex-control-nav img:hover{
  opacity:1;
  border-color:#cbd5e1;
  transform:translateY(-1px);
}
.woocommerce-product-gallery .flex-control-nav img.flex-active{
  opacity:1;
  border-color:#111;
}
@media (max-width:480px){
  .woocommerce-product-gallery .flex-control-nav img{
    width:58px !important;
    height:58px !important;
  }
}

.stm-sp__summary .stm-sp__summary-inner{
  border:1px solid #eee;
  border-radius:var(--stm-radius,18px);
  background:#fff;
  padding:18px 18px 16px;
  position:sticky;
  top:18px;
}
.stm-sp__summary .product_title{font-size:24px;line-height:1.25;margin:0 0 10px}
.stm-sp__summary .price{font-size:22px;font-weight:800;margin:10px 0 8px}

.stm-sp__summary .woocommerce-product-rating{
  display:flex;
  align-items:center;
  gap:10px;
  margin:0 0 10px;
}

.stm-sp__summary .woocommerce-product-details__short-description{
  color:#374151;
  font-size:14px;
}

.stm-sp__summary form.cart{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-top:14px;
}
.stm-sp__summary .quantity .qty{
  height:44px;
  border-radius:12px;
  border:1px solid #e5e7eb;
  padding:0 10px;
}
.stm-sp__summary button.single_add_to_cart_button{
  height:44px;
  border-radius:14px;
  border:0;
  padding:0 18px;
  font-weight:800;
}

.stm-sp__summary .product_meta{
  margin-top:14px;
  padding-top:14px;
  border-top:1px solid #f0f0f0;
  font-size:13px;
  color:#374151;
}
.stm-sp__summary .product_meta a{color:#111}

.woocommerce-tabs{margin-top:26px}
.woocommerce-tabs ul.tabs{
  display:flex;
  gap:10px;
  padding:0 !important;
  margin:0 0 14px !important;
  border-bottom:1px solid #eee !important;
  list-style:none;
}
.woocommerce-tabs ul.tabs li{border:0 !important;background:transparent !important;margin:0 !important;padding:0 !important}
.woocommerce-tabs ul.tabs li a{
  display:inline-flex;
  align-items:center;
  padding:10px 14px !important;
  border-radius:14px 14px 0 0;
  border:1px solid transparent;
  color:#111 !important;
  font-weight:700;
}
.woocommerce-tabs ul.tabs li.active a,
.woocommerce-tabs ul.tabs li a:hover{
  background:#f7f7f7;
  border-color:#eee;
}
.woocommerce-tabs .panel{
  border:1px solid #eee;
  border-radius:var(--stm-radius,18px);
  background:#fff;
  padding:18px;
}

.woocommerce #reviews #comments ol.commentlist li .comment-text{border:1px solid #eee;border-radius:16px}
.woocommerce #review_form #respond textarea{border-radius:16px;border:1px solid #e5e7eb}

.related.products,
.up-sells.upsells{margin-top:26px}
.related.products > h2,
.up-sells.upsells > h2{font-size:18px;margin:0 0 12px}

@media (max-width:980px){
  .stm-sp__grid{grid-template-columns:1fr;gap:18px}
  .stm-sp__summary .stm-sp__summary-inner{position:relative;top:auto}
}

/* ==============================
   Step 06 — Off-canvas Menu (V1)
============================== */
.stm-oc__overlay{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.45);
  opacity:0;
  pointer-events:none;
  transition:opacity .16s ease;
  z-index:99998;
}
.stm-oc__drawer{
  position:fixed;
  top:0;
  left:0;
  height:100vh;
  width:340px;
  max-width:86vw;
  background:#fff;
  transform:translateX(-102%);
  transition:transform .18s ease;
  z-index:99999;
  overflow:auto;
  -webkit-overflow-scrolling:touch;
  border-right:1px solid #eee;
}
body.stm-oc-open .stm-oc__overlay{opacity:1;pointer-events:auto}
body.stm-oc-open .stm-oc__drawer{transform:translateX(0)}
.stm-oc__overlay.is-open{opacity:1;pointer-events:auto}
.stm-oc__drawer.is-open{transform:translateX(0)}
body.stm-oc-open{overflow:hidden}

.stm-oc__head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 14px 10px;
  border-bottom:1px solid #eee;
}
.stm-oc__title{font-weight:800}
.stm-oc__close{
  width:36px;
  height:36px;
  border-radius:12px;
  border:1px solid #eee;
  background:#fff;
  font-size:22px;
  line-height:1;
  cursor:pointer;
}
.stm-oc__nav{padding:10px 10px 18px}
.stm-oc__menu{list-style:none;margin:0;padding:0}
.stm-oc__menu li{margin:0;padding:0}
.stm-oc__menu a{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:12px 12px;
  border-radius:14px;
  color:#111;
  text-decoration:none;
  font-weight:700;
}
.stm-oc__menu a:hover{background:#f7f7f7}
.stm-oc__menu .current-menu-item > a{background:#f3f4f6}

.stm-oc__subbtn{
  width:36px;
  height:36px;
  border-radius:12px;
  border:1px solid #eee;
  background:#fff;
  cursor:pointer;
  display:grid;
  place-items:center;
}
.stm-oc__subbtn span{
  font-size:20px;
  transform:rotate(0deg);
  transition:transform .15s ease;
}
.stm-oc__menu .menu-item-has-children.is-sub-open > .stm-oc__subbtn span{transform:rotate(90deg)}
.stm-oc__menu .sub-menu{
  list-style:none;
  margin:4px 0 6px 12px;
  padding:0;
  display:none;
}
.stm-oc__menu .menu-item-has-children.is-sub-open > .sub-menu{display:block}
.stm-oc__menu .sub-menu a{
  font-weight:600;
  padding:10px 12px;
  opacity:.92;
}
@media (min-width:981px){
  .stm-oc{display:none}
}

/* ======================================================
   GLOBAL SALE BADGE (HARD OVERRIDE)
====================================================== */
.woocommerce ul.products li.product,
.woocommerce ul.products li.product a,
.woocommerce ul.products li.product .woocommerce-LoopProduct-link,
.woocommerce ul.products li.product .woocommerce-loop-product__link,
.woocommerce ul.products li.product .stm-pl,
.woocommerce ul.products li.product .stm-pl__media{
  position:relative;
  overflow:hidden;
}

.woocommerce ul.products li.product span.onsale,
.woocommerce ul.products li.product a span.onsale,
.woocommerce ul.products li.product .woocommerce-LoopProduct-link span.onsale,
.woocommerce ul.products li.product .woocommerce-loop-product__link span.onsale,
.woocommerce div.product span.onsale{
  position:absolute !important;
  top:5px !important;
  right:5px !important;
  left:auto !important;
  bottom:auto !important;
  transform:none !important;
  margin:0 !important;
  display:inline-flex !important;
  align-items:center !important;
  justify-content:center !important;
  padding:8px 12px !important;
  height:auto !important;
  background:#16a34a !important;
  color:#ffffff !important;
  font-size:12px !important;
  font-weight:700 !important;
  line-height:1 !important;
  border-radius:999px !important;
  text-transform:uppercase !important;
  letter-spacing:.3px !important;
  white-space:nowrap !important;
  min-width:0 !important;
  min-height:0 !important;
  width:auto !important;
  max-width:max-content !important;
  z-index:50 !important;
  box-shadow:none !important;
}

.woocommerce span.onsale::before,
.woocommerce span.onsale::after{
  display:none !important;
}

/* ==============================
   Single Product: Page Top Row (Breadcrumb)
============================== */
.stm-page-top--breadcrumb{
  padding:14px 0 10px;
}

.stm-page-top--breadcrumb .woocommerce-breadcrumb{
  margin:0;
  font-size:13px;
  color:#6b7280;
}

.stm-page-top--breadcrumb .woocommerce-breadcrumb a{
  color:#111;
}

.stm-page-top--breadcrumb .woocommerce-breadcrumb a:hover{
  text-decoration:underline;
}

