/*
 * Product page parity with the current site (docs/plans/product-page-parity.md).
 * Loaded after style.css on product and My Account pages (inc/product-parity.php),
 * so these rules override the older product-page rules there without editing them.
 */

/* ------------------------------------------------ title and columns (round 1: #28, layout) */
/* Measured on the current site at 1280 px: 33.6 px / 400 / ~41.7 px line. */
.single-product div.product .product_title {
    font-size: 33.6px;
    font-weight: 400;
    line-height: 1.24;
}

@media (min-width: 768px) {
    /* Current site at 1280 px: gallery with thumbnails ~516 px, summary ~400 px
       (two buy buttons ~196 px each), the pair centred in the content width. */
    .single-product div.product .woocommerce-product-gallery,
    .storefront-full-width-content.single-product div.product .woocommerce-product-gallery {
        width: 50%;
        margin-left: 5%;
        margin-right: 4%;
    }

    .single-product div.product .summary,
    .storefront-full-width-content.single-product div.product .summary {
        width: 36%;
        float: left;
    }

    /* Storefront's single image size is 416 px; the wider column shows it full width. */
    .single-product div.product .woocommerce-product-gallery__image img {
        width: 100%;
    }

    /* Thumbnails (#18): a vertical column left of the main image, as on the
       current site. Mobile keeps WooCommerce's row under the image. */
    .single-product .woocommerce-product-gallery:has(> .flex-control-thumbs) {
        display: grid;
        grid-template-columns: 64px minmax(0, 1fr);
        column-gap: 12px;
        align-items: start;
    }

    .single-product .woocommerce-product-gallery:has(> .flex-control-thumbs) > .flex-viewport {
        grid-column: 2;
        grid-row: 1;
    }

    .single-product .woocommerce-product-gallery:has(> .flex-control-thumbs) > .jase-share {
        grid-column: 2;
        grid-row: 2;
    }

    .single-product .woocommerce-product-gallery > .flex-control-thumbs {
        display: flex;
        flex-direction: column;
        gap: 8px;
        grid-column: 1;
        grid-row: 1;
        max-height: 520px;
        margin: 0;
        padding: 0;
        overflow-y: auto;
    }

    /* Repeated classes and :nth-child(n) outrank Storefront's per-column
       thumbnail rules (.woocommerce-product-gallery--columns-N ... li:nth-child()). */
    .single-product.single-product div.product .woocommerce-product-gallery.woocommerce-product-gallery
    > .flex-control-thumbs.flex-control-thumbs li:nth-child(n) {
        width: 100%;
        margin: 0;
        float: none;
    }

    .single-product .woocommerce-product-gallery > .flex-control-thumbs img {
        display: block;
        border: 1px solid transparent;
    }

    .single-product .woocommerce-product-gallery > .flex-control-thumbs img.flex-active {
        border-color: var(--jase-red);
    }
}

/* ------------------------------------------------ promotion lines (#2) */
.jase-pdp-promos {
    margin: 0 0 16px;
    padding: 8px 12px;
    border-left: 3px solid var(--jase-red);
    background: var(--jase-soft);
    font-size: 14px;
    line-height: 1.6;
}

.jase-pdp-promos__line {
    display: block;
    color: var(--jase-text);
    text-decoration: none;
}

a.jase-pdp-promos__line:hover .jase-pdp-promos__text {
    text-decoration: underline;
}

.jase-pdp-promos__line + .jase-pdp-promos__line,
.jase-pdp-promos__more {
    margin-top: 4px;
}

.jase-pdp-promos__more[hidden],
.jase-pdp-promos__toggle[hidden] {
    display: none;
}

/* 「查看更多」 / 「收合」 (jase-core assets/promotions.js) */
.jase-pdp-promos__toggle,
.jase-pdp-promos__toggle:hover,
.jase-pdp-promos__toggle:focus {
    margin: 4px 0 0;
    padding: 0;
    border: 0;
    background: none;
    color: var(--jase-red);
    font-size: 13px;
    font-weight: 400;
    line-height: 1.6;
    cursor: pointer;
}

.jase-pdp-promos__toggle:hover,
.jase-pdp-promos__toggle:focus-visible {
    text-decoration: underline;
}

.jase-pdp-promos__date {
    margin-right: 6px;
    color: #999;
}

/* ------------------------------------------------ rating summary (#3) */
.single-product .jase-rating {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: -8px 0 16px;
    font-size: 14px;
}

.jase-rating__stars {
    position: relative;
    display: inline-block;
    font-size: 16px;
    line-height: 1;
    letter-spacing: 1px;
}

.jase-rating__base {
    color: #ddd;
}

.jase-rating__fill {
    position: absolute;
    top: 0;
    left: 0;
    overflow: hidden;
    color: #ffc500;
    white-space: nowrap;
}

.jase-rating__count {
    color: #999;
}

/* style.css hides WooCommerce's own rating link; this one is ours. */
.single-product .jase-rating .woocommerce-review-link {
    display: inline;
    color: #999;
    text-decoration: underline;
}

/* ------------------------------------------------ variant buttons (#7) */
.jase-swatches .jase-swatch,
.jase-swatches .jase-swatch:hover {
    padding: 8px 10px;
}

.jase-swatches .jase-swatch.is-out,
.jase-swatches .jase-swatch.is-out:hover {
    border-color: #ccc;
    color: #ccc;
}

.jase-swatches .jase-swatch.is-out.is-selected {
    border-color: var(--jase-red);
}

