:root {
    --black: #0a0a0a;
    --near-black: #1a1a1a;
    --dark-grey: #3d3d3d;
    --charcoal: #2a2a2a;
    --medium-grey: #7a7a7a;
    --light-grey: #c8c8c8;
    --silver: #d5d5d5;
    --off-white: #e8e8e8;
    --pale: #d0d0d0;
    --paper: #f5f5f5;
    --white: #ffffff;
    --body-dark: #e0e0e0;
}

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

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

body {
    font-family: 'Recursive', sans-serif;
    font-variation-settings: 'CASL' 0, 'MONO' 0;
    background: var(--white);
    color: var(--dark-grey);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* ===== SVG defs hidden ===== */
.svg-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

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

/* ===== Progress bar ===== */
#progress-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    height: 2px;
    width: 0%;
    background: var(--near-black);
    z-index: 100;
    transition: width 0.1s linear;
}

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

/* ===== Chamber base ===== */
.chamber {
    position: relative;
    width: 100vw;
    height: 100vh;
    flex-shrink: 0;
    scroll-snap-align: start;
    overflow: hidden;
    background: var(--white);
}

.chamber-dark {
    background: var(--near-black);
}

/* ===== Chamber grid lines ===== */
.chamber-grid-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background-image:
        repeating-linear-gradient(
            to right,
            var(--silver) 0px,
            var(--silver) 0.5px,
            transparent 0.5px,
            transparent calc(100% / 8)
        );
    opacity: 0.3;
}

/* ===== Chamber number ===== */
.chamber-number {
    position: absolute;
    top: 24px;
    right: 32px;
    font-family: 'Recursive', sans-serif;
    font-variation-settings: 'CASL' 0.7, 'MONO' 0, 'wght' 350;
    font-size: 0.75rem;
    color: var(--light-grey);
    z-index: 10;
    transition: color 0.5s ease;
    letter-spacing: 0.05em;
}

.chamber-dark .chamber-number {
    color: var(--medium-grey);
}

.chamber-number.active {
    color: var(--near-black);
}

.chamber-dark .chamber-number.active {
    color: var(--paper);
}

/* ==========================================================================
   CHAMBER 1: THE FOYER
   ========================================================================== */

.foyer-blob {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 450px;
    height: 400px;
    background: var(--light-grey);
    border-radius: 60% 40% 55% 45% / 50% 60% 40% 50%;
    z-index: 1;
    animation: blob-drift 12s cubic-bezier(0.37, 0, 0.63, 1) infinite alternate;
}

@keyframes blob-drift {
    0% { transform: translate(-50%, -50%) translateX(-15px); }
    100% { transform: translate(-50%, -50%) translateX(15px); }
}

.foyer-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 2;
}

.foyer-title {
    font-family: 'Recursive', sans-serif;
    font-variation-settings: 'CASL' 0, 'MONO' 0, 'wght' 900;
    font-size: clamp(8rem, 20vw, 28rem);
    line-height: 0.85;
    color: var(--black);
    letter-spacing: -0.03em;
}

.foyer-subtitle {
    font-family: 'Recursive', sans-serif;
    font-variation-settings: 'CASL' 0, 'MONO' 0, 'wght' 300;
    font-size: clamp(1.5rem, 3vw, 3rem);
    color: var(--dark-grey);
    letter-spacing: 0.35em;
    margin-top: 0.5rem;
    text-transform: lowercase;
}

.scroll-hint {
    position: absolute;
    right: 32px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    color: var(--light-grey);
    animation: hint-pulse 2s ease-in-out infinite;
}

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

/* ==========================================================================
   CHAMBER 2: THE CATALOGUE
   ========================================================================== */

.catalogue-grid {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 32px;
    width: min(80vw, 700px);
    height: min(70vh, 550px);
    z-index: 2;
}

.icon-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.icon-cell:hover {
    transform: scale(1.05);
}

.catalogue-icon {
    width: 48px;
    height: 48px;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.icon-cell:hover .catalogue-icon {
    transform: scale(1.15);
}

.icon-cell:hover .catalogue-icon .icon-path {
    stroke: var(--near-black);
}

.icon-label {
    font-family: 'Recursive', sans-serif;
    font-variation-settings: 'CASL' 0.7, 'MONO' 0, 'wght' 350;
    font-size: 0.7rem;
    color: var(--medium-grey);
    margin-top: 8px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    transition: color 0.3s ease;
}

.icon-cell:hover .icon-label {
    color: var(--near-black);
}

/* Icon blob morph on hover */
.icon-cell:hover .catalogue-icon {
    filter: url(#blob-morph-target);
}

/* Simulated blob morph via border-radius animation */
.icon-cell::before {
    content: '';
    position: absolute;
    width: 60px;
    height: 60px;
    background: var(--light-grey);
    border-radius: 50%;
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), border-radius 0.6s ease;
    z-index: -1;
}

.icon-cell:hover::before {
    opacity: 0.3;
    transform: scale(1);
    border-radius: 60% 40% 55% 45% / 50% 60% 40% 50%;
}

/* ==========================================================================
   CHAMBER 3: THE READING ROOM
   ========================================================================== */

.reading-blob {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    height: 500px;
    background: var(--off-white);
    border-radius: 55% 45% 60% 40% / 45% 55% 45% 55%;
    z-index: 0;
    animation: reading-blob-breathe 8s ease-in-out infinite;
}

@keyframes reading-blob-breathe {
    0%, 100% { transform: translate(-50%, -50%) scale(1.0); }
    50% { transform: translate(-50%, -50%) scale(1.03); }
}

.reading-room-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    gap: 48px;
    width: min(80vw, 800px);
    z-index: 2;
    padding: 40px;
}

