/* hwaklyul.com - Probability Cascade */
/* Color Palette */
:root {
    --bg-deep: #0d1117;
    --bg-panel: #161b2e;
    --accent-primary: #5e7ce2;
    --accent-secondary: #8b9cf5;
    --accent-tertiary: #c4cded;
    --highlight-amber: #e8b84d;
    --danger-rose: #e25e7c;
    --success-mint: #5ee2a0;
    --annotation: #7a86b8;
    --dot-matrix: #1a2035;
    --bounce-enter: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg-deep);
    font-family: 'Outfit', sans-serif;
    font-weight: 300;
    color: var(--accent-tertiary);
    line-height: 1.72;
    overflow-x: hidden;
    position: relative;
}

/* Dot Matrix Background */
#dot-matrix {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    background-image: radial-gradient(circle, var(--dot-matrix) 1px, transparent 1px);
    background-size: 24px 24px;
}

/* Korean Watermarks */
.watermark {
    position: fixed;
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 500;
    font-size: 15vw;
    opacity: 0.03;
    color: var(--accent-primary);
    pointer-events: none;
    z-index: 1;
    user-select: none;
}
.watermark-1 { top: 5%; left: 5%; }
.watermark-2 { top: 30%; right: 5%; }
.watermark-3 { top: 55%; left: 10%; }
.watermark-4 { top: 80%; right: 10%; }

/* Opening Sequence */
.opening-sequence {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: var(--bg-deep);
}

.coin-container {
    perspective: 800px;
    margin-bottom: 40px;
}

.coin {
    width: 80px;
    height: 80px;
    position: relative;
    transform-style: preserve-3d;
    animation: coinSpin 2s ease-in-out 0.4s 3 forwards;
    will-change: transform;
}

.coin-face {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    backface-visibility: hidden;
}

.coin-heads {
    background: var(--accent-primary);
    border: 3px solid var(--accent-secondary);
}

.coin-tails {
    background: var(--highlight-amber);
    border: 3px solid #d4a43e;
    transform: rotateY(180deg);
}

@keyframes coinSpin {
    0% { transform: rotateY(0deg); }
    100% { transform: rotateY(360deg); }
}

.site-title {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: clamp(3rem, 7vw, 6rem);
    color: var(--accent-primary);
    letter-spacing: -0.02em;
    opacity: 0;
    animation: fadeIn 1s ease 1s forwards;
}

