/* === Custom Properties === */
:root {
    --bg-primary: #f8f3eb;
    --text-primary: #2d261c;
    --text-body: #5c5445;
    --brass: #c4a165;
    --moss: #7a9e7e;
    --rust: #b87333;
    --sky: #a8c4d4;
    --glow: #e8d5a3;
    --muted-brass: #a89272;
    --border-gold: rgba(196, 161, 101, 0.3);
    --card-bg: rgba(248, 243, 235, 0.55);
}

/* === Reset & Base === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.8vw, 1.1rem);
    line-height: 1.65;
    letter-spacing: 0.01em;
    color: var(--text-body);
    background-color: var(--bg-primary);
    overflow-x: hidden;
}

/* === Grid Background === */
#grid-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        repeating-linear-gradient(0deg, rgba(196,161,101,0.06) 0 1px, transparent 1px 48px),
        repeating-linear-gradient(90deg, rgba(196,161,101,0.06) 0 1px, transparent 1px 48px),
        repeating-linear-gradient(0deg, rgba(196,161,101,0.08) 0 1px, transparent 1px 192px),
        repeating-linear-gradient(90deg, rgba(196,161,101,0.08) 0 1px, transparent 1px 192px);
}

/* === Content Wrapper === */
#content-wrap {
    position: relative;
    z-index: 1;
    max-width: 860px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* === Hero / Header === */
#hero {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#spine-svg {
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    width: 10px;
    height: 100%;
    z-index: 0;
    overflow: visible;
}

#spine-path {
    stroke-dasharray: 2200;
    stroke-dashoffset: 2200;
    transition: stroke-dashoffset 0.05s linear;
}

#site-title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: clamp(2.5rem, 6vw, 4rem);
    color: var(--text-primary);
    letter-spacing: 0.02em;
    opacity: 0;
    transition: opacity 0.8s ease;
    z-index: 1;
}

#site-title.visible {
    opacity: 1;
}

#site-subtitle {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 400;
    font-size: 1.1rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted-brass);
    margin-top: 0.5rem;
    z-index: 1;
    overflow: hidden;
}

#site-subtitle span {
    display: inline-block;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#site-subtitle span.visible {
    opacity: 1;
    transform: translateY(0);
}

/* === Timeline === */
#timeline {
    position: relative;
    padding: 4rem 0;
}

/* Central spine line using CSS for the timeline area */
#timeline::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--brass);
    opacity: 0.3;
    transform: translateX(-50%);
}

/* === Timeline Entries === */
.timeline-entry {
    position: relative;
    display: flex;
    margin-bottom: 3rem;
    align-items: flex-start;
}

.timeline-entry.left {
    justify-content: flex-start;
    padding-right: calc(50% + 40px);
}

.timeline-entry.right {
    justify-content: flex-end;
    padding-left: calc(50% + 40px);
}

/* Branch lines */
.branch-line {
    position: absolute;
    top: 2rem;
    height: 2px;
    background: var(--brass);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.timeline-entry.left .branch-line {
    right: calc(50% - 40px);
    width: 40px;
    transform-origin: right center;
}

.timeline-entry.right .branch-line {
    left: calc(50% - 40px);
    width: 40px;
    transform-origin: left center;
}

.timeline-entry.in-view .branch-line {
    opacity: 0.6;
}

/* === Glass Cards === */
.glass-card {
    backdrop-filter: blur(12px) saturate(120%);
    -webkit-backdrop-filter: blur(12px) saturate(120%);
    background: var(--card-bg);
    border: 1px solid var(--border-gold);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(45, 38, 28, 0.08);
    max-width: 380px;
    width: 100%;
    opacity: 0;
    transform: translateX(-30px);
    transition: opacity 0.6s ease, transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94), backdrop-filter 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}

.timeline-entry.right .glass-card {
    transform: translateX(30px);
}

.timeline-entry.in-view .glass-card {
    opacity: 1;
    transform: translateX(0);
}

.glass-card:hover {
    backdrop-filter: blur(16px) saturate(130%);
    -webkit-backdrop-filter: blur(16px) saturate(130%);
    border-color: rgba(196, 161, 101, 0.5);
    box-shadow: 0 8px 32px rgba(45, 38, 28, 0.08), inset 0 0 30px rgba(232, 213, 163, 0.1);
}

/* Card floating animation */
@keyframes card-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
}

.timeline-entry.in-view .glass-card:hover {
    animation: card-float 2s ease-in-out infinite;
}

/* === Card Content === */
.card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.date-stamp {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted-brass);
}

