/* ==========================================================================
   tanso.day -- a devotional to carbon
   Palette:
     #F8F4FF  lavender white (primary background, dawn)
     #1A0E2E  midnight violet (text on light, night background)
     #7B68EE  medium slate blue (aurora midpoint, link)
     #E0D4FF  pale violet (secondary surfaces)
     #FF6B9D  aurora rose (gradient accent)
     #4ECDC4  seafoam (aurora accent, isometric fill)
     #FFF8E7  warm ivory (noon background)
     #C4B5A0  marble vein beige
   Fonts: Cormorant Garamond (display), Outfit (body), Space Grotesk (marker)
   ========================================================================== */

:root {
    --c-lavender:   #F8F4FF;
    --c-midnight:   #1A0E2E;
    --c-slate:      #7B68EE;
    --c-pale:       #E0D4FF;
    --c-rose:       #FF6B9D;
    --c-seafoam:    #4ECDC4;
    --c-ivory:      #FFF8E7;
    --c-marble:     #C4B5A0;

    --font-display: "Cormorant Garamond", Garamond, "Times New Roman", serif;
    --font-body:    "Outfit", system-ui, -apple-system, sans-serif;
    --font-marker:  "Space Grotesk", "Outfit", sans-serif;

    --ma-unit:      clamp(4rem, 8vh, 8rem);
    --section-pad-y: clamp(6rem, 15vh, 12rem);
    --section-pad-x: clamp(2rem, 5vw, 6rem);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 1.05rem;
    line-height: 1.85;
    letter-spacing: 0.01em;
    color: var(--c-midnight);
    background-color: var(--c-lavender);
    overflow-x: hidden;
    min-height: 100vh;
    position: relative;
}

sub {
    font-size: 0.72em;
    vertical-align: sub;
}

/* --------------------------------------------------------------------------
   Sky Background -- full-page aurora that scrolls beneath the narrative
   -------------------------------------------------------------------------- */
.sky-background {
    position: fixed;
    inset: 0;
    z-index: -2;
    background:
        linear-gradient(
            180deg,
            #F8F4FF 0%,
            #E0D4FF 18%,
            #FFF8E7 38%,
            #F8F4FF 55%,
            #FF6B9D 78%,
            #1A0E2E 100%
        );
    background-size: 100% 500vh;
    background-attachment: fixed;
    background-repeat: no-repeat;
    pointer-events: none;
}

.sky-background::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 15% 10%, rgba(78, 205, 196, 0.18), transparent 60%),
        radial-gradient(ellipse at 90% 30%, rgba(123, 104, 238, 0.14), transparent 55%),
        radial-gradient(ellipse at 50% 75%, rgba(255, 107, 157, 0.18), transparent 60%);
    mix-blend-mode: screen;
    opacity: 0.9;
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   Narrative / Section skeleton
   -------------------------------------------------------------------------- */
.narrative {
    position: relative;
    z-index: 1;
}

.section {
    position: relative;
    min-height: 100vh;
    padding: var(--section-pad-y) var(--section-pad-x);
    display: grid;
    align-items: center;
    margin-bottom: -10vh; /* sections overlap so aurora blends */
    z-index: 1;
    isolation: isolate;
}

.section + .section { z-index: 2; }
.section + .section + .section { z-index: 3; }
.section + .section + .section + .section { z-index: 4; }
.section + .section + .section + .section + .section { z-index: 5; }

.section-marker {
    position: absolute;
    bottom: clamp(1.2rem, 3vh, 2.4rem);
    right: clamp(1.5rem, 4vw, 4rem);
    font-family: var(--font-marker);
    font-size: 0.72rem;
    font-weight: 300;
    letter-spacing: 0.35em;
    text-transform: uppercase;
    color: var(--c-midnight);
    opacity: 0.45;
    writing-mode: horizontal-tb;
}

.section--night .section-marker {
    color: var(--c-pale);
    opacity: 0.6;
}

.section-heading {
    font-family: var(--font-display);
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1.6rem, 3.5vw, 2.6rem);
    line-height: 1.2;
    letter-spacing: 0.01em;
    color: var(--c-midnight);
    padding-bottom: 0.6rem;
    margin-bottom: var(--ma-unit);
    border-bottom: 1px solid var(--c-marble);
    display: inline-block;
}

