/* =========================================================
   MOON PHASE JOURNEY — UPDATED RESPONSIVE VERSION
   ========================================================= */

.moon-phase-scroll-section {
    position: relative;
    height: 400vh;
    background: var(--sky, #030516);
}

.moon-phase-sticky {
    position: sticky;
    top: 0;
    width: 100%;
    height: 100svh;
    min-height: 560px;
    overflow: hidden;
    isolation: isolate;
    background: var(--sky, #030516);
}

.moonj-sky,
.moon-phase-sky,
.moon-phase-vignette {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.moonj-sky {
    z-index: 1;
}

.moonj-star {
    position: absolute;
    left: var(--x);
    top: var(--y);
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: #f4eee2;
    opacity: .35;
    animation: moonj-twinkle 3.4s ease-in-out infinite;
    animation-delay: var(--d);
}

@keyframes moonj-twinkle {
    0%,
    100% {
        opacity: .18;
        transform: scale(1);
    }
    50% {
        opacity: .9;
        transform: scale(1.6);
    }
}

.moon-phase-sky {
    z-index: 0;
    inset: -3%;
    background: linear-gradient(180deg, rgba(3, 5, 22, .05), rgba(3, 5, 22, .18)), url("../img/starry-bg.png") center / cover no-repeat;
    transform: scale(1.045);
    transition: transform 1.2s ease, filter 1s ease;
}

.moon-phase-scroll-section:not([data-stage="0"]) .moon-phase-sky {
    transform: scale(1);
    filter: brightness(.94);
}

.moon-phase-vignette {
    z-index: 2;
    background: radial-gradient(circle at 73% 50%, rgba(111, 86, 177, .17), transparent 44%), linear-gradient(90deg, rgba(2, 4, 20, .29), rgba(2, 4, 20, .025) 55%, rgba(2, 4, 20, .14)), linear-gradient(180deg, rgba(2, 4, 20, .07), rgba(2, 4, 20, .21));
}


/* ---------- Shared content ---------- */

.moon-container {
    position: relative;
    width: min(calc(100% - 48px), 1440px);
    height: 100%;
    margin-inline: auto;
}

.moon-phase-panel {
    position: absolute;
    inset: 0;
    z-index: 8;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .75s ease, visibility .75s linear;
}

.moon-phase-panel.is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.moon-phase-detail .moon-container {
    display: flex;
    align-items: center;
}

.moon-phase-content {
    width: min(42vw, 620px);
    color: rgba(255, 255, 255, .88);
    font-size: 1.08rem;
    line-height: 1.9;
    opacity: 0;
    transform: translateX(-44px);
    transition: opacity .7s ease .15s, transform .85s cubic-bezier(.22, 1, .36, 1) .1s;
}

.moon-phase-panel.is-active .moon-phase-content {
    opacity: 1;
    transform: translateX(0);
}

.moon-phase-content h2 {
    margin: 0 0 1.35rem;
    color: var(--gold, #d5b56f);
    font-family: var(--font-display, serif);
    font-size: clamp(2.5rem, 3.5vw, 4.5rem);
    font-weight: 400;
    line-height: 1.1;
}

.moon-phase-content .nour-kicker {
    color: var(--gold-soft, #e8d4a0);
    margin-bottom: 1rem;
}


/* =========================================================
   INTRO OVERVIEW: FLEX COLUMN, CENTERED
   ========================================================= */

.moon-phase-overview {
    position: absolute;
    inset: 0;
    z-index: 7;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: clamp(12px, 2.25vh, 24px);
    padding: clamp(72px, 14vh, 100px) 0 clamp(15px, 2.5vh, 30px);
    transition: opacity .55s ease, visibility .55s linear;
}

.moon-phase-scroll-section:not([data-stage="0"]) .moon-phase-overview {
    pointer-events: none;
}

.moon-phase-intro-copy {
    position: relative;
    z-index: 9;
    flex: 0 0 auto;
    width: min(calc(100% - 32px), 1000px);
    text-align: center;
    transition: opacity .55s ease, transform .65s cubic-bezier(.22, 1, .36, 1);
}

.moon-phase-intro-copy h2 {
    margin: 0 0 .8rem;
    color: var(--gold, #d5b56f);
    font-family: var(--font-display, serif);
    font-size: clamp(1.7rem, min(3.5vw, 6vh), 4.2rem);
    font-weight: 400;
    line-height: 1.15;
}

.moon-phase-intro-text {
   /* max-width: 720px;*/
    margin: 0 auto;
    color: rgba(255, 255, 255, .86);
    /*font-size: clamp(.85rem, min(1.2vw, 1.8vh), 1.08rem);
    line-height: 1.65;*/
}

.moon-phase-scroll-section:not([data-stage="0"]) .moon-phase-intro-copy {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-18px);
}


/* =========================================================
   ORBIT SCENE
   ========================================================= */

.moon-orbit-scene {
    position: relative;
    z-index: 5;
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    perspective: 1500px;
    perspective-origin: 72% 50%;
    touch-action: pan-y;
    outline: none;
}

.moon-orbit-stage {
    position: absolute;
    inset: 0;
    transform-style: preserve-3d;
    transform: rotateX(-2.5deg) rotateY(var(--drag-rotate, 0deg));
    transition: transform .28s ease-out;
}

.moon-orbit-scene.is-dragging .moon-orbit-stage {
    transition: none;
}

.moon-object {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--moon-size);
    aspect-ratio: 1 / 1;
    transform-origin: center;
    transform-style: preserve-3d;
    cursor: pointer;
    outline: none;
    will-change: left, top, transform, filter, opacity;
    transition: left 1.5s cubic-bezier(.22, 1, .36, 1), top 1.5s cubic-bezier(.22, 1, .36, 1), transform 1.7s cubic-bezier(.37, 0, .63, 1), filter 1.35s ease, opacity 1.35s ease;
}

.moon-object img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    max-width: 100%;
    max-height: 100%;
    user-select: none;
    pointer-events: none;
}


/* Sizes use both viewport width and viewport height. */

.moon-object-crescent {
    --moon-size: clamp(230px, min(50vw, 60vh), 680px);
}

.moon-object-full,
.moon-object-half {
    --moon-size: clamp(86px, min(15vw, 18vh), 190px);
}

.moon-object-label {
    position: absolute;
    color: var(--gold-soft, #e8d4a0);
    font-family: var(--font-body, sans-serif);
    font-size: clamp(.72rem, 1.05vw, .95rem);
    letter-spacing: .08em;
    text-transform: uppercase;
    white-space: nowrap;
    text-shadow: 0 2px 18px rgba(0, 0, 0, .65);
    transition: opacity .45s ease;
}

.moon-object-label-full {
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
}
.moon-object-label-crescent {
    left: 0;
    right: 0;
    margin: 0 auto;
    bottom: -10px;
    display: inline-table;
}

.moon-object-label-half {
    right: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
}


/* ---------- Stage 0: three moons, no cropping ---------- */

.moon-phase-scroll-section[data-stage="0"] .moon-orbit-scene {
    pointer-events: auto;
}

.moon-phase-scroll-section[data-stage="0"] .moon-object {
    top: 50%;
    opacity: 1;
    filter: none;
}

.moon-phase-scroll-section[data-stage="0"] .moon-object-full {
    left: 15px;
    z-index: 3;
    transform: translate(0, -50%) scale(1);
}

.moon-phase-scroll-section[data-stage="0"] .moon-object-crescent {
    left: 50%;
    z-index: 5;
    transform: translate(-50%, -50%) scale(1);
}

.moon-phase-scroll-section[data-stage="0"] .moon-object-half {
    right: 15px;
    left: auto;
    z-index: 3;
    transform: translate(0, -50%) scale(1);
}


/* ---------- Orbit mode ---------- */

.moon-phase-scroll-section:not([data-stage="0"]) .moon-phase-overview {
    padding: 0;
}

.moon-phase-scroll-section:not([data-stage="0"]) .moon-orbit-scene {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    flex: none;
    pointer-events: auto;
}

.moon-phase-scroll-section:not([data-stage="0"]) .moon-object {
    left: var(--orbit-center-x, 73%);
    right: auto;
    top: var(--orbit-center-y, 52%);
}

.moon-phase-scroll-section:not([data-stage="0"]) .moon-object-label {
    opacity: 0;
    visibility: hidden;
}

.moon-object[data-slot="active"] {
    z-index: 6;
    opacity: 1;
    filter: blur(0) brightness(1);
    transform: translate(-50%, -50%) translate3d(0, 0, 210px) scale(var(--active-scale, 1));
}

.moon-object[data-slot="rear-right"] {
    z-index: 3;
    opacity: .14;
    filter: blur(10px) brightness(.5);
    transform: translate(-50%, -50%) translate3d(var(--rear-x, 340px), 26px, -500px) rotateY(-34deg) scale(.34);
}

.moon-object[data-slot="rear-left"] {
    z-index: 3;
    opacity: .14;
    filter: blur(10px) brightness(.52);
    transform: translate(-50%, -50%) translate3d(calc(var(--rear-x, 340px) * -1), 10px, -470px) rotateY(33deg) scale(.36);
}

.moon-object[data-slot="rear-centre"] {
    z-index: 1;
    opacity: .1;
    filter: blur(15px) brightness(.36);
    transform: translate(-50%, -50%) translate3d(0, 42px, -720px) scale(.2);
}


/* Active orbit sizes are height-aware and retain image aspect ratio. */

.moon-phase-scroll-section:not([data-stage="0"]) .moon-object-crescent {
    --moon-size: clamp(260px, min(43vw, 68vh), 610px);
}

.moon-phase-scroll-section:not([data-stage="0"]) .moon-object-half,
.moon-phase-scroll-section:not([data-stage="0"]) .moon-object-full {
    --moon-size: clamp(240px, min(39vw, 62vh), 590px);
}


/* =========================================================
   ANIMATED ENTRY ARROW
   ========================================================= */

.moon-enter-arrow {
    position: relative;
    z-index: 10;
    flex: 0 0 auto;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    border: 0;
    padding: 0;
    background: transparent;
    color: rgba(248, 231, 201, .78);
    font: inherit;
    font-size: .5rem;
    letter-spacing: .17em;
    text-transform: uppercase;
    cursor: pointer;
    transition: opacity .35s ease, transform .35s ease, visibility .35s linear;
}

.moon-enter-arrow i {
    position: relative;
    display: block;
    width: 18px;
    height: 28px;
}

.moon-enter-arrow i::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 0;
    width: 1px;
    height: 24px;
    background: rgba(248, 231, 201, .72);
    transform: translateX(-50%);
    animation: moonArrowLine 1.55s ease-in-out infinite;
}

.moon-enter-arrow i::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 1px;
    width: 9px;
    height: 9px;
    border-right: 1px solid rgba(248, 231, 201, .9);
    border-bottom: 1px solid rgba(248, 231, 201, .9);
    transform: translateX(-50%) rotate(45deg);
    animation: moonArrowHead 1.55s ease-in-out infinite;
}

@keyframes moonArrowLine {
    0%,
    100% {
        opacity: .3;
        transform: translate(-50%, -5px) scaleY(.7);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, 4px) scaleY(1);
    }
}

@keyframes moonArrowHead {
    0%,
    100% {
        opacity: .35;
        transform: translate(-50%, -4px) rotate(45deg);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, 4px) rotate(45deg);
    }
}

