/* ===================================================
   RRIPPL.com - Pixel-Art Botanica Digital Herbarium
   Monochrome palette | Timeline-vertical layout
   =================================================== */

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

:root {
    --void-black: #0D0D0D;
    --carbon: #1A1A1A;
    --graphite: #2A2A2A;
    --slate: #3A3A3A;
    --pewter: #808080;
    --silver: #B0B0B0;
    --ash: #C8C8C8;
    --chalk: #E0E0E0;
    --paper-white: #F5F5F5;
    --pure-white: #FFFFFF;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--void-black);
    color: var(--ash);
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    line-height: 1.65;
    overflow-x: hidden;
    image-rendering: pixelated;
    -webkit-font-smoothing: antialiased;
}

/* --- Botanical Background Pattern --- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.15;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='128' height='128' viewBox='0 0 128 128'%3E%3Cpath d='M20 100 Q30 80 40 90 Q50 70 60 80' stroke='%232A2A2A' stroke-width='1' fill='none'/%3E%3Cpath d='M64 10 L64 50 M54 20 L64 30 L74 20' stroke='%232A2A2A' stroke-width='1' fill='none'/%3E%3Cpath d='M90 60 Q100 40 110 55 Q105 35 95 50' stroke='%232A2A2A' stroke-width='1' fill='none'/%3E%3Cpath d='M10 40 Q20 30 15 20 M15 40 Q25 35 20 25' stroke='%232A2A2A' stroke-width='1' fill='none'/%3E%3Cpath d='M80 110 L80 90 M72 105 Q80 95 88 105' stroke='%232A2A2A' stroke-width='1' fill='none'/%3E%3Cpath d='M110 100 Q115 85 120 95 M108 95 Q118 80 125 90' stroke='%232A2A2A' stroke-width='1' fill='none'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 128px 128px;
}

/* --- Pixel Navigation --- */
#pixel-nav {
    position: fixed;
    top: 24px;
    left: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pixel-nav-btn {
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid var(--graphite);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: none;
    image-rendering: pixelated;
}

.pixel-nav-btn:hover {
    border-color: var(--pewter);
}

.pixel-nav-btn:hover svg rect,
.pixel-nav-btn:hover svg circle,
.pixel-nav-btn:hover svg polygon {
    fill: #A0A0A0;
}

/* --- Hero Section --- */
#hero {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1;
    background-color: var(--void-black);
}

#seed-container {
    position: relative;
    width: 64px;
    height: 64px;
    margin-bottom: 32px;
}

#pixel-seed {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 4px;
    background-color: var(--pure-white);
    transform: translate(-50%, -50%);
    opacity: 0;
    image-rendering: pixelated;
}

#pixel-seed.animate {
    animation: seedGrow 1200ms steps(8, end) 400ms forwards;
}

@keyframes seedGrow {
    0% {
        width: 4px;
        height: 4px;
        opacity: 1;
        border-radius: 0;
    }
    12.5% {
        width: 8px;
        height: 8px;
        opacity: 1;
    }
    25% {
        width: 12px;
        height: 12px;
        opacity: 1;
    }
    37.5% {
        width: 16px;
        height: 16px;
        opacity: 1;
    }
    50% {
        width: 16px;
        height: 24px;
        opacity: 1;
    }
    62.5% {
        width: 20px;
        height: 32px;
        opacity: 1;
    }
    75% {
        width: 24px;
        height: 40px;
        opacity: 1;
    }
    100% {
        width: 32px;
        height: 48px;
        opacity: 1;
        background-color: var(--silver);
    }
}

#pixel-seed.sprouted {
    width: 32px;
    height: 48px;
    opacity: 1;
    background-color: var(--silver);
    box-shadow:
        -8px -16px 0 0 var(--pewter),
        8px -16px 0 0 var(--pewter),
        -12px -24px 0 0 var(--ash),
        12px -24px 0 0 var(--ash),
        0 12px 0 0 var(--slate),
        -4px 20px 0 0 var(--graphite),
        4px 20px 0 0 var(--graphite);
}

#hero-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(2.5rem, 6vw, 5rem);
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--paper-white);
    text-align: center;
    opacity: 0;
    overflow: hidden;
    white-space: nowrap;
    border-right: 2px solid var(--pure-white);
    width: 0;
    margin: 0 auto;
}

#hero-title.typing {
    opacity: 1;
    animation: typeHero 600ms steps(6, end) forwards,
               blinkCursor 530ms steps(1, end) infinite;
}

#hero-title.typed {
    opacity: 1;
    width: auto;
    border-right: 2px solid var(--slate);
    animation: none;
}

