/* ============================================
   mystical.boo — Translucent Frost Skeuomorphic
   ============================================ */

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

:root {
    --void: #0b1621;
    --brass: #c9a84c;
    --brass-shadow: #7a6329;
    --frost: #e8f0f6;
    --frost-glow: #b4d7e8;
    --frost-mid: #c8dce8;
    --velvet: #2a1428;
    --parchment: #f0e6d3;
    --spark: #8b5cf6;
}

body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: var(--void);
    font-family: 'Cormorant Garamond', serif;
    color: var(--frost);
}

/* ---- THE VOID ---- */
#void {
    position: fixed;
    inset: 0;
    z-index: 0;
    background: var(--void);
}

#noise-svg {
    position: absolute;
    inset: 0;
    animation: noiseShift 8s linear infinite;
}

@keyframes noiseShift {
    0% { transform: translate(0, 0); }
    50% { transform: translate(-2px, -2px); }
    100% { transform: translate(0, 0); }
}

/* ---- FLOATING ELEMENTS ---- */
#floating-elements {
    position: fixed;
    inset: 0;
    z-index: 10;
    pointer-events: none;
}

.floater {
    position: absolute;
}

/* Brass Gears */
.gear {
    border-radius: 50%;
    border: 3px solid var(--brass);
    box-shadow: 0 0 8px rgba(201, 168, 76, 0.3), inset 0 0 6px rgba(201, 168, 76, 0.15);
}

.gear::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40%;
    height: 40%;
    border-radius: 50%;
    border: 2px solid var(--brass);
    transform: translate(-50%, -50%);
}

.gear::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12%;
    height: 12%;
    border-radius: 50%;
    background: var(--brass);
    transform: translate(-50%, -50%);
}

.gear-1 {
    width: 80px; height: 80px;
    top: 8%; left: 5%;
    opacity: 0.4;
    animation: spin 30s linear infinite, drift1 25s ease-in-out infinite;
}
.gear-2 {
    width: 45px; height: 45px;
    top: 70%; left: 85%;
    opacity: 0.25;
    transform: scale(0.6);
    animation: spin 45s linear infinite reverse, drift2 30s ease-in-out infinite;
}
.gear-3 {
    width: 60px; height: 60px;
    top: 25%; right: 8%;
    opacity: 0.35;
    animation: spin 35s linear infinite, drift3 20s ease-in-out infinite;
}
.gear-4 {
    width: 30px; height: 30px;
    top: 85%; left: 20%;
    opacity: 0.2;
    transform: scale(0.4);
    animation: spin 50s linear infinite reverse, drift4 35s ease-in-out infinite;
}
.gear-5 {
    width: 50px; height: 50px;
    top: 55%; left: 12%;
    opacity: 0.3;
    animation: spin 40s linear infinite, drift5 28s ease-in-out infinite;
}

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

@keyframes drift1 {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(30px, 15px); }
    50% { transform: translate(-10px, 30px); }
    75% { transform: translate(20px, -10px); }
}
@keyframes drift2 {
    0%, 100% { transform: translate(0, 0) scale(0.6); }
    33% { transform: translate(-25px, 20px) scale(0.6); }
    66% { transform: translate(15px, -15px) scale(0.6); }
}
@keyframes drift3 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-20px, 25px); }
}
@keyframes drift4 {
    0%, 100% { transform: translate(0, 0) scale(0.4); }
    40% { transform: translate(20px, -20px) scale(0.4); }
    80% { transform: translate(-15px, 10px) scale(0.4); }
}
@keyframes drift5 {
    0%, 100% { transform: translate(0, 0); }
    30% { transform: translate(15px, 20px); }
    70% { transform: translate(-25px, -10px); }
}

/* Crystal Shards */
.crystal {
    width: 20px;
    height: 50px;
    clip-path: polygon(50% 0, 100% 100%, 0% 80%);
    background: rgba(232, 240, 246, 0.15);
    backdrop-filter: blur(2px);
}

.crystal-1 {
    top: 15%; left: 80%;
    opacity: 0.3;
    animation: tumble 20s ease-in-out infinite, driftC1 22s ease-in-out infinite;
}
.crystal-2 {
    top: 60%; left: 8%;
    width: 15px; height: 40px;
    opacity: 0.2;
    animation: tumble 25s ease-in-out infinite reverse, driftC2 28s ease-in-out infinite;
}
.crystal-3 {
    top: 40%; right: 15%;
    width: 12px; height: 35px;
    opacity: 0.25;
    animation: tumble 18s ease-in-out infinite, driftC3 24s ease-in-out infinite;
}
.crystal-4 {
    top: 80%; left: 45%;
    width: 18px; height: 45px;
    opacity: 0.15;
    animation: tumble 30s ease-in-out infinite reverse, driftC4 32s ease-in-out infinite;
}

