/* ============================================
   a6c.xyz — Swiss-Inflected Botanical Chronicle
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --deep-emerald: #1a5c3a;
    --amethyst: #7b2d8e;
    --ruby: #9e2a2b;
    --sapphire: #1e3a5f;
    --topaz: #c8961e;
    --cream: #f7f3eb;
    --deep-moss: #2d4a3e;
    --sage: #b8c4b0;
    --grid-line: #e8e3d8;
    --muted-sage: #6b7a6e;

    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Libre Baskerville', serif;
    --font-mono: 'IBM Plex Mono', monospace;

    --scroll-y: 0;
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background-color: var(--cream);
    color: var(--deep-moss);
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.72;
    letter-spacing: 0.01em;
    overflow-x: hidden;
}

/* --- Background Grid Layer (z:0) --- */
.bg-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.3;
    background-image:
        repeating-linear-gradient(
            to right,
            var(--grid-line) 0px,
            var(--grid-line) 1px,
            transparent 1px,
            transparent calc(100% / 12)
        ),
        repeating-linear-gradient(
            to bottom,
            var(--grid-line) 0px,
            var(--grid-line) 1px,
            transparent 1px,
            transparent 80px
        );
}

/* --- Floating Botanical Fragments (z:2) --- */
.floating-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    pointer-events: none;
    overflow: hidden;
}

.float-fragment {
    position: absolute;
    will-change: transform;
    transition: none;
}

.frag-1 {
    top: 15%;
    left: 8%;
}

.frag-2 {
    top: 35%;
    right: 12%;
}

.frag-3 {
    top: 55%;
    left: 5%;
}

.frag-4 {
    top: 72%;
    right: 8%;
}

.frag-5 {
    top: 88%;
    left: 15%;
}

/* --- Hero Section --- */
.hero {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1;
    overflow: hidden;
}

.hero-illustration {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60vmin;
    height: 60vmin;
    max-width: 600px;
    max-height: 600px;
    z-index: 0;
    opacity: 0.35;
}

.fern-svg {
    width: 100%;
    height: 100%;
}

.fern-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: drawFern 2s ease-in-out forwards;
}

.fern-stem { animation-delay: 0s; }
.fern-frond-l1 { animation-delay: 0.3s; }
.fern-frond-r1 { animation-delay: 0.4s; }
.fern-frond-l2 { animation-delay: 0.5s; }
.fern-frond-r2 { animation-delay: 0.6s; }
.fern-frond-l3 { animation-delay: 0.7s; }
.fern-frond-r3 { animation-delay: 0.8s; }
.fern-frond-l4 { animation-delay: 0.9s; }
.fern-frond-r4 { animation-delay: 1.0s; }
.fern-frond-l5 { animation-delay: 1.1s; }
.fern-frond-r5 { animation-delay: 1.2s; }
.fern-tip { animation-delay: 1.3s; }
.fern-leaflet { animation-delay: 1.5s; stroke-dasharray: 200; stroke-dashoffset: 200; }

@keyframes drawFern {
    to {
        stroke-dashoffset: 0;
    }
}

.hero-content {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 0 20px;
}

.hero-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(3rem, 8vw, 7rem);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--deep-moss);
    min-height: 1.2em;
    display: inline-block;
    position: relative;
}

.hero-title .cursor {
    display: inline-block;
    width: 3px;
    height: 0.85em;
    background-color: var(--deep-emerald);
    margin-left: 4px;
    vertical-align: baseline;
    animation: cursorBlink 530ms step-end infinite;
}

.hero-title .cursor.fade-amethyst {
    background-color: var(--amethyst);
    animation: cursorFade 1s ease-out forwards;
}

@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

@keyframes cursorFade {
    0% { opacity: 1; background-color: var(--amethyst); }
    50% { opacity: 1; background-color: var(--amethyst); }
    100% { opacity: 0; }
}