@keyframes typeHero {
    from { width: 0; }
    to { width: 6.5ch; }
}

@keyframes blinkCursor {
    0%, 100% { border-color: var(--pure-white); }
    50% { border-color: transparent; }
}

#hero-tagline {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.875rem;
    letter-spacing: 0.04em;
    color: var(--pewter);
    text-align: center;
    margin-top: 16px;
    opacity: 0;
    overflow: hidden;
    white-space: nowrap;
    border-right: 2px solid var(--pure-white);
    width: 0;
}

#hero-tagline.typing {
    opacity: 1;
    animation: typeTagline 1800ms steps(45, end) forwards,
               blinkCursor 530ms steps(1, end) infinite;
}

#hero-tagline.typed {
    opacity: 1;
    width: auto;
    border-right: 2px solid var(--slate);
    animation: none;
}

@keyframes typeTagline {
    from { width: 0; }
    to { width: 45ch; }
}

/* --- Timeline Container --- */
#timeline-container {
    position: relative;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px 200px;
    z-index: 1;
}

/* --- Timeline Axis --- */
#timeline-axis {
    position: absolute;
    left: 50%;
    top: 0;
    width: 2px;
    height: 100%;
    transform: translateX(-50%);
    background-image: repeating-linear-gradient(
        to bottom,
        var(--slate) 0px,
        var(--slate) 4px,
        transparent 4px,
        transparent 8px
    );
    opacity: 0;
    transition: opacity 600ms steps(4, end);
}

#timeline-axis.visible {
    opacity: 1;
}

/* --- Specimen Cards --- */
.specimen-card {
    position: relative;
    width: calc(50% - 40px);
    margin-bottom: 0;
    opacity: 0;
    transform: scale(0.1);
    transition: none;
}

.specimen-card.materialized {
    opacity: 1;
    transform: scale(1);
    animation: pixelMaterialize 600ms steps(8, end) forwards;
}

@keyframes pixelMaterialize {
    0% {
        opacity: 0;
        transform: scale(0.05);
        clip-path: inset(45% 45% 45% 45%);
    }
    12.5% {
        opacity: 1;
        clip-path: inset(40% 40% 40% 40%);
    }
    25% {
        clip-path: inset(35% 35% 35% 35%);
    }
    37.5% {
        clip-path: inset(25% 25% 25% 25%);
    }
    50% {
        clip-path: inset(18% 18% 18% 18%);
        transform: scale(0.6);
    }
    62.5% {
        clip-path: inset(10% 10% 10% 10%);
    }
    75% {
        clip-path: inset(5% 5% 5% 5%);
        transform: scale(0.85);
    }
    100% {
        opacity: 1;
        transform: scale(1);
        clip-path: inset(0 0 0 0);
    }
}

/* Fibonacci-inspired spacing: 64, 96, 160, 256, then repeat */
.specimen-card:nth-child(6n+1) { margin-top: 64px; }
.specimen-card:nth-child(6n+2) { margin-top: 96px; }
.specimen-card:nth-child(6n+3) { margin-top: 160px; }
.specimen-card:nth-child(6n+4) { margin-top: 96px; }
.specimen-card:nth-child(6n+5) { margin-top: 160px; }
.specimen-card:nth-child(6n+6) { margin-top: 256px; }

.card-left {
    margin-left: 0;
    margin-right: auto;
}

.card-right {
    margin-left: auto;
    margin-right: 0;
}

/* Interstitials need spacing too */
.interstitial {
    margin-top: 160px;
}

/* --- Node Marker --- */
.node-marker {
    position: absolute;
    width: 12px;
    height: 12px;
    background-color: var(--chalk);
    top: 40px;
    image-rendering: pixelated;
}

.card-left .node-marker {
    right: -46px;
}

.card-right .node-marker {
    left: -46px;
}

.node-marker.pulse {
    animation: nodePulse 1200ms steps(2, end) 3;
}

@keyframes nodePulse {
    0%, 100% { background-color: var(--chalk); }
    50% { background-color: var(--silver); }
}

/* --- Card Inner --- */
.card-inner {
    background-color: var(--carbon);
    border: 1px solid var(--graphite);
    box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.3);
    padding: 32px;
    position: relative;
    overflow: hidden;
}

.card-inner::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    opacity: 0;
    z-index: 10;
}

/* --- Specimen Image --- */
.specimen-image {
    width: 100%;
    max-width: 200px;
    height: 200px;
    margin: 0 auto 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.botanical-svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(2px 4px 6px rgba(0, 0, 0, 0.4));
}

/* --- Specimen Text --- */
.specimen-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--chalk);
    letter-spacing: 0.04em;
    margin-bottom: 8px;
    overflow: hidden;
    white-space: nowrap;
    border-right: 2px solid transparent;
    width: 0;
    opacity: 0;
}

