/* ===================================================================
   CHAKULA SMART — Futuristic FX (glassmorphism, 3D, motion)
   =================================================================== */

:root {
    --glass-bg: rgba(255, 255, 255, 0.12);
    --glass-bg-strong: rgba(255, 255, 255, 0.22);
    --glass-border: rgba(255, 255, 255, 0.35);
    --glass-blur: 18px;
    --glass-blur-heavy: 28px;
    --glow-green: rgba(64, 145, 108, 0.45);
    --glow-gold: rgba(232, 184, 74, 0.35);
    --fx-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --fx-ease-spring: cubic-bezier(0.34, 1.45, 0.64, 1);
}

/* ---------- Animated mesh background (app pages) ---------- */
body.fx-app:not(.dash-user-app),
body:not(.landing-page):not(.dash-user-app) {
    position: relative;
    isolation: isolate;
}

body.auth-page::before,
body.auth-page::after {
    display: none;
}

body.fx-app:not(.dash-user-app)::before,
body:not(.landing-page):not(.auth-page):not(.dash-user-app)::before {
    content: '';
    position: fixed;
    inset: -20%;
    z-index: -2;
    pointer-events: none;
    background:
        radial-gradient(ellipse 45% 35% at 15% 20%, rgba(64, 145, 108, 0.18), transparent 55%),
        radial-gradient(ellipse 40% 30% at 85% 10%, rgba(232, 184, 74, 0.12), transparent 50%),
        radial-gradient(ellipse 50% 40% at 70% 90%, rgba(45, 106, 79, 0.14), transparent 55%),
        radial-gradient(ellipse 35% 25% at 5% 80%, rgba(27, 67, 50, 0.1), transparent 50%);
    animation: fxMeshDrift 22s ease-in-out infinite alternate;
}

body.fx-app:not(.dash-user-app)::after,
body:not(.landing-page):not(.auth-page):not(.dash-user-app)::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: 0.4;
    background-image:
        linear-gradient(rgba(45, 106, 79, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(45, 106, 79, 0.03) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse 80% 70% at 50% 40%, black 20%, transparent 75%);
}

@keyframes fxMeshDrift {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(-2%, 3%) scale(1.05); }
}

/* ---------- Landing hero atmosphere (legacy hero only) ---------- */
body.landing-page header.hero:not(.hero-lux)::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 30%, rgba(64, 145, 108, 0.35) 0%, transparent 45%),
        radial-gradient(circle at 80% 20%, rgba(255, 159, 28, 0.2) 0%, transparent 40%),
        radial-gradient(circle at 50% 90%, rgba(27, 67, 50, 0.5) 0%, transparent 50%);
    animation: fxHeroPulse 8s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 0;
}

@keyframes fxHeroPulse {
    0% { opacity: 0.7; transform: scale(1); }
    100% { opacity: 1; transform: scale(1.08); }
}

/* Gentle float — avoid 3D rotate on <img> (breaks in Firefox/Edge) */
body.landing-page .logo-wrapper {
    animation: fxLogoFloat 5s ease-in-out infinite;
}

@keyframes fxLogoFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

body.landing-page .logo {
    filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.45)) drop-shadow(0 0 24px rgba(64, 145, 108, 0.35));
    -webkit-filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.45)) drop-shadow(0 0 24px rgba(64, 145, 108, 0.35));
}

