/* ============================================================
   xanadu.quest — surreal blobitecture, a ritual descent
   ============================================================ */

:root {
    --abyss: #0d0b1f;
    --night-amethyst: #1e1a3a;
    --rose: #ff9ecf;
    --mint: #a0e8d6;
    --amber: #f7c872;
    --selenite: #d8c4ff;
    --parchment: #f3eedc;
    --ice-cyan: #7ce7ff;
    --reverie-time: 0;
    --cursor-x: 0;
    --cursor-y: 0;
    --descent: 0;
}

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

html, body {
    background: var(--abyss);
    color: var(--selenite);
    font-family: "EB Garamond", serif;
    font-weight: 400;
    overflow-x: hidden;
    width: 100%;
    min-height: 100vh;
    cursor: none;
}

body {
    background:
        radial-gradient(ellipse at 20% 10%, rgba(216, 196, 255, 0.08), transparent 60%),
        radial-gradient(ellipse at 80% 90%, rgba(255, 158, 207, 0.08), transparent 60%),
        var(--abyss);
    position: relative;
}

.global-defs {
    position: absolute;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* ============================================================
   Typography
   ============================================================ */

.xanadu-text,
.fragment em,
.parchment-title em {
    font-family: "Cormorant Infant", serif;
}

.micro,
.stratum-label,
.scroll-hint,
.island-caption .micro,
.chamber-coords {
    font-family: "Syne Mono", monospace;
    font-size: 0.72rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.fragment {
    font-family: "Cormorant Infant", serif;
    font-weight: 300;
    font-style: italic;
    font-size: clamp(1.2rem, 2.2vw, 1.8rem);
    line-height: 1.4;
    letter-spacing: -0.01em;
    color: var(--selenite);
    max-width: 28ch;
    z-index: 5;
    text-shadow: 0 0 24px rgba(13, 11, 31, 0.8);
}

.fragment em {
    font-style: italic;
    color: var(--parchment);
}

/* ============================================================
   Minimal Nav — 4 Morphing Dots
   ============================================================ */

.dot-nav {
    position: fixed;
    top: 28px;
    left: 28px;
    display: flex;
    gap: 14px;
    z-index: 100;
    mix-blend-mode: screen;
}

.nav-dot {
    width: 10px;
    height: 10px;
    background: radial-gradient(circle at 30% 30%, var(--rose), var(--mint));
    border-radius: 62% 38% 40% 60% / 45% 60% 40% 55%;
    animation: morphDot 6s ease-in-out infinite;
    cursor: none;
    pointer-events: auto;
    transition: transform 0.3s ease;
}

.nav-dot:nth-child(1) { animation-delay: 0s; }
.nav-dot:nth-child(2) { animation-delay: -1.5s; background: radial-gradient(circle at 30% 30%, var(--selenite), var(--ice-cyan)); }
.nav-dot:nth-child(3) { animation-delay: -3s; background: radial-gradient(circle at 30% 30%, var(--amber), var(--rose)); }
.nav-dot:nth-child(4) { animation-delay: -4.5s; background: radial-gradient(circle at 30% 30%, var(--mint), var(--selenite)); }

.nav-dot.active {
    transform: scale(1.6);
    box-shadow: 0 0 14px rgba(255, 158, 207, 0.8);
}

@keyframes morphDot {
    0%, 100% { border-radius: 62% 38% 40% 60% / 45% 60% 40% 55%; }
    33% { border-radius: 40% 60% 55% 45% / 55% 40% 60% 45%; }
    66% { border-radius: 55% 45% 62% 38% / 40% 55% 45% 60%; }
}

/* ============================================================
   Sound Toggle
   ============================================================ */

.sound-toggle {
    position: fixed;
    top: 24px;
    right: 28px;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    cursor: none;
    z-index: 100;
    padding: 0;
    opacity: 0.55;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.sound-toggle:hover { opacity: 1; transform: scale(1.15); }
.sound-toggle.active { opacity: 1; filter: drop-shadow(0 0 8px var(--amber)); }

.sound-toggle svg path {
    animation: morphDot 10s ease-in-out infinite;
}

/* ============================================================
   Cursor Trail
   ============================================================ */

.cursor-trail {
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 200;
    mix-blend-mode: screen;
}

.cursor-droplet {
    position: fixed;
    top: 0;
    left: 0;
    width: 40px;
    height: 40px;
    pointer-events: none;
    transform: translate(-50%, -50%);
    will-change: transform, opacity;
}

.cursor-droplet[data-idx="0"] { opacity: 1; }
.cursor-droplet[data-idx="1"] { opacity: 0.85; }
.cursor-droplet[data-idx="2"] { opacity: 0.7; }
.cursor-droplet[data-idx="3"] { opacity: 0.55; }
.cursor-droplet[data-idx="4"] { opacity: 0.4; }
.cursor-droplet[data-idx="5"] { opacity: 0.28; }
.cursor-droplet[data-idx="6"] { opacity: 0.18; }

/* ============================================================
   Floating Glyph Field (incense motes)
   ============================================================ */

.glyph-field {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 4;
    overflow: hidden;
}

.mote {
    position: absolute;
    font-family: "Syne Mono", monospace;
    font-size: 16px;
    color: var(--amber);
    opacity: 0.3;
    will-change: transform;
    user-select: none;
}

/* ============================================================
   Strata (sections)
   ============================================================ */

.stratum {
    position: relative;
    width: 100%;
    overflow: hidden;
    isolation: isolate;
}

.stratum-label {
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    color: var(--selenite);
    opacity: 0.65;
    display: flex;
    align-items: center;
    gap: 10px;
    mix-blend-mode: screen;
}

.stratum-label .glyph {
    color: var(--amber);
    font-size: 1rem;
}

.stratum-label-dark {
    color: var(--night-amethyst);
    mix-blend-mode: normal;
    opacity: 0.5;
}
.stratum-label-dark .glyph { color: var(--rose); }

/* ============================================================
   Stratum I — The Dome
   ============================================================ */

.stratum-1 {
    height: 100vh;
    min-height: 720px;
    background:
        radial-gradient(ellipse at 50% 110%, rgba(255, 158, 207, 0.18), transparent 55%),
        radial-gradient(ellipse at 30% 30%, rgba(160, 232, 214, 0.08), transparent 60%),
        linear-gradient(180deg, #0d0b1f 0%, #1e1a3a 80%, #0d0b1f 100%);
}

.dome-wrap {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(calc(0.7 + var(--descent, 0) * 0.35));
    transition: transform 0.15s linear;
    will-change: transform;
}

.dome-svg {
    width: 95%;
    height: 85%;
    max-height: 90vh;
    overflow: visible;
}

.xanadu-title {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 75%;
    max-width: 1200px;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 3;
}

.xanadu-svg {
    width: 100%;
    height: auto;
    overflow: visible;
}

.xanadu-text {
    font-family: "Cormorant Infant", serif;
    font-weight: 500;
    font-style: italic;
    font-size: 240px;
    letter-spacing: -0.05em;
    fill: url(#irid-chrome);
}

.xanadu-ghost {
    fill: none;
    stroke: rgba(216, 196, 255, 0.25);
    stroke-width: 1;
}

.fragment-tl {
    position: absolute;
    top: 18%;
    left: 9%;
    text-align: left;
}

.fragment-br {
    position: absolute;
    bottom: 18%;
    right: 9%;
    text-align: right;
}

.scroll-hint {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--selenite);
    opacity: 0.55;
    z-index: 6;
    animation: bobHint 3.5s ease-in-out infinite;
}

.scroll-hint .arrow {
    font-size: 1rem;
}

@keyframes bobHint {
    0%, 100% { transform: translate(-50%, 0); opacity: 0.4; }
    50% { transform: translate(-50%, 6px); opacity: 0.75; }
}

/* ============================================================
   Stratum II — The River (horizontal scroll chamber)
   ============================================================ */

.stratum-2 {
    height: 180vh;
    min-height: 1400px;
    background:
        radial-gradient(ellipse at 20% 40%, rgba(124, 231, 255, 0.08), transparent 55%),
        radial-gradient(ellipse at 80% 60%, rgba(255, 158, 207, 0.09), transparent 55%),
        linear-gradient(180deg, #0d0b1f, #1e1a3a 50%, #0d0b1f);
}

.river-viewport {
    position: sticky;
    top: 0;
    height: 100vh;
    width: 100%;
    overflow: hidden;
}

.river-track {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 300vw;
    will-change: transform;
    transform: translate3d(0, 0, 0);
}

.river-svg {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 60%;
    transform: translateY(-50%);
    overflow: visible;
}

.river-flow {
    animation: flow 18s linear infinite;
    filter: drop-shadow(0 0 14px rgba(124, 231, 255, 0.4));
}

@keyframes flow {
    to { stroke-dashoffset: -520; }
}

.island {
    position: absolute;
    width: 320px;
    height: 260px;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: floatIsle 8s ease-in-out infinite;
}

.island svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    filter: drop-shadow(0 0 40px rgba(216, 196, 255, 0.3));
}

.island-amethyst { animation-delay: 0s; }
.island-selenite { animation-delay: -2s; }
.island-labradorite { animation-delay: -4s; }
.island-amber { animation-delay: -1s; }
.island-cyan { animation-delay: -6s; }

@keyframes floatIsle {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-14px); }
}

.island-caption {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 20px;
    color: var(--parchment);
}

.island-caption .micro {
    display: block;
    color: var(--amber);
    opacity: 0.85;
    margin-bottom: 8px;
}

.island-caption em {
    font-family: "Cormorant Infant", serif;
    font-style: italic;
    font-weight: 300;
    font-size: 1.1rem;
    line-height: 1.4;
    color: var(--parchment);
    text-shadow: 0 0 18px rgba(13, 11, 31, 0.9);
}

.river-progress {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--selenite);
    opacity: 0.6;
    z-index: 10;
}

.river-bar {
    width: 180px;
    height: 2px;
    background: rgba(216, 196, 255, 0.15);
    border-radius: 2px;
    overflow: hidden;
}

.river-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--ice-cyan), var(--selenite), var(--rose));
    transition: width 0.15s linear;
}

