/* timeline.css (6.65, 15 Nov 2026) - the Timeline page (timeline.php). Matt: "I do like the style we've got going, but I
 * want to make it vertical again because we're going to have a lot of different ... timeline events", and pictures:
 * "it should be the date, it should be a picture, and then it should be the description text underneath it".
 *
 * The 6.61 to 6.64 look turned upright: one glowing line runs down the middle; each event hangs off it on a diamond
 * marker, left and right in turn, and the two sides overlap so the cards interleave instead of leaving gaps. Where a
 * new year starts, a divide runs across the whole line with the year (and the in-game year) on it. Upcoming events are
 * dashed with a hollow marker. On a phone the line runs down the left and every card hangs to its right.
 * The markup comes from scripts/site_pages_lib.php (sp_timeline_html) and is sent again after every admin change, so
 * the look is all done here. Colours are the v7 tokens only (css/root.css). Plain words, no em dashes (site rule). */

.timeline-page .tl-wrap {
    box-sizing: border-box;
    width: 100%;
    max-width: var(--page-w);
    margin: 0 auto;
    padding: 1.2rem var(--gutter) clamp(2.5rem, 5vw, 4rem);
    text-align: left;
}

/* ---------------------------------------------------------- Head */

.tl-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 320px);
    gap: 1.2rem clamp(1.5rem, 4vw, 3rem);
    align-items: end;
    margin-bottom: clamp(1.4rem, 3vw, 2.2rem);
}

.tl-wrap .v7-plate {
    margin: 0 0 0.6rem;
}

.tl-wrap .tl-heading {
    margin: 0;
    font-size: clamp(1.3rem, 2.4vw, 1.9rem);
    line-height: 1.2;
    text-align: left;
}

.tl-crt {
    padding: 1rem 1.3rem 1.1rem;
    font-size: 3.6rem;
    border: 1px solid var(--rule);
}

.tl-crt small {
    font-size: 1.3rem;
    letter-spacing: 0.06em;
}

.tl-crt small + small {
    margin-top: 0;
}

.tl-end {
    margin-top: clamp(1.6rem, 4vw, 2.6rem);
}

/* ---------------------------------------------------------- The line */

.tl-line {
    --rail: 4rem;            /* the band down the middle the line runs along */
    --overlap: 3.5rem;       /* how far each card starts above the bottom of the one before (the other side) */
    position: relative;
    margin: 0;
    padding: 0.4rem 0 1.5rem;
    list-style: none;
}

/* the beam, and faint ticks along it */
.tl-line::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: calc(50% - 1px);
    width: 2px;
    background: linear-gradient(180deg, var(--rule-soft), var(--accent) 2.5rem, var(--accent-hi) 50%, var(--accent) calc(100% - 2.5rem), var(--rule-soft));
    box-shadow: var(--glow);
}

.tl-line::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: calc(50% - 5px);
    width: 10px;
    background: repeating-linear-gradient(180deg, var(--rule-soft) 0 1px, transparent 1px 24px);
    pointer-events: none;
}

.tl-item {
    position: relative;
    z-index: 1;
    box-sizing: border-box;
    width: calc(50% - var(--rail) / 2);
    padding-bottom: 1.4rem;
}

.tl-item.is-right {
    margin-left: auto;
}

.tl-item + .tl-item {
    margin-top: calc(-1 * var(--overlap));
}

/* the marker on the line, level with the date */
.tl-node {
    position: absolute;
    z-index: 2;
    top: 1.05rem;
    width: 16px;
    height: 16px;
    box-sizing: border-box;
    background: var(--accent);
    border: 2px solid var(--paper);
    outline: 1px solid var(--accent-hi);
    transform: rotate(45deg);
    box-shadow: var(--glow);
}

.tl-item.is-left .tl-node {
    right: calc(var(--rail) / -2 - 8px);
}

.tl-item.is-right .tl-node {
    left: calc(var(--rail) / -2 - 8px);
}

.tl-item.is-upcoming .tl-node {
    background: var(--paper);
    outline-style: dashed;
}

/* the stalk from the card to the marker */
.tl-item::before {
    content: "";
    position: absolute;
    top: calc(1.05rem + 7px);
    width: calc(var(--rail) / 2 - 10px);
    height: 0;
    border-top: 1px solid var(--accent);
}

.tl-item.is-left::before {
    right: calc(var(--rail) / -2 + 10px);
}

.tl-item.is-right::before {
    left: calc(var(--rail) / -2 + 10px);
}

/* ---------------------------------------------------------- Year divides (6.62, now across the line) */

.tl-year {
    position: relative;
    z-index: 3;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 1rem 0 1.6rem;
    min-height: 3.4rem;
    pointer-events: none;
}

.tl-year:first-child {
    margin-top: 0;
}

.tl-year::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 0;
    border-top: 2px solid var(--accent);
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent);
    mask-image: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent);
    opacity: 0.75;
}

.tl-year-tag {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.35rem 0.9rem 0.4rem;
    background: var(--paper);
    border: 1px solid var(--accent);
    box-shadow: var(--glow);
    text-align: center;
}

.tl-year-tag b {
    color: var(--phosphor, var(--accent-hi));
    font: 700 1.3rem/1.15 var(--font-crt);
    letter-spacing: 0.08em;
    text-shadow: var(--glow);
}

.tl-year-tag small {
    color: var(--ink-2);
    font: 500 0.72rem/1.3 var(--font-mono);
    white-space: nowrap;
}

.tl-year-tag em {
    color: var(--warn, var(--accent-hi));
    font: italic 500 0.7rem/1.3 var(--font-mono);
    letter-spacing: 0.04em;
}

/* the first card after a divide starts below it, not tucked under it */
.tl-year + .tl-item {
    margin-top: 0;
}

