/* ============================================
   desca.work - Geological Descent
   ============================================ */

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

html {
    overflow-x: hidden;
}

body {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(16px, 1.8vw, 20px);
    line-height: 1.7;
    color: #2a1f18;
    overflow-x: hidden;
    background: #f2ece4;
}

/* --- Palette Variables --- */
:root {
    --surface: #f2ece4;
    --limestone: #e0d5c1;
    --sandstone: #c4a882;
    --terracotta: #a0674b;
    --iron-oxide: #6b3d2e;
    --anthracite: #2e2220;
    --core: #1a1410;
    --magma: #c9541a;
    --selenite: #d4cfc8;
    --chalk: #f5f0ea;
    --peat: #2a1f18;
    --muted: #b8a99a;
}

/* --- Typography --- */
h1, h2 {
    font-family: 'Libre Bodoni', serif;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1.15;
}

.stratum-title {
    font-size: clamp(32px, 5vw, 72px);
}

p {
    max-width: 38em;
}

/* --- Depth Indicator --- */
#depth-indicator {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    height: 60vh;
    width: 30px;
    z-index: 100;
    pointer-events: none;
}

#depth-line {
    position: absolute;
    right: 14px;
    top: 0;
    width: 2px;
    height: 100%;
    background: #b8a99a;
    opacity: 0.5;
    transition: background-color 0.4s ease;
}

#depth-marker {
    position: absolute;
    right: 9px;
    top: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #f2ece4;
    border: 2px solid #b8a99a;
    transition: top 0.15s ease-out, background-color 0.3s ease, border-color 0.3s ease;
}

#depth-labels {
    position: absolute;
    right: 28px;
    top: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.depth-label {
    font-family: 'Inconsolata', monospace;
    font-size: 9px;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #b8a99a;
    opacity: 0.6;
    white-space: nowrap;
    text-align: right;
    transition: opacity 0.3s ease, color 0.4s ease;
}

.depth-label.active {
    opacity: 1;
}

/* --- Stratum Sections (shared) --- */
.stratum {
    position: relative;
    min-height: 100vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stratum-content {
    padding: 8vh 8vw;
    position: relative;
    z-index: 2;
}

.stratum-content-odd {
    padding-left: 15vw;
    padding-right: 8vw;
}

.stratum-content-even {
    padding-right: 15vw;
    padding-left: 8vw;
}

.stratum-title-wrap {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 3vh 8vw 2vh;
    will-change: transform;
}

.stratum[data-stratum="1"] .stratum-title-wrap,
.stratum[data-stratum="3"] .stratum-title-wrap,
.stratum[data-stratum="5"] .stratum-title-wrap {
    padding-left: 15vw;
}

.stratum[data-stratum="2"] .stratum-title-wrap,
.stratum[data-stratum="4"] .stratum-title-wrap {
    padding-left: 8vw;
}

/* --- Transition Zones --- */
.transition-zone {
    height: 15vh;
    position: relative;
    z-index: 1;
}

.transition-zone[data-from="0"][data-to="1"] {
    background: linear-gradient(to bottom, #f2ece4, #e0d5c1);
}
.transition-zone[data-from="1"][data-to="2"] {
    background: linear-gradient(to bottom, #e0d5c1, #c4a882);
}
.transition-zone[data-from="2"][data-to="3"] {
    background: linear-gradient(to bottom, #c4a882, #a0674b);
}
.transition-zone[data-from="3"][data-to="4"] {
    background: linear-gradient(to bottom, #a0674b, #6b3d2e);
}
.transition-zone[data-from="4"][data-to="5"] {
    background: linear-gradient(to bottom, #6b3d2e, #2e2220);
}
.transition-zone[data-from="5"][data-to="6"] {
    background: linear-gradient(to bottom, #2e2220, #1a1410);
}

/* =====================
   SURFACE LAYER
   ===================== */
#surface {
    background-color: #f2ece4;
    min-height: 100vh;
    /* Dot stipple texture at 4% opacity */
    background-image: radial-gradient(circle, rgba(184, 169, 154, 0.04) 1px, transparent 1px);
    background-size: 3px 3px;
}

#surface .stratum-content {
    padding: 0;
}

.surface-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

.surface-title {
    font-size: clamp(80px, 15vw, 200px);
    color: #2a1f18;
    position: relative;
    z-index: 2;
    /* Partial burial: clip bottom portion of the text below the horizon line */
    clip-path: inset(0 0 35% 0);
    transform: translateY(15vh);
    letter-spacing: 0.02em;
}

.horizon-line {
    position: absolute;
    top: 60%;
    left: 0;
    width: 100%;
    height: 1px;
    background: #b8a99a;
    z-index: 3;
}

.scroll-invite {
    position: absolute;
    bottom: 8vh;
    z-index: 4;
    animation: pulseDown 3s ease-in-out infinite;
}

@keyframes pulseDown {
    0%, 100% {
        transform: translateY(0);
        opacity: 0.6;
    }
    50% {
        transform: translateY(10px);
        opacity: 1;
    }
}

/* =====================
   STRATUM 1: LIMESTONE
   ===================== */
#stratum-1 {
    background-color: #e0d5c1;
    color: #2a1f18;
    min-height: 100vh;
    /* Horizontal hairline rules at 8% opacity */
    background-image: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent 39px,
        rgba(196, 168, 130, 0.08) 39px,
        rgba(196, 168, 130, 0.08) 40px
    );
}

#stratum-1 .stratum-title {
    color: #2a1f18;
}

/* =====================
   STRATUM 2: SANDSTONE
   ===================== */
#stratum-2 {
    background-color: #c4a882;
    color: #2a1f18;
    min-height: 90vh;
    /* Diagonal crosshatch at 5% opacity */
    background-image:
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 19px,
            rgba(42, 31, 24, 0.05) 19px,
            rgba(42, 31, 24, 0.05) 20px
        ),
        repeating-linear-gradient(
            -45deg,
            transparent,
            transparent 19px,
            rgba(42, 31, 24, 0.05) 19px,
            rgba(42, 31, 24, 0.05) 20px
        );
}