/* ---------- Glass panels ---------- */
.glass-panel,
.fx-glass {
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid rgba(255, 255, 255, 0.55);
    box-shadow:
        0 8px 32px rgba(15, 31, 23, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

body.landing-page .chakula-nav {
    backdrop-filter: blur(var(--glass-blur-heavy)) saturate(1.35);
    -webkit-backdrop-filter: blur(var(--glass-blur-heavy)) saturate(1.35);
}

/* ---------- 3D tilt cards ---------- */
.fx-tilt {
    transform-style: preserve-3d;
    transform: perspective(900px) rotateX(var(--fx-rx, 0deg)) rotateY(var(--fx-ry, 0deg)) translateZ(0);
    transition: transform 0.35s var(--fx-ease-out), box-shadow 0.35s var(--fx-ease-out);
    will-change: transform;
}

.fx-tilt:hover {
    transform: perspective(900px) rotateX(var(--fx-rx, 0deg)) rotateY(var(--fx-ry, 0deg)) translateZ(12px);
}

.fx-tilt-inner {
    transform: translateZ(24px);
}

/* ---------- Scroll reveal ---------- */
.fx-reveal {
    opacity: 0;
    transform: translateY(36px) scale(0.96);
    filter: blur(6px);
    transition:
        opacity 0.8s var(--fx-ease-out),
        transform 0.8s var(--fx-ease-out),
        filter 0.8s var(--fx-ease-out);
}

.fx-reveal.visible,
.reveal.fx-reveal.visible,
.reveal.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
}

/* Stagger children */
.fx-stagger > .fx-reveal:nth-child(1) { transition-delay: 0.05s; }
.fx-stagger > .fx-reveal:nth-child(2) { transition-delay: 0.12s; }
.fx-stagger > .fx-reveal:nth-child(3) { transition-delay: 0.19s; }
.fx-stagger > .fx-reveal:nth-child(4) { transition-delay: 0.26s; }

/* ---------- App: glass navbar ---------- */
.navbar-app.fx-glass-nav,
body.fx-app .navbar-app {
    background: linear-gradient(
        135deg,
        rgba(13, 40, 24, 0.88) 0%,
        rgba(26, 92, 58, 0.82) 50%,
        rgba(27, 67, 50, 0.88) 100%
    ) !important;
    backdrop-filter: blur(14px) saturate(1.3);
    -webkit-backdrop-filter: blur(14px) saturate(1.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12) !important;
    box-shadow:
        0 8px 32px rgba(13, 40, 24, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.navbar-app .brand-mark {
    background: rgba(255, 255, 255, 0.15) !important;
    backdrop-filter: blur(8px);
    box-shadow: 0 0 20px var(--glow-green);
    transition: transform 0.3s var(--fx-ease-spring), box-shadow 0.3s ease;
}

.navbar-app .navbar-brand:hover .brand-mark {
    transform: scale(1.08) rotate(-5deg);
    box-shadow: 0 0 28px var(--glow-green);
}

/* ---------- App: glass stat & cards ---------- */
body.fx-app .stat-card,
body:not(.landing-page) .stat-card.fx-glass-stat {
    position: relative;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid rgba(255, 255, 255, 0.75);
    box-shadow:
        0 10px 40px rgba(15, 31, 23, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.95),
        0 0 0 1px rgba(45, 106, 79, 0.06);
}

body.fx-app .stat-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.4) 0%, transparent 50%);
    pointer-events: none;
    opacity: 0.6;
}

body.fx-app .stat-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow:
        0 20px 50px rgba(45, 106, 79, 0.15),
        0 0 40px rgba(64, 145, 108, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 1);
    border-color: rgba(64, 145, 108, 0.25);
}