.moon-phase-scroll-section:not([data-stage="0"]) .moon-enter-arrow {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(14px);
}


/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 1100px) {
    .moon-phase-content {
        width: min(46vw, 535px);
    }
    .moon-phase-scroll-section:not([data-stage="0"]) .moon-object {
        --orbit-center-x: 76%;
        --rear-x: min(27vw, 280px);
    }
}

@media (max-width: 767.98px) {
    .moon-phase-sticky {
        min-height: 540px;
    }
    .moon-container {
        width: min(calc(100% - 28px), 1440px);
    }
    .moon-phase-overview {
        gap: 10px;
        padding: clamp(72px, 8vh, 82px) 0 clamp(15px, 2.5vh, 30px);
    }
    .moon-phase-intro-copy {
        width: min(calc(100% - 28px), 620px);
    }
    .moon-phase-intro-copy h2 {
        font-size: clamp(1.45rem, min(6.7vw, 4.6vh), 2.5rem);
    }
    .moon-phase-intro-text {
        max-width: 94%;
        /*font-size: clamp(.78rem, min(3.5vw, 1.8vh), .92rem);
        line-height: 1.55;*/
    }
    .moon-object-crescent {
        --moon-size: clamp(190px, min(58vw, 48vh), 410px);
    }
    .moon-object-full,
    .moon-object-half {
        --moon-size: clamp(62px, min(18vw, 14vh), 120px);
    }
    .moon-object-label {
        font-size: clamp(.58rem, 2.5vw, .74rem);
        letter-spacing: .04em;
    }
    .moon-object-label-full {
        /*left: calc(100% + 7px);*/
		left: 20%;
		top: calc(100% + 15px);
    }
    .moon-object-label-half {
        /*right: calc(100% + 7px);*/
		right: 20%;
		top: calc(100% + 15px);
    }
    .moon-phase-scroll-section[data-stage="0"] .moon-object-full {
        left: 15px;
    }
    .moon-phase-scroll-section[data-stage="0"] .moon-object-half {
        right: 15px;
    }
    .moon-phase-detail .moon-container {
        align-items: flex-end;
        padding-bottom: 3.4rem;
    }
    .moon-phase-content {
        width: 100%;
        padding: 1rem;
        border: 1px solid rgba(248, 231, 201, .13);
        background: linear-gradient(135deg, rgba(6, 7, 28, .72), rgba(6, 7, 28, .42));
        backdrop-filter: blur(9px);
    }
    .moon-phase-content h2 {
        margin-bottom: .8rem;
        font-size: clamp(2.2rem, 10.5vw, 4rem);
    }
    .moon-phase-content>p:not(.nour-kicker) {
        margin-bottom: 1rem;
        font-size: .86rem;
        line-height: 1.55;
    }
    .moon-phase-scroll-section:not([data-stage="0"]) .moon-object {
        --orbit-center-x: 50%;
        --orbit-center-y: 31%;
        --rear-x: min(36vw, 175px);
    }
    .moon-phase-scroll-section:not([data-stage="0"]) .moon-object-crescent {
        --moon-size: clamp(220px, min(78vw, 52vh), 500px);
    }
    .moon-phase-scroll-section:not([data-stage="0"]) .moon-object-half,
    .moon-phase-scroll-section:not([data-stage="0"]) .moon-object-full {
        --moon-size: clamp(205px, min(69vw, 47vh), 450px);
    }
    .moon-object[data-slot="active"] {
        --active-scale: .9;
        transform: translate(-50%, -50%) translate3d(0, 0, 150px) scale(var(--active-scale));
    }
    .moon-object[data-slot="rear-right"] {
        transform: translate(-50%, -50%) translate3d(var(--rear-x), 16px, -390px) rotateY(-33deg) scale(.26);
    }
    .moon-object[data-slot="rear-left"] {
        transform: translate(-50%, -50%) translate3d(calc(var(--rear-x) * -1), 10px, -360px) rotateY(32deg) scale(.28);
    }
}

@media (max-height: 680px) and (min-width: 768px) {
    .moon-phase-overview {
        padding-top: 58px;
        padding-bottom: 34px;
        gap: 8px;
    }
    .moon-phase-intro-copy h2 {
        font-size: clamp(1.6rem, 4vh, 2.5rem);
    }
    .moon-phase-intro-text {
        font-size: .84rem;
        /*line-height: 1.45;*/
    }
    .moon-object-crescent {
        --moon-size: clamp(170px, 38vh, 300px);
    }
    .moon-object-full,
    .moon-object-half {
        --moon-size: clamp(70px, 15vh, 115px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .moonj-star,
    .moon-enter-arrow i::before,
    .moon-enter-arrow i::after {
        animation: none;
    }
    .moon-object,
    .moon-phase-panel,
    .moon-phase-content,
    .moon-phase-intro-copy,
    .moon-orbit-stage {
        transition-duration: .01ms !important;
    }
}