/* ===========================================
   relative.quest — Generative Sepia Journey
   =========================================== */

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

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

body {
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.2vw, 1.1rem);
    line-height: 1.85;
    color: #4A3828;
    background-color: #FAF4E8;
    overflow-x: hidden;
    position: relative;
}

/* --- Grid-Line Cartographic Background --- */
.grid-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background-image:
        linear-gradient(rgba(192, 168, 128, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(192, 168, 128, 0.03) 1px, transparent 1px);
    background-size: 60px 60px;
}

/* --- SVG Connection Paths Background --- */
.connection-paths {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    opacity: 0.1;
}

.path-lines line,
.path-lines path {
    stroke: #8A7050;
    stroke-width: 1;
    fill: none;
}

/* --- Journey Progress Marker --- */
.journey-progress {
    position: fixed;
    left: clamp(20px, 4vw, 80px);
    top: 0;
    height: 100%;
    width: 2px;
    z-index: 10;
    pointer-events: none;
}

.progress-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 2px;
    height: 100%;
    background: linear-gradient(180deg, #C0A880 0%, #8A7050 50%, #C0A880 100%);
    opacity: 0.15;
}

.progress-dot {
    position: absolute;
    left: -5px;
    top: 0;
    width: 12px;
    height: 12px;
    background: #8A7050;
    border-radius: 50%;
    transition: top 0.15s ease-out;
    box-shadow: 0 0 16px rgba(138, 112, 80, 0.4), 0 0 4px rgba(138, 112, 80, 0.6);
}

.progress-dot::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 6px;
    height: 6px;
    background: #FFF8EE;
    border-radius: 50%;
    opacity: 0.6;
}

.progress-markers {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.progress-tick {
    position: absolute;
    left: -3px;
    width: 8px;
    height: 2px;
    background: #8A7050;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.progress-tick.active {
    opacity: 0.4;
}

/* --- Main Content --- */
.journey-content {
    position: relative;
    z-index: 5;
    max-width: 720px;
    margin: 0 auto;
    padding: 0 24px;
    padding-left: clamp(60px, 8vw, 140px);
}

/* --- Sections --- */
.section {
    padding-top: clamp(80px, 12vh, 160px);
    padding-bottom: clamp(40px, 6vh, 80px);
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.section.visible {
    opacity: 1;
    transform: translateY(0);
}

.section-inner {
    position: relative;
}

/* --- Journey Markers --- */
.journey-marker {
    display: inline-block;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.75rem;
    color: #8A7050;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-bottom: 20px;
    padding: 4px 0;
    border-bottom: 1px solid rgba(138, 112, 80, 0.2);
}

/* --- Hero Section --- */
.hero-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding-top: 0;
}

.hero-title {
    font-family: 'DM Sans', sans-serif;
    font-weight: 700;
    font-size: clamp(2.2rem, 5vw, 3.8rem);
    color: #1A1408;
    letter-spacing: 0.06em;
    line-height: 1.1;
    margin-bottom: 16px;
}

.hero-dot {
    color: #5A8050;
    display: inline-block;
    animation: dotPulse 3s ease-in-out infinite;
}

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

.hero-subtitle {
    font-family: 'DM Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(1rem, 1.8vw, 1.3rem);
    color: #8A7050;
    margin-bottom: 40px;
    line-height: 1.6;
}

.hero-illustration {
    margin-top: 24px;
    width: 100%;
    max-width: 400px;
}

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

/* --- Scroll Hint --- */
.scroll-hint {
    margin-top: 48px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    opacity: 0.5;
    transition: opacity 0.6s ease;
}

.scroll-hint.hidden {
    opacity: 0;
    pointer-events: none;
}

.scroll-hint-text {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.7rem;
    color: #8A7050;
    letter-spacing: 0.1em;
    text-transform: lowercase;
    margin-bottom: 8px;
}

.scroll-hint-arrow {
    width: 20px;
    height: 20px;
    animation: scrollBob 2s ease-in-out infinite;
}

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

/* --- Discovery Sections --- */
.discovery-card {
    background: #FFF8EE;
    border-radius: 4px;
    padding: clamp(24px, 4vw, 48px);
    border: 1px solid rgba(192, 168, 128, 0.15);
    position: relative;
    overflow: hidden;
}

.discovery-card::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    border-radius: 4px;
    border: 1px solid transparent;
    background: linear-gradient(135deg, rgba(90, 128, 80, 0.2), transparent 40%) border-box;
    mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    -webkit-mask-composite: xor;
    pointer-events: none;
}

.discovery-icon {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
}

.discovery-icon svg {
    width: 100%;
    height: 100%;
}

.discovery-title {
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    font-size: clamp(1.4rem, 3vw, 2rem);
    color: #1A1408;
    margin-bottom: 16px;
    line-height: 1.3;
}

.discovery-text {
    color: #4A3828;
    line-height: 1.85;
}

.discovery-trail {
    margin-top: 24px;
    width: 100%;
    overflow: hidden;
}

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

.branch-illustration {
    width: 100%;
    max-width: 400px;
    margin: 0 auto 24px;
}

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

/* --- Generation Counter --- */
.generation-counter {
    margin-top: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.gen-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.72rem;
    color: #8A7050;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.gen-dots {
    display: flex;
    gap: 6px;
    align-items: center;
}

.gen-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #C0A880;
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.gen-dot.revealed {
    opacity: 0.7;
    transform: scale(1);
}

.gen-dot:nth-child(2n) {
    background: #8A7050;
}

.gen-dot:nth-child(3n) {
    background: #5A8050;
}

