/* ==========================================================================
   LinkBoost - Premium Design System
   Inspired by Apple & Stripe design patterns
   ========================================================================== */

/* CSS Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Premium Color Palette */
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;

    /* Layered gradient backgrounds (Stripe-inspired) */
    --bg-gradient:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(120, 119, 198, 0.3), transparent),
        linear-gradient(180deg, #0f0f1a 0%, #1a1a2e 50%, #0d0d14 100%);

    --desktop-gradient:
        radial-gradient(ellipse at 30% 0%, rgba(99, 102, 241, 0.4) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 100%, rgba(244, 114, 182, 0.3) 0%, transparent 50%),
        radial-gradient(ellipse at 100% 50%, rgba(56, 189, 248, 0.2) 0%, transparent 40%),
        linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #1e1b4b 100%);

    /* Card styles with glassmorphism */
    --card-bg: rgba(255, 255, 255, 0.04);
    --card-bg-hover: rgba(255, 255, 255, 0.08);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-border-hover: rgba(255, 255, 255, 0.15);
    --card-glow: 0 0 40px rgba(99, 102, 241, 0.15);

    /* Typography */
    --text-primary: #f8fafc;
    --text-secondary: rgba(248, 250, 252, 0.7);
    --text-muted: rgba(248, 250, 252, 0.45);

    /* Shadows - more subtle & layered */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);
    --shadow-md:
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg:
        0 20px 25px -5px rgba(0, 0, 0, 0.2),
        0 10px 10px -5px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 60px rgba(99, 102, 241, 0.2);

    /* Border radius - more refined */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --radius-full: 9999px;

    /* Transitions - Stripe-style cubic-bezier */
    --ease-out: cubic-bezier(0.215, 0.61, 0.355, 1);
    --ease-in-out: cubic-bezier(0.645, 0.045, 0.355, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Spacing scale */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.01em;
}

/* Desktop: Immersive animated galaxy background */
@media (min-width: 768px) {
    body {
        background: #0a0a0f;
        display: flex;
        justify-content: center;
        align-items: flex-start;
        padding: var(--space-2xl) var(--space-lg);
        overflow-x: hidden;
    }

    body::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background:
            radial-gradient(ellipse at 20% 20%, rgba(88, 28, 135, 0.4) 0%, transparent 50%),
            radial-gradient(ellipse at 80% 80%, rgba(15, 23, 42, 0.8) 0%, transparent 50%),
            radial-gradient(ellipse at 40% 60%, rgba(59, 130, 246, 0.3) 0%, transparent 40%),
            radial-gradient(ellipse at 70% 30%, rgba(236, 72, 153, 0.25) 0%, transparent 45%);
        animation: nebulaDrift 20s ease-in-out infinite alternate;
        z-index: -3;
    }

    body::after {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 200%;
        height: 200%;
        background-image:
            radial-gradient(2px 2px at 20px 30px, white, transparent),
            radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.8), transparent),
            radial-gradient(1px 1px at 90px 40px, white, transparent),
            radial-gradient(2px 2px at 160px 120px, rgba(255,255,255,0.9), transparent),
            radial-gradient(1px 1px at 230px 80px, white, transparent),
            radial-gradient(2px 2px at 300px 150px, rgba(255,255,255,0.7), transparent),
            radial-gradient(1px 1px at 370px 200px, white, transparent),
            radial-gradient(2px 2px at 450px 50px, rgba(255,255,255,0.8), transparent),
            radial-gradient(1px 1px at 520px 180px, white, transparent),
            radial-gradient(2px 2px at 600px 100px, rgba(255,255,255,0.9), transparent),
            radial-gradient(1px 1px at 680px 250px, white, transparent),
            radial-gradient(2px 2px at 750px 30px, rgba(255,255,255,0.7), transparent),
            radial-gradient(1px 1px at 820px 160px, white, transparent),
            radial-gradient(2px 2px at 900px 220px, rgba(255,255,255,0.8), transparent),
            radial-gradient(1px 1px at 100px 300px, white, transparent),
            radial-gradient(2px 2px at 200px 350px, rgba(255,255,255,0.9), transparent),
            radial-gradient(1px 1px at 350px 400px, white, transparent),
            radial-gradient(2px 2px at 500px 320px, rgba(255,255,255,0.7), transparent),
            radial-gradient(1px 1px at 650px 380px, white, transparent),
            radial-gradient(2px 2px at 800px 340px, rgba(255,255,255,0.8), transparent);
        background-size: 1000px 500px;
        animation: starFloat 60s linear infinite;
        z-index: -2;
    }
}

@keyframes nebulaDrift {
    0% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: scale(1.1) rotate(2deg);
        opacity: 0.8;
    }
    100% {
        transform: scale(1.05) rotate(-1deg);
        opacity: 1;
    }
}

@keyframes starFloat {
    0% {
        transform: translateY(0) translateX(0);
    }
    100% {
        transform: translateY(-500px) translateX(-500px);
    }
}

/* ==========================================================================
   Container - Mobile First
   ========================================================================== */
