/* ========================================
   namu.land - Watercolor Devotional
   Temple-visit narrative architecture
   ======================================== */

/* CSS Custom Properties */
:root {
    --hanji-cream: #f5ede0;
    --aged-parchment: #f0e6d4;
    --warm-vellum: #ebe2d2;
    --beeswax-amber: #c4a882;
    --temple-gold: #a8904e;
    --aged-walnut: #4a3f35;
    --weathered-stone: #8a7d6d;
    --ink-soot: #2c2520;
    --moss-breath: #8a9a7a;
    --rain-slate: #9aa0a8;
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
    background-color: var(--hanji-cream);
}

body {
    font-family: 'Libre Baskerville', Georgia, serif;
    color: var(--aged-walnut);
    background-color: var(--hanji-cream);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* ========================================
   Paper Grain Overlay
   ======================================== */
.paper-grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 400ms ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
    background-repeat: repeat;
}

.paper-grain-overlay.visible {
    opacity: 1;
}

/* ========================================
   Scroll Container
   ======================================== */
.scroll-container {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: repeat(4, auto);
    scroll-snap-type: y proximity;
    position: relative;
    z-index: 1;
}

/* ========================================
   Section Base
   ======================================== */
.section {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    scroll-snap-align: start;
    overflow: hidden;
}

.section-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.section-content {
    position: relative;
    z-index: 2;
    max-width: 680px;
    width: 100%;
    margin: 0 auto;
    padding: clamp(3rem, 8vh, 6rem) clamp(1.5rem, 5vw, 3rem);
}

/* ========================================
   Marble Texture
   ======================================== */
.marble-texture {
    background:
        repeating-linear-gradient(
            23deg,
            transparent,
            transparent 80px,
            rgba(196, 168, 130, 0.03) 80px,
            rgba(196, 168, 130, 0.03) 82px
        ),
        repeating-linear-gradient(
            157deg,
            transparent,
            transparent 120px,
            rgba(196, 168, 130, 0.025) 120px,
            rgba(196, 168, 130, 0.025) 123px
        ),
        repeating-linear-gradient(
            89deg,
            transparent,
            transparent 100px,
            rgba(196, 168, 130, 0.04) 100px,
            rgba(196, 168, 130, 0.04) 101px
        );
    background-size: 400px 400px;
    opacity: 0;
    transition: opacity 600ms ease;
}

.marble-texture.visible {
    opacity: 1;
}

/* ========================================
   Watercolor Wash Accents
   ======================================== */
.watercolor-wash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity 1200ms ease;
}

.watercolor-wash.visible {
    opacity: 1;
}

.wash-courtyard {
    background:
        radial-gradient(ellipse at 15% 30%, rgba(138, 154, 122, 0.06) 0%, transparent 60%),
        radial-gradient(ellipse at 85% 70%, rgba(196, 168, 130, 0.05) 0%, transparent 50%);
}

.wash-inner-hall {
    background:
        radial-gradient(ellipse at 90% 20%, rgba(138, 154, 122, 0.04) 0%, transparent 55%),
        radial-gradient(ellipse at 10% 80%, rgba(196, 168, 130, 0.05) 0%, transparent 50%);
}

.wash-garden {
    background:
        radial-gradient(ellipse at 50% 30%, rgba(168, 144, 78, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 20% 70%, rgba(138, 154, 122, 0.04) 0%, transparent 55%);
}

/* ========================================
   Section 1: The Threshold
   ======================================== */
.section-threshold {
    background-color: var(--hanji-cream);
    height: 100vh;
    min-height: 100vh;
}

.candlelight-glow {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 50% 45%, rgba(168, 144, 78, 0.03) 0%, transparent 40%);
    z-index: 1;
    pointer-events: none;
}

.threshold-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 100vh;
    padding-top: 0;
    padding-bottom: 0;
}

.typewriter-text {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: clamp(2rem, 5vw, 3.5rem);
    color: var(--aged-walnut);
    letter-spacing: 0.08em;
    text-transform: lowercase;
    visibility: hidden;
    min-height: 1.2em;
    line-height: 1.2;
}

.typewriter-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--beeswax-amber);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink 1.06s step-end infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

@keyframes fade-out {
    to { opacity: 0; }
}

.threshold-rule {
    width: 120px;
    height: 1px;
    background-color: var(--beeswax-amber);
    margin: 1.5rem auto;
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 600ms ease-out;
}

.threshold-rule.visible {
    transform: scaleX(1);
}

.threshold-subtitle {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-style: italic;
    font-size: 0.85rem;
    color: var(--weathered-stone);
    letter-spacing: 0.12em;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 800ms ease-out, transform 800ms ease-out;
}

.threshold-subtitle.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ========================================
   Section Transitions (gradient blending)
   ======================================== */
.section-threshold::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 80px;
    background: linear-gradient(to bottom, transparent, var(--aged-parchment));
    z-index: 3;
    pointer-events: none;
}

