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

html {
    overflow: hidden;
    height: 100%;
}

body {
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    background: #d4e4ec;
    font-family: 'Cormorant Garamond', Georgia, serif;
    color: #2c3e50;
}

/* === Logotype === */
.logotype {
    position: fixed;
    top: 20px;
    left: 24px;
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-size: 16px;
    color: #1a2a3d;
    opacity: 0.5;
    z-index: 100;
    letter-spacing: 0.08em;
}

/* === Scroll Container === */
#scroll-container {
    display: flex;
    flex-direction: row;
    height: 100vh;
    width: max-content;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Hide scrollbar */
#scroll-container::-webkit-scrollbar {
    display: none;
}
#scroll-container {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* === Chambers === */
.chamber {
    width: 100vw;
    height: 100vh;
    flex-shrink: 0;
    scroll-snap-align: center;
    position: relative;
    overflow: hidden;
}

/* === Ghost Text === */
.ghost-text {
    position: absolute;
    font-family: 'Cormorant Garamond', serif;
    font-size: 14vw;
    font-weight: 400;
    opacity: 0.08;
    color: #1a2a3d;
    pointer-events: none;
    user-select: none;
    white-space: nowrap;
}

.ghost-text-1 {
    top: 10%;
    right: 5%;
    color: #6b8fa3;
    opacity: 0.1;
}

.ghost-text-2 {
    bottom: 8%;
    left: 5%;
    color: #eef4f8;
    opacity: 0.12;
}

.ghost-text-3 {
    top: 5%;
    right: 8%;
    color: #a8c4d4;
    opacity: 0.1;
}

.ghost-text-4 {
    top: 15%;
    left: 8%;
    color: #6b8fa3;
    opacity: 0.1;
}

/* === Chamber 1: The Crackle === */
#chamber-1 {
    background: #d4e4ec;
    display: flex;
    align-items: center;
    justify-content: center;
}

.crackle-pattern {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.crackle-pattern path {
    fill: none;
    stroke: #a8c4d4;
    stroke-opacity: 0.4;
    stroke-width: 1.2;
    stroke-linecap: round;
}

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

.title-main {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(4rem, 10vw, 8rem);
    color: #1a2a3d;
    letter-spacing: 0.08em;
    line-height: 1.2;
    opacity: 0;
    transition: opacity 1.2s ease;
}

.title-main.visible {
    opacity: 1;
}

.subtitle {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.1rem;
    letter-spacing: 0.15em;
    color: #6b8fa3;
    margin-top: 16px;
    opacity: 0;
    transition: opacity 1.2s ease;
}

.subtitle.visible {
    opacity: 1;
}

.scroll-hint {
    position: absolute;
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    font-family: 'Fira Code', monospace;
    font-size: 0.8rem;
    color: #b8956a;
    z-index: 10;
    animation: hint-pulse 2s ease-in-out infinite;
}

@keyframes hint-pulse {
    0%, 100% { transform: translateY(-50%) translateX(0); }
    50% { transform: translateY(-50%) translateX(8px); }
}

/* === Chamber 2: The Garden === */
#chamber-2 {
    background: #eef4f8;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tree-container {
    width: 90%;
    height: 80%;
    position: relative;
    z-index: 2;
}

.tree-container path {
    fill: none;
    stroke: #2c3e50;
    stroke-linecap: round;
}

.tree-container text.prob-label {
    font-family: 'Fira Code', monospace;
    font-size: 11px;
    fill: #6b8fa3;
}

.tree-container text.concept-label {
    font-family: 'Cormorant Garamond', serif;
    font-size: 14px;
    fill: #2c3e50;
}

/* === Chamber 3: The Marble Hall === */
#chamber-3 {
    background: #0d1b2a;
    display: flex;
    align-items: center;
    justify-content: center;
}

.marble-hall {
    display: flex;
    align-items: center;
    height: 100%;
    gap: 0;
    padding: 0 5vw;
    position: relative;
    z-index: 2;
}