/* --- Bounce-Enter Animation --- */
@keyframes discoveryBounce {
    0% {
        opacity: 0;
        transform: translateY(60px) scale(0.9);
    }
    60% {
        opacity: 1;
        transform: translateY(-12px) scale(1.02);
    }
    80% {
        transform: translateY(4px) scale(0.99);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.bounce-enter {
    opacity: 0;
    transform: translateY(60px) scale(0.9);
}

.bounce-enter.bounced {
    animation: discoveryBounce 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* --- Network Canvas --- */
.network-canvas-wrapper {
    margin-top: 24px;
    width: 100%;
    border-radius: 4px;
    overflow: hidden;
    background: rgba(26, 20, 8, 0.02);
}

.network-canvas {
    width: 100%;
    height: auto;
    display: block;
}

/* --- Milestones --- */
.section-title {
    font-family: 'DM Sans', sans-serif;
    font-weight: 700;
    font-size: clamp(1.6rem, 3.5vw, 2.4rem);
    color: #1A1408;
    margin-bottom: 24px;
    line-height: 1.2;
}

.milestone-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    margin-top: 32px;
}

.milestone {
    background: #FFF8EE;
    border: 1px solid rgba(192, 168, 128, 0.15);
    border-radius: 4px;
    padding: clamp(20px, 3vw, 36px);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.milestone::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, #5A8050, #8A7050, #C0A880);
    opacity: 0;
    transition: opacity 0.6s ease;
}

.milestone.bounced::after {
    opacity: 0.5;
}

.milestone-number {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    color: #1A1408;
    line-height: 1.2;
    margin-bottom: 8px;
}

.milestone-label {
    display: block;
    font-family: 'DM Sans', sans-serif;
    font-weight: 300;
    font-size: 0.85rem;
    color: #8A7050;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* --- Generative Map --- */
.section-description {
    color: #4A3828;
    margin-bottom: 32px;
    max-width: 600px;
    line-height: 1.85;
}

.map-canvas-wrapper {
    width: 100%;
    border-radius: 4px;
    overflow: hidden;
    background: rgba(26, 20, 8, 0.02);
    border: 1px solid rgba(192, 168, 128, 0.1);
}

.generative-map-canvas {
    width: 100%;
    height: auto;
    display: block;
}

.map-legend {
    display: flex;
    gap: 24px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: block;
}

.legend-text {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.68rem;
    color: #8A7050;
    letter-spacing: 0.05em;
}

/* --- Stories --- */
.story-cards {
    display: flex;
    flex-direction: column;
    gap: 32px;
    margin-top: 32px;
}

.story-card {
    background: #FFF8EE;
    border: 1px solid rgba(192, 168, 128, 0.15);
    border-radius: 4px;
    padding: clamp(24px, 4vw, 40px);
    position: relative;
}

.story-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: linear-gradient(180deg, #5A8050, #8A7050, #C0A880);
    border-radius: 4px 0 0 4px;
}

.story-coordinates {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.72rem;
    color: #8A7050;
    letter-spacing: 0.1em;
    margin-bottom: 12px;
    opacity: 0.7;
}

.story-title {
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    font-size: clamp(1.1rem, 2vw, 1.4rem);
    color: #1A1408;
    margin-bottom: 10px;
}

.story-text {
    color: #4A3828;
    line-height: 1.85;
    font-weight: 300;
}

.story-path-indicator {
    margin-top: 16px;
    width: 100%;
    max-width: 200px;
}

.story-path-indicator svg {
    width: 100%;
    height: auto;
}

/* --- Continuing Section --- */
.continuing-text {
    color: #4A3828;
    line-height: 1.85;
    margin-bottom: 32px;
    max-width: 600px;
}

.continuing-illustration {
    width: 100%;
    max-width: 400px;
    margin-bottom: 48px;
}

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

.expedition-stamp {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 40px;
    border: 2px solid #C0A880;
    border-radius: 4px;
    text-align: center;
    opacity: 0.6;
    transform: rotate(-2deg);
    position: relative;
}

.stamp-text {
    font-family: 'DM Sans', sans-serif;
    font-weight: 700;
    font-size: 1.2rem;
    color: #1A1408;
    letter-spacing: 0.15em;
}

.stamp-divider {
    display: block;
    width: 40px;
    height: 1px;
    background: #C0A880;
    margin: 8px 0;
    opacity: 0.5;
}

.stamp-subtext {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.7rem;
    color: #8A7050;
    letter-spacing: 0.08em;
    margin-top: 2px;
}

/* --- SVG Draw Animation --- */
.draw-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 2s ease-in-out;
}

.visible .draw-path,
.hero-section .draw-path {
    stroke-dashoffset: 0;
}

/* --- Pulse Node Animation --- */
@keyframes nodePulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.4); }
}

.pulse-node {
    animation: nodePulse 3s ease-in-out infinite;
    transform-origin: center;
    transform-box: fill-box;
}

.pulse-node:nth-child(even) {
    animation-delay: 1s;
}

.pulse-node:nth-child(3n) {
    animation-delay: 2s;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .journey-content {
        padding-left: 48px;
        padding-right: 16px;
    }

    .journey-progress {
        left: 16px;
    }

    .milestone-grid {
        grid-template-columns: 1fr;
    }

    .hero-section {
        min-height: 80vh;
    }

    .map-legend {
        gap: 16px;
    }
}

@media (max-width: 480px) {
    .journey-content {
        padding-left: 40px;
        padding-right: 12px;
    }

    .journey-progress {
        left: 12px;
    }

    .expedition-stamp {
        padding: 16px 24px;
    }

    .map-legend {
        flex-direction: column;
        gap: 8px;
    }
}

/* --- Scrollbar Styling --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #FAF4E8;
}

::-webkit-scrollbar-thumb {
    background: #C0A880;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #8A7050;
}

/* --- Selection Color --- */
::selection {
    background: rgba(138, 112, 80, 0.2);
    color: #1A1408;
}
