/* ── TBC Product Showcase Block ──
   A row of products shown one at a time — image gallery on the left,
   WooCommerce product data + Add to Cart on the right. Multiple products in
   the same row are a click-driven SLIDER (not a scroll-triggered stack):
   the "See what's inside?" button advances to the next product. */

.tbc-ps-section {
    width: 100%;

    /* Default: light scheme */
    --ps-card-bg:    var(--tbc-color-bg);
    --ps-text:       var(--tbc-color-text);
    --ps-border:     rgba(13, 13, 13, 0.15);
    --ps-border-mid: rgba(13, 13, 13, 0.2);
    --ps-bg-qty:     rgba(13, 13, 13, 0.06);
    --ps-btn-bg:     var(--tbc-color-text);
    --ps-btn-color:  #ffffff;
    --ps-btn-hover:  var(--tbc-pink);
}

.tbc-ps-section.is-dark {
    color: #ffffff;
    --ps-card-bg:    var(--tbc-color-black);
    --ps-text:       #ffffff;
    --ps-border:     rgba(255, 255, 255, 0.15);
    --ps-border-mid: rgba(255, 255, 255, 0.25);
    --ps-bg-qty:     rgba(255, 255, 255, 0.1);
    --ps-btn-bg:     #ffffff;
    --ps-btn-color:  var(--tbc-color-text);
    --ps-btn-hover:  var(--tbc-pink);
}

/* ── Product Slider (one card visible at a time, click-to-advance) ──
   Cards sit stacked via absolute positioning and slide horizontally:
   default (off-screen right) -> .is-active (0%) -> .is-prev (off-screen
   left) while leaving. See script.js for the transition sequencing.

   The slider's own height is set inline (in px) by script.js to match the
   active card's natural content height — position:absolute children never
   contribute to a parent's auto height, and this block's content length
   varies per product, so a fixed vh would either clip content behind a
   scrollbar or leave a lot of empty space. Height updates on load, after
   every slide change, and on resize. */
