/**
 * Forge storefront: template-owned EasyCommerce pages (shop, category,
 * product, cart). Loaded lazily by the com_easycommerce overrides.
 * Everything derives from the token layer; the product grid density
 * comes straight from --ec-grid.
 */

.ts-store {
    padding-block: calc(var(--ec-sect-y) / 2) var(--ec-sect-y);
}

/* Hero */
.ts-hero {
    position: relative;
    padding: var(--ec-sect-y) clamp(1.5rem, 5vw, 4rem);
    text-align: center;
    overflow: hidden;
    border-radius: var(--ec-radius);
}

.ts-hero--left {
    text-align: left;
}

.ts-hero__inner {
    position: relative;
    z-index: 1;
    max-width: 42rem;
    margin-inline: auto;
}

.ts-hero--left .ts-hero__inner {
    margin-inline: 0;
}

/* Default background (no merchant image): soft accent gradient blobs over
   the sunken surface with a faint dot grid. Token-driven, so it adapts to
   the active preset automatically. */
.ts-hero:not(.ts-hero--image) {
    display: flex;
    align-items: center;
    min-height: 44vh;
    border: 1px solid var(--ec-border);
    background-color: var(--ec-surface-2);
    background-image:
        radial-gradient(62% 80% at 12% 8%, var(--ec-accent-soft) 0%, transparent 60%),
        radial-gradient(54% 74% at 92% 4%, var(--ec-accent-soft) 0%, transparent 55%),
        radial-gradient(var(--ec-border) 1px, transparent 1.5px);
    background-size: 100% 100%, 100% 100%, 24px 24px;
}

.ts-hero:not(.ts-hero--image):not(.ts-hero--left) {
    justify-content: center;
}

/* Background image + contrast overlay */
.ts-hero--image {
    padding-inline: clamp(1.5rem, 5vw, 4rem);
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.ts-hero--image.ts-hero--left {
    justify-content: flex-start;
}

.ts-hero--image .ts-hero__eyebrow,
.ts-hero--image .ts-hero__desc {
    color: rgba(255, 255, 255, 0.85);
}

.ts-hero--image .ts-hero__title {
    color: #fff;
}

.ts-hero__bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
}

.ts-hero--image::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 0;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.55));
}

.ts-hero--image .ts-hero__inner {
    max-width: 42rem;
}

.ts-hero__eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.8rem;
    color: var(--ec-fg-2);
    margin-bottom: 0.75rem;
}

.ts-hero__title {
    font-size: clamp(2rem, 5vw, 3.25rem);
    max-width: 24ch;
}

.ts-hero:not(.ts-hero--left) .ts-hero__title {
    margin-inline: auto;
}

/* Section rhythm */
.ts-store-section {
    margin-top: var(--ec-sect-y);
}

.ts-store-section__title {
    font-size: 1.5rem;
    margin-bottom: 1.25rem;
}

.ts-store-header {
    margin-bottom: 1.5rem;
}

.ts-store-header__eyebrow {
    font-size: 0.85rem;
    color: var(--ec-fg-2);
}

.ts-store-header__title {
    font-size: clamp(1.6rem, 4vw, 2.4rem);
    margin-bottom: 0.35rem;
}

.ts-store-header__desc {
    color: var(--ec-fg-2);
    max-width: 60ch;
}

.ts-store-empty {
    color: var(--ec-fg-2);
    padding-block: var(--ec-sect-y);
    text-align: center;
}

/* Product grid: density from the token layer */
.ts-products {
    display: grid;
    grid-template-columns: repeat(var(--ec-grid), minmax(0, 1fr));
    gap: var(--ec-grid-gap);
}

@media (max-width: 1023.98px) {
    .ts-products {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 639.98px) {
    .ts-products {
        grid-template-columns: 1fr;
    }
}

/* Product card */
.ts-pcard {
    display: flex;
    flex-direction: column;
    background: var(--ec-surface);
    border: 1px solid var(--ec-border);
    border-radius: var(--ec-radius);
    box-shadow: var(--ec-shadow);
    overflow: hidden;
    transition: transform var(--ec-dur-2) var(--ec-ease);
}

.ts-pcard:hover {
    transform: translateY(-3px);
}

.ts-pcard__media {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    background: var(--ec-surface-2);
    overflow: hidden;
}

.ts-pcard__media img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    /* cover so product photos fill the thumbnail edge to edge (like the
       default storefront) instead of floating in whitespace; the fixed
       16/9 media box keeps the grid tidy. */
    object-fit: cover;
    border-radius: 0;
    transition: transform var(--ec-dur-3) var(--ec-ease);
}

.ts-pcard:hover .ts-pcard__media img {
    transform: scale(1.03);
}

.ts-pcard__placeholder {
    display: block;
    width: 100%;
    height: 100%;
    background: var(--ec-surface-2);
}

.ts-pcard__body {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 1rem;
}

