/**
 * Phase 5.5.0 - Foundation hardening + roadmap safe layer.
 * Only stable layout/UX guards. No DOM moving, no output buffering.
 */
:root{
  --usg-store-max:1760px;
  --usg-store-pad:clamp(14px,2.5vw,40px);
  --usg-touch:44px;
  --usg-radius-xl:28px;
}
body.usg-theme{overflow-x:hidden;}
body.usg-theme *{box-sizing:border-box;}

/* Full-width but controlled desktop containers */
@media (min-width:1024px){
  .usg-theme.single-product .site.grid-container,
  .usg-theme.single-product .site-content,
  .usg-theme.post-type-archive-product .site.grid-container,
  .usg-theme.tax-product_cat .site.grid-container,
  .usg-theme.woocommerce-shop .site.grid-container{
    width:min(calc(100% - 32px),var(--usg-store-max)) !important;
    max-width:var(--usg-store-max) !important;
    margin-inline:auto !important;
  }
  .usg-theme .inside-header,
  .usg-theme .main-navigation .inside-navigation{
    width:min(calc(100% - 32px),var(--usg-store-max)) !important;
    max-width:var(--usg-store-max) !important;
    margin-inline:auto !important;
  }
}

/* Product page safe baseline. Keep Woo hooks intact; just prevent floats/sticky/overflow. */
.usg-theme.single-product div.product{clear:both;}
.usg-theme.single-product div.product div.images,
.usg-theme.single-product div.product div.summary{
  position:relative !important;
  top:auto !important;
  right:auto !important;
  left:auto !important;
  bottom:auto !important;
  float:none !important;
  max-width:100% !important;
  min-width:0 !important;
}
@media (min-width:1024px){
  .usg-theme.single-product div.product{
    display:grid !important;
    grid-template-columns:minmax(420px,.95fr) minmax(460px,1.05fr) !important;
    gap:clamp(24px,3vw,56px) !important;
    align-items:start !important;
  }
  .usg-theme.single-product div.product .woocommerce-tabs,
  .usg-theme.single-product div.product .related,
  .usg-theme.single-product div.product .upsells,
  .usg-theme.single-product div.product .usg-product-trust-row,
  .usg-theme.single-product div.product .usg-product-after-gallery{
    grid-column:1 / -1;
  }
}
@media (max-width:1023px){
  .usg-theme.single-product div.product{display:block !important; width:100% !important;}
  .usg-theme.single-product div.product div.images,
  .usg-theme.single-product div.product div.summary{width:100% !important; margin-inline:0 !important;}
}

