/* ============================================================
   D_ART PRODUCT DETAIL — full-screen piece view
   ============================================================ */

.product-detail {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--paper);
  color: var(--ink);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  opacity: 0;
  /* NOTE: no `transform` and no `will-change: transform` here.
     A transform on this element breaks `position: sticky` on the
     topbar (browsers create a containing block for transformed
     ancestors), and `will-change: transform` keeps that containing
     block alive forever, even after the transition finishes.
     That was why the topbar misbehaved until a page refresh. */
  transition: opacity .4s cubic-bezier(.16,1,.3,1);
}
.product-detail[hidden] { display: none !important; }
.product-detail.is-open { opacity: 1; }

body.pd-open { overflow: hidden !important; }

/* Subtle ambient color behind the sheet */
.product-detail::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 12% 8%, rgba(200,145,43,.10), transparent 40%),
    radial-gradient(circle at 88% 92%, rgba(145,62,53,.08), transparent 40%);
  z-index: 0;
}

/* ---------- Top bar ---------- */
.pd-topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(20px, 4vw, 56px);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.pd-back {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: none;
  color: var(--ink);
  font: 500 11px var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 8px 4px;
  transition: color .2s ease, transform .2s ease;
}
.pd-back span:first-child {
  font-size: 18px;
  color: var(--gold);
  transition: transform .25s cubic-bezier(.16,1,.3,1);
}
.pd-back:hover { color: var(--gold); }
.pd-back:hover span:first-child { transform: translateX(-4px); }

.pd-topbar-brand {
  font: 700 13px var(--sans);
  letter-spacing: -.02em;
}
.pd-topbar-brand em {
  font-family: var(--serif);
  color: var(--gold);
  font-style: italic;
}

.pd-share-top {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  font: 500 10px var(--mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .2s ease, border-color .2s ease, transform .2s ease;
}
.pd-share-top:hover {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  transform: translateY(-1px);
}
.pd-share-top span { color: var(--gold); margin-left: 6px; }

/* ---------- Main grid ---------- */
.pd-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr);
  gap: clamp(28px, 5vw, 72px);
  padding: clamp(28px, 5vw, 64px) clamp(20px, 4vw, 56px) clamp(40px, 6vw, 80px);
  max-width: 1500px;
  margin: 0 auto;
}

/* ---------- Gallery ---------- */
.pd-gallery {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.pd-main-wrap {
  position: relative;
  aspect-ratio: 4 / 5;
  background: linear-gradient(135deg, rgba(233,226,212,.7), rgba(200,145,43,.08));
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(23,36,34,.12), 0 0 0 1px rgba(200,145,43,.14);
  /* transform-origin so the entrance animation doesn't jump */
  transform-origin: center top;
}

.pd-main-img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity .35s ease;
}
.pd-main-img.is-fading { opacity: 0; }

/* Crossfade stack for smooth gallery transitions */
.pd-img-stack {
  position: absolute;
  inset: 0;
}
.pd-img-stack img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity .55s cubic-bezier(.16,1,.3,1), transform .8s ease;
  transform: scale(1.02);
}
.pd-img-stack img.is-active {
  opacity: 1;
  transform: scale(1);
}

/* Nav arrows */
.pd-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(244,240,232,.4);
  background: rgba(23,36,34,.55);
  color: var(--paper);
  font-size: 22px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 3;
  opacity: 0;
  transition: opacity .25s ease, background .2s ease, transform .2s ease, color .2s ease;
}
.pd-main-wrap:hover .pd-nav { opacity: 1; }
.pd-nav:hover {
  background: var(--gold);
  color: var(--ink);
  border-color: var(--gold);
  transform: translateY(-50%) scale(1.06);
}
.pd-nav-prev { left: 16px; }
.pd-nav-next { right: 16px; }

.pd-count {
  position: absolute;
  bottom: 14px; right: 16px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(23,36,34,.6);
  color: var(--paper);
  font: 10px var(--mono);
  letter-spacing: .12em;
  z-index: 3;
}

.pd-badge {
  position: absolute;
  top: 14px; left: 14px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--gold);
  color: var(--ink);
  font: 600 9px var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  z-index: 3;
}