@keyframes tumble {
    0%, 100% { transform: rotate(0deg) rotateY(0deg); }
    25% { transform: rotate(20deg) rotateY(90deg); }
    50% { transform: rotate(-10deg) rotateY(180deg); }
    75% { transform: rotate(15deg) rotateY(270deg); }
}

@keyframes driftC1 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-30px, 20px); }
}
@keyframes driftC2 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(25px, -15px); }
}
@keyframes driftC3 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-20px, -20px); }
}
@keyframes driftC4 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(15px, 25px); }
}

/* Spark Motes */
.spark {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--spark);
    box-shadow: 0 0 6px var(--spark), 0 0 12px var(--spark), 0 0 20px rgba(139, 92, 246, 0.4);
}

.spark-1 { top: 30%; left: 25%; animation: sparkFloat 8s ease-in-out infinite; animation-delay: -1s; }
.spark-2 { top: 65%; left: 70%; animation: sparkFloat 7s ease-in-out infinite; animation-delay: -3s; }
.spark-3 { top: 50%; left: 40%; animation: sparkFloat 9s ease-in-out infinite; animation-delay: -5s; }
.spark-4 { top: 20%; left: 60%; animation: sparkFloat 6s ease-in-out infinite; animation-delay: -2s; }
.spark-5 { top: 75%; left: 35%; animation: sparkFloat 10s ease-in-out infinite; animation-delay: -7s; }
.spark-6 { top: 45%; left: 90%; animation: sparkFloat 8s ease-in-out infinite; animation-delay: -4s; }

@keyframes sparkFloat {
    0%, 100% { opacity: 0; transform: translateY(0); }
    20% { opacity: 0.8; }
    50% { opacity: 1; transform: translateY(-40px); }
    80% { opacity: 0.6; }
    100% { opacity: 0; transform: translateY(-80px); }
}

/* ---- CABINET FACE ---- */
#cabinet-face {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

/* Corner Brackets */
.cabinet-bracket {
    position: absolute;
    width: 40px;
    height: 40px;
    pointer-events: none;
}

.bracket-tl {
    top: 20px; left: 20px;
    border-top: 3px solid var(--brass);
    border-left: 3px solid var(--brass);
}
.bracket-tr {
    top: 20px; right: 20px;
    border-top: 3px solid var(--brass);
    border-right: 3px solid var(--brass);
}
.bracket-bl {
    bottom: 60px; left: 20px;
    border-bottom: 3px solid var(--brass);
    border-left: 3px solid var(--brass);
}
.bracket-br {
    bottom: 60px; right: 20px;
    border-bottom: 3px solid var(--brass);
    border-right: 3px solid var(--brass);
}

/* Nameplate */
#nameplate {
    position: absolute;
    top: 6vh;
    z-index: 101;
    padding: 10px 40px;
    background: linear-gradient(180deg, #d4b65a 0%, var(--brass) 40%, var(--brass-shadow) 100%);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.2), inset 0 -1px 0 rgba(0, 0, 0, 0.3);
}

#nameplate-text {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--void);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3), 0 -1px 0 rgba(0, 0, 0, 0.4);
}

/* Viewport Ring */
#viewport-ring {
    width: min(60vw, 60vh);
    height: min(60vw, 60vh);
    border-radius: 50%;
    border: 6px solid var(--brass);
    box-shadow: 0 0 0 2px var(--brass-shadow), 0 0 30px rgba(201, 168, 76, 0.2), inset 0 0 30px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
}

#frost-glass {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(232, 240, 246, 0.08);
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    border: 1px solid rgba(232, 240, 246, 0.12);
    transition: backdrop-filter 1.5s ease, -webkit-backdrop-filter 1.5s ease;
    pointer-events: auto;
    cursor: crosshair;
}

#frost-glass.revealed {
    backdrop-filter: blur(0px) saturate(1);
    -webkit-backdrop-filter: blur(0px) saturate(1);
    background: rgba(232, 240, 246, 0.02);
}

/* Switch Panel */
#switch-panel {
    position: absolute;
    bottom: 3vh;
    display: flex;
    gap: 40px;
    pointer-events: auto;
    z-index: 102;
}

.toggle-switch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.switch-label {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.15em;
    color: var(--brass);
    text-transform: uppercase;
}

