/* ============================================
   확률.com — Meditative Aquarium Library
   Palette: Sepia-Nostalgic with Aquarium Depth
   ============================================ */

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

:root {
    --aged-parchment: #F5ECD7;
    --deep-tank: #1A2F3E;
    --warm-hide: #D4C4A8;
    --ink-walnut: #3B2A1A;
    --slate-depth: #C8D6DF;
    --burnt-sienna: #A0522D;
    --caustic-teal: #5BA4A4;
    --goldfish: #D4943A;
    --umber-dark: #2A1F14;
    --deep-edge: #0F1F2A;
    --grain-tone: #C0AD8E;
    --hide-variation: #B89C7A;
    --parchment-dark: #EDE0C8;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.6vw, 1.125rem);
    line-height: 1.78;
    letter-spacing: 0.015em;
    color: var(--ink-walnut);
    background: linear-gradient(to bottom, var(--aged-parchment), var(--parchment-dark));
    background-attachment: fixed;
    overflow-x: hidden;
}

/* Leather texture background (CSS-only) */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background:
        repeating-radial-gradient(circle at 1px 1px, var(--grain-tone) 0px, transparent 1px) 0 0 / 4px 4px,
        radial-gradient(circle at 20% 30%, var(--hide-variation) 0px, transparent 16px) 0 0 / 200px 180px,
        radial-gradient(circle at 70% 60%, var(--hide-variation) 0px, transparent 12px) 50px 40px / 180px 200px,
        radial-gradient(circle at 40% 80%, var(--hide-variation) 0px, transparent 20px) 90px 70px / 220px 160px;
    opacity: 0.3;
}

/* ============================================
   Navigation Dots (Fish Eggs)
   ============================================ */

.nav-dots {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.nav-dots .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--caustic-teal);
    opacity: 0.6;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.nav-dots:hover .dot {
    opacity: 1;
    transform: scale(1.2);
}

.nav-menu {
    position: absolute;
    top: 50%;
    right: 50%;
    transform: translate(50%, -50%) scale(0);
    opacity: 0;
    background: rgba(26, 47, 62, 0.92);
    backdrop-filter: blur(8px);
    border-radius: 50%;
    width: 220px;
    height: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    transition: transform 0.5s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.4s ease;
    pointer-events: none;
}

.nav-dots:hover .nav-menu {
    transform: translate(50%, -50%) scale(1);
    opacity: 1;
    pointer-events: all;
    border-radius: 20px;
}

.nav-link {
    color: var(--slate-depth);
    text-decoration: none;
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 300;
    font-size: 0.85rem;
    letter-spacing: 0.03em;
    transition: color 0.3s ease;
    white-space: nowrap;
}

.nav-link:hover {
    color: var(--goldfish);
}

/* ============================================
   Hero Section — The Tank Wall
   ============================================ */

.hero {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    z-index: 1;
}

.leather-bg {
    position: absolute;
    inset: 0;
    background:
        repeating-radial-gradient(circle at 1px 1px, var(--grain-tone) 0px, transparent 1px) 0 0 / 4px 4px,
        radial-gradient(circle at 30% 40%, var(--hide-variation) 0px, transparent 18px) 0 0 / 200px 200px,
        radial-gradient(circle at 60% 70%, var(--hide-variation) 0px, transparent 14px) 60px 50px / 180px 180px,
        linear-gradient(to bottom, var(--warm-hide), var(--grain-tone));
    z-index: 0;
}

.blob-viewport {
    position: relative;
    width: 70vw;
    height: 65vh;
    z-index: 2;
    animation: blobBreathe 12s ease-in-out infinite;
    clip-path: polygon(
        50% 2%, 72% 5%, 90% 15%, 97% 35%,
        95% 58%, 88% 78%, 70% 92%, 50% 98%,
        30% 92%, 12% 78%, 5% 58%, 3% 35%,
        10% 15%, 28% 5%
    );
}

@keyframes blobBreathe {
    0%, 100% {
        clip-path: polygon(
            50% 2%, 72% 5%, 90% 15%, 97% 35%,
            95% 58%, 88% 78%, 70% 92%, 50% 98%,
            30% 92%, 12% 78%, 5% 58%, 3% 35%,
            10% 15%, 28% 5%
        );
    }
    50% {
        clip-path: polygon(
            50% 3%, 74% 6%, 91% 17%, 98% 37%,
            96% 60%, 89% 79%, 71% 93%, 50% 97%,
            29% 93%, 11% 77%, 4% 57%, 2% 33%,
            9% 14%, 27% 4%
        );
    }
}

