/*
 * Terai Roots — Advanced Visual Effects
 * effects.css v1.0
 *
 * 1.  SVG Gooey Filter (inline SVG in header.php)
 * 2.  Gradient Mesh Backgrounds
 * 3.  Glassmorphism
 * 4.  Neumorphism
 * 5.  Animated Gradient Borders
 * 6.  Scroll-Driven Animations (CSS native + JS fallback)
 * 7.  SVG Morphing Blob
 * 8.  SVG Botanical Stroke Draw
 * 9.  Hero Particle Canvas
 * 10. Wave Section Dividers
 * 11. Micro-interaction Enhancements
 * 12. Reading Progress
 */

/* ============================================================
   1. CSS EFFECT TOKENS
   ============================================================ */
:root {
    /* Glassmorphism */
    --glass-bg:      rgba(255, 255, 255, 0.18);
    --glass-bg-dark: rgba(5, 46, 22, 0.40);
    --glass-border:  rgba(255, 255, 255, 0.35);
    --glass-blur:    20px;

    /* Neumorphism (light surface) */
    --neu-bg:        #eef7f0;
    --neu-shadow-out: 8px 8px 20px rgba(180, 210, 185, 0.5), -8px -8px 20px rgba(255, 255, 255, 0.9);
    --neu-shadow-in:  inset 4px 4px 10px rgba(180, 210, 185, 0.4), inset -4px -4px 10px rgba(255, 255, 255, 0.8);

    /* Gradient border animation */
    --grad-border-size: 300%;

    /* Mesh gradient colors */
    --mesh-green:  rgba(22,  163, 74,  0.12);
    --mesh-amber:  rgba(217, 119,  6,  0.10);
    --mesh-forest: rgba(20,  83,  45,  0.08);
    --mesh-warm:   rgba(234, 88,  12,  0.07);
}

/* ============================================================
   2. GRADIENT MESH BACKGROUNDS
   ============================================================ */
.mesh-bg {
    background:
        radial-gradient(ellipse 60% 60% at 15% 15%, var(--mesh-green), transparent),
        radial-gradient(ellipse 50% 50% at 85% 85%, var(--mesh-amber), transparent),
        radial-gradient(ellipse 40% 40% at 65% 20%, var(--mesh-forest), transparent),
        radial-gradient(ellipse 45% 45% at 30% 80%, var(--mesh-warm),   transparent),
        var(--bg-body);
}

.mesh-bg-dark {
    background:
        radial-gradient(ellipse 55% 55% at 10% 20%, rgba(22,163,74,0.20), transparent),
        radial-gradient(ellipse 45% 45% at 90% 80%, rgba(217,119,6,0.15), transparent),
        radial-gradient(ellipse 35% 35% at 70% 15%, rgba(20,83,45,0.15),  transparent),
        var(--bg-dark);
}

.mesh-bg-warm {
    background:
        radial-gradient(ellipse 60% 50% at 20% 30%, rgba(217,119,6,0.10), transparent),
        radial-gradient(ellipse 50% 60% at 80% 70%, rgba(22,163,74,0.08),  transparent),
        radial-gradient(ellipse 40% 40% at 50% 10%, rgba(234,88,12,0.06),  transparent),
        var(--bg-warm);
}

/* Animated mesh (slow shift) */
.mesh-bg-animated {
    background:
        radial-gradient(ellipse 60% 60% at 15% 15%, var(--mesh-green), transparent),
        radial-gradient(ellipse 50% 50% at 85% 85%, var(--mesh-amber), transparent),
        radial-gradient(ellipse 40% 40% at 65% 20%, var(--mesh-forest), transparent),
        var(--bg-body);
    animation: meshShift 12s ease-in-out infinite alternate;
}

@keyframes meshShift {
    0%   { background-position: 0% 0%,   100% 100%, 65% 20%; }
    50%  { background-position: 20% 20%, 70% 70%,  80% 10%; }
    100% { background-position: 5% 30%,  90% 80%,  55% 30%; }
}

/* ============================================================
   3. GLASSMORPHISM
   ============================================================ */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur)) saturate(180%);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255,255,255,0.5);
}

.glass-dark {
    background: var(--glass-bg-dark);
    backdrop-filter: blur(var(--glass-blur)) saturate(160%);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.10);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.24);
}

.glass-card {
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 4px 24px rgba(22, 163, 74, 0.08), inset 0 1px 0 rgba(255,255,255,0.9);
}

/* ============================================================
   4. NEUMORPHISM
   ============================================================ */
.neu {
    background: var(--neu-bg);
    border-radius: var(--radius-xl);
    box-shadow: var(--neu-shadow-out);
    border: none;
}

.neu:hover {
    box-shadow: var(--neu-shadow-in);
}

.neu-stat {
    background: #eef7f0;
    border-radius: 20px;
    box-shadow: var(--neu-shadow-out);
    transition: box-shadow var(--transition-base);
}

