/* 
 * Terrain Collective Shop Design - Light Glassmorphism
 * Refined Layout: Mobile Viewport Breakout, Typo Fix (Line-Height), Image Fix (Auto)
 */

/* Bug 5 Fix: Moved inline styles to class */
.image-wrapper {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    /* Default square, can be auto if needed but square is safer for grid */
    background: transparent;
    overflow: visible;
    margin-bottom: 8px;
    position: relative;
}

.product-link {
    display: block;
    width: 100%;
    height: 100%;
}

.product-img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    border-radius: 12px;
}

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@700;800&family=Inter:wght@300;400;500&display=swap');

:root {
    --bg: #F5F5F7;
    --layer-1: rgba(255, 255, 255, 0.4);
    --layer-2: rgba(255, 255, 255, 0.7);
    --accent: #007AFF;
    --text-main: #1A1A1A;
    --text-dim: #6E6E73;
    --glass-border: rgba(255, 255, 255, 0.6);
    --transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.05);
}

.woocommerce-shop,
.woocommerce-page {
    background-color: var(--bg) !important;
    color: var(--text-main);
    font-family: var(--font-family-base);
    overflow-x: hidden;
    min-height: 100vh;
}

/* .topo-bg Moved to layout.css for global usage */

header.shop-hero {
    padding: 60px 24px 20px;
    position: relative;
    z-index: 10;
    display: block;
}

.category-container {
    display: flex;
    gap: 12px;
    padding: 0 24px 40px;
    overflow-x: auto;
    scrollbar-width: none;
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
    z-index: 10;
}

.category-container::-webkit-scrollbar {
    display: none;
}

.category-pill {
    padding: 12px 24px;
    background: var(--layer-1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    white-space: nowrap;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-main);
    transition: var(--transition);
    box-shadow: var(--glass-shadow);
    text-decoration: none;
    display: inline-block;
}

.category-pill.active,
.category-pill:hover {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0, 122, 255, 0.3);
}

.shop-grid {
    display: block;
}

ul.products {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)) !important;
    gap: 32px !important;
    padding: 0 24px 80px !important;
    max-width: 1400px !important;
    margin: 0 auto !important;
    list-style: none !important;
}

@media (min-width: 1024px) {
    ul.products {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

ul.products::before,
ul.products::after {
    display: none !important;
}

li.product,
.product-card {
    background: var(--layer-1) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 16px !important;
    /* Slightly smaller radius for tighter feel */
    padding: 0 !important;
    padding-top: 32px !important;
    /* FULL BLEED: No padding around image */
    position: relative;
    transition: var(--transition);
    border: 1px solid var(--glass-border) !important;
    cursor: pointer;
    opacity: 0;
    transform: translateY(30px);
    box-shadow: var(--glass-shadow) !important;
    width: 100% !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden;
    /* Ensure content stays inside radius */
}

li.product.visible,
.product-card.visible {
    opacity: 1 !important;
    transform: translateY(0) !important;
}

li.product:hover,
.product-card:hover {
    transform: translateY(-5px);
    background: var(--layer-2) !important;
    border-color: var(--accent);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08) !important;
    z-index: 5;
}

.image-wrapper {
    width: 100%;
    /* aspect-ratio: removed to let image dictate height */
    border-radius: 0 !important;
    /* Let card handle radius */
    overflow: hidden;
    background: transparent !important;
    position: relative;
    margin-bottom: 0 !important;
    /* No space between image and text area */
    padding: 0 !important;
    display: block !important;
}

.image-wrapper a {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
}

.product-img,
li.product a img {
    /* Prevent Stretching: Auto width/height with max constraints */
    width: auto !important;
    height: auto !important;
    max-width: 100% !important;
    max-height: 100% !important;

    object-fit: contain !important;
    transition: var(--transition);
    margin: 0 !important;
    border-radius: 8px !important;
}

.card-info {
    padding: 0 32px 5px 32px !important;
    /* Add internal padding for text */
    width: 100%;
    box-sizing: border-box !important;
    text-align: left;
    /* Ensure left align */
}

.product-label {
    display: none !important;
}

/* FIX: Text Clipping */
.product-name,
li.product h3,
li.product .woocommerce-loop-product__title {
    font-family: var(--font-family-base);
    font-size: 1.1rem;
    color: var(--text-main);
    margin-bottom: 8px !important;
    text-decoration: none;

    padding: 0 !important;
    display: block !important;
    overflow: visible !important;
    height: auto !important;
    white-space: normal !important;
}

li.product h3 a {
    color: var(--text-main);
    text-decoration: none;
    display: block;
    /* Ensure anchor takes full height */
    line-height: 1.5 !important;
}

.price-row {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    margin-top: 8px !important;
    width: 100% !important;
    gap: 12px;
}

.product-price,
li.product .price {
    font-weight: 500;
    color: var(--text-main);
    font-family: var(--font-family-base);
    margin: 0 !important;
    font-size: 1.05rem;
    line-height: 1;
    width: auto !important;
    white-space: nowrap !important;
}

li.product .price del {
    color: #999;
    margin-right: 5px;
}

/* Inline Add to Cart Button */
.add-cart-btn {
    position: relative !important;
    bottom: auto !important;
    right: auto !important;
    width: 44px !important;
    height: 44px !important;
    background: var(--accent) !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer;
    transition: var(--transition);
    opacity: 1 !important;
    transform: none !important;
    z-index: 5;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.2) !important;
    padding: 0 !important;
    font-size: 0 !important;
}

