/* ===========================
   hwagryul.com - Probability
   =========================== */

/* -- CSS Custom Properties -- */
:root {
    --bg-primary: #0B0E1A;
    --bg-secondary: #121830;
    --bg-tertiary: #1A2744;
    --bg-accent: #0D0A1A;
    --text-primary: #C4D4F0;
    --text-secondary: #A8B4CC;
    --text-tertiary: #7B9EC8;
    --accent-green: #3DDC84;
    --accent-pink: #E056A0;
    --accent-blue: #4A8FE7;
    --accent-gold: #D4A855;
    --lavender: #E8E0F0;
    --hex-border: #2A3A5C;

    --font-display: 'Instrument Serif', serif;
    --font-korean: 'Noto Serif KR', serif;
    --font-body: 'Lexend', sans-serif;
    --font-mono: 'DM Mono', monospace;
}

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

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

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-weight: 300;
    line-height: 1.85;
    letter-spacing: 0.01em;
    overflow-x: hidden;
}

/* -- Scroll Progress Bar -- */
#progress-bar {
    position: fixed;
    top: 0;
    right: 0;
    width: 3px;
    height: 0%;
    background: linear-gradient(180deg, #3DDC84 0%, #4A8FE7 50%, #E056A0 100%);
    z-index: 1000;
    transition: height 0.1s linear;
}

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

/* -- Zones -- */
.zone {
    position: relative;
    z-index: 1;
    overflow: hidden;
}

/* -- Watermarks -- */
.watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-korean);
    font-weight: 700;
    font-size: clamp(20rem, 40vw, 50rem);
    color: var(--text-primary);
    opacity: 0.03;
    pointer-events: none;
    user-select: none;
    z-index: 0;
    line-height: 1;
}

.watermark::after {
    content: attr(data-char);
}

/* ===========================
   Zone 1: The Coin Toss
   =========================== */
#zone-coin {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-primary);
    transition: background-color 1.5s ease;
}

#coin-svg-container {
    position: relative;
    width: clamp(300px, 50vw, 600px);
    height: clamp(300px, 50vw, 600px);
    z-index: 2;
}

#coin-svg {
    width: 100%;
    height: 100%;
}

#coin-svg circle {
    fill: var(--text-primary);
    transition: cx 0.05s, cy 0.05s;
}

#romanization {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(1rem, 2.5vw, 1.8rem);
    letter-spacing: 0.3em;
    text-transform: lowercase;
    color: var(--text-tertiary);
    opacity: 0;
    margin-top: 2rem;
    z-index: 2;
    transition: opacity 1.5s ease;
    font-feature-settings: "liga" 1, "onum" 1;
}

#romanization.visible {
    opacity: 1;
}

/* ===========================
   Zone 2: The Bell Curve Horizon
   =========================== */
#zone-bell {
    height: 150vh;
    background-color: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: background-color 1.5s ease;
}

#bell-curve-svg {
    position: absolute;
    bottom: 20%;
    left: 0;
    width: 100%;
    height: 50%;
    z-index: 1;
    opacity: 0;
    transition: opacity 1s ease;
}

#bell-curve-svg.visible {
    opacity: 1;
}

#cdf-percentage {
    position: absolute;
    top: 35%;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-mono);
    font-weight: 300;
    font-size: clamp(1.5rem, 3vw, 3rem);
    letter-spacing: 0.05em;
    color: var(--accent-gold);
    opacity: 0;
    z-index: 3;
    transition: opacity 0.5s ease;
}

#cdf-percentage.visible {
    opacity: 1;
}

#bell-text-container {
    position: relative;
    width: 100%;
    max-width: 1000px;
    padding: 0 2rem;
    z-index: 3;
}

.bell-text-block {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 1s ease, transform 1s ease;
    margin-bottom: 3rem;
}

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

.bell-text-center {
    text-align: center;
}

.bell-text-left {
    text-align: left;
    max-width: 400px;
}

.bell-text-right {
    text-align: right;
    max-width: 400px;
    margin-left: auto;
}

/* ===========================
   Zone 3: The Random Walk Garden
   =========================== */
#zone-walk {
    height: 150vh;
    background-color: var(--bg-secondary);
    position: relative;
    transition: background-color 1.5s ease;
}

#walk-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#walk-svg polyline {
    fill: none;
    stroke-width: 1;
    opacity: 0.3;
}

#walk-svg .walk-intersection {
    fill: var(--accent-blue);
    opacity: 0;
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { opacity: 0.2; r: 3; }
    50% { opacity: 0.7; r: 5; }
}

#walk-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

