:root {
    --parchment: #f2efe9;
    --carbon-black: #252627;
    --dusty-denim: #778da9;
    --palm-leaf: #8c9575;
    --dusty-rose: #ce796b;
    --paper: var(--parchment);
    --ink: var(--carbon-black);
    --contact: var(--palm-leaf);
    --line: rgba(37, 38, 39, 0.14);
    --gutter: clamp(1.2rem, 5vw, 3.5rem);
    --font-display: "Libre Bodoni", "Bodoni MT", "Didot", Georgia, serif;
    --font-ui: "Inter", ui-sans-serif, system-ui, sans-serif;
    --paper-grain: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.72' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    scroll-behavior: smooth;
}

body {
    min-height: 100%;
    margin: 0;
    color: var(--ink);
    background: var(--paper);
    font-family: var(--font-ui);
    text-transform: lowercase;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.35;
    background:
        linear-gradient(108deg, transparent 46%, rgba(30, 26, 22, 0.045) 49.5%, rgba(30, 26, 22, 0.07) 50.5%, transparent 54%),
        radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.35), transparent 28rem),
        radial-gradient(circle at 82% 88%, rgba(140, 149, 117, 0.18), transparent 26rem);
}

.paper-texture {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 50;
    opacity: 0.42;
    mix-blend-mode: multiply;
    background-image:
        var(--paper-grain),
        linear-gradient(90deg, rgba(255, 255, 255, 0.18) 1px, transparent 1px),
        linear-gradient(rgba(44, 35, 26, 0.05) 1px, transparent 1px);
    background-size: 220px 220px, 68px 68px, 68px 68px;
}

.paper-texture::after {
    content: "";
    position: absolute;
    inset: 0;
    opacity: 0.18;
    background: repeating-linear-gradient(3deg, rgba(70, 55, 40, 0.12) 0 1px, transparent 1px 5px);
}

.timeline-page {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: clamp(1.8rem, 4vh, 2.8rem) 0 clamp(1.5rem, 3vh, 2.2rem);
}

.timeline-header {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    padding: 0 var(--gutter);
    margin-bottom: clamp(1.6rem, 3.5vh, 2.4rem);
}

.back-link {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    color: rgba(37, 38, 39, 0.48);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-decoration: none;
    transition: color 140ms ease, transform 160ms ease;
}

.back-link:hover {
    color: rgba(37, 38, 39, 0.78);
    transform: translateX(-2px);
}

.back-link:focus-visible {
    outline: 1px solid rgba(37, 38, 39, 0.36);
    outline-offset: 3px;
}

.timeline-header__copy {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.75rem 1.75rem;
}

.timeline-header h1 {
    margin: 0;
    color: rgba(37, 38, 39, 0.92);
    font-family: var(--font-display);
    font-size: clamp(2.6rem, 5.5vw, 3.8rem);
    font-weight: 400;
    line-height: 1;
    letter-spacing: -0.02em;
    text-transform: none;
}

.timeline-header p {
    max-width: 34rem;
    margin: 0;
    color: rgba(37, 38, 39, 0.52);
    font-size: clamp(0.95rem, 1.2vw, 1.08rem);
    line-height: 1.5;
}

.timeline-layout {
    display: grid;
    grid-template-columns: minmax(17rem, 22rem) minmax(0, 1fr);
    gap: clamp(1.5rem, 3vw, 2.5rem);
    align-items: stretch;
    flex: 1;
    min-height: 0;
    padding-left: var(--gutter);
}

.section-label {
    margin: 0 0 1rem;
    color: rgba(37, 38, 39, 0.48);
    font-size: clamp(0.84rem, 1.05vw, 0.95rem);
    font-weight: 600;
    letter-spacing: 0.05em;
}

/* ── Form (left) ── */
.timeline-form-section {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: clamp(1.35rem, 2.4vw, 1.75rem);
    border: 1px solid rgba(37, 38, 39, 0.12);
    border-radius: 4px;
    background: var(--contact);
    color: rgba(37, 38, 39, 0.78);
}

.timeline-form-section .section-label {
    color: rgba(37, 38, 39, 0.55);
}

