/* ==========================================================================
   1. VARIABLES & COLOR THEMES (Liquid Glass Theme)
   ========================================================================== */
:root {
    --bg-gradient: radial-gradient(circle at 50% 50%, #0d0a1a, #05030a);
    --surface-glass: rgba(255, 255, 255, 0.04);
    --surface-glass-hover: rgba(255, 255, 255, 0.09);
    --surface-glass-active: rgba(255, 255, 255, 0.14);
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-glass-glow: rgba(255, 255, 255, 0.25);

    --text-primary: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-muted: #6e6e73;

    --accent-color: #0071e3;
    --accent-gradient: linear-gradient(135deg, #ff416c, #ff4b2b);
    --aurora-pink: rgba(255, 65, 108, 0.35);
    --aurora-purple: rgba(138, 43, 226, 0.35);
    --aurora-blue: rgba(0, 113, 227, 0.35);
    --aurora-cyan: rgba(0, 242, 254, 0.3);

    --shadow-main: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --shadow-card-hover: 0 20px 40px 0 rgba(0, 0, 0, 0.6);
    --blur-strength: 20px;
    --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --transition-smooth: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] {
    --bg-gradient: radial-gradient(circle at 50% 50%, #f5f5f7, #e5e5ea);
    --surface-glass: rgba(0, 0, 0, 0.03);
    --surface-glass-hover: rgba(0, 0, 0, 0.06);
    --surface-glass-active: rgba(0, 0, 0, 0.1);
    --border-glass: rgba(0, 0, 0, 0.08);
    --border-glass-glow: rgba(0, 0, 0, 0.2);

    --text-primary: #1d1d1f;
    --text-secondary: #515154;
    --text-muted: #86868b;

    --accent-color: #0071e3;
    --aurora-pink: rgba(255, 65, 108, 0.15);
    --aurora-purple: rgba(138, 43, 226, 0.15);
    --aurora-blue: rgba(0, 113, 227, 0.15);
    --aurora-cyan: rgba(0, 242, 254, 0.15);

    --shadow-main: 0 8px 32px 0 rgba(0, 0, 0, 0.08);
    --shadow-card-hover: 0 20px 40px 0 rgba(0, 0, 0, 0.12);
}

/* ==========================================================================
   2. SYSTEM RESET & BASE CONFIGURATION
   ========================================================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    width: 100%;
    min-height: 100vh;
    font-family: var(--font-stack);
    background: var(--bg-gradient);
    color: var(--text-primary);
    overflow-x: hidden;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   3. AURORA ANIMATED BACKGROUND & MOUSE GLOW
   ========================================================================== */
.aurora-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -2;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    width: 50vw;
    height: 50vw;
    border-radius: 50%;
    filter: blur(120px);
    mix-blend-mode: screen;
    animation: moveAurora 25s infinite alternate ease-in-out;
}

[data-theme="light"] .blob {
    mix-blend-mode: multiply;
    filter: blur(140px);
}

.blob-purple {
    background: var(--aurora-purple);
    top: -10%;
    left: -10%;
    animation-delay: 0s;
}

.blob-blue {
    background: var(--aurora-blue);
    top: 60%;
    left: -20%;
    animation-delay: 4s;
}

.blob-cyan {
    background: var(--aurora-cyan);
    bottom: -10%;
    right: -10%;
    animation-delay: 2s;
}

.blob-pink {
    background: var(--aurora-pink);
    top: -20%;
    right: 20%;
    animation-delay: 6s;
}

.mouse-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0) 70%);
    border-radius: 50%;
    pointer-events: none;
    transform: translate(-50%, -50%);
    z-index: -1;
    transition: transform 0.1s linear;
}

[data-theme="light"] .mouse-glow {
    background: radial-gradient(circle, rgba(0, 113, 227, 0.04) 0%, rgba(0, 113, 227, 0) 70%);
}

/* ==========================================================================
   4. NAVBAR
   ========================================================================== */
