/* luminary.dev - Earth-Tones Luminous Design */
/* Fonts: Playfair Display (900, 700), DM Sans (400, 500), Space Mono (400) */
/* Palette: #d4a040, #1a1408, #b35c3a, #6b7c54, #f0e6d2, #3d2e0a, #00e5c7, #c87d3b, #8b6914, #0d0a04 */

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

html {
    scroll-behavior: auto;
}

body {
    background: #0d0a04;
    color: #f0e6d2;
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    line-height: 1.7;
    letter-spacing: 0.01em;
    overflow-x: hidden;
}

/* Main scroll container */
#chambers {
    scroll-snap-type: y mandatory;
    overflow-y: scroll;
    height: 100vh;
    scroll-behavior: auto;
}

/* Chamber base styles */
.chamber {
    height: 100vh;
    width: 100%;
    position: relative;
    scroll-snap-align: start;
    overflow: hidden;
}

/* Refractive interstices between chambers */
.interstice {
    height: 20vh;
    width: 100%;
    position: relative;
    scroll-snap-align: none;
}

.interstice-1 {
    background: linear-gradient(180deg, #1a1408 0%, #0d0a04 100%);
}

.interstice-2 {
    background: linear-gradient(180deg, #0d0a04 0%, #1a1408 50%, #0d0a04 100%);
}

.interstice-3 {
    background: linear-gradient(180deg, #1a1408 0%, #0d0a04 100%);
}

.interstice-4 {
    background: linear-gradient(180deg, #0d0a04 0%, #3d2e0a 50%, #0d0a04 100%);
}

/* Seam luminescence lines */
.seam-line {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: rgba(212, 160, 64, 0.3);
    box-shadow: 0 0 20px 4px rgba(212, 160, 64, 0.3);
}

/* Chamber content centering */
.chamber-content {
    position: relative;
    width: 100%;
    height: 100%;
    z-index: 2;
}

/* ========================================= */
/* CHAMBER 1 - The Incandescent Foyer        */
/* ========================================= */
#chamber-1 {
    background:
        radial-gradient(ellipse at 35% 30%, rgba(212, 160, 64, 0.4) 0%, transparent 50%),
        radial-gradient(ellipse at 65% 70%, rgba(179, 92, 58, 0.2) 0%, transparent 40%),
        linear-gradient(180deg, #1a1408 0%, #0d0a04 100%);
}

#chamber-1 .chamber-content {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 38vh;
}

.copper-bezel {
    display: inline-block;
    padding: 24px 48px;
    border: 2px solid #8b6914;
    box-shadow:
        inset 0 1px 0 rgba(240, 230, 210, 0.1),
        inset 0 -1px 0 rgba(26, 20, 8, 0.3),
        0 0 40px rgba(212, 160, 64, 0.15);
    background: linear-gradient(180deg, rgba(240, 230, 210, 0.05) 0%, transparent 50%, rgba(26, 20, 8, 0.1) 100%);
    position: relative;
}

.embossed-title {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(4rem, 10vw, 8rem);
    letter-spacing: -0.04em;
    color: #d4a040;
    text-shadow:
        1px 1px 0px #1a1408,
        -1px -1px 0px rgba(212, 160, 64, 0.3);
    opacity: 0;
    transform: scale(1.02);
    animation: embossEntrance 600ms cubic-bezier(0.16, 1, 0.3, 1) 300ms forwards;
}

@keyframes embossEntrance {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Large crystal SVG in Chamber 1 */
.crystal-large {
    position: absolute;
    width: 200px;
    height: 340px;
    right: -20px;
    top: 55%;
    transform: rotate(15deg);
    pointer-events: none;
    z-index: 1;
    opacity: 0.7;
}

/* ========================================= */
/* CHAMBER 2 - The Spectrometer              */
/* ========================================= */
#chamber-2 {
    background:
        radial-gradient(ellipse at 20% 50%, rgba(139, 105, 20, 0.15) 0%, transparent 50%),
        linear-gradient(180deg, #0d0a04 0%, #1a1408 50%, #0d0a04 100%);
}

.spectrometer-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5vh 5vw;
}

.chamber-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    letter-spacing: -0.04em;
    color: #d4a040;
    text-shadow:
        1px 1px 0px #1a1408,
        -1px -1px 0px rgba(212, 160, 64, 0.3);
    margin-bottom: 4vh;
}

.emboss-entrance {
    opacity: 0;
    transform: scale(1.02);
}

.emboss-entrance.visible {
    animation: embossEntrance 600ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Prism container */
.prism-container {
    position: relative;
    width: 80%;
    max-width: 800px;
    height: 50vh;
    display: flex;
    align-items: center;
}

.prism {
    width: 120px;
    height: 280px;
    position: relative;
    flex-shrink: 0;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: linear-gradient(135deg,
        rgba(212, 160, 64, 0.3) 0%,
        rgba(240, 230, 210, 0.15) 30%,
        rgba(0, 229, 199, 0.1) 50%,
        rgba(139, 105, 20, 0.2) 70%,
        rgba(212, 160, 64, 0.25) 100%
    );
    box-shadow: 0 0 30px rgba(212, 160, 64, 0.2);
}

.prism-inner {
    position: absolute;
    inset: 4px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: linear-gradient(160deg,
        rgba(240, 230, 210, 0.08) 0%,
        rgba(0, 229, 199, 0.06) 40%,
        transparent 100%
    );
}

/* Spectrum bands */
.spectrum-bands {
    position: absolute;
    left: 130px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.spectrum-band {
    height: 3px;
    width: clamp(200px, 40vw, 500px);
    position: relative;
    transform-origin: left center;
    border-radius: 0 2px 2px 0;
}

.band-1 {
    background: #00e5c7;
    transform: rotate(-12deg);
    width: clamp(160px, 35vw, 420px);
    height: 2px;
    box-shadow: 0 0 8px rgba(0, 229, 199, 0.4);
}

.band-2 {
    background: #d4a040;
    transform: rotate(-6deg);
    width: clamp(180px, 38vw, 460px);
    height: 2.5px;
    box-shadow: 0 0 6px rgba(212, 160, 64, 0.3);
}

.band-3 {
    background: #c87d3b;
    transform: rotate(0deg);
    width: clamp(200px, 40vw, 500px);
    height: 3px;
    box-shadow: 0 0 6px rgba(200, 125, 59, 0.3);
}

.band-4 {
    background: #b35c3a;
    transform: rotate(6deg);
    width: clamp(180px, 38vw, 460px);
    height: 2.5px;
    box-shadow: 0 0 6px rgba(179, 92, 58, 0.3);
}

.band-5 {
    background: #6b7c54;
    transform: rotate(12deg);
    width: clamp(160px, 35vw, 420px);
    height: 2px;
    box-shadow: 0 0 6px rgba(107, 124, 84, 0.3);
}

.band-text {
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    font-size: 0.65rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    position: absolute;
    right: 0;
    top: -10px;
    color: #f0e6d2;
    opacity: 0.6;
    white-space: nowrap;
}

/* Etched scale marks */
.etch-marks {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 400px;
    opacity: 0.5;
}

/* ========================================= */
/* CHAMBER 3 - The Specimen Drawer           */
/* ========================================= */
#chamber-3 {
    background:
        radial-gradient(ellipse at 50% 40%, rgba(61, 46, 10, 0.4) 0%, transparent 60%),
        linear-gradient(180deg, #0d0a04 0%, #1a1408 50%, #0d0a04 100%);
}

#chamber-3 .chamber-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 4vh 4vw;
}

.specimen-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    max-width: 640px;
    width: 100%;
}

.specimen-box {
    aspect-ratio: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 2px solid rgba(200, 125, 59, 0.4);
    border-radius: 2px;
    cursor: default;
    transition: box-shadow 300ms ease, border-color 300ms ease;
    /* Wood grain texture */
    background:
        repeating-linear-gradient(
            87deg,
            rgba(61, 46, 10, 0.5) 0px,
            rgba(42, 31, 6, 0.6) 2px,
            rgba(61, 46, 10, 0.4) 4px,
            rgba(42, 31, 6, 0.5) 5px,
            rgba(61, 46, 10, 0.45) 8px
        ),
        linear-gradient(180deg, #3d2e0a 0%, #2a1f06 100%);
    box-shadow:
        inset 0 2px 4px rgba(26, 20, 8, 0.6),
        inset 0 -1px 2px rgba(26, 20, 8, 0.3),
        0 2px 8px rgba(26, 20, 8, 0.4);
}

.specimen-box:hover {
    box-shadow:
        inset 0 2px 4px rgba(26, 20, 8, 0.4),
        inset 0 -1px 2px rgba(26, 20, 8, 0.2),
        0 2px 12px rgba(212, 160, 64, 0.15);
}

.specimen-box:hover .specimen-crystal {
    filter: drop-shadow(0 0 16px rgba(212, 160, 64, 0.5));
}

.specimen-crystal {
    width: 50px;
    height: 65px;
    transition: filter 300ms ease;
}

.specimen-label {
    font-family: 'Space Mono', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.15em;
    color: #c87d3b;
    text-transform: uppercase;
    opacity: 0.8;
}

/* Shake error animation for specimen boxes */
@keyframes shake {
    0% { transform: translateX(0); }
    15% { transform: translateX(-4px); }
    30% { transform: translateX(4px); }
    45% { transform: translateX(-3px); }
    60% { transform: translateX(3px); }
    75% { transform: translateX(-1px); }
    90% { transform: translateX(1px); }
    100% { transform: translateX(0); }
}

.specimen-box.shaking {
    animation: shake 300ms ease;
    border-color: #d4a040;
}

/* ========================================= */
/* CHAMBER 4 - The Oscilloscope              */
/* ========================================= */
#chamber-4 {
    background: #0d0a04;
}

.oscilloscope-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 5vh 5vw;
    gap: 3vh;
}

.oscilloscope-screen {
    position: relative;
    width: 90%;
    max-width: 900px;
    height: 200px;
    overflow: hidden;
    border: 1px solid rgba(139, 105, 20, 0.3);
    border-radius: 4px;
}

.oscilloscope-grid {
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(
            90deg,
            rgba(139, 105, 20, 0.08) 0px,
            transparent 1px,
            transparent 40px
        ),
        repeating-linear-gradient(
            0deg,
            rgba(139, 105, 20, 0.08) 0px,
            transparent 1px,
            transparent 40px
        );
    pointer-events: none;
}

.waveform-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.waveform-line {
    /* Waveform is animated via JavaScript requestAnimationFrame */
}



/* Typewriter block */
.typewriter-block {
    width: 90%;
    max-width: 700px;
    min-height: 3em;
    padding: 16px 0;
}

.typewriter-content {
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.85rem, 1.2vw, 1.05rem);
    letter-spacing: 0.08em;
    color: #f0e6d2;
    line-height: 1.8;
}