.body-text {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 1.05rem;
    line-height: 1.85;
    letter-spacing: 0.01em;
    color: var(--c-midnight);
    max-width: 36ch;
}

.body-text + .body-text {
    margin-top: calc(var(--ma-unit) * 0.55);
}

/* --------------------------------------------------------------------------
   Lottie ghost containers (fallback CSS-only atmospheric motion)
   -------------------------------------------------------------------------- */
.lottie-ghost {
    position: absolute;
    width: min(48vw, 520px);
    height: min(48vw, 520px);
    opacity: 0.15;
    pointer-events: none;
    z-index: 0;
    filter: blur(0.2px);
}

.lottie-ghost::before {
    content: "";
    position: absolute;
    inset: 12%;
    border-radius: 50%;
    border: 1px dashed var(--c-slate);
    opacity: 0.7;
    animation: spin-slow 80s linear infinite;
}

.lottie-ghost::after {
    content: "";
    position: absolute;
    inset: 28%;
    border-radius: 50%;
    border: 1px solid var(--c-seafoam);
    opacity: 0.9;
    animation: spin-slow 140s linear infinite reverse;
}

@keyframes spin-slow {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

@keyframes drift {
    0%, 100% { transform: translate3d(0, 0, 0); }
    50%      { transform: translate3d(0, -12px, 0); }
}

#lottieDawn {
    top: 8%;
    right: 6%;
    opacity: 0.14;
}

#lottieMorning {
    bottom: 10%;
    left: 4%;
    opacity: 0.12;
    width: min(36vw, 380px);
    height: min(36vw, 380px);
}

#lottieNoon {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.08;
    width: min(60vw, 640px);
    height: min(60vw, 640px);
}

#lottieDusk {
    top: 10%;
    right: 8%;
    opacity: 0.12;
    width: min(34vw, 360px);
    height: min(34vw, 360px);
}

#lottieNight {
    top: 40%;
    left: 20%;
    opacity: 0.18;
    width: min(28vw, 320px);
    height: min(28vw, 320px);
}

/* --------------------------------------------------------------------------
   Section 1 -- Dawn (Hero)
   -------------------------------------------------------------------------- */
.section--dawn {
    background:
        linear-gradient(160deg,
            rgba(248, 244, 255, 0.0) 0%,
            rgba(224, 212, 255, 0.35) 25%,
            rgba(123, 104, 238, 0.28) 50%,
            rgba(255, 107, 157, 0.22) 75%,
            rgba(248, 244, 255, 0.0) 100%);
    min-height: 100vh;
}

.dawn__content {
    grid-column: 1 / -1;
    margin-top: 38vh; /* golden-ratio-ish point from top */
    max-width: 40ch;
    position: relative;
    z-index: 2;
}

.domain {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(2.8rem, 7vw, 5.5rem);
    letter-spacing: 0.06em;
    line-height: 1.05;
    color: var(--c-midnight);
    margin-bottom: calc(var(--ma-unit) * 0.35);
}

.tagline {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 300;
    font-size: clamp(1rem, 1.6vw, 1.25rem);
    letter-spacing: 0.02em;
    color: var(--c-midnight);
    opacity: 0.8;
    max-width: 28ch;
}

/* --------------------------------------------------------------------------
   Section 2 -- Morning
   -------------------------------------------------------------------------- */
.section--morning {
    background:
        linear-gradient(200deg,
            rgba(248, 244, 255, 0.2) 0%,
            rgba(224, 212, 255, 0.45) 35%,
            rgba(255, 248, 231, 0.55) 100%);
}

