/* ===== CSS Custom Properties ===== */
:root {
    --deep-obsidian: #1a1209;
    --warm-parchment: #f2e8d4;
    --aged-ivory: #e8dcc6;
    --charred-umber: #2a1f14;
    --burnished-gold: #c9943a;
    --tarnished-brass: #b8953e;
    --ember-rose: #c45c3a;
    --ash-veil: #6b5d4f;
    --grain-opacity: 0.08;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--deep-obsidian);
    color: var(--aged-ivory);
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.25rem);
    line-height: 1.75;
    overflow-x: hidden;
}

/* ===== Grain Overlay ===== */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    filter: url(#grain);
    opacity: var(--grain-opacity);
    mix-blend-mode: overlay;
    background: transparent;
}

/* ===== Typography ===== */
.chamber-label {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--ash-veil);
    display: block;
    margin-bottom: 1.5rem;
}

.word-strike {
    font-weight: 900;
    font-family: 'Playfair Display', serif;
    color: var(--burnished-gold);
}

/* ===== THE THRESHOLD ===== */
.threshold {
    display: grid;
    place-items: center;
    height: 100vh;
    position: relative;
    background: linear-gradient(180deg, var(--deep-obsidian) 0%, rgba(201, 148, 58, 0.08) 100%);
    --grain-opacity: 0.1;
}

.threshold-title {
    font-family: 'Playfair Display', serif;
    font-weight: 400;
    font-size: clamp(5rem, 15vw, 12rem);
    letter-spacing: -0.04em;
    color: var(--aged-ivory);
    text-align: center;
    line-height: 1;
}

.threshold-line {
    position: absolute;
    bottom: 10vh;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 0;
    background-color: var(--burnished-gold);
    animation: lineGrow 2s cubic-bezier(0.23, 1, 0.32, 1) 0.5s forwards;
}

@keyframes lineGrow {
    to {
        height: 40vh;
    }
}

/* ===== CHAMBERS (Bento Grid) ===== */
.chambers {
    padding: clamp(1rem, 3vw, 3rem);
}

.bento-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 3px;
    max-width: 1400px;
    margin: 0 auto;
}

