/* ==========================================
   lunatic.dev — Styles
   Wabi-sabi + Opulent-Grand aesthetic
   Diagonal-sections layout, kintsugi motifs
   ========================================== */

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

:root {
    --aged-parchment: #F2E8D5;
    --burnt-umber-dark: #2C1810;
    --kintsugi-gold: #C9A84C;
    --terracotta-blush: #B85C38;
    --moon-pale: #D4D7E0;
    --ink-black-warm: #1A1209;
    --cream-light: #F5EFE0;
    --amber-candle: #E8A630;

    --font-headline: 'Cormorant Garamond', Georgia, serif;
    --font-body: 'IBM Plex Mono', 'Courier New', monospace;
    --font-accent: 'Caveat', cursive;

    --ease-organic: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --baseline: 8px;
}

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

body {
    background-color: var(--aged-parchment);
    color: var(--ink-black-warm);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.9rem, 1vw, 1.05rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    position: relative;
}

/* --- Paper Grain Texture --- */
.grain-texture {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.04;
}

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

/* --- Kintsugi Global Overlay --- */
.kintsugi-global {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

/* --- Crescent Moon Navigation --- */
.moon-nav {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1000;
    background: none;
    border: none;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: filter 0.6s var(--ease-organic);
}

.moon-nav:hover {
    filter: drop-shadow(0 0 8px rgba(232, 166, 48, 0.6));
}

.moon-nav.pulse {
    animation: moonPulse 2s var(--ease-organic) 1;
}

@keyframes moonPulse {
    0%, 100% { filter: drop-shadow(0 0 0px rgba(232, 166, 48, 0)); }
    50% { filter: drop-shadow(0 0 16px rgba(232, 166, 48, 0.7)); }
}

/* --- Navigation Overlay --- */
.nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s var(--ease-organic);
}

.nav-overlay.active {
    pointer-events: all;
    opacity: 1;
}

.nav-overlay-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(212, 215, 224, 0.92);
    backdrop-filter: blur(8px);
}

.radial-nav {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
}

.nav-item {
    font-family: var(--font-headline);
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    font-weight: 600;
    color: var(--burnt-umber-dark);
    text-decoration: none;
    letter-spacing: -0.02em;
    transition: color 0.3s var(--ease-organic), transform 0.3s var(--ease-organic);
}

.nav-item:hover {
    color: var(--terracotta-blush);
    transform: scale(1.05);
}

.nav-close {
    position: absolute;
    top: 24px;
    right: 24px;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 2;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.4s var(--ease-organic);
}

.nav-close:hover {
    transform: rotate(180deg);
}

/* --- Section Base Styles --- */
.section {
    position: relative;
    overflow: hidden;
    padding: 80px 0;
}

.section-content {
    position: relative;
    z-index: 5;
    max-width: 720px;
    padding: 0 40px;
}

.content-left {
    margin-left: 80px;
    margin-right: auto;
}

.content-right {
    margin-left: auto;
    margin-right: 80px;
}

/* --- Diagonal Seams (Kintsugi Lines) --- */
.diagonal-seam {
    position: absolute;
    left: -5%;
    width: 110%;
    height: 1px;
    background: var(--kintsugi-gold);
    opacity: 0.6;
    z-index: 8;
    transition: opacity 0.5s var(--ease-organic), box-shadow 0.5s var(--ease-organic);
}

.seam-top {
    top: 0;
    transform: rotate(-3deg);
    transform-origin: left center;
}

.seam-bottom {
    bottom: 0;
    transform: rotate(3deg);
    transform-origin: right center;
}

.seam-light {
    background: var(--kintsugi-gold);
    opacity: 0.4;
}

.diagonal-seam.glow {
    opacity: 0.9;
    box-shadow: 0 0 12px rgba(201, 168, 76, 0.3);
}

/* --- Diagonal Section Clipping --- */
.section-opening {
    min-height: 100vh;
    display: flex;
    align-items: center;
    background: var(--aged-parchment);
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 5vw), 0 100%);
    padding-bottom: 120px;
}

.section-tilt-1 {
    min-height: 50vh;
    background: var(--cream-light);
    clip-path: polygon(0 5vw, 100% 0, 100% calc(100% - 3vw), 0 100%);
    margin-top: -5vw;
    padding: 100px 0;
}

