﻿/* ===========================================================
   PRODUCT DETAIL PAGE
   Layered on top of product.css. Owns the price block, gallery,
   variant pickers, tabs, specs, reviews and the mobile buy bar.
   =========================================================== */

/* ---------- Design tokens (scoped to the page wrapper class) ---------- */
.product-page {
    --pd-ink: #111;
    --pd-ink-soft: #555;
    --pd-muted: #8a8a8a;
    --pd-line: #e6e6e6;
    --pd-line-soft: #f0f0f0;
    --pd-bg: #fff;
    --pd-bg-alt: #fafafa;
    --pd-sale: #c0392b;
    --pd-sale-soft: #fdf1f0;
    --pd-success: #1f7a4d;
    --pd-radius: 10px;
    --pd-radius-sm: 6px;
    --pd-shadow-sm: 0 1px 2px rgba(17, 17, 17, .06);
    --pd-shadow: 0 6px 24px rgba(17, 17, 17, .08);
    --pd-shadow-lg: 0 18px 48px rgba(17, 17, 17, .14);
    --pd-ease: cubic-bezier(.2, .7, .3, 1);
}

/* ===========================================================
   1. PRICE BLOCK
   The .price-now / .price-was / .price-save components themselves live in
   header.css so every page shares them. Only the product-page sizing that
   overrides them belongs here.
   =========================================================== */
.pd-price .price-now { font-size: 28px; }
.pd-price .price-was  { font-size: 19px; }

.pd-rel-price .price-now { font-size: 16px; }
.pd-rel-price .price-was  { font-size: 13px; margin-left: 6px; }

.product-price .price-now { font-size: 24px; }
.product-price .price-was-inline { font-size: 15px; }

