/* ==========================================================================
   Phượt 4P — Studio Lightbox Pro (`css/vf-lightbox-pro.css`)
   Shared native `<dialog closedby="any">` luxury media viewer for PDP & Catalog.
   Synchronized with `var(--vf-blue)` and all 7 Vietnam Holiday Modes.
   ========================================================================== */

dialog.p4p-lightbox {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  max-width: 100dvw;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #f8fafc;
  font-family: var(--p4p-font, "Plus Jakarta Sans", system-ui, -apple-system, sans-serif);
  user-select: none;
  -webkit-user-select: none;
  opacity: 0;
  /* MANDATORY: transition display and overlay for top-layer elements */
  transition-property: opacity, transform, display, overlay;
  transition-duration: 0.26s;
  transition-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
  transition-behavior: allow-discrete;
}

@media (prefers-reduced-motion: no-preference) {
  dialog.p4p-lightbox {
    transform: scale(0.97);
  }
}

/* Scope display strictly to [open] so closed state stays hidden */
dialog.p4p-lightbox[open] {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* MANDATORY: Prevent scroll chaining to underlying page without locking html/body */
dialog.p4p-lightbox:modal {
  overflow: hidden;
  overscroll-behavior: contain;
}

dialog.p4p-lightbox::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background-color: rgba(6, 9, 15, 0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  transition-property: background-color, backdrop-filter, display, overlay;
  transition-duration: 0.26s;
  transition-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
  transition-behavior: allow-discrete;
}

/* Open state + @starting-style entry + :not([data-closing]) exit fallback */
dialog.p4p-lightbox[open]:where(:not([data-closing])) {
  opacity: 1;

  @starting-style {
    opacity: 0;
  }

  @media (prefers-reduced-motion: no-preference) {
    transform: scale(1);

    @starting-style {
      transform: scale(0.97);
    }
  }
}

dialog.p4p-lightbox[open]:where(:not([data-closing]))::backdrop {
  background-color: rgba(6, 9, 15, 0.93);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);

  @starting-style {
    background-color: rgba(6, 9, 15, 0);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
  }
}

@media (prefers-reduced-motion: reduce) {
  dialog.p4p-lightbox,
  dialog.p4p-lightbox::backdrop {
    transition-duration: 0.1s;
  }
}

/* Subtle studio ambient vignette inside dialog shell */
.p4p-lb-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 44%, rgba(30, 41, 59, 0.24) 0%, rgba(6, 9, 15, 0.45) 72%, rgba(4, 6, 11, 0.72) 100%);
  overflow: hidden;
}

/* ── Top Architectural Glass Bar ─────────────────────────────────────────── */
.p4p-lb-topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) clamp(14px, 2.5vw, 28px) 10px;
  pointer-events: none;
}

.p4p-lb-topbar > * {
  pointer-events: auto;
}

.p4p-lb-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.p4p-lb-counter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 15px;
  border-radius: 999px;
  background: rgba(15, 20, 28, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #f8fafc;
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
  white-space: nowrap;
}

.p4p-lb-counter-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--vf-blue, #1464f4);
  box-shadow: 0 0 10px var(--vf-blue, #1464f4);
  flex-shrink: 0;
}

.p4p-lb-zoom-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  min-width: 52px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(15, 20, 28, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.p4p-lb-zoom-pill:hover,
.p4p-lb-zoom-pill.is-zoomed {
  border-color: var(--vf-blue, #1464f4);
  color: #ffffff;
  background: rgba(20, 100, 244, 0.22);
}

.p4p-lb-title-center {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: rgba(248, 250, 252, 0.78);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-inline: 12px;
  pointer-events: none;
}

.p4p-lb-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(15, 20, 28, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.13);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.36);
}

.p4p-lb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: #e2e8f0;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease, transform 160ms ease, opacity 160ms ease;
}

.p4p-lb-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  transform: translateY(-1px);
}

