/* =============================================
   mysterious.boo - Styles
   Chrome-metallic palette, playful haunted mystery
   ============================================= */

/* --- CSS Custom Properties --- */
:root {
    --chrome-dark: #2A2A30;
    --chrome-light: #8A8A95;
    --chrome-white: #D0D0D8;
    --ghost-glow: #A8D0F0;
    --candle-warm: #F0C878;
    --shadow-deep: #14141A;
    --noise-gray: #4A4A55;

    --font-main: 'Libre Baskerville', Georgia, serif;
    --content-width: 680px;
    --room-padding: 48px;

    --ghost-x: 50vw;
    --ghost-y: 50vh;
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: var(--font-main);
    font-weight: 400;
    font-size: clamp(15px, 1vw, 17px);
    line-height: 1.85;
    color: var(--chrome-white);
    background-color: var(--shadow-deep);
    overflow-x: hidden;
    cursor: none;
}

/* --- SVG Filters (hidden) --- */
#svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* --- Noise Overlay --- */
#noise-overlay {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    pointer-events: none;
    z-index: 9998;
    opacity: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    mix-blend-mode: overlay;
    animation: noise-fade-in 500ms ease forwards, noise-drift 8s linear infinite;
}

@keyframes noise-fade-in {
    to { opacity: 0.12; }
}

@keyframes noise-drift {
    0% { transform: translate(0, 0); }
    25% { transform: translate(-5%, -5%); }
    50% { transform: translate(5%, -3%); }
    75% { transform: translate(-3%, 5%); }
    100% { transform: translate(0, 0); }
}

/* --- Ghost Cursor Follower --- */
#ghost-cursor {
    position: fixed;
    left: var(--ghost-x);
    top: var(--ghost-y);
    transform: translate(-50%, -50%) scale(0);
    pointer-events: none;
    z-index: 10000;
    transition: left 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                top 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 300ms ease;
    filter: drop-shadow(0 0 8px rgba(168, 208, 240, 0.4));
}

#ghost-cursor.visible {
    transform: translate(-50%, -50%) scale(1);
}

#ghost-cursor.hover-active {
    transform: translate(-50%, -50%) scale(1.2);
}

/* Ghost Trail */
#ghost-trail {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

.ghost-trail-dot {
    position: fixed;
    width: 12px;
    height: 12px;
    pointer-events: none;
    opacity: 0.4;
    transition: opacity 800ms ease;
}

.ghost-trail-dot svg {
    width: 100%;
    height: 100%;
}

.ghost-trail-dot.fading {
    opacity: 0;
}

/* --- Navigation --- */
#nav-toggle {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 10001;
    background: none;
    border: none;
    cursor: none;
    padding: 8px;
    transition: transform 300ms ease;
}

#nav-toggle:hover {
    animation: ghost-wobble 600ms ease infinite;
}

@keyframes ghost-wobble {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-8deg); }
    50% { transform: rotate(5deg); }
    75% { transform: rotate(-3deg); }
}

#nav-menu {
    position: fixed;
    top: 0;
    right: 0;
    width: 260px;
    height: 100vh;
    background: linear-gradient(180deg, var(--shadow-deep) 0%, var(--chrome-dark) 100%);
    border-left: 1px solid var(--noise-gray);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 40px;
    transform: translateX(100%);
    transition: transform 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

#nav-menu.open {
    transform: translateX(0);
}

#nav-menu.hidden {
    transform: translateX(100%);
}

.nav-link {
    font-family: var(--font-main);
    font-weight: 400;
    font-style: italic;
    font-size: 15px;
    color: var(--chrome-light);
    text-decoration: none;
    padding: 12px 0;
    border-bottom: 1px solid rgba(74, 74, 85, 0.3);
    transition: color 300ms ease, padding-left 300ms ease;
    cursor: none;
}

.nav-link:hover {
    color: var(--ghost-glow);
    padding-left: 12px;
}

