/* ===================== 
    Hero                 
   ===================== */

.hero-artwork {
    background-image: url("../imgs/heroes/hero-timeline.webp");
    background-position: center 8%;
}

@media (min-width: 1536px) {
    .hero-text h1 {
        max-width: 530px;
    }

    .hero-text p {
        max-width: 510px;
    }
}

/* =====================
    Page Layout
   ===================== */

.page-content {
    padding-right: 0;
    overflow: hidden;
}

.page-slot {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

/* The second column starts at 0px (rather than the drawer being absolutely
   positioned over the content) so opening it animates the timeline column
   narrowing via the grid-template-columns transition, instead of the drawer
   just appearing on top. */
.timeline-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 0px;
    gap: 48px;
    align-items: start;
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: var(--page-padding);
    transition: grid-template-columns 0.3s ease;
}

/* Set when the source drawer opens; widens the second grid column to make
   room for it. */
.timeline-layout.drawer-open {
    grid-template-columns: minmax(0, 1fr) min(520px, 42%);
}

/* =====================
    Year Navigation
   ===================== */

.timeline-years {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 24px 48px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
}

.timeline-years::-webkit-scrollbar {
    display: none;
}

.timeline-navigation {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 20px;
    z-index: 10;
    flex: 0 0 auto;
    max-width: 720px;
    margin: 0 auto;
    background: var(--background);
}

.timeline-years-viewport {
    position: relative;
    overflow: hidden;
    flex: 1 1 auto;
    min-width: 0;
}

.timeline-years-viewport::before,
.timeline-years-viewport::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 48px;
    width: 32px;
    pointer-events: none;
    z-index: 2;
    opacity: 1;
    transition: opacity .2s ease;
}

.timeline-years-viewport::before {
    left: 0;
    background:
        linear-gradient(
            to right,
            var(--background),
            transparent
        );
}

.timeline-years-viewport::after {
    right: 0;
    background:
        linear-gradient(
            to left,
            var(--background),
            transparent
        );
}

/* .at-start/.at-end are toggled by initYearScrollFade based on scroll
   position, hiding the fade gradient at whichever edge there's nothing left
   to scroll toward. */
.timeline-years-viewport.at-start::before {
    opacity: 0;
}

.timeline-years-viewport.at-end::after {
    opacity: 0;
}

.year-link {
    flex: 0 0 72px;
    border: none;
    background: transparent;
    font-family: "Alegreya Sans", sans-serif;
    font-size: 18px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    text-align: center;
    transition:
        color .2s ease,
        background .2s ease;
}

.year-link:hover {
    color: var(--text);
}

/* Marks the year currently filtering the entry list, set by selectYear. */
.year-link.active {
    background: var(--accent);
    color: white;
    padding: 5px 0;
    border-radius: 999px;
}

.year-arrow {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    margin-top: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    transition:
        color .2s ease,
        background .2s ease,
        opacity .2s ease;
}

.year-arrow svg {
    width: 16px;
    height: 16px;
}

.year-arrow:hover:not(:disabled) {
    color: var(--text);
    background: rgba(0, 0, 0, 0.05);
}

/* Disabled by updateArrowState at either end of the year range, since there's
   no adjacent year left to step to. */
.year-arrow:disabled {
    opacity: 0.25;
    cursor: default;
}

.year-separator {
    width: 7px;
    height: 7px;
    background: #CFC9C2;

    clip-path: polygon(
        25% 0%,
        75% 0%,
        100% 50%,
        75% 100%,
        25% 100%,
        0% 50%
    );

    flex-shrink: 0;
}

/* =====================
    Timeline
   ===================== */

.timeline {
    position: relative;
    max-width: 1200px;
    margin: 0;
    padding-left: 0;
}

.timeline-spine {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 69px;
    width: 2px;
    background: #E4E0DA;
}

#timeline-entries {
    display: block;
}

.timeline-entry {
    margin-bottom: 60px;
    position: relative;
}