/* Thumbnails */
.pd-thumbs {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.pd-thumbs::-webkit-scrollbar { display: none; }

.pd-thumb {
  flex: 0 0 auto;
  width: 74px;
  height: 92px;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid transparent;
  background: none;
  padding: 0;
  cursor: pointer;
  opacity: .6;
  transition: opacity .2s ease, border-color .25s ease, transform .25s ease;
}
.pd-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.pd-thumb:hover { opacity: 1; transform: translateY(-2px); }
.pd-thumb.is-active {
  opacity: 1;
  border-color: var(--gold);
}

/* ---------- Details column ---------- */
.pd-details {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding-top: clamp(4px, 2vw, 16px);
  min-width: 0;
}

.pd-eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font: 500 10px var(--mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--gold);
}
.pd-eyebrow::before {
  content: '';
  width: 22px; height: 1px;
  background: var(--gold);
}

.pd-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(34px, 4.4vw, 60px);
  letter-spacing: -.03em;
  line-height: 1;
  color: var(--ink);
}

.pd-subtitle {
  margin: -8px 0 0;
  font: 500 11px var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #7a8782;
}

.pd-price {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 12px 0 4px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 20px;
  flex-wrap: wrap;
}
.pd-price .price-original {
  font: 400 12px var(--mono);
  text-decoration: line-through;
  color: #8e978f;
}
.pd-price strong {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(24px, 2.6vw, 34px);
  letter-spacing: -.02em;
}
.pd-price .pd-save {
  font: 500 10px var(--mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--rust);
  background: rgba(145,62,53,.1);
  padding: 4px 8px;
  border-radius: 999px;
}

.pd-description {
  font-size: 15px;
  line-height: 1.75;
  color: #52605a;
  margin: 0;
  white-space: pre-line;
}

/* Specs */
.pd-specs {
  display: grid;
  gap: 20px;
  padding: 8px 0;
}

.pd-spec {
  display: grid;
  gap: 10px;
}
.pd-spec[hidden] { display: none; }

.pd-spec-label {
  font: 500 10px var(--mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #7a8782;
}

.pd-spec-value {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
}

.pd-sizes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pd-size-chip {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 10px 16px;
  border-radius: 999px;
  font: 500 11px var(--mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease, transform .2s ease;
}
.pd-size-chip:hover { border-color: var(--ink); transform: translateY(-1px); }
.pd-size-chip.is-selected {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.pd-measurements {
  font: 12px/1.75 var(--mono);
  color: #52605a;
  background: rgba(23,36,34,.04);
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  white-space: pre-wrap;
  margin: 0;
  overflow-x: auto;
}

/* Actions */
.pd-actions {
  display: flex;
  gap: 12px;
  align-items: stretch;
  flex-wrap: wrap;
  padding-top: 8px;
}

.pd-order {
  flex: 1 1 auto;
  min-width: 220px;
  justify-content: center;
}

.pd-share {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  padding: 15px 22px;
  font: 500 11px var(--mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, transform .2s ease;
}
.pd-share:hover {
  background: var(--ink);
  color: var(--paper);
  transform: translateY(-2px);
}
.pd-share span:last-child { color: var(--gold); }

.pd-note {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-top: 4px;
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(200,145,43,.08);
  border: 1px solid rgba(200,145,43,.2);
}
.pd-note-dot {
  flex: 0 0 auto;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--gold);
  margin-top: 5px;
  box-shadow: 0 0 10px rgba(200,145,43,.6);
  animation: pd-note-pulse 2s ease-in-out infinite;
}
@keyframes pd-note-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .6; transform: scale(1.3); }
}
.pd-note p {
  margin: 0;
  font: 12px/1.6 var(--mono);
  color: #52605a;
}

/* ---------- Entrance animations ---------- */
/* The outer .product-detail only fades in (no transform — that
   would break the sticky topbar). Details and gallery get their
   own nested rise animations instead. */

.product-detail.is-open .pd-eyebrow,
.product-detail.is-open .pd-title,
.product-detail.is-open .pd-subtitle,
.product-detail.is-open .pd-price,
.product-detail.is-open .pd-description,
.product-detail.is-open .pd-specs,
.product-detail.is-open .pd-actions,
.product-detail.is-open .pd-note {
  animation: pd-rise .7s cubic-bezier(.16,1,.3,1) both;
}
.product-detail.is-open .pd-eyebrow { animation-delay: .05s; }
.product-detail.is-open .pd-title { animation-delay: .1s; }
.product-detail.is-open .pd-subtitle { animation-delay: .13s; }
.product-detail.is-open .pd-price { animation-delay: .16s; }
.product-detail.is-open .pd-description { animation-delay: .2s; }
.product-detail.is-open .pd-specs { animation-delay: .24s; }
.product-detail.is-open .pd-actions { animation-delay: .28s; }
.product-detail.is-open .pd-note { animation-delay: .32s; }

.product-detail.is-open .pd-gallery {
  animation: pd-rise .8s .08s cubic-bezier(.16,1,.3,1) both;
}

.product-detail.is-open .pd-main-wrap {
  animation: pd-gallery-in .8s cubic-bezier(.16,1,.3,1) both;
}

@keyframes pd-rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pd-gallery-in {
  from { opacity: 0; transform: translateY(24px) scale(.97); }
  to { opacity: 1; transform: none; }
}

/* ---------- Related pieces ---------- */
.pd-related {
  position: relative;
  z-index: 1;
  padding: clamp(40px, 6vw, 80px) clamp(20px, 4vw, 56px) clamp(60px, 8vw, 110px);
  border-top: 1px solid var(--line);
  max-width: 1500px;
  margin: 0 auto;
}
.pd-related[hidden] { display: none !important; }

.pd-related-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}
.pd-related-head h2 {
  margin: 14px 0 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(30px, 4vw, 52px);
  letter-spacing: -.03em;
  line-height: 1;
}
.pd-related-head h2 em {
  color: var(--gold);
  font-style: italic;
}

