/**
 * Timeline section.
 * Vertical timeline: events alternate left/right of a central spine on desktop and
 * stack to a single left rail on mobile. Cards reuse the home banner portal style
 * (frosted glass, sheen sweep, orange hover glow). The event nearest the viewport
 * gets an "active" state as you scroll. Header type matches the other sections.
 */

.timeline-section {
    /* Shared tokens, scoped like the other sections. */
    --Neutrals-01: #EEEDED;
    --Secondary-100: #F65B1B;
    --Primary-100: #0B0B0B;
    --tl-orange: #F65B1B;
    --tl-pale: #D6E1F1;
    --tl-line: rgba(246, 91, 27, 0.18);
    --tl-ease: cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
    padding: 4rem 1.25rem;
    background: #000;
    color: var(--Neutrals-01);
}

@media (min-width: 768px) {
    .timeline-section {
        padding: 5rem 1.5rem;
    }
}

/* Subtle warm glow anchored to the bottom. */
.timeline-section::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 80% 50% at 50% 100%, rgba(246, 91, 27, 0.06) 0%, transparent 70%);
    pointer-events: none;
}

.timeline-container {
    position: relative;
    z-index: 1;
}

/* ---- Header (type matches directors/about sections) ---- */
.timeline-header {
    text-align: center;
    margin-bottom: 3rem;
}

@media (min-width: 768px) {
    .timeline-header {
        margin-bottom: 4rem;
    }
}

/* Eyebrow – same treatment as the Partners section title (Body/Large | Caps). */
.timeline-eyebrow {
    color: #FFF;
    font-family: "forma-djr-text", sans-serif;
    font-weight: 500;
    font-style: normal;
    font-size: 20px;
    line-height: 140%;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin: 0 0 0.75rem;
}

/* Title – same treatment as other section titles. */
.timeline-title {
    color: var(--Neutrals-01);
    font-family: "forma-djr-text", sans-serif;
    font-size: 56px;
    font-style: normal;
    font-weight: 400;
    line-height: 110%;
    margin: 0;
}

.timeline-title strong {
    font-weight: 500;
    color: var(--Secondary-100);
}

@media (max-width: 767px) {
    .timeline-eyebrow {
        font-size: 16px;
        letter-spacing: 1.5px;
    }
    .timeline-title {
        font-size: clamp(1.75rem, 8vw, 2.5rem);
    }
}

/* ---- Timeline rail ---- */
.timeline {
    position: relative;
    max-width: 1100px;
    margin: 0 auto;
}

/* Central spine (faint base line). */
.timeline-spine {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 1px;
    transform: translateX(-50%);
    background: linear-gradient(to bottom, transparent, var(--tl-line) 8%, var(--tl-line) 92%, transparent);
}

/* Orange fill that grows as the section scrolls (scaleY driven by JS). */
.timeline-spine-fill {
    position: absolute;
    inset: 0;
    transform-origin: top center;
    transform: scaleY(var(--timeline-progress, 0));
    background: linear-gradient(to bottom, transparent, var(--tl-orange) 10%, var(--tl-orange) 90%, transparent);
    box-shadow: 0 0 8px rgba(246, 91, 27, 0.5);
    transition: transform 0.15s linear;
    will-change: transform;
}

/* ---- Individual event ---- */
.timeline-event {
    display: grid;
    grid-template-columns: 1fr 56px 1fr;
    align-items: start;
    margin-bottom: 2.5rem;
    position: relative;
}

@media (min-width: 768px) {
    .timeline-event {
        margin-bottom: 3.25rem;
    }
}

.timeline-event:last-child {
    margin-bottom: 0;
}

/* Pin everything to row 1: the node comes first in the markup, so without an
   explicit row, left cards (column 1) auto-place onto a second row. */
.timeline-event--left .timeline-card {
    grid-column: 1;
    grid-row: 1;
    justify-self: end;
}

.timeline-event--right .timeline-card {
    grid-column: 3;
    grid-row: 1;
    justify-self: start;
}

.timeline-event .timeline-node {
    grid-column: 2;
    grid-row: 1;
}

/* ---- Node (centre dot) ---- */
/* Dot top-aligned (flex-start) with the card's top edge. */
.timeline-node {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 0;
    position: relative;
    z-index: 2;
}

.timeline-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #000;
    border: 2px solid var(--tl-line);
    flex-shrink: 0;
    transition: border-color 0.3s var(--tl-ease), background 0.3s var(--tl-ease), box-shadow 0.3s var(--tl-ease), transform 0.3s var(--tl-ease);
}

/* Active = the event currently in view as you scroll (set by JS). */
.timeline-event.is-active .timeline-dot {
    background: var(--tl-orange);
    border-color: var(--tl-orange);
    box-shadow: 0 0 0 5px rgba(246, 91, 27, 0.2);
    transform: scale(1.1);
}

.timeline-event:hover .timeline-dot {
    border-color: var(--tl-orange);
    box-shadow: 0 0 0 5px rgba(246, 91, 27, 0.14);
}

