/* =============================================
   lotus.dev -- styles.css
   Warm-Earthy Vaporwave / Contemplative Scroll
   ============================================= */

/* --- CSS Custom Properties --- */
:root {
    /* Backgrounds */
    --bg-primary: #F5EDE0;
    --bg-secondary: #E8DCC8;
    --bg-deep: #D4C4A8;
    --bg-vellum: #EDE4D8;

    /* Text */
    --text-primary: #5B3A29;
    --text-body: #4A3728;
    --text-code: #7A5C47;

    /* Accents */
    --accent-terracotta: #C4724E;
    --accent-terracotta-mid: #D4896A;
    --accent-terracotta-light: #E0A88A;
    --accent-copper-oxidized: #7B9E87;
    --accent-plum: #8B6B7B;
    --accent-copper-muted: #B87B5E;

    /* Progress indicator */
    --progress-top: #C17F4A;
    --progress-bottom: #6B4C5E;

    /* Shadows */
    --shadow-warm: rgba(90, 58, 41, 0.12);

    /* Typography */
    --font-heading: 'Playfair Display', Georgia, serif;
    --font-body: 'Source Serif 4', 'Source Serif Pro', Georgia, serif;
    --font-code: 'IBM Plex Mono', 'Courier New', monospace;
    --font-accent: 'Cormorant Garamond', 'Garamond', serif;
}

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

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

body {
    background-color: var(--bg-primary);
    color: var(--text-body);
    font-family: var(--font-body);
    font-size: 18px;
    line-height: 1.85;
    font-weight: 400;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Scroll Progress Indicator --- */
#scroll-progress {
    position: fixed;
    left: 16px;
    top: 0;
    width: 3px;
    height: 0%;
    background: var(--progress-top);
    z-index: 1000;
    transition: background-color 0.3s ease;
    border-radius: 0 0 1.5px 1.5px;
}

/* --- Atmospheric Plum Overlays --- */
#atmosphere-top {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 120px;
    background: linear-gradient(to bottom, rgba(139, 107, 123, 0.08), transparent);
    pointer-events: none;
    z-index: 999;
}

#atmosphere-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 120px;
    background: linear-gradient(to top, rgba(139, 107, 123, 0.1), transparent);
    pointer-events: none;
    z-index: 999;
}

/* --- VOID ENTRY --- */
#void-entry {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-primary);
    z-index: 1;
    overflow: hidden;
}

/* --- Lotus Glyph (Monumental - 240px) --- */
#lotus-glyph {
    position: relative;
    width: 240px;
    height: 240px;
    margin-bottom: 40px;
    opacity: 0;
}

#lotus-glyph.bloomed {
    opacity: 1;
}

.petal {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    clip-path: ellipse(22% 42% at 50% 30%);
    transform-origin: 50% 70%;
    transform: rotate(calc(var(--i) * 45deg)) scale(0) rotate(-20deg);
    mix-blend-mode: multiply;
    opacity: 0;
    transition: none;
}

.petal:nth-child(odd) {
    background-color: var(--accent-terracotta);
}
.petal:nth-child(even) {
    background-color: var(--accent-terracotta-mid);
}
.petal:nth-child(3n) {
    background-color: var(--accent-terracotta-light);
}

#lotus-glyph.bloomed .petal {
    animation: petalBloom 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    animation-delay: calc(1.2s + var(--i) * 0.08s);
}

@keyframes petalBloom {
    from {
        transform: rotate(calc(var(--i) * 45deg)) scale(0) rotate(-20deg);
        opacity: 0;
    }
    to {
        transform: rotate(calc(var(--i) * 45deg)) scale(1) rotate(0deg);
        opacity: 0.85;
    }
}

/* --- Site Title --- */
#site-title {
    font-family: var(--font-heading);
    font-size: 96px;
    font-weight: 400;
    letter-spacing: 0.08em;
    color: var(--text-primary);
    text-transform: none;
    opacity: 0;
    transition: opacity 1.2s ease;
}

#site-title.visible {
    opacity: 1;
}

/* --- Entry Ripple --- */
#entry-ripple {
    position: absolute;
    bottom: 60px;
    width: 200px;
    height: 40px;
}

#entry-ripple-svg {
    width: 100%;
    height: 100%;
}

.pulse-circle {
    animation: pulseDown 3s ease-in-out infinite;
    animation-delay: var(--delay);
}

@keyframes pulseDown {
    0%, 100% {
        opacity: 0.1;
        transform: translateY(0);
    }
    50% {
        opacity: 0.5;
        transform: translateY(4px);
    }
}

/* --- Ripple Zones --- */
.ripple-zone {
    position: relative;
    width: 100%;
    height: 80px;
    overflow: hidden;
    z-index: 0;
    background: transparent;
}

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

.ripple-svg circle {
    fill: none;
    stroke: var(--accent-copper-muted);
    stroke-width: 0.5;
    opacity: 0;
    animation: rippleExpand var(--duration, 10s) ease-out infinite;
    animation-delay: var(--delay, 0s);
}

