/* =====================================================================
   COMPETITIVE ANIMATIONS v1.0.0
   Advanced animations to surpass Elementor, Webflow, and premium sites
   
   Based on analysis of top blogs:
   - TechCrunch content-first layouts
   - TED Blog visual hierarchy
   - Apple-style micro-interactions
   - Stripe/Linear design systems
   
   PHILOSOPHY:
   - Subtle > Flashy
   - Performance > Effects
   - Accessibility > Trends
   ===================================================================== */

/* ========================================
   §1 — ADVANCED TEXT ANIMATIONS
   Text reveal, split text, typewriter
   ======================================== */

/* Clip-path text reveal */
.text-reveal {
    clip-path: inset(0 100% 0 0);
    animation: textRevealClip 0.8s var(--anim-ease-expo) forwards;
}

@keyframes textRevealClip {
    0% { clip-path: inset(0 100% 0 0); }
    100% { clip-path: inset(0 0 0 0); }
}

/* Underline draw animation */
.underline-draw {
    position: relative;
    display: inline-block;
}

.underline-draw::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 3px;
    background: var(--color-primary, #0066CC);
    border-radius: 2px;
    transition: width 0.6s var(--anim-ease-expo);
}

.underline-draw:hover::after,
.underline-draw.is-visible::after {
    width: 100%;
}

/* Text shimmer (PARITY MODE): no gradients.
   Use a solid primary accent so desktop/mobile/tablet match and avoid
   -webkit-text-fill-color=transparent issues across engines. */
.text-shimmer {
    background: none;
    color: var(--color-primary, #0066CC);
    -webkit-text-fill-color: currentColor;
    animation: none;
}

/* Letter stagger animation */
[data-anim="letter-stagger"] span {
    display: inline-block;
    opacity: 0;
    transform: translateY(20px);
}

[data-anim="letter-stagger"].anim-visible span {
    animation: letterReveal 0.5s var(--anim-ease-out-quint) forwards;
}

[data-anim="letter-stagger"].anim-visible span:nth-child(1) { animation-delay: 0ms; }
[data-anim="letter-stagger"].anim-visible span:nth-child(2) { animation-delay: 30ms; }
[data-anim="letter-stagger"].anim-visible span:nth-child(3) { animation-delay: 60ms; }
[data-anim="letter-stagger"].anim-visible span:nth-child(4) { animation-delay: 90ms; }
[data-anim="letter-stagger"].anim-visible span:nth-child(5) { animation-delay: 120ms; }
[data-anim="letter-stagger"].anim-visible span:nth-child(6) { animation-delay: 150ms; }
[data-anim="letter-stagger"].anim-visible span:nth-child(7) { animation-delay: 180ms; }
[data-anim="letter-stagger"].anim-visible span:nth-child(8) { animation-delay: 210ms; }

@keyframes letterReveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   §2 — PREMIUM CARD ANIMATIONS
   3D transforms with realistic depth
   ======================================== */

/* Card with 3D perspective tilt */
.card-3d {
    transform-style: preserve-3d;
    perspective: var(--transform-perspective);
    transition: transform 0.4s var(--anim-ease-smooth);
}

/* Parity: no cursor-driven tilt. Use the same lift interaction model everywhere. */
@media (hover: hover) and (pointer: fine) {
    .card-3d:hover {
        transform: translateY(-8px) scale(1.02);
    }
}

@media (hover: none), (pointer: coarse) {
    .card-3d:active,
    .card-3d:focus-within {
        transform: translateY(-4px) scale(1.01);
    }
}

/* Card shine effect (follows cursor) */
.card-shine {
    position: relative;
    overflow: hidden;
}

.card-shine::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 200%;
    height: 200%;
    /* Parity: no mouse-follow gradients. Use a subtle solid overlay. */
    background: rgba(255, 255, 255, 0.08);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

@media (hover: hover) and (pointer: fine) {
    .card-shine:hover::before {
        opacity: 1;
    }
}

@media (hover: none), (pointer: coarse) {
    .card-shine:active::before {
        opacity: 1;
    }
}

/* Glass morphism card */
.card-glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 
        0 4px 24px rgba(0, 0, 0, 0.08),
        inset 0 0 0 1px rgba(255, 255, 255, 0.1);
    transition: all 0.4s var(--anim-ease-smooth);
}

.card-glass:hover {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.12),
        inset 0 0 0 1px rgba(255, 255, 255, 0.15);
    transform: translateY(-4px);
}

/* Floating card with shadow dynamics */
.card-float {
    transition: 
        transform 0.5s var(--anim-ease-spring),
        box-shadow 0.5s var(--anim-ease-smooth);
    box-shadow: 
        0 4px 16px rgba(0, 0, 0, 0.08),
        0 2px 4px rgba(0, 0, 0, 0.04);
}