/* Product title and intro readability */
.usg-theme.single-product .product_title,
.usg-theme.single-product h1.product_title{
  font-size:clamp(1.65rem,3vw,3.45rem) !important;
  line-height:1.25 !important;
  letter-spacing:-.035em;
  max-width:14ch;
  margin-inline:auto;
}
.usg-theme.single-product .woocommerce-product-details__short-description{
  font-size:clamp(.95rem,1.35vw,1.08rem);
  line-height:2;
  color:var(--usg-muted,#64748b);
  max-width:68ch;
  margin-inline:auto;
}

/* Optional clipped intro; JS can expand by adding .is-expanded. */
.usg-theme.single-product .woocommerce-product-details__short-description.usg-is-collapsible:not(.is-expanded){
  display:-webkit-box;
  -webkit-line-clamp:2;
  line-clamp:2;
  -webkit-box-orient:vertical;
  overflow:hidden;
}
.usg-shortdesc-toggle{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:.35rem;
  min-height:36px;
  border:0;
  border-radius:999px;
  padding:.25rem .85rem;
  margin-top:.45rem;
  cursor:pointer;
  background:rgba(37,99,235,.08);
  color:var(--usg-primary,#2563eb);
  font:inherit;
  font-weight:800;
}

/* Product options and add-ons. Preserve custom plugin output, prevent narrow vertical text. */
.usg-theme.single-product form.cart,
.usg-theme.single-product .variations_form,
.usg-theme.single-product .cart.grouped_form{
  width:100% !important;
  max-width:100% !important;
  display:flex !important;
  flex-direction:column !important;
  gap:14px !important;
  overflow:visible !important;
}
.usg-theme .pcb-master-box,
.usg-theme .pcb-addon-list,
.usg-theme .pcb-grid,
.usg-theme .pcb-total-bar{
  width:100% !important;
  max-width:100% !important;
  min-width:0 !important;
}
.usg-theme .pcb-master-box{overflow:visible !important; align-self:stretch !important;}
.usg-theme .pcb-grid{grid-template-columns:repeat(auto-fit,minmax(min(100%,150px),1fr)) !important;}
.usg-theme .pcb-card,
.usg-theme .pcb-addon-item,
.usg-theme .pcb-addon-info,
.usg-theme .pcb-addon-text,
.usg-theme .pcb-addon-title{
  min-width:0 !important;
  max-width:100% !important;
  white-space:normal !important;
  word-break:normal !important;
  overflow-wrap:anywhere !important;
  writing-mode:horizontal-tb !important;
  text-orientation:mixed !important;
}

/* Quantity + purchase row */
.usg-theme.single-product .quantity{margin:0 !important;}
.usg-theme.single-product form.cart .quantity,
.usg-theme.single-product form.cart .single_add_to_cart_button{
  min-height:var(--usg-touch) !important;
}
.usg-theme.single-product form.cart .single_add_to_cart_button{
  width:100%;
  border-radius:18px !important;
  font-weight:900 !important;
}
@media (min-width:520px){
  .usg-theme.single-product form.cart .quantity{width:132px !important; flex:0 0 132px !important;}
  .usg-theme.single-product form.cart .single_add_to_cart_button{flex:1 1 auto !important;}
}

/* Product meta hidden visually by request, without touching schema/data. */
.usg-theme.single-product .product_meta{display:none !important;}

/* Trust row above tabs. */
.usg-product-trust-row{
  width:100%;
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:14px;
  margin:24px 0 12px;
}
.usg-product-trust-card{
  display:flex;
  align-items:center;
  gap:12px;
  padding:16px;
  border:1px solid rgba(148,163,184,.28);
  border-radius:22px;
  background:linear-gradient(180deg,#fff,rgba(248,250,252,.86));
  box-shadow:0 14px 36px rgba(15,23,42,.05);
}
.usg-product-trust-card svg{width:28px;height:28px;color:var(--usg-primary,#2563eb);flex:0 0 28px;}
.usg-product-trust-card strong{display:block;font-weight:900;color:var(--usg-heading,#0f172a);}
.usg-product-trust-card span{display:block;font-size:.88rem;color:var(--usg-muted,#64748b);margin-top:2px;}
@media (max-width:767px){.usg-product-trust-row{grid-template-columns:1fr;}}

/* Shop cards stable responsive baseline */
.usg-theme.woocommerce ul.products{display:grid !important; grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr)) !important; gap:clamp(14px,2vw,24px) !important;}
.usg-theme.woocommerce ul.products li.product{width:auto !important; min-width:0 !important; margin:0 !important;}
.usg-theme.woocommerce ul.products li.product .woocommerce-loop-product__title{font-size:clamp(.95rem,1vw,1.08rem);line-height:1.75;}

/* Checkout hardening without changing fields. */
@media (min-width:992px){
  .usg-theme.woocommerce-checkout form.checkout{
    display:grid !important;
    grid-template-columns:minmax(0,1.15fr) minmax(340px,.85fr) !important;
    gap:clamp(20px,3vw,46px) !important;
    align-items:start !important;
  }
  .usg-theme.woocommerce-checkout #customer_details{grid-column:1; min-width:0;}
  .usg-theme.woocommerce-checkout #order_review_heading,
  .usg-theme.woocommerce-checkout #order_review{grid-column:2; min-width:0;}
}
.usg-theme.woocommerce-checkout input,
.usg-theme.woocommerce-checkout textarea,
.usg-theme.woocommerce-checkout select{max-width:100%;}

/* Mobile nav safe area final guard */
@media (max-width:768px){
  .usg-bottom-nav{display:grid !important; position:fixed !important; inset-inline:10px !important; bottom:max(10px,env(safe-area-inset-bottom)) !important; z-index:99998 !important;}
  body.usg-theme{padding-bottom:calc(82px + env(safe-area-inset-bottom)) !important;}
}

@media (prefers-reduced-motion:reduce){
  .usg-theme *, .usg-theme *::before, .usg-theme *::after{animation-duration:.001ms !important; transition-duration:.001ms !important; scroll-behavior:auto !important;}
}