/* ============================================================
   Stratum III — Caves of Ice
   ============================================================ */

.stratum-3 {
    height: 100vh;
    min-height: 720px;
    background: var(--abyss);
    position: relative;
}

.aurora-field {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: var(--abyss);
}

.aurora-layer {
    position: absolute;
    inset: -20%;
    mix-blend-mode: screen;
    will-change: transform, filter;
    opacity: 0.85;
}

.aurora-1 {
    background: radial-gradient(circle at 30% 50%, var(--selenite) 0%, transparent 50%);
    animation: drift1 24s ease-in-out infinite;
}

.aurora-2 {
    background: radial-gradient(circle at 70% 40%, var(--mint) 0%, transparent 55%);
    animation: drift2 28s ease-in-out infinite;
}

.aurora-3 {
    background: radial-gradient(circle at 50% 70%, var(--rose) 0%, transparent 50%);
    animation: drift3 26s ease-in-out infinite;
}

@keyframes drift1 {
    0%, 100% { transform: translate(-5%, -3%) scale(1); filter: hue-rotate(0deg); }
    50% { transform: translate(8%, 6%) scale(1.1); filter: hue-rotate(-6deg); }
}
@keyframes drift2 {
    0%, 100% { transform: translate(6%, 4%) scale(1); filter: hue-rotate(0deg); }
    50% { transform: translate(-7%, -6%) scale(1.08); filter: hue-rotate(6deg); }
}
@keyframes drift3 {
    0%, 100% { transform: translate(3%, -5%) scale(1); filter: hue-rotate(0deg); }
    50% { transform: translate(-4%, 7%) scale(1.12); filter: hue-rotate(-3deg); }
}

