/**
 * @file style.css
 * @description Global design system and component architecture.
 * @complexity O(1) - Static CSS rules.
 */

:root {
    --bg: #0a0a0c;
    --surface: #16161a;
    --surface-light: #23232a;
    --primary: #ffffff;
    --accent: #3b82f6;
    --accent-soft: rgba(59, 130, 246, 0.1);
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --border: #2d2d35;
    --error: #ef4444;
    --success: #10b981;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#nav-root { width: 100%; }

body.light-mode {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-light: #e2e8f0;
    --primary: #0f172a;
    --accent: #2563eb;
    --accent-soft: rgba(37, 99, 235, 0.1);
    --text-main: #0f172a;
    --text-dim: #64748b;
    --border: #e2e8f0;
}

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

body {
    background-color: var(--bg);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 2rem; }

h1, h2, h3 { font-weight: 800; letter-spacing: -0.025em; }

.text-gradient {
    background: linear-gradient(to right, var(--accent), #60a5fa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.navbar {
    height: 80px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
    background: rgba(10,10,12,0.8);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo { font-weight: 800; font-size: 1.5rem; letter-spacing: -1px; }
.logo span { color: var(--accent); }

.hero { padding: 100px 0 40px; text-align: center; }
.hero h1 { font-size: clamp(2.5rem, 8vw, 4rem); margin-bottom: 1.5rem; }
.subtitle { color: var(--text-dim); font-size: 1.25rem; max-width: 600px; margin: 0 auto; }

/* Statistics Section */
.stats-section { padding-bottom: 60px; border-bottom: 1px solid var(--border); margin-bottom: 80px; }
.stats-kicker { font-size: 0.7rem; letter-spacing: 0.15em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 16px; font-weight: 600; }

/* HERO ROW: vertical inside each card, side-by-side row on desktop */
.stats-hero {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 32px;
}

.stat-item--hero {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px 20px;
    text-align: center;
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
}

.stat-item--hero .stat-value {
    display: block;
    font-size: clamp(2.5rem, 6vw, 3.5rem);
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.03em;
    color: var(--primary);
}

.stat-item--hero .stat-label {
    display: block;
    margin-top: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.8;
    color: var(--text-dim);
}

/* DETAIL GRID: horizontal flex per item */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.stats-grid .stat-item {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px 20px;
    text-align: left;
    transition: var(--transition);
}

.stats-grid .stat-item:hover { border-color: var(--accent); transform: translateY(-2px); }
.stats-grid .stat-meta { display: flex; flex-direction: column; }
.stats-grid .stat-value { font-size: 1.25rem; font-weight: 700; white-space: nowrap; color: var(--primary); }
.stats-grid .stat-label { font-size: 1rem; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--text-main); }
.stats-grid .stat-sub { font-size: 0.7rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 2px; }

/* Base stat fallback */
.stat-item { display: flex; flex-direction: column; gap: 0.25rem; }

/* Grid & Cards */
.grid-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    padding-bottom: 100px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-8px);
    border-color: var(--accent);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.card-content { padding: 2rem; }
.tag {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--accent);
    background: var(--accent-soft);
    padding: 4px 12px;
    border-radius: 9999px;
    margin-bottom: 1rem;
}
.card h2 { font-size: 1.5rem; margin-bottom: 1rem; }
.card p { color: var(--text-dim); font-size: 0.95rem; margin-bottom: 2rem; }
.card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: auto; }
.arpu { font-weight: 600; color: var(--text-main); }

.btn-icon {
    background: none;
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-main);
    font-size: 1.2rem;
}

.icon-sun { display: none; }
body.light-mode .icon-sun { display: inline; }
body.light-mode .icon-moon { display: none; }

/* Responsive */
@media (max-width: 768px) {
    .hero { padding: 60px 0; }
}

@media (max-width: 640px) {
    .stats-hero {
        grid-template-columns: 1fr; /* vertical stack */
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .stats-grid .stat-item {
        flex-direction: row; /* stays horizontal on mobile */
    }
}

/* --- Tabs Wrapper: minimizes height --- */
.stats-tabs-wrapper {
    padding-bottom: 40px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 80px;
    min-height: 420px; /* prevents layout shift when swapping */
}

.tabs-header {
    display: flex;
    justify-content: center;
    margin-bottom: 28px;
}

.tabs {
    display: inline-flex;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 9999px;
    padding: 4px;
}

.tab {
    padding: 8px 20px;
    border-radius: 9999px;
    border: 0;
    background: transparent;
    color: var(--text-dim);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.tab--active {
    background: var(--surface-light);
    color: var(--text-main);
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.tab:hover:not(.tab--active) { color: var(--text-main); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.tab-panel--active { animation: tabFade 0.25s ease; }
.tab-panel[hidden] { display: none!important; }

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

/* Platform specific meta */
.section-header { text-align: center; margin-bottom: 24px; }
.section-header h2 { font-size: 1.5rem; margin-bottom: 4px; }
.section-header p { color: var(--text-dim); font-size: 0.9rem; }
.stat-item--platform { position: relative; }
.stat-item--platform.stat-rank { font-size: 0.7rem; font-weight: 700; color: var(--text-dim); position: absolute; top: 10px; left: 12px; }
.stat-item--platform.stat-meta { display: block; font-size: 0.7rem; color: var(--text-dim); margin-top: 4px; }
.stat-item--platform-hero.stat-meta { margin-top: 6px; font-size: 0.75rem; color: var(--text-dim); }