/* ===== CSS Variables & Theme ===== */
:root {
    /* Light theme colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --bg-hover: #e5e7eb;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);

    /* Accent colors */
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-error: #ef4444;
    --color-info: #3b82f6;
    --color-purple: #8b5cf6;

    /* Score colors */
    --score-excellent: #10b981;
    --score-good: #3b82f6;
    --score-fair: #f59e0b;
    --score-poor: #ef4444;

    /* Font stacks */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', Monaco, 'Cascadia Code', monospace;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-hover: #475569;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --border-color: #334155;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.2);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4);
}

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

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

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color var(--transition-base), color var(--transition-base);
}

a {
    color: var(--color-info);
    text-decoration: none;
    transition: opacity var(--transition-fast);
}

a:hover {
    opacity: 0.8;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
    background: transparent;
}

select {
    font-family: inherit;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    cursor: pointer;
    transition: border-color var(--transition-fast);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 9L2 5h8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
}

/* ===== Container ===== */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ===== Header ===== */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    background: rgba(var(--bg-secondary), 0.9);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon {
    font-size: 1.5rem;
}

.version-badge {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
    font-family: var(--font-mono);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.5rem;
    background: var(--bg-tertiary);
    transition: background-color var(--transition-fast);
}

.theme-toggle:hover {
    background: var(--bg-hover);
}

.sun-icon,
.moon-icon {
    transition: opacity var(--transition-fast);
}

[data-theme="light"] .moon-icon,
[data-theme="dark"] .sun-icon {
    display: none;
}

.github-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    color: var(--text-primary);
}

/* ===== Hero Section ===== */
.hero {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    padding: 3rem 0;
    border-bottom: 1px solid var(--border-color);
}

.hero-content {
    text-align: center;
}

.hero-content h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--color-info) 0%, var(--color-purple) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-content p {
    color: var(--text-secondary);
    font-size: 1.125rem;
    margin-bottom: 2rem;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    flex-wrap: wrap;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ===== How It Works Section ===== */
.how-it-works {
    padding: 3rem 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.how-it-works h2 {
    text-align: center;
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 3rem;
}

.pipeline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.pipeline-step {
    flex: 0 1 250px;
    text-align: center;
    position: relative;
}

.step-number {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 2rem;
    height: 2rem;
    background: var(--color-info);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    z-index: 1;
}

.step-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

.pipeline-step h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.pipeline-step p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
}

.pipeline-arrow {
    font-size: 2rem;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .pipeline {
        flex-direction: column;
    }

    .pipeline-arrow {
        transform: rotate(90deg);
    }
}

/* ===== Contribute CTA ===== */
.contribute-cta {
    padding: 4rem 0;
    background: linear-gradient(135deg, var(--color-info) 0%, var(--color-purple) 100%);
    position: relative;
    overflow: hidden;
}

.contribute-cta::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.cta-content {
    position: relative;
    text-align: center;
    color: white;
}

.cta-text h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.cta-text p {
    font-size: 1.125rem;
    opacity: 0.95;
    margin-bottom: 2rem;
}

.cta-button {
    display: inline-flex;
    align-items: center;
    padding: 0.875rem 2rem;
    background: white;
    color: var(--color-info);
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 1rem;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.cta-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    opacity: 1;
}

/* ===== Main Content ===== */
.main-content {
    padding: 3rem 0;
    min-height: 60vh;
}

/* ===== Tabs ===== */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-secondary);
    position: relative;
    transition: color var(--transition-fast);
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--color-info);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--color-info);
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
    animation: fadeIn var(--transition-base);
}

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

/* ===== Leaderboard ===== */
.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.leaderboard-header h3 {
    font-size: 1.5rem;
    font-weight: 600;
}

