/* =====================================================================
   CMI LifeTech — Sacred Ethereal Animations & Transitions
   ===================================================================== */

/* 🌌 Ambient Breathing & God Rays */
.divine-ambient {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: radial-gradient(circle at 50% -10%, #ffffff 0%, #fcfaf6 45%, #f4eae0 100%);
    animation: heavenBreathe 16s infinite alternate ease-in-out;
    transition: opacity 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}
body.dark-theme .divine-ambient {
    opacity: 0;
}

.god-rays-container {
    position: fixed;
    top: -20%;
    left: -10%;
    width: 120%;
    height: 140%;
    z-index: 1;
    pointer-events: none;
    opacity: 0.32;
    transform: rotate(-15deg);
    display: flex;
    gap: 6vw;
    transition: opacity 1.2s;
}
body.dark-theme .god-rays-container {
    opacity: 0.12;
}
.god-ray {
    width: 16vw;
    height: 100%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.25) 50%, transparent 100%);
    filter: blur(55px);
    animation: rayFlow 14s infinite ease-in-out alternate;
    mix-blend-mode: overlay;
}
.god-ray:nth-child(2) {
    width: 24vw;
    animation-delay: -5s;
    animation-duration: 20s;
    opacity: 0.7;
}
.god-ray:nth-child(3) {
    width: 12vw;
    animation-delay: -9s;
    animation-duration: 16s;
}

@keyframes rayFlow {
    0% { opacity: 0.15; transform: translateY(-4%) translateX(-2%); }
    100% { opacity: 0.55; transform: translateY(4%) translateX(2%); }
}

@keyframes heavenBreathe {
    0% { filter: brightness(0.98) contrast(1.01); }
    100% { filter: brightness(1.04) contrast(0.97); }
}

/* ── 2. Chapel Processional Entry & Transitions ──────────── */
/* JS toggles class "on" (not "active"). Base panel must NOT keep opacity:0
   after the entry animation, or the chapel vanishes ~0.4s after tab switch. */
.pn {
    display: none;
    min-height: 60vh;
}
.pn.on,
.pn.active {
    display: block;
    opacity: 1;
    transform: none;
    animation: chapelAscent 0.52s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ── 3. The 6 Sacred Rites Ceremonial Motions ──────────────── */

/* Rite 1: Chapel Processional Ascension */
@keyframes chapelAscent {
    from {
        opacity: 0.32;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeUpInEpic {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Rite 2: Scribe's Inscriptional Stroke */
@keyframes scribeStroke {
    from {
        transform: scaleX(0);
        opacity: 0;
    }
    to {
        transform: scaleX(1);
        opacity: 1;
    }
}
.scribe-stroke {
    transform-origin: left center;
    animation: scribeStroke 0.65s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Rite 3: Consecration of Daily Manna Bloom */
@keyframes mannaBloom {
    0% {
        transform: scale(0.985);
        box-shadow: 0 0 0 rgba(226, 186, 77, 0);
    }
    45% {
        transform: scale(1.008);
        box-shadow: 0 0 65px rgba(226, 186, 77, 0.55), 0 25px 60px rgba(0, 0, 0, 0.6);
    }
    100% {
        transform: scale(1);
        box-shadow: var(--shadow-holy), 0 0 35px var(--holy-gold-glow);
    }
}
.manna-card.consecrated {
    animation: mannaBloom 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Rite 4: Sacred Candle Flame Ignition */
@keyframes candleIgnite {
    0% {
        transform: translateX(-50%) scale(0) translateY(8px);
        opacity: 0;
        filter: blur(4px);
    }
    55% {
        transform: translateX(-50%) scale(1.35) translateY(-6px);
        opacity: 1;
        filter: drop-shadow(0 0 28px rgba(255, 200, 50, 1)) drop-shadow(0 0 10px #ffffff);
    }
    100% {
        transform: translateX(-50%) scale(1) translateY(0);
        opacity: 1;
        filter: drop-shadow(0 0 15px rgba(255, 170, 0, 0.85));
    }
}
.altar-candle.lit .candle-flame {
    animation: candleIgnite 0.75s cubic-bezier(0.16, 1, 0.3, 1) forwards, flameFlicker 3s infinite ease-in-out 0.75s;
}

/* Rite 5: Seeker Anchor Cosmic Wave */
@keyframes anchorPulse {
    0% {
        transform: scale(0.85);
        opacity: 0.95;
    }
    60% {
        transform: scale(2.2);
        opacity: 0.45;
        box-shadow: 0 0 30px var(--holy-gold-bright);
    }
    100% {
        transform: scale(3.4);
        opacity: 0;
    }
}
.anchor-wave {
    position: absolute;
    border-radius: var(--radius-full);
    border: 2px solid var(--holy-gold-bright);
    pointer-events: none;
    animation: anchorPulse 1.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Rite 6: Living Covenant Tree Leaf Sprout */
@keyframes leafUnfurl {
    0% {
        transform: scale(0) rotate(-35deg);
        opacity: 0;
    }
    65% {
        transform: scale(1.22) rotate(6deg);
        opacity: 1;
        filter: drop-shadow(0 0 14px var(--holy-gold-bright));
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}
.tree-leaf-fresh {
    animation: leafUnfurl 0.85s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Candle Flame Dynamic Physics */
@keyframes flameFlicker {
    0% {
        transform: translateX(-50%) scale(1) rotate(-1deg);
        filter: drop-shadow(0 0 12px rgba(255, 170, 0, 0.8)) drop-shadow(0 -5px 15px rgba(255, 90, 0, 0.5));
    }
    25% {
        transform: translateX(-50%) scale(1.05, 0.95) rotate(1.5deg);
        filter: drop-shadow(0 0 16px rgba(255, 200, 50, 0.9)) drop-shadow(0 -7px 20px rgba(255, 110, 20, 0.6));
    }
    50% {
        transform: translateX(-50%) scale(0.96, 1.04) rotate(-0.5deg);
        filter: drop-shadow(0 0 10px rgba(255, 160, 10, 0.7)) drop-shadow(0 -4px 12px rgba(255, 80, 0, 0.4));
    }
    75% {
        transform: translateX(-50%) scale(1.03, 0.98) rotate(1deg);
        filter: drop-shadow(0 0 18px rgba(255, 210, 60, 0.95)) drop-shadow(0 -8px 22px rgba(255, 120, 30, 0.65));
    }
    100% {
        transform: translateX(-50%) scale(1) rotate(-1deg);
        filter: drop-shadow(0 0 12px rgba(255, 170, 0, 0.8)) drop-shadow(0 -5px 15px rgba(255, 90, 0, 0.5));
    }
}

/* 3D Card Folio Turn */
.flip-card {
    perspective: 1400px;
}
.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.75s cubic-bezier(0.16, 1, 0.3, 1);
    transform-style: preserve-3d;
}
.flip-card.flipped .flip-card-inner {
    transform: rotateY(180deg);
}
.flip-card-front, .flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: var(--radius-lg);
}
.flip-card-back {
    transform: rotateY(180deg);
}

/* Accessibility: Honor prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .pn.on,
    .pn.active {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
        filter: none !important;
    }
    .divine-ambient,
    .god-ray,
    .cathedral-film-grain {
        animation: none !important;
    }
    .flip-card-inner {
        transition: none !important;
    }
    .mandala-svg {
        animation: none !important;
    }
}