.section-courtyard::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 80px;
    background: linear-gradient(to bottom, var(--aged-parchment), transparent);
    z-index: 3;
    pointer-events: none;
}

.section-courtyard::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 80px;
    background: linear-gradient(to bottom, transparent, var(--hanji-cream));
    z-index: 3;
    pointer-events: none;
}

.section-inner-hall::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 80px;
    background: linear-gradient(to bottom, var(--hanji-cream), transparent);
    z-index: 3;
    pointer-events: none;
}

.section-inner-hall::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 80px;
    background: linear-gradient(to bottom, transparent, var(--warm-vellum));
    z-index: 3;
    pointer-events: none;
}

.section-garden::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 80px;
    background: linear-gradient(to bottom, var(--warm-vellum), transparent);
    z-index: 3;
    pointer-events: none;
}

/* ========================================
   Section 2: The Courtyard
   ======================================== */
.section-courtyard {
    background-color: var(--aged-parchment);
}

.courtyard-content {
    padding-top: clamp(4rem, 10vh, 8rem);
    padding-bottom: clamp(4rem, 10vh, 8rem);
}

.section-heading {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(1.4rem, 3vw, 2rem);
    color: var(--aged-walnut);
    letter-spacing: 0.06em;
    text-transform: lowercase;
    margin-bottom: 3rem;
    text-align: center;
}

.courtyard-text p {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.8vw, 1.1rem);
    line-height: 1.85;
    letter-spacing: 0.01em;
    color: var(--aged-walnut);
    margin-bottom: 1.8rem;
}

.courtyard-text p:last-child {
    margin-bottom: 0;
}

.courtyard-text em {
    font-style: italic;
    color: var(--ink-soot);
}

/* ========================================
   Section 3: The Inner Hall
   ======================================== */
.section-inner-hall {
    background-color: var(--hanji-cream);
}

.inner-hall-content {
    padding-top: clamp(4rem, 10vh, 8rem);
    padding-bottom: clamp(4rem, 10vh, 8rem);
}

.inner-hall-blocks {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.text-block {
    margin-bottom: 4rem;
}

.text-block:last-child {
    margin-bottom: 0;
}

.block-title {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(1rem, 2vw, 1.3rem);
    color: var(--weathered-stone);
    letter-spacing: 0.18em;
    text-transform: lowercase;
    font-variant: small-caps;
    margin-bottom: 1.2rem;
}

.text-block p {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.8vw, 1.1rem);
    line-height: 1.85;
    letter-spacing: 0.01em;
    color: var(--aged-walnut);
}

/* ========================================
   Section 4: The Garden
   ======================================== */
.section-garden {
    background-color: var(--warm-vellum);
    min-height: 80vh;
}

.garden-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 80vh;
}

/* ========================================
   Candle SVG
   ======================================== */
.candle-container {
    margin-bottom: 3rem;
}

.candle-svg {
    width: 40px;
    height: 80px;
    overflow: visible;
}

.candle-flame {
    transform-origin: 20px 33px;
    animation:
        flame-dance 3s ease-in-out infinite,
        flame-glow 4s ease-in-out infinite;
}

.candle-flame-inner {
    transform-origin: 20px 31px;
    animation: flame-dance-inner 2.7s ease-in-out infinite;
}

@keyframes flame-dance {
    0%, 100% { transform: scaleY(1) scaleX(1); }
    33% { transform: scaleY(1.05) scaleX(0.97); }
    66% { transform: scaleY(0.95) scaleX(1.03); }
}

@keyframes flame-dance-inner {
    0%, 100% { transform: scaleY(1) scaleX(1); }
    40% { transform: scaleY(1.03) scaleX(0.98); }
    70% { transform: scaleY(0.97) scaleX(1.02); }
}

@keyframes flame-glow {
    0%, 100% { filter: blur(0px) drop-shadow(0 0 20px rgba(168, 144, 78, 0.2)); }
    50% { filter: blur(0.5px) drop-shadow(0 0 35px rgba(168, 144, 78, 0.35)); }
}

/* ========================================
   Garden Footer
   ======================================== */
.garden-footer {
    margin-top: 1rem;
}

.footer-text {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-size: 0.7rem;
    color: var(--weathered-stone);
    letter-spacing: 0.18em;
    text-transform: lowercase;
    font-variant: small-caps;
    margin-bottom: 0.4rem;
}

.footer-year {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-size: 0.65rem;
    color: var(--rain-slate);
    letter-spacing: 0.18em;
    text-transform: lowercase;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
    .section-content {
        padding: clamp(2rem, 6vh, 4rem) clamp(1.2rem, 4vw, 2rem);
    }

    .text-block {
        margin-bottom: 3rem;
    }

    .courtyard-text p {
        margin-bottom: 1.5rem;
    }
}

@media (max-width: 480px) {
    .section-content {
        padding: 2rem 1.2rem;
    }

    .threshold-content {
        padding: 2rem 1.2rem;
    }
}
