/*
 * Teaching overview (fr/enseignement/enseignement.html, en/teaching/teaching.html):
 * hero figures, the course timeline and the year summaries. The markup is
 * generated by src/main/teaching_overview.py; colours come from the page's own
 * variables, and each lane or card carries its theme colour as --theme.
 */

.teaching-overview .hero-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.teaching-overview .hero-stat {
    background: var(--bg-secondary);
    border: 2px solid rgba(37, 99, 235, 0.1);
    border-radius: 1.25rem;
    padding: 1.25rem 1rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.teaching-overview .hero-stat-value {
    font-size: 2.6rem;
    font-weight: 800;
    line-height: 1;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.teaching-overview .hero-stat-label {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.timeline-section {
    margin-bottom: 2rem;
}

.timeline-hint {
    color: var(--text-secondary);
    max-width: 70ch;
    margin: -1.5rem 0 1.5rem;
}

.timeline-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.timeline-controls .control-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.year-btn,
.theme-btn {
    font: inherit;
    font-size: 0.9rem;
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    border: 2px solid rgba(37, 99, 235, 0.18);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.year-btn:hover,
.theme-btn:hover {
    border-color: var(--accent-blue);
}

.year-btn[aria-pressed="true"] {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: #fff;
}

.theme-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.theme-btn .theme-dot {
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 50%;
    background: var(--theme);
}

.theme-btn[aria-pressed="true"] {
    border-color: var(--theme);
    background: color-mix(in srgb, var(--theme) 14%, var(--bg-secondary));
}

.year-btn:focus-visible,
.theme-btn:focus-visible {
    outline: 3px solid var(--accent-orange);
    outline-offset: 2px;
}

.year-summaries {
    background: var(--bg-secondary);
    border: 2px solid rgba(37, 99, 235, 0.1);
    border-radius: 1.25rem;
    padding: 1rem 1.5rem;
    margin-bottom: 1.25rem;
    min-height: 3.5rem;
}

.year-summary h3 {
    color: var(--accent-blue);
    margin-bottom: 0.35rem;
}

.year-summary p {
    color: var(--text-secondary);
    margin: 0.15rem 0;
}

.year-summary .year-figures strong {
    color: var(--text-primary);
}

.year-summary .year-new::before {
    content: "+ ";
    color: #16a34a;
    font-weight: 700;
}

.year-summary .year-ended::before {
    content: "− ";
    color: #dc2626;
    font-weight: 700;
}

/*
 * The timeline is a column of names (HTML) beside the years (SVG). Row heights
 * are given in SVG units (--h) and both sides are scaled by the same --u, so
 * the rows line up. On a wide screen --u stretches the years to the remaining
 * width; on a narrow one it is 1px and only the years scroll.
 */
.timeline-frame {
    container-type: inline-size;
    background: var(--bg-secondary);
    border: 2px solid rgba(37, 99, 235, 0.1);
    border-radius: 1.25rem;
    padding: 0.5rem;
    box-shadow: var(--shadow-sm);
}

.timeline-body {
    --labels: 380px;
    --u: calc((100cqw - var(--labels)) / var(--years-w));
    display: flex;
    align-items: flex-start;
}

.timeline-labels {
    list-style: none;
    flex: 0 0 var(--labels);
    width: var(--labels);
    min-width: 0;
}

.timeline-labels li {
    height: calc(var(--u) * var(--h));
    display: flex;
    align-items: center;
    padding: 0 0.5rem 0 0.75rem;
    min-width: 0;
}

.timeline-labels .theme-row {
    font-weight: 700;
    gap: 0.5rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.timeline-labels .theme-swatch {
    flex: none;
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 3px;
    background: var(--theme);
}

.timeline-labels .lane {
    padding-left: 2rem;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.timeline-labels .lane span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.timeline-labels .lane-past {
    color: var(--text-secondary);
}

.timeline-scroll {
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
}

.timeline-svg {
    display: block;
    width: calc(var(--u) * var(--years-w));
    height: auto;
    font-family: inherit;
}

.timeline-svg .year-col rect {
    fill: transparent;
    cursor: pointer;
}

.timeline-svg .year-col:nth-child(odd) rect {
    fill: rgba(37, 99, 235, 0.03);
}

.timeline-svg .year-col.is-selected rect {
    fill: rgba(37, 99, 235, 0.12);
}

.timeline-svg .year-label {
    text-anchor: middle;
    font-size: 15px;
    font-weight: 600;
    fill: var(--text-secondary);
    cursor: pointer;
}

.timeline-svg .year-now .year-label {
    fill: var(--accent-blue);
    font-weight: 800;
}

.timeline-svg .run {
    fill: var(--theme);
    fill-opacity: 0.28;
}

.timeline-svg .lane-current .run {
    fill-opacity: 0.55;
}

.timeline-svg .dot {
    fill: var(--theme);
    stroke: #fff;
    stroke-width: 2;
    transition: r 0.15s ease;
}

.timeline-svg a:hover .dot,
.timeline-svg a:focus .dot {
    r: 9;
}

.timeline-svg a:focus {
    outline: none;
}

.timeline-svg a:focus-visible .dot {
    stroke: var(--accent-orange);
    stroke-width: 3;
}

.timeline-svg .lineage {
    fill: none;
    stroke: var(--text-secondary);
    stroke-width: 1.5;
    opacity: 0.55;
}

.timeline-svg .lineage.proposed {
    stroke-dasharray: 4 4;
}

.timeline-svg .lane,
.timeline-labels li,
.timeline-svg .lineage,
.course-card {
    transition: opacity 0.25s ease;
}

.timeline-svg .is-dim,
.timeline-labels .is-dim,
.course-card.is-dim {
    opacity: 0.18;
}

.course-card.is-dim {
    filter: grayscale(0.7);
}

.teaching-overview span.course-title {
    cursor: default;
}

@media (max-width: 1024px) {
    .teaching-overview .hero-stats {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    .timeline-body {
        --labels: 46vw;
        --u: 1px;
    }

    .timeline-labels .lane {
        padding-left: 1rem;
        font-size: 0.8rem;
    }

    .timeline-labels .theme-row {
        font-size: 0.85rem;
    }

    .teaching-overview .hero-stats {
        grid-template-columns: repeat(2, 1fr);
    }

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

    .year-summaries {
        padding: 0.75rem 1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .timeline-svg .lane,
    .timeline-labels li,
    .timeline-svg .lineage,
    .timeline-svg .dot,
    .course-card {
        transition: none;
    }
}