#timeline-form {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    color: rgba(37, 38, 39, 0.55);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.72rem 0.85rem;
    border: 1px solid rgba(37, 38, 39, 0.16);
    border-radius: 4px;
    color: var(--ink);
    background: rgba(242, 239, 233, 0.72);
    font: inherit;
    font-size: 0.95rem;
    transition: border-color 160ms ease, background-color 160ms ease;
}

.form-group input:hover,
.form-group textarea:hover {
    border-color: rgba(37, 38, 39, 0.28);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: rgba(37, 38, 39, 0.42);
    background: rgba(255, 255, 255, 0.55);
}

.form-group textarea {
    resize: vertical;
    min-height: 7.5rem;
    line-height: 1.5;
}

#timeline-form button {
    align-self: flex-start;
    margin-top: auto;
    padding: 0.72rem 1.25rem;
    border: 1px solid rgba(37, 38, 39, 0.18);
    border-radius: 4px;
    color: rgba(37, 38, 39, 0.92);
    background: rgba(255, 255, 255, 0.22);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition:
        background-color 160ms ease,
        border-color 160ms ease,
        color 160ms ease,
        transform 160ms ease;
}

#timeline-form button:hover {
    color: rgba(37, 38, 39, 1);
    background: rgba(255, 255, 255, 0.38);
    border-color: rgba(37, 38, 39, 0.28);
    transform: translateY(-1px);
}

#timeline-form button:focus-visible {
    outline: 1px solid rgba(37, 38, 39, 0.36);
    outline-offset: 3px;
}

#form-message {
    min-height: 1.3rem;
    margin: 0.85rem 0 0;
    color: rgba(37, 38, 39, 0.58);
    font-size: 0.86rem;
}

/* ── Horizontal timeline (center–right) ── */
.timeline-rail-section {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    padding-right: 0;
}

.timeline-rail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-right: var(--gutter);
    margin-bottom: 0.35rem;
}

.timeline-rail-header .section-label {
    margin: 0;
}

.timeline-nav {
    display: flex;
    gap: 0.45rem;
}

.timeline-nav__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.35rem;
    height: 2.35rem;
    border: 1px solid rgba(37, 38, 39, 0.16);
    border-radius: 4px;
    color: rgba(37, 38, 39, 0.78);
    background: rgba(140, 149, 117, 0.22);
    font-size: 1rem;
    cursor: pointer;
    transition:
        background-color 160ms ease,
        border-color 160ms ease,
        color 160ms ease,
        transform 160ms ease;
}

.timeline-nav__btn:hover:not(:disabled) {
    color: rgba(37, 38, 39, 1);
    background: rgba(140, 149, 117, 0.4);
    border-color: rgba(37, 38, 39, 0.28);
    transform: translateY(-1px);
}

.timeline-nav__btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.timeline-nav__btn:focus-visible {
    outline: 1px solid rgba(37, 38, 39, 0.36);
    outline-offset: 3px;
}

.timeline-rail {
    position: relative;
    flex: 1;
    min-height: 22rem;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    cursor: grab;
    outline: none;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(140, 149, 117, 0.55) transparent;
}

.timeline-rail.is-dragging {
    cursor: grabbing;
    scroll-behavior: auto;
    user-select: none;
}

.timeline-rail:focus-visible {
    box-shadow: inset 0 0 0 1px rgba(37, 38, 39, 0.22);
}

.timeline-rail::-webkit-scrollbar {
    height: 6px;
}

.timeline-rail::-webkit-scrollbar-track {
    background: transparent;
}

.timeline-rail::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(140, 149, 117, 0.55);
}

.timeline-track {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: 1.75rem;
    min-width: 100%;
    min-height: 100%;
    width: max-content;
    padding: 1.25rem var(--gutter) 2.4rem 0.35rem;
}

.timeline-track::before {
    content: "";
    position: absolute;
    left: 0.35rem;
    right: var(--gutter);
    top: 50%;
    height: 2px;
    transform: translateY(-50%);
    background: linear-gradient(
        90deg,
        rgba(140, 149, 117, 0.15),
        rgba(140, 149, 117, 0.7) 12%,
        rgba(140, 149, 117, 0.7) 88%,
        rgba(140, 149, 117, 0.1)
    );
    pointer-events: none;
}

.timeline-track.is-empty::before,
.timeline-track.is-status::before {
    display: none;
}