.tank-interior {
    position: relative;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, var(--deep-tank), var(--deep-edge));
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.hero-title {
    position: relative;
    z-index: 10;
    text-align: center;
}

.hero-title h1 {
    font-family: 'DM Serif Display', serif;
    font-weight: 400;
    font-size: clamp(3.5rem, 8vw + 1rem, 7rem);
    letter-spacing: -0.02em;
    color: var(--aged-parchment);
    text-shadow: 0 0 40px rgba(212, 148, 58, 0.3);
    line-height: 1.1;
}

.hero-title .subtitle {
    font-family: 'DM Serif Display', serif;
    font-weight: 400;
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    color: var(--slate-depth);
    letter-spacing: 0.05em;
    margin-top: -0.2em;
}

.hero-title .tagline {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 300;
    font-size: 1.2rem;
    color: var(--slate-depth);
    margin-top: 1rem;
    letter-spacing: 0.05em;
}

/* ============================================
   Fish Styles
   ============================================ */

.fish {
    position: absolute;
    will-change: transform;
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
    z-index: 5;
}

.angelfish {
    width: 25px;
    height: 30px;
}

.tang {
    width: 30px;
    height: 18px;
}

.lionfish {
    width: 30px;
    height: 30px;
}

.fish-1 { top: 20%; left: 10%; animation: swimRight 18s linear infinite; animation-delay: -2s; }
.fish-2 { top: 55%; left: 80%; animation: swimLeft 22s linear infinite; animation-delay: -5s; }
.fish-3 { top: 35%; left: 50%; animation: swimRight 15s linear infinite; animation-delay: -8s; }
.fish-4 { top: 70%; left: 20%; animation: swimLeft 20s linear infinite; animation-delay: -12s; }
.fish-5 { top: 80%; left: 90%; animation: swimLeft 25s linear infinite; animation-delay: -3s; }
.fish-6 { top: 15%; left: 65%; animation: swimRight 17s linear infinite; animation-delay: -7s; }
.fish-7 { top: 45%; left: 35%; animation: swimLeft 19s linear infinite; animation-delay: -10s; }
.fish-8 { top: 60%; left: 75%; animation: swimRight 23s linear infinite; animation-delay: -15s; }

@keyframes swimRight {
    0%   { transform: translateX(-120px) translateY(0) scaleX(1); }
    25%  { transform: translateX(40px) translateY(-15px) scaleX(1); }
    50%  { transform: translateX(160px) translateY(10px) scaleX(1); }
    75%  { transform: translateX(80px) translateY(-8px) scaleX(1); }
    100% { transform: translateX(-120px) translateY(0) scaleX(1); }
}

@keyframes swimLeft {
    0%   { transform: translateX(120px) translateY(0) scaleX(-1); }
    25%  { transform: translateX(-30px) translateY(12px) scaleX(-1); }
    50%  { transform: translateX(-150px) translateY(-8px) scaleX(-1); }
    75%  { transform: translateX(-60px) translateY(15px) scaleX(-1); }
    100% { transform: translateX(120px) translateY(0) scaleX(-1); }
}

/* Drifting fish in breathing spaces */
.drifting-fish {
    position: absolute;
    z-index: 2;
}

.drift-1 {
    width: 20px;
    top: 40%;
    animation: driftAcross 25s linear infinite;
}

.drift-2 {
    width: 24px;
    top: 50%;
    animation: driftAcrossReverse 20s linear infinite;
    animation-delay: -5s;
}

.drift-3 {
    width: 18px;
    top: 35%;
    animation: driftAcross 22s linear infinite;
    animation-delay: -8s;
}

.drift-4 {
    width: 22px;
    top: 55%;
    animation: driftAcrossReverse 18s linear infinite;
    animation-delay: -3s;
}

@keyframes driftAcross {
    0%   { left: -5%; opacity: 0; }
    10%  { opacity: 0.4; }
    90%  { opacity: 0.4; }
    100% { left: 105%; opacity: 0; }
}

@keyframes driftAcrossReverse {
    0%   { left: 105%; opacity: 0; }
    10%  { opacity: 0.4; }
    90%  { opacity: 0.4; }
    100% { left: -5%; opacity: 0; }
}

/* ============================================
   Caustic Light Patterns
   ============================================ */

.caustic-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

.caustic-1 {
    background: radial-gradient(ellipse at 30% 40%, rgba(91, 164, 164, 0.15) 0%, transparent 50%);
    animation: causticMove1 25s ease-in-out infinite;
}