.morning__grid {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: calc(var(--ma-unit) * 1);
    align-items: center;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

.icon-cluster {
    grid-column: 1 / 2;
    display: flex;
    flex-direction: column;
    gap: calc(var(--ma-unit) * 0.8);
    align-items: flex-start;
    padding-left: clamp(0rem, 2vw, 2rem);
}

.morning__text {
    grid-column: 3 / 4;
    max-width: 36ch;
    justify-self: start;
}

/* middle column left deliberately empty -- ma */

.iso-icon {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    animation: drift 14s ease-in-out infinite;
}

.iso-icon--large .iso-svg { width: 120px; height: 120px; }
.iso-icon--medium .iso-svg { width: 90px; height: 90px; }
.iso-icon--small svg { width: 60px; height: 60px; }

.iso-icon figcaption {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 300;
    font-size: 0.9rem;
    letter-spacing: 0.04em;
    color: var(--c-midnight);
    opacity: 0.75;
    text-align: center;
}

.iso-icon--large  { animation-delay: 0s; }
.iso-icon--medium { animation-delay: -6s; }

/* --------------------------------------------------------------------------
   Section 3 -- Noon
   -------------------------------------------------------------------------- */
.section--noon {
    background:
        linear-gradient(180deg,
            rgba(255, 248, 231, 0.5) 0%,
            rgba(255, 248, 231, 0.85) 50%,
            rgba(224, 212, 255, 0.35) 100%);
    text-align: center;
}

.noon__content {
    grid-column: 1 / -1;
    justify-self: center;
    max-width: 52ch;
    position: relative;
    z-index: 2;
}

.noon__block {
    margin: 8rem auto;
    max-width: 42ch;
    text-align: center;
}

.noon__block:first-child { margin-top: 0; }
.noon__block:last-child  { margin-bottom: 0; }

.marble-divider {
    position: relative;
    width: min(60vw, 420px);
    height: 80px;
    margin: 0 auto;
    background-image:
        linear-gradient(90deg,
            #FFF8E7 0%,
            #C4B5A0 2%,
            #FFF8E7 4%,
            #C4B5A0 6%,
            #FFF8E7 8%,
            #C4B5A0 10%,
            #FFF8E7 14%,
            #C4B5A0 17%,
            #FFF8E7 22%,
            #C4B5A0 26%,
            #FFF8E7 32%,
            #C4B5A0 38%,
            #FFF8E7 46%,
            #C4B5A0 52%,
            #FFF8E7 60%,
            #C4B5A0 66%,
            #FFF8E7 72%,
            #C4B5A0 78%,
            #FFF8E7 84%,
            #C4B5A0 90%,
            #FFF8E7 100%);
    background-size: 220% 100%;
    opacity: 0.5;
    border-top: 1px solid var(--c-marble);
    border-bottom: 1px solid var(--c-marble);
    animation: marble-breathe 24s ease-in-out infinite;
}

@keyframes marble-breathe {
    0%, 100% { background-position: 0% 50%; }
    50%      { background-position: 100% 50%; }
}

/* --------------------------------------------------------------------------
   Section 4 -- Dusk
   -------------------------------------------------------------------------- */
.section--dusk {
    background:
        linear-gradient(200deg,
            rgba(255, 248, 231, 0.35) 0%,
            rgba(255, 107, 157, 0.32) 45%,
            rgba(123, 104, 238, 0.28) 100%);
    text-align: center;
}

.dusk__content {
    grid-column: 1 / -1;
    justify-self: center;
    max-width: 720px;
    position: relative;
    z-index: 2;
}

.dusk__heading {
    display: inline-block;
    margin-bottom: calc(var(--ma-unit) * 1.1);
}

.molecule-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(2rem, 5vw, 4rem);
    justify-items: center;
    align-items: center;
    margin: 0 auto calc(var(--ma-unit) * 1.1);
    max-width: 520px;
}

.molecule-grid .iso-icon {
    animation: drift 11s ease-in-out infinite;
}

.molecule-grid .iso-icon:nth-child(1) { animation-delay: 0s; }
.molecule-grid .iso-icon:nth-child(2) { animation-delay: -1.2s; }
.molecule-grid .iso-icon:nth-child(3) { animation-delay: -2.4s; }
.molecule-grid .iso-icon:nth-child(4) { animation-delay: -3.6s; }
.molecule-grid .iso-icon:nth-child(5) { animation-delay: -4.8s; }
.molecule-grid .iso-icon:nth-child(6) { animation-delay: -6.0s; }
.molecule-grid .iso-icon:nth-child(7) { animation-delay: -7.2s; }
.molecule-grid .iso-icon:nth-child(8) { animation-delay: -8.4s; }
.molecule-grid .iso-icon:nth-child(9) { animation-delay: -9.6s; }

.dusk__close {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 300;
    font-size: clamp(1.05rem, 1.8vw, 1.35rem);
    letter-spacing: 0.03em;
    color: var(--c-midnight);
    opacity: 0.85;
    max-width: 36ch;
    margin: 0 auto;
}

/* --------------------------------------------------------------------------
   Section 5 -- Night
   -------------------------------------------------------------------------- */
.section--night {
    background:
        linear-gradient(180deg,
            rgba(123, 104, 238, 0.28) 0%,
            rgba(26, 14, 46, 0.85) 40%,
            #1A0E2E 100%);
    color: var(--c-pale);
    position: relative;
    overflow: hidden;
}

.section--night::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(90deg,
            #FFF8E7 0%,
            #C4B5A0 2%,
            #FFF8E7 4%,
            #C4B5A0 6%,
            #FFF8E7 8%,
            #C4B5A0 12%,
            #FFF8E7 18%,
            #C4B5A0 24%,
            #FFF8E7 30%,
            #C4B5A0 38%,
            #FFF8E7 46%,
            #C4B5A0 54%,
            #FFF8E7 62%,
            #C4B5A0 70%,
            #FFF8E7 78%,
            #C4B5A0 86%,
            #FFF8E7 100%);
    opacity: 0.03;
    pointer-events: none;
    z-index: 0;
}

.night__content {
    grid-column: 1 / -1;
    justify-self: center;
    align-self: end;
    margin-bottom: 12vh;
    position: relative;
    z-index: 2;
}

.night__line {
    font-family: var(--font-display);
    font-weight: 300;
    font-style: italic;
    font-size: clamp(1.1rem, 2vw, 1.5rem);
    letter-spacing: 0.05em;
    color: var(--c-pale);
    opacity: 0.85;
    text-align: center;
}

/* --------------------------------------------------------------------------
   Scroll Indicator -- a thin vertical rule of aurora progress
   -------------------------------------------------------------------------- */
.scroll-indicator {
    position: fixed;
    top: 0;
    right: clamp(0.5rem, 1.2vw, 1.2rem);
    height: 100vh;
    width: 1px;
    background: rgba(26, 14, 46, 0.08);
    z-index: 10;
    pointer-events: none;
}

.scroll-indicator__fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 0%;
    background: linear-gradient(180deg, #7B68EE 0%, #FF6B9D 55%, #4ECDC4 100%);
    transition: height 120ms linear;
}

/* --------------------------------------------------------------------------
   Reveal states driven by IntersectionObserver in script.js
   -------------------------------------------------------------------------- */
.section {
    opacity: 0.0;
    transform: translateY(14px);
    transition: opacity 1400ms ease, transform 1400ms ease;
}

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

.section--dawn { opacity: 1; transform: none; } /* hero always visible */

/* --------------------------------------------------------------------------
   Responsive adjustments
   -------------------------------------------------------------------------- */
@media (max-width: 860px) {
    .morning__grid {
        grid-template-columns: 1fr;
        gap: calc(var(--ma-unit) * 0.6);
    }
    .icon-cluster {
        grid-column: 1 / -1;
        flex-direction: row;
        gap: 2.5rem;
        justify-content: center;
        padding-left: 0;
    }
    .morning__text { grid-column: 1 / -1; justify-self: center; text-align: left; }
    .molecule-grid { gap: 2rem; }
    .dawn__content { margin-top: 30vh; }
    .noon__block { margin: 5rem auto; }
}

@media (max-width: 520px) {
    .molecule-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.2rem;
    }
    .iso-icon--small svg { width: 50px; height: 50px; }
    .section-marker { right: 1rem; bottom: 1rem; letter-spacing: 0.25em; }
}

@media (prefers-reduced-motion: reduce) {
    .iso-icon,
    .molecule-grid .iso-icon,
    .lottie-ghost::before,
    .lottie-ghost::after,
    .marble-divider {
        animation: none !important;
    }
    html { scroll-behavior: auto; }
}
