/*
 * Storefront PDP (product detail page) styles — docs/webshop 06 §7 + §15.
 *
 * Page-scoped CSS loaded only by the PDP (host per-page asset pattern). EXTENDS
 * shop-tokens.css / shop-components.css (sh-* system) — references --sh-* and
 * host tokens (--c-*, --radius*, --shadow*, --container, --pad, --ease), never
 * hardcodes brand colors. Mobile-first: single column on <lg (gallery → info →
 * tabs → rails), a two-column gallery/info split on lg+ with a sticky gallery.
 *
 * Progressive enhancement — everything is usable without JS. The gallery
 * degrades to a scrollable image list, tabs to anchored stacked panels, the
 * sticky bar stays hidden (P2.5 reveals it). Swiper/Fancybox theming is scoped
 * so the vendored CSS doesn't leak into the rest of the storefront.
 *
 * Breakpoints match shop-components.css: 576 / 768 / 1024(lg) / 1280.
 * Contrast verified against tokens (AA). Hand-authored, ?v= cache-busted.
 */

/* Screen-reader-only utility (shared name with shop-plp.css; idempotent). */
.sh-visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

.sh-pdp { padding-block: var(--sh-space-4) var(--sh-space-8); }

/* =============================================================== *
 * Top: gallery + purchase panel
 * =============================================================== */
.sh-pdp__top {
  display: flex;
  flex-direction: column;
  gap: var(--sh-space-5);
}

/* =============================================================== *
 * Gallery
 * =============================================================== */
.sh-gallery { position: relative; }

.sh-gallery__main {
  position: relative;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md, 12px);
  overflow: hidden;
  background: var(--sh-surface);
}
.sh-gallery__slide {
  display: flex;
  align-items: center;
  justify-content: center;
}
.sh-gallery__zoom {
  display: block;
  position: relative;
  width: 100%;
  cursor: zoom-in;
}
.sh-gallery__img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;       /* reserve space → no CLS on the LCP image */
  object-fit: cover;
  background: var(--sh-surface-2);
}
.sh-gallery--empty .sh-gallery__img {
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md, 12px);
  object-fit: contain;
  padding: var(--sh-space-6);
}
.sh-gallery__zoom-hint {
  position: absolute;
  right: var(--sh-space-3);
  bottom: var(--sh-space-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--sh-radius-pill);
  background: rgba(255, 255, 255, .9);
  color: var(--c-text);
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,.12));
  font-size: 16px;
}

/* Prev/next arrows (shown when >1 image; Swiper is optional enhancement). */
.sh-gallery__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--sh-tap); height: var(--sh-tap);
  border: 1px solid var(--c-border);
  border-radius: var(--sh-radius-pill);
  background: rgba(255, 255, 255, .92);
  color: var(--c-text);
  cursor: pointer;
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,.12));
}
.sh-gallery__nav--prev { left: var(--sh-space-2); }
.sh-gallery__nav--next { right: var(--sh-space-2); }
.sh-gallery__nav:hover { background: #fff; }

/* Thumbnail strip — scroll-snap row without JS; Swiper thumbs enhances it. */
.sh-gallery__thumbs {
  margin-top: var(--sh-space-3);
  overflow-x: auto;
}
.sh-gallery__thumbs .swiper-wrapper {
  display: flex;
  gap: var(--sh-space-2);
}
.sh-gallery__thumb {
  flex: 0 0 auto;
  width: 64px; height: 64px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  background: var(--sh-surface-2);
  transition: border-color var(--sh-dur) var(--ease);
}
.sh-gallery__thumb.is-active { border-color: var(--c-blue); }
.sh-gallery__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* =============================================================== *
 * Purchase panel
 * =============================================================== */
.sh-pdp__brand {
  margin: 0 0 var(--sh-space-1);
  color: var(--c-muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.sh-pdp__title {
  margin: 0 0 var(--sh-space-2);
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 700;
  line-height: 1.2;
}
.sh-pdp__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sh-space-3);
  margin-bottom: var(--sh-space-2);
  color: var(--c-muted);
  font-size: 13px;
}
.sh-pdp__sku strong { color: var(--c-text); font-weight: 600; }
.sh-pdp__rating {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--c-text);
  text-decoration: none;
}
.sh-pdp__rating:hover { text-decoration: underline; }
.sh-pdp__rating-count { color: var(--c-muted); }

.sh-pdp__price { margin: var(--sh-space-3) 0; }
/* Enlarge the price on the PDP anchor (sh-price--lg base + PDP scale). */
.sh-pdp__price .sh-price__amount { font-size: clamp(24px, 3.4vw, 30px); font-weight: 700; }

.sh-pdp__short {
  margin: 0 0 var(--sh-space-4);
  color: var(--c-text);
  max-width: 60ch;
  line-height: 1.55;
}