.container {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: var(--space-lg) var(--space-md);
    min-height: 100vh;
}

/* Desktop: Floating card container */
@media (min-width: 768px) {
    .container {
        background: var(--bg-gradient);
        background-attachment: scroll;
        border-radius: var(--radius-xl);
        border: 1px solid var(--card-border);
        box-shadow:
            var(--shadow-lg),
            var(--shadow-glow),
            inset 0 1px 0 rgba(255, 255, 255, 0.05);
        min-height: auto;
        max-height: 90vh;
        overflow-y: auto;
        padding: var(--space-xl) var(--space-lg);
        scrollbar-width: thin;
        scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
    }

    .container::-webkit-scrollbar {
        width: 8px;
    }

    .container::-webkit-scrollbar-track {
        background: transparent;
        border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
        margin: 4px 0;
    }

    .container::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.15);
        border-radius: 4px;
        border: 2px solid transparent;
        background-clip: padding-box;
    }

    .container::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, 0.25);
        border: 2px solid transparent;
        background-clip: padding-box;
    }
}

/* ==========================================================================
   Profile Header - Apple-inspired minimal
   ========================================================================== */
.profile-header {
    text-align: center;
    padding: var(--space-sm) 0 var(--space-md);
}

.avatar {
    width: 96px;
    height: 96px;
    margin: 0 auto var(--space-md);
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, #ec4899 100%);
    padding: 3px;
    box-shadow:
        var(--shadow-md),
        0 0 30px rgba(99, 102, 241, 0.3);
    transition: transform 0.4s var(--ease-spring), box-shadow 0.4s var(--ease-out);
    overflow: hidden;
}

.avatar:hover {
    transform: scale(1.05);
    box-shadow:
        var(--shadow-lg),
        0 0 50px rgba(99, 102, 241, 0.4);
}

.avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    object-position: center;
    background: #1a1a2e;
    transform: scale(1.9);
}

.brand-name {
    font-size: 1.875rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    background: linear-gradient(135deg, #f8fafc 0%, rgba(248, 250, 252, 0.8) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--space-sm);
}

.tagline {
    font-size: 0.9375rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin: 0 auto;
    line-height: 1.5;
    white-space: nowrap;
}

/* ==========================================================================
   Social Links - Refined hover states
   ========================================================================== */
.social-links {
    display: flex;
    justify-content: center;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
}

.social-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 50%;
    color: var(--text-secondary);
    text-decoration: none;
    transition:
        transform 0.3s var(--ease-spring),
        background 0.3s var(--ease-out),
        border-color 0.3s var(--ease-out),
        color 0.3s var(--ease-out),
        box-shadow 0.3s var(--ease-out);
}

.social-icon svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s var(--ease-spring);
}

.social-icon:hover {
    background: var(--card-bg-hover);
    border-color: var(--card-border-hover);
    color: var(--text-primary);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.social-icon:hover svg {
    transform: scale(1.1);
}

.social-icon:active {
    transform: translateY(-1px);
}

/* ==========================================================================
   Search Section - Premium input styling
   ========================================================================== */
.search-container {
    margin-bottom: var(--space-lg);
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 18px;
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
    transition: color 0.3s var(--ease-out);
}

#search-input {
    width: 100%;
    padding: 14px 48px;
    font-size: 0.9375rem;
    font-family: inherit;
    font-weight: 400;
    letter-spacing: -0.01em;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    outline: none;
    transition:
        background 0.3s var(--ease-out),
        border-color 0.3s var(--ease-out),
        box-shadow 0.3s var(--ease-out);
}

#search-input::placeholder {
    color: var(--text-muted);
    transition: color 0.3s var(--ease-out);
}

#search-input:hover {
    background: var(--card-bg-hover);
    border-color: var(--card-border-hover);
}

#search-input:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
    box-shadow:
        0 0 0 3px rgba(99, 102, 241, 0.15),
        0 4px 20px rgba(0, 0, 0, 0.1);
}

#search-input:focus + .search-icon,
.search-box:focus-within .search-icon {
    color: var(--primary-light);
}

.clear-btn {
    position: absolute;
    right: 14px;
    width: 28px;
    height: 28px;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    transition:
        background 0.2s var(--ease-out),
        color 0.2s var(--ease-out),
        transform 0.2s var(--ease-spring);
}

.clear-btn.visible {
    display: flex;
}

.clear-btn svg {
    width: 14px;
    height: 14px;
}

.clear-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
    transform: scale(1.1);
}

.clear-btn:active {
    transform: scale(0.95);
}

/* ==========================================================================
   Category Filter - Pill buttons
   ========================================================================== */
.category-filter {
    display: flex;
    gap: var(--space-sm);
    overflow-x: auto;
    padding-bottom: var(--space-sm);
    margin-bottom: var(--space-lg);
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
}

.category-filter::-webkit-scrollbar {
    display: none;
}

