.timeline-table-frame { container-type: inline-size; }
.timeline-guide summary { color: var(--link); cursor: pointer; width: fit-content; }
.timeline-guide p { color: var(--muted); }
.timeline-guide summary:focus-visible,
.timeline-table-frame .table-scroll:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; }
.timeline-sort-controls { display: none; }
.timeline-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

body[data-wiki-presentation] .wp-content .timeline-table-frame table.wikitable {
    table-layout: fixed;
    line-height: 1.55;
}
body[data-wiki-presentation] .wp-content #life-timeline :is(th, td) {
    border-color: var(--soft-border);
    padding: .62em .75em;
    text-align: start;
    overflow-wrap: break-word;
}
body[data-wiki-presentation] .wp-content #life-timeline th { padding: 0; }
#life-timeline th:nth-child(-n+2) { width: 5.4em; }
#life-timeline th:nth-child(3) { width: 13%; }
#life-timeline th:nth-child(4) { width: 17%; }
#life-timeline th:nth-child(6) { width: 21%; }
#life-timeline .timeline-year {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    white-space: nowrap;
}
#life-timeline .timeline-role { font-weight: 600; }
#life-timeline .timeline-date-detail { color: var(--muted); font-weight: 600; }
#life-timeline .timeline-sources a { font-weight: 400; text-decoration: none; }
#life-timeline .timeline-sources a + br + a { margin-block-start: .35em; }
#life-timeline tbody tr:nth-child(even) { background: var(--panel); }
#life-timeline tbody tr { scroll-margin-block-start: 4rem; }
#life-timeline tbody tr:target td { background: color-mix(in srgb, var(--link) 10%, var(--page)); }
#life-timeline tbody tr:target .timeline-year:first-child { box-shadow: inset 3px 0 var(--link); }
#life-timeline .timeline-header-label { display: block; padding: .6em .75em; }
#life-timeline th button {
    display: flex;
    align-items: center;
    gap: .38em;
    justify-content: space-between;
    width: 100%;
    min-height: 44px;
    padding: .5em .75em;
    cursor: pointer;
    font-weight: 600;
    text-align: start;
    border: 0;
    background: transparent;
}
#life-timeline th button::after { content: '↕' / ''; color: var(--muted); flex: none; }
#life-timeline th[aria-sort='ascending'] button::after { content: '↑' / ''; }
#life-timeline th[aria-sort='descending'] button::after { content: '↓' / ''; }
#life-timeline th[aria-sort] button::after { color: var(--link); }
#life-timeline th button:hover { background: color-mix(in srgb, var(--link) 8%, var(--panel)); }
#life-timeline th button:focus-visible { outline-offset: -3px; }
#life-timeline th:has(button) .timeline-header-label { display: none; }

@container (min-width: 48rem) {
    body[data-wiki-presentation] .wp-content .timeline-table-frame .table-scroll { overflow: visible; }
    #life-timeline thead th { position: sticky; top: 0; z-index: 1; box-shadow: 0 1px var(--soft-border); }
}

@container (max-width: 47.999rem) {
    .timeline-sort-controls:not([hidden]) {
        display: flex;
        flex-wrap: wrap;
        gap: .5em;
        align-items: center;
        padding: .75em;
        margin-block-start: 1em;
        background: var(--panel);
        border: 1px solid var(--soft-border);
    }
    .timeline-sort-controls label { font-weight: 600; }
    .timeline-sort-controls :is(select, button) { min-height: 44px; padding: .3em .55em; }
    .timeline-sort-controls button { cursor: pointer; }
    body[data-wiki-presentation] .wp-content .timeline-table-frame table.wikitable {
        display: block;
        position: relative;
        border: 0;
    }
    #life-timeline caption { display: block; }
    #life-timeline thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }
    #life-timeline th button { display: none; }
    #life-timeline th:has(button) .timeline-header-label { display: block; }
    #life-timeline tbody { display: block; border: 1px solid var(--soft-border); }
    #life-timeline tbody tr {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding: .85em .95em;
    }
    #life-timeline tbody tr + tr { border-top: 1px solid var(--soft-border); }
    body[data-wiki-presentation] .wp-content #life-timeline tbody td { border: 0; padding: .3em 0; }
    #life-timeline tbody td:nth-child(odd):nth-child(-n+4) { padding-inline-end: .75em; }
    #life-timeline .timeline-year::before,
    #life-timeline .timeline-sources::before { display: block; font-weight: 600; color: var(--muted); font-size: .83em; }
    #life-timeline .timeline-year::before { content: attr(data-label) / ''; }
    #life-timeline .timeline-sources::before { content: 'Sources' / ''; }
    #life-timeline .timeline-activity, #life-timeline .timeline-sources { grid-column: 1 / -1; }
    #life-timeline .timeline-sources a { min-height: 24px; }
    #life-timeline tbody tr:target td { background: none; }
    #life-timeline tbody tr:target .timeline-year:first-child { box-shadow: none; }
    #life-timeline tbody tr:target {
        background: color-mix(in srgb, var(--link) 10%, var(--page));
        box-shadow: inset 3px 0 var(--link);
    }
}