.navbar {
    position: sticky;
    top: 0;
    width: 100%;
    z-index: 1000;
    background: var(--surface-glass);
    backdrop-filter: blur(var(--blur-strength));
    -webkit-backdrop-filter: blur(var(--blur-strength));
    border-bottom: 1px solid var(--border-glass);
    transition: var(--transition-smooth);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.logo-text {
    letter-spacing: -0.5px;
}

.gradient-text {
    background: linear-gradient(90deg, #ff416c, #ff4b2b, #8a2be2, #0071e3);
    background-size: 300% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: flowGradient 8s infinite linear;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-btn {
    background: var(--surface-glass);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    padding: 0.75rem;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: var(--transition-smooth);
    overflow: hidden;
}

.nav-btn:hover {
    background: var(--surface-glass-hover);
    border-color: var(--border-glass-glow);
    transform: translateY(-2px);
}

.nav-btn .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ff3b30;
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 0.15rem 0.4rem;
    border-radius: 10px;
    min-width: 15px;
    text-align: center;
}

/* ==========================================================================
   5. HERO SECTION
   ========================================================================== */
.main-layout {
    max-width: 1400px;
    margin: 0 auto;
    padding: 3rem 2rem;
}

.hero-section {
    text-align: center;
    margin-bottom: 3.5rem;
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -1.5px;
    margin-bottom: 1.2rem;
    color: var(--text-primary);
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    max-width: 700px;
    margin: 0 auto;
    line-height: 1.5;
}

/* ==========================================================================
   6. LIVE STATISTICS
   ========================================================================== */
.stats-panel {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 4rem;
}

.stat-card {
    background: var(--surface-glass);
    backdrop-filter: blur(var(--blur-strength));
    -webkit-backdrop-filter: blur(var(--blur-strength));
    border: 1px solid var(--border-glass);
    border-radius: 24px;
    padding: 1.5rem 2rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: var(--transition-smooth);
    box-shadow: var(--shadow-main);
}

.stat-card:hover {
    transform: translateY(-4px);
    background: var(--surface-glass-hover);
    border-color: var(--border-glass-glow);
}

.stat-icon {
    font-size: 2rem;
    color: var(--accent-color);
    background: rgba(0, 113, 227, 0.1);
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
}

.stat-counter {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ==========================================================================
   7. CONTROL HUB (SEARCH & FILTERS)
   ========================================================================== */
.control-hub {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin-bottom: 3rem;
    position: sticky;
    top: 80px;
    z-index: 900;
}

.search-wrapper {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.search-wrapper .search-icon {
    position: absolute;
    left: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 1.2rem;
    pointer-events: none;
    transition: var(--transition-smooth);
}

.search-wrapper input {
    width: 100%;
    padding: 1.2rem 1.5rem 1.2rem 3.5rem;
    font-size: 1.1rem;
    border-radius: 30px;
    background: var(--surface-glass);
    backdrop-filter: blur(var(--blur-strength));
    -webkit-backdrop-filter: blur(var(--blur-strength));
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    outline: none;
    box-shadow: var(--shadow-main);
    transition: var(--transition-smooth);
}

.search-wrapper input:focus {
    background: var(--surface-glass-hover);
    border-color: var(--accent-color);
    box-shadow: 0 0 25px rgba(0, 113, 227, 0.25);
}

.search-wrapper input:focus+.search-icon {
    color: var(--accent-color);
}

.clear-btn {
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    display: none;
    transition: var(--transition-smooth);
}

.clear-btn:hover {
    color: var(--text-primary);
}

.category-scroll-container {
    width: 100%;
    overflow-x: auto;
    padding: 0.5rem 0;
    scrollbar-width: none;
}

.category-scroll-container::-webkit-scrollbar {
    display: none;
}

.category-chips {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    width: max-content;
    margin: 0 auto;
    padding: 0.4rem;
    background: var(--surface-glass);
    backdrop-filter: blur(var(--blur-strength));
    -webkit-backdrop-filter: blur(var(--blur-strength));
    border-radius: 40px;
    border: 1px solid var(--border-glass);
}

.chip {
    padding: 0.6rem 1.5rem;
    border-radius: 30px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.chip:hover {
    color: var(--text-primary);
    background: var(--surface-glass-hover);
}

.chip.active {
    /* background: var(--text-primary);
    color: var(--bg-gradient); */
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

/* ==========================================================================
   8. EMOJI DISPLAY GRID & LUXURY CARDS
   ========================================================================== */
.gallery-container {
    min-height: 400px;
    position: relative;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 1.5rem;
    transition: var(--transition-smooth);
}

.emoji-card {
    position: relative;
    background: var(--surface-glass);
    backdrop-filter: blur(var(--blur-strength));
    -webkit-backdrop-filter: blur(var(--blur-strength));
    border: 1px solid var(--border-glass);
    border-radius: 28px;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    box-shadow: var(--shadow-main);
    transition: var(--transition-smooth);
}

/* Glass Reflection Layer */
.emoji-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -75%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.13) 100%);
    transform: skewX(-25deg);
    transition: 0.75s;
    pointer-events: none;
}

.emoji-card:hover::before {
    left: 125%;
}

.emoji-card:hover {
    transform: translateY(-8px) scale(1.03);
    background: var(--surface-glass-hover);
    border-color: var(--border-glass-glow);
    box-shadow: var(--shadow-card-hover);
}

.card-fav-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    z-index: 10;
    transition: var(--transition-smooth);
}

.card-fav-btn:hover {
    transform: scale(1.2);
}

.card-fav-btn.is-favorite {
    color: #ff2d55;
    filter: drop-shadow(0 0 5px rgba(255, 45, 85, 0.5));
}

.emoji-char {
    font-size: 3rem;
    margin-bottom: 0.75rem;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    user-select: none;
}

.emoji-card:hover .emoji-char {
    transform: scale(1.15) rotate(8deg);
}

.emoji-name {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    text-transform: capitalize;
}

/* Ripple Click Effect Canvas/Element */
.ripple {
    position: absolute;
    border-radius: 50%;
    transform: scale(0);
    animation: rippleEffect 0.6s linear;
    background: rgba(255, 255, 255, 0.25);
    pointer-events: none;
}

[data-theme="light"] .ripple {
    background: rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   9. SKELETON LOADING SHIMMER EFFECT
   ========================================================================== */
.skeleton-card {
    height: 140px;
    background: var(--surface-glass);
    border: 1px solid var(--border-glass);
    border-radius: 28px;
    position: relative;
    overflow: hidden;
}

.skeleton-card::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: linear-gradient(90deg, transparent, var(--surface-glass-hover), transparent);
    transform: translateX(-100%);
    animation: shimmer 1.6s infinite;
}

/* ==========================================================================
   10. FALLBACK STATS & ENGINE UTILITIES
   ========================================================================== */
.hidden {
    display: none !important;
}

.error-state,
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.error-icon,
.empty-icon {
    font-size: 3.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-muted);
}

.retry-action-btn {
    margin-top: 1.5rem;
    padding: 0.8rem 2rem;
    border-radius: 25px;
    border: none;
    background: var(--accent-color);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.retry-action-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 113, 227, 0.4);
}