/* ---------------------------------------------------------- The card: date, picture, words */

.tl-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    box-sizing: border-box;
    min-height: calc(var(--overlap) * 2 + 0.5rem);   /* so two cards on one side never meet where the sides overlap */
    padding: 0.95rem 1.05rem 1rem;
    background: var(--sheet);
    border: 1px solid var(--rule);
    clip-path: var(--chamfer);
    backdrop-filter: blur(6px);
    transition: border-color 0.18s ease;
}

.tl-item.is-left .tl-card {
    border-right: 3px solid var(--accent);   /* the edge that faces the line */
}

.tl-item.is-right .tl-card {
    border-left: 3px solid var(--accent);
}

/* The chamfer clips a card's own shadow (review), and a filter on the item would switch off the card's blur, so a
   card says it is picked with its border, and its marker lights up. */
.tl-item:hover .tl-node,
.tl-item:focus-within .tl-node {
    background: var(--accent-hi);
}

.tl-card:hover,
.tl-item:focus-within .tl-card {
    border-color: var(--accent);
}

.tl-item.is-upcoming .tl-card {
    border-style: dashed;
}

.tl-item.is-upcoming.is-left .tl-card {
    border-right-style: solid;
    border-right-color: var(--warn);
}

.tl-item.is-upcoming.is-right .tl-card {
    border-left-style: solid;
    border-left-color: var(--warn);
}

.tl-item.is-new .tl-card {
    border-color: var(--good);
}

.tl-item.is-new .tl-node {
    background: var(--good);
    outline-color: var(--good);
}

.tl-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem 0.8rem;
}

.tl-card .tl-date {
    margin: 0;
    color: var(--accent-hi);
    font: 600 0.95rem/1.35 var(--font-crt);
    letter-spacing: 0.04em;
    text-transform: none;
}

.tl-upcoming {
    display: inline-block;
    margin: 0 0.5rem 0.15rem 0;
    padding: 0.05rem 0.5rem;
    background: var(--warn);
    color: var(--on-accent);
    font: 600 0.72rem/1.5 var(--font-mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    vertical-align: middle;
}

/* 6.65 (Matt: "in real life or in universe"): the tag */
.tl-realm {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.12rem 0.55rem;
    border: 1px solid var(--rule);
    background: var(--paper);
    color: var(--ink-2);
    font: 500 0.74rem/1.4 var(--font-mono);
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.tl-realm-verse {
    border-color: var(--accent);
    color: var(--phosphor, var(--accent-hi));
}

.tl-realm-none {
    border-style: dashed;
    border-color: var(--warn);
    color: var(--warn);
}

/* 6.65: the picture, under the date */
.tl-pic {
    position: relative;
    display: block;
    margin: 0;
    overflow: hidden;
    border: 1px solid var(--rule);
    background: var(--paper);
}

.tl-pic img {
    display: block;
    width: 100%;
    height: auto;
}

a.tl-pic:focus-visible {
    outline: 2px solid var(--accent-hi);
    outline-offset: 3px;
}

.tl-pic-open {
    position: absolute;
    right: 0.45rem;
    bottom: 0.45rem;
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    background: var(--paper);
    border: 1px solid var(--accent);
    color: var(--accent-hi);
    opacity: 0;
    transition: opacity 0.15s ease;
}

a.tl-pic:hover .tl-pic-open,
a.tl-pic:focus-visible .tl-pic-open {
    opacity: 1;
}

@media (hover: none) {
    .tl-pic-open {
        opacity: 0.85;   /* no hover on a touch screen: always show that it opens */
    }
}

.tl-card .tl-body {
    margin: 0;
    color: var(--ink-2);
    font-size: 0.98rem;
    line-height: 1.55;
}

.tl-card .tl-body p {
    margin: 0;
}

.tl-card .tl-body p + p {
    margin-top: 0.5rem;
}

.tl-card .tl-admin {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 0.2rem;
}

.tl-empty {
    margin: 1rem 0;
    color: var(--ink-2);
    list-style: none;
    text-align: center;
    position: relative;
    z-index: 1;
    background: var(--paper);
}

.tl-wrap .tl-add {
    margin: 1rem 0 0;
    text-align: center;
}

.tl-wrap .tl-store {
    max-width: 62ch;
    margin: 0.7rem auto 0;
}

/* ---------------------------------------------------------- Phones: the line down the left */

@media (max-width: 700px) {
    .tl-head {
        grid-template-columns: minmax(0, 1fr);
    }

    .tl-crt {
        font-size: 2.6rem;
    }

    .tl-line {
        --rail: 2.2rem;
    }

    .tl-line::before {
        left: calc(var(--rail) / 2 - 1px);
    }

    .tl-line::after {
        left: calc(var(--rail) / 2 - 5px);
    }

    .tl-item,
    .tl-item.is-right {
        width: auto;
        margin-left: var(--rail);
    }

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

    .tl-item.is-left .tl-node,
    .tl-item.is-right .tl-node {
        left: calc(var(--rail) / -2 - 8px);
        right: auto;
    }

    .tl-item.is-left::before,
    .tl-item.is-right::before {
        left: calc(var(--rail) / -2 + 10px);
        right: auto;
    }

    .tl-item.is-left .tl-card {
        border-right: 1px solid var(--rule);
        border-left: 3px solid var(--accent);
    }

    .tl-item.is-upcoming.is-left .tl-card {
        border-right-style: dashed;
        border-left-color: var(--warn);
    }

    .tl-card {
        min-height: 0;
    }

    .tl-year {
        justify-content: flex-start;   /* the tag sits on the line, at the left */
    }
}

@media (prefers-reduced-motion: reduce) {
    .tl-card,
    .tl-pic-open {
        transition: none;
    }
}