@media (hover: hover) and (pointer: fine) {
    .card-float:hover {
        transform: translateY(-12px);
        box-shadow: 
            0 24px 48px rgba(0, 0, 0, 0.12),
            0 12px 24px rgba(0, 0, 0, 0.08);
    }
}

@media (hover: none), (pointer: coarse) {
    .card-float:active,
    .card-float:focus-within {
        transform: translateY(-6px);
        box-shadow:
            0 18px 36px rgba(0, 0, 0, 0.12),
            0 8px 16px rgba(0, 0, 0, 0.08);
    }
}

/* ========================================
   §3 — HERO SECTION ANIMATIONS
   Cinematic entrance effects
   ======================================== */

/* Split hero entrance */
.hero-split-reveal {
    overflow: hidden;
}

.hero-split-reveal .hero-content {
    animation: heroSlideUp 1s var(--anim-ease-expo) 0.2s backwards;
}

.hero-split-reveal .hero-media {
    animation: heroSlideRight 1s var(--anim-ease-expo) 0.4s backwards;
}

@keyframes heroSlideUp {
    from {
        opacity: 0;
        transform: translateY(60px);
    }
}

@keyframes heroSlideRight {
    from {
        opacity: 0;
        transform: translateX(-60px) scale(0.95);
    }
}

/* Parallax hero background */
.hero-parallax {
    position: relative;
    overflow: hidden;
}

.hero-parallax-bg {
    position: absolute;
    inset: -20%;
    background-size: cover;
    background-position: center;
    will-change: transform;
    transition: transform 0.1s linear;
}

/* Hero gradient mesh background */
.hero-mesh {
    position: relative;
    overflow: hidden;
}

.hero-mesh::before {
    content: '';
    position: absolute;
    inset: 0;
    /* Parity + policy: no gradients. Use a subtle blurred solid glow instead. */
    background: rgba(var(--color-primary-rgb, 0, 102, 204), 0.10);
    filter: blur(80px);
    opacity: 0.55;
    /* Finite iterations (policy): decorative motion must stop */
    animation: meshFloat 8s ease-in-out 3;
    pointer-events: none;
}

@keyframes meshFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(2%, -2%) scale(1.02); }
    50% { transform: translate(-1%, 2%) scale(1.01); }
    75% { transform: translate(1%, -1%) scale(1.03); }
}

/* ========================================
   §4 — SCROLL PROGRESS & READING UX
   Enhanced reading experience
   ======================================== */

/* Reading progress bar */
.reading-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: var(--color-primary, #0066CC);
    z-index: 9999;
    transition: width 0.1s linear;
    box-shadow: 0 0 10px rgba(var(--color-primary-rgb, 0, 102, 204), 0.5);
}

/* Section indicator */
.section-indicator {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
}

.section-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-border, #E5E5E5);
    cursor: pointer;
    transition: all 0.3s var(--anim-ease-smooth);
}

.section-dot.is-active {
    background: var(--color-primary, #0066CC);
    transform: scale(1.3);
    box-shadow: 0 0 12px rgba(var(--color-primary-rgb, 0, 102, 204), 0.5);
}

@media (hover: hover) and (pointer: fine) {
    .section-dot:hover {
        transform: scale(1.2);
    }
}

/* Back to top button */
.back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border, #E5E5E5);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s var(--anim-ease-smooth);
    z-index: 100;
}

.back-to-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

@media (hover: hover) and (pointer: fine) {
    .back-to-top:hover {
        transform: translateY(-4px);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    }
}

/* ========================================
   §5 — ADVANCED MICRO-INTERACTIONS
   Premium button & link effects
   ======================================== */

/* Magnetic button (follows cursor slightly) */
.btn-magnetic {
    position: relative;
    transition: transform 0.3s var(--anim-ease-smooth);
}

/* Parity: no cursor-follow magnet. Keep button stable across devices. */
.btn-magnetic:hover {
    transform: none;
}