.scroll-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2.5rem;
    color: var(--text-secondary);
}

.spinner {
    width: 35px;
    height: 35px;
    border: 3px solid var(--border-glass);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ==========================================================================
   11. TOAST NOTIFICATIONS & CONTROLS
   ========================================================================== */
.toast-notification {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.07);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 1rem 2.5rem;
    border-radius: 50px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 2000;
    transition: cubic-bezier(0.175, 0.885, 0.32, 1.2) 0.5s;
    pointer-events: none;
}

[data-theme="light"] .toast-notification {
    background: rgba(0, 0, 0, 0.8);
    color: white;
}

.toast-notification.visible {
    bottom: 40px;
}

.scroll-top-btn {
    position: fixed;
    bottom: 40px;
    right: 40px;
    background: var(--surface-glass);
    backdrop-filter: blur(var(--blur-strength));
    -webkit-backdrop-filter: blur(var(--blur-strength));
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    width: 55px;
    height: 55px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: var(--shadow-main);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    z-index: 999;
    transition: var(--transition-smooth);
}

.scroll-top-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-top-btn:hover {
    background: var(--surface-glass-hover);
    border-color: var(--border-glass-glow);
    transform: translateY(-4px);
}

/* ==========================================================================
   12. GLASS FOOTER
   ========================================================================== */