/* ------------------------------------------------ stock text (#8, #9, #10) */
.single-product div.product p.stock::before {
    content: none;
}

.single-product div.product p.stock.in-stock,
.single-product .woocommerce-variation-availability p.stock.in-stock {
    width: 100%;
    margin: 8px 0 0;
    color: var(--jase-red); /* #e02020, measured on the current site */
    font-size: 14px;
    text-align: center;
}

.single-product div.product p.stock.out-of-stock,
.single-product .woocommerce-variation-availability p.stock.out-of-stock {
    width: 100%;
    margin: 8px 0 16px;
    padding: 10px 0;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #f5f5f5;
    color: #999;
    font-size: 18px;
    text-align: center;
}

/* A sold-out variation: no quantity, no buy buttons, only 「售完」 (as the current site). */
.single-product .single_variation_wrap:has(p.stock.out-of-stock) .woocommerce-variation-add-to-cart {
    display: none;
}

/* ------------------------------------------------ quantity (#11, #12) */
.jase-qty-label {
    flex: 0 0 100%;
    color: var(--jase-muted);
    font-size: 15px;
}

.jase-qty {
    flex: 0 0 100%;
    justify-content: flex-start;
}

.jase-qty input.qty {
    flex: 0 0 72px;
    width: 72px;
}

/* ------------------------------------------------ buy buttons (#13: 50 / 50 and icons; colour unchanged) */
.single-product form.cart .single_add_to_cart_button,
.single-product form.cart .jase-buy-now {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 1 1 calc(50% - 6px);
    min-width: 0;
}

.single-product form.cart .single_add_to_cart_button::before,
.single-product form.cart .jase-buy-now::before {
    content: "";
    display: inline-block;
    width: 18px;
    height: 18px;
    background: currentColor;
    -webkit-mask: var(--jase-btn-icon) center / contain no-repeat;
    mask: var(--jase-btn-icon) center / contain no-repeat;
}

.single-product form.cart .single_add_to_cart_button {
    --jase-btn-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 18a2 2 0 1 0 0 4 2 2 0 0 0 0-4zm10 0a2 2 0 1 0 0 4 2 2 0 0 0 0-4zM1 2v2h2l3.6 7.6-1.4 2.4C4.5 15.3 5.4 17 7 17h12v-2H7.4l1.1-2h7.5c.8 0 1.4-.4 1.7-1l3.6-6.5L19.6 4.5H5.2L4.3 2H1z'/%3E%3C/svg%3E");
}

.single-product form.cart .jase-buy-now {
    --jase-btn-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M18 6h-2a4 4 0 0 0-8 0H6a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2zm-6-2a2 2 0 0 1 2 2h-4a2 2 0 0 1 2-2zm6 16H6V8h2v2h2V8h4v2h2V8h2v12z'/%3E%3C/svg%3E");
}

/* ------------------------------------------------ 加入追蹤清單 (#4) */
/* Directly under the buy buttons, as on the current site. */
.single-product div.product form.cart {
    margin-bottom: 0;
    padding-bottom: 0;
}

/* Storefront's clearfix pseudo-elements are flex items here: each adds an empty gap row. */
.single-product div.product form.cart::before,
.single-product div.product form.cart::after,
.single-product .woocommerce-variation-add-to-cart::before,
.single-product .woocommerce-variation-add-to-cart::after {
    display: none;
}

.jase-wishlist {
    margin: 12px 0 16px;
    text-align: center;
}

.jase-wishlist__btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    color: var(--jase-text);
    font-size: 14px;
    text-decoration: none;
}

.jase-wishlist__btn:hover,
.jase-wishlist__btn:focus {
    color: var(--jase-red);
}

.jase-wishlist__icon--on,
.jase-wishlist__btn.is-tracked .jase-wishlist__icon--off {
    display: none;
}

.jase-wishlist__btn.is-tracked {
    color: var(--jase-red);
}

.jase-wishlist__btn.is-tracked .jase-wishlist__icon--on {
    display: inline;
}

/* My Account → 追蹤清單 */
.jase-wishlist-list__items {
    margin: 0;
    padding: 0;
    list-style: none;
}

.jase-wishlist-list__item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--jase-line);
}

.jase-wishlist-list__image img {
    display: block;
    width: 72px;
    height: 72px;
    object-fit: cover;
}

.jase-wishlist-list__info {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.jase-wishlist-list__name {
    color: var(--jase-text);
    text-decoration: none;
}

.jase-wishlist-list__price {
    color: var(--jase-red);
}

.jase-wishlist-list__soldout {
    color: #999;
    font-size: 14px;
}

.jase-wishlist-list__remove {
    margin: 0;
}

/* ------------------------------------------------ tabs (#14, #15, #16) */
.single-product .woocommerce-tabs ul.tabs li a {
    font-size: 16px;
}

.single-product .woocommerce-Tabs-panel > h2:first-child {
    font-size: 18px;
    font-weight: 700;
}

.jase-shipping-cols {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
    margin-bottom: 16px;
}

.jase-shipping-cols__title {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 700;
}

.jase-shipping-cols__list {
    margin: 0 0 0 1.2em;
    font-size: 14px;
}

/* ------------------------------------------------ 您可能喜歡... (#17) */
.single-product .related.products > h2 {
    text-align: center;
    font-size: 20px;
    font-weight: 400;
}

@media (max-width: 767px) {
    .single-product .woocommerce-tabs ul.tabs li a {
        font-size: 14px;
    }

    .jase-shipping-cols {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
    }
}
