/* =============================================
   bada.city - Drowned City Underwater Metropolis
   ============================================= */

/* --- CSS Custom Properties --- */
:root {
    --abyssal-ink: #040810;
    --bathyal-blue: #0b1a2e;
    --twilight-indigo: #162a45;
    --bioluminescent-teal: #00b8a9;
    --coral-amber: #d4956a;
    --anemone-violet: #7b5ea7;
    --sea-foam-silver: #c8d8e4;
    --kelp-sage: #6a8f7a;
    --sonar-green: #4a7a8a;

    --current-depth: 0;
    --bg-color: #162a45;
}

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

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

body {
    font-family: 'Lora', Georgia, serif;
    font-weight: 400;
    font-size: 18px;
    line-height: 1.8;
    color: var(--sea-foam-silver);
    background-color: var(--bg-color);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Typography --- */
.city-title {
    font-family: 'Playfair Display', 'Georgia', serif;
    font-weight: 700;
    font-size: clamp(3rem, 7vw, 6.5rem);
    font-variant: small-caps;
    letter-spacing: 0.12em;
    color: var(--sea-foam-silver);
    text-shadow: 0 0 40px rgba(0, 184, 169, 0.2), 0 0 80px rgba(0, 184, 169, 0.1);
}

.section-title {
    font-family: 'Playfair Display', 'Georgia', serif;
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 4rem);
    font-variant: small-caps;
    letter-spacing: 0.12em;
    color: var(--sea-foam-silver);
    text-shadow: 0 0 30px rgba(0, 184, 169, 0.15);
    margin-bottom: 1.5rem;
}

.carved-title {
    font-family: 'Playfair Display', 'Georgia', serif;
    font-weight: 900;
    font-size: clamp(2.5rem, 6vw, 5.5rem);
    font-variant: small-caps;
    letter-spacing: 0.15em;
    color: var(--sea-foam-silver);
    text-shadow:
        0 0 30px rgba(0, 184, 169, 0.1),
        2px 2px 4px rgba(0, 0, 0, 0.8),
        -1px -1px 2px rgba(200, 216, 228, 0.1);
    text-align: center;
}

.depth-label {
    font-family: 'IBM Plex Mono', 'Courier New', monospace;
    font-weight: 300;
    font-size: 12px;
    letter-spacing: 0.2em;
    color: var(--sonar-green);
    text-transform: uppercase;
}

.depth-marker {
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 50;
    text-align: right;
}

.upper-marker {
    position: relative;
    top: auto;
    right: auto;
    text-align: left;
    margin-bottom: 3rem;
    margin-left: 10%;
}

p {
    color: var(--sea-foam-silver);
    text-shadow: 0 0 20px rgba(0, 150, 180, 0.15);
    max-width: 60ch;
}

.coral-text {
    color: var(--coral-amber);
    text-shadow: 0 0 20px rgba(212, 149, 106, 0.15);
}

.closing-text {
    font-family: 'Playfair Display', 'Georgia', serif;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    font-weight: 700;
    font-style: italic;
    line-height: 1.6;
    text-align: center;
    color: var(--sea-foam-silver);
    text-shadow: 0 0 40px rgba(0, 184, 169, 0.15);
    max-width: 40ch;
    margin: 0 auto;
}

/* --- Sections / Layout --- */
.depth-section {
    position: relative;
    width: 100%;
    overflow: hidden;
}

#surface-canopy {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#upper-towers {
    min-height: 200vh;
    padding: 10vh 5%;
}

#inhabited-zone {
    min-height: 250vh;
    padding: 10vh 5%;
}

#deep-foundation {
    min-height: 250vh;
    padding: 10vh 5%;
}

#abyss-floor {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.section-content {
    position: relative;
    z-index: 10;
    padding: 5vh 0;
}

.abyss-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    width: 100%;
}

/* --- Surface Canopy --- */
.surface-content {
    position: relative;
    z-index: 10;
    text-align: center;
}