.specimen-title.typing {
    opacity: 1;
    border-right-color: var(--pure-white);
    animation: blinkCursor 530ms steps(1, end) infinite;
}

.specimen-title.typed {
    opacity: 1;
    width: auto;
    border-right: 2px solid var(--slate);
}

.specimen-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    color: var(--pewter);
    display: block;
    margin-bottom: 16px;
    overflow: hidden;
    white-space: nowrap;
    border-right: 2px solid transparent;
    width: 0;
    opacity: 0;
}

.specimen-label.typing {
    opacity: 1;
    border-right-color: var(--pure-white);
    animation: blinkCursor 530ms steps(1, end) infinite;
}

.specimen-label.typed {
    opacity: 1;
    width: auto;
    border-right: 2px solid var(--slate);
}

.specimen-desc {
    font-family: 'Inter', sans-serif;
    font-size: 0.9375rem;
    line-height: 1.65;
    color: var(--ash);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 400ms steps(4, end), transform 400ms steps(4, end);
}

.specimen-desc.visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- Pixel Ripple Effect on Hover --- */
.specimen-card .card-inner {
    cursor: crosshair;
}

/* --- Interstitials --- */
.interstitial {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
    opacity: 0;
    transition: opacity 600ms steps(4, end);
}

.interstitial.visible {
    opacity: 1;
}

.interstitial-specimen {
    width: 60vw;
    max-width: 600px;
    height: 60vw;
    max-height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 48px;
}

.rotating-botanical {
    width: 100%;
    height: 100%;
    animation: slowRotate 30s linear infinite;
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.5));
}

@keyframes slowRotate {
    from { transform: rotateY(0deg); }
    to { transform: rotateY(360deg); }
}

.interstitial-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1rem;
    letter-spacing: 0.04em;
    color: var(--pewter);
    text-align: center;
    overflow: hidden;
    white-space: nowrap;
    border-right: 2px solid transparent;
    width: 0;
    opacity: 0;
}

.interstitial-text.typing {
    opacity: 1;
    border-right-color: var(--pure-white);
    animation: blinkCursor 530ms steps(1, end) infinite;
}

.interstitial-text.typed {
    opacity: 1;
    width: auto;
    border-right: 2px solid var(--slate);
}

/* --- Footer --- */
#footer {
    position: relative;
    width: 100%;
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    background-color: var(--void-black);
    padding: 80px 24px;
}

#footer-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
}

#footer-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1.125rem;
    letter-spacing: 0.04em;
    color: var(--pewter);
    overflow: hidden;
    white-space: nowrap;
    border-right: 2px solid transparent;
    width: 0;
    opacity: 0;
}

#footer-text.typing {
    opacity: 1;
    border-right-color: var(--pure-white);
    animation: blinkCursor 530ms steps(1, end) infinite;
}

#footer-text.typed {
    opacity: 1;
    width: auto;
    border-right: 2px solid var(--slate);
}

#footer-seed {
    animation: seedPulse 2000ms steps(2, end) infinite;
}

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

#scroll-top-btn {
    cursor: pointer;
    padding: 16px;
    opacity: 0.5;
    transition: opacity 200ms steps(2, end);
}

#scroll-top-btn:hover {
    opacity: 1;
}

/* --- Ripple Canvas --- */
#ripple-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
}

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
    #timeline-container {
        padding-left: 40px;
        padding-right: 16px;
    }

    #timeline-axis {
        left: 24px;
        transform: none;
    }

    .specimen-card {
        width: calc(100% - 40px);
        margin-left: 40px !important;
        margin-right: 0 !important;
    }

    .card-left .node-marker,
    .card-right .node-marker {
        left: -34px;
        right: auto;
    }

    .specimen-image {
        max-width: 160px;
        height: 160px;
    }

    .card-inner {
        padding: 24px;
    }

    .interstitial-specimen {
        width: 80vw;
        height: 80vw;
    }

    #hero-title {
        font-size: clamp(2rem, 10vw, 3.5rem);
    }

    #pixel-nav {
        top: 16px;
        left: 16px;
    }

    .pixel-nav-btn {
        width: 28px;
        height: 28px;
    }
}

@media (max-width: 480px) {
    .card-inner {
        padding: 16px;
    }

    .specimen-title {
        font-size: 1.25rem;
    }

    .specimen-desc {
        font-size: 0.875rem;
    }

    #hero-tagline {
        font-size: 0.75rem;
    }
}

/* --- Utility: Step Transition All --- */
.step-transition {
    transition-timing-function: steps(8, end);
}