.ts-pcard__stock {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    font-size: 0.75rem;
    color: var(--ec-fg-2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ts-pcard__stock-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #16a34a;
}

.ts-badge--type {
    background: var(--ec-surface);
    color: var(--ec-fg);
    border: 1px solid var(--ec-border);
}

.ts-pcard__title {
    font-size: 1rem;
    margin: 0;
}

.ts-pcard__title a {
    color: var(--ec-fg);
    text-decoration: none;
}

.ts-pcard__title a:hover {
    color: var(--ec-accent);
}

.ts-pcard__price {
    margin: 0;
    font-weight: 600;
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
}

.ts-pcard__compare {
    color: var(--ec-fg-2);
    font-weight: 400;
    font-size: 0.9em;
}

.ts-pcard__add {
    margin-top: 0.35rem;
    align-self: flex-start;
}

/* Badges */
.ts-badge {
    position: absolute;
    top: 0.6rem;
    left: 0.6rem;
    padding: 0.2rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: 999px;
    background: var(--ec-accent);
    color: var(--ec-accent-fg);
}

.ts-badge--stock {
    background: var(--ec-fg-2);
    color: var(--ec-bg);
}

.ts-product__price .ts-badge {
    position: static;
}

/* Trust bar */
.ts-trustbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem 2.5rem;
    margin-top: var(--ec-sect-y);
    padding: 1.25rem;
    border-block: 1px solid var(--ec-border);
    text-align: center;
}

.ts-trustbar__item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--ec-fg-2);
}

.ts-trustbar__item svg {
    color: var(--ec-accent);
    flex: none;
}

/* Story / editorial */
.ts-story {
    margin-top: var(--ec-sect-y);
    padding: var(--ec-sect-y) 0;
    background: var(--ec-surface-2);
    border-radius: var(--ec-radius);
    text-align: center;
}

.ts-story__inner {
    max-width: 46rem;
    margin-inline: auto;
    padding-inline: var(--ec-gut);
}

.ts-story__title {
    font-size: clamp(1.6rem, 4vw, 2.4rem);
}

.ts-story__body {
    color: var(--ec-fg-2);
    font-size: 1.1rem;
}

/* Newsletter */
.ts-newsletter {
    margin-top: var(--ec-sect-y);
    text-align: center;
    max-width: 34rem;
    margin-inline: auto;
}

.ts-newsletter__title {
    font-size: 1.5rem;
}

.ts-newsletter__body {
    color: var(--ec-fg-2);
}

.ts-newsletter__form {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.ts-newsletter__form input {
    flex: 1;
}

.ts-newsletter__done {
    margin-top: 1rem;
    color: var(--ec-accent);
    font-weight: 600;
}

@media (max-width: 479.98px) {
    .ts-newsletter__form {
        flex-direction: column;
    }
}

/* Category tiles */
.ts-cat-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
    gap: var(--ec-grid-gap);
}

.ts-cat-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 6.5rem;
    padding: 1rem;
    background: var(--ec-surface-2);
    border: 1px solid var(--ec-border);
    border-radius: var(--ec-radius);
    color: var(--ec-fg);
    text-decoration: none;
    font-family: var(--ec-font-display);
    font-size: 1.15rem;
    transition: border-color var(--ec-dur-1) var(--ec-ease);
}

.ts-cat-tile:hover {
    border-color: var(--ec-accent);
    color: var(--ec-accent);
}

/* Product page */
.ts-product {
    display: grid;
    grid-template-columns: minmax(0, 6fr) minmax(0, 5fr);
    gap: clamp(1.5rem, 4vw, 3.5rem);
    align-items: start;
    margin-top: 1.5rem;
}

@media (max-width: 899.98px) {
    .ts-product {
        grid-template-columns: 1fr;
    }
}

/* Gallery: a framed, contained media panel so banner or square product
   images show in full without being cropped or blown up. */
.ts-product__gallery {
    position: sticky;
    top: 1.5rem;
}

@media (max-width: 899.98px) {
    .ts-product__gallery {
        position: static;
    }
}

.ts-product__image {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: contain;
    padding: clamp(1rem, 3vw, 2rem);
    border: 1px solid var(--ec-border);
    border-radius: var(--ec-img-radius);
    background: var(--ec-surface-2);
}

.ts-product__thumbs {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.ts-product__thumb {
    appearance: none;
    padding: 0;
    border: 2px solid var(--ec-border);
    border-radius: var(--ec-img-radius);
    background: var(--ec-surface-2);
    cursor: pointer;
    width: 64px;
    height: 64px;
    overflow: hidden;
    transition: border-color var(--ec-dur-1) var(--ec-ease);
}

.ts-product__thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 4px;
}

.ts-product__thumb.is-active {
    border-color: var(--ec-accent);
}

/* Info column */
.ts-product__info {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ts-product__title {
    margin: 0;
    font-size: clamp(1.7rem, 3.5vw, 2.5rem);
    line-height: 1.1;
}

.ts-product__price {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ec-fg);
}

.ts-product__stock {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
}

.ts-product__stock.is-in {
    color: #15803d;
}

.ts-product__stock.is-out {
    color: var(--ec-fg-2);
}

.ts-product__summary {
    margin: 0;
    color: var(--ec-fg-2);
    line-height: 1.65;
}

.ts-product__buy {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: stretch;
    margin-top: 0.5rem;
}

/* Fixed-width qty; the two-class selector out-ranks the global
   input[type="number"] { width: 100% } baseline. */
.ts-product__buy .ts-product__qty {
    flex: 0 0 auto;
    width: 5rem;
    min-height: 44px;
    text-align: center;
    border: 1px solid var(--ec-border);
    border-radius: var(--ec-btn-radius);
    background: var(--ec-surface);
    color: var(--ec-fg);
    font-size: 1rem;
}

/* Add-to-cart fills the rest of the row and never wraps its label. */
.ts-product__buy .ts-btn {
    flex: 1 1 auto;
    min-width: 11rem;
    white-space: nowrap;
}

.ts-product__description {
    max-width: 72ch;
    line-height: 1.7;
    color: var(--ec-fg);
}
