/* CSS Custom Properties for theming and data visualization */
:root {
    color-scheme: light dark;
    --primary-color: light-dark(#007acc, #00d4ff);
    --secondary-color: light-dark(#f0f0f0, #333);
    --text-color: light-dark(#333, #f0f0f0);
    --bg-color: light-dark(#fff, #1a1a1a);
    --border-radius: 8px;
    --transition: all 0.3s ease;
    --activity-low: light-dark(#e3f2fd, #1a237e);
    --activity-medium: light-dark(#2196f3, #64b5f6);
    --activity-high: light-dark(#0d47a1, #bbdefb);
    --diversity-color-1: #ff6b6b;
    --diversity-color-2: #4ecdc4;
    --diversity-color-3: #45b7d1;
    --diversity-color-4: #f9ca24;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background: var(--bg-color);
    transition: var(--transition);
}

h1,
h2 {
    margin-bottom: 1rem;
    text-box-trim: trim-start;
}

body {
    font-family: system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    transition: var(--transition);
}

header {
    background: var(--primary-color);
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

nav {
    display: flex;
    gap: 1rem;
}

nav button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

nav button:hover {
    background: rgba(255, 255, 255, 0.3);
}

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

section {
    margin-bottom: 3rem;
    padding: 1.5rem;
    border: 1px solid var(--secondary-color);
    border-radius: var(--border-radius);
    background: var(--bg-color);
}

/* Contributors Heatmap - CSS Grid Magic */
.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(7, 1fr);
    gap: 2px;
    width: 100%;
    max-width: 400px;
    margin: 1rem auto;
    border-radius: var(--border-radius);
    overflow: hidden;
}

.heatmap-cell {
    aspect-ratio: 1;
    background: var(--activity-low);
    border-radius: 2px;
    transition: var(--transition);
    position: relative;
}

.heatmap-cell[data-activity="medium"] {
    background: var(--activity-medium);
}

.heatmap-cell[data-activity="high"] {
    background: var(--activity-high);
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.heatmap-cell:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--secondary-color);
    color: var(--text-color);
    padding: 0.5rem;
    border-radius: var(--border-radius);
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 10;
}

/* Activity Levels - CSS Flexbox Charts */
.activity-flex {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 1rem 0;
}

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

.activity-label {
    min-width: 150px;
    font-weight: bold;
}

.activity-fill {
    flex: 1;
    height: 20px;
    background: var(--secondary-color);
    border-radius: var(--border-radius);
    position: relative;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.pr-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--primary-color);
    border-radius: var(--border-radius);
    width: var(--percentage, 0%);
    transition: width 1s ease;
}

.mailing-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: #ff9800;
    /* Orange for mailing */
    border-radius: var(--border-radius);
    width: var(--percentage, 0%);
    transition: width 1s ease;
}

.activity-value {
    min-width: 50px;
    text-align: right;
}

/* Hide mailing activity when toggled */
#activity-section.hide-mailing .mailing-fill,
#activity-section.hide-mailing .activity-value:last-child {
    display: none;
}

/* Discussions Feed - CSS Transitions */
.discussions-list {
    margin: 1rem 0;
}

.discussion-item {
    padding: 1rem;
    border: 1px solid var(--secondary-color);
    border-radius: var(--border-radius);
    margin-bottom: 0.5rem;
    transition: var(--transition);
    cursor: pointer;
}

.discussion-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.discussion-item.new {
    animation: slideIn 0.5s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Diversity Metrics - CSS Animations */
.diversity-animated {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    margin: 1rem 0;
    justify-content: center;
}

.diversity-item {
    text-align: center;
    min-width: 120px;
}

.diversity-chart {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: conic-gradient(var(--diversity-color-1) 0% var(--segment-1, 0%),
            var(--diversity-color-2) var(--segment-1, 0%) var(--segment-2, 0%),
            var(--diversity-color-3) var(--segment-2, 0%) var(--segment-3, 0%),
            var(--diversity-color-4) var(--segment-3, 0%) 100%);
    margin: 0 auto 0.5rem;
    position: relative;
    animation: rotate 10s linear infinite;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.diversity-label {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

/* Toggle Button */
.toggle-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    margin-bottom: 10px;
    transition: background 0.3s ease;
}

.toggle-btn:hover {
    background: var(--secondary-color);
}

.hidden {
    display: none;
}

/* Mailing List Activity */
.mailing-list {
    margin: 1rem 0;
}

.mailing-item {
    padding: 1rem;
    border: 1px solid var(--secondary-color);
    border-radius: var(--border-radius);
    margin-bottom: 0.5rem;
    transition: var(--transition);
    cursor: pointer;
}

.mailing-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.mailing-item h3 {
    margin-bottom: 0.5rem;
}

.mailing-item p {
    color: var(--text-color);
    opacity: 0.8;
}

/* Responsive Design */
@media (max-width: 768px) {
    .heatmap-grid {
        grid-template-columns: repeat(5, 1fr);
        grid-template-rows: repeat(9, 1fr);
    }

    .activity-flex {
        gap: 0.5rem;
    }

    .activity-label {
        min-width: 100px;
        font-size: 0.9rem;
    }

    header {
        flex-direction: column;
        gap: 1rem;
    }

    nav {
        width: 100%;
        justify-content: center;
    }
}

/* Accessibility: Respect user motion preferences */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
button:focus,
.heatmap-cell:focus,
.discussion-item:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

footer {
    text-align: center;
    padding: 1rem;
    background: var(--secondary-color);
    margin-top: 2rem;
}