/* ==========================================================
   gabs.quest — topographic descent
   palette: parchment cream → river teal → deep water → gold
   ========================================================== */

:root {
    --parchment: #f4f0e8;
    --contour: #8b7e6a;
    --valley-warm: #f0e8d8;
    --river-teal: #5b8a72;
    --deep-water: #1a3a3a;
    --gold: #c9a84c;
    --ink-dark: #2c2a25;
    --fog-light: #e8e0d0;

    --bg-color: var(--parchment);
    --text-color: var(--ink-dark);
    --accent-color: var(--contour);

    --font-display: "Josefin Sans", "Inter", sans-serif;
    --font-body: "Literata", "Lora", Georgia, serif;
    --font-mono: "Azeret Mono", "Space Mono", ui-monospace, monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 1.15vw, 1.1rem);
    line-height: 1.8;
    color: var(--text-color);
    background-color: var(--bg-color);
    transition: background-color 1.5s ease, color 1s ease;
    overflow-x: hidden;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============== Elevation Gauge ============== */
.elevation-gauge {
    position: fixed;
    top: 50%;
    left: 2.4rem;
    transform: translateY(-50%);
    height: 60vh;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    pointer-events: none;
    color: var(--accent-color);
    transition: color 1s ease;
}

.gauge-label-top, .gauge-label-bottom {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    opacity: 0.75;
    text-align: center;
    line-height: 1.4;
}

.gauge-coord {
    font-size: 0.62rem;
    opacity: 0.7;
}

.gauge-num {
    font-size: 0.9rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
}

.gauge-unit {
    font-size: 0.6rem;
    opacity: 0.6;
}

.gauge-zone {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: 0.65rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    opacity: 0.85;
}

.gauge-track {
    position: relative;
    flex: 1;
    width: 1px;
    margin: 0.8rem 0;
}

.gauge-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 100%;
    background: currentColor;
    opacity: 0.35;
}

.gauge-tick {
    position: absolute;
    left: -4px;
    width: 9px;
    height: 1px;
    background: currentColor;
    opacity: 0.35;
}

.gauge-indicator {
    position: absolute;
    left: -3.5px;
    top: 0%;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 0 3px var(--bg-color), 0 0 0 4px currentColor;
    transition: top 0.18s linear, background-color 1s ease, box-shadow 1s ease;
}

/* ============== Trail Spine SVG ============== */
.trail-spine {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    color: var(--accent-color);
}

#trailPath {
    transition: stroke 1s ease;
}

/* ============== Section Base ============== */
.section {
    position: relative;
    width: 100%;
    overflow: hidden;
    padding: 0 6vw;
    z-index: 3;
}

/* ============== Contour fields ============== */
.contour-field {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

.contour {
    position: absolute;
    width: var(--w);
    height: var(--h);
    border: 1px solid rgba(139, 126, 106, var(--o, 0.3));
    border-radius: 50%;
    transform: translate(-50%, -50%);
    will-change: transform;
}

.contour-flat {
    border-radius: 50% / 30%;
}

.depths .contour {
    border-color: rgba(232, 224, 208, calc(var(--o, 0.3) * 0.4));
}

/* ============== SECTION 1: Summit ============== */
.summit {
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    background: var(--parchment);
}

.summit-content {
    position: relative;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.1rem;
}

.wordmark {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: 1.2rem;
    letter-spacing: 0.32em;
    text-transform: lowercase;
    color: var(--ink-dark);
    padding: 0.6rem 1.4rem;
    border: 1px solid rgba(139, 126, 106, 0.55);
    background: rgba(244, 240, 232, 0.6);
    backdrop-filter: blur(2px);
}

.summit-coords {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    color: var(--contour);
    opacity: 0.75;
    display: flex;
    gap: 1.4rem;
    flex-wrap: wrap;
    justify-content: center;
}

.summit-label {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: 0.78rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--contour);
    opacity: 0.7;
    margin-top: 0.5rem;
}

.scroll-hint {
    position: absolute;
    bottom: 4vh;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-display);
    font-size: 0.72rem;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--contour);
    opacity: 0.6;
    z-index: 5;
}

.scroll-arrow {
    font-size: 1rem;
    animation: arrowDrift 2.6s ease-in-out infinite;
}

@keyframes arrowDrift {
    0%, 100% { transform: translateY(0); opacity: 0.4; }
    50% { transform: translateY(8px); opacity: 0.9; }
}

/* ============== SECTION 2: Ridge ============== */
.ridge {
    min-height: 200vh;
    padding-top: 8vh;
    padding-bottom: 8vh;
    background: var(--parchment);
}

.ridge-track {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 14vh;
    padding: 6vh 0;
    z-index: 5;
}