.glass-card h2 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    color: var(--text-primary);
    letter-spacing: 0.02em;
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.glass-card p {
    color: var(--text-body);
    margin-bottom: 0.75rem;
}

/* Inline sketches */
.inline-sketch {
    display: block;
    margin: 0.5rem auto;
}

/* Schematic drawings */
.schematic-drawing {
    display: block;
    margin: 0.75rem 0;
}

.schematic-drawing .annotation,
.interlude-illustration .annotation {
    font-family: 'Courier Prime', monospace;
    font-size: 10px;
    fill: #7a6f60;
}

/* Vine containers */
.vine-container {
    margin-top: 0.5rem;
}

.vine {
    width: 80px;
    height: 40px;
    overflow: visible;
}

.vine-path {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 1.5s ease 0.4s;
}

.timeline-entry.in-view .vine-path {
    stroke-dashoffset: 0;
}

/* Vine bud pulse */
@keyframes bud-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

.vine-bud {
    transform-origin: center;
    animation: bud-pulse 4s ease-in-out infinite;
    opacity: 0;
    transition: opacity 0.5s ease 1.5s;
}

.timeline-entry.in-view .vine-bud {
    opacity: 1;
}

/* === Interludes === */
.interlude {
    position: relative;
    padding: 4rem 0;
    margin: 2rem 0;
}

.interlude-illustration {
    display: block;
    margin: 0 auto;
    max-width: 600px;
}

/* Path draw for interlude illustrations */
.draw-path {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 2s ease;
}

.interlude.in-view .draw-path {
    stroke-dashoffset: 0;
}

/* Grid visibility shift in interludes */
.interlude.in-view ~ #grid-bg {
    opacity: 1;
}

/* === Final Entry === */
.card-final {
    text-align: center;
    max-width: 420px;
}

.final-message {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(1.3rem, 3vw, 1.8rem);
    color: var(--text-primary);
    letter-spacing: 0.02em;
}

/* === Terminal Gear === */
#terminal-gear {
    display: flex;
    justify-content: center;
    padding: 2rem 0 1rem;
}

#terminal-gear svg {
    opacity: 0;
    transition: opacity 0.6s ease;
}

#terminal-gear.in-view svg {
    opacity: 1;
    animation: gear-spin-stop 3s ease-out forwards;
}

@keyframes gear-spin-stop {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* === Footer === */
#site-footer {
    text-align: center;
    padding: 2rem 0 3rem;
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--muted-brass);
    letter-spacing: 0.08em;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

/* === Background Gears === */
.bg-gear {
    position: fixed;
    z-index: 0;
    pointer-events: none;
}

#bg-gear-1 {
    top: 15%;
    right: 8%;
    animation: gear-rotate 30s linear infinite;
}

#bg-gear-2 {
    top: 55%;
    left: 5%;
    animation: gear-rotate 45s linear infinite reverse;
}

#bg-gear-3 {
    top: 78%;
    right: 15%;
    animation: gear-rotate 36s linear infinite;
}

@keyframes gear-rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
    .bg-gear,
    .vine-bud {
        animation: none;
    }
    .glass-card:hover {
        animation: none;
    }
    #terminal-gear.in-view svg {
        animation: none;
        transform: rotate(360deg);
    }
    .draw-path {
        stroke-dashoffset: 0;
    }
    .vine-path {
        stroke-dashoffset: 0;
    }
    #spine-path {
        stroke-dashoffset: 0;
    }
    .glass-card,
    .timeline-entry.in-view .glass-card {
        opacity: 1;
        transform: none;
        transition: none;
    }
    .branch-line {
        opacity: 0.6;
        transition: none;
    }
    #site-title {
        opacity: 1;
        transition: none;
    }
    #site-subtitle span {
        opacity: 1;
        transform: none;
        transition: none;
    }
}

/* === Mobile === */
@media (max-width: 768px) {
    #content-wrap {
        padding: 0 1rem;
    }

    #timeline::before {
        left: 1rem;
    }

    .timeline-entry.left,
    .timeline-entry.right {
        padding-left: 3rem;
        padding-right: 0;
        justify-content: flex-start;
    }

    .timeline-entry.left .branch-line,
    .timeline-entry.right .branch-line {
        left: 1rem;
        right: auto;
        width: 2rem;
    }

    .glass-card {
        max-width: 100%;
        transform: translateX(20px);
    }

    .timeline-entry.right .glass-card {
        transform: translateX(20px);
    }

    .timeline-entry.in-view .glass-card {
        transform: translateX(0);
    }

    .final-entry {
        padding-left: 3rem;
        padding-right: 0;
    }
}