.typewriter-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: #d4a040;
    vertical-align: text-bottom;
    margin-left: 2px;
    animation: blink 530ms step-end infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ========================================= */
/* CHAMBER 5 - The Afterglow                 */
/* ========================================= */
#chamber-5 {
    background: linear-gradient(180deg, #3d2e0a 0%, #1a1a2e 60%, #0d0a14 100%);
}

.afterglow-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    position: relative;
}

.crystal-fragments {
    position: absolute;
    width: 200px;
    height: 200px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.crystal-fragment {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 6px;
    background: rgba(212, 160, 64, 0.2);
    border: 0.5px solid rgba(212, 160, 64, 0.4);
    clip-path: polygon(20% 0%, 80% 0%, 100% 50%, 80% 100%, 20% 100%, 0% 50%);
    transform: rotate(var(--angle)) translateX(80px);
    transform-origin: 0 0;
    opacity: 0.6;
}

.crystal-fragment:nth-child(even) {
    width: 14px;
    height: 8px;
    transform: rotate(var(--angle)) translateX(95px);
    opacity: 0.4;
    background: rgba(200, 125, 59, 0.15);
    border-color: rgba(200, 125, 59, 0.3);
}

.crystal-fragment:nth-child(3n) {
    width: 8px;
    height: 5px;
    transform: rotate(var(--angle)) translateX(110px);
    opacity: 0.3;
}

.afterglow-dot {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #d4a040;
    box-shadow: 0 0 30px 10px rgba(212, 160, 64, 0.3);
    animation: pulse 4s ease-in-out infinite;
    position: relative;
    z-index: 2;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 30px 10px rgba(212, 160, 64, 0.3);
    }
    50% {
        transform: scale(1.08);
        box-shadow: 0 0 40px 15px rgba(212, 160, 64, 0.4);
    }
}

/* ========================================= */
/* Responsive adjustments                     */
/* ========================================= */
@media (max-width: 640px) {
    .specimen-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        max-width: 360px;
    }

    .specimen-crystal {
        width: 35px;
        height: 46px;
    }

    .copper-bezel {
        padding: 16px 24px;
    }

    .prism {
        width: 80px;
        height: 200px;
    }

    .spectrum-bands {
        left: 90px;
    }

    .crystal-large {
        width: 140px;
        height: 240px;
    }
}