.surface-ripples {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 30%;
    overflow: hidden;
    z-index: 5;
}

.ripple-light {
    position: absolute;
    width: 200%;
    height: 100%;
    background: repeating-linear-gradient(
        90deg,
        transparent 0%,
        rgba(0, 184, 169, 0.03) 2%,
        transparent 4%,
        rgba(200, 216, 228, 0.02) 6%,
        transparent 8%
    );
    animation: ripple-drift linear infinite;
}

.r1 { top: 0; animation-duration: 12s; opacity: 0.8; }
.r2 { top: 5%; animation-duration: 15s; animation-delay: -3s; opacity: 0.6; }
.r3 { top: 10%; animation-duration: 18s; animation-delay: -7s; opacity: 0.5; }
.r4 { top: 15%; animation-duration: 20s; animation-delay: -11s; opacity: 0.4; }
.r5 { top: 20%; animation-duration: 25s; animation-delay: -5s; opacity: 0.3; }

@keyframes ripple-drift {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* --- Title Letter Animation --- */
.title-letter {
    display: inline-block;
    opacity: 0;
    animation: letter-appear 0.8s ease-out forwards;
    animation-delay: calc(var(--delay) * 0.15s + 0.5s);
}

@keyframes letter-appear {
    0% {
        opacity: 0;
        transform: translateX(10px) translateY(5px);
        filter: blur(4px);
    }
    100% {
        opacity: 1;
        transform: translateX(0) translateY(0);
        filter: blur(0);
    }
}

/* gentle horizontal drift after appearing */
.title-letter {
    animation: letter-appear 0.8s ease-out forwards, letter-drift 6s ease-in-out infinite;
    animation-delay: calc(var(--delay) * 0.15s + 0.5s), calc(var(--delay) * 0.15s + 1.3s);
}

@keyframes letter-drift {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(calc(var(--delay) * 1px - 4px)); }
}

/* --- Jellyfish Chevron --- */
#jellyfish-chevron {
    position: absolute;
    bottom: 10vh;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    animation: jellyfish-bob 3s ease-in-out infinite;
    cursor: pointer;
}

.jellyfish-svg {
    width: 60px;
    height: 80px;
}

.jelly-tentacle {
    animation: tentacle-sway 4s ease-in-out infinite;
}

.t1 { animation-delay: 0s; }
.t2 { animation-delay: 0.3s; }
.t3 { animation-delay: 0.6s; }
.t4 { animation-delay: 0.9s; }
.t5 { animation-delay: 1.2s; }

@keyframes jellyfish-bob {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-15px); }
}

@keyframes tentacle-sway {
    0%, 100% { transform: translateX(0) scaleY(1); }
    25% { transform: translateX(3px) scaleY(0.95); }
    75% { transform: translateX(-3px) scaleY(1.05); }
}

.jelly-chevron {
    animation: chevron-pulse 2s ease-in-out infinite;
}

@keyframes chevron-pulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 0.3; }
}

/* --- Building Silhouettes --- */
.building-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.building-silhouette {
    position: absolute;
    height: 60%;
    width: auto;
}

.building-silhouette.near {
    z-index: 4;
    height: 70%;
    opacity: 0.95;
}

.building-silhouette.mid {
    z-index: 3;
    height: 55%;
    opacity: 0.8;
    filter: blur(1px);
}

.building-silhouette.far {
    z-index: 2;
    height: 45%;
    opacity: 0.6;
    filter: blur(2px);
}

.building-silhouette.farthest {
    z-index: 1;
    height: 35%;
    opacity: 0.4;
    filter: blur(3px);
}

.building-silhouette.distant {
    z-index: 1;
    height: 40%;
    opacity: 0.5;
    filter: blur(2px);
}

.building-silhouette.dark {
    opacity: 1;
}

/* --- Building Windows --- */
.bldg-window {
    fill: rgba(0, 184, 169, 0.05);
    transition: fill 0.3s ease, filter 0.3s ease;
}

