/* ==========================================================================
 * Product page + cards (2026-12-06, Impeccable pass; findings F1-F20 in docs/product-page-critique.md).
 * PHP side: inc/pdp-pricing-titles.php. Small JS: assets/pdp.js. First-paint rules (title, "Fra", lone tile) live in critical.css.
 * Tokens (from DESIGN.md): ink #1E293B, slate (muted text) #475569 = 7.6:1 on white, teal #006C68, lime-tint #EAF4D8.
 * Everything here is scoped to product pages / product cards and can be reverted by removing the "pdp.css" enqueue in functions.php.
 * ========================================================================== */

/* ---- Price: the per-piece note beside the one price (set by pdp.js from the selected pack) ---- */
html body.cbd-design.single-product .summary p.price[data-unit]::after {
  content: "\00b7\00a0" attr(data-unit);
  margin-left: .55em;
  font-size: max(.5em, 13px);
  font-weight: 500;
  letter-spacing: 0;
  color: #475569;
  white-space: nowrap;
}
/* ...and no second price on the tiles: they keep the pack count and the saving. */
html body.cbd-pdp-unit.cbd-design.single-product .summary .cbd-unit { display: none; }
/* Saving as a quiet content chip (ink on lime tint, 12:1). Brand lime is allowed in content, never around menu links. */
html body.cbd-design.single-product .summary .cbd-save {
  padding: 1px 8px;
  border-radius: 999px;
  background: #EAF4D8;
  color: #1E293B;
}
/* A sold-out page should not shout its price. */
html body.cbd-oos.single-product .summary p.price { color: #5b6678; }

/* ---- Option groups ---- */
/* Five or more options (colours): three even columns instead of a 4+2 orphan row. */
html body.cbd-design.single-product .summary .ast-variation-button-group:has(> :nth-child(5)) {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
/* Unavailable combination: dashed (plugin) plus strike-through, so "not available" does not rely on the border alone. */
html body.cbd-design.single-product .summary .ast-variation-button-group .ast-single-variation[aria-disabled="true"] {
  text-decoration: line-through;
  text-decoration-color: #8290a3;
}

/* ---- Facts under the price: quiet inline facts instead of grey pills that look like filters or tags ---- */
@media (min-width: 545px) {
  html body.cbd-design.single-product .summary .cbd-facts { gap: 4px 22px; }
  html body.cbd-design.single-product .summary .cbd-fact {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
  }
}

/* ---- Phones: air between the ViaBill line and what follows ---- */
@media (max-width: 544px) {
  html body.cbd-live-viabill.single-product .summary .viabill-pricetag-wrap { margin: 4px 0 14px; }
}

/* ---- Description: the leading h2 that repeats the product title stays for search engines and screen readers only ---- */
.single-product .cbd-dup-title {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px !important;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
}
/* "Key: value" spec paragraphs: closer together (they read as one list), measure kept. */
.single-product .woocommerce-Tabs-panel--description .ast-distributed-wrap > p:has(> b:first-child, > strong:first-child) {
  margin: 0 0 4px;
  line-height: 1.5;
}

/* ---- Cards (shop, category, related, up-sells): name, qualifier, one price, brand ---- */
html ul.products li.product .woocommerce-loop-product__title {
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  color: #1E293B;
  text-wrap: balance;
}
ul.products li.product .woocommerce-loop-product__title .cbd-t-main {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}
ul.products li.product .woocommerce-loop-product__title .cbd-t-sub {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  color: #475569;
  white-space: nowrap;
  text-overflow: ellipsis;
}
ul.products li.product .price { white-space: nowrap; }
ul.products li.product .price .cbd-from { margin-right: .3em; font-size: 13px; font-weight: 500; color: #475569; }
ul.products li.product .price del { margin-right: .3em; font-weight: 500; color: #5b6678; }
ul.products li.product .price ins { text-decoration: none; }
/* Brand line: smaller and quieter than the price (it was larger than both). */
ul.products li.product .ast-woo-shop-product-description,
ul.products li.product .ast-woo-shop-product-description p { margin: 4px 0 0; font-size: 13px; line-height: 1.3; color: #475569; }

/* ---- Gallery: calmer motion (no layout change anywhere in this block) ---- */
@media (prefers-reduced-motion: no-preference) {
  @keyframes cbd-fade-in { from { opacity: 0; } to { opacity: 1; } }
  /* What appears when the real slider takes over from the first-paint image (neighbour peek, thumbnails) fades in. */
  .woocommerce-product-gallery.cbd-g-ready .flex-viewport .woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image:not(:first-child),
  .woocommerce-product-gallery.cbd-g-ready .ast-single-product-thumbnails {
    animation: cbd-fade-in 480ms cubic-bezier(0.16, 1, 0.3, 1) both;
  }
  /* Desktop slide change: ease out instead of WooCommerce's default ease. */
  .woocommerce-product-gallery .flex-viewport .woocommerce-product-gallery__wrapper { transition-timing-function: cubic-bezier(0.22, 1, 0.36, 1) !important; }
  /* Thumbnails and the active mark respond smoothly. */
  .single-product .ast-single-product-thumbnails .ast-woocommerce-product-gallery__image { transition: border-color 200ms ease-out, box-shadow 200ms ease-out, opacity 200ms ease-out; }
  .single-product .ast-single-product-thumbnails .ast-woocommerce-product-gallery__image img { transition: opacity 200ms ease-out; }
}
.single-product .ast-single-product-thumbnails .ast-woocommerce-product-gallery__image:not(.flex-active-slide) img { opacity: .8; }
.single-product .ast-single-product-thumbnails .ast-woocommerce-product-gallery__image:hover img,
.single-product .ast-single-product-thumbnails .ast-woocommerce-product-gallery__image.flex-active-slide img { opacity: 1; }

/* Phones/tablets (swipe layout): the neighbour that peeks is slightly receded, the current image is crisp; magnifier is a 44px
 * target that sits inside the first slide instead of on the peek. */
@media (max-width: 921px) {
  @media (prefers-reduced-motion: no-preference) {
    body.cbd-live-swipe.single-product .woocommerce-product-gallery.cbd-swipe-on > .flex-viewport > .woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image {
      transition: opacity 260ms ease-out;
    }
  }
  body.cbd-live-swipe.single-product .woocommerce-product-gallery.cbd-swipe-on > .flex-viewport > .woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image:not(.flex-active-slide) { opacity: .82; }
  body.cbd-live-swipe.single-product .woocommerce-product-gallery.cbd-swipe-on .woocommerce-product-gallery__trigger {
    width: 44px;
    height: 44px;
    top: 10px;
    right: calc(14% + 10px);
  }
}
