/* ==========================================================================
   GOPAL KRISHI KENDRA - THEME ENGINE CSS
   Premium Agricultural E-Commerce Experience
   ========================================================================== */

:root {
    /* Default Theme Colors */
    --theme-primary: #10b981;
    --theme-secondary: #059669;
    --theme-bg-start: #ecfdf5;
    --theme-bg-end: #d1fae5;
    --theme-accent: #34d399;
    
    /* Animation Tokens */
    --theme-transition: 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    --spring-transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ==========================================================================
   1. GLOBAL STYLES & LAYOUT
   ========================================================================== */

body {
    background: linear-gradient(135deg, var(--theme-bg-start) 0%, var(--theme-bg-end) 100%);
    transition: background var(--theme-transition);
    position: relative;
    overflow-x: hidden;
    min-height: 100vh;
}

* {
    transition-property: background-color, color, border-color, box-shadow, transform;
    transition-duration: var(--theme-transition);
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Performance optimization for rapid-change elements */
input, textarea, .no-theme-transition, video, canvas {
    transition: none !important;
}

/* ==========================================================================
   2. MAIN STICKY HEADER SYSTEM
   ========================================================================== */

#shop-header-system {
    background-color: rgba(var(--theme-rgb, 37, 99, 235), 0.85) !important;
    backdrop-filter: blur(25px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    height: auto;
    z-index: 50;
    transition: max-height 0.4s ease, transform 0.4s ease;
}

.sticky-wrapper {
    position: sticky;
    top: -80px; /* Tucks branding away on scroll */
    z-index: 50;
}

#header-branding {
    transition: all 0.4s var(--theme-transition);
    will-change: transform, max-height, opacity;
}

#main-search {
    background: rgba(255, 255, 255, 0.9) !important;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

/* ==========================================================================
   3. CATEGORY NAVIGATION (IMAGE-BASED)
   ========================================================================== */

#categoryShowcase {
    transition: background var(--theme-transition);
}

.category-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    height: auto;
    transition: all 0.3s var(--theme-transition);
}

.category-img-wrapper {
    width: 3.5rem;
    height: 3.5rem;
    transition: all 0.4s var(--spring-transition);
    will-change: transform, max-height, opacity;
}

#categoryShowcase .category-item {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
}

/* Category State: Scrolled Compact */
.category-item.scrolled-compact {
    background: rgba(255, 255, 255, 0.15);
    padding: 6px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.category-item.scrolled-compact span {
    font-size: 11px;
    letter-spacing: 0.02em;
}

/* ==========================================================================
   4. UNIFIED INTERACTION BAR (FILTER + SUBS)
   ========================================================================== */

.interaction-bar-wrapper {
    position: sticky;
    top: 175px; 
    z-index: 45;
    margin-top: -10px;
    padding: 10px 16px;
    transition: transform 0.4s ease, top 0.4s ease;
}

.interaction-container {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.2) !important;
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

#filterSection {
    background: transparent !important;
    border: none !important;
    backdrop-filter: none !important;
    box-shadow: none !important;
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    padding-right: 12px;
    flex-shrink: 0;
}

#filterSection i {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    color: white;
}

#filterSection span {
    font-size: 8px;
    font-weight: 900;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.9;
}

/* Subcategory Chips */
.subcategory-chip {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: none;    
    transition: all 0.3s var(--theme-transition);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.subcategory-chip.active-subcategory {
    background: #ffffff !important;
    border-color: #ffffff !important;
    transform: scale(1.05);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

#subcategorySection {
    mask-image: linear-gradient(to right, black 85%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, black 85%, transparent 100%);
}

/* ==========================================================================
   5. PRODUCT LIST & CARDS
   ========================================================================== */

#productList {
    margin-top: 5px;
    padding-bottom: 120px;
    z-index: 10;
}

.product-card {
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 0 20px var(--theme-accent);
    border-color: var(--theme-primary);
}

/* ==========================================================================
   6. TREASURE STORE & COMPONENTS
   ========================================================================== */

#insta-store-wrapper {
    background: linear-gradient(135deg, var(--theme-bg-start) 0%, var(--theme-bg-end) 100%) !important;
    position: relative;
}

#insta-store-wrapper h1 {
    background: linear-gradient(90deg, var(--theme-primary), var(--theme-secondary), var(--theme-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-size: 200% 100%;
    animation: shimmer 3s infinite linear;
}

#offer-progress-bar {
    background: linear-gradient(90deg, var(--theme-primary), var(--theme-accent), var(--theme-primary)) !important;
    background-size: 200% 100%;
    animation: progressShine 2s infinite linear;
    box-shadow: 0 2px 8px var(--theme-accent), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* ==========================================================================
   7. THEME DATA ATTRIBUTES
   ========================================================================== */

body[data-theme="all"] { --theme-primary: #16a34a; --theme-bg-start: #f0fdf4; --theme-bg-end: #dcfce7; }
body[data-theme="seeds"] { --theme-primary: #f59e0b; --theme-bg-start: #fffbeb; --theme-bg-end: #fef3c7; }
body[data-theme="cropprotection"] { --theme-primary: #059669; --theme-bg-start: #f0fdfa; --theme-bg-end: #ccfbf1; }
body[data-theme="cropnutrition"] { --theme-primary: #84cc16; --theme-bg-start: #f7fee7; --theme-bg-end: #ecfccb; }
body[data-theme="agrotools"] { --theme-primary: #0891b2; --theme-bg-start: #f0fdfa; --theme-bg-end: #cffafe; }

/* ==========================================================================
   8. BACKGROUND ANIMATIONS & PATTERNS
   ========================================================================== */

body::before {
    content: '';
    position: fixed;
    top: -50%; right: -50%; width: 200%; height: 200%;
    background: radial-gradient(circle at center, var(--theme-accent) 0%, transparent 70%);
    opacity: 0.15; z-index: -1;
    animation: gentleRotate 30s infinite linear;
}

@keyframes gentleRotate { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 0% 50%; } 100% { background-position: 200% 50%; } }
@keyframes progressShine { 0% { background-position: 0% 50%; } 100% { background-position: 200% 50%; } }

/* ==========================================================================
   9. MOBILE & ACCESSBILITY
   ========================================================================== */

@media (max-width: 768px) {
    .scrolled #header-icon-box { transform: scale(0.7); margin-bottom: -10px; }
    .scrolled #theme-title { font-size: 1.2rem; }
    body::before { animation: none; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition-duration: 0.1s !important; animation-duration: 0.1s !important; }
}



/* theme-engine.css */

/* This name must be unique for the transition to work */
.product-hero-transition {
    view-transition-name: product-image;
}

/* Ensure the browser handles the transition smoothly */
::view-transition-old(product-image),
::view-transition-new(product-image) {
    animation-duration: 0.5s;
    animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}