.switch-housing {
    width: 28px;
    height: 48px;
    background: linear-gradient(180deg, #3a3a3a, #1a1a1a);
    border-radius: 14px;
    border: 2px solid var(--brass-shadow);
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5), 0 1px 0 rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

.switch-handle {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: linear-gradient(180deg, #e0e0e0 0%, #999 100%);
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    transition: top 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.toggle-switch.active .switch-handle {
    top: 22px;
    background: linear-gradient(180deg, var(--spark), #6d3fd4);
    box-shadow: 0 0 10px var(--spark), 0 2px 4px rgba(0, 0, 0, 0.4);
}

.toggle-switch.active .switch-housing {
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5), 0 0 12px rgba(139, 92, 246, 0.3);
}

.switch-flash {
    position: absolute;
    inset: 0;
    border-radius: 14px;
    background: var(--spark);
    opacity: 0;
    animation: switchFlash 0.4s ease-out;
}

@keyframes switchFlash {
    0% { opacity: 0.6; }
    100% { opacity: 0; }
}

/* ---- MECHANISM ---- */
#mechanism {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1s ease;
}

#mechanism.visible {
    opacity: 1;
    pointer-events: auto;
}

#carousel-container {
    perspective: 1200px;
    width: 300px;
    height: 350px;
}

#carousel {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    animation: carouselSpin 40s linear infinite;
}

#carousel:hover {
    animation-play-state: paused;
}

@keyframes carouselSpin {
    to { transform: rotateY(360deg); }
}

.fortune-card {
    position: absolute;
    width: 200px;
    height: 320px;
    left: 50%;
    top: 50%;
    margin-left: -100px;
    margin-top: -160px;
    background: var(--parchment);
    background-image: repeating-linear-gradient(45deg, transparent, transparent 2px, rgba(0,0,0,0.02) 2px, rgba(0,0,0,0.02) 4px),
                       repeating-linear-gradient(135deg, transparent, transparent 2px, rgba(0,0,0,0.02) 2px, rgba(0,0,0,0.02) 4px);
    border-radius: 8px;
    padding: 30px 20px;
    transform: rotateY(calc(var(--i) * 60deg)) translateZ(280px);
    backface-visibility: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: transform 0.4s ease, opacity 0.3s ease;
}

.fortune-card::before,
.fortune-card::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
}

.fortune-card::before {
    top: 8px;
    left: 8px;
    border-top: 2px solid var(--brass);
    border-left: 2px solid var(--brass);
}

.fortune-card::after {
    bottom: 8px;
    right: 8px;
    border-bottom: 2px solid var(--brass);
    border-right: 2px solid var(--brass);
}

.fortune-card h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--velvet);
}

.fortune-card p {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: clamp(1rem, 2vw, 1.4rem);
    line-height: 1.65;
    letter-spacing: 0.01em;
    color: var(--velvet);
}

.card-brackets {
    display: none;
}

/* ---- INNER SANCTUM ---- */
#inner-sanctum {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1s ease;
}

#inner-sanctum.visible {
    opacity: 1;
    pointer-events: auto;
}

#parchment-scroll {
    width: min(70vw, 600px);
    max-height: 0;
    overflow: hidden;
    background: var(--parchment);
    background-image: radial-gradient(circle, rgba(0,0,0,0.03) 1px, transparent 1px);
    background-size: 4px 4px;
    border-radius: 8px;
    padding: 0 40px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
    transition: max-height 2.5s cubic-bezier(0.25, 0.1, 0.25, 1), padding 0.5s ease;
}

#parchment-scroll.unfurled {
    max-height: 80vh;
    padding: 40px;
    overflow-y: auto;
}

#parchment-scroll::-webkit-scrollbar {
    width: 6px;
}
#parchment-scroll::-webkit-scrollbar-track {
    background: rgba(42, 20, 40, 0.1);
}
#parchment-scroll::-webkit-scrollbar-thumb {
    background: var(--brass);
    border-radius: 3px;
}

.parchment-line {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.3rem);
    line-height: 1.75;
    color: var(--velvet);
    margin-bottom: 1.2em;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.6s ease, transform 0.6s ease;
    transition-delay: calc(var(--line-i) * 0.2s + 0.5s);
}

#parchment-scroll.unfurled .parchment-line {
    opacity: 1;
    transform: translateY(0);
}

.parchment-line em {
    font-weight: 600;
    font-style: italic;
}

.parchment-drop {
    font-size: 2.5em;
    float: left;
    line-height: 0.8;
    margin-right: 4px;
    margin-top: 4px;
    font-weight: 600;
    color: var(--brass-shadow);
}

/* ---- TICKER TAPE ---- */
#ticker-tape {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    height: 32px;
    background: rgba(42, 20, 40, 0.85);
    border-top: 1px solid rgba(201, 168, 76, 0.3);
    overflow: hidden;
    display: flex;
    align-items: center;
}

#ticker-content {
    white-space: nowrap;
    animation: tickerScroll 30s linear infinite;
}

#ticker-content span {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    letter-spacing: 0.06em;
    color: #c8dce8;
}

@keyframes tickerScroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}