.bldg-window.glow {
    fill: rgba(0, 184, 169, 0.12);
}

.bldg-window.bio {
    fill: rgba(0, 184, 169, 0.2);
    animation: bio-pulse 4s ease-in-out infinite;
}

.bldg-window.dim {
    fill: rgba(0, 184, 169, 0.03);
}

.bldg-window.sonar-lit {
    fill: rgba(0, 184, 169, 0.7);
    filter: drop-shadow(0 0 8px rgba(0, 184, 169, 0.6));
}

@keyframes bio-pulse {
    0%, 100% { fill: rgba(0, 184, 169, 0.15); }
    50% { fill: rgba(0, 184, 169, 0.35); }
}

/* stagger bio-pulse for different windows */
.bldg-window.bio:nth-child(odd) { animation-delay: -1s; }
.bldg-window.bio:nth-child(3n) { animation-delay: -2.5s; }
.bldg-window.bio:nth-child(4n) { animation-delay: -0.5s; }
.bldg-window.bio:nth-child(5n) { animation-delay: -3s; }

/* --- Text Panels --- */
.text-panel {
    max-width: 55%;
    padding: 2rem 2.5rem;
    position: relative;
    z-index: 15;
}

.glass-panel {
    background: rgba(11, 26, 46, 0.4);
    border: 1px solid rgba(0, 184, 169, 0.1);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    border-radius: 2px;
}

.stone-panel {
    background: rgba(4, 8, 16, 0.6);
    border: 1px solid rgba(106, 143, 122, 0.1);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    position: relative;
}

.stone-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(106, 143, 122, 0.05) 1px, transparent 1px),
        radial-gradient(circle at 60% 70%, rgba(106, 143, 122, 0.04) 1px, transparent 1px),
        radial-gradient(circle at 80% 20%, rgba(106, 143, 122, 0.03) 2px, transparent 2px);
    pointer-events: none;
}

.stone-inscription {
    text-align: center;
    padding: 5vh 5%;
    position: relative;
    z-index: 15;
}

/* --- Text Reveal Animation --- */
.reveal-text {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.reveal-text.visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- Diving Tether --- */
#diving-tether {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    opacity: 0.6;
}

/* --- Vignette Overlay --- */
#vignette-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    background: radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

/* --- Korean Typographic Ghosts --- */
#korean-ghosts {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 800vh;
    pointer-events: none;
    z-index: 1;
}

.ghost-char {
    position: absolute;
    font-family: 'Playfair Display', serif;
    color: var(--twilight-indigo);
    opacity: 0.06;
    user-select: none;
    line-height: 1;
}

/* --- Bathymetric Contour Lines --- */
#contour-lines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    opacity: 0.5;
}

.contour-svg {
    position: absolute;
    width: 100%;
    height: 60px;
}

.contour-line {
    stroke: var(--kelp-sage);
    stroke-width: 1;
    stroke-opacity: 0.2;
    fill: none;
    animation: contour-flow 20s linear infinite;
}

.contour-line.bright {
    stroke-opacity: 0.3;
}

@keyframes contour-flow {
    0% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: -200; }
}

.contour-line {
    stroke-dasharray: 200 100;
}

/* --- Sonar Pulse --- */
.sonar-trigger {
    position: absolute;
    width: 1px;
    height: 1px;
    left: 50%;
    top: 80%;
    z-index: 1;
}

.sonar-pulse-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 20;
}

.sonar-ring {
    position: absolute;
    border-radius: 50%;
    border: 1px solid var(--bioluminescent-teal);
    animation: sonar-expand 2.5s ease-out forwards;
    pointer-events: none;
}

.sonar-ring:nth-child(2) { animation-delay: 0.2s; }
.sonar-ring:nth-child(3) { animation-delay: 0.4s; }

@keyframes sonar-expand {
    0% {
        width: 0;
        height: 0;
        opacity: 0.6;
    }
    100% {
        width: 800px;
        height: 800px;
        opacity: 0;
    }
}

