/* Theme Overrides for Stats Page */

/* Hacker News */
html[data-theme="light-hacker-news"] h1 {
    font-size: 14pt;
}

/* Dark TWIR */
html[data-theme="dark-twir"] h1 {
    font-family: "Univers", sans-serif;
}

/* Stats Grid Layout */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    grid-auto-rows: minmax(120px, auto);
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stat-card:hover {
    border-color: var(--color-primary);
}

.stat-value {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--color-primary);
    font-family: "Univers", sans-serif;
    margin-bottom: 8px;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.section {
    margin-bottom: 32px;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 24px;
    font-family: "Univers", sans-serif;
}

#articles-chart {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 24px;
}

/* Category list */
.category-list {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
}

.category-row {
    padding-bottom: 16px;
    border-bottom: 1px solid var(--color-border);
}

.category-row:last-child {
    border-bottom: 0;
}

.category-row:hover {
    background-color: rgba(72, 213, 151, 0.02);
}

.category-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px 10px;
}


.category-name {
    font-weight: 500;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 10px;
}

.category-icon,
.domain-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.category-icon {
    width: 20px;
    height: 20px;
}

.domain-icon {
    width: 16px;
    height: 16px;
}

.category-icon svg {
    fill: currentColor;
    stroke: var(--color-primary);
}

.category-count {
    font-family: "Martian Mono", monospace;
    color: var(--color-primary);
    font-weight: 600;
    font-size: 1.1rem;
}

/* Progress Bars */
.progress-bar {
    height: 4px;
    margin: 0 24px;
    overflow: hidden;
    background-color: var(--color-border);
    border-radius: 2px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(
        90deg,
        var(--color-primary-muted),
        var(--color-primary)
    );
    border-radius: inherit;
}

.year-section {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 24px;
}

html[data-theme="light-docs-rs"] .stat-card,
html[data-theme="light-docs-rs"] #articles-chart,
html[data-theme="light-docs-rs"] .year-section {
    border-radius: 16px;
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.02),
        0 2px 4px -1px rgba(0, 0, 0, 0.02);
}

/* Domain grid */
.domain-item {
    display: inline-flex;
    align-items: center;
    background: var(--color-surface);
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 4px 10px;
    font-size: 0.8rem;
    color: var(--color-text);
    text-decoration: none;
}

.domain-item:hover {
    background: var(--color-border);
}

.domains-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.domain-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.domain-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border: 0;
}

.year-subsection-title {
    margin: 0 0 16px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text);
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 12px;
    font-family: "Univers", sans-serif;
}

.category-icon svg {
    width: 18px;
    height: 18px;
}

.domain-name {
    font-weight: 500;
    color: var(--color-text);
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.domain-count {
    background: var(--color-border);
    color: var(--color-text-muted);
    border-radius: 10px;
    padding: 2px 6px;
    margin-left: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}


/* Navigation */
.back-link {
    display: inline-block;
    margin-bottom: 32px;
    font-weight: 500;
}

@media (max-width: 600px) {
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .stat-card {
        padding: 20px;
    }

    #articles-chart {
        padding: 16px;
    }

    .year-section {
        padding: 16px;
    }

    .stat-value {
        font-size: 2rem;
    }

    .category-row {
        padding-bottom: 12px;
    }

    .category-item {
        padding: 12px 16px 8px;
    }

    .progress-bar {
        margin: 0 16px;
    }
}

/* Hacker News stats: retain the existing layout, but use the flatter, denser
   visual language of the theme. This stylesheet only loads on /statistics. */
html[data-theme="light-hacker-news"] {
    --color-primary: #ff6600;
    --color-border: #d8d8d0;
}

html[data-theme="light-hacker-news"] .stats-grid {
    grid-auto-rows: minmax(84px, auto);
    gap: 8px;
    margin-bottom: 24px;
}

html[data-theme="light-hacker-news"] .stat-card {
    padding: 14px;
    border-radius: 0;
}

html[data-theme="light-hacker-news"] .stat-value,
html[data-theme="light-hacker-news"] .section-title,
html[data-theme="light-hacker-news"] .category-count {
    font-family: Verdana, Geneva, sans-serif;
}

html[data-theme="light-hacker-news"] .stat-value {
    margin-bottom: 4px;
    color: var(--color-primary);
    font-size: 1.55rem;
    font-weight: bold;
    letter-spacing: normal;
}

html[data-theme="light-hacker-news"] .stat-label {
    color: var(--color-text-muted);
    font-size: 8pt;
    font-weight: normal;
    letter-spacing: normal;
    text-transform: none;
}

html[data-theme="light-hacker-news"] .section {
    margin-bottom: 24px;
}

html[data-theme="light-hacker-news"] .section-title {
    margin-bottom: 12px;
    color: var(--color-text);
    font-size: 11pt;
}

html[data-theme="light-hacker-news"] #articles-chart,
html[data-theme="light-hacker-news"] .category-list,
html[data-theme="light-hacker-news"] .year-section,
html[data-theme="light-hacker-news"] .domain-item,
html[data-theme="light-hacker-news"] .domain-count,
html[data-theme="light-hacker-news"] .progress-bar,
html[data-theme="light-hacker-news"] .progress-fill {
    border-radius: 0;
}

html[data-theme="light-hacker-news"] #toggle-categories {
    border-radius: 0 !important;
}

html[data-theme="light-hacker-news"] #articles-chart,
html[data-theme="light-hacker-news"] .year-section {
    padding: 12px;
}

html[data-theme="light-hacker-news"] .category-row {
    padding-bottom: 10px;
}

html[data-theme="light-hacker-news"] .category-item {
    padding: 10px 14px 6px;
}

html[data-theme="light-hacker-news"] .progress-bar {
    margin: 0 14px;
}

html[data-theme="light-hacker-news"] .category-count,
html[data-theme="light-hacker-news"] .domain-count,
html[data-theme="light-hacker-news"] .back-link {
    color: var(--color-text-muted);
    font-size: 8pt;
    font-weight: normal;
}

html[data-theme="light-hacker-news"] .progress-bar {
    height: 4px;
    background-color: var(--color-border);
}

html[data-theme="light-hacker-news"] .progress-fill {
    background: var(--color-primary);
}
