/* =========================================
   LLITTL.com - Surreal Miniature Dreamscape
   ========================================= */

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

:root {
    --deep-bg: #1a1125;
    --surface: #2d1b3d;
    --amber: #e8a838;
    --moth-blue: #7b9eb8;
    --moonlight: #f0e6d3;
    --cream: #ede4d4;
    --lavender: #9a8ba8;
    --rose: #c45c6a;
}

html {
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--lavender) var(--deep-bg);
}

body {
    background: var(--deep-bg);
    color: var(--cream);
    font-family: 'Karla', sans-serif;
    font-size: 1.05rem;
    line-height: 1.75;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Film Grain Overlay --- */
.grain-overlay {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.045;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    animation: grain 0.8s steps(6) infinite;
}

@keyframes grain {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-5%, -10%); }
    20% { transform: translate(-15%, 5%); }
    30% { transform: translate(7%, -25%); }
    40% { transform: translate(-5%, 25%); }
    50% { transform: translate(-15%, 10%); }
    60% { transform: translate(15%, 0%); }
    70% { transform: translate(0%, 15%); }
    80% { transform: translate(3%, 35%); }
    90% { transform: translate(-10%, 10%); }
}

/* --- Floating Keys --- */
.floating-keys {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    overflow: hidden;
}

.floating-key {
    position: absolute;
    opacity: 0.15;
}

.key-1 {
    top: 10%;
    left: 8%;
    animation: floatKey1 28s ease-in-out infinite;
}

.key-2 {
    top: 45%;
    right: 12%;
    animation: floatKey2 35s ease-in-out infinite;
}

.key-3 {
    top: 70%;
    left: 25%;
    animation: floatKey3 22s ease-in-out infinite;
}

@keyframes floatKey1 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(40px, -60px) rotate(15deg); }
    50% { transform: translate(-20px, -100px) rotate(-10deg); }
    75% { transform: translate(60px, -40px) rotate(20deg); }
}

@keyframes floatKey2 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(-50px, -80px) rotate(-20deg); }
    50% { transform: translate(30px, -120px) rotate(10deg); }
    75% { transform: translate(-40px, -50px) rotate(-15deg); }
}

@keyframes floatKey3 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(30px, -50px) rotate(10deg); }
    50% { transform: translate(-40px, -80px) rotate(-20deg); }
    75% { transform: translate(20px, -30px) rotate(5deg); }
}

/* --- Navigation Dots --- */
.nav-dots {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.nav-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--lavender);
    border: none;
    cursor: pointer;
    padding: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    opacity: 0.5;
    animation: dotPulse 3s ease-in-out infinite;
}

.nav-dot:hover {
    width: 10px;
    height: 10px;
    opacity: 0.9;
    background: var(--moth-blue);
}

.nav-dot.active {
    width: 8px;
    height: 8px;
    opacity: 1;
    background: var(--amber);
    animation: dotPulseActive 2s ease-in-out infinite;
}

@keyframes dotPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.6; }
}

@keyframes dotPulseActive {
    0%, 100% { opacity: 0.85; box-shadow: 0 0 4px var(--amber); }
    50% { opacity: 1; box-shadow: 0 0 10px var(--amber); }
}

/* --- Rooms (Sections) --- */
.room {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.room-0 {
    background: var(--deep-bg);
}

.room-1 {
    background: var(--surface);
}

.room-2 {
    background: linear-gradient(180deg, var(--surface) 0%, var(--deep-bg) 100%);
}

.room-3 {
    background: var(--deep-bg);
}

.room-4 {
    background: linear-gradient(180deg, var(--deep-bg) 0%, #0d0a12 100%);
}

/* --- Vignette --- */
.vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(26, 17, 37, 0.6) 100%);
}

.vignette-deep {
    background: radial-gradient(ellipse at center, transparent 20%, rgba(26, 17, 37, 0.85) 100%);
}

/* --- Room Content --- */
.room-content {
    position: relative;
    z-index: 3;
    max-width: 560px;
    width: 90%;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* --- Typography --- */
.title-text {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(3rem, 10vw, 7rem);
    font-weight: 300;
    letter-spacing: 0.15em;
    color: var(--cream);
    position: relative;
    transition: opacity 1.2s ease, transform 1.2s ease;
}

.heading-serif {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(2rem, 5vw, 4.5rem);
    font-weight: 300;
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--moonlight);
    margin-bottom: 1.5rem;
}

.body-text {
    font-family: 'Karla', sans-serif;
    font-size: 1.05rem;
    line-height: 1.75;
    color: var(--cream);
    opacity: 0.9;
    margin-bottom: 1.5rem;
}

