/* Product page (docs/pages/category-product.md, D-062).
   Phones: the photo, then everything about it, then the shelf again. From 900px: the photo on the right, the words beside it */

.product {
  display: grid;
  gap: var(--space-5);
  padding-block: var(--space-4) var(--space-6);
}

/* ---------- Gallery: the card's frame, grown up. Same punched corner, same heart, bigger (D-032, D-062) ---------- */

.gallery {
  min-width: 0;
}

.gallery__frame {
  --punch: 60px;
  position: relative;
}

/* The photos sit side by side and you move them by hand (M-18). Nothing slides on its own (DP-11) */
.gallery__track {
  display: flex;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  border-radius: var(--radius-m);
  background: var(--color-surface);
  mask:
    var(--shape-punch) 0 0 / var(--punch) var(--punch) no-repeat,
    linear-gradient(#000 0 0);
  mask-composite: exclude;
}

.gallery__track::-webkit-scrollbar {
  display: none;
}

/* The mask would cut the focus ring off, so the ring goes on the frame around it */
.gallery__track:focus-visible {
  outline: none;
}

.gallery__frame:has(.gallery__track:focus-visible) {
  border-radius: var(--radius-m);
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
  animation: focus-in var(--duration-base) var(--ease-spring);
}

.gallery__slide {
  flex: 0 0 100%;
  scroll-snap-align: start;
}

.gallery__slide img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
}

.gallery__thumbs {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.gallery__thumb {
  display: block;
  width: 64px;
  overflow: hidden;
  border-radius: var(--radius-s);
  background: var(--color-surface);
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition:
    outline-color var(--duration-fast),
    translate var(--duration-base) var(--ease-spring);
}

.gallery__thumb img {
  display: block;
  width: 100%;
  height: auto;
}

/* M-38: the ring follows the photo on screen, whether you tapped a small one or scrolled the big ones */
.gallery__thumb[aria-current="true"] {
  outline-color: var(--color-ink);
}

.gallery__thumb:not([aria-current="true"]):hover {
  outline-color: var(--color-line);
  translate: 0 -2px;
}

/* ---------- The words: category, name, price, the deal, what it is, and the next step ---------- */

.product__info {
  min-width: 0;
}

/* The way back to the shelf, with the department's own icon from the home page (D-062) */
.product__dept {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  color: var(--color-muted);
  font: 600 var(--text-s) / 1.2 var(--font-ui);
  text-decoration: none;
}

.product__dept svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.product__dept:hover {
  color: var(--color-ink);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.product__name {
  font: 600 var(--text-xl) / 1.2 var(--font-ui);
  text-wrap: balance;
}

/* DP-1: the price is the biggest number on the page */
.product__price {
  margin-top: var(--space-3);
  color: var(--color-brand-red);
  font: 600 var(--text-2xl) / 1 var(--font-ui);
}

/* 3 ב-100, explained once, with the way to everything in it (P-05, D-064) */
.product__deal {
  display: grid;
  justify-items: start;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding: var(--space-4) var(--space-4) var(--space-2);
  border-radius: var(--radius-m);
  background: var(--color-yellow-tint);
}

.product__deal-tag {
  background: var(--color-brand-yellow);
  color: var(--color-ink);
  rotate: -4deg;
  transition:
    rotate var(--duration-base) var(--ease-spring),
    scale var(--duration-base) var(--ease-spring);
}

/* M-31, as on the cards: reach for the deal and its sticker gets pressed flat */
.product__deal:is(:hover, :focus-within) .product__deal-tag {
  rotate: 0deg;
  scale: 1.08;
}

.product__deal-text {
  font-size: var(--text-s);
  line-height: 1.5;
}

.product__facts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.product__facts li {
  padding: 7px 12px;
  border-radius: var(--radius-full);
  background: var(--color-bg-deep);
  font: 600 var(--text-xs) / 1 var(--font-ui);
}

.product__desc {
  max-width: 46ch;
  margin-top: var(--space-4);
  line-height: 1.6;
}

.product__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.product__actions .btn--primary {
  flex: 1 1 auto;
}

@media (min-width: 600px) {
  .product__actions .btn--primary {
    flex: 0 0 auto;
  }
}

/* From 900px the photo starts at the page's edge, like the shelf under it, and is about as tall as the words
   beside it, so neither side outweighs the other (D-062, update) */
@media (min-width: 900px) {
  .product {
    grid-template-columns: minmax(0, 440px) minmax(0, 520px);
    column-gap: var(--space-7);
    align-items: start;
    padding-block: var(--space-6) var(--space-7);
  }

  .product__info {
    padding-top: var(--space-2);
  }

  .product__name {
    font-size: var(--text-2xl);
  }

  .product__price {
    margin-top: var(--space-4);
    font-size: var(--text-price-l);
  }

  .gallery__thumb {
    width: 80px;
  }
}

@media (min-width: 1100px) {
  .product {
    column-gap: var(--space-8);
  }
}