.metric-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.metric-selector label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.leaderboard-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.leaderboard-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.leaderboard-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.leaderboard-item:nth-child(1)::before {
    background: linear-gradient(90deg, #fbbf24 0%, #f59e0b 100%);
    opacity: 1;
}

.leaderboard-item:nth-child(2)::before {
    background: linear-gradient(90deg, #94a3b8 0%, #64748b 100%);
    opacity: 1;
}

.leaderboard-item:nth-child(3)::before {
    background: linear-gradient(90deg, #f97316 0%, #ea580c 100%);
    opacity: 1;
}

.leaderboard-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.rank {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-tertiary);
    min-width: 3rem;
    text-align: center;
}

.rank.gold { color: #fbbf24; }
.rank.silver { color: #94a3b8; }
.rank.bronze { color: #f97316; }

.tool-info {
    flex: 1;
}

.tool-name {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.tool-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

.metric {
    text-align: center;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    display: block;
    margin-bottom: 0.25rem;
}

.metric-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

/* ===== Score Colors ===== */
.score-excellent { color: var(--score-excellent); }
.score-good { color: var(--score-good); }
.score-fair { color: var(--score-fair); }
.score-poor { color: var(--score-poor); }

/* ===== Challenges Grid ===== */
.challenges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.challenge-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.5rem;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    cursor: pointer;
}

.challenge-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.challenge-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
}

.challenge-title {
    font-size: 1.125rem;
    font-weight: 600;
}

.challenge-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.badge-security {
    background: rgba(239, 68, 68, 0.1);
    color: var(--color-error);
}

.badge-bug {
    background: rgba(251, 191, 36, 0.1);
    color: var(--color-warning);
}

.badge-performance {
    background: rgba(139, 92, 246, 0.1);
    color: var(--color-purple);
}

.challenge-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.challenge-stats {
    display: flex;
    justify-content: space-between;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.challenge-stat {
    text-align: center;
}

.challenge-stat-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.challenge-stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ===== Tools Grid ===== */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 1.5rem;
}

.tool-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.5rem;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.tool-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.tool-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.tool-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.tool-stars {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.tool-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.tool-install {
    background: var(--bg-tertiary);
    padding: 0.75rem;
    border-radius: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.tool-performance {
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.performance-bars {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.performance-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.bar-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    min-width: 80px;
}

.bar-track {
    flex: 1;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width var(--transition-slow);
}

.bar-value {
    font-size: 0.875rem;
    font-weight: 600;
    min-width: 45px;
    text-align: right;
}

/* ===== Matrix View ===== */
.matrix-container {
    background: var(--bg-secondary);
    border-radius: 0.75rem;
    padding: 1.5rem;
}

.matrix-container h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.matrix-legend {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.legend-items {
    display: flex;
    gap: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-color {
    width: 1rem;
    height: 1rem;
    border-radius: 0.25rem;
}

.matrix-table {
    overflow-x: auto;
}

.matrix-table table {
    width: 100%;
    border-collapse: collapse;
}

.matrix-table th,
.matrix-table td {
    padding: 1rem;
    text-align: center;
    border: 1px solid var(--border-color);
}

.matrix-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    font-size: 0.875rem;
}

.matrix-table td {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.matrix-table td:hover {
    background: var(--bg-hover);
}

.matrix-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.matrix-score {
    font-size: 1.125rem;
    font-weight: 600;
}

.matrix-detail {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: 1rem;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    margin: 2rem;
    position: relative;
    box-shadow: var(--shadow-lg);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    transition: background-color var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-secondary);
}

#modal-body {
    padding: 2rem;
}

/* ===== Footer ===== */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    margin-top: 4rem;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-left p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.footer-right {
    display: flex;
    gap: 1.5rem;
}

.footer-right a {
    color: var(--text-secondary);
    font-size: 0.875rem;
    transition: color var(--transition-fast);
}

.footer-right a:hover {
    color: var(--text-primary);
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .hero-content h2 {
        font-size: 1.5rem;
    }

    .hero-stats {
        gap: 1.5rem;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .challenges-grid,
    .tools-grid {
        grid-template-columns: 1fr;
    }

    .footer-content {
        flex-direction: column;
        align-items: start;
    }

    .tabs {
        overflow-x: auto;
        scrollbar-width: none;
    }

    .tabs::-webkit-scrollbar {
        display: none;
    }
}