.add-cart-btn:hover {
    transform: scale(1.1) !important;
    background: #0062cc !important;
}

.add-cart-btn::after,
.add-cart-btn::before {
    display: none !important;
    content: none !important;
}

a.added_to_cart {
    display: none !important;
}

@keyframes cart-pop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.4);
        background: #1A1A1A;
        color: #fff;
    }

    100% {
        transform: scale(1);
    }
}

.add-cart-btn.btn-success {
    animation: cart-pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background: #1A1A1A !important;
    color: #fff !important;
}

/* 
   MOBILE VIEWPORT BREAKOUT for UL.PRODUCTS only
*/
@media (max-width: 600px) {

    html,
    body {
        overflow-x: hidden !important;
        position: relative;
    }

    .shop-grid {
        display: block !important;
        width: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
    }

    /* Restore grid for widgets/generic lists (No Breakout) */
    ul.products,
    ul.products.columns-4,
    body.woocommerce-shop ul.products,
    body.woocommerce-shop ul.products.columns-4 {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 0 80px !important;
        box-sizing: border-box !important;
        left: auto !important;
        right: auto !important;
    }

    .shop-grid ul.products {
        /* Redundant safety, inherits from above */
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        width: 100% !important;
        padding: 0 0 80px !important;
    }

    body.woocommerce-shop {
        padding: 0 !important;
    }

    li.product,
    .product-card {
        padding: 0px !important;
        padding-top: 12px !important;
        border-radius: 8px !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        box-sizing: border-box !important;

        /* Force visibility on mobile to avoid JS race conditions */
        opacity: 1 !important;
        transform: none !important;
    }

    .product-name,
    li.product h3,
    li.product .woocommerce-loop-product__title {
        font-size: 0.8rem !important;
        margin-bottom: 6px !important;
        padding: 0 !important;
        height: auto !important;
    }

    .product-price,
    li.product .price {
        font-size: 0.85rem !important;
    }

    .image-wrapper {
        margin-bottom: 1px !important;
    }

    .add-cart-btn {
        width: 32px !important;
        height: 32px !important;
        border-radius: 8px !important;
    }

    .add-cart-btn svg {
        width: 14px !important;
        height: 14px !important;
    }

    .card-info {
        padding: 0 16px 3px 16px !important;
        width: 100%;
        box-sizing: border-box !important;
        text-align: left;
    }
}