.tbc-ps-slider {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.tbc-ps-card {
    position: absolute;
    inset: 0;
    width: 100%;
    height: auto;
    background: var(--ps-card-bg);
    transform: translateX(100%);
    transition: transform 0.7s cubic-bezier(0.65, 0, 0.35, 1);
    pointer-events: none;
}

/* position:relative on the active card only (all others stay absolute) —
   a CSS-only height fallback. The ACF block editor's canvas iframe never
   fires this block's own 'load' event after its content is injected (see
   script.js), so JS-computed height never runs there; without this, the
   wrapper (position:absolute children + overflow:hidden, no CSS height)
   would collapse to 0px and the whole block would look empty in wp-admin.
   Front-end behavior is unaffected — JS still overrides with an explicit
   px height once it runs, and only one card is ever .is-active at a time. */
.tbc-ps-card.is-active {
    position: relative;
    transform: translateX(0%);
    pointer-events: auto;
}

.tbc-ps-card.is-prev {
    transform: translateX(-100%);
}

.tbc-ps-card.no-anim {
    transition: none !important;
}

.tbc-ps-card__inner {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
}

/* min-width:0 — without it, a 1fr track's implicit minimum is its content's
   min-content size, so the image column (and the whole grid) blows out past
   its container to fit the photo's intrinsic width instead of the 1fr share
   it was given. aspect-ratio keeps every product image square regardless of
   how tall the right column's content is; align-self:start overrides the
   grid's default item-stretch so the square isn't stretched to match it. */
.tbc-ps-card__left {
    position: relative;
    overflow: hidden;
    /* aspect-ratio: 1 / 1; */
    /* align-self: start; */
    min-width: 0;
    min-height: 49.482vw;
}

.tbc-ps-card__right {
    display: flex;
    align-items: center;
    padding: var(--space-80-40) var(--space-120-40);
    height: 100%;
    min-width: 0;
}

/* ── Image Gallery (a product's own photos, within its card) ── */
.tbc-ps-gallery {
    position: relative;
    width: 100%;
    height: 100%;
}

.tbc-ps-gallery__slide {
    position: absolute;
    inset: 0;
	display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transform: translateX(100%);
    transition: transform 0.7s cubic-bezier(0.65, 0, 0.35, 1);
    pointer-events: none;
}

.tbc-ps-gallery__slide.is-active {
    transform: translateX(0%);
    pointer-events: auto;
}

.tbc-ps-gallery__slide.is-prev {
    transform: translateX(-100%);
}

.tbc-ps-gallery__slide.no-anim {
    transition: none !important;
}

.tbc-ps-gallery__slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.tbc-ps-gallery__slide img[src*="TBC_Worksheets_Product"] {
    width: 90%;
    height: 90%;
    object-fit: contain;
}

/* Pagination dots — only rendered when a product has 2+ photos, so it's
   clear there's more to auto-cycle through. */
.tbc-ps-gallery__dots {
    position: absolute;
    left: 50%;
    bottom: 1.25rem;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 2;
}

.tbc-ps-gallery__dot {
    width: 8px;
    height: 8px;
    border: none;
    padding: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: background 0.3s ease, transform 0.3s ease;
}

.tbc-ps-gallery__dot:hover {
    background: rgba(255, 255, 255, 0.8);
}

.tbc-ps-gallery__dot.is-active {
    background: #ffffff;
    transform: scale(1.25);
}

/* ── Sticky Stack (2+ products/formats) ──
   Each card sticks at the top of the viewport (height:100vh); later cards
   have a higher z-index (set inline in block.php) so they slide up and
   fully cover the previous card as the user scrolls — ported directly from
   BSB's "Product Showcase" block (.bsb-ps-card). A lone card never uses
   this — it keeps the plain .tbc-ps-slider markup above. */
.tbc-ps-section--stack .tbc-ps-card {
    position: sticky;
    inset: auto;
    top: 0;
    width: 100%;
    height: 100vh;
    background: var(--ps-card-bg);
    /* Override the plain-slider base rule above (position:absolute,
       inset:0, transform:translateX(100%), pointer-events:none) — stack-mode
       cards are never .is-active, they're always visible via sticky +
       z-index. inset:0 in particular also sets bottom:0, which combined
       with top:0 on a sticky element locks it permanently in place instead
       of letting it scroll with its own normal-flow slot — inset:auto
       resets that so only top:0 constrains it. */
    transform: none;
    transition: none;
    pointer-events: auto;
}

.tbc-ps-section--stack .tbc-ps-card__inner {
    display: grid;
    grid-template-columns: 1fr 1fr;
    height: 100%;
}

.tbc-ps-section--stack .tbc-ps-card__left {
    height: 100%;
    min-height: 0;
}

@media (min-width:1024px) {   
    .tbc-ps-section--stack .tbc-ps-card__right {
        overflow-y: auto;
        height: 100%;
        scrollbar-width: none;
    }
}

/* Logged-in admin bar (32px desktop / 46px mobile, breakpoint 782px) eats
   into the real viewport without shrinking 100vh, so the card overflows by
   that exact amount and shows an unwanted inner scrollbar — compensate so
   reviewers browsing while logged in see the same fit as real visitors. */
body.admin-bar .tbc-ps-section--stack .tbc-ps-card {
    height: calc(100vh - 32px);
}

@media (max-width: 1024px) {
    body.admin-bar .tbc-ps-section--stack .tbc-ps-card {
        height: auto;
    }
    /* Disable the sticky stack below 1024px — revert to natural flow */
    .tbc-ps-section--stack .tbc-ps-card {
        position: relative;
        height: auto;
    }

    .tbc-ps-section--stack .tbc-ps-card__inner {
        grid-template-columns: 1fr;
        height: auto;
    }

    .tbc-ps-section--stack .tbc-ps-card__left {
        height: 100vw;
        min-height: 280px;
    }

    .tbc-ps-section--stack .tbc-ps-card__right {
        height: auto;
        /* overflow-y:auto above is only there for the desktop sticky stack,
           where a 100vh card can genuinely have taller content that needs
           its own internal scroll. On mobile the card is normal flow
           (height:auto, nothing to scroll internally), so leaving
           overflow-y:auto set here made this element its own (invisible,
           scrollbar-width:none) scroll container — any resting
           sub-pixel overflow was enough for it to capture touch-scroll
           ahead of the page, causing the screen-jump/non-smooth-scroll
           bug. visible removes that capture entirely. */
        overflow-y: visible;
    }
}

/* ── Product Content ── */
.tbc-ps-content {
    width: 100%;
    max-width: 540px;
    margin-inline: auto;
}

.tbc-ps-title,
.tbc-ps-desc h2{
    font-family: var(--tbc-font-heading);
    font-size: var(--fs-32-24);
    font-weight: 900;
    text-transform: uppercase;
    color: var(--ps-text);
    margin: 0 0 0.5rem;
    line-height: 1.2;
    margin-bottom: .5rem;
}

.tbc-ps-eyebrow {
    font-family: var(--tbc-font-body);
    font-size: 0.75rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 16%;
    color: var(--ps-text);
    margin-bottom: var(--space-40-20);
}

.tbc-ps-desc h2{
    margin-top: var(--space-40-20);
}
.tbc-ps-price {
    font-family: var(--tbc-font-body);
    font-size: clamp(1rem, 1.5vw, 1.25rem);
    font-weight: 800;
    color: var(--ps-text);
    margin-bottom: 1.5rem;
    margin-bottom: var(--space-40-20);
}

.tbc-ps-price .woocommerce-Price-amount,
.tbc-ps-price del,
.tbc-ps-price ins {
    color: inherit;
}

.tbc-ps-desc {
    font-family: var(--tbc-font-body);
    --fs-20-16: clamp(1rem, 0.714rem + 0.595vw, 1.25rem);
    font-size: var(--fs-20-16);
    line-height: 1.75;
    color: var(--ps-text);
    margin-bottom: 2rem;
}
@media (min-width: 1024px) {
    .tbc-ps-desc {
        max-width: 370px;
    }
}

.tbc-ps-desc p { 
    font-size: var(--fs-20-16);
    margin-bottom: 0.75rem; 
}
.tbc-ps-desc p:last-child { margin-bottom: 0; }

.tbc-ps-desc ul {
    list-style: disc;
    padding-left: 1.25rem;
    font-size: 1rem;
}

.tbc-ps-desc ul li {
    margin-bottom: 0.35rem;
}

/* ── Cart Form ── */
.tbc-ps-cart-form {
    display: flex;
    flex-direction: column;
    width: 390px;
    max-width: 100%;
}

.tbc-ps-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.tbc-ps-qty {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--ps-bg-qty);
    border-radius: 50px;
    padding: 0.25rem;
    flex-shrink: 0;
    justify-content: space-between;
    width: calc(40% - (1rem / 2));
}