/* ---- Card: home banner portal style (frosted glass) ---- */
.timeline-card {
    position: relative;
    width: 100%;
    max-width: 420px;
    padding: 1.75rem 2rem;
    border-radius: 20px;
    border: 1px solid rgba(238, 237, 237, 0.16);
    background: rgba(20, 18, 17, 0.34);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    color: var(--Neutrals-01);
    text-align: left;
    overflow: hidden;
    isolation: isolate;
    transition: transform 0.45s var(--tl-ease), border-color 0.35s ease, box-shadow 0.45s var(--tl-ease), background 0.35s ease;
}

/* Dark scrim so the frosted card stays legible over the section glow. */
.timeline-card::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(115deg, rgba(10, 9, 8, 0.55) 0%, rgba(10, 9, 8, 0.22) 60%, rgba(10, 9, 8, 0.4) 100%);
    transition: background 0.45s ease;
}

/* Diagonal sheen that sweeps across the card on hover. */
.timeline-card__sheen {
    position: absolute;
    top: 0;
    left: -60%;
    width: 50%;
    height: 100%;
    z-index: 0;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.14), transparent);
    transform: skewX(-18deg);
    pointer-events: none;
    transition: left 0.7s var(--tl-ease);
}

.timeline-card__body {
    position: relative;
    z-index: 1;
}

.timeline-event:hover .timeline-card,
.timeline-card:focus-within {
    transform: translateY(-6px);
    border-color: rgba(246, 91, 27, 0.65);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(246, 91, 27, 0.25), 0 0 26px rgba(246, 91, 27, 0.22);
}

.timeline-event:hover .timeline-card::before,
.timeline-card:focus-within::before {
    background: linear-gradient(115deg, rgba(10, 9, 8, 0.4) 0%, rgba(10, 9, 8, 0.12) 60%, rgba(10, 9, 8, 0.3) 100%);
}

.timeline-event:hover .timeline-card__sheen {
    left: 120%;
}

/* Active card (scrolled into view) gets a softer version of the hover emphasis. */
.timeline-event.is-active .timeline-card {
    border-color: rgba(246, 91, 27, 0.5);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4), 0 0 18px rgba(246, 91, 27, 0.16);
}

/* Horizontal connector from the card to the spine; sits at the dot's centre. */
.timeline-connector {
    position: absolute;
    top: 8px;
    width: 32px;
    height: 1px;
    z-index: 0;
    background: linear-gradient(90deg, var(--tl-line), transparent);
    pointer-events: none;
}

.timeline-event--left .timeline-connector {
    right: -32px;
    background: linear-gradient(90deg, transparent, var(--tl-line));
}

.timeline-event--right .timeline-connector {
    left: -32px;
}

/* ---- Card content (type scale matches the other sections) ---- */
/* Category + year share one row, pushed to opposite ends. */
.timeline-card__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

/* Category: plain meta label (matches the documents card meta). */
.timeline-tag {
    font-family: "Forma DJR Text", "forma-djr-text", sans-serif;
    font-size: 14px;
    font-weight: 500;
    line-height: 140%;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: var(--Neutrals-01);
}

/* Year: same meta treatment, MagnaTerra orange. */
.timeline-year {
    font-family: "Forma DJR Text", "forma-djr-text", sans-serif;
    font-size: 14px;
    font-weight: 500;
    line-height: 140%;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: var(--Secondary-100);
}

/* Event title – card heading scale (matches documents/directors cards). */
.timeline-event-title {
    font-family: "forma-djr-text", sans-serif;
    font-size: 24px;
    font-weight: 400;
    line-height: 120%;
    color: var(--Neutrals-01);
    margin: 0 0 0.6rem;
}

/* Event description – body scale & colour matching the other section descriptions. */
.timeline-event-body {
    font-family: "Forma DJR Text", "forma-djr-text", sans-serif;
    font-size: 16px;
    font-weight: 400;
    line-height: 140%;
    letter-spacing: 0.4px;
    color: var(--Neutrals-01);
    margin: 0;
}

@media (min-width: 768px) {
    .timeline-card__meta {
        margin-bottom: 1.25rem;
    }
    .timeline-tag,
    .timeline-year {
        font-size: 16px;
    }
}

/* ---- Scroll-reveal ---- */
.timeline-event {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s var(--tl-ease), transform 0.6s var(--tl-ease);
    transition-delay: calc(min(var(--ti-index, 0), 6) * 60ms);
}

.timeline-event.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ---- Tablet / mobile: single left rail, all cards full-width ---- */
@media (max-width: 768px) {
    .timeline-spine {
        left: 20px;
        transform: none;
    }

    .timeline-event {
        grid-template-columns: 40px 1fr;
    }

    .timeline-event--left .timeline-card,
    .timeline-event--right .timeline-card {
        grid-column: 2;
        justify-self: stretch;
        max-width: 100%;
    }

    .timeline-event--left .timeline-node,
    .timeline-event--right .timeline-node {
        grid-column: 1;
        justify-content: center;
    }

    /* Connector always points left toward the rail. */
    .timeline-event--left .timeline-connector,
    .timeline-event--right .timeline-connector {
        left: -20px;
        right: auto;
        width: 20px;
        background: linear-gradient(90deg, transparent, var(--tl-line));
    }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
    .timeline-event {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .timeline-card,
    .timeline-card__sheen,
    .timeline-dot,
    .timeline-spine-fill {
        transition: none;
    }

    .timeline-event:hover .timeline-card,
    .timeline-card:focus-within {
        transform: none;
    }
}