.chamber {
    border: 3px solid var(--tarnished-brass);
    padding: clamp(1.5rem, 3vw, 3rem);
    overflow: hidden;
    position: relative;
    transition: border-color 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

.chamber:hover {
    border-color: var(--burnished-gold);
}

.chamber[data-bg="dark"] {
    background-color: var(--deep-obsidian);
    color: var(--aged-ivory);
}

.chamber[data-bg="light"] {
    background-color: var(--warm-parchment);
    color: var(--charred-umber);
}

.chamber[data-bg="light"] .chamber-label {
    color: var(--ash-veil);
}

/* Chamber grid placements */
.chamber-hero {
    grid-column: span 8;
    min-height: 60vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.chamber-aphorism {
    grid-column: span 4;
    min-height: 60vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.chamber-scale {
    grid-column: span 4;
    min-height: 40vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.chamber-aphorism-2 {
    grid-column: span 4;
    min-height: 30vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.chamber-mandala-2 {
    grid-column: span 4;
    min-height: 40vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.chamber-fragment {
    grid-column: span 12;
    min-height: 30vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

/* Second bento grid */
.chamber-mandala-3 {
    grid-column: span 6;
    min-height: 50vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.chamber-final-aphorism {
    grid-column: span 6;
    min-height: 50vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.chamber-scale-2 {
    grid-column: span 12;
    min-height: 35vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Aphorism text */
.aphorism-text {
    font-family: 'Playfair Display', serif;
    font-weight: 400;
    font-size: clamp(2.5rem, 5vw, 4.5rem);
    letter-spacing: -0.04em;
    line-height: 1.15;
}

.aphorism-text-sm {
    font-family: 'Source Serif 4', serif;
    font-weight: 300;
    font-size: clamp(1.25rem, 2vw, 1.75rem);
    line-height: 1.6;
}

.fragment-text {
    font-family: 'Playfair Display', serif;
    font-weight: 400;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    letter-spacing: -0.02em;
    max-width: 700px;
}

/* Chamber hover lift */
.chamber .aphorism-text,
.chamber .aphorism-text-sm,
.chamber .fragment-text {
    transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

.chamber:hover .aphorism-text,
.chamber:hover .aphorism-text-sm,
.chamber:hover .fragment-text {
    transform: translateY(-2px);
}

/* ===== Mandalas ===== */
.mandala {
    width: min(80%, 300px);
    height: auto;
    animation: mandalaSpin 30s linear infinite;
}

.mandala-sm {
    width: min(70%, 220px);
}

@keyframes mandalaSpin {
    to {
        transform: rotate(360deg);
    }
}

.facet {
    transition: fill 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

.facet:hover {
    fill: rgba(201, 148, 58, 0.15);
}

/* ===== Justice Scales ===== */
.justice-scale {
    width: min(70%, 250px);
    height: auto;
}

.scale-group {
    transform-origin: 100px 100px;
    animation: scaleOscillate 4s ease-in-out infinite;
}

@keyframes scaleOscillate {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(3deg); }
    75% { transform: rotate(-3deg); }
}

.justice-scale-tilted .scale-group {
    animation: scaleOscillateTilted 5s ease-in-out infinite;
}

@keyframes scaleOscillateTilted {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

/* ===== Fracture Lines ===== */
.fractures {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.fracture-line {
    transition: stroke-dashoffset 1.5s ease-out 0.5s;
}

.chamber.visible .fracture-line {
    stroke-dashoffset: 0;
}

/* ===== THE NAVE ===== */
.nave {
    padding: 12vh 0;
    background-color: var(--deep-obsidian);
    --grain-opacity: 0.06;
}

.nave-content {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 clamp(1.5rem, 3vw, 3rem);
}

.nave-heading {
    font-family: 'Playfair Display', serif;
    font-weight: 400;
    font-size: clamp(2.5rem, 5vw, 4.5rem);
    letter-spacing: -0.04em;
    line-height: 1.1;
    margin-bottom: 3rem;
    color: var(--aged-ivory);
}

.nave-passage {
    font-family: 'Source Serif 4', serif;
    font-weight: 300;
    font-size: clamp(1rem, 1.2vw, 1.25rem);
    line-height: 1.75;
    color: var(--aged-ivory);
    margin-bottom: 2rem;
}

.nave-passage:last-child {
    margin-bottom: 0;
}

/* ===== THE CRYPT ===== */
.crypt {
    min-height: 80vh;
    display: grid;
    place-items: center;
    background-color: var(--deep-obsidian);
    position: relative;
    --grain-opacity: 0.12;
}

.crypt-content {
    text-align: center;
    position: relative;
}

.crypt-mandala {
    width: min(60vw, 300px);
    height: auto;
    margin-bottom: 4rem;
    animation: mandalaSpin 30s linear infinite;
}

/* Shatter effect */
.shard {
    transition: transform 1.2s cubic-bezier(0.23, 1, 0.32, 1), opacity 1.2s ease;
}

.crypt-content.visible .shard {
    transform: translate(var(--shard-x), var(--shard-y)) rotate(var(--shard-r));
    opacity: 0.4;
}

.crypt-inscription {
    font-family: 'Playfair Display', serif;
    font-weight: 400;
    font-size: clamp(1.25rem, 2.5vw, 2rem);
    letter-spacing: -0.02em;
    color: var(--aged-ivory);
    opacity: 0;
    transition: opacity 1.5s ease 0.8s;
}

.crypt-content.visible .crypt-inscription {
    opacity: 1;
}

/* ===== Scroll Reveal ===== */
.reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.23, 1, 0.32, 1);
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger children */
.reveal.visible:nth-child(2) { transition-delay: 0.1s; }
.reveal.visible:nth-child(3) { transition-delay: 0.2s; }
.reveal.visible:nth-child(4) { transition-delay: 0.3s; }
.reveal.visible:nth-child(5) { transition-delay: 0.4s; }
.reveal.visible:nth-child(6) { transition-delay: 0.5s; }

/* ===== Mobile Responsive ===== */
@media (max-width: 768px) {
    .bento-grid {
        grid-template-columns: 1fr;
    }

    .chamber-hero,
    .chamber-aphorism,
    .chamber-scale,
    .chamber-aphorism-2,
    .chamber-mandala-2,
    .chamber-fragment,
    .chamber-mandala-3,
    .chamber-final-aphorism,
    .chamber-scale-2 {
        grid-column: span 1;
    }

    .threshold-title {
        font-size: clamp(3rem, 12vw, 6rem);
    }
}