.hero-subtitle {
    font-family: var(--font-body);
    font-style: italic;
    font-size: clamp(1rem, 2vw, 1.35rem);
    color: var(--muted-sage);
    margin-top: 1.5rem;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.hero-subtitle.visible {
    opacity: 1;
    transform: translateY(0);
}

.scroll-indicator {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    opacity: 0;
    animation: fadeInScroll 1s ease-out 3.5s forwards;
}

.scroll-label {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--muted-sage);
}

@keyframes fadeInScroll {
    to { opacity: 1; }
}

.scroll-indicator svg {
    animation: scrollBounce 2s ease-in-out infinite;
}

@keyframes scrollBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(6px); }
}

/* --- Timeline Container --- */
.timeline-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    padding-bottom: 120px;
}

/* --- Timeline Spine --- */
.timeline-spine {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: var(--sage);
    transform: translateX(-50%);
    z-index: 0;
}

.timeline-progress {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background-color: var(--deep-emerald);
    transition: height 0.1s linear;
}

/* --- Timeline Node --- */
.timeline-node {
    position: relative;
    padding: 60px 0;
    min-height: 80vh;
    display: flex;
    align-items: flex-start;
}

.timeline-node:first-child {
    padding-top: 120px;
}

/* --- Rosette --- */
.rosette-container {
    position: absolute;
    left: 50%;
    top: 80px;
    transform: translateX(-50%) scale(0);
    width: 32px;
    height: 32px;
    z-index: 5;
    cursor: pointer;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.rosette-container.visible {
    transform: translateX(-50%) scale(1) rotate(360deg);
}

.rosette-container:hover {
    animation: rosettePulse 0.4s ease-in-out;
}

@keyframes rosettePulse {
    0% { transform: translateX(-50%) scale(1) rotate(360deg); }
    50% { transform: translateX(-50%) scale(1.15) rotate(360deg); }
    100% { transform: translateX(-50%) scale(1) rotate(360deg); }
}

.rosette {
    width: 32px;
    height: 32px;
}

.rosette-tooltip {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--deep-moss);
    background: var(--cream);
    padding: 2px 8px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    border: 1px solid var(--sage);
}

.rosette-container:hover .rosette-tooltip {
    opacity: 1;
}

/* --- Branch Line --- */
.branch-line {
    position: absolute;
    top: 96px;
    height: 2px;
    background-color: var(--sage);
    z-index: 1;
    transform: scaleX(0);
    transition: transform 0.3s ease-out 0.3s;
}

.node-right .branch-line {
    left: calc(50% + 16px);
    width: calc(4% - 16px);
    transform-origin: left;
}

.node-left .branch-line {
    right: calc(50% + 16px);
    width: calc(4% - 16px);
    transform-origin: right;
}

.timeline-node.revealed .branch-line {
    transform: scaleX(1);
}

/* --- Node Content --- */
.node-content {
    position: relative;
    z-index: 2;
    max-width: 440px;
    opacity: 0;
    transition: opacity 0.5s ease-out 0.5s, transform 0.5s ease-out 0.5s;
    box-shadow: 8px 12px 32px rgba(45, 74, 62, 0.08);
    background: var(--cream);
    padding: 32px;
    border-radius: 2px;
}

.node-right .node-content {
    margin-left: 54%;
    transform: translateX(40px);
}

.node-left .node-content {
    margin-right: 54%;
    margin-left: auto;
    transform: translateX(-40px);
}

.timeline-node.revealed .node-content {
    opacity: 1;
    transform: translateX(0);
}

/* --- Specimen Content --- */
.specimen-illustration {
    width: 100%;
    max-width: 280px;
    margin: 0 auto 20px;
}

.specimen-svg {
    width: 100%;
    height: auto;
}

.specimen-svg .draw-path {
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
    transition: stroke-dashoffset 1.5s ease-in-out;
}

.timeline-node.revealed .specimen-svg .draw-path {
    stroke-dashoffset: 0;
}

