/* Phox Woo Builder: the Quick View popup.

   ONE overlay (#pwb-qv) printed in wp_footer by includes/parts/quickview.php,
   filled by quickview.js. Everything themable is a custom property or a
   single-class rule, so the design controls of the button that opened the
   popup (css.twig, written as `.<button class> .pwb-qv__...`) always win.
   Properties set on the overlay by the script from the opening button:
   --pwb-qv-w (dialog width) --pwb-qv-maxh (max height) --pwb-qv-img (image
   column). From css.twig: --pwb-qv-radius. Colours read the house tokens
   (pwb-base.css); the popup is a white surface and sets its own text colour. */

html.pwb-qv-locked { overflow: hidden; scrollbar-gutter: stable; }

.pwb-qv {
  position: fixed;
  inset: 0;
  z-index: var(--pwb-qv-z, 999990);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  visibility: hidden;
  opacity: 0;
  transition: opacity .2s ease, visibility 0s linear .2s;
  color: var(--pwb-text, #222);
  font-size: var(--pwb-font, 15px);
  line-height: 1.5;
}
.pwb-qv.is-open { visibility: visible; opacity: 1; transition-delay: 0s; }
.pwb-qv--nav { padding-inline: 60px; }
.pwb-qv__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); }

.pwb-qv__dialog {
  position: relative;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  width: min(var(--pwb-qv-w, 960px), 100%);
  max-height: min(var(--pwb-qv-maxh, 90vh), calc(100vh - 32px));
  max-height: min(var(--pwb-qv-maxh, 90vh), calc(100dvh - 32px));
  overflow: hidden;
  container-type: inline-size;
  container-name: pwbqv;
  border-radius: var(--pwb-qv-radius, 12px);
  background: var(--pwb-surface, #fff);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
  color: var(--pwb-text, #222);
  outline: none;
  transform: translateY(14px) scale(.985);
  transition: transform .24s ease;
}
.pwb-qv.is-open .pwb-qv__dialog { transform: none; }
.pwb-qv__scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.pwb-qv__content { padding: 28px; }
.pwb-qv__content:empty { padding: 0; }

/* ---- Close and next / previous ---- */
.pwb-qv .pwb-qv__close,
.pwb-qv .pwb-qv__nav {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--pwb-surface, #fff);
  color: var(--pwb-text, #222);
  -webkit-text-fill-color: currentColor;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .18);
  line-height: 1;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: background-color .2s ease, color .2s ease, transform .2s ease;
}
.pwb-qv .pwb-qv__close { position: absolute; top: 12px; right: 12px; z-index: 10; width: 40px; height: 40px; font-size: 20px; }
.pwb-qv .pwb-qv__close:where(:hover, :focus-visible),
.pwb-qv .pwb-qv__nav:where(:hover, :focus-visible) { background: var(--pwb-primary, #222); color: var(--pwb-primary-text, #fff); }
.pwb-qv .pwb-qv__close:focus-visible,
.pwb-qv .pwb-qv__nav:focus-visible { outline: 2px solid var(--pwb-focus, var(--pwb-primary-border, var(--pwb-primary, #222))); outline-offset: 2px; }
.pwb-qv__close .pwb-icon, .pwb-qv__nav .pwb-icon { display: block; width: 1em; height: 1em; }
.pwb-qv .pwb-qv__nav { position: absolute; top: 50%; z-index: 2; width: 44px; height: 44px; margin-top: -22px; font-size: 22px; }
.pwb-qv .pwb-qv__nav[hidden] { display: none; }
.pwb-qv .pwb-qv__nav[disabled] { opacity: .35; cursor: not-allowed; }
.pwb-qv__nav--prev { left: max(8px, calc(50% - min(var(--pwb-qv-w, 960px), 100vw - 120px) / 2 - 58px)); }
.pwb-qv__nav--next { right: max(8px, calc(50% - min(var(--pwb-qv-w, 960px), 100vw - 120px) / 2 - 58px)); }

/* ---- Loading ---- */
.pwb-qv__loader { position: absolute; inset: 0; z-index: 6; display: none; align-items: center; justify-content: center; pointer-events: none; }
.pwb-qv.is-loading .pwb-qv__loader { display: flex; }
.pwb-qv__spin {
  width: 34px;
  height: 34px;
  border: 3px solid var(--pwb-line, rgba(0, 0, 0, .15));
  border-top-color: var(--pwb-primary, #222);
  border-radius: 50%;
  animation: pwb-qv-spin .7s linear infinite;
}
@keyframes pwb-qv-spin { to { transform: rotate(360deg); } }
@keyframes pwb-qv-shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.pwb-qv__skeleton { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; min-height: 360px; }
.pwb-qv__skeleton i, .pwb-qv__skeleton b {
  display: block;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--pwb-surface-2, #f1f1f1) 25%, color-mix(in srgb, var(--pwb-surface-2, #f1f1f1) 55%, #fff) 50%, var(--pwb-surface-2, #f1f1f1) 75%);
  background-size: 200% 100%;
  animation: pwb-qv-shimmer 1.4s linear infinite;
}
.pwb-qv__skeleton b { aspect-ratio: 1 / 1; border-radius: 12px; }
.pwb-qv__skeleton span { display: grid; align-content: start; gap: 14px; }
.pwb-qv__skeleton i { height: 18px; }
.pwb-qv__skeleton i:nth-child(1) { width: 80%; height: 28px; }
.pwb-qv__skeleton i:nth-child(2) { width: 30%; }
.pwb-qv__skeleton i:nth-child(4) { width: 90%; }
.pwb-qv__skeleton i:nth-child(5) { height: 44px; margin-top: 12px; }
.pwb-qv__error { padding: 40px 12px; text-align: center; }
.pwb-qv__error p { margin: 0 0 16px; }

/* ---- Built-in layout ---- */
.pwb-qv__layout { display: grid; grid-template-columns: minmax(0, var(--pwb-qv-img, 50%)) minmax(0, 1fr); gap: 32px; align-items: start; }
.pwb-qv__layout--no-media { grid-template-columns: minmax(0, 1fr); }
.pwb-qv__media { min-width: 0; }
.pwb-qv__info { display: flex; flex-direction: column; align-items: stretch; gap: 14px; min-width: 0; }
.pwb-qv__title { margin: 0; padding-right: 44px; font-size: 1.6em; font-weight: 700; line-height: 1.25; color: inherit; }
.pwb-qv__price { font-size: 1.3em; font-weight: 700; line-height: 1.3; }
.pwb-qv__price .price { font: inherit; color: inherit; }
.pwb-qv__price del { margin-right: 4px; font-size: .8em; font-weight: 400; opacity: .6; }
.pwb-qv__price ins { text-decoration: none; color: var(--pwb-accent-text, #b83c0b); }
.pwb-qv__layout--has-price .woocommerce-variation-price { display: none; }
.pwb-qv__excerpt { color: var(--pwb-soft, inherit); }
.pwb-qv__excerpt > :first-child { margin-top: 0; }
.pwb-qv__excerpt > :last-child { margin-bottom: 0; }
.pwb-qv__form { min-width: 0; }
.pwb-qv__wishlist { display: flex; }
.pwb-qv__meta { display: grid; gap: 2px; padding-top: 12px; border-top: 1px solid var(--pwb-line); font-size: var(--pwb-font-sm, 13px); color: var(--pwb-soft); }
.pwb-qv__meta a { color: inherit; }
.pwb-qv__meta-label { font-weight: 600; }
.pwb-qv__link { align-self: flex-start; color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.pwb-qv__link:where(:hover, :focus-visible) { color: var(--pwb-accent-text, #b83c0b); }

.pwb-qv__rating { display: flex; align-items: center; gap: 8px; }
.pwb-qv__stars { position: relative; display: inline-block; font-size: 16px; line-height: 1; letter-spacing: .1em; white-space: nowrap; }
.pwb-qv__stars::before { content: "\2605\2605\2605\2605\2605"; color: var(--pwb-border, #e5e5e5); }
.pwb-qv__stars::after { content: "\2605\2605\2605\2605\2605"; position: absolute; left: 0; top: 0; width: var(--pwb-qv-rating, 0%); overflow: hidden; color: var(--pwb-star, #f5a623); }
.pwb-qv__count { font-size: var(--pwb-font-sm, 13px); color: var(--pwb-soft); }

/* ---- Builder: the built-in popup drawn in place (Preview The Popup) ---- */
.pwb-qv.pwb-qv--static {
  position: relative;
  inset: auto;
  z-index: auto;
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 16px;
  visibility: visible;
  opacity: 1;
  overflow: hidden;
  border-radius: 8px;
  pointer-events: none;
}
.pwb-qv--static .pwb-qv__backdrop { z-index: 0; }
.pwb-qv--static .pwb-qv__dialog { z-index: 1; margin: 0 auto; max-height: none; transform: none; }
.pwb-qv--static .pwb-qv__scroll { overflow: visible; }
.pwb-qv--static .pwb-qv__close { cursor: default; }

/* Stack image above details when the popup itself is narrow */
@container pwbqv (max-width: 480px) {
  .pwb-qv__layout, .pwb-qv__skeleton { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .pwb-qv__content { padding: 20px; }
  /* the close button sits over the top right of a full-width image: park the gallery's expand button at the bottom */
  .pwb-qv__media .pwb-gallery__expand { top: auto; bottom: 10px; }
}

/* ---- Phones: bottom sheet (default) or full screen ---- */
@media (max-width: 599px) {
  .pwb-qv--nav { padding-inline: 16px; }
  /* Previous / next product: two 44px buttons in a header row at the top of the sheet (JS sets --pwb-qv-nav-top to the dialog's top edge). */
  .pwb-qv .pwb-qv__nav {
    top: calc(var(--pwb-qv-nav-top, 0px) + 10px);
    margin-top: 0;
    z-index: 11;
    opacity: 0;
    transition: opacity .2s ease .12s, background-color .2s ease, color .2s ease;
  }
  .pwb-qv.is-open .pwb-qv__nav { opacity: 1; }
  .pwb-qv .pwb-qv__nav[disabled] { opacity: .35; }
  .pwb-qv .pwb-qv__nav--prev { left: 12px; right: auto; }
  .pwb-qv .pwb-qv__nav--next { left: 64px; right: auto; }
  .pwb-qv--nav .pwb-qv__content { padding-top: 64px; }
  .pwb-qv--sheet { padding: 0; align-items: flex-end; }
  .pwb-qv--sheet .pwb-qv__dialog {
    width: 100%;
    height: calc(100vh - 16px);
    height: calc(100dvh - 16px);
    max-height: none;
    border-radius: var(--pwb-qv-radius, 16px) var(--pwb-qv-radius, 16px) 0 0;
    transform: translateY(100%);
  }
  .pwb-qv--sheet.is-open .pwb-qv__dialog { transform: none; }
  .pwb-qv--sheet .pwb-qv__content { padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
}

@media (max-width: 599px) {
  .pwb-qv--full { padding: 0; align-items: stretch; }
  .pwb-qv--full .pwb-qv__dialog {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    transform: translateY(24px);
  }
  .pwb-qv--full.is-open .pwb-qv__dialog { transform: none; }
  .pwb-qv--full .pwb-qv__content { padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
}

/* The next / previous product slides in from the side it was swiped to. */
@keyframes pwb-qv-in-next { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
@keyframes pwb-qv-in-prev { from { opacity: 0; transform: translateX(-28px); } to { opacity: 1; transform: none; } }
.pwb-qv__content.is-slide-next { animation: pwb-qv-in-next .22s ease-out; }
.pwb-qv__content.is-slide-prev { animation: pwb-qv-in-prev .22s ease-out; }

@media (prefers-reduced-motion: reduce) {
  .pwb-qv, .pwb-qv__dialog, .pwb-qv .pwb-qv__nav { transition: none; }
  .pwb-qv__content.is-slide-next, .pwb-qv__content.is-slide-prev { animation: none; }
  .pwb-qv__spin, .pwb-qv__skeleton i, .pwb-qv__skeleton b { animation-duration: 3s; }
}
