/* Firefall history */
/* The custom properties are also read by the charts in javascript/pages/history.js. */

.history {
    --prose: 720px;
    --toc-height: 45px;
    --bg: var(--color-surface);
    --surface: #23262a;
    --surface-2: var(--color-slate);
    --ink: #e9e9e9;
    --ink-2: var(--color-text);
    --muted: #969ca3;
    --line: #3d4349;
    --accent: var(--color-accent);
    --crystite: #5cb8ff;
    --melding: #b07cff;
    --s1: var(--color-info);
    --s2: var(--color-accent);
    --s3: var(--color-success);

    padding-bottom: 40px;

    a[href] {
        text-underline-offset: 3px;
    }

    code {
        font-family: var(--font-mono);
        font-size: .85em;
        color: var(--ink);
        background: var(--surface-2);
        padding: .1em .35em;
        border-radius: 4px;
    }

    /* Hero */

    .history-hero {
        position: relative;
        overflow: hidden;
        margin: 0 -15px;
        border-bottom: 1px solid var(--line);

        h1 {
            margin: 28px 0 18px;
            font-size: 34px;
            font-size: clamp(34px, 6vw, 58px);
            line-height: 1.05;
            color: var(--ink);
        }

        .lede {
            max-width: var(--prose);
            margin: 0;
            font-size: 20px;
            line-height: 1.6;
        }
    }

    .history-hero-bg {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        background-position: center;
        background-size: cover;
        opacity: .4;

        &:after {
            content: "";
            position: absolute;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
            background: linear-gradient(180deg, transparent 0%, var(--color-surface) 95%);
        }
    }

    .history-hero-inner {
        position: relative;
        padding: 56px 30px 40px;
    }

    .history-logo {
        display: block;
        width: 90%;
        max-width: 520px;
        height: auto;
        filter: drop-shadow(0 6px 24px rgba(0, 0, 0, .5));
    }

    .stats {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 12px;
        margin-top: 36px;

        > * {
            min-width: 0;
        }
    }

    .stat {
        padding: 14px 16px;
        border: 1px solid var(--line);
        border-radius: 5px;
        background: rgb(35 38 42 / 85%);

        b {
            display: block;
            font-size: 26px;
            line-height: 1.1;
            color: var(--accent);
        }

        span {
            display: block;
            margin-top: 4px;
            font-size: 13px;
            line-height: 1.45;
            color: var(--muted);
        }
    }

    /* Chapter navigation */

    .history-toc {
        position: sticky;
        top: var(--nav-height);
        z-index: 50;
        margin: 0 -15px;
        padding: 0 15px;
        background: rgb(27 26 25 / 94%);
        backdrop-filter: blur(8px);
        border-bottom: 1px solid var(--line);
        font-size: 14px;
        line-height: 1.2;
    }

    .history-toc-links {
        display: flex;
        gap: 4px;
        height: calc(var(--toc-height) - 1px);
        align-items: center;
        overflow-x: auto;
        scrollbar-width: none;

        &::-webkit-scrollbar {
            display: none;
        }

        a {
            padding: 6px 10px;
            border-radius: 5px;
            white-space: nowrap;
            color: var(--muted);

            &:hover,
            &:focus {
                color: var(--ink);
                background: var(--surface-2);
            }

            &.active {
                color: #fff;
                background: var(--accent);
            }
        }
    }

    .history-progress {
        position: absolute;
        left: 0;
        bottom: -1px;
        width: 0;
        height: 2px;
        background: var(--accent);
    }

    /* Chapters and prose */

    .chapter {
        padding-top: 56px;
        /* Jump targets would otherwise end up below the two fixed bars */
        scroll-margin-top: calc(var(--nav-height) + var(--toc-height) - 20px);

        &.chapter-intro {
            padding-top: 40px;
        }
    }

    .chapter-head {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        gap: 14px;
        margin-bottom: 4px;
    }

    .chapter-years {
        font-family: var(--font-mono);
        font-size: 14px;
        line-height: 1;
        letter-spacing: .08em;
        color: var(--accent);
    }

    h2.headline {
        margin-top: 10px;
        font-size: 29px;

        @media (max-width: 767px) {
            font-size: 22px;
        }
    }

    h3 {
        margin: 0 0 10px;
        font-size: 22px;
    }

    .prose {
        max-width: var(--prose);

        p {
            margin: 0 0 1.1em;
        }

        p.dropcap:first-letter {
            float: left;
            padding: .06em .1em 0 0;
            font-size: 3.3em;
            font-weight: 700;
            line-height: .85;
            color: var(--accent);
        }
    }

    blockquote.patch {
        max-width: var(--prose);
        margin: 26px 0;
        padding: 16px 20px;
        border-left: 3px solid var(--accent);
        border-radius: 0 5px 5px 0;
        background: var(--surface);
        font-family: var(--font-mono);
        font-size: 15px;
        line-height: 1.6;
        color: var(--ink-2);

        strong {
            color: var(--ink);
        }

        cite {
            display: block;
            margin-top: 10px;
            font-family: var(--font-sans);
            font-size: 13px;
            font-style: normal;
            color: var(--muted);
        }
    }

    /* Figures */

    figure {
        margin: 32px 0;

        a {
            display: block;
            cursor: zoom-in;
        }

        img {
            display: block;
            width: 100%;
            height: auto;
            border-radius: 5px;
            background: var(--surface-2);
            box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
        }
    }

    figcaption {
        max-width: var(--prose);
        margin-top: 10px;
        font-size: 14px;
        line-height: 1.5;
        color: var(--muted);
    }

    .fig-row {
        margin: 32px 0;
    }

    .fig-pair {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 14px;

        figure {
            margin: 0;
        }
    }

    .frames {
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 6px;
        align-items: end;
        margin: 32px 0 10px;
        padding: 10px 6px 0;
        border-radius: 5px;
        background: radial-gradient(ellipse at 50% 90%, var(--color-slate), transparent 70%);

        figure {
            margin: 0;
            text-align: center;
        }

        img {
            max-width: 300px;
            margin: 0 auto;
            border-radius: 0;
            background: none;
            box-shadow: none;
        }

        figcaption {
            margin: 4px 0 10px;
            font-size: 12px;
            letter-spacing: .08em;
            text-transform: uppercase;
        }
    }

    .float-right {
        float: right;
        width: 34%;
        margin: 6px 0 16px 24px;

        &.float-wide {
            width: 40%;
        }

        img {
            background: none;
            box-shadow: none;
        }
    }

    .clear {
        clear: both;
    }

    /* Version explorer */

    .explorer {
        margin: 28px 0;
        border: 1px solid var(--line);
        border-radius: 5px;
        background: var(--surface);
        overflow: hidden;
    }

    .v-tabs {
        display: flex;
        gap: 2px;
        padding: 8px;
        overflow-x: auto;
        background: var(--surface-2);
        scrollbar-width: thin;

        button {
            flex: 0 0 auto;
            padding: 10px 12px;
            border: 0;
            border-radius: 5px;
            background: transparent;
            font-size: 14px;
            font-weight: 700;
            line-height: 1;
            color: var(--ink-2);
            cursor: pointer;

            &:hover {
                background: var(--surface);
                color: var(--ink);
            }

            &[aria-selected="true"] {
                background: var(--accent);
                color: #fff;
            }
        }
    }

    .v-panel {
        display: grid;
        grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
        min-height: 340px;

        > * {
            min-width: 0;
        }

        .v-img {
            min-height: 220px;
            background: var(--surface-2) center no-repeat;
            background-size: cover;
        }
    }

    .v-body {
        padding: 22px 24px;
        font-size: 15px;
        line-height: 1.6;

        h4 {
            margin: 0 0 4px;
            font-size: 24px;
            line-height: 1.2;
            color: var(--ink);
        }

        ul {
            margin: 0;
            padding-left: 18px;
        }

        li {
            margin-bottom: 6px;
        }
    }

    .v-meta {
        margin-bottom: 14px;
        font-family: var(--font-mono);
        font-size: 13px;
        color: var(--muted);
    }

    /* Diagram and charts */

    .fig-panel {
        margin: 32px 0;
        padding: 18px 18px 14px;
        border: 1px solid var(--line);
        border-radius: 5px;
        background: var(--surface);

        svg {
            display: block;
            width: 100%;
            height: auto;
        }
    }

    .fig-panel-head {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;
        margin-bottom: 8px;
    }

    .fig-panel-title {
        margin: 0;
        font-size: 17px;
        font-weight: 700;
        line-height: 1.3;
        color: var(--ink);
    }

    .fig-panel-sub {
        margin: 2px 0 0;
        font-size: 14px;
        line-height: 1.5;
        color: var(--muted);
    }

    .seg {
        display: inline-flex;
        padding: 3px;
        border: 1px solid var(--line);
        border-radius: 5px;
        background: var(--bg);

        button {
            padding: 6px 12px;
            border: 0;
            border-radius: 3px;
            background: transparent;
            font-size: 13px;
            font-weight: 700;
            color: var(--ink-2);
            cursor: pointer;

            &[aria-pressed="true"] {
                background: var(--accent);
                color: #fff;
            }
        }
    }

    .legend {
        display: flex;
        flex-wrap: wrap;
        gap: 16px;
        margin: 6px 0 4px;
        font-size: 13px;

        i {
            display: inline-block;
            width: 10px;
            height: 10px;
            margin-right: 6px;
            border-radius: 50%;
        }
    }

    .chart-wrap {
        position: relative;

        svg {
            overflow: visible;
        }
    }

    .tip {
        position: absolute;
        z-index: 5;
        min-width: 180px;
        max-width: 260px;
        padding: 8px 10px;
        border: 1px solid var(--line);
        border-radius: 5px;
        background: var(--bg);
        box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
        font-size: 13px;
        line-height: 1.45;
        opacity: 0;
        pointer-events: none;
        transition: opacity .1s;

        b {
            font-size: 14px;
            color: var(--ink);
        }
    }

    .chart-note {
        margin: 8px 0 0;

        &.prose {
            margin-bottom: 28px;
        }
        font-size: 13px;
        line-height: 1.5;
        color: var(--muted);
    }

    .loop-caption {
        min-height: 3.2em;
        margin: 10px 4px 0;
        font-size: 14px;
        line-height: 1.6;
    }

    details.table-view {
        margin-top: 8px;
        font-size: 13px;

        summary {
            color: var(--muted);
            cursor: pointer;
        }

        table {
            width: 100%;
            margin-top: 8px;
            border-collapse: collapse;
        }

        td,
        th {
            padding: 4px 6px;
            border-bottom: 1px solid var(--line);
            text-align: left;
            font-variant-numeric: tabular-nums;
        }
    }

    /* Timeline */
    /* The timeline itself comes with the timeline plugin, this only gives it the colors of the page */

    .timeline-intro {
        margin: 0 0 8px;
    }

    .timeline {
        --timeline-bg: var(--bg);
        --timeline-surface: var(--surface);
        --timeline-surface-active: var(--surface-2);
        --timeline-text: var(--ink-2);
        --timeline-heading: var(--ink);
        --timeline-muted: var(--muted);
        --timeline-border: var(--line);
        --timeline-accent: var(--accent);
        --timeline-line: linear-gradient(var(--crystite), var(--melding) 55%, var(--accent));
        --timeline-font-mono: var(--font-mono);
        /* The filters stick below the navigation and the chapters */
        --timeline-sticky-top: calc(var(--nav-height) + var(--toc-height));
    }

    /* As wide as the hero and the chapter navigation */
    .timeline-controls {
        margin: 0 -15px;
        padding: 10px 15px;
    }

    /* Sources */

    .history-sources {
        margin-top: 64px;
        padding-top: 32px;
        border-top: 1px solid var(--line);
        font-size: 14px;
        line-height: 1.6;
        color: var(--muted);

        p {
            font-size: inherit;
            line-height: inherit;
        }

        ul {
            padding-left: 18px;
        }
    }

    /* Phones */

    @media (max-width: 767px) {
        .history-hero-inner {
            padding: 40px 15px 32px;
        }

        .v-panel {
            grid-template-columns: minmax(0, 1fr);

            .v-img {
                min-height: 180px;
            }
        }

        .fig-pair {
            grid-template-columns: minmax(0, 1fr);
        }

        .float-right,
        .float-right.float-wide {
            float: none;
            width: 70%;
            margin: 16px auto;
        }

        .frames figcaption {
            font-size: 9px;
            letter-spacing: 0;
        }

        .fig-panel {
            padding: 14px 10px 10px;
        }

        /* Scaled down to the width of a phone the labels of the charts would be unreadable */
        .chart-wrap {
            overflow-x: auto;

            svg {
                min-width: 640px;
            }
        }
    }
}

/* Image viewer */

.history-lightbox {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 2000;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, .9);
    cursor: zoom-out;

    &.open {
        display: flex;
    }

    img {
        max-width: 100%;
        max-height: 84vh;
        border-radius: 5px;
    }

    p {
        max-width: 800px;
        margin: 12px 0 0;
        font-size: 14px;
        line-height: 1.5;
        text-align: center;
        color: var(--color-text);
    }

    a {
        white-space: nowrap;
    }
}

@media (prefers-reduced-motion: no-preference) {
    html:has(.history) {
        scroll-behavior: smooth;
    }
}