body.fx-app .card,
body:not(.landing-page) .card.fx-glass-card {
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow:
        0 12px 36px rgba(15, 31, 23, 0.07),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

body.fx-app .card:hover {
    transform: translateY(-6px);
    box-shadow:
        0 24px 48px rgba(15, 31, 23, 0.1),
        0 0 32px rgba(64, 145, 108, 0.08);
}

/* ---------- Landing: feature / step / testimonial glass 3D ---------- */
body.landing-page .features .card,
body.landing-page .step-card,
body.landing-page .testimonial-card {
    background: rgba(255, 255, 255, 0.75) !important;
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid rgba(255, 255, 255, 0.65) !important;
    transform-style: preserve-3d;
    transition:
        transform 0.45s var(--fx-ease-out),
        box-shadow 0.45s var(--fx-ease-out),
        border-color 0.35s ease;
}

body.landing-page .features .card:hover,
body.landing-page .step-card:hover,
body.landing-page .testimonial-card:hover {
    transform: translateY(-12px) rotateX(4deg) scale(1.02);
    box-shadow:
        0 28px 56px rgba(45, 106, 79, 0.18),
        0 0 48px rgba(64, 145, 108, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 1);
}

body.landing-page .hero-stat {
    transform-style: preserve-3d;
}

body.landing-page .hero-stat:hover {
    transform: translateY(-14px) scale(1.06) rotateX(5deg);
    box-shadow:
        0 24px 48px rgba(0, 0, 0, 0.35),
        0 0 40px rgba(255, 255, 255, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

body.landing-page .about .container {
    background: rgba(255, 255, 255, 0.78) !important;
    backdrop-filter: blur(var(--glass-blur-heavy));
    -webkit-backdrop-filter: blur(var(--glass-blur-heavy));
    border: 1px solid rgba(255, 255, 255, 0.7) !important;
}

body.landing-page .about ul li {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    transition: transform 0.4s var(--fx-ease-spring), box-shadow 0.4s ease;
}

body.landing-page .about ul li:hover {
    transform: translateY(-8px) translateZ(20px) scale(1.03);
    box-shadow: 0 16px 32px rgba(45, 106, 79, 0.15);
}

/* ---------- Buttons: futuristic glow ---------- */
.btn.fx-glow,
body.landing-page .btn-primary,
body.fx-app .btn-primary {
    position: relative;
    overflow: hidden;
    transition: transform 0.25s var(--fx-ease-spring), box-shadow 0.35s ease;
}

.btn.fx-glow::before,
body.landing-page .btn-primary::before,
body.fx-app .btn-primary::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
    transform: translateX(-120%);
    transition: transform 0.6s ease;
}

.btn.fx-glow:hover::before,
body.landing-page .btn-primary:hover::before,
body.fx-app .btn-primary:hover::before {
    transform: translateX(120%);
}

body.landing-page .btn-primary:hover,
body.fx-app .btn-primary:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow:
        0 12px 28px rgba(45, 106, 79, 0.35),
        0 0 24px var(--glow-green);
}

/* ---------- Auth modals glass ---------- */
.auth-modal .auth-modal-content {
    background: rgba(255, 255, 255, 0.92) !important;
    backdrop-filter: blur(var(--glass-blur-heavy)) saturate(1.15);
    -webkit-backdrop-filter: blur(var(--glass-blur-heavy)) saturate(1.15);
    border: 1px solid rgba(255, 255, 255, 0.8) !important;
    box-shadow:
        0 32px 64px rgba(13, 40, 24, 0.25),
        0 0 60px rgba(64, 145, 108, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 1) !important;
}

/* ---------- Messages glass ---------- */
.messages-page .chat-shell {
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid rgba(255, 255, 255, 0.65);
    box-shadow: 0 20px 60px rgba(15, 31, 23, 0.12);
}

.messages-page .bubble-sent {
    box-shadow: 0 4px 20px rgba(45, 106, 79, 0.25);
}

/* ---------- Accordion / FAQ glass ---------- */
body.landing-page .accordion-item {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.6) !important;
    margin-bottom: 0.5rem;
    border-radius: var(--radius-md) !important;
    overflow: hidden;
}

/* ---------- Shimmer loading accent (optional utility) ---------- */
.fx-shimmer {
    position: relative;
    overflow: hidden;
}

.fx-shimmer::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        105deg,
        transparent 40%,
        rgba(255, 255, 255, 0.35) 50%,
        transparent 60%
    );
    animation: fxShimmer 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes fxShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ---------- Page header glow ---------- */
.fx-page-header {
    position: relative;
    padding-bottom: 0.5rem;
}

.fx-page-header::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 4rem;
    height: 3px;
    background: linear-gradient(90deg, var(--brand-600), var(--accent-500));
    border-radius: 3px;
    box-shadow: 0 0 12px var(--glow-green);
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .fx-reveal,
    .reveal {
        opacity: 1;
        transform: none;
        filter: none;
    }

    .fx-tilt {
        transform: none !important;
    }
}
