/* ═══════════════════════════════════════════════════════════════
   Codemola Product Page v1.0.0 — FaithBenjamin luxury palette
   black · ivory #faf7f1 · cream #f5f2ec · gold #c9a35c · wine #8a2b3a
   Selectors prefixed with `html body` to outrank theme/cmhdr rules.
   ═══════════════════════════════════════════════════════════════ */

:root {
    --cmpp-ivory: #faf7f1;
    --cmpp-cream: #f5f2ec;
    --cmpp-gold:  #c9a35c;
    --cmpp-wine:  #8a2b3a;
    --cmpp-ink:   #171412;
    --cmpp-line:  #e6e0d4;
    --cmpp-img-max: 1000px; /* main product image height cap */
}

/* ── 0) Main image sizing ───────────────────────────────────── */
/* Cap height at 1000px while keeping full column width — the
   image crops from the bottom (object-position top) rather than
   shrinking. 15px breathing room below. */

html body.single-product .woocommerce-product-gallery .woocommerce-product-gallery__image img,
html body.single-product .woocommerce-product-gallery .flex-viewport img {
    width: 100%;
    max-height: var(--cmpp-img-max);
    object-fit: cover;
    object-position: top center;
}

html body.single-product .woocommerce-product-gallery .flex-viewport,
html body.single-product .woocommerce-product-gallery .woocommerce-product-gallery__wrapper {
    max-height: var(--cmpp-img-max);
    overflow: hidden;
}

html body.single-product .woocommerce-product-gallery {
    margin-bottom: 15px;
}

/* ── 0b) Layout flow repair ─────────────────────────────────── */
/* WooCommerce floats the gallery and summary columns; the theme's
   CSS lacks the stock clearfix, so the tabs/related sections rise
   into the columns' vertical band and anything sliding down the
   gallery's column covers them. flow-root contains the floats
   (row height = tallest column) and clear:both forces every
   below-section to start underneath BOTH columns. */

html body.single-product .cmpux-row,
html body.single-product div.product {
    display: flow-root;
}

html body.single-product div.product::after {
    content: "";
    display: block;
    clear: both;
}

html body.single-product .woocommerce-tabs,
html body.single-product .wc-tabs-wrapper,
html body.single-product section.related,
html body.single-product .related.products,
html body.single-product .up-sells,
html body.single-product .cross-sells,
html body.single-product [class*="recently-viewed"] {
    clear: both !important;
    /* Paint-order backstop: these sections sit ABOVE the gallery in
       stacking order with an opaque background — even if the gallery
       slides beneath them, it cannot be seen. */
    position: relative;
    z-index: 3;
    background: var(--cmpp-page-bg, #fff);
}

/* ── 1) Gallery: thumbnail rail on the LEFT ─────────────────── */

html body.single-product.cmpp-thumbs-left .woocommerce-product-gallery {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 14px;
}

html body.single-product.cmpp-thumbs-left .woocommerce-product-gallery .woocommerce-product-gallery__wrapper,
html body.single-product.cmpp-thumbs-left .woocommerce-product-gallery .flex-viewport {
    order: 2;
    flex: 1 1 auto;
    min-width: 0;
}

html body.single-product.cmpp-thumbs-left .woocommerce-product-gallery ol.flex-control-thumbs {
    order: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
    padding: 0;
    width: 84px;
    flex: 0 0 84px;
    max-height: 560px;
    overflow-y: auto;
    scrollbar-width: thin;
}

html body.single-product.cmpp-thumbs-left .woocommerce-product-gallery ol.flex-control-thumbs li {
    width: 100% !important;   /* flexslider inline-sizes these */
    float: none !important;
    margin: 0 !important;
    padding: 0;
    list-style: none;
}

html body.single-product.cmpp-thumbs-left .woocommerce-product-gallery ol.flex-control-thumbs li img {
    width: 100%;
    height: auto;
    display: block;
    border: 1px solid var(--cmpp-line);
    opacity: .65;
    cursor: pointer;
    transition: opacity .2s ease, border-color .2s ease;
}

html body.single-product.cmpp-thumbs-left .woocommerce-product-gallery ol.flex-control-thumbs li img:hover {
    opacity: 1;
}

html body.single-product.cmpp-thumbs-left .woocommerce-product-gallery ol.flex-control-thumbs li img.flex-active {
    opacity: 1;
    border-color: var(--cmpp-ink);
}

/* ── 1b) Sticky gallery (JS engine) ─────────────────────────── */
/* Pinning is driven by product-page.js via translateY — the
   gallery never leaves the document flow, so the theme's columns
   cannot shift or reflow. Images keep their natural size. */

html body.single-product .woocommerce-product-gallery.cmpp-pinned {
    will-change: transform;
    z-index: 1; /* BELOW the tabs/related backstop (z 3), far below the header */
}

/* Hard-stop: no other stylesheet (theme sticky, Elementor) may pin
   the gallery — this engine's translateY is the only mover. */
html body.single-product .woocommerce-product-gallery {
    position: relative !important;
    top: auto !important;
    bottom: auto !important;
}

/* Mobile: rail returns to a horizontal strip under the image */
@media (max-width: 767px) {
    html body.single-product.cmpp-thumbs-left .woocommerce-product-gallery {
        flex-direction: column;
        gap: 10px;
    }
    html body.single-product.cmpp-thumbs-left .woocommerce-product-gallery ol.flex-control-thumbs {
        order: 3;
        flex-direction: row;
        width: 100%;
        flex-basis: auto;
        max-height: none;
        overflow-x: auto;
        overflow-y: hidden;
    }
    html body.single-product.cmpp-thumbs-left .woocommerce-product-gallery ol.flex-control-thumbs li {
        flex: 0 0 72px;
    }
}

/* ── 2) Title row + wishlist star ───────────────────────────── */

html body.single-product .cmpp-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

html body.single-product .cmpp-title-row .product_title {
    margin-bottom: 0;
    flex: 1 1 auto;
    min-width: 0;
}

html body.single-product .cmpp-wishlist-btn {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    margin-top: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--cmpp-line);
    border-radius: 50%;
    background: #fff;
    color: var(--cmpp-ink);
    cursor: pointer;
    transition: border-color .2s ease, color .2s ease, transform .15s ease, background .2s ease;
    padding: 0;
    line-height: 1;
}

