/* ===========================================
   확률.com — Probability Dreamscape
   Colors: #6B1D3A, #3A0E20, #F5EDE0, #FAF7F2, #C4A265, #D4918E, #1A0B12
   Fonts: Josefin Sans, Work Sans, Space Mono
   =========================================== */

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

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

body {
    background-color: #1A0B12;
    color: #F5EDE0;
    font-family: 'Work Sans', sans-serif;
    font-weight: 400;
    font-size: 18px;
    line-height: 1.75;
    overflow-x: hidden;
}

/* --- Typography --- */

.heading-primary {
    font-family: 'Josefin Sans', sans-serif;
    font-size: clamp(64px, 10vw, 96px);
    font-weight: 300;
    letter-spacing: 0.08em;
    color: #F5EDE0;
    line-height: 1.1;
}

.heading-secondary {
    font-family: 'Josefin Sans', sans-serif;
    font-size: clamp(36px, 5vw, 64px);
    font-weight: 300;
    letter-spacing: 0.08em;
    color: #F5EDE0;
    line-height: 1.2;
}

.body-text {
    font-family: 'Work Sans', sans-serif;
    font-size: clamp(16px, 2vw, 22px);
    font-weight: 400;
    line-height: 1.75;
    color: #F5EDE0;
    max-width: 540px;
}

.body-aside {
    font-family: 'Work Sans', sans-serif;
    font-style: italic;
    font-size: clamp(18px, 2.2vw, 20px);
    font-weight: 300;
    line-height: 1.75;
    color: #D4918E;
    max-width: 540px;
}

.data-accent {
    font-family: 'Space Mono', monospace;
    font-size: clamp(14px, 1.5vw, 16px);
    font-weight: 400;
    color: #C4A265;
    letter-spacing: 0.04em;
    margin-top: 16px;
}

/* --- Progress Indicator --- */

#progress-indicator {
    position: fixed;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.progress-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1.5px solid #C4A265;
    background: transparent;
    transition: background-color 0.4s cubic-bezier(0.23, 1, 0.32, 1),
                transform 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    cursor: pointer;
}

.progress-dot.active {
    background-color: #6B1D3A;
    transform: scale(1.4);
    border-color: #C4A265;
}

/* --- Scene Base --- */

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

.scene-bg-pattern {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.06;
}

.scene-text {
    position: absolute;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.23, 1, 0.32, 1);
}

.scene-text.visible {
    opacity: 1;
}

/* --- Scene 1: Floating Die --- */

