/*
 * Single product page — top-align the image column and let it stick while the
 * details column scrolls. Added 2026-08-19.
 *
 * Two separate problems this fixes:
 *
 * 1. article.product is `display:flex; align-items:center`, so the ~532px image
 *    was being vertically centred against a ~975px details column — pushing it
 *    roughly 220px down the page. Opening an accordion made the details column
 *    taller, which shoved the image down further still.
 *
 * 2. The image scrolled away entirely. It should stay visible.
 *
 * NOTE ON SCOPING: there is deliberately no body-class prefix here. This theme
 * hardcodes `<body class="<?php echo $body_id; ?>">` in header.php and never
 * calls body_class(), so WordPress/WooCommerce classes such as `single-product`
 * do not exist on this site. Scoping is done instead by only enqueueing this
 * stylesheet on single product pages — see inc/product-sticky-image.php.
 *
 * To revert: delete this file, inc/product-sticky-image.php, and the require in
 * functions.php.
 */

/* ---- gallery thumbnails ------------------------------------------------
 * Strip under the product gallery. The slider keeps its own pagination dots
 * for accessibility and as the fallback the thumbnails click through, but they
 * are hidden once thumbnails are on screen — two paginations for one gallery
 * is just clutter.
 */
.product_section article.product figure .mv-thumbs {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-flex-wrap: wrap;
        -ms-flex-wrap: wrap;
            flex-wrap: wrap;
    gap: 10px;
    margin-top: 22px;
    padding-left: 48px; /* matches figure.col's own padding-left */
}

/* slick renders .slick-dots INSIDE .slider, and .mv-thumbs is a sibling of
   .slider — so hide the dots on any figure that has a thumbnail strip.
   !important is required and justified: slick writes `display: block` as an
   INLINE style on the element, which beats any stylesheet rule without it. */
.product_section article.product figure:has(.mv-thumbs) .slick-dots {
    display: none !important;
}

/* default.css:582 gives .slider 60px of bottom padding purely to make room for
   those dots. With the dots gone that is dead space between the image and the
   thumbnails, so reclaim it. */
.product_section article.product figure:has(.mv-thumbs) .slider {
    padding-bottom: 0;
}

.product_section article.product .mv-thumb {
    width: 74px;
    height: 74px;
    padding: 0;
    background: #fff;
    border: 1px solid #dcdcd7;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    -webkit-appearance: none;
            appearance: none;
}

.product_section article.product .mv-thumb[hidden] {
    display: none !important;
}

.product_section article.product .mv-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product_section article.product .mv-thumb:hover {
    border-color: #315B42;
}

.product_section article.product .mv-thumb.is-active {
    border-color: #315B42;
    box-shadow: 0 0 0 1px #315B42;
}

.product_section article.product .mv-thumb:focus-visible {
    outline: 2px solid #315B42;
    outline-offset: 2px;
}

@media screen and (max-width: 820px) {
    /* media.css reserves 15% on both sides of the image column. That leaves
       only about 250px for the gallery on a 390px phone, so release the side
       padding and let the product imagery use the available content width. */
    .product_section article.product figure.col {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /*
     * media.css:601 centres everything inside .outer_wrapper on mobile. That
     * suits the title and price, but centred body copy is hard to read —
     * every line starts in a different place. Return the reading content to
     * the left while leaving the headline treatment alone.
     */
    .product_section article.product .less_text,
    .product_section article.product .less_text.short_desc,
    .product_section article.product .mv-acc,
    .product_section article.product .mv-acc__inner,
    .product_section article.product .mv-acc__heading,
    .product_section article.product .mv-delivery-note,
    .product_section article.product .wcsatt-options-wrapper,
    .product_section article.product .woocommerce-variation-description,
    .product_section article.product .cols.mv-price-row,
    .product_section article.product .cols.mv-price-row .col2,
    .product_section article.product .col2.price,
    .product_section article.product .woocommerce-variation-price,
    .product_section article.product .woocommerce-variation-availability,
    .product_section article.product .stock,
    .product_section article.product .single_variation_wrap {
        text-align: left;
    }

    .product_section article.product figure .mv-thumbs {
        padding-left: 0;
        justify-content: center;
    }

    .product_section article.product .mv-thumb {
        width: 62px;
        height: 62px;
    }
}

/* ---- enlarge / lightbox ------------------------------------------------
 * The theme's custom slick gallery bypasses WooCommerce's PhotoSwipe, so this
 * is a small self-contained lightbox.
 */

/* Positioning context is the gallery wrapper, NOT figure.col — figure carries
   88px of top padding, which left the button floating above the product. */
.product_section article.product .mv-gallery {
    position: relative;
}

/* Slick's adaptiveHeight option now follows the active image at every
   viewport. Ease that measured-height change so the thumbnails move smoothly
   between the short product photos and tall label artwork. */
.product_section article.product .mv-gallery .slick-list {
    transition: height 0.2s ease;
}

@media (prefers-reduced-motion: reduce) {
    .product_section article.product .mv-gallery .slick-list {
        transition: none;
    }
}

/* Desktop only: the whole image is clickable to enlarge. On touch the gallery
   is swiped instead, so no pointer cue there. */
@media screen and (min-width: 821px) {
    .product_section article.product .mv-gallery .slider img {
        cursor: zoom-in;
    }
}

.product_section article.product .mv-zoom {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 2;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
        -ms-flex-align: center;
            align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
        -ms-flex-pack: center;
            justify-content: center;
    /* Bigger and higher contrast — at 42px on a pale background it was easy to
       miss entirely. */
    width: 52px;
    height: 52px;
    padding: 0;
    background-color: #fff;
    border: 2px solid #315B42;
    border-radius: 50%;
    box-shadow: 0 2px 10px rgba(31, 57, 51, 0.22);
    color: #1F3933;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
    -webkit-appearance: none;
            appearance: none;
}

.product_section article.product .mv-zoom:hover {
    background-color: #315B42;
    color: #fff;
    transform: scale(1.05);
}

.product_section article.product .mv-zoom:focus-visible {
    outline: 2px solid #315B42;
    outline-offset: 2px;
}

.mv-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
        -ms-flex-align: center;
            align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
        -ms-flex-pack: center;
            justify-content: center;
    padding: 40px;
    background-color: rgba(20, 28, 24, 0.88);
}

