/* === CSS Custom Properties === */
:root {
    --midnight-indigo: #1a1035;
    --smoky-plum: #3d2066;
    --ritual-teal: #00d4aa;
    --ember-coral: #ff6b6b;
    --spectral-lavender: #e0d4f5;
    --dusty-mauve: #b8b0c8;
    --obsidian-purple: #0d0a1a;
    --dusk-violet: #2a1548;
    --scroll-depth: 0;
    --grid-gap: 4px;
}

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

html {
    scroll-behavior: auto;
}

body {
    background-color: var(--midnight-indigo);
    color: var(--dusty-mauve);
    font-family: 'Albert Sans', sans-serif;
    font-size: clamp(0.95rem, 1.1vw, 1.15rem);
    line-height: 1.7;
    letter-spacing: 0.015em;
    overflow-x: hidden;
    background-image: linear-gradient(
        to bottom,
        var(--midnight-indigo) 0%,
        color-mix(in srgb, var(--midnight-indigo) calc((1 - var(--scroll-depth)) * 100%), var(--obsidian-purple)) 100%
    );
}

/* === Symbol Navigation === */
#symbol-nav {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.nav-glyph {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: crosshair;
    flex-direction: row-reverse;
}

.nav-glyph svg {
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    flex-shrink: 0;
}

.nav-glyph:hover svg {
    transform: scale(1.3);
}

.nav-label {
    font-family: 'Space Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--ritual-teal);
    opacity: 0;
    transform: translateX(10px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    white-space: nowrap;
}

.nav-glyph:hover .nav-label {
    opacity: 1;
    transform: translateX(0);
}

/* === Threshold Grid === */
.threshold-grid {
    height: 100vh;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    grid-template-rows: 2fr 1fr 1fr;
    gap: var(--grid-gap);
    padding: var(--grid-gap);
    position: relative;
}

.grid-cell {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 2px solid transparent;
    transition: border-color 0.25s ease;
    cursor: crosshair;
    opacity: 0;
    transform: translateY(30px);
}

.grid-cell.entered {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.01s, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.grid-cell:hover {
    border-color: var(--ritual-teal);
}

.cell-title {
    grid-row: 1 / 3;
    grid-column: 1 / 2;
    background: var(--smoky-plum);
}

.cell-triangle {
    background: var(--dusk-violet);
}

.cell-circle {
    background: var(--smoky-plum);
}

.cell-zigzag {
    grid-column: 2 / 3;
    background: var(--dusk-violet);
}

.cell-square {
    background: var(--midnight-indigo);
    border: 1px solid rgba(0, 212, 170, 0.15);
}

.cell-dot {
    background: var(--smoky-plum);
}

.cell-lines {
    background: var(--dusk-violet);
}

/* === Title Totem === */
.totem-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 0.9;
    z-index: 1;
}

.totem-letter {
    font-family: 'Righteous', cursive;
    font-size: clamp(2.5rem, 8vw, 6rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--spectral-lavender);
    text-shadow: 0 0 40px rgba(138, 92, 246, 0.3);
    display: block;
}

.cell-subtitle {
    font-family: 'Space Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--ritual-teal);
    margin-top: 1rem;
    z-index: 1;
}

/* === Concentric Rings === */
.concentric-rings {
    position: absolute;
    width: 80%;
    height: 80%;
    top: 10%;
    left: 10%;
    z-index: 0;
}

.ring {
    transform-origin: center;
}

.ring-1 {
    animation: ring-pulse 8s ease-in-out infinite;
}

.ring-2 {
    animation: ring-pulse 12s ease-in-out infinite reverse;
}

.ring-3 {
    animation: ring-pulse 16s ease-in-out infinite;
}

@keyframes ring-pulse {
    0%, 100% { stroke-dashoffset: 0; }
    50% { stroke-dashoffset: 40; }
}

/* === Cell Glyphs & Labels === */
.cell-glyph {
    width: 50%;
    max-width: 80px;
    height: auto;
}

.cell-label {
    font-family: 'Space Mono', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--ritual-teal);
    margin-top: 0.75rem;
}

/* === Terrazzo Overlay === */
.terrazzo-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

/* === Zigzag Divider === */
.zigzag-divider {
    padding: 0.5rem 0;
}

/* === Scroll Panels === */
.scroll-panels,
.myths-section {
    padding: var(--grid-gap);
}

.panel-row {
    display: flex;
    gap: var(--grid-gap);
    margin-bottom: var(--grid-gap);
}

.panel {
    position: relative;
    background: var(--smoky-plum);
    border: 2px solid transparent;
    overflow: hidden;
    cursor: crosshair;
    transition: border-color 0.25s ease;
    min-height: 280px;
}

.panel:hover {
    border-color: var(--ritual-teal);
}

.panel:hover .panel-terrazzo {
    opacity: 0.6;
}

.panel-terrazzo {
    position: absolute;
    inset: 0;
    opacity: 0.15;
    transition: opacity 0.4s ease;
    pointer-events: none;
    background-image:
        radial-gradient(circle 3px at 15% 20%, var(--ember-coral) 100%, transparent 100%),
        radial-gradient(circle 4px at 45% 70%, var(--ritual-teal) 100%, transparent 100%),
        radial-gradient(circle 3px at 75% 35%, var(--spectral-lavender) 100%, transparent 100%),
        radial-gradient(circle 5px at 85% 80%, var(--ember-coral) 100%, transparent 100%),
        radial-gradient(circle 3px at 30% 90%, var(--ritual-teal) 100%, transparent 100%),
        radial-gradient(circle 4px at 60% 15%, var(--spectral-lavender) 100%, transparent 100%);
}

.panel-wide {
    flex: 2;
}