.glass-footer {
    margin-top: 6rem;
    padding: 3rem 2rem;
    background: var(--surface-glass);
    backdrop-filter: blur(var(--blur-strength));
    -webkit-backdrop-filter: blur(var(--blur-strength));
    border-top: 1px solid var(--border-glass);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.glass-footer a {
    color: var(--accent-color);
    text-decoration: none;
}

.glass-footer .credits {
    margin-top: 0.5rem;
    font-size: 0.8rem;
}

/* ==========================================================================
   13. KEYFRAMES & ACCESSIBILITY CONTEXTS
   ========================================================================== */
@keyframes moveAurora {
    0% {
        transform: translate(0, 0) rotate(0deg) scale(1);
    }

    50% {
        transform: translate(10vw, 8vh) rotate(180deg) scale(1.1);
    }

    100% {
        transform: translate(-5vw, -5vh) rotate(360deg) scale(0.9);
    }
}

@keyframes flowGradient {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

@keyframes shimmer {
    100% {
        transform: translateX(100%);
    }
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

@keyframes rippleEffect {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

.animate-fade-in {
    animation: fadeIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-fade-in-delayed {
    opacity: 0;
    animation: fadeIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.2s forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   14. SYSTEM ADAPTIVE RESPONSIVENESS
   ========================================================================== */
@media (max-width: 1024px) {
    .emoji-grid {
        grid-template-columns: repeat(6, 1fr);
    }

    .hero-title {
        font-size: 2.8rem;
    }

    .stats-panel {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .emoji-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .stats-panel {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .control-hub {
        top: 70px;
    }

    .hero-title {
        font-size: 2.2rem;
    }
}

@media (max-width: 480px) {
    .emoji-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.75rem;
    }

    .main-layout {
        padding: 1.5rem 1rem;
    }

    .hero-title {
        font-size: 1.8rem;
    }

    .chip {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    .blob,
    .emoji-card,
    .emoji-char {
        animation: none !important;
        transition: none !important;
    }
}


/* Container to center your navigation buttons */
.flex-container {
    display: flex;
    flex-direction: row;
    /* Puts buttons side by side */
    gap: 15px;
    /* Spaces out the buttons */
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-top: 50px;
}

/* Button styles */
.nav-btn {
    cursor: pointer;
    padding: 10px 24px;
    font-size: 16px;
    background-color: #081226;
    color: #fff;
    border: none;
    border-radius: 4px;
    transition: background 0.3s ease;
}

.nav-btn:hover {
    background-color: #11254a;
}

/* FULL PAGE OVERLAY MODALS */
.full-page-overlay {
    display: none;
    /* Hidden by default; changed to flex by JS */
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(180deg, #081226 0%, #071026 100%);
    color: #fff;
    box-sizing: border-box;
    z-index: 9999;
    overflow-y: auto;
    /* Adds internal scrolling if text is longer than screen height */
    justify-content: center;
    align-items: center;
}

/* Content framing wrapper */
.content-inner {
    text-align: center;
    padding: 20px;
    width: 100%;
}

/* Dedicated close button style */
.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    color: #fff;
    border: 2px solid #fff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* --- MEDIA QUERIES FOR RESPONSIVE DESIGN --- */

/* Desktop viewports */
@media (min-width: 768px) {
    .content-inner {
        max-width: 650px;
        /* Limits prose width for peak readability */
    }

    .content-inner h2 {
        font-size: 36px;
        margin-bottom: 25px;
    }

    .content-inner p {
        font-size: 18px;
        line-height: 1.6;
    }
}

/* Mobile viewports */
@media (max-width: 767px) {
    .flex-container {
        flex-direction: column;
        /* Stacks buttons on top of each other on tiny screens */
    }

    .content-inner {
        max-width: 90%;
        padding: 60px 15px 30px 15px;
        /* Added top padding so header avoids close button */
    }

    .content-inner h2 {
        font-size: 28px;
        margin-bottom: 15px;
    }

    .content-inner p {
        font-size: 15px;
        line-height: 1.5;
    }

    .close-btn {
        top: 15px;
        right: 15px;
    }
}