.neu-stat:hover {
    box-shadow: 4px 4px 12px rgba(180,210,185,0.6), -4px -4px 12px rgba(255,255,255,0.95);
}

/* ============================================================
   5. ANIMATED GRADIENT BORDERS
   ============================================================ */
.grad-border {
    position: relative;
    z-index: 0;
}

.grad-border::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    padding: 2px;
    background: linear-gradient(
        90deg,
        var(--color-primary),
        var(--color-secondary),
        var(--color-accent),
        var(--color-secondary),
        var(--color-primary)
    );
    background-size: var(--grad-border-size) 100%;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: gradBorderSpin 4s linear infinite;
    z-index: -1;
}

@keyframes gradBorderSpin {
    0%   { background-position: 0%   50%; }
    100% { background-position: 300% 50%; }
}

/* Button with animated border on hover */
.btn-grad-hover {
    position: relative;
    overflow: hidden;
    z-index: 0;
}

.btn-grad-hover::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary), var(--color-accent), var(--color-primary));
    background-size: 300% 100%;
    opacity: 0;
    transition: opacity 0.3s;
    animation: gradShift 3s linear infinite;
    z-index: -1;
}

.btn-grad-hover:hover::after { opacity: 1; }

@keyframes gradShift {
    0%   { background-position: 0%   center; }
    100% { background-position: 300% center; }
}

/* ============================================================
   6. SCROLL-DRIVEN ANIMATIONS (CSS native + IntersectionObserver)
   ============================================================ */

/* Base reveal — hidden until .revealed is added by JS */
.reveal {
    opacity: 0;
    transform: translateY(28px);
    transition: opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1),
                transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Directional variants */
.reveal-left  { transform: translateX(-36px); }
.reveal-right { transform: translateX(36px);  }
.reveal-scale { transform: scale(0.92);       }

.reveal-left.revealed,
.reveal-right.revealed { transform: translateX(0); }
.reveal-scale.revealed { transform: scale(1); }

/* Stagger delays */
.animate-delay-1 { transition-delay: 0.10s; }
.animate-delay-2 { transition-delay: 0.20s; }
.animate-delay-3 { transition-delay: 0.30s; }
.animate-delay-4 { transition-delay: 0.40s; }
.animate-delay-5 { transition-delay: 0.50s; }

/* CSS Scroll-driven animation — progressive enhancement for modern browsers */
@supports (animation-timeline: scroll()) {
    .scroll-fade-up {
        animation: scrollRevealUp linear both;
        animation-timeline: view();
        animation-range: entry 0% entry 60%;
    }

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

    .scroll-scale {
        animation: scrollScaleIn linear both;
        animation-timeline: view();
        animation-range: entry 0% entry 60%;
    }

    @keyframes scrollScaleIn {
        from { opacity: 0; transform: scale(0.90); }
        to   { opacity: 1; transform: scale(1);    }
    }
}

/* Reading progress bar */
#reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary), var(--color-accent));
    z-index: 9999;
    transition: width 0.1s linear;
    border-radius: 0 2px 2px 0;
}

/* ============================================================
   7. SVG MORPHING BLOB
   ============================================================ */
.morphing-blob {
    position: absolute;
    pointer-events: none;
    opacity: 0.18;
    z-index: 0;
}

.morphing-blob svg {
    width: 100%;
    height: 100%;
    filter: blur(2px);
}

.blob-path {
    fill: var(--color-primary);
}

.blob-path-amber {
    fill: var(--color-secondary);
}

/* ============================================================
   8. SVG BOTANICAL STROKE DRAW
   ============================================================ */
.botanical-svg {
    position: absolute;
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.5s ease 0.3s;
}

.botanical-svg.visible { opacity: 1; }

.botanical-svg .draw-path {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    animation: strokeDraw 3s cubic-bezier(0.5, 0, 0.5, 1) forwards;
    animation-play-state: paused;
}

.botanical-svg.visible .draw-path {
    animation-play-state: running;
}

.botanical-svg .draw-path:nth-child(2) { animation-delay: 0.4s; }
.botanical-svg .draw-path:nth-child(3) { animation-delay: 0.8s; }
.botanical-svg .draw-path:nth-child(4) { animation-delay: 1.2s; }
.botanical-svg .draw-path:nth-child(5) { animation-delay: 1.6s; }
.botanical-svg .draw-path:nth-child(6) { animation-delay: 2.0s; }

@keyframes strokeDraw {
    to { stroke-dashoffset: 0; }
}

/* ============================================================
   9. HERO PARTICLE CANVAS
   ============================================================ */
.hero-particles {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    opacity: 0.55;
}

/* ============================================================
   10. WAVE SECTION DIVIDERS
   ============================================================ */
.wave-divider {
    line-height: 0;
    overflow: hidden;
    position: relative;
    z-index: 2;
}

.wave-divider svg {
    display: block;
    width: 100%;
}