/* Button with expanding background */
.btn-expand {
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.btn-expand::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: var(--color-primary-hover, #004D99);
    transform: translate(-50%, -50%);
    transition: all 0.5s var(--anim-ease-expo);
    z-index: -1;
}

@media (hover: hover) and (pointer: fine) {
    .btn-expand:hover::before {
        width: 300%;
        height: 300%;
    }
}

@media (hover: none), (pointer: coarse) {
    .btn-expand:active::before {
        width: 260%;
        height: 260%;
    }
}

/* Link with arrow slide */
.link-arrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.link-arrow svg,
.link-arrow::after {
    transition: transform 0.3s var(--anim-ease-smooth);
}

.link-arrow::after {
    content: '→';
}

.link-arrow:hover svg,
.link-arrow:hover::after {
    transform: translateX(4px);
}

/* Icon bounce on hover */
.icon-bounce:hover svg,
.icon-bounce:hover .icon {
    animation: iconBounce 0.4s var(--anim-ease-bounce);
}

@keyframes iconBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

/* ========================================
   §6 — GRID & LIST ANIMATIONS
   Staggered cascade reveals
   ======================================== */

/* Staggered grid entrance */
.grid-stagger > * {
    opacity: 0;
    transform: translateY(30px);
}

.grid-stagger.is-visible > * {
    animation: gridItemReveal 0.6s var(--anim-ease-out-quint) forwards;
}

.grid-stagger.is-visible > *:nth-child(1) { animation-delay: 0ms; }
.grid-stagger.is-visible > *:nth-child(2) { animation-delay: 80ms; }
.grid-stagger.is-visible > *:nth-child(3) { animation-delay: 160ms; }
.grid-stagger.is-visible > *:nth-child(4) { animation-delay: 240ms; }
.grid-stagger.is-visible > *:nth-child(5) { animation-delay: 320ms; }
.grid-stagger.is-visible > *:nth-child(6) { animation-delay: 400ms; }
.grid-stagger.is-visible > *:nth-child(7) { animation-delay: 480ms; }
.grid-stagger.is-visible > *:nth-child(8) { animation-delay: 560ms; }
.grid-stagger.is-visible > *:nth-child(9) { animation-delay: 640ms; }

@keyframes gridItemReveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Masonry reveal (different directions) */
.masonry-reveal > *:nth-child(odd) {
    transform: translateX(-30px);
}

.masonry-reveal > *:nth-child(even) {
    transform: translateX(30px);
}

.masonry-reveal.is-visible > * {
    opacity: 1;
    transform: translateX(0);
    transition: all 0.6s var(--anim-ease-out-quint);
}

/* ========================================
   §7 — IMAGE & MEDIA ANIMATIONS
   Premium visual effects
   ======================================== */

/* Image reveal with curtain */
.img-curtain {
    position: relative;
    overflow: hidden;
}

.img-curtain::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--color-surface, #fff);
    transform: scaleX(1);
    transform-origin: right;
    transition: transform 0.8s var(--anim-ease-expo);
}

.img-curtain.is-visible::after {
    transform: scaleX(0);
}

/* Image zoom on hover container */
.img-zoom-container {
    overflow: hidden;
    border-radius: inherit;
}

.img-zoom-container img {
    transition: transform 0.6s var(--anim-ease-out-quint);
    will-change: transform;
}

@media (hover: hover) and (pointer: fine) {
    .img-zoom-container:hover img {
        transform: scale(1.1);
    }
}

@media (hover: none), (pointer: coarse) {
    .img-zoom-container:active img {
        transform: scale(1.06);
    }
}

/* Ken Burns effect (slow zoom + pan) */
.img-ken-burns {
    /* Finite iterations (policy): avoid perpetual motion */
    animation: kenBurns 20s ease-in-out 2 alternate;
}

@keyframes kenBurns {
    0% { transform: scale(1) translate(0, 0); }
    100% { transform: scale(1.1) translate(-2%, -2%); }
}

/* Image tilt on hover */
.img-tilt {
    transition: transform 0.4s var(--anim-ease-smooth);
    will-change: transform;
}

@media (hover: hover) and (pointer: fine) {
    .img-tilt:hover {
        transform: perspective(1000px) rotateY(5deg) rotateX(5deg);
    }
}

/* ========================================
   §8 — LOADING & SKELETON STATES
   Premium loading experience
   ======================================== */