.trail-marker {
    position: relative;
    max-width: 35ch;
    padding: 1.6rem 1.8rem 1.8rem;
    border: 1px solid rgba(139, 126, 106, 0.4);
    background: rgba(244, 240, 232, 0.7);
    backdrop-filter: blur(1px);
    opacity: 0;
    transform: translateY(28px);
    transition: opacity 0.9s ease, transform 0.9s ease;
}

.trail-marker.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.tm-left {
    align-self: flex-start;
    margin-left: 4%;
}

.tm-right {
    align-self: flex-end;
    margin-right: 4%;
    text-align: left;
}

.elev-tag {
    position: absolute;
    top: 0.9rem;
    right: 1rem;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    color: var(--contour);
    opacity: 0.7;
    font-variant-numeric: tabular-nums;
}

.checkpoint {
    position: absolute;
    top: -6px;
    left: -6px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid var(--contour);
    background: var(--parchment);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.5s ease, border-color 0.5s ease;
}

.checkpoint span {
    font-family: var(--font-mono);
    font-size: 8px;
    line-height: 1;
    color: var(--contour);
    transition: color 0.5s ease, opacity 0.5s ease;
}

.trail-marker.is-visible .checkpoint {
    background-color: var(--river-teal);
    border-color: var(--river-teal);
}

.trail-marker.is-visible .checkpoint span {
    color: var(--parchment);
    opacity: 0.9;
}

.tm-right .checkpoint {
    left: auto;
    right: -6px;
}

.marker-heading {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(1.2rem, 2.2vw, 1.7rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-dark);
    margin-bottom: 0.8rem;
    line-height: 1.2;
}

.trail-marker p {
    color: var(--ink-dark);
    font-size: 0.98rem;
    line-height: 1.75;
}

/* ============== SECTION 3: Valley ============== */
.valley {
    min-height: 120vh;
    padding-top: 12vh;
    padding-bottom: 12vh;
    background: var(--valley-warm);
    transition: background-color 1.5s ease;
}

.river {
    position: absolute;
    top: 30%;
    left: -5%;
    width: 110%;
    height: 60%;
    pointer-events: none;
    z-index: 2;
    overflow: visible;
}

#riverPath {
    animation: riverFlow 14s linear infinite;
}

@keyframes riverFlow {
    from { stroke-dashoffset: 0; }
    to { stroke-dashoffset: -200; }
}

.valley-track {
    position: relative;
    max-width: 70ch;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 12vh;
    z-index: 5;
}

.valley-block {
    max-width: 55ch;
    margin: 0 auto;
    padding: 1.4rem 0.4rem;
    text-align: left;
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 1s ease, transform 1s ease;
}

.valley-block.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.block-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.block-coord {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    color: var(--contour);
    opacity: 0.7;
    text-transform: uppercase;
    white-space: nowrap;
}

.block-rule {
    flex: 1;
    height: 1px;
    background: rgba(139, 126, 106, 0.35);
}

.valley-heading {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(1.5rem, 3.4vw, 2.4rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-dark);
    margin-bottom: 0.8rem;
    line-height: 1.18;
}

.valley-block p {
    color: var(--ink-dark);
    line-height: 1.85;
}

.valley-block em {
    font-style: italic;
    color: var(--river-teal);
}

/* ============== SECTION 4: Depths ============== */
.depths {
    min-height: 100vh;
    padding-top: 14vh;
    padding-bottom: 14vh;
    background: var(--deep-water);
    color: var(--fog-light);
    transition: background-color 1.6s ease, color 1s ease;
}

.bio-field {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
}

.bio-dot {
    position: absolute;
    left: var(--x);
    top: var(--y);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(201, 168, 76, 0.8) 0%, rgba(201, 168, 76, 0) 70%);
    transform: translate(-50%, -50%) scale(1);
    animation: bioPulse var(--dur, 5s) ease-in-out infinite;
    animation-delay: var(--d, 0s);
    opacity: 0;
}

.bio-dot::after {
    content: "";
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(201, 168, 76, 0.35) 0%, rgba(201, 168, 76, 0) 70%);
}

@keyframes bioPulse {
    0%, 100% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.3); }
}

.depths-track {
    position: relative;
    max-width: 50ch;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 10vh;
    z-index: 5;
    padding: 6vh 0;
}

.depths-line {
    font-family: var(--font-body);
    font-style: italic;
    font-size: clamp(1.05rem, 1.6vw, 1.35rem);
    line-height: 1.85;
    color: var(--fog-light);
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1.4s ease, transform 1.4s ease;
}

.depths-line.is-visible {
    opacity: 0.92;
    transform: translateY(0);
}

.depths-line:nth-child(odd) {
    text-align: left;
}

.depths-line:nth-child(even) {
    text-align: right;
}

/* ============== SECTION 5: Treasure ============== */
.treasure {
    min-height: 100vh;
    background: var(--deep-water);
    color: var(--fog-light);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding-top: 8vh;
    padding-bottom: 6vh;
    transition: background-color 1.6s ease, color 1s ease;
}