/* --- Searchlight Effect --- */
#searchlight {
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(200, 216, 228, 0.06) 0%, transparent 70%);
    pointer-events: none;
    z-index: 8;
    top: 50%;
    left: 30%;
    animation: searchlight-sweep 12s ease-in-out infinite;
}

@keyframes searchlight-sweep {
    0% { transform: translate(0, 0); }
    25% { transform: translate(40vw, -10vh); }
    50% { transform: translate(20vw, 15vh); }
    75% { transform: translate(-10vw, 5vh); }
    100% { transform: translate(0, 0); }
}

/* --- Stone Texture Overlay --- */
.stone-texture-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(106, 143, 122, 0.03) 2px, transparent 2px),
        radial-gradient(circle at 30% 50%, rgba(106, 143, 122, 0.02) 3px, transparent 3px),
        radial-gradient(circle at 50% 80%, rgba(106, 143, 122, 0.03) 1px, transparent 1px),
        radial-gradient(circle at 70% 30%, rgba(106, 143, 122, 0.02) 2px, transparent 2px),
        radial-gradient(circle at 90% 60%, rgba(106, 143, 122, 0.03) 2px, transparent 2px);
    background-size: 100px 100px, 150px 150px, 80px 80px, 120px 120px, 90px 90px;
}

/* --- Abyss Floor --- */
.city-underside {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 2;
}

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

#abyss-lights {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
}

.abyss-light {
    position: absolute;
    width: 3px;
    height: 3px;
    background: var(--bioluminescent-teal);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--bioluminescent-teal), 0 0 15px rgba(0, 184, 169, 0.3);
    animation: abyss-blink 5s ease-in-out infinite;
}

.abyss-light:nth-child(2) { animation-delay: -1.5s; animation-duration: 7s; }
.abyss-light:nth-child(3) { animation-delay: -3s; animation-duration: 4s; }
.abyss-light:nth-child(4) { animation-delay: -0.8s; animation-duration: 6s; }
.abyss-light:nth-child(5) { animation-delay: -2.5s; animation-duration: 8s; }
.abyss-light:nth-child(6) { animation-delay: -4s; animation-duration: 5.5s; }
.abyss-light:nth-child(7) { animation-delay: -1.2s; animation-duration: 9s; }
.abyss-light:nth-child(8) { animation-delay: -3.5s; animation-duration: 6.5s; }

@keyframes abyss-blink {
    0%, 100% { opacity: 0; }
    30% { opacity: 0.8; }
    50% { opacity: 0.3; }
    70% { opacity: 0.9; }
}

.abyss-meditation {
    position: relative;
    z-index: 15;
    padding: 2rem;
}

/* --- Return to Surface --- */
#return-surface {
    margin-top: 5vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    z-index: 20;
    position: relative;
    animation: jellyfish-bob 3s ease-in-out infinite reverse;
}

.return-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 11px;
    letter-spacing: 0.3em;
    color: var(--sonar-green);
    opacity: 0.6;
}

.jellyfish-svg.return {
    width: 40px;
    height: 60px;
}

/* --- Parallax Layer Base --- */
.parallax-layer {
    will-change: transform;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .text-panel {
        max-width: 90% !important;
        margin-left: 5% !important;
        padding: 1.5rem;
    }

    .city-title {
        font-size: clamp(2rem, 10vw, 4rem);
    }

    .section-title {
        font-size: clamp(1.5rem, 5vw, 2.5rem);
    }

    .carved-title {
        font-size: clamp(1.8rem, 8vw, 3.5rem);
    }

    .building-silhouette {
        opacity: 0.5;
    }

    .closing-text {
        font-size: clamp(1.2rem, 4vw, 2rem);
    }

    .ghost-char {
        opacity: 0.03;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 16px;
    }

    .text-panel {
        padding: 1rem 1.2rem;
    }

    .depth-marker {
        top: 10px;
        right: 10px;
    }
}