/* --- Variant selectors ---------------------------------------- */
.sh-variants {
  display: flex;
  flex-direction: column;
  gap: var(--sh-space-4);
  margin-bottom: var(--sh-space-4);
}
.sh-variant { border: 0; margin: 0; padding: 0; min-width: 0; }
.sh-variant__label {
  display: flex;
  align-items: baseline;
  gap: var(--sh-space-2);
  padding: 0;
  margin-bottom: var(--sh-space-2);
  font-weight: 600;
  font-size: 14px;
}
.sh-variant__chosen { color: var(--c-muted); font-weight: 400; }
.sh-variant__options {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sh-space-2);
}

/* The radio itself is visually hidden; the <label> is the control. */
.sh-variant__input {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
  pointer-events: none;
}

/* Chip option (size / generic axes). */
.sh-variant__option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--sh-tap);
  min-height: var(--sh-tap);
  padding: 0 var(--sh-space-3);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--sh-surface);
  color: var(--c-text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: border-color var(--sh-dur) var(--ease), background var(--sh-dur) var(--ease), box-shadow var(--sh-dur) var(--ease);
}
.sh-variant__option:hover { border-color: var(--c-text); }

/* Checked state (radio :checked toggles the label). */
.sh-variant__input:checked + .sh-variant__swatch,
.sh-variant__option:has(.sh-variant__input:checked) {
  border-color: var(--c-blue);
  box-shadow: 0 0 0 1px var(--c-blue) inset;
}

/* Keyboard focus ring on the label when its radio is focused. */
.sh-variant__option:has(.sh-variant__input:focus-visible) {
  outline: 2px solid var(--sh-focus);
  outline-offset: 2px;
}

/* Swatch option (color). --sh-swatch set inline per value. */
.sh-variant__option--swatch {
  min-width: 40px;
  width: 40px; height: 40px;
  padding: 3px;
  border-radius: var(--sh-radius-pill);
}
.sh-variant__swatch {
  display: block;
  width: 100%; height: 100%;
  border-radius: var(--sh-radius-pill);
  background: var(--sh-swatch, var(--sh-surface-2));
  border: 1px solid rgba(0, 0, 0, .1);
}

/* Unavailable / out-of-stock combo (P2.5 adds .is-unavailable). */
.sh-variant__option.is-unavailable {
  opacity: .45;
  cursor: not-allowed;
  text-decoration: line-through;
}
.sh-variant__option.is-unavailable .sh-variant__swatch { text-decoration: none; }

.sh-variants__hint { margin: 0; color: var(--sh-warning); font-size: 13px; }

/* --- Availability / delivery ---------------------------------- */
.sh-pdp__avail {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sh-space-2) var(--sh-space-4);
  margin-bottom: var(--sh-space-4);
  font-size: 14px;
}
.sh-pdp__stock { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.sh-pdp__stock--in  { color: var(--sh-success); }
.sh-pdp__stock--low { color: var(--sh-warning); }
.sh-pdp__stock--oos { color: var(--sh-danger); }
.sh-pdp__delivery { display: inline-flex; align-items: center; gap: 6px; color: var(--c-muted); }

/* --- Qty stepper + actions ------------------------------------ */
.sh-pdp__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: var(--sh-space-3);
  margin-bottom: var(--sh-space-4);
}
.sh-qty {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex: 0 0 auto;
}
.sh-qty__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--sh-tap);
  min-height: 52px;
  border: 0;
  background: var(--sh-surface);
  color: var(--c-text);
  font-size: 16px;
  cursor: pointer;
}
.sh-qty__btn:hover { background: var(--c-bg-soft); }
.sh-qty__input {
  width: 52px;
  border: 0;
  border-inline: 1px solid var(--c-border);
  text-align: center;
  font: inherit;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.sh-qty__input::-webkit-outer-spin-button,
.sh-qty__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.sh-pdp__add { flex: 1 1 220px; }

.sh-pdp__wish {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px; min-height: 52px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--sh-surface);
  color: var(--c-text);
  font-size: 18px;
  cursor: pointer;
  transition: color var(--sh-dur) var(--ease), border-color var(--sh-dur) var(--ease);
}
.sh-pdp__wish:hover,
.sh-pdp__wish[aria-pressed="true"] { color: var(--sh-sale); border-color: var(--sh-sale); }
.sh-pdp__wish[aria-pressed="true"] .bi::before { content: "\f417"; } /* bi-heart-fill */

/* --- Trust row ------------------------------------------------- */
.sh-pdp__trust {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sh-space-2) var(--sh-space-4);
  margin: 0;
  padding: var(--sh-space-3) 0 0;
  list-style: none;
  border-top: 1px solid var(--c-border);
  color: var(--c-muted);
  font-size: 13px;
}
.sh-pdp__trust li { display: inline-flex; align-items: center; gap: 6px; }
.sh-pdp__trust .bi { color: var(--sh-success); }

/* Global visible focus for PDP interactive controls (never removed). */
.sh-pdp a:focus-visible,
.sh-pdp button:focus-visible,
.sh-pdp input:focus-visible {
  outline: 2px solid var(--sh-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* =============================================================== *
 * Tabs
 * =============================================================== */
.sh-pdp__tabs { margin-top: var(--sh-space-7); }
.sh-tabs__nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sh-space-1);
  border-bottom: 1px solid var(--c-border);
  overflow-x: auto;
}
.sh-tabs__tab {
  padding: var(--sh-space-3) var(--sh-space-4);
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--c-muted);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}
.sh-tabs__tab:hover { color: var(--c-text); }
.sh-tabs__tab.is-active { color: var(--c-text); border-bottom-color: var(--c-blue); }