.section-tilt-2 {
    min-height: 50vh;
    background: var(--aged-parchment);
    clip-path: polygon(0 0, 100% 3vw, 100% 100%, 0 calc(100% - 4vw));
    margin-top: -3vw;
    padding: 100px 0;
}

.section-tilt-3 {
    min-height: 50vh;
    background: var(--cream-light);
    clip-path: polygon(0 4vw, 100% 0, 100% calc(100% - 3vw), 0 100%);
    margin-top: -4vw;
    padding: 100px 0;
}

.section-chamber {
    min-height: 150vh;
    background: var(--burnt-umber-dark);
    clip-path: polygon(0 3vw, 100% 0, 100% calc(100% - 4vw), 0 100%);
    margin-top: -3vw;
    padding: 120px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 80px;
}

.section-return {
    min-height: 100vh;
    background: var(--aged-parchment);
    clip-path: polygon(0 4vw, 100% 0, 100% 100%, 0 100%);
    margin-top: -4vw;
    padding: 120px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 64px;
}

/* --- Hero Section --- */
.opening-content {
    margin-left: 80px;
    z-index: 5;
}

.hero-title {
    font-family: var(--font-headline);
    font-size: clamp(2.4rem, 6vw, 5.2rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ink-black-warm);
    transform: rotate(-8deg);
    transform-origin: left bottom;
    line-height: 1;
    margin-bottom: 32px;
}

.hero-subtitle {
    font-family: var(--font-body);
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    line-height: 1.75;
    color: var(--ink-black-warm);
    max-width: 520px;
    opacity: 0.85;
}

.hero-subtitle em {
    font-family: var(--font-accent);
    font-size: 1.15em;
    color: var(--terracotta-blush);
}

/* --- Moon Photograph (Hero) --- */
.moon-photograph {
    position: absolute;
    right: -10%;
    top: 50%;
    transform: translateY(-50%) rotate(8deg);
    width: 60vw;
    height: 60vw;
    max-width: 700px;
    max-height: 700px;
    border-radius: 50%;
    overflow: hidden;
    z-index: 2;
}

.moon-surface {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(
        ellipse at 40% 45%,
        var(--kintsugi-gold) 0%,
        #9A7B3A 25%,
        var(--burnt-umber-dark) 60%,
        #0F0B06 100%
    );
    position: relative;
    box-shadow:
        inset -30px -20px 60px rgba(26, 18, 9, 0.6),
        0 0 80px rgba(201, 168, 76, 0.15),
        0 0 160px rgba(201, 168, 76, 0.08);
}

.crater {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(
        ellipse at 35% 35%,
        rgba(201, 168, 76, 0.25) 0%,
        rgba(44, 24, 16, 0.4) 60%,
        rgba(44, 24, 16, 0.6) 100%
    );
    box-shadow: inset 2px 2px 8px rgba(26, 18, 9, 0.4);
}

.crater-1 { width: 22%; height: 22%; top: 15%; left: 25%; }
.crater-2 { width: 14%; height: 14%; top: 45%; left: 55%; }
.crater-3 { width: 18%; height: 18%; top: 60%; left: 20%; }
.crater-4 { width: 10%; height: 10%; top: 25%; left: 65%; }
.crater-5 { width: 8%; height: 8%; top: 70%; left: 50%; }

.moon-glow {
    position: absolute;
    top: -20%;
    left: -20%;
    width: 140%;
    height: 140%;
    border-radius: 50%;
    background: radial-gradient(
        circle at 40% 45%,
        rgba(201, 168, 76, 0.12) 0%,
        rgba(201, 168, 76, 0.04) 40%,
        transparent 70%
    );
    pointer-events: none;
}

/* --- Floating Elements --- */
.floating-element {
    position: absolute;
    pointer-events: none;
    z-index: 3;
    will-change: transform;
}

.crescent {
    opacity: 0.4;
}

.gold-flake {
    width: 6px;
    height: 6px;
    background: var(--kintsugi-gold);
    opacity: 0.35;
    clip-path: polygon(20% 0%, 80% 0%, 100% 40%, 70% 100%, 30% 100%, 0% 40%);
}

.orbit-circle {
    width: 80px;
    height: 80px;
    border: 1px solid var(--moon-pale);
    border-radius: 50%;
    opacity: 0.15;
}

.orbit-large {
    width: 120px;
    height: 120px;
}