.mv-lightbox[hidden] {
    display: none;
}

/* Shrink-wraps the image so the close button lands on the image's corner
   rather than the corner of the viewport. */
.mv-lightbox__inner {
    position: relative;
    display: inline-block;
    max-width: 100%;
    max-height: 100%;
    line-height: 0;
}

.mv-lightbox__img {
    max-width: 100%;
    max-height: 85vh;
    background-color: #fff;
    border-radius: 8px;
    object-fit: contain;
}

.mv-lightbox__close {
    position: absolute;
    /* Straddle the image's top-right corner: half the 46px button sits on the
       image, half outside, so its centre lands exactly on the corner.
       .mv-lightbox's 40px padding leaves room for the overhang. */
    top: -23px;
    right: -23px;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
        -ms-flex-align: center;
            align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
        -ms-flex-pack: center;
            justify-content: center;
    width: 46px;
    height: 46px;
    padding: 0 0 3px;
    background-color: rgba(255, 255, 255, 0.94);
    border: 0;
    border-radius: 50%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    font-size: 30px;
    line-height: 1;
    color: #1F3933;
    cursor: pointer;
    transition: background-color 0.15s ease;
    -webkit-appearance: none;
            appearance: none;
}

.mv-lightbox__close:hover {
    background-color: #fff;
    color: #315B42;
}

/* Previous / next. Same visual language as the close button, straddling the
   left and right edges of the image so they never cover the product. */
.mv-lightbox__nav {
    position: absolute;
    top: 50%;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
        -ms-flex-align: center;
            align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
        -ms-flex-pack: center;
            justify-content: center;
    width: 46px;
    height: 46px;
    margin-top: -23px;
    padding: 0;
    background-color: rgba(255, 255, 255, 0.94);
    border: 0;
    border-radius: 50%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    color: #1F3933;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
    -webkit-appearance: none;
            appearance: none;
}

.mv-lightbox__nav--prev { left: -23px; }
.mv-lightbox__nav--next { right: -23px; }

.mv-lightbox__nav:hover {
    background-color: #fff;
    color: #315B42;
}

.mv-lightbox__nav:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

.mv-lightbox__nav[hidden] {
    display: none;
}

/* Position counter, e.g. "2 / 3". */
.mv-lightbox__count {
    position: absolute;
    left: 50%;
    bottom: -34px;
    transform: translateX(-50%);
    font-family: inherit;
    font-size: 13px;
    line-height: 1;
    letter-spacing: 0.04em;
    color: rgba(255, 255, 255, 0.85);
    white-space: nowrap;
}

.mv-lightbox__count[hidden] {
    display: none;
}

@media screen and (max-width: 640px) {
    /* Keep the arrows on the image rather than off-screen on narrow viewports. */
    .mv-lightbox__nav--prev { left: 6px; }
    .mv-lightbox__nav--next { right: 6px; }
}

.mv-lightbox__close:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

@media screen and (max-width: 820px) {
    .mv-lightbox {
        padding: 20px;
    }
}