.scene-1 {
    background: radial-gradient(ellipse at 50% 40%, #3A0E20 0%, #1A0B12 70%);
}

.scene-1-text {
    bottom: 15%;
    left: 10%;
    transform: translate(-30px, 20px) rotate(-2deg);
}

.scene-1-text.visible {
    transform: translate(0, 0) rotate(-2deg);
}

.die-container {
    perspective: 800px;
    width: 180px;
    height: 180px;
    position: relative;
    z-index: 5;
    margin-top: -10vh;
}

.die {
    width: 180px;
    height: 180px;
    position: relative;
    transform-style: preserve-3d;
    animation: die-float 6s ease-in-out infinite;
}

.die-face {
    position: absolute;
    width: 180px;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Josefin Sans', sans-serif;
    font-size: 48px;
    font-weight: 300;
    backface-visibility: visible;
    border: 1.5px solid #C4A265;
}

.die-face span {
    color: #F5EDE0;
}

.die-front  {
    background: rgba(107, 29, 58, 0.85);
    transform: rotateY(0deg) translateZ(90px);
}
.die-back   {
    background: rgba(58, 14, 32, 0.85);
    transform: rotateY(180deg) translateZ(90px);
}
.die-right  {
    background: rgba(107, 29, 58, 0.7);
    transform: rotateY(90deg) translateZ(90px);
}
.die-left   {
    background: rgba(58, 14, 32, 0.7);
    transform: rotateY(-90deg) translateZ(90px);
}
.die-top    {
    background: rgba(107, 29, 58, 0.6);
    transform: rotateX(90deg) translateZ(90px);
}
.die-bottom {
    background: rgba(58, 14, 32, 0.6);
    transform: rotateX(-90deg) translateZ(90px);
}

@keyframes die-float {
    0%, 100% {
        transform: rotateX(25deg) rotateY(30deg) translateY(0px);
    }
    25% {
        transform: rotateX(30deg) rotateY(120deg) translateY(-15px);
    }
    50% {
        transform: rotateX(20deg) rotateY(210deg) translateY(-8px);
    }
    75% {
        transform: rotateX(28deg) rotateY(300deg) translateY(-20px);
    }
}

.chevron-divider {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40px;
    z-index: 20;
    opacity: 0.7;
}

.chevron-divider svg {
    width: 100%;
    height: 100%;
}

/* --- Scene 2: Diagonal Split --- */

.scene-2 {
    background: #1A0B12;
}

.diagonal-panel {
    position: absolute;
    width: 55%;
    height: 100%;
    display: flex;
    align-items: center;
    transition: transform 1s cubic-bezier(0.23, 1, 0.32, 1),
                opacity 0.8s ease;
    opacity: 0;
}

.panel-left {
    left: 0;
    top: 0;
    background: #3A0E20;
    clip-path: polygon(0 0, 100% 0, 70% 100%, 0 100%);
    transform: translateX(-100%);
    padding: 60px;
    padding-right: 120px;
    justify-content: flex-end;
}

.panel-left.visible {
    transform: translateX(0);
    opacity: 1;
}

.panel-right {
    right: 0;
    top: 0;
    background: #6B1D3A;
    clip-path: polygon(30% 0, 100% 0, 100% 100%, 0 100%);
    transform: translateX(100%);
    padding: 60px;
    padding-left: 120px;
    justify-content: flex-start;
}

.panel-right.visible {
    transform: translateX(0);
    opacity: 1;
}

.panel-content {
    max-width: 400px;
}

.panel-content .heading-secondary {
    margin-bottom: 20px;
}

.panel-content .data-accent {
    margin-top: 24px;
}

.diagonal-line {
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 100%;
    background: #C4A265;
    transform-origin: top center;
    transform: rotate(15deg) scaleY(0);
    transition: transform 1.2s cubic-bezier(0.23, 1, 0.32, 1) 0.3s;
    z-index: 10;
}

.diagonal-line.visible {
    transform: rotate(15deg) scaleY(1.2);
}

/* --- Scene 3: Bell Curve Terrain --- */

.scene-3 {
    background: linear-gradient(180deg, #1A0B12 0%, #3A0E20 100%);
    flex-direction: column;
}

.bell-curve-container {
    width: 100%;
    height: 60vh;
    position: relative;
    perspective: 600px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    overflow: hidden;
}

.bell-curve-svg {
    width: 90%;
    max-width: 1200px;
    transform: rotateX(25deg);
    transform-origin: bottom center;
    transition: transform 0.6s ease;
}

.bell-curve-line {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 2s cubic-bezier(0.23, 1, 0.32, 1);
}

.bell-curve-line.drawn {
    stroke-dashoffset: 0;
}

.bell-curve-area {
    opacity: 0;
    transition: opacity 1.5s ease 0.5s;
}

.bell-curve-area.drawn {
    opacity: 1;
}

.data-monoliths {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.monolith {
    position: absolute;
    width: 4px;
    background: linear-gradient(to top, #C4A265, #FAF7F2);
    bottom: 20%;
    opacity: 0;
    transform: scaleY(0);
    transform-origin: bottom;
    transition: transform 0.8s cubic-bezier(0.23, 1, 0.32, 1),
                opacity 0.5s ease;
}

.monolith.visible {
    opacity: 0.7;
    transform: scaleY(1);
}

.scene-3-text {
    bottom: 8%;
    left: 8%;
    transform: translate(-20px, 20px) rotate(-1deg);
}

.scene-3-text.visible {
    transform: translate(0, 0) rotate(-1deg);
}

/* --- Scene 4: Card Fan --- */

.scene-4 {
    background: radial-gradient(ellipse at 50% 60%, #3A0E20 0%, #1A0B12 80%);
}

.card-fan-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 1200px;
}

.rhombus-card {
    position: absolute;
    width: 260px;
    height: 340px;
    clip-path: polygon(15% 0%, 100% 0%, 85% 100%, 0% 100%);
    background: rgba(107, 29, 58, 0.15);
    border: 1px solid rgba(196, 162, 101, 0.25);
    backdrop-filter: blur(2px);
    transition: transform 1s cubic-bezier(0.23, 1, 0.32, 1),
                opacity 0.8s ease,
                box-shadow 0.4s ease;
    opacity: 0;
    transform: translateY(100px) rotate(5deg) scale(0.8);
    cursor: pointer;
}

.rhombus-card.visible {
    opacity: 1;
}

.rhombus-card:hover {
    transform: rotate(2deg) scale(1.05) !important;
    box-shadow: 0 0 30px rgba(196, 162, 101, 0.3);
}

.card-inner {
    padding: 40px 36px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.card-title {
    font-family: 'Josefin Sans', sans-serif;
    font-size: 24px;
    font-weight: 300;
    letter-spacing: 0.06em;
    color: #F5EDE0;
    margin-bottom: 12px;
}

.card-body {
    font-family: 'Work Sans', sans-serif;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.7;
    color: #D4918E;
    margin-bottom: 16px;
}

.card-formula {
    font-family: 'Space Mono', monospace;
    font-size: 13px;
    color: #C4A265;
    letter-spacing: 0.02em;
}

.scene-4-text {
    top: 8%;
    right: 8%;
    text-align: right;
    transform: translate(20px, -20px) rotate(1deg);
}

.scene-4-text.visible {
    transform: translate(0, 0) rotate(1deg);
}

/* --- Scene 5: Convergence --- */

.scene-5 {
    background: radial-gradient(circle at 50% 50%, #3A0E20 0%, #1A0B12 60%, #0D0509 100%);
}

.convergence-container {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.convergence-lines {
    position: absolute;
    inset: 0;
}

.convergence-line {
    position: absolute;
    background: #C4A265;
    opacity: 0;
    transform-origin: center;
    transition: opacity 0.8s ease, transform 1.2s cubic-bezier(0.23, 1, 0.32, 1);
}

.vanishing-point {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #C4A265;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 1s cubic-bezier(0.23, 1, 0.32, 1) 0.5s;
    box-shadow: 0 0 40px rgba(196, 162, 101, 0.6),
                0 0 80px rgba(196, 162, 101, 0.3);
}

.vanishing-point.visible {
    transform: translate(-50%, -50%) scale(1);
    animation: pulse-gold 2s ease-in-out infinite;
}

@keyframes pulse-gold {
    0%, 100% {
        box-shadow: 0 0 40px rgba(196, 162, 101, 0.6),
                    0 0 80px rgba(196, 162, 101, 0.3);
    }
    50% {
        box-shadow: 0 0 60px rgba(196, 162, 101, 0.8),
                    0 0 120px rgba(196, 162, 101, 0.4);
    }
}

.scene-5-text {
    z-index: 10;
    text-align: center;
    transform: translateY(30px) scale(0.95);
}

.scene-5-text.visible {
    transform: translateY(0) scale(1);
}

.restart-dot {
    position: absolute;
    bottom: 8%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    cursor: pointer;
    text-align: center;
    opacity: 0;
    transition: opacity 0.8s ease 1s;
}

.scene-5.in-view .restart-dot {
    opacity: 1;
}

.restart-label {
    font-family: 'Work Sans', sans-serif;
    font-size: 14px;
    font-weight: 300;
    color: #C4A265;
    letter-spacing: 0.06em;
    display: block;
    margin-top: 8px;
}

.restart-dot::before {
    content: '';
    display: block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #C4A265;
    margin: 0 auto;
    animation: pulse-restart 2s ease-in-out infinite;
}

@keyframes pulse-restart {
    0%, 100% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.3); opacity: 1; }
}

/* --- Scatter Dots Overlay --- */

.scatter-dots-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    opacity: 0.15;
}

.scatter-dot {
    position: absolute;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: #F5EDE0;
}

/* --- Angle Grid Pattern --- */

.angle-grid-line {
    position: absolute;
    width: 1px;
    height: 200%;
    background: #F5EDE0;
    opacity: 0.04;
    transform-origin: center;
    transform: rotate(15deg);
}

/* --- Fibonacci Spiral (behind text) --- */

.fibonacci-path {
    position: absolute;
    stroke: #C4A265;
    stroke-width: 0.5;
    fill: none;
    opacity: 0.15;
}

/* --- Responsive --- */

@media (max-width: 768px) {
    .heading-primary {
        font-size: 48px;
    }

    .heading-secondary {
        font-size: 32px;
    }

    .die-container {
        width: 120px;
        height: 120px;
    }

    .die {
        width: 120px;
        height: 120px;
    }

    .die-face {
        width: 120px;
        height: 120px;
        font-size: 32px;
    }

    .die-front  { transform: rotateY(0deg) translateZ(60px); }
    .die-back   { transform: rotateY(180deg) translateZ(60px); }
    .die-right  { transform: rotateY(90deg) translateZ(60px); }
    .die-left   { transform: rotateY(-90deg) translateZ(60px); }
    .die-top    { transform: rotateX(90deg) translateZ(60px); }
    .die-bottom { transform: rotateX(-90deg) translateZ(60px); }

    @keyframes die-float {
        0%, 100% { transform: rotateX(25deg) rotateY(30deg) translateY(0px); }
        25% { transform: rotateX(30deg) rotateY(120deg) translateY(-10px); }
        50% { transform: rotateX(20deg) rotateY(210deg) translateY(-5px); }
        75% { transform: rotateX(28deg) rotateY(300deg) translateY(-12px); }
    }

    .panel-left {
        width: 100%;
        height: 50%;
        clip-path: polygon(0 0, 100% 0, 100% 80%, 0 100%);
        padding: 40px;
        padding-right: 40px;
    }

    .panel-right {
        width: 100%;
        height: 50%;
        top: 50%;
        clip-path: polygon(0 20%, 100% 0, 100% 100%, 0 100%);
        padding: 40px;
        padding-left: 40px;
    }

    .rhombus-card {
        width: 200px;
        height: 270px;
    }

    .card-inner {
        padding: 24px 20px;
    }

    .card-title {
        font-size: 18px;
    }

    .card-body {
        font-size: 13px;
    }

    #progress-indicator {
        right: 12px;
    }
}