.reading-col {
    flex: 1;
}

.reading-heading {
    font-family: 'Recursive', sans-serif;
    font-variation-settings: 'CASL' 0, 'MONO' 0, 'wght' 700;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: var(--near-black);
    letter-spacing: -0.03em;
    margin-bottom: 1.5rem;
    line-height: 1.1;
}

.reading-text {
    font-family: 'Recursive', sans-serif;
    font-variation-settings: 'CASL' 0, 'MONO' 0, 'wght' 400;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    color: #2a2a2a;
    line-height: 1.65;
    max-width: 38ch;
    margin-bottom: 1.25rem;
    letter-spacing: 0.01em;
}

.reading-text-annotation {
    font-variation-settings: 'CASL' 0.7, 'MONO' 0, 'wght' 350;
    font-size: 0.85rem;
    color: var(--medium-grey);
    font-style: normal;
    border-left: 2px solid var(--light-grey);
    padding-left: 16px;
}

/* ==========================================================================
   CHAMBER 4: THE OBSERVATORY
   ========================================================================== */

.observatory-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.observatory-rings {
    width: min(80vw, 600px);
    height: min(80vh, 600px);
}

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

.ring text {
    font-family: 'Recursive', sans-serif;
    fill: var(--paper);
    font-size: 11px;
    letter-spacing: 0.04em;
}

.ring-1 text {
    font-variation-settings: 'CASL' 0, 'MONO' 0, 'wght' 350;
    font-size: 11px;
    opacity: 0.5;
}

.ring-2 text {
    font-variation-settings: 'CASL' 0.3, 'MONO' 0, 'wght' 400;
    font-size: 11.5px;
    opacity: 0.6;
}

.ring-3 text {
    font-variation-settings: 'CASL' 0.5, 'MONO' 0, 'wght' 450;
    font-size: 12px;
    opacity: 0.7;
}

.ring-4 text {
    font-variation-settings: 'CASL' 0.7, 'MONO' 0, 'wght' 500;
    font-size: 12.5px;
    opacity: 0.85;
}

.ring-1 {
    animation: ring-rotate-1 60s linear infinite;
    transform-origin: 300px 300px;
}

.ring-2 {
    animation: ring-rotate-2 45s linear infinite;
    transform-origin: 300px 300px;
}

.ring-3 {
    animation: ring-rotate-3 35s linear infinite;
    transform-origin: 300px 300px;
}

.ring-4 {
    animation: ring-rotate-4 25s linear infinite;
    transform-origin: 300px 300px;
}

@keyframes ring-rotate-1 {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes ring-rotate-2 {
    from { transform: rotate(0deg); }
    to { transform: rotate(-360deg); }
}

@keyframes ring-rotate-3 {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes ring-rotate-4 {
    from { transform: rotate(0deg); }
    to { transform: rotate(-360deg); }
}

.observatory-eye {
    transform-origin: 300px 300px;
}

/* ==========================================================================
   CHAMBER 5: THE THRESHOLD
   ========================================================================== */

.threshold-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 2;
}

.threshold-text {
    font-family: 'Recursive', sans-serif;
    font-variation-settings: 'CASL' 0, 'MONO' 0, 'wght' 100;
    font-size: clamp(1.8rem, 4vw, 3.5rem);
    color: var(--near-black);
    letter-spacing: -0.02em;
    line-height: 1.2;
    transition: font-variation-settings 0.1s linear;
}

.threshold-blob {
    width: 80px;
    height: 80px;
    background: var(--light-grey);
    border-radius: 55% 45% 60% 40% / 50% 55% 45% 50%;
    margin: 48px auto 0;
    opacity: 0;
    transform: scale(1);
    transition: opacity 0.3s ease;
}

.threshold-blob.pulse {
    animation: blob-heartbeat 600ms ease-in-out forwards;
    opacity: 1;
}

@keyframes blob-heartbeat {
    0% { transform: scale(1.0); opacity: 1; }
    50% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1.0); opacity: 1; }
}

/* ===== Chamber 4 dark dot-grid hide ===== */
#chamber-4 ~ #dot-grid,
.chamber-dark #dot-grid {
    display: none;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .catalogue-grid {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(4, 1fr);
        gap: 20px;
        width: 90vw;
    }

    .reading-room-content {
        flex-direction: column;
        gap: 24px;
        width: 90vw;
        padding: 20px;
    }

    .foyer-blob {
        width: 280px;
        height: 250px;
    }

    .reading-blob {
        width: 320px;
        height: 320px;
    }

    .observatory-rings {
        width: 90vw;
        height: 90vw;
    }
}