.p4p-lb-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.p4p-lb-btn:focus-visible {
  outline: 2px solid var(--vf-blue, #1464f4);
  outline-offset: 2px;
}

.p4p-lb-btn:disabled {
  opacity: 0.34;
  cursor: not-allowed;
}

.p4p-lb-btn--sep {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.14);
  margin-inline: 2px;
  pointer-events: none;
}

.p4p-lb-btn--close {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.p4p-lb-btn--close:hover:not(:disabled) {
  background: var(--vf-blue, #1464f4);
  border-color: var(--vf-blue, #1464f4);
  color: #ffffff;
}

/* ── Main Studio Stage ───────────────────────────────────────────────────── */
.p4p-lb-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
  padding: 6px clamp(16px, 5vw, 84px);
}

.p4p-lb-viewport {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  will-change: transform;
}

.p4p-lb-img-frame {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
  transform-origin: center center;
  will-change: transform;
}

.p4p-lb-img {
  display: block;
  max-width: min(88vw, 1280px);
  max-height: calc(100dvh - 210px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.62), 0 0 0 1px rgba(255, 255, 255, 0.12);
  cursor: zoom-in;
  -webkit-user-drag: none;
  touch-action: none;
  transition: opacity 180ms ease;
}

dialog.p4p-lightbox.is-single .p4p-lb-img {
  max-height: calc(100dvh - 150px);
}

dialog.p4p-lightbox.is-zoomed .p4p-lb-img {
  cursor: grab;
  border-radius: 4px;
}

dialog.p4p-lightbox.is-dragging .p4p-lb-img {
  cursor: grabbing;
}

.p4p-lb-img.is-loading {
  opacity: 0.35;
}

.p4p-lb-spinner {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--vf-blue, #1464f4);
  animation: p4pLbSpin 0.7s linear infinite;
  pointer-events: none;
  opacity: 0;
  transition: opacity 160ms ease;
}

.p4p-lb-spinner.is-visible {
  opacity: 1;
}

@keyframes p4pLbSpin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* Prev / Next Floating Studio Arrows */
.p4p-lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 15;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(15, 20, 28, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #ffffff;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.42);
  transition: background-color 180ms ease, border-color 180ms ease, transform 180ms ease, opacity 180ms ease;
}

.p4p-lb-nav:hover {
  background: var(--vf-blue, #1464f4);
  border-color: var(--vf-blue, #1464f4);
  transform: translateY(-50%) scale(1.06);
}

.p4p-lb-nav:active {
  transform: translateY(-50%) scale(0.95);
}

.p4p-lb-nav:focus-visible {
  outline: 2px solid var(--vf-blue, #1464f4);
  outline-offset: 2px;
}

.p4p-lb-nav--prev {
  left: clamp(10px, 2vw, 26px);
}

.p4p-lb-nav--next {
  right: clamp(10px, 2vw, 26px);
}

dialog.p4p-lightbox.is-single .p4p-lb-nav {
  display: none;
}

/* ── Bottom Dock: Caption + Variant/Price + Filmstrip ────────────────────── */
.p4p-lb-bottom {
  position: relative;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 8px clamp(12px, 2.5vw, 28px) max(14px, env(safe-area-inset-bottom));
  pointer-events: none;
}

.p4p-lb-bottom > * {
  pointer-events: auto;
}

.p4p-lb-caption-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  max-width: min(92vw, 820px);
  padding: 9px 18px;
  border-radius: 12px;
  background: rgba(15, 20, 28, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.42);
  text-align: center;
}

.p4p-lb-caption-bar:empty,
.p4p-lb-caption-bar[hidden] {
  display: none;
}

.p4p-lb-caption-text {
  font-size: 13.5px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.01em;
  line-height: 1.35;
}

.p4p-lb-caption-sub {
  font-size: 11.5px;
  font-weight: 600;
  color: rgba(203, 213, 225, 0.8);
}

.p4p-lb-price-wrap {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  font-variant-numeric: tabular-nums;
}

.p4p-lb-price {
  font-family: var(--p4p-price-font, "Chakra Petch", "Plus Jakarta Sans", sans-serif);
  font-size: 16.5px;
  font-weight: 800;
  color: var(--p4p-price-color, #ee4d2d);
  line-height: 1;
}

.p4p-lb-base-price {
  font-family: var(--p4p-price-font, "Chakra Petch", "Plus Jakarta Sans", sans-serif);
  font-size: 12px;
  font-weight: 600;
  color: rgba(203, 213, 225, 0.48);
  text-decoration: line-through;
}

/* Filmstrip Thumbnails */
.p4p-lb-filmstrip {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(94vw, 920px);
  padding: 6px 10px;
  border-radius: 12px;
  background: rgba(15, 20, 28, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.11);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.24) transparent;
}

.p4p-lb-filmstrip::-webkit-scrollbar {
  height: 4px;
}

.p4p-lb-filmstrip::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.24);
  border-radius: 999px;
}

dialog.p4p-lightbox.is-single .p4p-lb-filmstrip {
  display: none;
}

.p4p-lb-thumb {
  position: relative;
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  padding: 3px;
  border-radius: 7px;
  border: 2px solid transparent;
  background: #ffffff;
  overflow: hidden;
  cursor: pointer;
  opacity: 0.54;
  transition: opacity 160ms ease, border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.p4p-lb-thumb:hover {
  opacity: 0.92;
  transform: translateY(-2px);
}

.p4p-lb-thumb.is-active {
  opacity: 1;
  border-color: var(--vf-blue, #1464f4);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.22), 0 6px 16px rgba(0, 0, 0, 0.4);
  transform: translateY(-2px);
}

.p4p-lb-thumb:focus-visible {
  outline: 2px solid var(--vf-blue, #1464f4);
  outline-offset: 2px;
}

.p4p-lb-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

/* Subtle keyboard hint on desktop */
.p4p-lb-hint {
  font-size: 10.5px;
  font-weight: 600;
  color: rgba(203, 213, 225, 0.56);
  letter-spacing: 0.03em;
}

/* Toast notification inside top-layer dialog (always visible above backdrop!) */
.p4p-lb-toast {
  position: absolute;
  top: 68px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  z-index: 30;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(15, 20, 28, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  white-space: nowrap;
}

.p4p-lb-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Responsive Mobile Polish (390px & below) ────────────────────────────── */
@media (max-width: 768px) {
  .p4p-lb-title-center,
  .p4p-lb-hint,
  .p4p-lb-btn[data-lb-action="reset"] {
    display: none;
  }

  .p4p-lb-topbar {
    gap: 8px;
    padding: max(10px, env(safe-area-inset-top)) 12px 6px;
  }

  .p4p-lb-counter {
    height: 34px;
    padding: 0 11px;
    font-size: 11.5px;
  }

  .p4p-lb-zoom-pill {
    height: 34px;
    min-width: 44px;
    padding: 0 9px;
    font-size: 11px;
  }

  .p4p-lb-toolbar {
    gap: 2px;
    padding: 3px;
  }

  .p4p-lb-btn {
    width: 34px;
    height: 34px;
    font-size: 13px;
  }

  .p4p-lb-stage {
    padding: 4px 10px;
  }

  .p4p-lb-img {
    max-width: 94vw;
    max-height: calc(100dvh - 196px);
    border-radius: 8px;
  }

  .p4p-lb-nav {
    width: 38px;
    height: 38px;
    font-size: 14px;
  }

  .p4p-lb-nav--prev {
    left: 8px;
  }

  .p4p-lb-nav--next {
    right: 8px;
  }

  .p4p-lb-caption-bar {
    padding: 7px 14px;
    gap: 4px 10px;
  }

  .p4p-lb-caption-text {
    font-size: 12.5px;
  }

  .p4p-lb-price {
    font-size: 14.5px;
  }

  .p4p-lb-thumb {
    width: 46px;
    height: 46px;
  }
}