@keyframes rippleExpand {
    0% {
        r: 2;
        opacity: 0.5;
    }
    100% {
        r: 180;
        opacity: 0;
    }
}

/* --- Teaching Layers --- */
.teaching-layer {
    position: relative;
    z-index: var(--z, 2);
    margin-top: -60px;
    background-color: var(--layer-bg, var(--bg-primary));
    box-shadow: 0 -8px 24px var(--shadow-warm);
    padding: 80px 0 100px 0;
    min-height: 100vh;
}

.teaching-layer:first-of-type {
    margin-top: 0;
}

.layer-content {
    max-width: 580px;
    margin: 0 auto;
    padding: 0 24px;
    text-align: left;
}

/* --- Lotus Divider (Medium - 48px) --- */
.lotus-divider {
    position: relative;
    width: 48px;
    height: 48px;
    margin: 0 auto 48px auto;
}

.mini-petal {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    clip-path: ellipse(22% 42% at 50% 30%);
    transform-origin: 50% 70%;
    transform: rotate(calc(var(--i) * 45deg));
    mix-blend-mode: multiply;
    opacity: 0.7;
}

.mini-petal:nth-child(odd) {
    background-color: var(--accent-terracotta);
}
.mini-petal:nth-child(even) {
    background-color: var(--accent-terracotta-mid);
}
.mini-petal:nth-child(3n) {
    background-color: var(--accent-terracotta-light);
}

/* --- Headings --- */
h2 {
    font-family: var(--font-heading);
    font-size: 56px;
    font-weight: 400;
    letter-spacing: 0.06em;
    color: var(--text-primary);
    text-transform: none;
    margin-bottom: 36px;
    line-height: 1.2;
}

/* --- Body Text --- */
.layer-content p {
    font-family: var(--font-body);
    font-size: 18px;
    line-height: 1.85;
    color: var(--text-body);
    margin-bottom: 28px;
}

.layer-content p em {
    font-style: italic;
    color: var(--accent-terracotta);
}

/* --- Code Blocks --- */
.code-block {
    background-color: var(--bg-vellum);
    box-shadow: inset 0 2px 8px rgba(90, 58, 41, 0.1);
    padding: 28px 32px;
    margin: 36px 0;
    overflow-x: auto;
    position: relative;
}

.code-block::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: repeating-conic-gradient(
        from 0deg at 50% 50%,
        rgba(196, 114, 78, 0.03) 0deg 30deg,
        transparent 30deg 60deg
    );
    background-size: 40px 40px;
    pointer-events: none;
}

.code-block pre {
    margin: 0;
    position: relative;
    z-index: 1;
}

.code-block code {
    font-family: var(--font-code);
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-code);
    display: block;
    white-space: pre;
}

.code-comment {
    color: var(--accent-copper-muted);
    opacity: 0.7;
}

.code-keyword {
    color: var(--accent-terracotta);
    font-weight: 400;
}

.code-fn {
    color: var(--accent-copper-oxidized);
}

/* --- Captions --- */
.caption {
    font-family: var(--font-accent);
    font-size: 22px;
    font-weight: 300;
    font-style: italic;
    letter-spacing: 0.03em;
    color: var(--accent-plum);
    line-height: 1.6;
}

/* --- Root System --- */
#root-system {
    position: relative;
    z-index: var(--z, 6);
    margin-top: -60px;
    background-color: var(--layer-bg, var(--bg-deep));
    box-shadow: 0 -8px 24px var(--shadow-warm);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#root-canvas {
    width: 100%;
    max-width: 800px;
    height: 500px;
    display: block;
    margin: 0 auto;
}

#root-quote {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 580px;
    text-align: center;
    font-family: var(--font-accent);
    font-size: 20px;
    font-weight: 300;
    font-style: italic;
    letter-spacing: 0.03em;
    color: var(--accent-plum);
    opacity: 0;
    transition: opacity 1.5s ease;
}

#root-quote.visible {
    opacity: 1;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    #site-title {
        font-size: 52px;
        letter-spacing: 0.05em;
    }

    h2 {
        font-size: 38px;
    }

    #lotus-glyph {
        width: 160px;
        height: 160px;
    }

    .layer-content {
        max-width: 100%;
        padding: 0 20px;
    }

    .teaching-layer {
        padding: 60px 0 80px 0;
        margin-top: -40px;
    }

    .code-block {
        padding: 20px 16px;
    }

    .code-block code {
        font-size: 13px;
    }

    #root-canvas {
        height: 350px;
    }
}

@media (max-width: 480px) {
    #site-title {
        font-size: 36px;
    }

    h2 {
        font-size: 30px;
    }

    #lotus-glyph {
        width: 120px;
        height: 120px;
        margin-bottom: 24px;
    }

    .caption {
        font-size: 18px;
    }
}