/* Shimmer skeleton */
.skeleton-shimmer {
    /* Parity + policy: no gradients. Use pulse skeleton instead. */
    background: var(--color-surface-alt, #F5F5F5);
    animation: skeletonPulse 1.5s ease-in-out infinite;
    border-radius: 4px;
}

/* Pulse skeleton */
.skeleton-pulse {
    background: var(--color-surface-alt, #F5F5F5);
    animation: skeletonPulse 1.5s ease-in-out infinite;
    border-radius: 4px;
}

@keyframes skeletonPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Content placeholder set */
.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
    border-radius: 4px;
}

.skeleton-text:last-child {
    width: 70%;
}

.skeleton-title {
    height: 1.5em;
    width: 60%;
    margin-bottom: 1em;
}

.skeleton-image {
    aspect-ratio: 16/9;
    border-radius: 8px;
}

/* ========================================
   §9 — NOTIFICATION & TOAST ANIMATIONS
   Attention-grabbing reveals
   ======================================== */

/* Slide-in notification */
.notification-slide {
    animation: notifSlideIn 0.4s var(--anim-ease-spring) forwards;
}

@keyframes notifSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Bounce-in notification */
.notification-bounce {
    animation: notifBounce 0.5s var(--anim-ease-bounce) forwards;
}

@keyframes notifBounce {
    0% {
        opacity: 0;
        transform: scale(0.5) translateY(-20px);
    }
    60% {
        transform: scale(1.05) translateY(0);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Exit animation */
.notification-exit {
    animation: notifExit 0.3s var(--anim-ease-smooth) forwards;
}

@keyframes notifExit {
    to {
        opacity: 0;
        transform: translateX(100%) scale(0.9);
    }
}

/* ========================================
   §10 — DECORATIVE BACKGROUND EFFECTS
   Subtle ambient animations
   ======================================== */

/* Floating orbs */
.bg-orbs {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.bg-orbs::before,
.bg-orbs::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.15;
}

.bg-orbs::before {
    width: 400px;
    height: 400px;
    background: var(--color-primary, #0066CC);
    top: -100px;
    right: -100px;
    /* Finite iterations (policy): decorative motion must stop */
    animation: orbFloat1 15s ease-in-out 3;
}

.bg-orbs::after {
    width: 300px;
    height: 300px;
    background: var(--color-primary, #0066CC);
    bottom: -50px;
    left: 10%;
    /* Finite iterations (policy): decorative motion must stop */
    animation: orbFloat2 18s ease-in-out 3;
}

@keyframes orbFloat1 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-50px, 50px); }
}

@keyframes orbFloat2 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(50px, -30px); }
}

/* Grain texture overlay */
.bg-grain {
    position: relative;
}

.bg-grain::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    opacity: 0.03;
    pointer-events: none;
    mix-blend-mode: overlay;
}

/* ========================================
   §11 — INTERACTIVE CONTENT BLOCKS
   Stats, counters, comparison blocks
   ======================================== */

/* Animated counter */
.counter-animate {
    font-variant-numeric: tabular-nums;
}

.counter-animate.is-visible .counter-value {
    animation: counterUp 2s var(--anim-ease-out-quint) forwards;
}

/* Stats card with value highlight */
.stat-card-highlight {
    position: relative;
    overflow: hidden;
}

.stat-card-highlight::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    /* Parity + policy: no gradients. Use a subtle pulsing glow overlay. */
    background: rgba(var(--color-primary-rgb, 0, 102, 204), 0.10);
    filter: blur(24px);
    opacity: 0.0;
    /* Finite iterations (policy): decorative motion must stop */
    animation: statPulse 2.8s ease-in-out 3;
    pointer-events: none;
}

@keyframes statPulse {
    0%, 100% { opacity: 0.0; }
    50% { opacity: 0.9; }
}

/* Comparison slider animation */
.comparison-reveal {
    animation: comparisonSlide 1s var(--anim-ease-expo) 0.5s backwards;
}

@keyframes comparisonSlide {
    from {
        clip-path: inset(0 100% 0 0);
    }
    to {
        clip-path: inset(0 0 0 0);
    }
}

/* ========================================
   §12 — ACCESSIBILITY OVERRIDES
   Respect user preferences
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    /* Disable all custom animations */
    .text-shimmer,
    .hero-mesh::before,
    .bg-orbs::before,
    .bg-orbs::after,
    .img-ken-burns,
    .stat-card-highlight::before {
        animation: none !important;
    }
    
    /* Remove transforms that cause motion */
    .card-3d:hover,
    .card-float:hover,
    .img-tilt:hover,
    .btn-magnetic:hover {
        transform: none !important;
    }
    
    /* Instant state changes */
    [data-anim],
    .grid-stagger > *,
    .masonry-reveal > * {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }
}

/* High contrast mode adjustments */
@media (prefers-contrast: high) {
    .card-glass {
        background: var(--color-surface, #fff);
        backdrop-filter: none;
        border: 2px solid var(--color-text, #000);
    }
    
    .skeleton-shimmer,
    .skeleton-pulse {
        background: var(--color-surface-alt, #E5E5E5);
        animation: none;
    }
}

/* ========================================
   §13 — DARK MODE ENHANCEMENTS
   Theme-aware animation tweaks
   ======================================== */

[data-theme="dark"] .card-shine::before {
    background: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .card-glass {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .img-curtain::after {
    background: var(--color-bg, #0D0D0D);
}

[data-theme="dark"] .skeleton-shimmer {
    background: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .bg-grain::after {
    opacity: 0.02;
}
