/*
 * Single product page (woocommerce/single-product.php).
 *
 * Gallery on the left, summary on the right; the summary stays in view
 * (sticky) while the visitor scrolls past a taller gallery. Below:
 * product information, related products and the category button.
 * Below 768px everything stacks, gallery first.
 */

.p2p-single-product {
    padding-bottom: 3rem;
}

.p2p-single-product-section-title {
    margin: 0 0 1rem;
    font-size: 1.5rem;
}


/* ---------------------------------------------------------
   Main: gallery + summary
--------------------------------------------------------- */

.p2p-single-product-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
}

@media (min-width: 768px) {
    .p2p-single-product-main {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 2rem;
    }
}

@media (min-width: 1200px) {
    .p2p-single-product-main {
        grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
        gap: 3rem;
    }
}


/* Gallery ------------------------------------------------- */

.p2p-single-product-gallery {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 0;
}

.p2p-single-product-main-image {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: #fff;

    img {
        display: block;
        width: 100%;
        height: 100%;
        object-fit: contain;
    }
}

.p2p-single-product-thumbnails {
    display: flex;
    gap: 0.5rem;
    margin: 0;
    padding: 0 0 0.25rem;
    list-style: none;
    overflow-x: auto;
    scrollbar-width: thin;

    li {
        flex: 0 0 4.5rem;
    }
}

.p2p-single-product-thumbnail {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    padding: 0.2rem;
    border: 1px solid rgba(0, 0, 0, 0.18);
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s ease, border-color 0.2s ease;

    img {
        display: block;
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

    &:hover,
    &.is-active {
        opacity: 1;
    }

    &.is-active {
        border: 2px solid var(--p2p-primary);
    }

    &:focus-visible {
        outline: 2px solid #555;
        outline-offset: 2px;
    }
}


/* Summary ------------------------------------------------- */

.p2p-single-product-summary {
    min-width: 0;
}

/*
 * Sticky from 768px, below the fixed header (its height is set by
 * header-scroll-handler.js), moving down when the main header slides in.
 */
@media (min-width: 768px) {
    .p2p-single-product-summary {
        position: sticky;
        top: calc(var(--p2p-fixed-header-offset, 0px) + 1.5rem);
        transition: top 0.25s ease;
    }

    .p2p-fixed-header-expanded .p2p-single-product-summary {
        top: calc(var(--p2p-fixed-header-offset-expanded, 0px) + 1.5rem);
    }
}

.p2p-single-product-summary-content {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.p2p-single-product-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;

    h1,
    p {
        margin: 0;
        padding: 0;
    }
}

.p2p-single-product-title {
    font-size: 2rem;
    line-height: 1.2;
}

.p2p-single-product-secondary-title {
    color: var(--p2p-grey);
    font-size: 1.1rem;
}

/* Category chip above the title. */
.p2p-single-product-category {
    --p2p-category-icon-color: currentColor;

    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
    padding: 0.3rem 0.75rem;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 999px;
    color: var(--p2p-darkgrey);
    font-size: 0.85rem;
    line-height: 1.2;
    text-decoration: none;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;

    &:hover {
        border-color: var(--p2p-primary);
        background-color: var(--p2p-primary);
        color: #fff;
    }

    &:focus-visible {
        outline: 2px solid #555;
        outline-offset: 2px;
    }
}

.p2p-single-product-category__icon {
    flex: 0 0 auto;
    width: 1.1em;
    height: 1.1em;
}

.p2p-single-product-price {
    .p2p-price-tag {
        margin: 0;
    }

    .p2p-price-tag__amount {
        font-size: 1.75rem;
    }

    .p2p-price-tag__units {
        font-size: 0.9rem;
    }
}

.p2p-single-product-purchase {
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
    padding-block: 1.25rem;
    border-block: 1px solid rgba(0, 0, 0, 0.12);

    > p {
        margin: 0;
        padding: 0;
    }

    form {
        display: flex;
        flex-flow: row wrap;
        gap: 1rem;
    }

    /* A larger add-to-cart control: it is the page's main action. */
    .product-cart-qty-selector {
        gap: 0.5rem;

        .product-cart__qty {
            width: 4rem;
            height: 2.75rem;
            font-size: 1rem;
        }

        .product-cart__button {
            width: 2.75rem;
            min-width: 2.75rem;
            height: 2.75rem;
            font-size: 1.35rem;
        }
    }
}

.p2p-single-product-specification-table {
    overflow-x: auto;

    .p2p-product-table {
        width: 100%;

        th,
        td {
            padding: 0.5rem 0.25rem;
            border-bottom: 1px solid rgba(0, 0, 0, 0.1);
            vertical-align: top;
        }

        th {
            width: 40%;
            color: var(--p2p-grey);
            font-weight: 600;
        }
    }
}

.p2p-single-product-meta {
    color: var(--p2p-grey);
    font-size: 0.85rem;

    .product_meta > span {
        display: block;
    }
}


/* ---------------------------------------------------------
   Product information
--------------------------------------------------------- */

.p2p-single-product-details {
    margin-top: 3rem;
}

.p2p-single-product-description-content {
    max-width: 75ch;

    > :first-child {
        margin-top: 0;
    }
}


/* ---------------------------------------------------------
   Related products + category button
--------------------------------------------------------- */

.p2p-single-product-related {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(0, 0, 0, 0.12);
}

/*
 * One row of cards at every width (two rows of two on phones). The
 * grid's columns come from product-cell.css: 2 / 3 / 4 / 5.
 */
.p2p-single-product-related__grid > .p2p-product-cell:nth-child(n + 5) {
    display: none;
}

@media (min-width: 768px) and (max-width: 991.98px) {
    .p2p-single-product-related__grid > .p2p-product-cell:nth-child(n + 4) {
        display: none;
    }
}

@media (min-width: 1200px) {
    .p2p-single-product-related__grid > .p2p-product-cell:nth-child(5) {
        display: flex;
    }
}

.p2p-single-product-related__more {
    display: flex;
    justify-content: center;
    margin-top: 2rem;
}

.p2p-single-product-category-button {
    --p2p-category-icon-color: currentColor;

    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    max-width: 100%;
    padding: 0.8rem 1.5rem;
    border-radius: 6px;
    background-color: var(--p2p-primary);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    transition: background-color 0.2s ease;

    &:hover {
        background-color: var(--p2p-primaryHover);
        color: #fff;
    }

    &:focus-visible {
        outline: 2px solid #555;
        outline-offset: 3px;
    }

    .p2p-single-product-category-button__arrow {
        flex: 0 0 auto;
        width: 1em;
        height: 1em;
        transition: transform 0.2s ease;
    }

    &:hover .p2p-single-product-category-button__arrow {
        transform: translateX(3px);
    }
}


/* ---------------------------------------------------------
   Phones
--------------------------------------------------------- */

@media (max-width: 575.98px) {
    .p2p-single-product-title {
        font-size: 1.5rem;
    }

    .p2p-single-product-price .p2p-price-tag__amount {
        font-size: 1.5rem;
    }

    .p2p-single-product-details,
    .p2p-single-product-related {
        margin-top: 2rem;
    }

    .p2p-single-product-category-button {
        width: 100%;
        justify-content: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    .p2p-single-product-summary,
    .p2p-single-product-category-button__arrow {
        transition: none;
    }
}
