/*
 * Timeline
 *
 * Everything site specific is a custom property. Set them on .timeline or on any element above it.
 * Note that the defaults assume a dark page.
 */

.timeline {
    --timeline-bg: #1b1a19;             /* Background of the page, used behind the dots and the sticky filters */
    --timeline-surface: #23262a;        /* Cards and the search field */
    --timeline-surface-active: #30353a; /* Active filter */
    --timeline-text: #ccc;
    --timeline-heading: #e9e9e9;
    --timeline-muted: #969ca3;
    --timeline-border: #3d4349;
    --timeline-accent: #f78f0b;
    --timeline-line: linear-gradient(var(--timeline-accent), var(--timeline-accent));
    --timeline-radius: 5px;
    --timeline-sticky-top: 0px;         /* Height of a fixed navigation, so the filters stick below it */
    --timeline-font-mono: Consolas, "Cascadia Mono", "SF Mono", Menlo, monospace;

    color: var(--timeline-text);
}

/* The layout relies on it, so the timeline doesn't depend on the reset of the site */
.timeline,
.timeline *,
.timeline *::before,
.timeline *::after {
    box-sizing: border-box;
}

.timeline [hidden] {
    display: none !important;
}

/* Filters and search */

.timeline-controls {
    position: sticky;
    top: var(--timeline-sticky-top);
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    border-bottom: 1px solid var(--timeline-border);
    background: color-mix(in srgb, var(--timeline-bg) 94%, transparent);
    backdrop-filter: blur(8px);
}

.timeline-filter {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--timeline-border);
    border-radius: var(--timeline-radius);
    background: transparent;
    color: var(--timeline-category, var(--timeline-text));
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    opacity: .55;

    &[aria-pressed="true"] {
        border-color: var(--timeline-muted);
        background: var(--timeline-surface-active);
        opacity: 1;
    }

    svg {
        width: 12px;
        height: 12px;
    }

    span {
        color: var(--timeline-text);
    }
}

.timeline-search {
    flex: 1 1 180px;
    min-width: 0;
    padding: 7px 14px;
    border: 1px solid var(--timeline-border);
    border-radius: var(--timeline-radius);
    background: var(--timeline-surface);
    color: var(--timeline-heading);
    font: inherit;
    font-size: 14px;
    line-height: 1.3;

    &:focus {
        border-color: var(--timeline-accent);
        outline: 0;
    }
}

.timeline-count {
    color: var(--timeline-muted);
    font-size: 13px;
}

/* The line and its events */

.timeline-list {
    position: relative;
    margin-top: 24px;

    &::before {
        content: "";
        position: absolute;
        top: 0;
        bottom: 0;
        left: 50%;
        width: 2px;
        background: var(--timeline-line);
        transform: translateX(-1px);
        opacity: .55;
    }
}

.timeline-group {
    position: relative;
    margin: 34px 0 18px;
    text-align: center;

    span {
        display: inline-block;
        padding: 6px 16px;
        border-radius: var(--timeline-radius);
        background: var(--timeline-accent);
        color: var(--timeline-heading);
        font-size: 20px;
        font-weight: 900;
        line-height: 1.2;
    }
}

.timeline-item {
    position: relative;
    width: 50%;
    padding: 0 34px 18px 0;

    /* The two sides overlap, otherwise the line would be twice as long as needed. */
    /* The first visible event below a heading must not be pulled up, it would slide into the heading. */
    /* The script marks it, since a hidden event can still sit in between. */
    & + &:not(.timeline-item-first) {
        margin-top: -40px;
    }
}

.timeline-item-right {
    margin-left: 50%;
    padding: 0 0 18px 34px;

    .timeline-dot {
        right: auto;
        left: -9px;
    }
}

.timeline-dot {
    position: absolute;
    top: 14px;
    right: -9px;
    display: grid;
    place-items: center;
    width: 18px;
    height: 18px;
    border: 2px solid var(--timeline-category, var(--timeline-muted));
    border-radius: 50%;
    background: var(--timeline-bg);
    color: var(--timeline-category, var(--timeline-text));

    svg {
        width: 8px;
        height: 8px;
    }
}

.timeline-card {
    padding: 12px 14px;
    border: 1px solid var(--timeline-border);
    border-radius: var(--timeline-radius);
    background: var(--timeline-surface);
    transition: border-color .15s;

    &[role="button"] {
        cursor: pointer;

        &:hover {
            border-color: var(--timeline-muted);
        }
    }

    &:focus-visible {
        outline: 2px solid var(--timeline-accent);
        outline-offset: 2px;
    }
}

.timeline-card-major {
    border-left: 3px solid var(--timeline-accent);
}

.timeline-date {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    color: var(--timeline-muted);
    font-size: 12px;

    /* Only the date is monospaced, the tag next to it keeps the font of the page */
    > :first-child {
        font-family: var(--timeline-font-mono);
    }
}

.timeline-tag {
    padding: 3px 6px;
    border: 1px solid currentColor;
    border-radius: 3px;
    color: var(--timeline-category, var(--timeline-text));
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.timeline .timeline-title {
    max-width: none;
    margin: 4px 0 0;
    color: var(--timeline-heading);
    font-size: 16px;
    font-weight: 700;
    line-height: 1.35;
}

.timeline-detail {
    margin-top: 8px;
    font-size: 14px;
    line-height: 1.55;
}

/* Without the script the details stay open, as there's no other way to get to them */
.timeline-enhanced .timeline-card:not(.is-open) .timeline-detail {
    display: none;
}

.timeline .timeline-empty {
    max-width: none;
    padding: 40px 0;
    color: var(--timeline-muted);
    font-size: 15px;
    text-align: center;
}

/* A phone has no room for two sides, so the line moves to the left and all the events sit on its right */
@media (max-width: 767px) {
    /* Sticky filters would cover quite a bit of the screen */
    .timeline-controls {
        position: static;
    }

    .timeline-list::before {
        left: 10px;
    }

    .timeline-item,
    .timeline-item-right {
        width: auto;
        margin-left: 0;
        padding: 0 0 16px 34px;

        .timeline-dot {
            right: auto;
            left: 1px;
        }
    }

    .timeline-item + .timeline-item {
        margin-top: 0;
    }

    .timeline-group {
        text-align: left;
    }
}
