/* Product details: shared by /product/{slug} and the product modal. Colours come from config/theme.php (--mx-*). */

.pd { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: clamp(20px, 3.4vw, 40px); align-items: start; }
.pd-gallery { position: sticky; top: 16px; display: grid; gap: 10px; min-width: 0; }
.pd-stage { position: relative; display: grid; aspect-ratio: 1; place-items: center; overflow: hidden; border-radius: 20px; background: var(--mx-surface-muted, #f4f6f8); }
.pd-stage img { width: 100%; height: 100%; padding: 6%; object-fit: contain; }
.pd-stage > .bi { color: var(--mx-muted); font-size: 72px; }
.pd-deal { position: absolute; top: 14px; left: 14px; z-index: 1; padding: 5px 10px; color: #fff; border-radius: 999px; background: var(--mx-danger); font-size: 12px; font-weight: 800; }
.pd-nav { position: absolute; top: 50%; display: grid; width: 40px; height: 40px; place-items: center; color: var(--mx-ink); border: 1px solid var(--mx-border); border-radius: 50%; background: rgba(255,255,255,.92); cursor: pointer; transform: translateY(-50%); transition: background .15s, transform .15s; }
.pd-nav:hover { background: #fff; transform: translateY(-50%) scale(1.06); }
.pd-prev { left: 12px; }
.pd-next { right: 12px; }
.pd-thumbs { display: flex; gap: 8px; padding: 2px; overflow-x: auto; scrollbar-width: thin; }
.pd-thumbs button { flex: 0 0 64px; width: 64px; height: 64px; padding: 4px; overflow: hidden; border: 1.5px solid var(--mx-border); border-radius: 12px; background: #fff; cursor: pointer; }
.pd-thumbs button[hidden] { display: none; }
.pd-thumbs button[aria-pressed="true"] { border-color: var(--mx-primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--mx-primary) 22%, transparent); }
.pd-thumbs img { width: 100%; height: 100%; object-fit: contain; }

.pd-info { display: grid; gap: 14px; min-width: 0; }
.pd-kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 0; color: var(--mx-muted); font-size: 13px; font-weight: 700; }
.pd-kicker > span:not(.condition-label) + span:not(.condition-label)::before { content: ""; display: inline-block; width: 4px; height: 4px; margin-right: 12px; vertical-align: middle; border-radius: 50%; background: currentColor; opacity: .5; }
.pd-title { margin: -4px 0 0; font-size: clamp(24px, 3vw, 32px); line-height: 1.15; }
.pd-price-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.pd-price { margin: 0; color: var(--mx-ink); font-size: clamp(26px, 3.2vw, 32px); font-weight: 800; letter-spacing: -.01em; }
.pd-price small { color: var(--mx-muted); font-size: 14px; font-weight: 700; }
.pd-compare, .pd-offer, .pd-min, .pd-sku { margin: -6px 0 0; font-size: 13px; }
.pd-offer { color: var(--mx-danger); font-weight: 700; }
.pd-sku { color: var(--mx-muted); }
.pd-stock { display: inline-flex; width: max-content; align-items: center; gap: 6px; margin: -4px 0 0; padding: 5px 11px; border-radius: 999px; font-size: 13px; font-weight: 800; }
.pd-stock.is-in { color: var(--mx-success); background: color-mix(in srgb, var(--mx-success) 12%, transparent); }
.pd-stock.is-low { color: #9a5b00; background: color-mix(in srgb, var(--mx-warning) 18%, transparent); }
.pd-stock.is-out { color: var(--mx-danger); background: color-mix(in srgb, var(--mx-danger) 10%, transparent); }

.pd-option { margin: 0; padding: 0; border: 0; min-width: 0; }
.pd-option legend { margin-bottom: 8px; padding: 0; color: var(--mx-muted); font-size: 13px; font-weight: 700; }
.pd-option legend strong { color: var(--mx-ink); }
.pd-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.pd-chip { display: inline-grid; min-width: 84px; min-height: 48px; gap: 1px; place-content: center; padding: 8px 14px; color: var(--mx-ink); text-align: center; border: 1.5px solid var(--mx-border); border-radius: 12px; background: #fff; cursor: pointer; transition: border-color .15s, background .15s; }
.pd-chip strong { font-size: 14px; }
.pd-chip small { color: var(--mx-muted); font-size: 11px; font-weight: 600; }
.pd-chip small:empty { display: none; }
.pd-chip:hover { border-color: color-mix(in srgb, var(--mx-primary) 55%, var(--mx-border)); }
.pd-chip[aria-pressed="true"] { border-color: var(--mx-primary); background: color-mix(in srgb, var(--mx-primary) 8%, #fff); box-shadow: inset 0 0 0 1px var(--mx-primary); }
.pd-chip.is-soldout strong, .pd-swatch.is-soldout em { text-decoration: line-through; }
.pd-chip.is-soldout, .pd-chip.is-unavailable { color: var(--mx-muted); }
.pd-chip.is-unavailable { border-style: dashed; background: var(--mx-surface-muted, #f6f7f9); }

.pd-swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.pd-swatch { position: relative; display: grid; width: 44px; height: 44px; place-items: center; padding: 0; border: 1.5px solid var(--mx-border); border-radius: 50%; background: #fff; cursor: pointer; }
.pd-swatch span { width: 32px; height: 32px; border-radius: 50%; background: var(--swatch, #d9dee3); box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.pd-swatch em { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.pd-swatch[aria-pressed="true"] { border-color: var(--mx-primary); box-shadow: 0 0 0 2px var(--mx-primary); }
.pd-swatch.is-soldout::after, .pd-swatch.is-unavailable::after { content: ""; position: absolute; width: 2px; height: 38px; border-radius: 2px; background: var(--mx-muted); transform: rotate(45deg); }
.pd-swatch.is-unavailable span { opacity: .45; }
.pd-missing { margin: -4px 0 0; color: var(--mx-muted); font-size: 12px; }

.pd-buy { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin: 2px 0 0; }
.pd-qty { display: grid; gap: 5px; }
.pd-qty label { color: var(--mx-muted); font-size: 12px; font-weight: 700; }
.pd-qty .stepper { border-radius: 12px; }
.pd-qty .stepper button { width: 42px; height: 50px; }
.pd-qty .stepper input { width: 48px; min-height: 50px; }
.pd-add { display: inline-flex; flex: 1 1 200px; min-height: 52px; align-items: center; justify-content: center; gap: 8px; font-size: 16px; }
.pd-add[disabled] { cursor: not-allowed; opacity: .55; }
.pd-add[aria-busy="true"] { opacity: .75; }
.pd-added, .pd-error { margin: -4px 0 0; font-size: 14px; font-weight: 700; }
.pd-added { color: var(--mx-success); }
.pd-added a { margin-left: 6px; color: var(--mx-primary); }
.pd-error { color: var(--mx-danger); }

.pd-lipa { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--mx-border); border-radius: 16px; background: var(--mx-surface-muted, #f7f9fa); }
.pd-lipa-head { display: flex; align-items: center; gap: 10px; }
.pd-lipa-head p { margin: 2px 0 0; color: var(--mx-muted); font-size: 12px; }
.pd-lipa-row { display: flex; gap: 8px; }
.pd-lipa-row select { flex: 1; min-height: 44px; }
.pd-lipa-row .btn-secondary[disabled] { opacity: .55; }
.pd-description { padding-top: 14px; border-top: 1px solid var(--mx-border); }
.pd-description h3 { margin: 0 0 6px; font-size: 15px; }
.pd-description p { margin: 0; color: var(--mx-ink); font-size: 14px; line-height: 1.65; }

/* Modal */
html.pd-locked { overflow: hidden; }
.pd-dialog { width: min(1080px, calc(100vw - 40px)); max-width: none; max-height: calc(100dvh - 40px); padding: 0; overflow: hidden; color: var(--mx-ink); border: 0; border-radius: 24px; background: #fff; box-shadow: 0 30px 90px rgba(0,0,0,.28); }
.pd-dialog[open] { display: flex; flex-direction: column; animation: pd-in .18s ease-out; }
.pd-dialog::backdrop { background: rgba(8, 22, 16, .58); backdrop-filter: blur(2px); }
.pd-dialog-body { flex: 1; min-height: 240px; padding: clamp(18px, 3vw, 32px); overflow-y: auto; overscroll-behavior: contain; }
.pd-dialog .pd-gallery { top: 0; }
.pd-close { position: absolute; top: 12px; right: 12px; z-index: 3; display: grid; width: 42px; height: 42px; place-items: center; color: var(--mx-ink); border: 1px solid var(--mx-border); border-radius: 50%; background: rgba(255,255,255,.95); cursor: pointer; font-size: 16px; }
.pd-close:hover { background: var(--mx-surface-muted, #f2f4f6); }
.pd-dialog-status { display: flex; min-height: 200px; align-items: center; justify-content: center; gap: 10px; margin: 0; color: var(--mx-muted); font-weight: 700; }
.pd-dialog-status.is-error { color: var(--mx-danger); }
.pd-spinner { width: 20px; height: 20px; border: 3px solid var(--mx-border); border-top-color: var(--mx-primary); border-radius: 50%; animation: pd-spin .8s linear infinite; }
@keyframes pd-spin { to { transform: rotate(360deg); } }
@keyframes pd-in { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .pd-dialog[open], .pd-spinner { animation: none; } }

@media (max-width: 760px) {
  .pd { grid-template-columns: 1fr; gap: 16px; }
  .pd-gallery { position: static; }
  .pd-stage { border-radius: 16px; }
  .pd-dialog { width: 100vw; max-height: 100dvh; height: 100dvh; margin: 0; border-radius: 0; }
  .pd-dialog-body { padding: 14px 14px 0; }
  .pd-in-modal .pd-buy { position: sticky; bottom: 0; z-index: 2; margin: 0 -14px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--mx-border); background: #fff; }
  .pd-in-modal .pd-description { padding-bottom: 16px; }
  .pd-chip { min-width: 74px; }
}

/* Product cards: "From" price and colour dots */
.price-from { color: var(--mx-muted); font-size: .72em; font-weight: 700; }
.card-swatches { display: flex; align-items: center; gap: 4px; margin: 4px 0 0; }
.card-swatches i { width: 12px; height: 12px; border-radius: 50%; background: var(--swatch, #d9dee3); box-shadow: inset 0 0 0 1px rgba(0,0,0,.16); }
.card-swatches em { color: var(--mx-muted); font-size: 11px; font-style: normal; font-weight: 700; }
.pd-lipa-row select { border-radius: 12px; }

/* Buy + Add to cart */
.pd-actions { display: flex; flex: 1 1 280px; gap: 10px; }
.pd-actions .pd-add { flex: 1 1 0; }
.pd-buy-now { display: inline-flex; flex: 1 1 0; min-height: 52px; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; color: var(--mx-primary); border: 0; border-radius: 12px; background: var(--mx-secondary); box-shadow: 0 8px 18px color-mix(in srgb, var(--mx-secondary) 30%, transparent); font: inherit; font-size: 16px; font-weight: 800; cursor: pointer; transition: background .15s, transform .15s; }
.pd-buy-now:hover { background: color-mix(in srgb, var(--mx-secondary) 85%, #fff); transform: translateY(-1px); }
.pd-buy-now[disabled] { cursor: not-allowed; opacity: .55; transform: none; box-shadow: none; }
.pd-buy-now:focus-visible { outline: 3px solid var(--mx-primary); outline-offset: 2px; }

.product-card-link { display: contents; color: inherit; text-decoration: none; }
.product-card:has(.product-card-link:focus-visible) { outline: 3px solid var(--mx-secondary); outline-offset: 2px; }
.card-actions { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 6px; margin: 0; padding: 0 11px 11px; }
.product-card > .card-actions { padding: 0 12px 12px; grid-column: 1 / -1; }
.card-actions .home-cart-button { width: 100%; margin: 0; }
.product-card .card-actions .home-cart-button { min-height: 38px; color: var(--mx-primary); background: var(--mx-secondary); font-size: 12px; }
.product-card .card-actions .home-cart-button:hover { background: color-mix(in srgb, var(--mx-secondary) 85%, #fff); }
.card-buy { display: flex; min-height: 37px; align-items: center; justify-content: center; padding: 7px 8px; color: var(--mx-primary); border: 1.5px solid var(--mx-primary); border-radius: 7px; background: #fff; font: inherit; font-size: 9px; font-weight: 800; text-decoration: none; cursor: pointer; white-space: nowrap; }
.product-card .card-buy { min-height: 38px; font-size: 12px; }
.card-buy:hover { color: #fff; background: var(--mx-primary); }
.card-actions .home-cart-button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 760px) {
  .pd-in-modal .pd-buy { flex-wrap: nowrap; gap: 8px; }
  .pd-in-modal .pd-qty label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .pd-in-modal .pd-qty .stepper button { width: 34px; height: 46px; }
  .pd-in-modal .pd-qty .stepper input { width: 36px; min-height: 46px; }
  .pd-in-modal .pd-actions { flex: 1 1 auto; gap: 8px; min-width: 0; }
  .pd-in-modal .pd-add, .pd-in-modal .pd-buy-now { min-height: 46px; padding: 8px 6px; font-size: 13px; min-width: 0; }
  .pd-in-modal .pd-actions i { display: none; }
}
.home-product-card > .card-actions, .product-card > .card-actions { display: grid; }
.pd-actions .pd-add, .pd-buy-now { padding-inline: 10px; font-size: 15px; white-space: nowrap; }
@media (max-width: 420px) {
  .card-actions .home-cart-button i { display: none; }
  .card-actions { grid-template-columns: minmax(0, .75fr) minmax(0, 1.25fr); }
}