.timeline-entry-header {
    display: grid;
    grid-template-columns: 36px 56px 1fr;
    column-gap: 12px;
    align-items: center;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.timeline-entry-header:hover {
    opacity: 0.7;
}

.timeline-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1;
    text-align: center;
    width: 36px;
}

.timeline-date .month {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text);
}

.timeline-date .day {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
}

.timeline-node {
    width: 44px;
    height: 50px;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
}

.timeline-node svg {
    width: 18px;
    height: 18px;
    color: white;
    stroke-width: 2;
}

.timeline-content {
    padding-top: 6px;
}

.timeline-content h2 {
    margin: 0;
    font-family: "Newsreader", serif;
    font-size: 1.3rem;
    font-weight: 500;
    line-height: 1.3;
}

.timeline-content p {
    margin-top: 8px;
    font-size: 1rem;
    color: var(--text-muted);
}

/* =====================
    Expandable
   ===================== */

/* Same 0fr/1fr grid-template-rows collapse trick used by .detail-collapse in
   style-common.css: lets the entry's expanded content animate open/closed
   without knowing its height up front. Collapsed by default; entries start
   with the "expanded" class in the rendered markup (see renderEntries). */
.timeline-entry-expanded {
    display: grid;
    grid-template-rows: 0fr;
    margin-left: 130px;
    opacity: 0;
    transition: grid-template-rows 0.3s ease, opacity 0.25s ease, margin-bottom 0.3s ease;
}

/* .expanded is toggled by attachEntryEvents when a timeline-entry-header is clicked. */
.timeline-entry.expanded .timeline-entry-expanded {
    grid-template-rows: 1fr;
    opacity: 1;
    margin-bottom: 60px;
}

.timeline-entry-expanded-inner {
    overflow: hidden;
    min-height: 0;
    padding: 24px 0;
}

/* --divider-width is computed and kept in sync by initDividerWidth so this
   divider stays the width it would be with the drawer open, even while closed. */
.timeline-entry-expanded-inner::before {
    content: "";
    display: block;
    width: var(--divider-width, 50%);
    height: 1px;
    background: var(--border-color);
    margin-bottom: 24px;
}

.timeline-entry-card {
    display: grid;
    grid-template-columns: 1fr;
    gap: 32px;
    width: 100%;
}

.artifact-info {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.artifact-media-type {
    display: inline-block;
    padding: 0;
    margin-bottom: 12px;
    color: var(--accent);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.artifact-title {
    font-family: "Newsreader", serif;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.2;
    margin-bottom: 8px;
}

.artifact-metadata {
    margin-top: 0;
    color: var(--text-subtle);
    font-size: 0.95rem;
    line-height: 1.8;
}

/* =====================
    Drawer
   ===================== */

/* --drawer-top is set inline by openDrawer to align the drawer with the
   entry it was opened from. */
.timeline-drawer {
    position: absolute;
    top: var(--drawer-top, 0);
    right: 25px;
    width: min(420px, 42%);
    max-height: calc(100vh - var(--page-padding));
    overflow-y: auto;
    padding-left: 32px;
    border-left: 1px solid var(--border-color);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Set by openDrawer only when the drawer's content overflows its max-height,
   so scrolling inside it doesn't also scroll-chain into the page behind it. */
.timeline-drawer.scrollable {
    overscroll-behavior: contain;
}

/* Deliberately overrides the site-wide .hidden (display:none) utility with a
   fade+slide-out instead, so closing the drawer animates rather than snapping away. */
.timeline-drawer.hidden {
    display: block;
    opacity: 0;
    transform: translateX(24px);
    pointer-events: none;
}

.drawer-cover {
    text-align: left;
    margin-bottom: 14px;
}

.drawer-cover-trigger {
    display: block;
    background: none;
    border: none;
    padding: 0;
    cursor: zoom-in;
}

.drawer-cover img {
    display: block;
    width: min(240px, 100%);
    margin: 0;
}

.drawer-cover-caption {
    margin-top: 12px;
    font-size: 11px;
    letter-spacing: 0.05em;
    color: var(--text-faint);
}

.drawer-section h3 {
    margin: 0 0 16px 0;
}