/* --- Room Base Styles --- */
.room {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.room-atmosphere {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    transition: opacity 600ms ease;
}

.room-content {
    position: relative;
    z-index: 2;
    max-width: var(--content-width);
    width: 100%;
    padding: var(--room-padding);
}

.room-title {
    font-family: var(--font-main);
    font-weight: 700;
    font-size: clamp(28px, 3.5vw, 56px);
    letter-spacing: 0.01em;
    color: var(--chrome-white);
    margin-bottom: 24px;
}

.room-text {
    color: var(--chrome-light);
    margin-bottom: 32px;
}

/* --- Ghost Whispers --- */
.ghost-whisper {
    font-family: var(--font-main);
    font-weight: 400;
    font-style: italic;
    font-size: clamp(13px, 1vw, 15px);
    letter-spacing: 0.03em;
    color: var(--chrome-white);
    opacity: 0.6;
    margin-top: 32px;
}

/* --- Foyer Room --- */
.foyer-room {
    background: var(--shadow-deep);
}

.foyer-atmosphere {
    background: radial-gradient(ellipse at center, var(--chrome-dark) 0%, var(--shadow-deep) 70%);
    opacity: 0;
    animation: foyer-bloom 800ms 300ms ease forwards;
}

@keyframes foyer-bloom {
    to { opacity: 1; }
}

.foyer-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.site-title {
    font-family: var(--font-main);
    font-weight: 700;
    font-size: clamp(36px, 5vw, 72px);
    letter-spacing: 0.01em;
    color: var(--chrome-white);
    margin-bottom: 16px;
}

.title-mysterious {
    opacity: 0;
    animation: text-fade-in 600ms 600ms ease forwards;
}

.title-dot {
    opacity: 0;
    animation: text-fade-in 400ms 800ms ease forwards;
    color: var(--chrome-light);
}

.title-boo {
    opacity: 0;
    display: inline-block;
    animation: text-fade-in 500ms 1000ms ease forwards, boo-breathe 2s 1500ms ease-in-out infinite;
    color: var(--ghost-glow);
}

@keyframes text-fade-in {
    to { opacity: 1; }
}

@keyframes boo-breathe {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(1.1); }
}

.title-boo:hover {
    animation: text-fade-in 500ms 1000ms ease forwards, boo-breathe-hover 1.5s ease-in-out infinite;
}

@keyframes boo-breathe-hover {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(1.2); }
}

.foyer-whisper {
    opacity: 0;
    animation: text-fade-in 800ms 1600ms ease forwards;
}

/* Candle glow in foyer */
.candle-glow {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(240, 200, 120, 0.15) 0%, transparent 70%);
    position: absolute;
    bottom: 15%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    animation: candle-pulse-once 1500ms 2000ms ease forwards;
}

@keyframes candle-pulse-once {
    0% { opacity: 0; transform: translateX(-50%) scale(0.8); }
    50% { opacity: 1; transform: translateX(-50%) scale(1.1); }
    100% { opacity: 0.3; transform: translateX(-50%) scale(1); }
}

/* Scroll hint */
.scroll-hint {
    margin-top: 48px;
    opacity: 0;
    animation: text-fade-in 600ms 2500ms ease forwards, scroll-bounce 2s 3000ms ease-in-out infinite;
}

@keyframes scroll-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(8px); }
}

/* --- Fog Room --- */
.fog-room-section {
    background: linear-gradient(180deg, var(--shadow-deep) 0%, var(--chrome-dark) 30%, var(--chrome-dark) 70%, var(--shadow-deep) 100%);
}

.fog-atmosphere {
    background: radial-gradient(ellipse at 50% 50%, rgba(138, 138, 149, 0.1) 0%, transparent 60%);
}

.fog-effect {
    position: absolute;
    left: 0;
    width: 100%;
    height: 200px;
    pointer-events: none;
    z-index: 3;
}

.fog-bottom {
    bottom: 0;
    background: linear-gradient(to top, var(--shadow-deep) 0%, transparent 100%);
    filter: blur(20px);
    opacity: 0.7;
}

.fog-top {
    top: 0;
    background: linear-gradient(to bottom, var(--shadow-deep) 0%, transparent 100%);
    filter: blur(20px);
    opacity: 0.7;
}

.fog-room-section .room-content {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 800ms ease, transform 800ms ease;
}

.fog-room-section.in-view .room-content {
    opacity: 1;
    transform: translateY(0);
}

/* --- Candle Room --- */
.candle-room-section {
    background: linear-gradient(180deg, var(--shadow-deep) 0%, #1E1E24 40%, #1E1E24 60%, var(--shadow-deep) 100%);
}

.candle-atmosphere {
    background: radial-gradient(ellipse at 50% 50%, rgba(240, 200, 120, 0.05) 0%, transparent 50%);
}

.candle-light-effect {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 500px;
    height: 500px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(240, 200, 120, 0.08) 0%, transparent 60%);
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity 600ms ease;
}

.candle-room-section.in-view .candle-light-effect {
    animation: candle-flicker 3s ease-in-out infinite;
}

@keyframes candle-flicker {
    0% { opacity: 0.6; }
    10% { opacity: 0.5; }
    20% { opacity: 0.7; }
    30% { opacity: 0.4; }
    40% { opacity: 0.8; }
    50% { opacity: 0.55; }
    60% { opacity: 0.75; }
    70% { opacity: 0.45; }
    80% { opacity: 0.65; }
    90% { opacity: 0.5; }
    100% { opacity: 0.6; }
}

/* Candle cluster */
.candle-cluster {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin: 32px 0;
}