.caves-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
}

.caves-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.hollow-captions {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
}

.hollow-cap {
    position: absolute;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--ice-cyan);
    mix-blend-mode: screen;
    filter: drop-shadow(0 0 10px rgba(124, 231, 255, 0.6));
}

.hollow-cap .micro {
    display: block;
    color: var(--amber);
    margin-bottom: 6px;
}

.hollow-cap em {
    font-family: "Cormorant Infant", serif;
    font-style: italic;
    font-weight: 300;
    font-size: clamp(1rem, 1.6vw, 1.5rem);
    line-height: 1.3;
    letter-spacing: -0.02em;
}

/* ============================================================
   Stratum IV — Pleasure-Dome Interior (3D chamber)
   ============================================================ */

.stratum-4 {
    height: 120vh;
    min-height: 900px;
    background:
        radial-gradient(ellipse at 50% 50%, rgba(30, 26, 58, 0.85) 0%, var(--abyss) 70%);
    perspective: 1400px;
    overflow: hidden;
}

.chamber-perspective {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 1400px;
    perspective-origin: 50% 50%;
}

.chamber-3d {
    position: relative;
    width: 520px;
    height: 520px;
    transform-style: preserve-3d;
    transform: rotateX(calc(var(--cursor-y, 0) * 6deg)) rotateY(calc(var(--cursor-x, 0) * 8deg)) rotateZ(calc(var(--reverie-time, 0) * 0.1deg));
    transition: transform 0.25s ease-out;
    will-change: transform;
}

.dome-seg {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 400px;
    height: 400px;
    margin: -200px 0 0 -200px;
    transform-style: preserve-3d;
}

.dome-seg svg {
    width: 100%;
    height: 100%;
    overflow: visible;
    filter: drop-shadow(0 0 40px rgba(255, 158, 207, 0.25));
}

.seg-front { transform: translateZ(180px); animation: spinSeg 40s linear infinite; }
.seg-back { transform: rotateY(180deg) translateZ(180px); animation: spinSeg 40s linear infinite reverse; }
.seg-left { transform: rotateY(-90deg) translateZ(180px); animation: spinSeg 52s linear infinite; }
.seg-right { transform: rotateY(90deg) translateZ(180px); animation: spinSeg 52s linear infinite reverse; }

@keyframes spinSeg {
    0% { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(360deg); }
}