.sh-tabs__panel { padding: var(--sh-space-5) 0; }
/* Without JS every panel stays visible (stacked). P2.5 hides inactive ones by
   adding [hidden]; the anchor jump still works either way. */

.sh-prose { max-width: 70ch; line-height: 1.6; color: var(--c-text); }
.sh-prose p { margin: 0 0 var(--sh-space-3); }
.sh-prose :is(h2, h3) { margin: var(--sh-space-4) 0 var(--sh-space-2); }
.sh-prose ul, .sh-prose ol { margin: 0 0 var(--sh-space-3) 1.25em; }

.sh-pdp__empty-note { color: var(--c-muted); font-style: italic; margin: 0; }

/* Specs table. */
.sh-specs {
  width: 100%;
  max-width: 640px;
  border-collapse: collapse;
  font-size: 14px;
}
.sh-specs th, .sh-specs td {
  padding: var(--sh-space-3);
  text-align: left;
  border-bottom: 1px solid var(--c-border);
  vertical-align: top;
}
.sh-specs th { width: 40%; color: var(--c-muted); font-weight: 600; }

/* Reviews summary + empty state. */
.sh-reviews__summary { margin-bottom: var(--sh-space-4); }
.sh-reviews__avg { display: flex; align-items: center; gap: var(--sh-space-2); }
.sh-reviews__avg strong { font-size: 28px; font-weight: 700; }
.sh-reviews__count { color: var(--c-muted); font-size: 14px; }

.sh-pdp__empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--sh-space-2);
  padding: var(--sh-space-6) var(--sh-space-4);
  color: var(--c-muted);
}
.sh-pdp__empty-state .bi { font-size: 32px; color: var(--c-border); }
.sh-pdp__empty-state p { margin: 0; max-width: 40ch; }

/* =============================================================== *
 * Cross-sell / up-sell / related rails
 * =============================================================== */
.sh-pdp__rail { margin-top: var(--sh-space-7); }
.sh-pdp__rail-title {
  margin: 0 0 var(--sh-space-4);
  font-size: clamp(18px, 2vw, 22px);
  font-weight: 700;
}
/* Reuses .sh-grid; grid columns come from shop-components.css. */

/* =============================================================== *
 * Sticky add-to-cart bar (revealed by P2.5 on scroll)
 * =============================================================== */
.sh-pdp__sticky {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: var(--sh-z-header);
  background: var(--sh-surface);
  border-top: 1px solid var(--c-border);
  box-shadow: 0 -2px 12px rgba(10, 23, 51, .08);
  padding: var(--sh-space-2) 0;
}
.sh-pdp__sticky[hidden] { display: none; }
.sh-pdp__sticky-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sh-space-3);
}
.sh-pdp__sticky-media { display: flex; align-items: center; gap: var(--sh-space-3); min-width: 0; }
.sh-pdp__sticky-media img { border-radius: var(--radius-sm); flex: 0 0 auto; object-fit: cover; }
.sh-pdp__sticky-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sh-pdp__sticky-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40vw;
}
.sh-pdp__sticky-add { width: auto; flex: 0 0 auto; }

/* Hide the on-page price label duplication inside the compact sticky bar. */
.sh-pdp__sticky-price .sh-price__tax { display: none; }

/* =============================================================== *
 * Fancybox / Swiper scoping (keep vendored CSS from leaking)
 * =============================================================== */
.sh-gallery .swiper { width: 100%; }

/* =============================================================== *
 * Responsive — md: larger thumbs; lg: two-column split with sticky gallery
 * =============================================================== */
@media (min-width: 768px) {
  .sh-gallery__thumb { width: 80px; height: 80px; }
}

@media (min-width: 1024px) {
  .sh-pdp__top {
    flex-direction: row;
    align-items: flex-start;
    gap: var(--sh-space-7);
  }
  .sh-pdp__gallery {
    flex: 1 1 52%;
    position: sticky;
    top: calc(var(--header-h, 72px) + var(--sh-space-4));
    align-self: flex-start;
  }
  .sh-pdp__info { flex: 1 1 48%; }

  /* On desktop the sticky bottom bar is less necessary; still available but
     narrower priority. Keep it functional (P2.5 decides reveal threshold). */
  .sh-pdp__sticky-name { max-width: 320px; }
}

@media (min-width: 1280px) {
  .sh-pdp__gallery { flex-basis: 55%; }
  .sh-pdp__info { flex-basis: 45%; padding-left: var(--sh-space-4); }
}

/* Reduced motion: neutralize any enhancement transitions. */
@media (prefers-reduced-motion: reduce) {
  .sh-variant__option,
  .sh-gallery__thumb,
  .sh-pdp__wish { transition: none; }
}
