/*
 * The product page's layout (product.html, and every /books/<id> page made from it). Layout only: where the
 * ui.css components sit, with the system's tokens. Components, colours and type live in ui.css.
 */
@layer page {
  :root { --ui-scroll-offset: calc(var(--ui-header-h) + var(--s-2)); }

  /* The book: the gallery, then the buy box (side by side from 900px) */
  .pp-hero { padding-block: 0 var(--s-6); }
  .pp-hero__grid { display: grid; gap: var(--s-5); }
  .pp-buy { display: grid; gap: var(--s-4); align-content: start; min-inline-size: 0; }
  /* The breadcrumb and the rating sit close above the title; the rating keeps its 44px target over the gap */
  .pp-buy .ui-breadcrumb { margin-block-end: calc(-1 * var(--s-2)); }
  .pp-buy .ui-rating { margin-block: calc(-1 * var(--s-2h)); }
  /* What the book is made of: small tags under the benefits */
  .pp-quality { list-style: none; margin: calc(-1 * var(--s-1)) 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s-1h) var(--s-2); }
  /* On a phone the photo and the offer reach the screen's edges */
  .pp-gallery .ui-gallery__stage { margin-inline: calc(-1 * var(--ui-gutter)); }
  .pp-offer {
    margin-block-start: var(--s-2); margin-inline: calc(-1 * var(--ui-gutter));
    padding-inline: var(--ui-gutter); border-inline-width: 0; border-radius: 0; box-shadow: none;
  }

  /* The sections' rows */
  .pp-books { --ui-rail-item: 58%; }
  .pp-feed { --ui-rail-item: 270px; --ui-rail-item-wide: 300px; }
  .pp-more__all { margin-block-start: var(--s-4); }
  .pp-how { display: grid; gap: var(--s-6); align-items: center; }
  .pp-private { margin-block-start: var(--s-4); }
  .pp-quotes { display: grid; gap: var(--s-3); }
  .pp-final { display: grid; justify-items: center; gap: var(--s-4); text-align: center; }
  .pp-final__btn { inline-size: 100%; max-inline-size: 360px; }

  /* The preview's dialog. One form, two variants (data-for on the dialog): "preview" (the default) and "cart", opened by
     Add to cart. A part marked data-for-preview shows only in the first, data-for-cart only in the second. */
  #pvModal[data-for="cart"] [data-for-preview], #pvModal:not([data-for="cart"]) [data-for-cart] { display: none; }
  .pv-form { display: grid; gap: var(--s-4); }
  .pv-kids { display: grid; gap: var(--s-3); }
  .pv-addkid { justify-self: start; }

  /* The WhatsApp button stays on a phone; with the sticky bar showing it sits just above it */
  @media (max-width: 899px) {
    body.page-product.has-ui-sticky .wa-fab { opacity: 1; transform: translateY(-72px); pointer-events: auto; }
  }

  @media (min-width: 760px) {
    .pp-gallery .ui-gallery__stage { margin-inline: 0; }
    .pp-offer { margin-inline: 0; padding-inline: var(--s-5); border-inline-width: 1px; border-radius: var(--r-lg); box-shadow: var(--sh-card); }
    .pp-quotes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  }
  @media (min-width: 900px) {
    .pp-hero { padding-block: var(--s-6) var(--s-7); }
    .pp-hero__grid { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: var(--s-8); align-items: start; }
    .pp-gallery { position: sticky; inset-block-start: calc(var(--ui-header-h) + var(--s-5)); }
    .pp-how { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s-8); }
  }
}