.astro-note {
    font-family: var(--font-accent);
    font-size: 1.2rem;
    color: var(--moon-pale);
    opacity: 0.25;
}

/* Float animation keyframes — each has unique timing */
.float-1 { top: 15%; left: 10%; animation: floatA 7.2s ease-in-out infinite; }
.float-2 { top: 30%; left: 75%; animation: floatB 8.6s ease-in-out infinite; }
.float-3 { top: 70%; left: 20%; animation: floatC 6.4s ease-in-out infinite; }
.float-4 { top: 55%; left: 5%; animation: floatD 9.1s ease-in-out infinite; }
.float-5 { top: 20%; right: 15%; animation: floatA 7.8s ease-in-out infinite; }
.float-6 { top: 60%; left: 30%; animation: floatB 6.9s ease-in-out infinite; }
.float-7 { top: 40%; right: 25%; animation: floatC 8.3s ease-in-out infinite; }
.float-8 { top: 80%; left: 55%; animation: floatD 7.1s ease-in-out infinite; }
.float-9 { top: 25%; left: 8%; animation: floatA 9.4s ease-in-out infinite; }
.float-10 { top: 50%; right: 12%; animation: floatB 6.7s ease-in-out infinite; }
.float-11 { top: 75%; left: 60%; animation: floatC 8.8s ease-in-out infinite; }
.float-12 { top: 15%; left: 45%; animation: floatD 7.5s ease-in-out infinite; }
.float-13 { top: 65%; right: 30%; animation: floatA 9.2s ease-in-out infinite; }
.float-14 { top: 40%; left: 15%; animation: floatB 6.3s ease-in-out infinite; }
.float-15 { top: 80%; right: 10%; animation: floatC 8.1s ease-in-out infinite; }
.float-16 { top: 10%; left: 20%; animation: floatD 7.7s ease-in-out infinite; }
.float-17 { top: 35%; right: 20%; animation: floatA 9.6s ease-in-out infinite; }
.float-18 { top: 55%; left: 10%; animation: floatB 8.2s ease-in-out infinite; }
.float-19 { top: 75%; right: 15%; animation: floatC 6.8s ease-in-out infinite; }
.float-20 { top: 20%; left: 70%; animation: floatD 7.3s ease-in-out infinite; }
.float-21 { top: 45%; left: 40%; animation: floatA 8.9s ease-in-out infinite; }
.float-22 { top: 85%; right: 35%; animation: floatB 6.5s ease-in-out infinite; }
.float-23 { top: 30%; left: 55%; animation: floatC 9.3s ease-in-out infinite; }
.float-24 { top: 65%; left: 75%; animation: floatD 7.9s ease-in-out infinite; }
.float-25 { top: 15%; right: 20%; animation: floatA 8.4s ease-in-out infinite; }
.float-26 { top: 50%; left: 35%; animation: floatB 7.6s ease-in-out infinite; }
.float-27 { top: 70%; right: 40%; animation: floatC 9.0s ease-in-out infinite; }
.float-28 { top: 30%; left: 65%; animation: floatD 6.6s ease-in-out infinite; }

@keyframes floatA {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    33% { transform: translateY(-10px) rotate(2deg); }
    66% { transform: translateY(8px) rotate(-1deg); }
}

@keyframes floatB {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(12px) rotate(-2deg); }
    75% { transform: translateY(-8px) rotate(1.5deg); }
}

@keyframes floatC {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    40% { transform: translateY(-15px) rotate(3deg); }
    80% { transform: translateY(6px) rotate(-1deg); }
}

@keyframes floatD {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    30% { transform: translateY(10px) rotate(-2.5deg); }
    70% { transform: translateY(-12px) rotate(2deg); }
}

/* --- Kintsugi Section Cracks --- */
.kintsugi-section {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 4;
}

.crack-draw {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 2s var(--ease-organic);
}

.crack-draw.drawn {
    stroke-dashoffset: 0;
}