.specimen-svg:hover .draw-path[fill="none"] {
    stroke-width: 2;
}

.specimen-label {
    display: block;
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--muted-sage);
    margin-bottom: 4px;
}

.specimen-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.5rem, 4vw, 2.2rem);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--deep-moss);
    line-height: 1.2;
    margin-bottom: 16px;
    min-height: 1.3em;
    overflow: hidden;
}

.specimen-name .typewriter-cursor {
    display: inline-block;
    width: 2px;
    height: 0.85em;
    background-color: var(--deep-emerald);
    margin-left: 2px;
    vertical-align: baseline;
    animation: cursorBlink 530ms step-end infinite;
}

.specimen-name .typewriter-cursor.done {
    animation: cursorFade 1s ease-out forwards;
}

.specimen-body {
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.72;
    color: var(--deep-moss);
    max-width: 42ch;
    margin-bottom: 16px;
    opacity: 0;
    transition: opacity 0.6s ease-out 1s;
}

.timeline-node.revealed .specimen-body {
    opacity: 1;
}

.specimen-meta {
    display: block;
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--muted-sage);
}

.mono {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.85rem;
    text-transform: none;
    letter-spacing: 0;
}

/* --- Footer --- */
.site-footer {
    position: relative;
    z-index: 1;
    width: 100%;
    padding: 120px 20px 80px;
    text-align: center;
    border-top: 1px solid var(--sage);
}

.footer-content {
    max-width: 500px;
    margin: 0 auto;
}

.footer-illustration {
    width: 200px;
    margin: 0 auto 32px;
}

.footer-svg {
    width: 100%;
    height: auto;
}

.footer-wordmark {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 2rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--deep-moss);
    margin-bottom: 12px;
}

.footer-tagline {
    font-family: var(--font-body);
    font-style: italic;
    font-size: 1rem;
    color: var(--muted-sage);
    margin-bottom: 24px;
}

.footer-meta {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--sage);
}

/* ============================================
   RESPONSIVE: < 768px
   ============================================ */
@media (max-width: 768px) {
    .hero-title {
        font-size: clamp(2.5rem, 12vw, 5rem);
    }

    .timeline-spine {
        left: 24px;
        transform: none;
    }

    .timeline-node {
        min-height: auto;
        padding: 40px 0;
    }

    .rosette-container {
        left: 24px;
        transform: translateX(-50%) scale(0);
        width: 24px;
        height: 24px;
    }

    .rosette-container.visible {
        transform: translateX(-50%) scale(1) rotate(360deg);
    }

    @keyframes rosettePulse {
        0% { transform: translateX(-50%) scale(1) rotate(360deg); }
        50% { transform: translateX(-50%) scale(1.15) rotate(360deg); }
        100% { transform: translateX(-50%) scale(1) rotate(360deg); }
    }

    .rosette {
        width: 24px;
        height: 24px;
    }

    .branch-line {
        top: 92px;
    }

    .node-right .branch-line,
    .node-left .branch-line {
        left: 36px;
        right: auto;
        width: 20px;
        transform-origin: left;
    }

    .node-right .node-content,
    .node-left .node-content {
        margin-left: 60px;
        margin-right: 0;
        max-width: calc(100% - 80px);
        transform: translateX(30px);
    }

    .timeline-node.revealed .node-content {
        transform: translateX(0);
    }

    .node-content {
        padding: 24px;
    }

    .specimen-name {
        font-size: clamp(1.2rem, 5vw, 1.8rem);
    }

    .specimen-body {
        font-size: 0.95rem;
    }

    .float-fragment {
        opacity: 0.5;
    }
}

/* ============================================
   ANIMATION HELPERS
   ============================================ */

/* Typewriter text appears character by character via JS */
.typewrite-target {
    visibility: hidden;
}

.typewrite-target.typing,
.typewrite-target.typed {
    visibility: visible;
}