.treasure-stage {
    position: relative;
    width: 25vw;
    min-width: 220px;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 3rem;
}

.sonar-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1px solid var(--gold);
    opacity: 0;
    animation: sonar 5.6s ease-out infinite;
    animation-delay: var(--delay, 0s);
}

@keyframes sonar {
    0% { transform: scale(0.4); opacity: 0; border-width: 1.5px; }
    15% { opacity: 0.85; }
    100% { transform: scale(2.4); opacity: 0; border-width: 0.5px; }
}

.treasure-glyph {
    position: relative;
    font-family: var(--font-body);
    font-weight: 500;
    font-size: clamp(8rem, 18vw, 15rem);
    color: var(--gold);
    line-height: 1;
    text-shadow: 0 0 24px rgba(201, 168, 76, 0.35);
    z-index: 2;
    animation: glyphBreath 6s ease-in-out infinite;
}

@keyframes glyphBreath {
    0%, 100% { transform: scale(1); text-shadow: 0 0 24px rgba(201, 168, 76, 0.35); }
    50% { transform: scale(1.025); text-shadow: 0 0 38px rgba(201, 168, 76, 0.55); }
}

.treasure-caption {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(0.9rem, 1.4vw, 1.05rem);
    letter-spacing: 0.28em;
    text-transform: lowercase;
    color: var(--fog-light);
    opacity: 0.85;
    margin-bottom: 1.4rem;
}

.treasure-coords {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    color: var(--gold);
    opacity: 0.7;
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 4rem;
}

.treasure-footer {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: 0.7rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--fog-light);
    opacity: 0.45;
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    justify-content: center;
}

.dot-sep {
    opacity: 0.6;
}

/* ============== Body palette states ============== */
body[data-palette="summit"] {
    --bg-color: var(--parchment);
    --text-color: var(--ink-dark);
    --accent-color: var(--contour);
}
body[data-palette="ridge"] {
    --bg-color: var(--parchment);
    --text-color: var(--ink-dark);
    --accent-color: var(--contour);
}
body[data-palette="valley"] {
    --bg-color: var(--valley-warm);
    --text-color: var(--ink-dark);
    --accent-color: var(--river-teal);
}
body[data-palette="depths"] {
    --bg-color: var(--deep-water);
    --text-color: var(--fog-light);
    --accent-color: var(--fog-light);
}
body[data-palette="discovery"] {
    --bg-color: var(--deep-water);
    --text-color: var(--fog-light);
    --accent-color: var(--gold);
}

/* ============== Responsive ============== */
@media (max-width: 768px) {
    .elevation-gauge {
        position: fixed;
        top: 0.6rem;
        left: 50%;
        transform: translateX(-50%);
        flex-direction: row;
        height: auto;
        width: 86vw;
        gap: 0.6rem;
        padding: 0.4rem 0.6rem;
        background: rgba(244, 240, 232, 0.78);
        backdrop-filter: blur(4px);
        border: 1px solid rgba(139, 126, 106, 0.3);
    }

    body[data-palette="depths"] .elevation-gauge,
    body[data-palette="discovery"] .elevation-gauge {
        background: rgba(26, 58, 58, 0.78);
        border-color: rgba(232, 224, 208, 0.25);
    }

    .gauge-label-top, .gauge-label-bottom {
        flex-direction: row;
        gap: 0.4rem;
        align-items: center;
        font-size: 0.62rem;
    }

    .gauge-coord { display: none; }

    .gauge-track {
        flex: 1;
        height: 1px;
        width: auto;
        margin: 0 0.4rem;
    }

    .gauge-line {
        width: 100%;
        height: 1px;
    }

    .gauge-tick {
        left: auto;
        top: -3.5px;
        width: 1px;
        height: 7px;
    }

    .gauge-indicator {
        top: 50%;
        left: 0%;
        transform: translate(-50%, -50%);
        transition: left 0.18s linear;
        box-shadow: 0 0 0 2px var(--bg-color), 0 0 0 3px currentColor;
    }

    .summit-content { gap: 0.8rem; }

    .ridge {
        min-height: auto;
        padding-top: 12vh;
    }

    .ridge-track { gap: 8vh; }

    .trail-marker,
    .tm-left,
    .tm-right {
        align-self: stretch;
        margin: 0 4%;
        max-width: none;
    }

    .tm-right .checkpoint {
        left: -6px;
        right: auto;
    }

    .valley-track { gap: 8vh; }

    .trail-spine {
        opacity: 0.5;
    }

    .contour-field .contour:nth-child(n+5) {
        display: none;
    }

    .bio-field .bio-dot:nth-child(n+9) {
        display: none;
    }

    .treasure-stage {
        width: 60vw;
    }
}

@media (max-width: 480px) {
    .summit-coords {
        font-size: 0.6rem;
        gap: 0.8rem;
    }

    .marker-heading,
    .valley-heading {
        font-size: 1.3rem;
    }
}