.panel-narrow {
    flex: 1;
}

.panel-square {
    flex: 1;
    aspect-ratio: 1;
}

.panel-full {
    flex: 1;
    width: 100%;
}

.panel-content {
    position: relative;
    z-index: 1;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    height: 100%;
}

.panel-content-horizontal {
    flex-direction: row;
    align-items: center;
    gap: 3rem;
}

.panel-heading {
    font-family: 'Righteous', cursive;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--spectral-lavender);
    text-shadow: 0 0 40px rgba(138, 92, 246, 0.3);
    margin-bottom: 1rem;
}

.panel-heading-sm {
    font-family: 'Righteous', cursive;
    font-size: clamp(1.2rem, 2vw, 1.6rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--spectral-lavender);
    text-shadow: 0 0 40px rgba(138, 92, 246, 0.3);
    margin-bottom: 0.75rem;
}

.panel-text {
    color: var(--dusty-mauve);
    max-width: 38ch;
    margin-bottom: 1rem;
}

.panel-label {
    font-family: 'Space Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--ritual-teal);
    margin-top: auto;
}

.panel-illustration {
    width: 120px;
    height: auto;
    margin: 1rem 0;
}

.panel-illustration-large {
    width: 180px;
    height: auto;
    flex-shrink: 0;
}

.panel-glyph {
    width: 48px;
    height: auto;
    margin-top: auto;
}

/* === Mandala === */
.panel-mandala {
    width: 120px;
    height: auto;
    margin: 0 auto 1rem;
}

.mandala-ring-1 {
    animation: mandala-spin 20s linear infinite;
    transform-origin: 75px 75px;
}

.mandala-ring-2 {
    animation: mandala-spin 30s linear infinite reverse;
    transform-origin: 75px 75px;
}

.mandala-ring-3 {
    animation: mandala-spin 45s linear infinite;
    transform-origin: 75px 75px;
}

@keyframes mandala-spin {
    to { transform: rotate(360deg); }
}

/* === Totem Stacks === */
.totem-stack {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 160px;
    z-index: 1;
}

.totem-left {
    left: 1rem;
}

.totem-right {
    right: 1rem;
}

.totem-circle {
    animation: totem-rotate 60s linear infinite;
    transform-origin: 20px 20px;
}

.totem-triangle {
    animation: totem-rotate 45s linear infinite reverse;
    transform-origin: 20px 65px;
}

.totem-rect {
    animation: totem-rotate 90s linear infinite;
    transform-origin: 20px 105px;
}

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

/* === Scroll Reveal === */
.scroll-reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.01s, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* === Myths Section === */
.myths-row {
    display: flex;
    gap: var(--grid-gap);
}

.myths-section .panel-narrow {
    background: var(--dusk-violet);
}

/* === Corridor Section === */
.corridor-section {
    padding: 2rem var(--grid-gap);
}

.corridor-stage {
    margin-bottom: var(--grid-gap);
    display: grid;
    gap: var(--grid-gap);
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    transition: max-width 0.8s ease-out;
}

.corridor-8 {
    grid-template-columns: 1fr 1fr;
    max-width: 80%;
}

.corridor-4 {
    grid-template-columns: 1fr;
    max-width: 55%;
}

.corridor-2 {
    grid-template-columns: 1fr;
    max-width: 35%;
}

.corridor-1 {
    grid-template-columns: 1fr;
    max-width: 500px;
}

.corridor-panel {
    background: var(--smoky-plum);
    padding: 2rem;
    position: relative;
    overflow: hidden;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    border: 2px solid transparent;
    transition: border-color 0.25s ease;
    cursor: crosshair;
}

.corridor-panel:hover {
    border-color: var(--ritual-teal);
}

.corridor-panel:hover .panel-terrazzo {
    opacity: 0.6;
}

.corridor-panel-wide {
    grid-column: 1 / -1;
}

.corridor-panel-center {
    text-align: center;
    align-items: center;
}

.corridor-illustration {
    width: 100px;
    height: auto;
    margin: 1rem 0;
}

/* === Final Panel === */
.corridor-final {
    align-items: center;
    text-align: center;
    padding: 3rem 2rem;
    background: var(--dusk-violet);
    border: 2px solid transparent;
    animation: pulse-attention 3s ease-in-out infinite;
}

.final-glyph {
    width: 120px;
    height: auto;
    margin-bottom: 2rem;
}

.pulse-ring {
    animation: pulse-ring-anim 3s ease-in-out infinite;
    transform-origin: 60px 60px;
}

@keyframes pulse-ring-anim {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

@keyframes pulse-attention {
    0%, 100% { transform: scale(1); border-color: var(--ember-coral); }
    50% { transform: scale(1.02); border-color: var(--ember-coral); }
}

.final-text {
    font-family: 'Righteous', cursive;
    font-size: clamp(1.3rem, 3vw, 2rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--spectral-lavender);
    text-shadow: 0 0 40px rgba(138, 92, 246, 0.3);
}

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

    .cell-title {
        grid-row: 1 / 2;
        grid-column: 1 / -1;
        min-height: 50vh;
    }

    .totem-title {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }

    .totem-letter {
        font-size: clamp(2rem, 10vw, 4rem);
    }

    .panel-row,
    .myths-row {
        flex-direction: column;
    }

    .panel-content-horizontal {
        flex-direction: column;
    }

    .corridor-8 {
        max-width: 95%;
        grid-template-columns: 1fr;
    }

    .corridor-4 { max-width: 90%; }
    .corridor-2 { max-width: 80%; }
    .corridor-1 { max-width: 95%; }

    .totem-stack { display: none; }

    #symbol-nav {
        top: 0.75rem;
        right: 0.75rem;
    }
}