.marble-column {
    width: 60px;
    height: 70vh;
    flex-shrink: 0;
    background: linear-gradient(90deg, #d4e4ec 0%, #eef4f8 30%, #d4e4ec 50%, #c0d4e0 70%, #d4e4ec 100%);
    border-radius: 4px;
    opacity: 0.7;
    animation: column-float 6s ease-in-out infinite;
    position: relative;
}

.marble-column::after {
    content: '';
    position: absolute;
    top: 10%;
    left: 15%;
    width: 70%;
    height: 80%;
    background: repeating-linear-gradient(
        175deg,
        transparent,
        transparent 18px,
        rgba(168, 196, 212, 0.3) 18px,
        rgba(168, 196, 212, 0.3) 19px
    );
    border-radius: 2px;
}

@keyframes column-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

.marble-column:nth-child(1) { animation-delay: 0s; }
.marble-column:nth-child(3) { animation-delay: -2s; }
.marble-column:nth-child(5) { animation-delay: -4s; }

.marble-text-panel {
    max-width: 28ch;
    padding: 0 3vw;
    flex-shrink: 0;
}

.marble-body {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    line-height: 1.75;
    color: #c8dce8;
    letter-spacing: 0.01em;
}

.kintsugi-line {
    width: 100%;
    height: 1px;
    background: #b8956a;
    margin: 24px 0;
    opacity: 0.6;
}

/* === Chamber 4: The Dice Room === */
#chamber-4 {
    background: #162638;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dice-room-center {
    position: relative;
    width: 60vmin;
    height: 60vmin;
    z-index: 2;
}

.morph-shape {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200px;
    height: 200px;
    transform: translate(-50%, -50%);
    background: rgba(168, 196, 212, 0.6);
    transition: clip-path 3s cubic-bezier(0.22, 1, 0.36, 1),
                border-radius 3s cubic-bezier(0.22, 1, 0.36, 1);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    border: 2px solid rgba(168, 196, 212, 0.4);
}

.morph-shape.circle {
    clip-path: circle(50% at 50% 50%);
}

.morph-shape.hexagon {
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

.morph-shape.diamond {
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

.morph-shape.bell {
    clip-path: polygon(0% 100%, 5% 90%, 15% 55%, 25% 25%, 35% 8%, 45% 2%, 50% 0%, 55% 2%, 65% 8%, 75% 25%, 85% 55%, 95% 90%, 100% 100%);
}

.orbiting-chars {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
}

.orbit-char {
    position: absolute;
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-size: 2rem;
    color: #6b8fa3;
    opacity: 0.3;
    animation: orbit 30s linear infinite;
    --angle: calc(var(--i) * 60deg);
    --radius: 180px;
}

@keyframes orbit {
    from {
        transform: rotate(var(--angle)) translateX(var(--radius)) rotate(calc(-1 * var(--angle)));
    }
    to {
        transform: rotate(calc(var(--angle) + 360deg)) translateX(var(--radius)) rotate(calc(-1 * (var(--angle) + 360deg)));
    }
}

.orbit-char:nth-child(1) { --angle: 0deg; animation-delay: 0s; }
.orbit-char:nth-child(2) { --angle: 60deg; animation-delay: -5s; }
.orbit-char:nth-child(3) { --angle: 120deg; animation-delay: -10s; }
.orbit-char:nth-child(4) { --angle: 180deg; animation-delay: -15s; }
.orbit-char:nth-child(5) { --angle: 240deg; animation-delay: -20s; }
.orbit-char:nth-child(6) { --angle: 300deg; animation-delay: -25s; }

/* === Chamber 5: The Exit === */
#chamber-5 {
    background: #d4e4ec;
    display: flex;
    align-items: center;
    justify-content: center;
}

.exit-crackle path {
    stroke-opacity: 0.25;
}

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

.exit-text {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 400;
    font-size: 1.4rem;
    color: #2c3e50;
    letter-spacing: 0.05em;
}

/* === Progress Bar === */
.progress-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: #162638;
    z-index: 100;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: #b8956a;
    transition: width 0.1s linear;
}

/* === Responsive === */
@media (max-width: 768px) {
    .marble-hall {
        padding: 0 3vw;
    }
    .marble-column {
        width: 30px;
    }
    .marble-text-panel {
        padding: 0 2vw;
        max-width: 22ch;
    }
    .morph-shape {
        width: 140px;
        height: 140px;
    }
    .orbit-char {
        --radius: 120px;
        font-size: 1.4rem;
    }
}
