/**
 * SHOPEE AFFILIATE LANDING PAGE - CSS
 * Mobile-first, performance-optimized styles
 * All layout values are overrideable via CSS custom properties
 */

/* ============================================
   CSS CUSTOM PROPERTIES (Configurable via JS)
   ============================================ */
:root {
    /* Grid Configuration */
    --mobile-columns: 2;
    --desktop-columns: 4;
    --grid-gap: 12px;
    
    /* Brand Colors */
    --primary-color: #ee4d2d;
    --primary-hover: #d73211;
    --bg-color: #f5f5f5;
    --card-bg: #ffffff;
    --text-primary: #222222;
    --text-secondary: #757575;
    --shadow-color: rgba(0, 0, 0, 0.08);
    
    /* Spacing */
    --container-padding: 12px;
    --card-padding: 8px;
    --card-radius: 8px;
    
    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* ============================================
   RESET & BASE STYLES
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.4;
    min-height: 100vh;
    overflow-x: hidden;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    text-decoration: none;
    color: inherit;
    -webkit-touch-callout: none;
}

/* ============================================
   HEADER SECTION
   ============================================ */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
    padding: 16px var(--container-padding);
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px var(--shadow-color);
}

.header[hidden] {
    display: none;
}

.header__title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 4px;
    letter-spacing: -0.02em;
}

.header__subtitle {
    font-size: 0.875rem;
    opacity: 0.9;
    font-weight: 400;
}

/* ============================================
   HERO SECTION
   ============================================ */
.hero {
    width: 100%;
    overflow: hidden;
}

.hero[hidden] {
    display: none;
}

.hero__image {
    width: 100%;
    height: auto;
    object-fit: cover;
    display: block;
}

/* ============================================
   PRODUCT GRID
   ============================================ */
.product-grid {
    display: grid;
    grid-template-columns: repeat(var(--mobile-columns), 1fr);
    gap: var(--grid-gap);
    padding: var(--container-padding);
    max-width: 1200px;
    margin: 0 auto;
}

/* ============================================
   PRODUCT CARD
   ============================================ */
.product-card {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    overflow: hidden;
    box-shadow: 0 1px 4px var(--shadow-color);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    
    /* Touch optimization */
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.product-card:active {
    transform: scale(0.97);
    box-shadow: 0 1px 2px var(--shadow-color);
}

/* Hover effect for desktop */
@media (hover: hover) {
    .product-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    }
}

.product-card__image-wrapper {
    position: relative;
    width: 100%;
    padding-top: 100%; /* 1:1 Aspect ratio */
    overflow: hidden;
    background: #f8f8f8;
}

.product-card__image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.2s ease;
}

/* Lazy loading placeholder */
.product-card__image[data-src] {
    opacity: 0;
}

.product-card__image.loaded {
    opacity: 1;
}

.product-card__content {
    padding: var(--card-padding);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-card__title {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.35;
    
    /* Clamp to 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    
    /* Minimum height for consistency */
    min-height: 2.2em;
}

/* Hide title container if empty */
.product-card__content:empty {
    display: none;
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
    text-align: center;
    padding: 24px var(--container-padding);
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* ============================================
   LOADING STATE
   ============================================ */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* Small tablets */
@media (min-width: 480px) {
    :root {
        --grid-gap: 16px;
        --container-padding: 16px;
    }
    
    .product-card__title {
        font-size: 0.875rem;
    }
}

/* Tablets */
@media (min-width: 768px) {
    :root {
        --container-padding: 24px;
    }
    
    .product-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .header__title {
        font-size: 1.5rem;
    }
    
    .header__subtitle {
        font-size: 1rem;
    }
}

/* Desktop */
@media (min-width: 1024px) {
    .product-grid {
        grid-template-columns: repeat(var(--desktop-columns), 1fr);
    }
    
    .product-card__title {
        font-size: 0.9375rem;
    }
}

/* Large Desktop */
@media (min-width: 1400px) {
    :root {
        --grid-gap: 20px;
    }
    
    .product-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .product-card {
        transition: none;
    }
    
    .skeleton {
        animation: none;
    }
}

/* Focus visible for keyboard navigation */
.product-card:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}