#stratum-2 .stratum-title {
    color: #2a1f18;
}

/* =====================
   STRATUM 3: TERRACOTTA
   ===================== */
#stratum-3 {
    background-color: #a0674b;
    color: #f5f0ea;
    min-height: 100vh;
    /* Irregular grain via layered radial gradients simulating a 200x200 tile */
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(107, 61, 46, 0.3) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(107, 61, 46, 0.2) 0%, transparent 40%),
        radial-gradient(ellipse at 50% 80%, rgba(107, 61, 46, 0.25) 0%, transparent 45%),
        radial-gradient(circle at 30% 30%, rgba(42, 31, 24, 0.1) 0%, transparent 30%),
        radial-gradient(circle at 70% 70%, rgba(42, 31, 24, 0.08) 0%, transparent 25%);
    background-size: 200px 200px;
}

#stratum-3 .stratum-title {
    color: #f5f0ea;
}

/* =====================
   STRATUM 4: IRON OXIDE
   ===================== */
#stratum-4 {
    background-color: #6b3d2e;
    color: #f5f0ea;
    min-height: 90vh;
    /* Vertical striations with varying widths at 6% opacity */
    background-image:
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 18px,
            rgba(245, 240, 234, 0.06) 18px,
            rgba(245, 240, 234, 0.06) 19px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 43px,
            rgba(245, 240, 234, 0.04) 43px,
            rgba(245, 240, 234, 0.04) 46px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 71px,
            rgba(245, 240, 234, 0.03) 71px,
            rgba(245, 240, 234, 0.03) 73px
        );
}

#stratum-4 .stratum-title {
    color: #f5f0ea;
}

/* =====================
   STRATUM 5: ANTHRACITE
   ===================== */
#stratum-5 {
    background-color: #2e2220;
    color: #f5f0ea;
    min-height: 80vh;
    /* Near-solid with faint horizontal banding */
    background-image: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent 79px,
        rgba(245, 240, 234, 0.02) 79px,
        rgba(245, 240, 234, 0.02) 80px
    );
}

#stratum-5 .stratum-title {
    color: #f5f0ea;
}

/* =====================
   CORE SECTION
   ===================== */
