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

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

body {
    font-family: 'Lato', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #fafafa;
    color: #333;
    line-height: 1.5;
}

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

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

header h1 {
    font-size: 1.8rem;
    font-weight: 600;
    color: #222;
}

header h1 .scholar-link {
    font-size: 1rem;
    font-weight: 400;
}

header h1 a {
    color: #4a90d9;
    text-decoration: none;
}

header h1 a:hover {
    text-decoration: underline;
}

/* Toggle controls */
.controls {
    display: flex;
    gap: 24px;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.toggle-label {
    font-size: 0.85rem;
    color: #666;
}

.toggle input {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 36px;
    height: 20px;
    background: #ccc;
    border-radius: 10px;
    transition: background 0.2s ease;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle input:checked + .toggle-slider {
    background: #4a90d9;
}

.toggle input:checked + .toggle-slider::after {
    transform: translateX(16px);
}

section {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

section h2 {
    font-size: 1.1rem;
    font-weight: 500;
    color: #444;
    margin-bottom: 16px;
}

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

.section-header h2 {
    margin-bottom: 0;
}

#paper-select {
    font-size: 0.9rem;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    min-width: 300px;
    max-width: 500px;
    cursor: pointer;
}

#paper-select:focus {
    outline: none;
    border-color: #666;
}

#year-select {
    font-size: 0.9rem;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer;
}

#year-select:focus {
    outline: none;
    border-color: #666;
}

#line-plot, #stream-plot {
    width: 100%;
    overflow: hidden;
}

/* Chart styling */
.axis path,
.axis line {
    stroke: #ccc;
}

.axis text {
    font-size: 11px;
    fill: #666;
}

.axis-label {
    font-size: 12px;
    fill: #444;
}

.uncertainty-area {
    fill: #4a90d9;
    opacity: 0.2;
}

.smoothed-line {
    fill: none;
    stroke: #4a90d9;
    stroke-width: 2;
}

/* Forecast elements */
.forecast-area {
    fill: #4a90d9;
    opacity: 0.15;
}

.forecast-line {
    fill: none;
    stroke: #4a90d9;
    stroke-width: 2;
    stroke-dasharray: 5, 5;
}

.demarcation-line {
    stroke: #888;
    stroke-width: 1;
    stroke-dasharray: 4, 4;
}

.empirical-point {
    fill: #e74c3c;
    stroke: white;
    stroke-width: 1.5;
}

.forecast-sample-point {
    fill: none;
    stroke: #e74c3c;
    stroke-width: 1.5;
}

.stream-layer {
    opacity: 0.85;
    transition: opacity 0.15s ease;
}

.stream-layer:hover {
    opacity: 1;
}

.stream-layer.faded {
    opacity: 0.3;
}

/* Treemap */
#treemap-plot {
    width: 100%;
    overflow: hidden;
}

.treemap-cell {
    stroke: white;
    stroke-width: 1px;
    transition: stroke 0.15s ease, stroke-width 0.15s ease;
}

.treemap-cell:hover {
    stroke: #333;
    stroke-width: 2px;
}

.treemap-label {
    font-size: 11px;
    fill: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    pointer-events: none;
}

/* Legend */
.legend {
    display: flex;
    gap: 20px;
    margin-top: 12px;
    font-size: 0.85rem;
    color: #666;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
}

.legend-color.empirical {
    background: #e74c3c;
    border-radius: 50%;
    width: 10px;
    height: 10px;
}

.legend-color.smoothed {
    background: #4a90d9;
    height: 3px;
    border-radius: 0;
}

.legend-color.uncertainty {
    background: #4a90d9;
    opacity: 0.3;
}

.legend-color.forecast {
    background: linear-gradient(90deg, #4a90d9 0%, #4a90d9 40%, transparent 40%, transparent 60%, #4a90d9 60%, #4a90d9 100%);
    height: 3px;
    border-radius: 0;
}

/* Tooltip */
#tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 10px 14px;
    border-radius: 4px;
    font-size: 0.85rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    max-width: 350px;
    z-index: 100;
}

#tooltip.visible {
    opacity: 1;
}

#tooltip .title {
    font-weight: 500;
    margin-bottom: 4px;
}

#tooltip .value {
    color: #aaa;
}

/* Footer */
footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    margin-top: 8px;
    font-size: 0.85rem;
    color: #888;
}

footer a {
    color: #4a90d9;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .controls {
        flex-wrap: wrap;
        gap: 16px;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    #paper-select {
        width: 100%;
        max-width: none;
    }

    .legend {
        flex-wrap: wrap;
    }
}
