/* =============================================
   relative.quest - Glassmorphism Forest Observatory
   ============================================= */

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

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

body {
    background-color: #1a3a2a;
    color: #e4edde;
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.4vw, 1.15rem);
    line-height: 1.72;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Mycelium Background Network --- */
.mycelium-network {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 600vh;
    z-index: 0;
    pointer-events: none;
}

.mycelium-path {
    fill: none;
    stroke: #5b8c5a;
    stroke-opacity: 0.06;
    stroke-width: 1.5;
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
}

.mycelium-path.drawn {
    transition: stroke-dashoffset 3s cubic-bezier(0.16, 1, 0.3, 1);
    stroke-dashoffset: 0;
}

/* --- Perspective Container --- */
.perspective-container {
    position: relative;
    perspective: 1200px;
    transform-style: preserve-3d;
    z-index: 1;
}

/* --- Glass Panes --- */
.pane {
    position: relative;
    min-height: 100vh;
    padding: clamp(3rem, 8vh, 6rem) 0;
    transform-style: preserve-3d;
    will-change: transform;
}

.pane::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

/* Hero pane - no glass effect */
.pane-hero {
    display: flex;
    align-items: center;
    min-height: 100vh;
    padding: 0;
    transform: translateZ(0);
}

/* Content panes - glassmorphism */
.pane-1,
.pane-2,
.pane-3,
.pane-4,
.pane-closing {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(16px) saturate(1.2);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    border-top: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 2px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    margin: 0 clamp(1rem, 3vw, 3rem);
}

.pane-1 { transform: translateZ(-40px); }
.pane-2 { transform: translateZ(-80px); }
.pane-3 { transform: translateZ(-120px); }
.pane-4 { transform: translateZ(-160px); }
.pane-closing { transform: translateZ(-200px); }

/* Glass refraction pseudo-element */
.pane-1::before,
.pane-2::before,
.pane-3::before,
.pane-4::before,
.pane-closing::before {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, transparent 50%);
    border-radius: 2px;
    z-index: 1;
}

/* Hover state for glass panes */
.pane-1:hover,
.pane-2:hover,
.pane-3:hover,
.pane-4:hover {
    background: rgba(255, 255, 255, 0.14);
    border-top-color: rgba(255, 255, 255, 0.24);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15), inset 0 0 0 1px #2d5a3f;
    transition: background 0.4s ease, border-top-color 0.4s ease, box-shadow 0.4s ease;
}

/* --- Grid System (12-column) --- */
.pane-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: clamp(1rem, 3vw, 2.5rem);
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 clamp(1.5rem, 4vw, 3rem);
    position: relative;
    z-index: 2;
}

/* --- Hero Content --- */
.hero-content {
    grid-column: 2 / 9;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100vh;
}

.hero-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-size: clamp(3rem, 8vw, 6.5rem);
    letter-spacing: 0.04em;
    color: #e4edde;
    line-height: 1.1;
    opacity: 0;
    transform: translateY(10px);
}

.hero-title.visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 800ms cubic-bezier(0.16, 1, 0.3, 1),
                transform 800ms cubic-bezier(0.16, 1, 0.3, 1);
}

.hero-subtitle {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1rem, 2vw, 1.4rem);
    color: rgba(228, 237, 222, 0.7);
    margin-top: 1.5rem;
    letter-spacing: 0.02em;
    opacity: 0;
    transform: translateY(10px);
}

.hero-subtitle.visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 800ms cubic-bezier(0.16, 1, 0.3, 1) 600ms,
                transform 800ms cubic-bezier(0.16, 1, 0.3, 1) 600ms;
}

/* --- Section Typography --- */
.section-heading {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 600;
    font-size: clamp(1.5rem, 3.5vw, 2.6rem);
    letter-spacing: 0.02em;
    color: #e4edde;
    line-height: 1.2;
    margin-bottom: 0.75rem;
}

.section-subheading {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 500;
    font-size: clamp(0.9rem, 1.8vw, 1.3rem);
    color: #8fbc8f;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.section-body {
    color: rgba(228, 237, 222, 0.92);
    max-width: 52ch;
}

/* --- Pane Text Positioning --- */
.pane-text {
    grid-column: 2 / 7;
    padding: clamp(1rem, 2vw, 2rem) 0;
}

.pane-text-right {
    grid-column: 6 / 12;
}

.pane-viz {
    grid-column: 7 / 13;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pane-text-right + .pane-viz,
.pane-viz + .pane-text-right {
    grid-column: 1 / 7;
}

.pane-text-right ~ .pane-viz {
    grid-column: 1 / 7;
    grid-row: 1;
}

.pane-text-right {
    grid-row: 1;
}

.pane-viz-full {
    grid-column: 1 / 13;
}

/* --- Closing Section --- */
.closing-content {
    grid-column: 3 / 11;
    text-align: center;
    padding: clamp(4rem, 10vh, 8rem) 0;
}

.closing-quote {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1.3rem, 3vw, 2.2rem);
    color: #e4edde;
    line-height: 1.5;
    margin-bottom: 2rem;
}

.closing-quote::before {
    content: '';
    display: block;
    width: 40px;
    height: 2px;
    background: #c9a84c;
    margin: 0 auto 2rem;
}

.closing-domain {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    letter-spacing: 0.04em;
    color: #5b8c5a;
}

/* --- Pane Navigation Dots --- */
.pane-nav {
    position: fixed;
    right: clamp(1rem, 2vw, 2rem);
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 100;
}

.pane-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    border: none;
    padding: 0;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.3s ease;
    outline: none;
}

.pane-dot:hover {
    background: rgba(255, 255, 255, 0.5);
    transform: scale(1.5);
}

.pane-dot.active {
    background: #5b8c5a;
    transform: scale(1.5);
}

