@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6ee7b7;
    --primary-glow: rgba(110, 231, 183, 0.25);
    --accent: #a78bfa;
    --accent-glow: rgba(167, 139, 250, 0.25);
    --bg-deep: #0a0a0f;
    --bg-card: rgba(255, 255, 255, 0.04);
    --bg-card-hover: rgba(255, 255, 255, 0.07);
    --bg-glass: rgba(255, 255, 255, 0.06);
    --text-primary: #f0f0f5;
    --text-secondary: rgba(240, 240, 245, 0.55);
    --text-muted: rgba(240, 240, 245, 0.3);
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --radius-pill: 50px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-deep);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ── Animated background ── */
.background {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
}

.background::before,
.background::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    animation: drift 18s ease-in-out infinite alternate;
}

.background::before {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(110, 231, 183, 0.15), transparent 70%);
    top: -15%;
    left: -10%;
}

.background::after {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(167, 139, 250, 0.12), transparent 70%);
    bottom: -15%;
    right: -10%;
    animation-delay: -9s;
}

@keyframes drift {
    0%   { transform: translate(0, 0) scale(1); }
    50%  { transform: translate(40px, -30px) scale(1.1); }
    100% { transform: translate(-20px, 20px) scale(0.95); }
}

/* Extra subtle grid overlay */
.background-grid {
    position: fixed;
    inset: 0;
    z-index: -1;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
    background-size: 60px 60px;
}

/* ── Container ── */
.container {
    width: 100%;
    max-width: 560px;
    animation: enterUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes enterUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ── Header ── */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    padding: 0 4px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 26px;
    display: inline-block;
    animation: glow-pulse 3s ease-in-out infinite;
}

@keyframes glow-pulse {
    0%, 100% { filter: drop-shadow(0 0 6px var(--primary-glow)); transform: scale(1); }
    50%      { filter: drop-shadow(0 0 18px var(--primary-glow)); transform: scale(1.12); }
}

.logo-text {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.3px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.date-display {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ── Fact meta (number + countdown) ── */
.fact-meta {
    display: flex;
    align-items: center;
    gap: 10px;
}

.next-update {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    padding: 3px 8px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-pill);
    border: 1px solid rgba(255, 255, 255, 0.06);
    letter-spacing: 0.3px;
}

/* ── Main content ── */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ── Fact card (glass) ── */
.fact-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 32px;
    border: 1px solid var(--border);
    backdrop-filter: blur(24px) saturate(1.3);
    -webkit-backdrop-filter: blur(24px) saturate(1.3);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                border-color 0.35s ease,
                box-shadow 0.35s ease;
    position: relative;
    overflow: hidden;
}

/* Subtle inner glow */
.fact-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(110, 231, 183, 0.3), transparent);
}

.fact-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-hover);
    box-shadow: 0 20px 60px -15px rgba(0, 0, 0, 0.5),
                0 0 40px -20px var(--primary-glow);
}

.fact-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.fact-badge {
    background: linear-gradient(135deg, rgba(110, 231, 183, 0.15), rgba(167, 139, 250, 0.15));
    color: var(--primary);
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: 1px solid rgba(110, 231, 183, 0.15);
}

.fact-number {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.fact-content {
    text-align: center;
    padding: 16px 0;
    min-height: 130px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.fact-icon {
    font-size: 44px;
    margin-bottom: 18px;
    animation: float 4s ease-in-out infinite;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}

.fact-text {
    font-size: 17px;
    line-height: 1.85;
    color: var(--text-primary);
    font-weight: 500;
    transition: opacity 0.35s ease, transform 0.35s ease;
    max-width: 95%;
}

.fact-footer {
    display: flex;
    gap: 10px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

/* ── Buttons ── */
.refresh-btn,
.share-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: inherit;
    letter-spacing: 0.2px;
}

.refresh-btn {
    background: linear-gradient(135deg, var(--primary), #34d399);
    color: #0a0a0f;
    box-shadow: 0 4px 20px -4px var(--primary-glow);
}

.refresh-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px -4px var(--primary-glow);
}

.refresh-btn:active {
    transform: translateY(0) scale(0.98);
}

.refresh-btn.loading svg {
    animation: spin 0.8s linear infinite;
}

.share-btn {
    background: var(--bg-glass);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.share-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

.share-btn:active {
    transform: translateY(0) scale(0.98);
}

/* ── Stats section ── */
.stats-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-item {
    background: var(--bg-card);
    padding: 20px;
    border-radius: var(--radius-md);
    text-align: center;
    border: 1px solid var(--border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.stat-item:hover {
    transform: translateY(-3px);
    border-color: var(--border-hover);
    box-shadow: 0 12px 40px -10px rgba(0, 0, 0, 0.4);
}

.stat-value {
    display: block;
    font-size: 30px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ── Footer ── */
.footer {
    text-align: center;
    margin-top: 28px;
    padding: 0 10px;
}

.footer p {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ── Loading overlay ── */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 15, 0.85);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.loading-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    margin-bottom: 18px;
    box-shadow: 0 0 20px var(--primary-glow);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ── Toast notification ── */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    z-index: 2000;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.6);
}

.toast.toast-success {
    border-color: rgba(110, 231, 183, 0.3);
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.6),
                0 0 20px -5px var(--primary-glow);
}

.toast.toast-error {
    border-color: rgba(248, 113, 113, 0.3);
}

.toast.toast-info {
    border-color: rgba(167, 139, 250, 0.3);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Category icons ── */
.category-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
    margin-bottom: 14px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-pill);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

/* ── Responsive ── */
@media (max-width: 640px) {
    body {
        padding: 16px;
        align-items: flex-start;
        padding-top: 40px;
    }

    .container {
        max-width: 100%;
    }

    .fact-card {
        padding: 24px 20px;
        border-radius: 20px;
    }

    .fact-text {
        font-size: 15px;
    }

    .stats-section {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .stat-value {
        font-size: 26px;
    }

    .logo-text {
        font-size: 19px;
    }

    .date-display {
        font-size: 11px;
    }

    .header {
        margin-bottom: 20px;
    }

    .refresh-btn, .share-btn {
        padding: 12px 14px;
        font-size: 12px;
    }
}

@media (max-width: 380px) {
    .fact-footer {
        flex-direction: column;
    }
}