.tbc-ps-qty__btn {
    width: 40px;
    height: 40px;
    border: none;
    background: none;
    font-size: 1.25rem;
    line-height: 1;
    color: var(--ps-text);
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.tbc-ps-qty__btn:hover {
    background: var(--ps-border-mid);
}

.tbc-ps-qty__value {
    font-family: var(--tbc-font-body);
    font-size: 1rem;
    font-weight: 600;
    color: var(--ps-text);
    min-width: 32px;
    text-align: center;
    user-select: none;
}

.tbc-ps-add-to-cart {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 2rem;
    background: var(--ps-btn-bg);
    color: var(--ps-btn-color);
    border: none;
    border-radius: 50px;
    font-family: var(--tbc-font-body);
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.15s ease;
    white-space: nowrap;
    width: calc(60% - (1rem / 2));
    justify-content: center;
}

.tbc-ps-add-to-cart:hover {
    background: var(--ps-btn-hover);
    color: var(--tbc-color-text);
}

.tbc-ps-add-to-cart:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.tbc-ps-add-to-cart.is-added {
    background: #22a06b;
    color: #ffffff;
}

/* Payment methods */
.tbc-ps-payment {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: flex-end;
}

.tbc-ps-payment img {
    height: 48px;
    width: auto;
    display: block;
    opacity: 0.8;
}

/* ── "See what's inside?" — scroll-to-next-panel link (multi-card scroll
   layout only; see .tbc-ps-split further down) ── */
.tbc-ps-cta-wrap {
    margin-top: 2rem;
    text-align: right;
}

.tbc-ps-scroll-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--tbc-font-body);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--ps-text);
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.tbc-ps-scroll-link svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.tbc-ps-scroll-link:hover {
    opacity: 0.7;
}

.tbc-ps-scroll-link:hover svg {
    transform: translateY(3px);
}

/* ── "Format Group" mode — Formats list (label + price pill, own qty
   stepper, own Add to Cart) ── */
.tbc-ps-formats {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 460px;
    max-width: 100%;
    margin-bottom: 1.5rem;
}

.tbc-ps-format-row {
    display: flex;
    align-items: center;
    gap: 1rem;
	flex-wrap: wrap;
}
.tbc-ps-section .added_to_cart.wc-forward {
    font-family: var(--tbc-font-body);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ps-text);
    text-decoration: underline;
    text-underline-offset: 3px;
    white-space: nowrap;
}

.tbc-ps-format-qty {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--ps-bg-qty);
    border-radius: 50px;
    padding: 0.25rem;
    flex-shrink: 0;
    justify-content: space-between;
    width: auto;
}

.tbc-ps-format-btn {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1.5rem;
    border: 1px solid var(--tbc-color-black);
    border-radius: 50px;
    font-family: var(--tbc-font-body);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.35s ease;
    white-space: nowrap;
}