.chamber-core {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200px;
    height: 200px;
    margin: -100px 0 0 -100px;
    transform-style: preserve-3d;
}

.chamber-core svg {
    width: 100%;
    height: 100%;
    overflow: visible;
    filter: drop-shadow(0 0 60px rgba(247, 200, 114, 0.7));
}

.fragment-chamber {
    position: absolute;
    bottom: 14%;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    max-width: 40ch;
    z-index: 5;
}

.chamber-coords {
    position: absolute;
    top: 80px;
    right: 40px;
    color: var(--amber);
    opacity: 0.7;
    z-index: 10;
}

/* ============================================================
   Stratum V — Ancestral Voices (parchment)
   ============================================================ */

.stratum-5 {
    min-height: 100vh;
    background:
        radial-gradient(ellipse at 50% 50%, var(--parchment) 0%, #e8dfc4 60%, #d8cfab 100%);
    padding: 120px 0 160px;
    position: relative;
}

.parchment {
    position: relative;
    max-width: 760px;
    margin: 0 auto;
    padding: 40px 0;
}

.gutter {
    position: absolute;
    top: 50%;
    width: 120px;
    height: 95%;
    transform: translateY(-50%);
    overflow: visible;
    pointer-events: none;
}

.gutter-left { left: -120px; }
.gutter-right { right: -120px; }

.parchment-inner {
    position: relative;
    z-index: 2;
    padding: 0 60px;
    color: var(--night-amethyst);
}

.parchment-title {
    font-family: "Cormorant Infant", serif;
    font-weight: 300;
    font-size: clamp(2.2rem, 5vw, 3.6rem);
    letter-spacing: -0.03em;
    text-align: center;
    margin-bottom: 48px;
    color: var(--night-amethyst);
}

.parchment-title em {
    font-style: italic;
}

.parchment-inner p {
    font-family: "EB Garamond", serif;
    font-weight: 400;
    font-size: 1.15rem;
    line-height: 1.8;
    max-width: 38ch;
    margin: 0 auto 24px;
    color: var(--night-amethyst);
}

.parchment-inner p em {
    font-style: italic;
    color: #3a2a5c;
}

.parchment-signature {
    text-align: center;
    margin-top: 48px !important;
}

.parchment-signature .micro {
    color: var(--night-amethyst);
    opacity: 0.6;
}

/* ============================================================
   Stratum VI — Honey-dew
   ============================================================ */

.stratum-6 {
    height: 100vh;
    min-height: 760px;
    background:
        radial-gradient(ellipse at 50% 50%, rgba(247, 200, 114, 0.2) 0%, transparent 55%),
        radial-gradient(ellipse at 50% 50%, rgba(255, 158, 207, 0.12) 0%, transparent 70%),
        var(--abyss);
    display: flex;
    align-items: center;
    justify-content: center;
}

.closing-wrap {
    position: relative;
    width: min(600px, 70vw);
    height: min(600px, 70vw);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulseClose 5s ease-in-out infinite;
}

@keyframes pulseClose {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 60px rgba(247, 200, 114, 0.5)); }
    50% { transform: scale(1.04); filter: drop-shadow(0 0 90px rgba(247, 200, 114, 0.75)); }
}

.closing-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.fragment-closing {
    position: relative;
    z-index: 5;
    text-align: center;
    max-width: 30ch;
    color: var(--parchment);
    text-shadow: 0 0 30px rgba(13, 11, 31, 0.9);
}

.end-foot {
    position: absolute;
    bottom: 28px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 40px;
    color: var(--selenite);
    opacity: 0.6;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 900px) {
    .fragment-tl, .fragment-br {
        left: 6%; right: 6%;
        max-width: 80%;
    }
    .fragment-br { bottom: 10%; }
    .fragment-tl { top: 10%; }
    .chamber-3d { width: 360px; height: 360px; }
    .dome-seg { width: 280px; height: 280px; margin: -140px 0 0 -140px; }
    .seg-front { transform: translateZ(120px); }
    .seg-back { transform: rotateY(180deg) translateZ(120px); }
    .seg-left { transform: rotateY(-90deg) translateZ(120px); }
    .seg-right { transform: rotateY(90deg) translateZ(120px); }
    .island { width: 240px; height: 200px; }
    .hollow-cap em { font-size: 0.9rem; }
    .end-foot { flex-direction: column; align-items: center; gap: 8px; }
    .gutter-left { left: -40px; }
    .gutter-right { right: -40px; }
    .parchment-inner { padding: 0 30px; }
}

@media (max-width: 600px) {
    .xanadu-text { font-size: 130px; }
    .stratum-label { font-size: 0.62rem; }
    .dot-nav { top: 18px; left: 18px; gap: 10px; }
    .sound-toggle { top: 14px; right: 18px; }
}
