/* ============================================================
   bability.pro - Probability as Visual Art
   Colors from DESIGN.md:
     Primary:   #0a0e1a  (Probability Dark)
     Curve:     #6366f1  (Indigo Distribution)
     Secondary: #ec4899  (Probability Pink)
     Tertiary:  #14b8a6  (Teal Confidence)
     Surface:   #111827  (Panel Space)
     Text:      #e5e7eb  (Statistical White)
     Muted:     #6b7280  (Margin Gray)
     Alert:     #f59e0b  (Significance Amber)
   ============================================================ */

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

html {
    scroll-snap-type: y mandatory;
    overflow-y: scroll;
    scroll-behavior: smooth;
}

body {
    background: #0a0e1a;
    color: #e5e7eb;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.95rem;
    line-height: 1.6;
    font-weight: 400;
    overflow-x: hidden;
}

/* ---- Galton Board Canvas (persistent background) ---- */
#galton-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
}

/* ---- Scroll Container ---- */
#scroll-container {
    position: relative;
    z-index: 1;
}

/* ---- Snap Sections ---- */
.snap-section {
    width: 100vw;
    height: 100vh;
    scroll-snap-align: start;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.section-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 2rem;
}

/* ---- Typography ---- */
h1, h2, .section-title {
    font-family: 'DM Serif Display', serif;
    font-weight: 400;
}

#domain-title {
    font-family: 'DM Serif Display', serif;
    font-size: clamp(2rem, 5vw, 4.5rem);
    font-weight: 400;
    color: #e5e7eb;
    text-align: center;
    position: relative;
    z-index: 3;
    letter-spacing: 0.02em;
}

#domain-title .dot {
    color: #f59e0b;
}

.hero-subtitle {
    font-family: 'DM Sans', sans-serif;
    font-size: clamp(0.85rem, 1.5vw, 1.1rem);
    color: #6b7280;
    text-align: center;
    margin-top: 0.5rem;
    letter-spacing: 0.08em;
    text-transform: lowercase;
}

.section-title {
    font-size: clamp(1.5rem, 3.5vw, 3rem);
    color: #e5e7eb;
    margin-bottom: 0.5rem;
    text-align: center;
}

.section-caption {
    font-family: 'DM Sans', sans-serif;
    font-size: clamp(0.8rem, 1.2vw, 0.95rem);
    color: #6b7280;
    text-align: center;
    margin-bottom: 1.5rem;
    max-width: 500px;
}

.math {
    font-family: 'STIX Two Math', serif;
    color: #f59e0b;
    font-size: 1.1rem;
}

/* ---- Hero Section ---- */
#hero {
    background: radial-gradient(ellipse at 50% 60%, rgba(99, 102, 241, 0.08) 0%, transparent 60%);
}

#hero-curve {
    position: absolute;
    bottom: 15%;
    left: 50%;
    transform: translateX(-50%);
    width: min(90vw, 800px);
    height: auto;
    z-index: 1;
}

#hero .section-content {
    justify-content: center;
    padding-bottom: 10vh;
}

/* ---- Dice Constellation ---- */
.dice {
    position: absolute;
    opacity: 0.12;
    z-index: 1;
}

.dice-1 { top: 12%; left: 8%; transform: rotate(15deg); }
.dice-2 { top: 8%; right: 12%; transform: rotate(-20deg); }
.dice-3 { bottom: 25%; left: 5%; transform: rotate(30deg); }
.dice-4 { top: 35%; right: 6%; transform: rotate(-10deg); }
.dice-5 { bottom: 30%; right: 15%; transform: rotate(25deg); }

/* ---- CLT Section ---- */
#clt-section {
    background: radial-gradient(ellipse at 50% 50%, rgba(20, 184, 166, 0.06) 0%, transparent 55%);
}

#clt-canvas {
    width: min(85vw, 700px);
    height: 300px;
    border-radius: 4px;
}

.confidence-band {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    height: 100%;
    top: 0;
    pointer-events: none;
    border-left: 1px solid rgba(20, 184, 166, 0.2);
    border-right: 1px solid rgba(20, 184, 166, 0.2);
    background: rgba(20, 184, 166, 0.03);
    transition: width 0.8s ease;
}

.confidence-band-1 {
    width: 50%;
}

.confidence-band-2 {
    width: 30%;
    background: rgba(20, 184, 166, 0.05);
}

/* ---- Bayes Section ---- */
#bayes-section {
    background: radial-gradient(ellipse at 50% 50%, rgba(236, 72, 153, 0.06) 0%, transparent 55%);
}

#bayes-svg {
    width: min(85vw, 750px);
    height: auto;
    cursor: crosshair;
    position: relative;
    z-index: 2;
}

.bayes-formula {
    margin-top: 1.5rem;
    padding: 0.5rem 1.5rem;
    background: rgba(17, 24, 39, 0.7);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 6px;
}

.bayes-legend {
    display: flex;
    gap: 1.5rem;
    margin-top: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.8rem;
    color: #6b7280;
}

.legend-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

/* ---- Monte Carlo Section ---- */
#monte-carlo-section {
    background: radial-gradient(ellipse at 50% 50%, rgba(245, 158, 11, 0.05) 0%, transparent 55%);
}

#monte-carlo-canvas {
    width: min(70vw, 400px);
    height: min(70vw, 400px);
    border-radius: 4px;
    border: 1px solid rgba(99, 102, 241, 0.15);
}

.monte-carlo-stats {
    display: flex;
    gap: 2rem;
    margin-top: 1.5rem;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
}

.stat-label {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.75rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.stat-value {
    font-family: 'STIX Two Math', serif;
    font-size: 1.3rem;
    color: #f59e0b;
}

/* ---- Distribution Gallery ---- */
#gallery-section {
    background: radial-gradient(ellipse at 50% 50%, rgba(99, 102, 241, 0.05) 0%, transparent 55%);
}

.distribution-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    max-width: 500px;
    width: 90%;
}

.dist-card {
    background: rgba(17, 24, 39, 0.6);
    border: 1px solid rgba(99, 102, 241, 0.12);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: border-color 0.3s ease, transform 0.3s ease, background 0.3s ease;
}

.dist-card:hover {
    border-color: rgba(99, 102, 241, 0.4);
    transform: translateY(-2px);
    background: rgba(17, 24, 39, 0.8);
}

.dist-svg {
    width: 100%;
    height: 90px;
}

.dist-label {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.8rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ---- Formula Ribbon ---- */
#formula-ribbon {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: 32px;
    background: rgba(17, 24, 39, 0.85);
    border-top: 1px solid rgba(99, 102, 241, 0.15);
    z-index: 100;
    overflow: hidden;
    display: flex;
    align-items: center;
}

.formula-track {
    display: flex;
    gap: 3rem;
    white-space: nowrap;
    animation: formulaScroll 40s linear infinite;
}

.formula {
    font-family: 'STIX Two Math', serif;
    font-size: 0.8rem;
    color: #6b7280;
    letter-spacing: 0.03em;
    flex-shrink: 0;
}

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

/* ---- Responsive ---- */
@media (max-width: 640px) {
    .distribution-grid {
        grid-template-columns: 1fr;
        max-width: 260px;
    }

    .monte-carlo-stats {
        gap: 1rem;
    }

    .confidence-band-1 { width: 70%; }
    .confidence-band-2 { width: 45%; }

    .dice { display: none; }
}
