/* ==========================================================
   munju.wiki — Wabi-Sabi Celestial Archive
   ========================================================== */

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

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

body {
    background-color: #0A1020;
    color: #8090A8;
    font-family: 'EB Garamond', Georgia, serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.2vw, 1.1rem);
    line-height: 1.95;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Star Field (fixed background scatter) --- */
#star-field {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

#star-field .star {
    position: absolute;
    border-radius: 50%;
    background: #B0C0D0;
}

#star-field .star--twinkle {
    animation: twinkle var(--twinkle-dur, 4s) ease-in-out infinite alternate;
    animation-delay: var(--twinkle-delay, 0s);
}

@keyframes twinkle {
    0%   { opacity: var(--twinkle-lo, 0.04); }
    100% { opacity: var(--twinkle-hi, 0.2); }
}

/* --- Nebula Layers (fixed gradient-mesh) --- */
#nebula-layer {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.nebula {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    will-change: opacity;
}

.nebula--alpha {
    width: 60vw;
    height: 60vw;
    top: -15vh;
    left: -10vw;
    background: radial-gradient(ellipse at 40% 45%, #1A1838 0%, transparent 70%);
    opacity: 0.45;
    animation: nebulaPulse 12s ease-in-out infinite alternate;
}

.nebula--beta {
    width: 50vw;
    height: 45vw;
    bottom: -10vh;
    right: -8vw;
    background: radial-gradient(ellipse at 55% 60%, #6070A0 0%, transparent 65%);
    opacity: 0.18;
    animation: nebulaPulse 16s ease-in-out infinite alternate-reverse;
}

.nebula--gamma {
    width: 35vw;
    height: 35vw;
    top: 45vh;
    left: 30vw;
    background: radial-gradient(ellipse at 50% 50%, #1A1838 0%, #0A1020 60%, transparent 80%);
    opacity: 0.25;
    animation: nebulaPulse 20s ease-in-out infinite alternate;
}

@keyframes nebulaPulse {
    0%   { opacity: var(--neb-lo, 0.15); transform: scale(1); }
    100% { opacity: var(--neb-hi, 0.35); transform: scale(1.06); }
}

.nebula--alpha {
    --neb-lo: 0.35;
    --neb-hi: 0.5;
}
.nebula--beta {
    --neb-lo: 0.12;
    --neb-hi: 0.22;
}
.nebula--gamma {
    --neb-lo: 0.18;
    --neb-hi: 0.3;
}

/* --- Content layering above background --- */
#void-opening,
#knowledge-stream,
#void-closing {
    position: relative;
    z-index: 1;
}

/* ==========================================================
   OPENING VOID — first 100vh
   ========================================================== */

#void-opening {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 8vw;
}

.void-inner {
    position: relative;
}

.title-cluster {
    max-width: 52rem;
    /* Asymmetric: offset to the left */
    margin-left: 4vw;
}

.title-annotation {
    display: block;
    font-family: 'Caveat', cursive;
    font-size: clamp(0.85rem, 1.1vw, 1rem);
    color: #6070A0;
    letter-spacing: 0.04em;
    margin-bottom: 0.8rem;
    opacity: 0;
    transform: translateY(8px);
    animation: annotationFadeIn 1.8s 1.2s ease-out forwards;
}

.site-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
    font-size: clamp(3rem, 7vw, 5.5rem);
    color: #C0C8D8;
    letter-spacing: 0.12em;
    line-height: 1;
    margin-bottom: 1.2rem;
    opacity: 0;
    animation: titleReveal 2.4s 0.4s ease-out forwards;
}

.gold-dot {
    color: #C0A870;
}

.title-whisper {
    font-family: 'EB Garamond', Georgia, serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(0.9rem, 1.3vw, 1.15rem);
    color: #8090A8;
    letter-spacing: 0.06em;
    opacity: 0;
    animation: whisperIn 2s 2s ease-out forwards;
}

