/* ═══════════════════════════════════════════════════════════════════════
   PRODUCT DETAIL PAGE — page-scoped rules only.
   Loaded LAST (see _Layout.cshtml's Styles section, after layout.css) —
   every rule below composes tokens.css/theme.css/components.css, never
   redeclares a colour, radius, spacing or shadow. Nothing here is a new
   design decision; it is composition of the existing 5-layer system for
   one page's specific arrangement (gallery + purchase panel + selectors).
   ═══════════════════════════════════════════════════════════════════════ */

.pdp { padding-block: var(--space-2) var(--space-16); }

/* §79 حرفيا: 620 معرض + 40 فجوة + 620 معلومات = 1280. القياس قبل هذا الإصلاح
   على 1440: 656 / 536 — نسبة 11fr:9fr القديمة أعطت معرضا أعرض ولوحة شراء أضيق
   من المواصفة. و1280 هو عرض الحاوية القصوى، لكن .container يحجز 24px حشوة لكل
   جهة، فالمتاح داخله 1232 لا 1280؛ الخروج من الحشوة بهامش سالب يعيد الصندوق
   الداخلي إلى 1280 بالضبط فتتحقق أرقام المؤسس بلا فيضان — نفس الأسلوب المستعمل
   في .cart-layout على /checkout. */
.pdp-layout {
    display: grid;
    grid-template-columns: 620px 620px;
    gap: 40px;
    align-items: start;
    margin-inline: calc(-1 * var(--container-padding));
}
@media (max-width: 1279px) {
    /* تحت عرض الحاوية الكامل: نسبة مرنة بدل أرقام صلبة تفيض. */
    .pdp-layout {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        margin-inline: 0;
    }
}
@media (max-width: 900px) { /* --bp-lg */
    .pdp-layout { grid-template-columns: 1fr; gap: var(--space-8); }
}

/* ── Gallery ──────────────────────────────────────────────────────────────
   Today every product resolves to exactly ONE image (CatalogArtwork.ForProductDetail
   — a real photo when the ERP has one, otherwise category artwork, never a broken/
   empty placeholder). The single-image state is deliberately generous (large tray,
   centred, padded) so it reads as a staged product photo, not a missing gallery;
   the thumbnail row only renders at all once Images.Count > 1 (Product.cshtml). ── */

.pdp-gallery {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    position: sticky;
    top: 80px;
}
@media (max-width: 900px) { /* --bp-lg */ .pdp-gallery { position: static; } }

.pdp-gallery__main {
    position: relative;
    aspect-ratio: var(--ratio-square);
    background: var(--tray);
    border: var(--card-border, 1px solid var(--line));
    border-radius: var(--card-radius, var(--radius-md));
    overflow: hidden;
}
.pdp-gallery__main img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: var(--space-10);
    transition: opacity var(--duration-base) var(--ease-standard);
}

/* Share + wishlist cluster, pinned to the frame's top corner. .pdp-gallery__main
   already carries position:relative above; .icon-btn/.wish-heart are the existing
   44×44 circular primitives (components.css/wishlist.css) — only the placement is
   page-specific here (Q9: compose, do not redeclare the buttons themselves). */
.pdp-gallery__actions {
    position: absolute;
    top: var(--space-3);
    inset-inline-end: var(--space-3);
    z-index: 2;
    display: flex;
    gap: var(--space-2);
}
.pdp-gallery__actions .icon-btn,
.pdp-gallery__actions .wish-heart {
    background: var(--paper);
    border-color: var(--line);
}

.pdp-gallery__thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}
.pdp-gallery__thumb {
    width: 72px;
    height: 72px;
    flex: 0 0 auto;
    padding: var(--space-2);
    background: var(--tray);
    border: 2px solid var(--line);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color var(--duration-fast) var(--ease-standard);
}
.pdp-gallery__thumb img { width: 100%; height: 100%; object-fit: contain; }
.pdp-gallery__thumb:hover { border-color: var(--ink-soft); }
.pdp-gallery__thumb.is-active { border-color: var(--brand); }

/* ── Purchase panel ───────────────────────────────────────────────────────── */