/* Tint the headline when there is a real saving. */
.pd-price:has(.price-save) .price-now { color: var(--pd-sale, #c0392b); }

/* ===========================================================
   2. LAYOUT / BREADCRUMB
   =========================================================== */
.product-page {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 40px 80px;
}

.pd-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 24px 0 4px;
    font-size: 13px;
    color: var(--pd-muted, #8a8a8a);
}

.pd-breadcrumb a {
    color: inherit;
    text-decoration: none;
    transition: color .18s var(--pd-ease);
}
.pd-breadcrumb a:hover { color: var(--pd-ink, #111); }
.pd-breadcrumb span[aria-current] { color: var(--pd-ink-soft, #555); }

.pd-top {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
    gap: 56px;
    align-items: start;
    padding-top: 12px;
}

/* ===========================================================
   3. GALLERY
   =========================================================== */
.product-gallery { position: sticky; top: 24px; }

.gallery-main {
    position: relative;
    border-radius: var(--pd-radius, 10px);
    overflow: hidden;
    background: var(--pd-bg-alt, #fafafa);
    box-shadow: var(--pd-shadow-sm);
}

.gallery-main-inner {
    display: block;
    aspect-ratio: 1 / 1;
    overflow: hidden;
}

.gallery-main-inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .5s var(--pd-ease), opacity .3s var(--pd-ease);
}

/* Gentle zoom on hover, skipped on touch devices. */
@media (hover: hover) and (pointer: fine) {
    .gallery-main:hover .gallery-main-inner img { transform: scale(1.04); }
}

.gallery-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, .92);
    color: var(--pd-ink, #111);
    box-shadow: var(--pd-shadow-sm);
    cursor: pointer;
    opacity: 0;
    transition: opacity .22s var(--pd-ease), background .2s, transform .2s var(--pd-ease);
}

.gallery-main:hover .gallery-arrow,
.gallery-arrow:focus-visible { opacity: 1; }

.gallery-arrow:hover { background: #fff; transform: translateY(-50%) scale(1.08); }
.gallery-prev { left: 14px; }
.gallery-next { right: 14px; }

/* A single scrolling row of fixed-size squares. The previous
   grid-auto-flow:column + grid-auto-columns:1fr divided the strip into N
   equal columns, so 18-24 thumbs collapsed to roughly 25px each. */
.gallery-thumbnails {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    padding: 0 0 6px;
    list-style: none;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
    scrollbar-color: #cfcfcf transparent;
    -webkit-overflow-scrolling: touch;
}

.gallery-thumbnails::-webkit-scrollbar { height: 6px; }
.gallery-thumbnails::-webkit-scrollbar-track { background: transparent; }
.gallery-thumbnails::-webkit-scrollbar-thumb { background: #cfcfcf; border-radius: 3px; }
.gallery-thumbnails::-webkit-scrollbar-thumb:hover { background: #b4b4b4; }

.gallery-thumbnails li { margin: 0; flex: 0 0 auto; }

.gallery-thumbnails button,
.gallery-thumbnails .thumb {
    display: block;
    /* flex: 0 0 auto above would stretch the box; pin both axes to 1:1 */
    flex: 0 0 auto;
    width: 76px;
    height: 76px;
    aspect-ratio: 1 / 1;
    padding: 0;
    border: 1.5px solid transparent;
    border-radius: var(--pd-radius-sm, 6px);
    background: var(--pd-bg-alt, #fafafa);
    overflow: hidden;
    cursor: pointer;
    scroll-snap-align: start;
    transition: border-color .2s var(--pd-ease), transform .2s var(--pd-ease);
}

.gallery-thumbnails img {
    width: 100%;
    height: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    object-position: center;
    display: block;
}

.gallery-thumbnails button:hover { transform: translateY(-2px); border-color: var(--pd-line, #e6e6e6); }
.gallery-thumbnails .active,
.gallery-thumbnails button.active { border-color: var(--pd-ink, #111); }

/* ===========================================================
   4. BADGE
   =========================================================== */
.pd-badge {
    display: inline-block;
    padding: 5px 11px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    line-height: 1;
    margin-bottom: 12px;
}

.pd-badge-new  { background: var(--pd-ink, #111); color: #fff; }
.pd-badge-best { background: #f3e9c9; color: #6b5310; }
.pd-badge-sale { background: var(--pd-sale, #c0392b); color: #fff; }

/* ===========================================================
   5. VARIANT PICKERS
   =========================================================== */
.product-info h1 {
    font-size: 26px;
    line-height: 1.25;
    font-weight: 700;
    color: var(--pd-ink, #111);
    margin: 0 0 10px;
    letter-spacing: -.3px;
}

.pd-desc {
    color: var(--pd-ink-soft, #555);
    font-size: 14px;
    line-height: 1.7;
    margin: 14px 0 22px;
}

.option-group { margin-bottom: 22px; }

.color-options { display: flex; flex-wrap: wrap; gap: 10px; }

.color-item {
    width: 34px;
    height: 34px;
    padding: 3px;
    border: 1.5px solid var(--pd-line, #e6e6e6);
    border-radius: 50%;
    cursor: pointer;
    background: none;
    transition: border-color .2s var(--pd-ease), transform .2s var(--pd-ease);
}

.color-item:hover { transform: scale(1.06); border-color: #bbb; }

.color-item.active {
    border-color: var(--pd-ink, #111);
    box-shadow: 0 0 0 2px #fff inset;
}

.color-circle {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .18) inset;
}

.size-btn {
    min-width: 48px;
    height: 42px;
    padding: 0 16px;
    border: 1.5px solid var(--pd-line, #e6e6e6);
    border-radius: var(--pd-radius-sm, 6px);
    background: #fff;
    color: var(--pd-ink-soft, #555);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all .2s var(--pd-ease);
}

.size-btn:hover { border-color: var(--pd-ink, #111); color: var(--pd-ink, #111); }
.size-btn.active { border-color: var(--pd-ink, #111); background: var(--pd-ink, #111); color: #fff; }

/* ===========================================================
   6. QUANTITY + ACTIONS
   =========================================================== */
.pd-qty {
    display: flex;
    align-items: center;
    width: 132px;
    height: 52px;
    border: 1px solid var(--pd-line, #e6e6e6);
    border-radius: var(--pd-radius-sm, 6px);
    overflow: hidden;
    background: #fff;
}

.pd-qty button {
    width: 42px;
    height: 100%;
    border: none;
    background: var(--pd-bg-alt, #fafafa);
    color: var(--pd-ink-soft, #555);
    font-size: 15px;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background .18s, color .18s;
}

.pd-qty button:hover { background: var(--pd-ink, #111); color: #fff; }

.pd-qty input {
    flex: 1;
    min-width: 0;
    border: none;
    background: #fff;
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    color: var(--pd-ink, #111);
    outline: none;
    -moz-appearance: textfield;
}

.pd-qty input::-webkit-outer-spin-button,
.pd-qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.pd-actions { display: flex; gap: 12px; margin: 18px 0 8px; }

.pd-add-to-cart {
    flex: 1;
    height: 52px;
    border: none;
    border-radius: var(--pd-radius-sm, 6px);
    background: var(--pd-ink, #111);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    cursor: pointer;
    transition: background .22s var(--pd-ease), transform .12s var(--pd-ease);
}

.pd-add-to-cart:hover { background: #333; }
.pd-add-to-cart:active { transform: scale(.985); }
.pd-add-to-cart:disabled { background: #bbb; cursor: not-allowed; }
.pd-add-to-cart.is-added { background: var(--pd-success, #1f7a4d); }

.pd-btn-link {
    color: inherit;
    text-decoration: underline;
    margin-left: 6px;
}

.pd-wishlist {
    width: 52px;
    height: 52px;
    flex: none;
    border: 1.5px solid var(--pd-line, #e6e6e6);
    border-radius: var(--pd-radius-sm, 6px);
    background: #fff;
    color: var(--pd-ink-soft, #555);
    font-size: 17px;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: all .2s var(--pd-ease);
}

.pd-wishlist:hover { border-color: var(--pd-ink, #111); color: var(--pd-ink, #111); }
.pd-wishlist.active { color: var(--pd-sale, #c0392b); border-color: var(--pd-sale, #c0392b); }

/* ===========================================================
   7. TRUST / FEATURE STRIP
   =========================================================== */
.feature-icons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    padding: 20px 0 4px;
    margin-top: 18px;
    border-top: 1px solid var(--pd-line-soft, #f0f0f0);
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 11px;
    font-size: 12.5px;
    color: var(--pd-ink-soft, #555);
    line-height: 1.4;
}

.feature-item i,
.feature-item img {
    width: 22px;
    height: 22px;
    flex: none;
    color: var(--pd-ink, #111);
    font-size: 18px;
}

/* ===========================================================
   8. TABS
   =========================================================== */
.pd-tabs { margin-top: 64px; }

.pd-tabs-nav {
    display: flex;
    gap: 30px;
    border-bottom: 1px solid var(--pd-line, #e6e6e6);
    overflow-x: auto;
    scrollbar-width: none;
}

.pd-tabs-nav::-webkit-scrollbar { display: none; }

.pd-tab-btn {
    position: relative;
    padding: 0 0 14px;
    border: none;
    background: none;
    color: var(--pd-muted, #8a8a8a);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    letter-spacing: .8px;
    text-transform: uppercase;
    white-space: nowrap;
    cursor: pointer;
    transition: color .2s var(--pd-ease);
}

.pd-tab-btn::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    background: var(--pd-ink, #111);
    transform: scaleX(0);
    transition: transform .25s var(--pd-ease);
}

.pd-tab-btn:hover { color: var(--pd-ink, #111); }
.pd-tab-btn.active { color: var(--pd-ink, #111); }
.pd-tab-btn.active::after { transform: scaleX(1); }

.pd-tab-panel { display: none; padding: 28px 0 0; }
.pd-tab-panel.active { display: block; animation: pd-fade .28s var(--pd-ease); }

@keyframes pd-fade {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

/* ===========================================================
   9. SPECIFICATIONS
   =========================================================== */
.pd-spec-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 40px;
}

.pd-spec-item {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 13px 0;
    border-bottom: 1px solid var(--pd-line-soft, #f0f0f0);
    font-size: 13.5px;
}

.pd-spec-label { color: var(--pd-muted, #8a8a8a); }
.pd-spec-value { color: var(--pd-ink, #111); font-weight: 600; text-align: right; }

/* ===========================================================
   10. REVIEWS
   =========================================================== */
.reviews-list { display: grid; gap: 16px; }

.pd-review-card {
    padding: 20px 22px;
    border: 1px solid var(--pd-line-soft, #f0f0f0);
    border-radius: var(--pd-radius, 10px);
    background: #fff;
    transition: border-color .2s var(--pd-ease), box-shadow .2s var(--pd-ease);
}

.pd-review-card:hover {
    border-color: var(--pd-line, #e6e6e6);
    box-shadow: var(--pd-shadow-sm);
}

.pd-review-top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.pd-review-avatar {
    width: 38px;
    height: 38px;
    flex: none;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--pd-bg-alt, #fafafa);
    color: var(--pd-ink, #111);
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
}

.pd-review-user { font-size: 13.5px; font-weight: 600; color: var(--pd-ink, #111); }
.pd-review-stars { color: #d4a017; font-size: 12px; letter-spacing: 1px; }
.pd-review-text { font-size: 13.5px; line-height: 1.7; color: var(--pd-ink-soft, #555); margin: 0; }

/* ===========================================================
   11. RELATED PRODUCTS
   =========================================================== */
.pd-related { margin-top: 72px; }
.pd-related-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; }

.pd-rel-card {
    display: block;
    border-radius: var(--pd-radius, 10px);
    overflow: hidden;
    background: #fff;
    text-decoration: none;
    transition: transform .25s var(--pd-ease), box-shadow .25s var(--pd-ease);
}

.pd-rel-card:hover { transform: translateY(-4px); box-shadow: var(--pd-shadow); }

.pd-rel-img { aspect-ratio: 1 / 1; overflow: hidden; background: var(--pd-bg-alt, #fafafa); }
.pd-rel-img img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s var(--pd-ease); }
.pd-rel-card:hover .pd-rel-img img { transform: scale(1.05); }

.pd-rel-info { padding: 14px 4px 4px; }
.pd-rel-info h3 { font-size: 13.5px; font-weight: 600; color: var(--pd-ink, #111); margin: 0 0 6px; line-height: 1.4; }

.pd-rel-colors { display: flex; gap: 5px; margin-top: 9px; }
.pd-rel-colors span { width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, .1) inset; }

/* ===========================================================
   12. ACCESSIBILITY
   =========================================================== */
.product-page :focus-visible {
    outline: 2px solid var(--pd-ink, #111);
    outline-offset: 2px;
    border-radius: 3px;
}

/* ===========================================================
   13. MOBILE BUY BAR
   =========================================================== */
.pd-buybar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    display: none;
    align-items: center;
    gap: 12px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, .97);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--pd-line, #e6e6e6);
    box-shadow: 0 -6px 20px rgba(17, 17, 17, .07);
    transform: translateY(110%);
    transition: transform .3s var(--pd-ease);
}

.pd-buybar.is-visible { transform: none; }

.pd-buybar .pd-buybar-price { flex: 1; min-width: 0; }
.pd-buybar .price-now { font-size: 17px; }
.pd-buybar .price-was { font-size: 12px; }
.pd-buybar .pd-add-to-cart { flex: 0 0 auto; width: 190px; height: 46px; }

/* ===========================================================
   14. RESPONSIVE
   =========================================================== */
@media (max-width: 1100px) {
    .pd-top { grid-template-columns: 1fr; gap: 36px; }
    .product-gallery { position: static; }
    .pd-related-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
    .product-page { padding: 0 20px 96px; }
    .pd-spec-grid { grid-template-columns: 1fr; }
    .pd-related-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
    .pd-tabs { margin-top: 44px; }
    .pd-tabs-nav { gap: 22px; }
    .gallery-arrow { opacity: 1; width: 36px; height: 36px; }
    .gallery-prev { left: 8px; }
    .gallery-next { right: 8px; }

    /* Keep the buy button reachable without scrolling back up. */
    .pd-buybar { display: flex; }
    .product-page .pd-actions { margin-bottom: 12px; }
}

@media (max-width: 520px) {
    .product-info h1 { font-size: 21px; }
    .pd-price .price-now { font-size: 23px; }
    .pd-price .price-was { font-size: 16px; }
    .feature-icons { grid-template-columns: 1fr; }
    .pd-buybar .pd-add-to-cart { width: 150px; }
}

@media (prefers-reduced-motion: reduce) {
    .product-page *,
    .product-page * {
        animation-duration: .001ms !important;
        transition-duration: .001ms !important;
    }
    .pd-rel-card:hover,
    .gallery-main:hover .gallery-main-inner img { transform: none; }
}

@media print {
    .pd-buybar, .pd-actions, .gallery-thumbnails, .gallery-arrow { display: none !important; }
    .product-page { padding: 0; }
}