@keyframes titleReveal {
    0%   { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}

@keyframes annotationFadeIn {
    0%   { opacity: 0; transform: translateY(8px); }
    100% { opacity: 0.7; transform: translateY(0); }
}

@keyframes whisperIn {
    0%   { opacity: 0; }
    100% { opacity: 0.55; }
}

/* Star cluster near title */
.opening-star-cluster {
    position: absolute;
    top: -5rem;
    right: 8vw;
    width: 12rem;
    height: 12rem;
}

.star-svg {
    position: absolute;
}

.star--large {
    width: 5rem;
    height: 5rem;
    top: 0;
    right: 0;
    animation: twinkle 6s ease-in-out infinite alternate;
}

.star--med {
    width: 2.5rem;
    height: 2.5rem;
    bottom: 1rem;
    left: 2rem;
    animation: twinkle 4.5s ease-in-out infinite alternate-reverse;
}

/* Scroll drift indicator */
.scroll-drift {
    position: absolute;
    bottom: 6vh;
    left: calc(4vw + 8vw);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.drift-line {
    display: block;
    width: 1px;
    height: 4rem;
    background: linear-gradient(to bottom, transparent, #6070A0 40%, transparent);
    opacity: 0.3;
    animation: driftPulse 3s ease-in-out infinite;
}

@keyframes driftPulse {
    0%, 100% { opacity: 0.15; transform: scaleY(0.8); }
    50%      { opacity: 0.35; transform: scaleY(1); }
}

/* ==========================================================
   KNOWLEDGE STREAM — organic flow
   ========================================================== */

#knowledge-stream {
    padding: 8vh 0 12vh;
}

/* --- Passage base --- */
.flow-passage {
    position: relative;
    margin-bottom: 12vh;
    /* Zoom-focus initial state */
    opacity: 0.35;
    transform: scale(0.92);
    transition: opacity 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.flow-passage.in-focus {
    opacity: 1;
    transform: scale(1);
}

/* --- Organic flow: each passage has unique positioning --- */
.passage--first {
    padding-left: 12vw;
    padding-right: 22vw;
    display: flex;
    gap: 3rem;
}

.passage--first .passage-ornament {
    flex-shrink: 0;
    width: 60px;
    padding-top: 0.5rem;
}

.passage--first .passage-body {
    flex: 1;
    max-width: 38rem;
}

.passage--second {
    padding-left: 25vw;
    padding-right: 10vw;
    position: relative;
}

.passage--second .passage-body {
    max-width: 36rem;
}

.passage--third {
    padding-left: 8vw;
    padding-right: 18vw;
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.passage--third .passage-body {
    max-width: 40rem;
    flex: 1;
}

.passage--third .passage-ornament--offset {
    flex-shrink: 0;
    width: 80px;
    margin-top: 3rem;
}

.passage--fourth {
    padding-left: 18vw;
    padding-right: 14vw;
    position: relative;
}

.passage--fourth .passage-body {
    max-width: 35rem;
}

.passage--fifth {
    padding-left: 10vw;
    padding-right: 20vw;
    display: flex;
    gap: 2rem;
}

.passage--fifth .passage-ornament--small {
    flex-shrink: 0;
    width: 30px;
    padding-top: 0.8rem;
}

.passage--fifth .passage-body {
    max-width: 38rem;
    flex: 1;
}

/* --- Passage typography --- */
.passage-heading {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
    font-size: clamp(2rem, 4vw, 3.2rem);
    color: #C0C8D8;
    line-height: 1.2;
    margin-bottom: 1.6rem;
    letter-spacing: 0.02em;
}

.passage-text {
    color: #8090A8;
    margin-bottom: 1.4rem;
}

.passage-text:last-of-type {
    margin-bottom: 0;
}

/* --- Margin notes (wabi-sabi annotations) --- */
.margin-note {
    display: block;
    font-family: 'Caveat', cursive;
    font-size: clamp(0.85rem, 1.1vw, 1.05rem);
    color: #6070A0;
    margin-top: 1.8rem;
    padding-left: 1rem;
    border-left: 1px solid rgba(96, 112, 160, 0.2);
    line-height: 1.6;
    opacity: 0;
    transition: opacity 1.2s ease-out 0.4s;
}

.flow-passage.in-focus .margin-note {
    opacity: 0.7;
}

.margin-note--right {
    position: absolute;
    right: 3vw;
    top: 2rem;
    max-width: 14rem;
    padding-left: 0;
    padding-right: 1rem;
    border-left: none;
    border-right: 1px solid rgba(96, 112, 160, 0.2);
    text-align: right;
}

.margin-note--left {
    position: absolute;
    left: 5vw;
    bottom: -2rem;
    max-width: 12rem;
}

/* --- Flow interlude (decorative break) --- */
.flow-interlude {
    position: relative;
    height: 20vh;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 4vh 0;
}

.interlude-nebula {
    position: absolute;
    width: 40vw;
    height: 12vh;
    background: radial-gradient(ellipse at center, #1A1838 0%, transparent 70%);
    opacity: 0.2;
    filter: blur(40px);
}

.interlude-stars {
    width: 200px;
    height: 40px;
    opacity: 0.6;
}

/* --- Ornament SVGs --- */
.ornament-star,
.ornament-ring,
.ornament-star-sm {
    width: 100%;
    height: auto;
    display: block;
}

/* ==========================================================
   CLOSING VOID
   ========================================================== */

#void-closing {
    min-height: 40vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8vh 8vw;
    text-align: center;
}

.closing-inner {
    position: relative;
}

.closing-text {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1.2rem, 2.2vw, 1.8rem);
    color: #C0C8D8;
    letter-spacing: 0.04em;
    opacity: 0.6;
    margin-bottom: 1.5rem;
}

.closing-annotation {
    display: block;
    font-family: 'Caveat', cursive;
    font-size: clamp(0.8rem, 1vw, 0.95rem);
    color: #6070A0;
    opacity: 0.45;
}

.closing-star-scatter {
    position: absolute;
    top: -3rem;
    right: -5rem;
}

.closing-star {
    width: 20px;
    height: 20px;
}

/* ==========================================================
   WABI-SABI TEXTURE DETAILS
   ========================================================== */

/* Subtle noise overlay on body for weathered feel */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.025;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-size: 256px 256px;
}

/* Uneven passage borders — wabi-sabi imperfection */
.passage--first .passage-body::before {
    content: '';
    position: absolute;
    left: 12vw;
    top: -2vh;
    width: 3rem;
    height: 1px;
    background: linear-gradient(to right, transparent, #6070A0 30%, #6070A0 70%, transparent);
    opacity: 0.15;
}

.passage--third .passage-body::after {
    content: '';
    position: absolute;
    right: 18vw;
    bottom: -3vh;
    width: 5rem;
    height: 1px;
    background: linear-gradient(to right, transparent, #C0A870 40%, transparent);
    opacity: 0.1;
}

/* ==========================================================
   RESPONSIVE — preserve organic feel at smaller viewports
   ========================================================== */

@media (max-width: 900px) {
    .passage--first,
    .passage--second,
    .passage--third,
    .passage--fourth,
    .passage--fifth {
        padding-left: 6vw;
        padding-right: 6vw;
    }

    .passage--first {
        flex-direction: column;
        gap: 1.5rem;
    }

    .passage--third {
        flex-direction: column;
    }

    .passage--fifth {
        flex-direction: column;
    }

    .margin-note--right {
        position: relative;
        right: auto;
        top: auto;
        max-width: none;
        text-align: left;
        border-right: none;
        border-left: 1px solid rgba(96, 112, 160, 0.2);
        padding-right: 0;
        padding-left: 1rem;
        margin-top: 1.5rem;
    }

    .margin-note--left {
        position: relative;
        left: auto;
        bottom: auto;
        max-width: none;
    }

    .title-cluster {
        margin-left: 0;
    }

    .opening-star-cluster {
        right: 2vw;
        top: -3rem;
        width: 8rem;
        height: 8rem;
    }

    .star--large {
        width: 3.5rem;
        height: 3.5rem;
    }
}

@media (max-width: 600px) {
    .site-title {
        letter-spacing: 0.06em;
    }

    #void-opening {
        padding: 0 5vw;
    }

    .passage-heading {
        font-size: clamp(1.6rem, 5vw, 2.4rem);
    }

    .opening-star-cluster {
        display: none;
    }
}