.wave-divider-top  { margin-bottom: -1px; }
.wave-divider-bot  { margin-top: -1px;    }

/* ============================================================
   11. MICRO-INTERACTION ENHANCEMENTS
   ============================================================ */

/* Magnetic hover for buttons */
.btn {
    will-change: transform;
}

/* Card image zoom on hover */
.card-img-zoom {
    overflow: hidden;
    border-radius: var(--radius-lg);
}

.card-img-zoom img {
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform-origin: center;
}

.card-img-zoom:hover img {
    transform: scale(1.08);
}

/* Shine sweep on hover */
.shine-hover {
    position: relative;
    overflow: hidden;
}

.shine-hover::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(
        105deg,
        transparent 40%,
        rgba(255, 255, 255, 0.25) 50%,
        transparent 60%
    );
    transition: left 0.5s ease;
    pointer-events: none;
}

.shine-hover:hover::after {
    left: 150%;
}

/* Tag pill float */
.tag-link {
    transition: transform var(--transition-fast), background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}
.tag-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(22,163,74,0.2);
}

/* Feature icon pulse */
.feature-icon-pulse {
    animation: iconPulse 3s ease-in-out infinite;
}

@keyframes iconPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.3); }
    50%       { box-shadow: 0 0 0 12px rgba(22, 163, 74, 0); }
}

/* Floating badge animation */
.float-badge {
    animation: floatBadge 4s ease-in-out infinite;
}

@keyframes floatBadge {
    0%, 100% { transform: translateY(0px);  }
    50%       { transform: translateY(-8px); }
}

/* Counter animation trigger */
.count-up { display: inline-block; }

/* ============================================================
   12. HERO ENTRY ANIMATIONS
   ============================================================ */
@keyframes heroFadeUp {
    from { opacity: 0; transform: translateY(40px); }
    to   { opacity: 1; transform: translateY(0);    }
}

@keyframes heroFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes heroSlideRight {
    from { opacity: 0; transform: translateX(-30px); }
    to   { opacity: 1; transform: translateX(0);     }
}

.hero-eyebrow  { animation: heroFadeUp   0.8s cubic-bezier(0.22,1,0.36,1) 0.1s both; }
.hero h1       { animation: heroFadeUp   0.9s cubic-bezier(0.22,1,0.36,1) 0.25s both; }
.hero > .container > .hero-content > p
               { animation: heroFadeUp   0.9s cubic-bezier(0.22,1,0.36,1) 0.4s both; }
.hero-actions  { animation: heroFadeUp   0.9s cubic-bezier(0.22,1,0.36,1) 0.55s both; }
.hero-scroll-hint
               { animation: heroFadeIn   1s   ease                        0.8s both; }

/* Scroll bounce hint */
@keyframes scrollBounce {
    0%, 100% { transform: translateX(-50%) translateY(0);  }
    50%       { transform: translateX(-50%) translateY(8px); }
}

/* ============================================================
   13. SVG MASKING REVEAL (image wipe in on scroll)
   ============================================================ */
.svg-mask-reveal {
    clip-path: inset(0 100% 0 0);
    transition: clip-path 1.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.svg-mask-reveal.revealed {
    clip-path: inset(0 0% 0 0);
}

/* ============================================================
   14. GRADIENT TEXT
   ============================================================ */
.gradient-text {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gradient-text-warm {
    background: linear-gradient(135deg, var(--color-secondary), var(--color-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============================================================
   15. HOVER CARD FLOAT
   ============================================================ */
.card-float {
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.35s ease;
}

.card-float:hover {
    transform: translateY(-8px) rotate(-0.3deg);
    box-shadow: 0 20px 48px rgba(22, 163, 74, 0.16);
}


/* ============================================================
   17. SVG SECTION BACKGROUND HELPERS
   Sections that embed inline <pattern> SVGs need overflow:hidden
   so clipped patterns don't bleed outside the section boundary.
   ============================================================ */
.section-has-pattern {
    position: relative;
    overflow: hidden;
}

/* ============================================================
   18. MISSION COMPACT LIST (homepage "What We Do" fix)
   Ensures the 2-col list collapses to 1-col on small screens
   so items remain readable without the old 3×2 card height.
   ============================================================ */
@media (max-width: 640px) {
    .mission-list-2col {
        grid-template-columns: 1fr !important;
    }
}

/* ============================================================
   19. FOUR PILLARS — responsive grid breakpoints
   4-col → 2-col at tablet → 1-col at mobile
   ============================================================ */
@media (max-width: 1024px) {
    /* Tablet: 2×2 grid */
    section[aria-label="Our four pillars"] > .container > div[style*="grid-template-columns:repeat(4"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}
@media (max-width: 560px) {
    /* Mobile: single column */
    section[aria-label="Our four pillars"] > .container > div[style*="grid-template-columns:repeat(4"] {
        grid-template-columns: 1fr !important;
    }
}
