/* =============================================
   kakuritsu.com — Generative Mathematical Probability
   ============================================= */

:root {
    --void-indigo: #0B0E2A;
    --deep-slate: #141833;
    --probability-teal: #4ECDC4;
    --twilight-violet: #6C63A0;
    --probability-white: #E8E4F0;
    --muted-lavender: #9B95A8;
    --outcome-gold: #D4A843;
    --luminous-cyan: #1AFFD5;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background: var(--void-indigo);
    color: var(--probability-white);
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 300;
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    line-height: 1.75;
    overflow-x: hidden;
}

/* ---- Cursor Trail ---- */
.cursor-trail {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1000;
}

.cursor-dot {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--probability-teal);
    opacity: 0.3;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

/* ---- CDF Progress ---- */
.cdf-progress {
    position: fixed;
    right: 0;
    top: 0;
    width: 4px;
    height: 100vh;
    z-index: 100;
}

.cdf-progress svg {
    width: 100%;
    height: 100%;
}

.cdf-path {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 0.1s linear;
}

/* ---- Section Base ---- */
.section {
    position: relative;
    width: 100%;
    opacity: 0;
    transition: opacity 0.6s ease-out;
}

.section.in-view {
    opacity: 1;
}

.section-title {
    font-family: 'Zen Kaku Gothic New', sans-serif;
    font-weight: 900;
    font-size: clamp(2rem, 5vw, 4rem);
    color: var(--probability-white);
    letter-spacing: 0.2em;
    margin-bottom: 20px;
}

.section-desc {
    font-family: 'Source Serif 4', serif;
    font-weight: 300;
    font-size: clamp(1rem, 1.5vw, 1.25rem);
    color: var(--muted-lavender);
    max-width: 55ch;
    margin-bottom: 40px;
}

.annotation {
    font-family: 'Source Serif 4', serif;
    font-weight: 300;
    font-style: italic;
    font-size: clamp(0.85rem, 1vw, 1rem);
    color: var(--muted-lavender);
    margin-top: 20px;
}

/* =============================================
   1. THE CERTAINTY THRESHOLD
   ============================================= */
#certainty {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--void-indigo);
}

.hero-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
}

.hero-kanji {
    font-family: 'Zen Kaku Gothic New', sans-serif;
    font-weight: 900;
    font-size: clamp(4rem, 10vw, 9rem);
    color: var(--probability-white);
    letter-spacing: 0.05em;
    opacity: 0;
    transition: opacity 2s ease;
}

.hero-kanji.visible {
    opacity: 1;
}

.hero-romanization {
    font-family: 'Zen Kaku Gothic New', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 2vw, 1.5rem);
    color: var(--muted-lavender);
    letter-spacing: 0.5em;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease 0.5s, transform 0.8s cubic-bezier(0.23, 1, 0.32, 1) 0.5s;
}

.hero-romanization.visible {
    opacity: 1;
    transform: translateY(0);
}

/* =============================================
   2. THE COIN SPACE
   ============================================= */
#coin-space {
    min-height: 150vh;
    background: var(--void-indigo);
    padding: 100px 0;
}

.coin-layout {
    display: flex;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 40px;
    gap: 80px;
    align-items: flex-start;
}

.histogram-area {
    flex: 1;
}

.histogram-canvas {
    width: 100%;
    max-width: 400px;
    height: 300px;
    display: block;
}

.coin-counter {
    position: sticky;
    top: 40vh;
    text-align: right;
    min-width: 160px;
}

.counter-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 11px;
    letter-spacing: 0.12em;
    color: var(--muted-lavender);
    margin-top: 20px;
}

.counter-label:first-child {
    margin-top: 0;
}

.counter-value {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(2rem, 4vw, 3.5rem);
    color: var(--probability-teal);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

/* =============================================
   3. THE DISTRIBUTION GALLERY
   ============================================= */
#distributions {
    min-height: 200vh;
    background: var(--void-indigo);
    padding: 100px 0;
}

.dist-panel {
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding: 60px 40px;
    max-width: 1200px;
    margin: 0 auto;
    gap: 40px;
}

.dist-text {
    width: 30%;
    padding-top: 10vh;
    align-self: flex-start;
}

.dist-description {
    font-family: 'Source Serif 4', serif;
    font-weight: 300;
    font-size: clamp(1rem, 1.5vw, 1.25rem);
    color: var(--probability-white);
    line-height: 1.75;
}

.dist-viz {
    width: 70%;
    position: relative;
}

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

.dist-curve {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 1.5s ease-in-out;
}

.dist-panel.in-view .dist-curve {
    stroke-dashoffset: 0;
}

.dist-equation {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 14px;
    color: var(--twilight-violet);
    margin-top: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.dist-panel:hover .dist-equation {
    opacity: 1;
}

/* =============================================
   4. THE RANDOM WALK
   ============================================= */
#random-walk {
    min-height: 150vh;
    background: var(--void-indigo);
    position: relative;
}

.walk-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.walk-label {
    position: sticky;
    top: 80vh;
    padding: 0 40px;
    z-index: 2;
}

.walk-annotations {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
}

.walk-note {
    position: absolute;
    font-family: 'Source Serif 4', serif;
    font-weight: 300;
    font-style: italic;
    font-size: 13px;
    color: var(--outcome-gold);
    opacity: 0.7;
    white-space: nowrap;
}

/* =============================================
   5. THE ENTROPY FLOOR
   ============================================= */
#entropy {
    min-height: 100vh;
    background: var(--void-indigo);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.entropy-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.entropy-text {
    position: relative;
    z-index: 2;
    text-align: center;
}

.closing-line {
    font-family: 'Source Serif 4', serif;
    font-weight: 300;
    font-style: italic;
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    color: var(--probability-white);
    letter-spacing: 0.06em;
    opacity: 0;
    transition: opacity 1.5s ease;
}

.closing-line.visible {
    opacity: 1;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .coin-layout {
        flex-direction: column;
        gap: 40px;
    }

    .coin-counter {
        position: static;
        text-align: left;
        display: flex;
        flex-wrap: wrap;
        gap: 10px 30px;
    }

    .dist-panel {
        flex-direction: column;
    }

    .dist-text,
    .dist-viz {
        width: 100%;
    }
}