.caustic-2 {
    background: radial-gradient(ellipse at 70% 60%, rgba(91, 164, 164, 0.12) 0%, transparent 45%);
    animation: causticMove2 33s ease-in-out infinite;
}

.caustic-3 {
    background: radial-gradient(ellipse at 50% 30%, rgba(91, 164, 164, 0.1) 0%, transparent 40%);
    animation: causticMove3 28s ease-in-out infinite;
}

@keyframes causticMove1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, 20px) scale(1.1); }
    66% { transform: translate(-20px, -15px) scale(0.95); }
}

@keyframes causticMove2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(-25px, 15px) scale(1.08); }
    66% { transform: translate(20px, -20px) scale(1.05); }
}

@keyframes causticMove3 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(15px, -25px) scale(1.12); }
}

/* ============================================
   Breathing Space
   ============================================ */

.breathing-space {
    position: relative;
    height: 12vh;
    z-index: 1;
    overflow: hidden;
}

.breathing-space-final {
    height: 8vh;
}

/* ============================================
   Content Sections
   ============================================ */

.content-section {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: center;
    padding: 0;
}

.blob-container {
    position: relative;
    width: 100%;
    padding: 8vh 0;
    overflow: hidden;
}

.section-content {
    max-width: clamp(20rem, 60vw, 42.5rem);
    margin: 0 auto;
    padding: 4rem 2rem;
    position: relative;
    z-index: 5;
}

.section-content h2 {
    font-family: 'DM Serif Display', serif;
    font-weight: 400;
    font-size: clamp(2rem, 4vw + 0.5rem, 3.5rem);
    letter-spacing: -0.02em;
    margin-bottom: 1.6em;
    line-height: 1.2;
}

.section-content p {
    margin-bottom: 1.6em;
}

.section-content blockquote {
    margin: 2.4em 0;
    padding-left: 1.5em;
    border-left: 3px solid var(--burnt-sienna);
}

.section-content blockquote p {
    font-family: 'DM Serif Display', serif;
    font-style: italic;
    font-size: clamp(1.1rem, 2vw, 1.4rem);
    line-height: 1.6;
    color: var(--burnt-sienna);
}

/* Scroll-triggered reveal */
.reveal {
    opacity: 0;
    transition: opacity 600ms ease;
}

.reveal.visible {
    opacity: 1;
}

/* ============================================
   Section 2: Bell Curve Room (Leather BG)
   ============================================ */

.bell-curve-section .blob-container {
    background:
        repeating-radial-gradient(circle at 1px 1px, var(--grain-tone) 0px, transparent 1px) 0 0 / 4px 4px,
        radial-gradient(circle at 25% 35%, var(--hide-variation) 0px, transparent 16px) 0 0 / 200px 180px,
        radial-gradient(circle at 65% 55%, var(--hide-variation) 0px, transparent 14px) 50px 40px / 180px 200px,
        linear-gradient(to bottom, var(--warm-hide), var(--grain-tone));
    clip-path: polygon(
        5% 8%, 15% 3%, 30% 1%, 50% 0%, 70% 1%, 85% 3%, 95% 8%,
        99% 20%, 100% 40%, 99% 60%, 97% 78%,
        90% 90%, 75% 96%, 60% 99%, 40% 99%, 25% 96%, 10% 90%,
        3% 78%, 1% 60%, 0% 40%, 1% 20%
    );
}

.bell-curve-section .section-content {
    color: var(--ink-walnut);
}

.bell-curve-section h2 {
    color: var(--ink-walnut);
}

/* ============================================
   Section 3: Deep Tank (Dark BG)
   ============================================ */

.deep-tank-section .blob-container {
    background: radial-gradient(ellipse at center, var(--deep-tank), var(--deep-edge));
    clip-path: polygon(
        0% 50%, 2% 30%, 6% 15%, 15% 5%, 30% 1%, 50% 0%,
        70% 2%, 85% 8%, 95% 20%, 100% 40%,
        100% 60%, 98% 75%, 92% 88%, 80% 95%,
        65% 99%, 45% 100%, 25% 98%, 12% 92%,
        4% 80%, 0% 65%
    );
}

.deep-tank-section .section-content {
    color: var(--slate-depth);
}

.deep-tank-section h2 {
    color: var(--aged-parchment);
}

.math {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9em;
    color: #5C4A3A;
    background: rgba(91, 164, 164, 0.1);
    padding: 0.15em 0.4em;
    border-radius: 3px;
}