/* ---- stock status ------------------------------------------------------
 * A green tick next to "In stock". Only on the in-stock variant — an
 * out-of-stock or backorder message must not get a reassuring check.
 * display:flex also makes it left-aligned regardless of the centring the
 * theme applies on mobile.
 */
.product_section article.product p.stock.in-stock {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
        -ms-flex-align: center;
            align-items: center;
    gap: 7px;
    margin-bottom: 14px;
    padding: 0;
    font-size: 14px;
    font-weight: 600;
    color: #315B42;
}

.product_section article.product p.stock.in-stock::before {
    content: '';
    -webkit-box-flex: 0;
    -webkit-flex: 0 0 auto;
        -ms-flex: 0 0 auto;
            flex: 0 0 auto;
    width: 17px;
    height: 17px;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Ccircle cx='10' cy='10' r='9' fill='%23315B42'/%3E%3Cpath d='M5.8 10.4l2.7 2.7 5.7-5.7' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
}

/* ---- price row ---------------------------------------------------------
 * The theme sat the price and the star rating in two half-width columns, which
 * left the price only ~200px wide — so "$39.95 – $51.00 — or subscribe to save
 * 15%" wrapped onto three lines. Stack them instead: price across the full
 * column, rating underneath.
 */
.product_section article.product .cols.mv-price-row {
    display: block;
}

.product_section article.product .cols.mv-price-row .col2 {
    width: 100%;
}

.product_section article.product .cols.mv-price-row .col2.price {
    margin-bottom: 8px;
}

/* ---- column widths -----------------------------------------------------
 * The theme split the row 47.16% image / 42.9% details. The image column was
 * mostly empty space around the product shot while the details column — which
 * carries the title, price, swatches, purchase options and every accordion —
 * was the narrower of the two. Rebalanced. The photo itself still fills its
 * column, so it barely changes size; what goes is the surrounding whitespace.
 */
.product_section article.product figure.col {
    width: 41%;
}

.product_section article.product div.col {
    width: 56%;
}

/*
 * Widening the column alone changed nothing, because the theme caps the
 * content inside it regardless of how much room there is:
 *
 *   default.css:625  article.product .outer_wrapper { max-width: 418px }
 *   default.css:1161 .product_section article.product h1 { max-width: 350px }
 *
 * The 418px cap held the title, price, swatches, purchase box and every
 * accordion to a fixed strip with ~250px of dead space beside it. The 350px cap
 * on the heading is why the product name broke over three lines.
 * Both are released so the content actually uses its column.
 */
.product_section article.product .outer_wrapper {
    max-width: 100%;
}

/*
 * Title width is capped so "(60 Chews)" wraps onto its own line instead of
 * breaking mid-bracket as "... (60 / Chews)".
 *
 * Measured at the live 40px bold Montserrat:
 *   "MaxiFlora Daily Probiotic"       522px  <- must fit
 *   "MaxiFlora Daily Probiotic (60"   600px  <- must NOT fit
 * 560px sits between the two with ~38px of headroom either side, so it
 * tolerates font-rendering differences.
 *
 * No <br> is used, so it still reflows sensibly on narrow screens.
 *
 * NOTE: this figure is tuned to THIS product name. Rename the product and the
 * break moves — re-measure rather than nudging it blindly.
 */
.product_section article.product h1.product_title {
    max-width: 560px;
}

/* 1. Top-align the two columns instead of vertically centring them. */
.product_section article.product {
    -webkit-box-align: start;
    -webkit-align-items: flex-start;
        -ms-flex-align: start;
            align-items: flex-start;
}

/*
 * 2. position:sticky is cancelled by any ancestor that establishes a scroll
 *    container. default.css line 95 sets `.wrap { overflow-x: hidden }`, and
 *    overflow-x:hidden forces overflow-y to compute as `auto` — which is
 *    exactly such a container. That single declaration is why sticky would
 *    otherwise silently do nothing here.
 *
 *    overflow-x:clip clips identically but does NOT create a scroll container,
 *    so sticky works. Only product pages load this file, so the rest of the
 *    site keeps the behaviour it has today.
 */
.wrap {
    overflow-x: clip;
}

.product_section article.product figure.col {
    position: -webkit-sticky;
    position: sticky;
    /* .main_header is position:fixed and 92px tall; 20px of breathing room. */
    top: 112px;
}

/*
 * Below 820px the two columns stack full width (media.css:566), so there is no
 * second column to scroll past — sticky would just pin the image over the
 * details. Turn it off and restore the original clipping.
 */
@media screen and (max-width: 820px) {
    .product_section article.product figure.col {
        position: static;
        top: auto;
    }

    .wrap {
        overflow-x: hidden;
    }
}