.tbc-ps-format-btn.is-primary {
    background: var(--tbc-pink);
    border-color: var(--tbc-pink);
    color: var(--tbc-color-black);
}
.tbc-ps-format-btn.is-primary:hover,
.tbc-ps-format-btn.is-primary:focus-visible {
    background: var(--tbc-color-black);
    border-color: var(--tbc-color-black);
    color: #ffffff;
}

.tbc-ps-format-btn.is-secondary {
    background: var(--tbc-color-black);
    border-color: var(--tbc-color-black);
    color: #ffffff;
}

.tbc-ps-format-btn.is-secondary:hover,
.tbc-ps-format-btn.is-secondary:focus-visible {
    background: transparent;
    color: var(--tbc-color-black);
}

.tbc-ps-format-btn.is-added {
    background: #22a06b;
    color: #ffffff;
}

.tbc-ps-format-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.tbc-ps-note {
    font-family: var(--tbc-font-body);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ps-text);
    margin: -0.75rem 0 1.5rem;
}

/* ── "Format Group" mode, no Slides — "Stacked Pages" image layout (a
   pre-composed image + optional trust badge), in place of the square
   cover-image layout. ── */
.tbc-ps-card__left.is-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-40-20);
    aspect-ratio: auto;
    align-self: auto;
}

.tbc-ps-stack {
    width: 100%;
    max-width: 100%;
    margin-inline: auto;
}

.tbc-ps-stack img {
    width: 100%;
    height: auto;
    display: block;
}

.home-product-showcase .tbc-ps-stack {
    padding-top: var(--space-40-20);
}
.home-product-showcase .tbc-ps-stack img {
    width: 70%;
    margin-inline: auto;
}

.tbc-ps-badge {
    display: flex;
    align-items: center;
    gap: 2rem;
    width: 100%;
    max-width: 375px;
    margin-inline: auto;
}

@media (min-width: 1300px) {
    .home-product-showcase .tbc-ps-stack {
        padding-top: 4vw;
    }
    .home-product-showcase .tbc-ps-stack img {
        width: 532px;
        margin-right: 0;
    }
    .tbc-ps-badge{
        margin-right: 4rem;
    }
    .tbc-ps-content{
        margin-left: 0;
    }
}

.tbc-ps-badge__icon {
    --badge-size: 95px;
    width: var(--badge-size);
    height: var(--badge-size);
    flex-shrink: 0;
    display: block;
}

.tbc-ps-badge__copy {
    flex: 1 1 0%;
    min-width: 0;
    color: var(--ps-text);
}

.tbc-ps-badge__copy p {
    font-size: 1.125rem;
}

.tbc-ps-badge__title {
    font-weight: 700;
    margin: 0 0 0.2rem;
}

.tbc-ps-badge__text {
    line-height: 1.2;
    margin: 0;
}

/* Notice (product not found / WC not active) */
.tbc-ps-notice {
    font-family: var(--tbc-font-body);
    font-size: 0.9rem;
    padding: 2rem;
    border: 1px dashed var(--ps-border-mid);
    color: var(--ps-text);
}

/* ── Responsive ── */
@media (max-width: 1024px) {
    .tbc-ps-card__right {
        padding: var(--space-40-20);
    }
}

@media (max-width: 1024px) {
    .tbc-ps-slider {
        min-height: 0;
    }

    .tbc-ps-card__inner {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 0;
    }

    .tbc-ps-content{
        max-width: 100%;
        padding-block: 1rem;
    }
    
    .tbc-ps-card__left {
        aspect-ratio: 1 / 1;
        min-height: inherit;
    }

    .tbc-ps-card__right {
        height: auto;
        padding: var(--space-40-20) 1.25rem;
    }

    .home-product-showcase .tbc-ps-stack{
        padding-top: 0;
    }

    .home-product-showcase .tbc-ps-stack img{
        width: 100%;
    }

    .tbc-ps-badge{
        padding-inline: 1.25rem;
        max-width: 100%;
    }
    
    .tbc-ps-format-row .tbc-ps-format-qty {
        align-self: center;
    }
}
@media (max-width: 575px) {
    .tbc-ps-badge{
        gap: 1rem;
    }
    .tbc-ps-badge__icon {
        --badge-size: 85px;
    }
}
@media (max-width: 375px) {
    .tbc-ps-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .tbc-ps-qty{
        width: fit-content;
    }
    .tbc-ps-add-to-cart{
        width: 100%;
    }
    .tbc-ps-formats{
        row-gap: 1rem;
    }
    .tbc-ps-format-row {
        flex-direction: column;
        align-items: stretch;
    }
}