.walk-block {
    position: absolute;
    max-width: 320px;
    padding: 1.5rem 2rem;
    background: rgba(11, 14, 26, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    box-shadow: 0 0 40px rgba(74, 143, 231, 0.1);
    border: 1px solid rgba(42, 58, 92, 0.3);
    border-radius: 4px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1s ease, transform 1s ease;
}

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

/* ===========================
   Zone 4: The Dice Chamber
   =========================== */
#zone-dice {
    min-height: 150vh;
    background-color: var(--bg-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10vh 2rem;
    perspective: 800px;
    transition: background-color 1.5s ease;
}

#hex-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    perspective: 800px;
}

.hex-row {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.hex-row-offset {
    margin-left: 70px;
}

.hex-cell {
    width: 120px;
    height: 138px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: var(--bg-secondary);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform 0.4s ease, box-shadow 0.4s ease, background 0.4s ease;
    cursor: default;
}

.hex-cell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: linear-gradient(135deg, rgba(42, 58, 92, 0.5), rgba(18, 24, 48, 0.8));
    z-index: 0;
}

.hex-cell::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: var(--bg-accent);
    z-index: 1;
}

.hex-content {
    position: relative;
    z-index: 2;
    font-size: 0.85em;
    text-align: center;
    line-height: 1.3;
}

.hex-cell:hover {
    transform: rotateY(0deg) scale(1.08);
    z-index: 10;
}

.hex-cell:hover::before {
    background: linear-gradient(135deg, rgba(61, 220, 132, 0.4), rgba(74, 143, 231, 0.4), rgba(224, 86, 160, 0.4));
    box-shadow: 0 0 20px rgba(61, 220, 132, 0.3);
}

/* ===========================
   Zone 5: The Convergence
   =========================== */
#zone-converge {
    height: 150vh;
    background: radial-gradient(ellipse at 50% 30%, #1A2744 0%, #0B0E1A 70%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: background-color 1.5s ease;
}

#convergence-message {
    text-align: center;
    z-index: 2;
    max-width: 800px;
    padding: 0 2rem;
}

#typewriter-text {
    min-height: 3em;
}

#typewriter-english {
    opacity: 0;
    transition: opacity 1.5s ease;
    margin-top: 1.5rem;
}

#typewriter-english.visible {
    opacity: 1;
}

#golden-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent-gold);
    margin-top: 3rem;
    z-index: 2;
    opacity: 0;
    animation: golden-pulse 2s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(212, 168, 85, 0.4), 0 0 40px rgba(212, 168, 85, 0.2);
}

#golden-dot.visible {
    opacity: 1;
}

@keyframes golden-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(212, 168, 85, 0.4), 0 0 40px rgba(212, 168, 85, 0.2);
    }
    50% {
        transform: scale(1.3);
        box-shadow: 0 0 30px rgba(212, 168, 85, 0.6), 0 0 60px rgba(212, 168, 85, 0.3);
    }
}

/* ===========================
   Typography
   =========================== */
.korean-display {
    font-family: var(--font-korean);
    font-weight: 300;
    font-size: clamp(2rem, 5vw, 4.5rem);
    letter-spacing: 0.08em;
    line-height: 1.8;
    color: var(--lavender);
}

.english-sub {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(1rem, 2vw, 1.5rem);
    letter-spacing: -0.02em;
    line-height: 1.05;
    color: var(--text-primary);
    font-feature-settings: "liga" 1, "onum" 1;
    margin-top: 0.5em;
}

.body-text {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(0.9rem, 1.8vw, 1.15rem);
    line-height: 1.85;
    letter-spacing: 0.01em;
    color: var(--text-secondary);
}

.mono-text {
    font-family: var(--font-mono);
    font-weight: 300;
    font-size: 0.85em;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
}

/* ===========================
   Responsive
   =========================== */
@media (max-width: 768px) {
    .hex-row-offset {
        margin-left: 35px;
    }

    .hex-cell {
        width: 80px;
        height: 92px;
    }

    .hex-content {
        font-size: 0.65em;
    }

    .walk-block {
        max-width: 260px;
        padding: 1rem 1.5rem;
    }

    #coin-svg-container {
        width: 260px;
        height: 260px;
    }

    .bell-text-left,
    .bell-text-right {
        max-width: 100%;
    }
}

/* ===========================
   Camera Shake
   =========================== */
.camera-shake {
    animation: shake 0.2s ease;
}

@keyframes shake {
    0% { transform: translate(0, 0); }
    25% { transform: translate(2px, -1px); }
    50% { transform: translate(-2px, 2px); }
    75% { transform: translate(1px, -2px); }
    100% { transform: translate(0, 0); }
}