.timeline-status {
    display: flex;
    align-items: center;
    margin: 0;
    padding: 2rem 0;
    color: rgba(37, 38, 39, 0.48);
    font-size: 0.95rem;
}

.timeline-node {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-rows: 1fr auto 1fr;
    flex: 0 0 auto;
    width: min(17.5rem, 72vw);
    min-height: 22rem;
    scroll-snap-align: start;
}

.timeline-node__marker {
    grid-row: 2;
    justify-self: start;
    margin-left: 1.15rem;
    width: 0.85rem;
    height: 0.85rem;
    border: 2px solid rgba(37, 38, 39, 0.55);
    border-radius: 50%;
    background: var(--contact);
    box-shadow: 0 0 0 4px rgba(242, 239, 233, 0.95);
    transition: transform 180ms ease, background-color 180ms ease, border-color 180ms ease;
}

.timeline-node:hover .timeline-node__marker,
.timeline-node:focus-within .timeline-node__marker {
    background: rgba(37, 38, 39, 0.82);
    border-color: rgba(37, 38, 39, 0.82);
    transform: scale(1.12);
}

.timeline-node__body {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    align-self: end;
    width: 100%;
    min-height: 0;
    max-height: 100%;
    margin-bottom: 0.85rem;
    padding: 1.1rem 1.15rem 1.2rem;
    border: 1px solid rgba(37, 38, 39, 0.12);
    border-radius: 4px;
    background: rgba(140, 149, 117, 0.22);
    transition:
        background-color 180ms ease,
        border-color 180ms ease,
        transform 180ms ease;
}

.timeline-node:nth-child(odd) .timeline-node__body {
    grid-row: 1;
    align-self: end;
    margin-bottom: 0.85rem;
    margin-top: 0;
}

.timeline-node:nth-child(even) .timeline-node__body {
    grid-row: 3;
    align-self: start;
    margin-top: 0.85rem;
    margin-bottom: 0;
}

.timeline-node:hover .timeline-node__body,
.timeline-node:focus-within .timeline-node__body {
    background: rgba(140, 149, 117, 0.36);
    border-color: rgba(37, 38, 39, 0.22);
    transform: translateY(-2px);
}

.timeline-node__date {
    margin: 0;
    color: rgba(37, 38, 39, 0.48);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.timeline-node__body h3 {
    margin: 0;
    color: rgba(37, 38, 39, 0.92);
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 400;
    letter-spacing: -0.01em;
    text-transform: none;
}

.post-email {
    margin: 0;
    color: rgba(37, 38, 39, 0.45);
    font-size: 0.74rem;
    font-weight: 500;
}

.post-content {
    margin: 0.45rem 0 0;
    color: rgba(37, 38, 39, 0.78);
    font-size: 0.92rem;
    line-height: 1.5;
    white-space: pre-wrap;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.timeline-hint {
    margin: 0.75rem 0 0;
    padding-right: var(--gutter);
    color: rgba(37, 38, 39, 0.38);
    font-size: 0.76rem;
    font-weight: 500;
    letter-spacing: 0.03em;
}

@media (max-width: 900px) {
    .timeline-layout {
        grid-template-columns: 1fr;
        gap: 1.75rem;
        padding-right: var(--gutter);
    }

    .timeline-form-section {
        max-width: 28rem;
    }

    .timeline-rail {
        min-height: 20rem;
        margin-right: calc(-1 * var(--gutter));
        padding-right: 0;
    }

    .timeline-rail-header,
    .timeline-hint {
        padding-right: 0;
    }

    .timeline-track {
        padding-right: var(--gutter);
    }

    .timeline-node:nth-child(even) .timeline-node__body {
        grid-row: 1;
        align-self: end;
        margin-bottom: 0.85rem;
        margin-top: 0;
    }
}

@media (max-width: 560px) {
    .timeline-header h1 {
        font-size: clamp(2.3rem, 12vw, 3rem);
    }

    .timeline-header__copy {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.55rem;
    }

    #timeline-form button {
        width: 100%;
    }

    .timeline-node {
        width: min(15.5rem, 78vw);
    }

    .timeline-node__body {
        min-height: 9.5rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        scroll-behavior: auto !important;
        transition-duration: 0.001ms !important;
    }

    .timeline-rail {
        scroll-behavior: auto;
    }
}