/* الفجوة 20px بين أحد عشر عنصرا أعطت لوحة بارتفاع 1077 بجوار معرض 656 — أي
   421px فراغ ميت إلى جانب الصورة. 12px تجعل اللوحة كثيفة كما في مرفق المؤسس،
   حيث العنوان والتقييم والتوفر والسعر والخيارات والأزرار تُقرأ ككتلة واحدة. */
.pdp-panel { display: flex; flex-direction: column; gap: var(--space-3); }

.pdp-panel__brand {
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--brand);
    margin: 0;
}
.pdp-panel__title {
    font-size: var(--text-3xl);
    font-weight: var(--weight-bold);
    color: var(--ink);
    line-height: var(--leading-snug);
}
@media (max-width: 900px) { /* --bp-lg — one type-scale step down once the gallery stacks above */
    .pdp-panel__title { font-size: var(--text-2xl); }
    .pdp-price .price__whole { font-size: 1.9rem; }
}
.pdp-panel__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1) var(--space-3);
    font-size: var(--text-sm);
    color: var(--ink-soft);
}
.pdp-panel__meta strong { color: var(--ink); font-weight: var(--weight-semibold); }
.pdp-panel__meta .sep { color: var(--ink-faint); }

/* Large price block — same .price primitives as the product card, scaled up
   via one wrapper class (Q9: compose, do not redeclare). */
.pdp-price { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--space-3); }
.pdp-price .price__whole { font-size: 2.4rem; }
.pdp-price .price__fraction { font-size: 1.1rem; }
.pdp-price .price__currency { font-size: var(--text-lg); }
.pdp-price .price__unit { font-size: var(--text-base); }
.pdp-price .price__compare { font-size: var(--text-base); }

/* Discount badge — same var(--gold)/var(--neutral-900) pairing as components.css's
   .badge-discount, but position:static since this one sits inline in the price row
   instead of pinned to a card corner (Q9: same colour contract, different layout
   context — not a redefinition of the token pairing). */
.pdp-discount-badge {
    display: inline-flex;
    align-items: center;
    background: var(--gold);
    color: var(--neutral-900);
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
}

.pdp-availability { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-base); }
.pdp-availability__reason { font-size: var(--text-sm); color: var(--ink-soft); }

/* ── Variant selectors — the heart of the screen ─────────────────────────── */

.pdp-selectors {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    padding-block: var(--space-5);
    border-block: 1px solid var(--line);
}

.pdp-selector__legend {
    display: flex;
    align-items: baseline;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
    font-size: var(--text-base);
    font-weight: var(--weight-bold);
    color: var(--ink);
}
.pdp-selector__value { font-weight: var(--weight-regular); color: var(--ink-soft); }

.pdp-options { display: flex; flex-wrap: wrap; gap: var(--space-3); }

/* Colour swatch — a ring on selection, never a colour change on the swatch
   itself (colour IS the identity being chosen; changing it would lie). */
.pdp-swatch {
    position: relative;
    width: 42px;
    height: 42px;
    padding: 3px;
    border-radius: 50%;
    border: 2px solid transparent;
    background: var(--paper);
    cursor: pointer;
    transition: border-color var(--duration-fast) var(--ease-standard);
}
.pdp-swatch__fill {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 1px solid var(--line-strong);
}
.pdp-swatch:hover:not(.is-disabled) { border-color: var(--line-strong); }
.pdp-swatch.is-selected { border-color: var(--brand); }
.pdp-swatch.is-disabled {
    cursor: not-allowed;
    opacity: .4;
}
.pdp-swatch.is-disabled::after {
    content: "";
    position: absolute;
    inset-inline-start: 4px;
    inset-inline-end: 4px;
    top: 50%;
    height: 2px;
    background: var(--danger-base);
    transform: rotate(-45deg);
}

/* Text/pill option — size, capacity, etc. */
.pdp-option {
    min-width: 44px;
    height: 44px;
    padding-inline: var(--space-4);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-strong);
    background: var(--paper);
    color: var(--ink);
    font: inherit;
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    cursor: pointer;
    transition: border-color var(--duration-fast) var(--ease-standard),
                background var(--duration-fast) var(--ease-standard),
                color var(--duration-fast) var(--ease-standard);
}
.pdp-option:hover:not(.is-disabled) { border-color: var(--brand); }
.pdp-option.is-selected { border-color: var(--brand); background: var(--brand-tint); color: var(--brand-deep); }
.pdp-option.is-disabled {
    cursor: not-allowed;
    color: var(--ink-faint);
    background: var(--paper-muted);
    text-decoration: line-through;
}