.deep-tank-section .math {
    color: var(--caustic-teal);
    background: rgba(91, 164, 164, 0.15);
}

/* Fish Demo */
.fish-demo {
    position: relative;
    width: 100%;
    height: 180px;
    margin: 2rem 0;
    border-radius: 20px;
    background: rgba(15, 31, 42, 0.5);
    overflow: hidden;
}

.demo-fish {
    position: absolute;
    will-change: transform;
    transition: transform 1.5s cubic-bezier(0.23, 1, 0.32, 1);
}

.conditional-fish-a {
    width: 30px;
    height: 38px;
    top: 30%;
    left: 25%;
}

.conditional-fish-b {
    width: 30px;
    height: 38px;
    top: 40%;
    left: 40%;
}

.independent-fish {
    width: 35px;
    height: 22px;
    top: 55%;
    left: 70%;
}

.demo-label {
    position: absolute;
    bottom: 0.8rem;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 300;
    color: var(--slate-depth);
    opacity: 0.7;
}

/* ============================================
   Section 4: Rare Event Alcove (Leather BG)
   ============================================ */

.rare-event-section .blob-container {
    background:
        repeating-radial-gradient(circle at 1px 1px, var(--grain-tone) 0px, transparent 1px) 0 0 / 4px 4px,
        radial-gradient(circle at 40% 30%, var(--hide-variation) 0px, transparent 18px) 0 0 / 220px 190px,
        radial-gradient(circle at 75% 65%, var(--hide-variation) 0px, transparent 12px) 30px 50px / 190px 210px,
        linear-gradient(to bottom, var(--warm-hide), var(--grain-tone));
    clip-path: polygon(
        2% 30%, 4% 15%, 10% 5%, 22% 1%, 40% 0%, 55% 1%,
        70% 3%, 82% 8%, 92% 18%, 98% 32%,
        100% 50%, 99% 68%, 95% 82%, 88% 92%,
        76% 98%, 60% 100%, 42% 99%, 26% 95%,
        14% 88%, 6% 75%, 1% 58%, 0% 42%
    );
}

.rare-event-section .section-content {
    color: var(--ink-walnut);
}

.rare-event-section h2 {
    color: var(--ink-walnut);
}

.lionfish-drift {
    position: absolute;
    right: -60px;
    top: 30%;
    width: 50px;
    height: 50px;
    opacity: 0;
    z-index: 10;
    animation: lionfishDrift 20s ease-in-out infinite;
    animation-delay: 3s;
}

@keyframes lionfishDrift {
    0%   { transform: translateX(0); opacity: 0; }
    10%  { opacity: 0.8; }
    80%  { opacity: 0.8; }
    100% { transform: translateX(calc(-100vw + 60px)); opacity: 0; }
}

/* ============================================
   Section 5: Probability River (Dark BG)
   ============================================ */

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

.river-section .blob-container {
    background: radial-gradient(ellipse at center, var(--deep-tank), var(--deep-edge));
    clip-path: polygon(
        0% 15%, 5% 5%, 15% 1%, 30% 0%, 50% 0%,
        70% 0%, 85% 1%, 95% 5%, 100% 15%,
        100% 85%, 95% 95%, 85% 99%, 70% 100%,
        50% 100%, 30% 100%, 15% 99%, 5% 95%, 0% 85%
    );
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
}

.river-content {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 4rem 2rem;
    text-align: center;
}

#randomWalkCanvas {
    width: 100%;
    height: 300px;
    display: block;
    margin-bottom: 2rem;
}

.river-text {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 300;
    font-size: 1.2rem;
    color: var(--slate-depth);
    letter-spacing: 0.04em;
}

/* ============================================
   Mobile Responsive
   ============================================ */

@media (max-width: 640px) {
    .blob-viewport {
        width: 90vw;
        height: 60vh;
    }

    .section-content {
        max-width: 88vw;
        padding: 3rem 1.2rem;
    }

    .bell-curve-section .blob-container,
    .deep-tank-section .blob-container,
    .rare-event-section .blob-container {
        clip-path: ellipse(48% 48% at 50% 50%);
    }

    .river-section .blob-container {
        clip-path: polygon(
            0% 5%, 100% 5%, 100% 95%, 0% 95%
        );
    }

    .nav-dots {
        top: 1rem;
        right: 1rem;
    }

    .nav-menu {
        width: 180px;
        height: 180px;
    }

    .fish-demo {
        height: 140px;
    }

    .hero-title h1 {
        font-size: clamp(2.5rem, 12vw, 5rem);
    }
}