#core {
    background-color: #1a1410;
    color: #f5f0ea;
    min-height: 100vh;
}

.core-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 100vh;
    position: relative;
    padding: 8vh 8vw;
}

.magma-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: radial-gradient(circle, #c9541a 0%, rgba(201, 84, 26, 0.3) 40%, transparent 70%);
    opacity: 0.4;
    animation: magmaPulse 8s ease-in-out infinite;
    z-index: 1;
    pointer-events: none;
}

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

.core-title {
    font-size: clamp(28px, 4vw, 56px);
    color: #f5f0ea;
    margin-bottom: 3vh;
    position: relative;
    z-index: 2;
}

.core-text {
    color: #d4cfc8;
    max-width: 32em;
    position: relative;
    z-index: 2;
    opacity: 0.85;
}

/* =====================
   ARTIFACTS
   ===================== */
.artifact-container {
    margin-top: 6vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.artifact-svg {
    width: 100%;
    max-width: 400px;
    height: auto;
}

/* Crystal cluster: circle clip reveal from center */
#artifact-crystal .artifact-svg {
    clip-path: circle(0% at 50% 50%);
    transition: clip-path 0.6s ease-out;
}

#artifact-crystal.revealed .artifact-svg {
    clip-path: circle(60% at 50% 50%);
}

/* Ammonite: stroke-dashoffset draw */
.ammonite-spiral {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
}

/* Root network: inset clip reveal top-to-bottom */
#artifact-roots .artifact-svg {
    clip-path: inset(100% 0 0 0);
    transition: clip-path 0.8s ease-out;
}

#artifact-roots.revealed .artifact-svg {
    clip-path: inset(0 0 0 0);
}

/* Mineral vein: stroke-dashoffset draw left-to-right */
.artifact-vein-svg {
    width: 100%;
    max-width: 100%;
    height: 200px;
}

.mineral-vein {
    stroke-dasharray: 1400;
    stroke-dashoffset: 1400;
}

/* Magma chamber */
.magma-chamber {
    width: 250px;
    height: 250px;
    border-radius: 45% 55% 60% 40% / 50% 45% 55% 50%;
    background: radial-gradient(circle, #c9541a 0%, rgba(201, 84, 26, 0.4) 45%, transparent 70%);
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
    animation: morphBlob 12s ease-in-out infinite;
}

#artifact-magma.revealed .magma-chamber {
    opacity: 0.8;
    transform: scale(1);
}

@keyframes morphBlob {
    0% {
        border-radius: 45% 55% 60% 40% / 50% 45% 55% 50%;
    }
    25% {
        border-radius: 55% 45% 50% 50% / 40% 60% 40% 60%;
    }
    50% {
        border-radius: 50% 50% 45% 55% / 55% 50% 50% 45%;
    }
    75% {
        border-radius: 40% 60% 55% 45% / 50% 40% 60% 50%;
    }
    100% {
        border-radius: 45% 55% 60% 40% / 50% 45% 55% 50%;
    }
}

/* =====================
   MOBILE RESPONSIVE
   ===================== */
@media (max-width: 768px) {
    .stratum-content-odd,
    .stratum-content-even {
        padding-left: 6vw;
        padding-right: 6vw;
    }

    .stratum[data-stratum="1"] .stratum-title-wrap,
    .stratum[data-stratum="2"] .stratum-title-wrap,
    .stratum[data-stratum="3"] .stratum-title-wrap,
    .stratum[data-stratum="4"] .stratum-title-wrap,
    .stratum[data-stratum="5"] .stratum-title-wrap {
        padding-left: 6vw;
        padding-right: 6vw;
    }

    .stratum-title {
        font-size: clamp(24px, 8vw, 48px);
    }

    #depth-indicator {
        display: none;
    }

    .artifact-svg {
        max-width: 240px;
    }

    .artifact-vein-svg {
        max-width: 100%;
        height: 120px;
    }

    .magma-chamber {
        width: 150px;
        height: 150px;
    }

    .surface-title {
        font-size: clamp(48px, 15vw, 120px);
    }

    .magma-glow {
        width: 200px;
        height: 200px;
    }
}