.pd-related-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(14px, 2vw, 24px);
}
@media (max-width: 800px) {
  .pd-related-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.pd-related-card {
  position: relative;
  border: 0;
  background: none;
  padding: 0;
  text-align: left;
  cursor: pointer;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform .3s cubic-bezier(.16,1,.3,1);
}
.pd-related-card:hover { transform: translateY(-4px); }

.pd-related-image {
  position: relative;
  aspect-ratio: 4 / 5;
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(233,226,212,.7), rgba(200,145,43,.08));
  box-shadow: 0 14px 32px rgba(23,36,34,.08);
}
.pd-related-image img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .8s ease;
}
.pd-related-card:hover .pd-related-image img { transform: scale(1.05); }

.pd-related-name {
  font-family: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: .04em;
  text-transform: uppercase;
  line-height: 1.15;
  margin: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}
.pd-related-price {
  margin: 0;
  font: 500 10px var(--mono);
  letter-spacing: .1em;
  color: #7a8782;
}

/* ---------- Toast ---------- */
.pd-toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: var(--paper);
  padding: 12px 20px;
  border-radius: 999px;
  font: 500 11px var(--mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease, transform .4s cubic-bezier(.16,1,.3,1);
  box-shadow: 0 16px 40px rgba(23,36,34,.3);
}
.pd-toast.is-show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Mobile ---------- */
@media (max-width: 1000px) {
  .pd-grid {
    grid-template-columns: 1fr;
    gap: 30px;
    padding-top: 24px;
  }
  .pd-main-wrap { aspect-ratio: 3 / 4; }
  .pd-topbar-brand { display: none; }
}

@media (max-width: 600px) {
  .pd-topbar { padding: 12px 16px; }
  .pd-share-top { padding: 7px 11px; font-size: 9px; }
  .pd-back { font-size: 10px; letter-spacing: .1em; }
  .pd-nav { width: 38px; height: 38px; font-size: 18px; opacity: 1; }
  .pd-nav-prev { left: 10px; }
  .pd-nav-next { right: 10px; }
  .pd-thumb { width: 60px; height: 74px; }
  .pd-actions { flex-direction: column; }
  .pd-order { min-width: 0; width: 100%; }
  .pd-share { width: 100%; justify-content: center; }
  .pd-measurements { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .product-detail { transition: opacity .2s ease; }
  .product-detail.is-open .pd-eyebrow,
  .product-detail.is-open .pd-title,
  .product-detail.is-open .pd-subtitle,
  .product-detail.is-open .pd-price,
  .product-detail.is-open .pd-description,
  .product-detail.is-open .pd-specs,
  .product-detail.is-open .pd-actions,
  .product-detail.is-open .pd-note,
  .product-detail.is-open .pd-gallery,
  .product-detail.is-open .pd-main-wrap { animation: none; }
  .pd-note-dot { animation: none; }
}