html body.single-product .cmpp-wishlist-btn:hover {
    border-color: var(--cmpp-gold);
    color: var(--cmpp-gold);
}

html body.single-product .cmpp-wishlist-btn:focus-visible {
    outline: 2px solid var(--cmpp-gold);
    outline-offset: 2px;
}

html body.single-product .cmpp-wishlist-btn.is-active {
    background: var(--cmpp-ink);
    border-color: var(--cmpp-ink);
    color: var(--cmpp-gold);
}

html body.single-product .cmpp-wishlist-btn.is-active .cmpp-star path {
    fill: currentColor;
}

html body.single-product .cmpp-wishlist-btn.cmpp-pop {
    transform: scale(1.15);
}

/* ── 3) Low-stock urgency ───────────────────────────────────── */

html body.single-product .cmpp-stock {
    margin: 14px 0 18px;
}

html body.single-product .cmpp-stock__text {
    margin: 0 0 8px;
    font-size: .95rem;
    letter-spacing: .01em;
    color: var(--cmpp-ink);
}

html body.single-product .cmpp-stock__text strong {
    color: var(--cmpp-wine);
}

html body.single-product .cmpp-stock__track {
    height: 4px;
    width: 100%;
    background: var(--cmpp-line);
    border-radius: 999px;
    overflow: hidden;
}

html body.single-product .cmpp-stock__bar {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--cmpp-wine), #b4485a);
    border-radius: 999px;
    transition: width .6s cubic-bezier(.22, .61, .36, 1);
}

/* ── 4) Size chat prompt ────────────────────────────────────── */

html body.single-product .cmpp-size-chat {
    margin: 4px 0 18px;
    font-size: .95rem;
    color: var(--cmpp-ink);
}

html body.single-product .cmpp-size-chat__lead {
    margin-right: 6px;
    opacity: .8;
}

html body.single-product .cmpp-size-chat__link {
    color: var(--cmpp-wine);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: var(--cmpp-gold);
    transition: color .2s ease;
}

html body.single-product .cmpp-size-chat__link:hover {
    color: var(--cmpp-gold);
}

/* ── 5) Pickup block ────────────────────────────────────────── */

html body.single-product .cmpp-pickup {
    margin: 22px 0 6px;
    padding: 16px 18px;
    background: var(--cmpp-cream);
    border: 1px solid var(--cmpp-line);
}

html body.single-product .cmpp-pickup__head {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

html body.single-product .cmpp-pickup__check {
    flex: 0 0 auto;
    margin-top: 2px;
    color: #2e7d4f;
}

html body.single-product .cmpp-pickup__lines p {
    margin: 0 0 4px;
    font-size: .92rem;
    line-height: 1.5;
}

html body.single-product .cmpp-pickup__title strong {
    font-weight: 600;
}

html body.single-product .cmpp-pickup__ready {
    color: #6f6a60;
}

html body.single-product .cmpp-pickup__toggle {
    background: none;
    border: none;
    padding: 0;
    margin-top: 2px;
    font-size: .88rem;
    color: var(--cmpp-ink);
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
    transition: color .2s ease;
}

html body.single-product .cmpp-pickup__toggle:hover {
    color: var(--cmpp-gold);
}

html body.single-product .cmpp-pickup__panel {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--cmpp-line);
}

html body.single-product .cmpp-pickup__store-name {
    margin: 0 0 4px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    font-size: .85rem;
}

html body.single-product .cmpp-pickup__store-line {
    margin: 0 0 4px;
    font-size: .9rem;
    color: #4d483f;
}

html body.single-product .cmpp-pickup__map {
    color: var(--cmpp-wine);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* ── 6) Assurance lines (secure strip, delivery, fit) ───────── */

html body.single-product .cmpp-secure {
    margin: 16px 0 4px;
    padding-top: 14px;
    border-top: 1px solid var(--cmpp-line);
    font-size: .88rem;
    letter-spacing: .02em;
    color: #8b8577;
}

html body.single-product .cmpp-assure {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin: 10px 0 0;
    font-size: .92rem;
    color: var(--cmpp-ink);
    line-height: 1.5;
}

html body.single-product .cmpp-assure__icon {
    flex: 0 0 auto;
    margin-top: 2px;
    color: var(--cmpp-gold);
}

html body.single-product .cmpp-assure--fit {
    color: #6f6a60;
}

/* ── Wishlist page ──────────────────────────────────────────── */

.cmpp-wishlist-page .cmpp-wishlist-loading,
.cmpp-wishlist-page .cmpp-wishlist-empty {
    text-align: center;
    padding: 48px 16px;
    color: #6f6a60;
    letter-spacing: .02em;
}

/* ── Reduced motion ─────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    html body.single-product .cmpp-stock__bar,
    html body.single-product .cmpp-wishlist-btn {
        transition: none;
    }
}