/* ── Quantity stepper ─────────────────────────────────────────────────────── */

.pdp-qty {
    display: inline-flex;
    align-items: stretch;
    width: fit-content;
    min-height: 44px; /* stretches __btn and __input to a real tap/click target (WCAG 2.5.5) */
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.pdp-qty__btn {
    width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--paper-muted);
    border: 0;
    font-size: 1.15rem;
    color: var(--ink);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-standard);
}
.pdp-qty__btn:hover:not(:disabled) { background: var(--brand-tint); color: var(--brand-deep); }
.pdp-qty__btn:disabled { opacity: .4; cursor: not-allowed; }
.pdp-qty__input {
    width: 54px;
    text-align: center;
    border: 0;
    border-inline: 1px solid var(--line-strong);
    font: inherit;
    font-size: var(--text-base);
    color: var(--ink);
    background: var(--paper);
}
.pdp-qty__input:focus { outline: none; background: var(--brand-tint); }

/* ── CTA row + honest notes (Q42) ─────────────────────────────────────────── */

.pdp-cta-row { display: flex; flex-direction: column; gap: var(--space-3); }
.pdp-cta-row .btn { width: 100%; }

/* Primary — gold fill, dark ink text (founder comp). Composes .btn (shape/size/
   :disabled opacity already handled there) with a page-specific colour pair,
   same color-mix(...,black) hover pattern components.css already uses on
   .btn--danger:hover (Q9 — not a new convention). */
.pdp-cta--primary { background: var(--gold); color: var(--neutral-900); }
.pdp-cta--primary:hover:not(:disabled) { background: color-mix(in srgb, var(--gold) 88%, black); }
.pdp-cta--primary:active:not(:disabled) { transform: translateY(1px); }

/* Secondary — transparent with a brand-navy outline (founder comp: "اشتر الآن"). */
.pdp-cta--secondary { background: transparent; color: var(--brand); border: 1px solid var(--brand); }
.pdp-cta--secondary:hover:not(:disabled) { background: var(--brand-tint); }

.pdp-note {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    font-size: var(--text-sm);
    color: var(--ink-soft);
    line-height: var(--leading-normal);
}
.pdp-note--reason { color: var(--danger-base); }
.pdp-note .icon { flex: 0 0 auto; margin-top: 2px; }

/* ── Facts strip (unit / category / tax) ─────────────────────────────────── */

.pdp-facts {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: .5rem var(--space-4);
    font-size: var(--text-sm);
    padding-block: var(--space-4);
    border-top: 1px solid var(--line);
}
.pdp-facts dt { color: var(--ink-soft); }
.pdp-facts dd { margin: 0; color: var(--ink); font-weight: var(--weight-medium); }

/* ── Description ──────────────────────────────────────────────────────────── */

.pdp-description {
    margin-top: var(--space-12);
    max-width: 72ch;
}
.pdp-description h2 {
    font-size: var(--text-xl);
    font-weight: var(--weight-bold);
    color: var(--ink);
    margin-bottom: var(--space-3);
}
.pdp-description p {
    font-size: var(--text-md);
    color: var(--ink-soft);
    line-height: var(--leading-relaxed);
    white-space: pre-line;
}

/* ── Mobile refinements (<480px, --bp-xs) ─────────────────────────────────────
   NOTE — the thumbnail strip itself (.pdp-gallery__thumbs) is not touched at this
   breakpoint: mobile.css (loaded LAST, after this file) already replaces it with
   a swipeable single-image track + dots for the entire ≤900px range (§4 in that
   file) and hides .pdp-gallery__thumbs outright, so any thumbnail-sizing rule
   added here would never paint — that would be dead CSS (Q46), not a real fix. */
@media (max-width: 480px) { /* --bp-xs */
    /* Image reads full-bleed inside the frame — the frame itself already spans
       the full container gutter (grid child, no fixed width anywhere above). */
    .pdp-gallery__main img { padding: var(--space-4); }
    .pdp-cta-row { gap: var(--space-2); }
}
