/*
 * Storefront widgets — base styles.
 *
 * Every property uses CSS custom properties set by Storefront\Theme::styleTag.
 * Sites override by passing different values in config['theme'], OR by
 * loading a site-specific stylesheet AFTER this one (CSS specificity wins;
 * nothing in here uses !important).
 *
 * Class-name convention: every selector is prefixed `.storefront-` so styles
 * never leak into the host page's existing markup.
 */

/* ===== reset / base ===== */
.storefront-section,
.storefront-product-grid,
.storefront-product-card,
.storefront-add-to-cart,
.storefront-cart-badge,
.storefront-intro {
    box-sizing: border-box;
    font-family: var(--storefront-font-body, system-ui, sans-serif);
    color: var(--storefront-text, #222);
}

/* ===== section wrapper ===== */
.storefront-section {
    background: var(--storefront-background, #fff);
    padding: 4rem 1rem;
}
.storefront-section .section-inner {
    max-width: 1200px;
    margin: 0 auto;
}
.storefront-section .section-label {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--storefront-muted, #777);
    margin: 0 0 0.5rem;
}
.storefront-section .section-title {
    font-family: var(--storefront-font-heading, inherit);
    font-size: 2.5rem;
    margin: 0 0 1rem;
    color: var(--storefront-text, #222);
}
.storefront-section .section-divider {
    width: 60px;
    height: 3px;
    background: var(--storefront-primary, #c41e3a);
    margin-bottom: 1.5rem;
}
.storefront-intro {
    font-size: 1.0625rem;
    color: var(--storefront-muted, #777);
    margin: 0 0 2rem;
    max-width: 60ch;
}

/* ===== product grid ===== */
.storefront-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
}
.storefront-product-grid[data-loading="true"]::before {
    content: "";
    grid-column: 1 / -1;
    height: 200px;
    background: var(--storefront-surface, #f8f8f8);
    border-radius: var(--storefront-radius, 6px);
    /* Subtle pulse so it reads as loading rather than empty. */
    animation: storefront-pulse 1.5s ease-in-out infinite;
}
@keyframes storefront-pulse {
    0%, 100% { opacity: 0.6; }
    50%      { opacity: 1; }
}

/* ===== product card ===== */
.storefront-product-card {
    background: var(--storefront-surface, #f8f8f8);
    border: 1px solid var(--storefront-border, #e5e5e5);
    border-radius: var(--storefront-radius, 6px);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.storefront-product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
}
.storefront-product-card img {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 1 / 1;
    object-fit: cover;
}
.storefront-product-card .storefront-product-info {
    padding: 1rem;
}
.storefront-product-card-image {
    display: block;
}
.storefront-product-card .storefront-product-title {
    margin: 0 0 0.5rem;
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--storefront-text, #222);
}
.storefront-product-card .storefront-product-price {
    color: var(--storefront-primary, #c41e3a);
    font-weight: 600;
    margin: 0 0 1rem;
}
.storefront-product-card .storefront-view-details {
    display: block;
    text-align: center;
    width: 100%;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
}

/* ===== buttons ===== */
.storefront-add-to-cart,
.storefront-button {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: 2px solid var(--storefront-primary, #c41e3a);
    background: var(--storefront-primary, #c41e3a);
    color: var(--storefront-primary-text, #fff);
    border-radius: var(--storefront-radius, 6px);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.storefront-add-to-cart:hover,
.storefront-button:hover {
    transform: translateY(-1px);
}
.storefront-add-to-cart:active,
.storefront-button:active {
    transform: translateY(0);
}

/* outline variant — set body class or theme.button_style='outline' */
[data-storefront-button-style="outline"] .storefront-add-to-cart,
.storefront-button.is-outline {
    background: transparent;
    color: var(--storefront-primary, #c41e3a);
}

/* pill variant */
[data-storefront-button-style="pill"] .storefront-add-to-cart,
.storefront-button.is-pill {
    border-radius: 999px;
}

/* ===== cart badge ===== */
.storefront-cart-badge {
    color: var(--storefront-text, #222);
    text-decoration: none;
    font-weight: 500;
}
.storefront-cart-badge[data-cart-count]:not(.is-empty)::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--storefront-primary, #c41e3a);
    border-radius: 50%;
    margin-right: 0.4em;
    vertical-align: middle;
}

/* ===== responsive ===== */
@media (max-width: 640px) {
    .storefront-section { padding: 2.5rem 1rem; }
    .storefront-section .section-title { font-size: 1.875rem; }
    .storefront-product-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 1rem;
    }
}