.pull-quote {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(1.4rem, 3vw, 2rem);
    font-weight: 300;
    font-style: italic;
    color: var(--amber);
    border: none;
    padding: 1.5rem 0;
    margin: 1rem 0;
    letter-spacing: -0.01em;
    line-height: 1.4;
}

.marginalia {
    font-family: 'Homemade Apple', cursive;
    font-size: 0.7rem;
    color: var(--lavender);
    opacity: 0.6;
    display: block;
    margin-bottom: 1.5rem;
    letter-spacing: 0.03em;
}

.marginalia-left {
    text-align: left;
    transform: rotate(-2deg);
    align-self: flex-start;
    margin-left: -10px;
}

.marginalia-right {
    text-align: right;
    transform: rotate(1.5deg);
    align-self: flex-end;
    margin-right: -10px;
    margin-top: 1rem;
}

.marginalia-center {
    text-align: center;
    transform: rotate(-1deg);
    margin-top: 2rem;
}

/* --- Reveal Animation --- */
.reveal-block {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.9s ease, transform 0.9s ease;
}

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

/* --- Moth (Title) --- */
.moth-title {
    position: absolute;
    top: -8px;
    left: calc(50% - 2.8em);
    transform-origin: center center;
    transition: transform 1.5s ease, opacity 1.5s ease;
}

.moth-title.fly-away {
    transform: translate(-30px, -200px) rotate(-20deg) scale(0.5);
    opacity: 0;
}

/* --- Moth Wing Flutter --- */
.moth-wing-left, .moth-wing-right,
.moth-wing-lower-left, .moth-wing-lower-right {
    transform-origin: center;
}

.moth-rest:hover .moth-wing-left {
    animation: flutterLeft 0.3s ease-in-out infinite alternate;
}

.moth-rest:hover .moth-wing-right {
    animation: flutterRight 0.3s ease-in-out infinite alternate;
}

@keyframes flutterLeft {
    0% { transform: scaleX(1); }
    100% { transform: scaleX(0.85); }
}

@keyframes flutterRight {
    0% { transform: scaleX(1); }
    100% { transform: scaleX(0.85); }
}

/* Moth section positioning with random-like offsets */
.moth-section-1 {
    margin-top: 2rem;
    transform: translate(3px, -2px);
}

.moth-section-2 {
    margin-top: 1.5rem;
    transform: translate(-5px, 1px);
}

.moth-section-3 {
    margin-top: 2.5rem;
    transform: translate(7px, -3px);
}

/* --- Mini Doors --- */
.mini-door {
    margin-top: 3rem;
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    opacity: 0.5;
}

.mini-door:hover {
    transform: scale(1.2);
    opacity: 0.9;
}

/* --- Keyhole Reveal --- */
.keyhole-reveal {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.keyhole-inner {
    clip-path: ellipse(40% 45% at 50% 50%);
    transition: clip-path 1s ease;
    padding: 2rem 0;
}

.keyhole-inner.expanded {
    clip-path: ellipse(100% 100% at 50% 50%);
}

/* --- Ending Section --- */
.ending-text {
    opacity: 0.7;
    font-size: 0.95rem;
    max-width: 400px;
    margin: 0 auto 2rem;
}

.ending-title {
    font-size: clamp(1.5rem, 4vw, 3rem);
    opacity: 0.4;
    letter-spacing: 0.2em;
    margin-bottom: 0;
}

/* --- Link / Interactive Glow --- */
a {
    color: var(--amber);
    text-decoration: none;
    transition: text-shadow 0.3s ease, color 0.3s ease;
}

a:hover {
    text-shadow: 0 0 12px rgba(232, 168, 56, 0.4);
    color: var(--moonlight);
}

/* --- Breathing Background (applied via JS) --- */
.room.breathing {
    animation: breathe 6s ease-in-out infinite;
}

@keyframes breathe {
    0%, 100% { background-size: 100% 100%; }
    50% { background-size: 102% 102%; }
}

/* --- Scroll Depth Pulse (applied via JS) --- */
@keyframes depthPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.room.pulse-depth .vignette {
    animation: depthPulse 1.5s ease-in-out;
}

/* --- Responsive --- */
@media (max-width: 600px) {
    .room-content {
        width: 92%;
        max-width: 100%;
    }

    .title-text {
        font-size: clamp(2.5rem, 12vw, 5rem);
    }

    .heading-serif {
        font-size: clamp(1.6rem, 6vw, 3rem);
    }

    .nav-dots {
        bottom: 1.5rem;
        right: 1rem;
    }

    .moth-title {
        left: calc(50% - 2.2em);
    }

    .floating-key {
        opacity: 0.08;
    }

    .marginalia {
        font-size: 0.6rem;
    }
}

/* --- Selection --- */
::selection {
    background: var(--amber);
    color: var(--deep-bg);
}