.candle {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.candle-body {
    width: 12px;
    height: 40px;
    background: linear-gradient(180deg, var(--candle-warm) 0%, #C8A050 100%);
    border-radius: 2px 2px 4px 4px;
}

.candle-1 .candle-body { height: 50px; }
.candle-2 .candle-body { height: 35px; }
.candle-3 .candle-body { height: 45px; }

.candle-flame {
    width: 10px;
    height: 18px;
    background: radial-gradient(ellipse at 50% 80%, var(--candle-warm) 0%, #E8A830 40%, transparent 70%);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    margin-bottom: 2px;
    opacity: 0;
    transition: opacity 600ms ease;
}

.candle-room-section.in-view .candle-flame {
    opacity: 1;
}

.candle-1 .candle-flame {
    animation: flame-dance-1 1.5s ease-in-out infinite;
}

.candle-2 .candle-flame {
    animation: flame-dance-2 1.8s ease-in-out infinite;
}

.candle-3 .candle-flame {
    animation: flame-dance-3 1.3s ease-in-out infinite;
}

@keyframes flame-dance-1 {
    0%, 100% { transform: scaleX(1) scaleY(1) rotate(0deg); }
    25% { transform: scaleX(0.8) scaleY(1.1) rotate(-3deg); }
    50% { transform: scaleX(1.1) scaleY(0.9) rotate(2deg); }
    75% { transform: scaleX(0.9) scaleY(1.05) rotate(-1deg); }
}

@keyframes flame-dance-2 {
    0%, 100% { transform: scaleX(1) scaleY(1) rotate(0deg); }
    30% { transform: scaleX(1.1) scaleY(0.85) rotate(4deg); }
    60% { transform: scaleX(0.85) scaleY(1.15) rotate(-2deg); }
    80% { transform: scaleX(1.05) scaleY(0.95) rotate(1deg); }
}

@keyframes flame-dance-3 {
    0%, 100% { transform: scaleX(1) scaleY(1) rotate(0deg); }
    20% { transform: scaleX(0.9) scaleY(1.1) rotate(-2deg); }
    40% { transform: scaleX(1.15) scaleY(0.9) rotate(3deg); }
    70% { transform: scaleX(0.85) scaleY(1.05) rotate(-4deg); }
}

.candle-room-section .room-content {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 800ms ease, transform 800ms ease;
}

.candle-room-section.in-view .room-content {
    opacity: 1;
    transform: translateY(0);
}

/* --- Shadow Room --- */
.shadow-room-section {
    background: linear-gradient(180deg, var(--shadow-deep) 0%, #0F0F14 40%, #0F0F14 60%, var(--shadow-deep) 100%);
}

.shadow-atmosphere {
    background: radial-gradient(ellipse at 50% 50%, rgba(42, 42, 48, 0.3) 0%, transparent 60%);
}

/* Shadow puppets */
.shadow-stage {
    position: relative;
    height: 200px;
    margin: 32px 0;
    overflow: hidden;
}

.shadow-puppet {
    position: absolute;
    bottom: 0;
    opacity: 0.15;
    transition: opacity 600ms ease;
}

.shadow-room-section.in-view .shadow-puppet {
    opacity: 0.25;
}

.puppet-1 {
    left: 10%;
    width: 80px;
    height: 120px;
    background: var(--shadow-deep);
    clip-path: polygon(50% 0%, 65% 25%, 85% 20%, 75% 45%, 95% 60%, 70% 60%, 60% 85%, 50% 65%, 40% 85%, 30% 60%, 5% 60%, 25% 45%, 15% 20%, 35% 25%);
    animation: puppet-sway-1 4s ease-in-out infinite;
}

.puppet-2 {
    left: 45%;
    width: 100px;
    height: 140px;
    background: var(--shadow-deep);
    clip-path: polygon(20% 0%, 30% 20%, 50% 15%, 70% 20%, 80% 0%, 85% 35%, 100% 50%, 80% 55%, 85% 75%, 65% 70%, 50% 100%, 35% 70%, 15% 75%, 20% 55%, 0% 50%, 15% 35%);
    animation: puppet-sway-2 5s ease-in-out infinite;
}

.puppet-3 {
    right: 10%;
    width: 70px;
    height: 110px;
    background: var(--shadow-deep);
    clip-path: polygon(50% 0%, 80% 20%, 100% 50%, 80% 80%, 50% 100%, 20% 80%, 0% 50%, 20% 20%);
    animation: puppet-sway-3 3.5s ease-in-out infinite;
}

@keyframes puppet-sway-1 {
    0%, 100% { transform: rotate(-5deg) translateX(0); }
    50% { transform: rotate(5deg) translateX(10px); }
}

@keyframes puppet-sway-2 {
    0%, 100% { transform: rotate(3deg) translateY(0); }
    50% { transform: rotate(-3deg) translateY(-10px); }
}

@keyframes puppet-sway-3 {
    0%, 100% { transform: rotate(4deg) translateX(0); }
    50% { transform: rotate(-6deg) translateX(-8px); }
}

.shadow-room-section .room-content {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 800ms ease, transform 800ms ease;
}

.shadow-room-section.in-view .room-content {
    opacity: 1;
    transform: translateY(0);
}

/* --- Clue Room / Archives --- */
.clue-room-section {
    background: linear-gradient(180deg, var(--shadow-deep) 0%, var(--chrome-dark) 30%, var(--chrome-dark) 70%, var(--shadow-deep) 100%);
}

.archive-atmosphere {
    background: radial-gradient(ellipse at 50% 50%, rgba(208, 208, 216, 0.04) 0%, transparent 60%);
}

.archive-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    margin: 32px 0;
}

.archive-entry {
    background: linear-gradient(135deg, rgba(42, 42, 48, 0.6) 0%, rgba(20, 20, 26, 0.8) 100%);
    border: 1px solid rgba(74, 74, 85, 0.3);
    border-radius: 4px;
    padding: 28px;
    transition: box-shadow 400ms ease, border-color 400ms ease, transform 400ms ease;
    cursor: none;
}

.archive-entry:hover {
    box-shadow: 0 0 12px rgba(168, 208, 240, 0.3);
    border-color: rgba(168, 208, 240, 0.3);
    transform: translateY(-2px);
}

.archive-icon {
    margin-bottom: 16px;
}

.archive-title {
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 0.01em;
    color: var(--chrome-white);
    margin-bottom: 10px;
}

.archive-desc {
    font-size: clamp(14px, 0.9vw, 16px);
    color: var(--chrome-light);
    line-height: 1.7;
}

.clue-room-section .room-content {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 800ms ease, transform 800ms ease;
}

.clue-room-section.in-view .room-content {
    opacity: 1;
    transform: translateY(0);
}

.final-whisper {
    text-align: center;
    margin-top: 48px;
    font-size: clamp(15px, 1.2vw, 18px);
}

/* --- Clue Panels --- */
.clue-panel {
    background: linear-gradient(135deg, rgba(42, 42, 48, 0.5) 0%, rgba(20, 20, 26, 0.7) 100%);
    border: 1px solid rgba(74, 74, 85, 0.4);
    border-left: 3px solid var(--candle-warm);
    padding: 24px 28px;
    margin: 24px 0;
    position: relative;
    transition: box-shadow 400ms ease;
    cursor: none;
}

.clue-panel:hover {
    box-shadow: 0 0 12px rgba(168, 208, 240, 0.3);
}

.clue-slide {
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 400ms ease, transform 400ms ease;
}

.clue-slide.visible {
    opacity: 1;
    transform: translateX(0);
}

.clue-ornament {
    position: absolute;
    top: -10px;
    right: 20px;
    background: var(--chrome-dark);
    padding: 2px 8px;
}

.clue-label {
    font-family: var(--font-main);
    font-weight: 400;
    font-style: italic;
    font-size: 12px;
    font-variant: small-caps;
    color: var(--candle-warm);
    letter-spacing: 0.05em;
    display: block;
    margin-bottom: 8px;
}

.clue-text {
    font-family: var(--font-main);
    font-weight: 400;
    font-style: italic;
    font-size: clamp(14px, 1vw, 16px);
    line-height: 1.8;
    color: var(--chrome-white);
    margin-bottom: 8px;
}

.clue-source {
    font-family: var(--font-main);
    font-weight: 400;
    font-style: italic;
    font-size: 12px;
    color: var(--chrome-light);
    opacity: 0.6;
}

/* --- Chrome Metallic Surfaces --- */
.chrome-surface {
    background: linear-gradient(135deg, var(--chrome-dark) 0%, var(--chrome-light) 40%, var(--chrome-dark) 60%, var(--chrome-light) 100%);
    transition: background 400ms ease;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    :root {
        --room-padding: 24px;
    }

    .site-title {
        font-size: clamp(28px, 8vw, 48px);
    }

    .candle-cluster {
        gap: 20px;
    }

    .shadow-stage {
        height: 140px;
    }

    .puppet-1 { width: 60px; height: 90px; }
    .puppet-2 { width: 75px; height: 105px; }
    .puppet-3 { width: 50px; height: 80px; }

    #nav-menu {
        width: 100%;
    }

    body {
        cursor: auto;
    }

    #ghost-cursor,
    #ghost-trail {
        display: none;
    }
}

@media (max-width: 480px) {
    .archive-grid {
        gap: 16px;
    }

    .archive-entry {
        padding: 20px;
    }

    .clue-panel {
        padding: 18px 20px;
    }
}