/* --- Body Text --- */
.body-text {
    font-family: var(--font-body);
    font-size: clamp(0.9rem, 1vw, 1.05rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    color: var(--ink-black-warm);
    margin-bottom: 24px;
}

.body-text em {
    font-family: var(--font-accent);
    font-size: 1.1em;
    color: var(--terracotta-blush);
    font-style: normal;
}

.body-text-light {
    color: var(--cream-light);
}

.body-text-light em {
    color: var(--amber-candle);
}

/* --- Marginalia --- */
.marginalia {
    display: block;
    font-family: var(--font-accent);
    font-size: clamp(1rem, 1.8vw, 1.4rem);
    font-weight: 400;
    color: var(--terracotta-blush);
    opacity: 0.7;
    transform: rotate(-4deg);
    margin-top: 16px;
    margin-left: -20px;
}

.marginalia-light {
    color: var(--amber-candle);
}

/* --- Pull Quote --- */
.pull-quote {
    position: relative;
    z-index: 5;
    max-width: 680px;
    padding: 0 40px;
    transform: rotate(-6deg);
}

.pull-quote-text {
    font-family: var(--font-accent);
    font-size: clamp(1.6rem, 3.5vw, 2.8rem);
    font-weight: 700;
    color: var(--kintsugi-gold);
    line-height: 1.4;
    letter-spacing: -0.01em;
}

/* --- Chamber Section --- */
.chamber-content {
    max-width: 640px;
    padding: 0 40px;
}

.chamber-content-lower {
    max-width: 640px;
    padding: 0 40px;
}

/* --- Return Section --- */
.return-content {
    max-width: 640px;
    padding: 0 40px;
    text-align: center;
}

.return-content .marginalia {
    text-align: center;
    margin-left: 0;
}

/* --- Kintsugi Bloom --- */
.kintsugi-bloom {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(
        circle,
        rgba(201, 168, 76, 0.5) 0%,
        rgba(232, 166, 48, 0.2) 30%,
        rgba(201, 168, 76, 0.05) 60%,
        transparent 100%
    );
    opacity: 0;
    transition: opacity 1.5s var(--ease-organic), transform 1.5s var(--ease-organic);
    transform: scale(0.5);
    z-index: 3;
}

.kintsugi-bloom.visible {
    opacity: 1;
    transform: scale(1);
}

/* --- Final Moon --- */
.final-moon {
    z-index: 5;
    animation: slowRotate 30s linear infinite;
    opacity: 0;
    transition: opacity 2s var(--ease-organic);
}

.final-moon.visible {
    opacity: 1;
}

@keyframes slowRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* --- Closing Line --- */
.closing-line {
    font-family: var(--font-headline);
    font-size: clamp(1.4rem, 2.5vw, 2rem);
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--ink-black-warm);
    opacity: 0.6;
    z-index: 5;
}

/* --- Zoom-Focus Animation --- */
.zoom-element {
    opacity: 0;
    transform: scale(0.94);
    filter: blur(2px);
    transition: opacity 0.8s var(--ease-organic),
                transform 0.8s var(--ease-organic),
                filter 0.8s var(--ease-organic);
}

.zoom-element.in-view {
    opacity: 1;
    transform: scale(1);
    filter: blur(0px);
}

/* Keep hero title rotation when in view */
.hero-title.in-view {
    transform: scale(1) rotate(-8deg);
}

/* Keep marginalia rotation when in view */
.marginalia.in-view {
    transform: scale(1) rotate(-4deg);
}

/* Keep pull quote rotation when in view */
.pull-quote.in-view .pull-quote-text,
.pull-quote.in-view {
    transform: scale(1) rotate(-6deg);
}

/* --- Wabi-Sabi Imperfect Borders --- */
.tilt-content {
    border-radius: 2px 4px 3px 5px;
}

.chamber-content,
.chamber-content-lower {
    border-radius: 3px 5px 2px 4px;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .content-left,
    .content-right {
        margin-left: 24px;
        margin-right: 24px;
    }

    .opening-content {
        margin-left: 24px;
    }

    .moon-photograph {
        right: -30%;
        width: 80vw;
        height: 80vw;
        opacity: 0.4;
    }

    .pull-quote {
        padding: 0 24px;
    }

    .chamber-content,
    .chamber-content-lower,
    .return-content {
        padding: 0 24px;
    }

    .moon-nav {
        top: 16px;
        right: 16px;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: clamp(2rem, 10vw, 3.5rem);
    }

    .section {
        padding: 48px 0;
    }

    .section-opening {
        padding-bottom: 80px;
    }

    .section-chamber {
        gap: 48px;
        padding: 80px 0;
    }

    .section-return {
        gap: 40px;
    }
}