.site-subtitle {
    font-family: 'Outfit', sans-serif;
    font-weight: 200;
    font-size: clamp(1rem, 2vw, 1.5rem);
    color: var(--accent-tertiary);
    letter-spacing: 0.05em;
    opacity: 0;
    animation: fadeIn 1s ease 1.5s forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Timeline Spine */
.timeline-spine {
    position: fixed;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    width: 2px;
    height: 100%;
    z-index: 5;
    pointer-events: none;
}

.spine-line {
    width: 100%;
    height: 100%;
    background: var(--accent-primary);
    transform-origin: top;
    transform: scaleY(0);
    animation: spinePulse 3s ease-in-out infinite;
    opacity: 0.6;
}

@keyframes spinePulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

/* Minimap */
.minimap {
    position: fixed;
    right: 16px;
    top: 20vh;
    width: 16px;
    height: 60vh;
    z-index: 20;
    background: rgba(22, 27, 46, 0.5);
    border-radius: 8px;
    overflow: hidden;
}

.minimap-viewport {
    position: absolute;
    width: 100%;
    height: 10%;
    background: rgba(94, 124, 226, 0.3);
    border-radius: 4px;
    transition: top 0.1s ease;
}

/* Timeline Container */
.timeline-container {
    position: relative;
    z-index: 10;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Timeline Nodes */
.timeline-node {
    position: relative;
    display: flex;
    justify-content: center;
    margin: clamp(80px, 12vh, 160px) auto;
    z-index: 12;
}

.node-burst {
    position: relative;
    z-index: 12;
}

.node-circle {
    fill: none;
    stroke: var(--accent-primary);
    stroke-width: 1.5;
    transition: fill 0.5s ease;
}

.node-circle.filled {
    fill: var(--accent-primary);
}

.node-final {
    stroke-width: 2;
}

.burst-line {
    stroke: var(--accent-primary);
    stroke-width: 0.8;
    opacity: 0.5;
}

.burst-dot {
    fill: var(--accent-primary);
    opacity: 0.6;
}

.fork-glow {
    filter: drop-shadow(0 0 20px rgba(139, 156, 245, 0.5));
    animation: forkPulse 2s infinite;
}

@keyframes forkPulse {
    0%, 100% { filter: drop-shadow(0 0 10px rgba(139, 156, 245, 0.3)); }
    50% { filter: drop-shadow(0 0 25px rgba(139, 156, 245, 0.6)); }
}

/* Panels */
.panel {
    position: relative;
    opacity: 0;
    margin: clamp(40px, 6vh, 80px) 0;
}

.panel-left {
    transform: translateX(-60px);
    padding-right: calc(50% + 40px);
}

.panel-right {
    transform: translateX(60px);
    padding-left: calc(50% + 40px);
}

.panel.visible {
    animation: bounceEnterLeft 0.8s var(--bounce-enter) forwards;
}

.panel-right.visible {
    animation: bounceEnterRight 0.8s var(--bounce-enter) forwards;
}

@keyframes bounceEnterLeft {
    from { opacity: 0; transform: translateX(-60px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes bounceEnterRight {
    from { opacity: 0; transform: translateX(60px); }
    to { opacity: 1; transform: translateX(0); }
}

.panel-connector {
    position: absolute;
    top: 30px;
    width: 40px;
    height: 2px;
    background: var(--accent-primary);
    opacity: 0.5;
}

.panel-left .panel-connector {
    right: calc(50% + 0px);
}

.panel-right .panel-connector {
    left: calc(50% + 0px);
}

.panel-content {
    position: relative;
    background: var(--bg-panel);
    border-radius: 8px;
    padding: clamp(24px, 4vw, 40px);
    border: 1px solid rgba(94, 124, 226, 0.1);
    overflow: hidden;
}

.panel-immersive .panel-content {
    min-height: 60vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Circuit Traces Background */
.circuit-traces {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.06;
    pointer-events: none;
    background-image:
        linear-gradient(0deg, var(--accent-primary) 1px, transparent 1px),
        linear-gradient(90deg, var(--accent-primary) 1px, transparent 1px);
    background-size: 48px 48px;
}

/* Typography */
h2 {
    font-family: 'Outfit', sans-serif;
    font-weight: 400;
    font-size: clamp(1.8rem, 4vw, 3rem);
    color: var(--accent-secondary);
    letter-spacing: 0.01em;
    margin-bottom: 20px;
}

p {
    font-family: 'Outfit', sans-serif;
    font-weight: 300;
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    color: var(--accent-tertiary);
    line-height: 1.72;
    max-width: 38ch;
    margin-bottom: 16px;
}

.high-certainty {
    font-weight: 700;
    color: var(--accent-tertiary);
}

.medium-certainty {
    font-weight: 400;
    color: var(--accent-secondary);
}

.low-certainty {
    font-weight: 200;
    color: var(--annotation);
}

.annotation {
    font-family: 'Outfit', sans-serif;
    font-weight: 200;
    font-size: clamp(0.75rem, 1.2vw, 0.9rem);
    color: var(--annotation);
    max-width: none;
}

.number {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    color: var(--highlight-amber);
}

.korean-text {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 500;
    color: var(--accent-secondary);
}

em {
    font-style: italic;
    color: var(--accent-primary);
}

/* Bell Curve Demo */
.bell-curve-demo {
    margin: 30px 0;
}

.bar-container {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 200px;
    padding: 0 10px;
}

.bar {
    flex: 1;
    height: 0;
    border-radius: 2px 2px 0 0;
    transition: height 0.8s var(--bounce-enter);
}

.bar.animate {
    height: var(--h);
    animation-delay: calc(var(--i) * 40ms);
}

/* Bar colors: center bars primary, edge bars tertiary */
.bar:nth-child(1), .bar:nth-child(30) { background: var(--accent-tertiary); opacity: 0.5; }
.bar:nth-child(2), .bar:nth-child(29) { background: var(--accent-tertiary); opacity: 0.55; }
.bar:nth-child(3), .bar:nth-child(28) { background: var(--accent-tertiary); opacity: 0.6; }
.bar:nth-child(4), .bar:nth-child(27) { background: var(--accent-tertiary); opacity: 0.65; }
.bar:nth-child(5), .bar:nth-child(26) { background: var(--accent-tertiary); opacity: 0.7; }
.bar:nth-child(6), .bar:nth-child(25) { background: var(--accent-secondary); opacity: 0.7; }
.bar:nth-child(7), .bar:nth-child(24) { background: var(--accent-secondary); opacity: 0.75; }
.bar:nth-child(8), .bar:nth-child(23) { background: var(--accent-secondary); opacity: 0.8; }
.bar:nth-child(9), .bar:nth-child(22) { background: var(--accent-secondary); opacity: 0.85; }
.bar:nth-child(10), .bar:nth-child(21) { background: var(--accent-secondary); opacity: 0.9; }
.bar:nth-child(11), .bar:nth-child(20) { background: var(--accent-primary); opacity: 0.85; }
.bar:nth-child(12), .bar:nth-child(19) { background: var(--accent-primary); opacity: 0.9; }
.bar:nth-child(13), .bar:nth-child(18) { background: var(--accent-primary); opacity: 0.95; }
.bar:nth-child(14), .bar:nth-child(17) { background: var(--accent-primary); }
.bar:nth-child(15), .bar:nth-child(16) { background: var(--accent-primary); }

/* Decision Tree */
.decision-tree {
    margin: 20px 0;
}

.tree-svg {
    width: 100%;
    max-width: 400px;
}

.tree-branch {
    opacity: 0;
    transition: opacity 0.6s ease;
}

.tree-branch.visible {
    opacity: 1;
}

.tree-node {
    fill: var(--bg-panel);
    stroke: var(--accent-primary);
    stroke-width: 1.5;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.tree-node.visible {
    opacity: 1;
}

.tree-label {
    font-family: 'Space Mono', monospace;
    font-size: 12px;
    font-weight: 700;
    fill: var(--highlight-amber);
    opacity: 0;
    transition: opacity 0.6s ease 0.3s;
}

.tree-label.visible {
    opacity: 1;
}

/* Monty Hall Visual */
.monty-hall-visual {
    display: flex;
    gap: 16px;
    margin: 24px 0;
}

.door {
    width: 80px;
    height: 120px;
    background: var(--bg-panel);
    border: 2px solid var(--accent-primary);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.5s ease;
}

.door-open {
    border-color: var(--danger-rose);
    opacity: 0.5;
    background: rgba(226, 94, 124, 0.05);
}

.door-3 {
    border-color: var(--success-mint);
    box-shadow: 0 0 15px rgba(94, 226, 160, 0.2);
}

.door-label {
    font-family: 'Outfit', sans-serif;
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--accent-tertiary);
}

.door-prob {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--highlight-amber);
}

/* Random Walk */
.random-walk-demo {
    margin: 20px 0;
    border-radius: 4px;
    overflow: hidden;
}

.walk-svg {
    width: 100%;
    background: rgba(13, 17, 23, 0.5);
    border-radius: 4px;
}

.walk-line {
    stroke: var(--accent-primary);
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Fork Visuals */
.fork-visual {
    position: relative;
    width: 60%;
    max-width: 400px;
    height: 100px;
    margin: 0 auto;
    z-index: 11;
}

.fork-svg {
    width: 100%;
    height: 100%;
}

.fork-path {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    transition: stroke-dashoffset 0.8s ease-out;
}

.fork-path.drawn {
    stroke-dashoffset: 0;
}

/* Branch Container */
.branch-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(20px, 4vw, 60px);
    padding: 0 20px;
    margin: clamp(40px, 6vh, 80px) 0;
    position: relative;
    z-index: 10;
}

.branch-left, .branch-right {
    opacity: 0;
    transform: translateY(30px);
}

.branch-left.visible, .branch-right.visible {
    animation: bounceEnterUp 0.8s var(--bounce-enter) forwards;
}

@keyframes bounceEnterUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.branch-panel {
    background: var(--bg-panel);
    border-radius: 8px;
    padding: clamp(20px, 3vw, 32px);
    border: 1px solid rgba(94, 124, 226, 0.1);
}

.branch-favorable {
    border-color: rgba(94, 226, 160, 0.2);
}

.branch-unfavorable {
    border-color: rgba(226, 94, 124, 0.2);
}

/* Probability Badges */
.probability-badge {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 20px;
    margin: 12px 0;
}

.probability-badge.mint {
    background: rgba(94, 226, 160, 0.1);
    border: 1px solid rgba(94, 226, 160, 0.3);
}

.probability-badge.rose {
    background: rgba(226, 94, 124, 0.1);
    border: 1px solid rgba(226, 94, 124, 0.3);
}

.probability-badge .number {
    font-size: 0.9rem;
}

.probability-badge.mint .number {
    color: var(--success-mint);
}

.probability-badge.rose .number {
    color: var(--danger-rose);
}

/* Geometric Floats */
.geo-float {
    position: absolute;
    opacity: 0.15;
    z-index: 2;
    pointer-events: none;
}

.geo-dice {
    right: 8%;
    margin-top: -50px;
}

.geo-coin {
    left: 6%;
    margin-top: -30px;
}

.geo-card {
    right: 10%;
    margin-top: -40px;
}

.geo-roulette {
    left: 8%;
    margin-top: -30px;
}

/* Closing Sequence */
.closing-sequence {
    position: relative;
    z-index: 10;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-deep);
}

.convergence-spine {
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    width: 4px;
    height: 100%;
    background: var(--accent-primary);
    opacity: 0.6;
}

.final-character {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 500;
    font-size: 9vw;
    color: var(--accent-primary);
    opacity: 0;
    z-index: 11;
    transition: opacity 1s ease;
    text-shadow: 0 0 40px rgba(94, 124, 226, 0.4);
}

.final-character.visible {
    opacity: 1;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .coin { animation: none; }
    .panel { transition: opacity 0.01s; transform: none !important; }
    .panel.visible { animation: none; opacity: 1; }
    .panel-right.visible { animation: none; opacity: 1; }
    .branch-left.visible, .branch-right.visible { animation: none; opacity: 1; }
    .fork-path { transition: none; stroke-dashoffset: 0; }
    .bar { transition: none; }
    .bar.animate { height: var(--h); }
    .fork-glow { animation: none; }
    @keyframes spinePulse { 0%, 100% { opacity: 0.6; } }
}

/* Responsive */
@media (max-width: 768px) {
    .panel-left { padding-right: 20px; padding-left: 60px; }
    .panel-right { padding-left: 20px; padding-right: 20px; padding-left: 60px; }
    .panel-left .panel-connector { display: none; }
    .panel-right .panel-connector { display: none; }
    .branch-container { grid-template-columns: 1fr; padding: 0 60px 0 20px; }
    .minimap { right: 8px; width: 12px; }
    .monty-hall-visual { flex-direction: row; flex-wrap: wrap; }
    .door { width: 60px; height: 90px; }
    .geo-float { display: none; }
}