/* --- SVG Visualizations --- */
.viz-network,
.viz-radial-tree,
.viz-arc-diagram,
.viz-world-map {
    width: 100%;
    height: auto;
    max-height: 60vh;
    overflow: visible;
}

/* Network edges */
.network-edge {
    fill: none;
    stroke: #5b8c5a;
    stroke-width: 1.2;
    stroke-opacity: 0.6;
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    transition: stroke 0.3s ease, stroke-opacity 0.3s ease;
}

.network-edge.drawn {
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1.5s cubic-bezier(0.16, 1, 0.3, 1),
                stroke 0.3s ease, stroke-opacity 0.3s ease;
}

.network-edge.highlighted {
    stroke: #c9a84c;
    stroke-opacity: 1;
}

.network-edge.dimmed {
    stroke-opacity: 0.15;
}

/* Network nodes */
.node {
    cursor: pointer;
    transition: opacity 0.3s ease;
}

.node use {
    transition: transform 0.3s ease, opacity 0.3s ease;
    transform-origin: center;
}

.node.highlighted use {
    transform: scale(1.3);
    opacity: 1;
}

.node.dimmed {
    opacity: 0.3;
}

.node-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    fill: #8fbc8f;
    text-anchor: middle;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.node-label.visible {
    opacity: 1;
}

/* Data labels */
.data-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    fill: #8fbc8f;
    text-anchor: middle;
}

/* --- Radial Tree --- */
.radial-branch,
.radial-branch-l2 {
    fill: none;
    stroke: #5b8c5a;
    stroke-width: 1.2;
    stroke-opacity: 0.6;
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
}

.radial-branch.drawn,
.radial-branch-l2.drawn {
    stroke-dashoffset: 0;
}

.radial-branch.drawn {
    transition: stroke-dashoffset 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.radial-branch-l2.drawn {
    transition: stroke-dashoffset 1s cubic-bezier(0.16, 1, 0.3, 1) 0.6s;
}

.radial-center {
    opacity: 0;
    transition: opacity 0.6s ease;
}

.radial-center.visible {
    opacity: 1;
}

.radial-terminals use {
    opacity: 0;
    transition: opacity 0.8s ease 1.2s;
}

.radial-terminals.visible use {
    opacity: 1;
}

.radial-labels .data-label {
    opacity: 0;
    transition: opacity 0.6s ease 1.6s;
}

.radial-labels.visible .data-label {
    opacity: 1;
}

.radial-label-center {
    opacity: 0;
    transition: opacity 0.6s ease 0.3s;
}

.radial-label-center.visible {
    opacity: 1;
}

/* --- Arc Diagram --- */
.arc-path {
    fill: none;
    stroke-width: 1.2;
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
}

.arc-short {
    stroke: #5b8c5a;
    stroke-opacity: 0.7;
}

.arc-medium {
    stroke: #5b8c5a;
    stroke-opacity: 0.5;
}

.arc-long {
    stroke: #6b8f9c;
    stroke-opacity: 0.5;
}

.arc-path.drawn {
    stroke-dashoffset: 0;
}

.arc-short.drawn {
    transition: stroke-dashoffset 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.arc-medium.drawn {
    transition: stroke-dashoffset 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.arc-long.drawn {
    transition: stroke-dashoffset 1.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.arc-label {
    opacity: 0;
    transition: opacity 0.6s ease;
}

.arc-label.visible {
    opacity: 1;
}

.arc-nodes circle {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.arc-nodes.visible circle {
    opacity: 1;
}

/* --- World Map --- */
.continent-path {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
}

.continent-path.drawn {
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 2s cubic-bezier(0.16, 1, 0.3, 1);
}

.map-curve {
    fill: none;
    stroke: #5b8c5a;
    stroke-width: 1.2;
    stroke-opacity: 0.6;
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
}

.map-curve.drawn {
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.map-points circle {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.map-points.visible circle {
    opacity: 1;
}

.map-labels .data-label {
    opacity: 0;
    transition: opacity 0.6s ease;
}

.map-labels.visible .data-label {
    opacity: 1;
}

/* --- Fade-up Animation --- */
[data-animate="fade-up"] {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 600ms cubic-bezier(0.16, 1, 0.3, 1),
                transform 600ms cubic-bezier(0.16, 1, 0.3, 1);
}

[data-animate="fade-up"].animated {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger children */
[data-animate="fade-up"].animated .section-heading {
    opacity: 1;
    transform: translateY(0);
}

[data-animate="fade-up"].animated .section-subheading {
    transition-delay: 100ms;
}

[data-animate="fade-up"].animated .section-body {
    transition-delay: 200ms;
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .pane-grid {
        grid-template-columns: repeat(6, 1fr);
    }

    .hero-content {
        grid-column: 1 / -1;
        padding: 0 1rem;
    }

    .pane-text,
    .pane-text-right {
        grid-column: 1 / -1;
    }

    .pane-viz,
    .pane-text-right ~ .pane-viz {
        grid-column: 1 / -1;
        grid-row: auto;
    }

    .pane-text-right {
        grid-row: auto;
    }

    .pane-viz-full {
        grid-column: 1 / -1;
    }

    .closing-content {
        grid-column: 1 / -1;
    }

    .pane-1,
    .pane-2,
    .pane-3,
    .pane-4,
    .pane-closing {
        margin: 0 0.75rem;
    }
}

@media (max-width: 600px) {
    .pane-nav {
        right: 0.5rem;
    }

    .pane-dot {
        width: 3px;
        height: 3px;
    }
}

/* --- will-change hints --- */
.pane {
    will-change: transform, opacity;
}

.network-edge,
.radial-branch,
.radial-branch-l2,
.arc-path,
.map-curve,
.continent-path {
    will-change: stroke-dashoffset;
}