.category-btn {
    flex-shrink: 0;
    padding: 10px 20px;
    font-size: 0.8125rem;
    font-family: inherit;
    font-weight: 500;
    letter-spacing: 0.01em;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition:
        background 0.3s var(--ease-out),
        border-color 0.3s var(--ease-out),
        color 0.3s var(--ease-out),
        transform 0.2s var(--ease-spring),
        box-shadow 0.3s var(--ease-out);
}

.category-btn:hover {
    background: var(--card-bg-hover);
    border-color: var(--card-border-hover);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.category-btn:active {
    transform: translateY(0);
}

.category-btn.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-color: transparent;
    color: #fff;
    box-shadow:
        0 4px 15px rgba(99, 102, 241, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* ==========================================================================
   Products Grid
   ========================================================================== */
.products-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* ==========================================================================
   Product Card - Premium glassmorphism
   ========================================================================== */
.product-card {
    display: flex;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition:
        background 0.4s var(--ease-out),
        border-color 0.4s var(--ease-out),
        transform 0.4s var(--ease-spring),
        box-shadow 0.4s var(--ease-out);
    opacity: 0;
    animation: fadeInUp 0.5s var(--ease-out) forwards;
}

.product-card:hover {
    background: var(--card-bg-hover);
    border-color: var(--card-border-hover);
    transform: translateY(-4px) scale(1.01);
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.2),
        var(--card-glow);
}

.product-card:active {
    transform: translateY(-2px) scale(1.005);
}

/* Staggered animation delays */
.product-card:nth-child(1) { animation-delay: 0.05s; }
.product-card:nth-child(2) { animation-delay: 0.1s; }
.product-card:nth-child(3) { animation-delay: 0.15s; }
.product-card:nth-child(4) { animation-delay: 0.2s; }
.product-card:nth-child(5) { animation-delay: 0.25s; }
.product-card:nth-child(6) { animation-delay: 0.3s; }
.product-card:nth-child(7) { animation-delay: 0.35s; }
.product-card:nth-child(8) { animation-delay: 0.4s; }
.product-card:nth-child(9) { animation-delay: 0.45s; }
.product-card:nth-child(10) { animation-delay: 0.5s; }
.product-card:nth-child(11) { animation-delay: 0.55s; }
.product-card:nth-child(12) { animation-delay: 0.6s; }

.product-image {
    width: 100px;
    min-width: 100px;
    height: 100px;
    background: linear-gradient(135deg, #fafafa 0%, #f0f0f0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-sm);
    transition: background 0.3s var(--ease-out);
}

.product-card:hover .product-image {
    background: linear-gradient(135deg, #ffffff 0%, #f5f5f5 100%);
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.4s var(--ease-spring);
}

.product-card:hover .product-image img {
    transform: scale(1.08);
}

.product-info {
    flex: 1;
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    gap: var(--space-sm);
}

.product-title {
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
    transition: color 0.3s var(--ease-out);
}

.product-card:hover .product-title {
    color: #fff;
}

.product-meta {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.product-badge {
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    transition: transform 0.3s var(--ease-spring);
}

.product-card:hover .product-badge {
    transform: scale(1.05);
}

.badge-deal {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.badge-new {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.badge-trending {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #1a1a2e;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.product-category {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: color 0.3s var(--ease-out);
}

.product-card:hover .product-category {
    color: var(--text-secondary);
}

/* ==========================================================================
   No Results State
   ========================================================================== */
.no-results {
    display: none;
    text-align: center;
    padding: var(--space-2xl) var(--space-lg);
    color: var(--text-secondary);
}

.no-results.visible {
    display: block;
    animation: fadeIn 0.4s var(--ease-out);
}

.no-results p:first-child {
    font-size: 1.125rem;
    font-weight: 500;
    margin-bottom: var(--space-sm);
}

.no-results-hint {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ==========================================================================
   Footer - Subtle & clean
   ========================================================================== */
.footer {
    margin-top: var(--space-xl);
    padding: var(--space-lg) 0;
    text-align: center;
    border-top: 1px solid var(--card-border);
}

.affiliate-disclosure {
    font-size: 0.6875rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
    line-height: 1.6;
    letter-spacing: 0.01em;
}

.copyright {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Loading skeleton state */
.product-card.loading {
    pointer-events: none;
}

.product-card.loading .product-image,
.product-card.loading .product-title {
    background: linear-gradient(
        90deg,
        var(--card-bg) 25%,
        var(--card-bg-hover) 50%,
        var(--card-bg) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */
@media (min-width: 600px) {
    .brand-name {
        font-size: 2.125rem;
    }

    .product-image {
        width: 110px;
        min-width: 110px;
        height: 110px;
    }

    .product-title {
        font-size: 1rem;
    }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .product-card {
        opacity: 1;
    }
}

/* Focus states */
.product-card:focus-visible,
.social-icon:focus-visible,
.category-btn:focus-visible,
#search-input:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --card-border: rgba(255, 255, 255, 0.3);
        --text-secondary: rgba(255, 255, 255, 0.85);
        --text-muted: rgba(255, 255, 255, 0.7);
    }
}
