/* ============================================================
   LANDING PAGE ANIMATIONS v2 - Shared by ClosrQuote & TPI
   Interactive backgrounds, aurora effects, enhanced mockups,
   magnetic cards, floating shapes, light reflections
   ============================================================ */

/* ============ SCROLL PROGRESS BAR ============ */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: var(--gradient-hero, linear-gradient(135deg, #C46A4A 0%, #D9876B 100%));
    z-index: 9999;
    transition: width 0.1s linear;
    pointer-events: none;
}

/* ============ AURORA GRADIENT BACKGROUND ============ */
.aurora-bg {
    position: absolute;
    top: -20%;
    left: -20%;
    width: 140%;
    height: 140%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.6;
    transition: transform 0.1s linear;
}

.aurora-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    mix-blend-mode: normal;
    animation: auroraFloat 20s ease-in-out infinite;
}

.aurora-blob--0 {
    width: 500px;
    height: 500px;
    background: rgba(196, 106, 74, 0.08);
    top: 10%;
    left: 5%;
    animation-delay: 0s;
}

.aurora-blob--1 {
    width: 400px;
    height: 400px;
    background: rgba(217, 135, 107, 0.06);
    top: 40%;
    right: 10%;
    animation-delay: -7s;
}

.aurora-blob--2 {
    width: 350px;
    height: 350px;
    background: rgba(230, 168, 142, 0.05);
    bottom: 10%;
    left: 30%;
    animation-delay: -14s;
}

[data-theme="dark"] .aurora-blob--0 {
    background: rgba(217, 135, 107, 0.06);
}

[data-theme="dark"] .aurora-blob--1 {
    background: rgba(196, 106, 74, 0.05);
}

[data-theme="dark"] .aurora-blob--2 {
    background: rgba(217, 135, 107, 0.04);
}

@keyframes auroraFloat {
    0%, 100% { transform: translate(0, 0) scale(1) rotate(0deg); }
    25% { transform: translate(40px, -30px) scale(1.1) rotate(5deg); }
    50% { transform: translate(-20px, 40px) scale(0.95) rotate(-3deg); }
    75% { transform: translate(30px, 20px) scale(1.05) rotate(2deg); }
}

/* ============ ANIMATED BACKGROUND PARTICLES ============ */
.hero-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.particle {
    position: absolute;
    border-radius: 50%;
    opacity: 0;
    animation: particleFloat linear infinite;
}

.particle--warm {
    background: radial-gradient(circle, rgba(196, 106, 74, 0.25) 0%, transparent 70%);
}

.particle--soft {
    background: radial-gradient(circle, rgba(217, 135, 107, 0.18) 0%, transparent 70%);
}

.particle--glow {
    background: radial-gradient(circle, rgba(230, 168, 142, 0.15) 0%, rgba(196, 106, 74, 0.05) 40%, transparent 70%);
    box-shadow: 0 0 20px rgba(196, 106, 74, 0.08);
}

@keyframes particleFloat {
    0% {
        opacity: 0;
        transform: translateY(100vh) scale(0.5) rotate(0deg);
    }
    10% {
        opacity: 1;
    }
    50% {
        transform: translateY(40vh) scale(0.9) rotate(180deg);
    }
    90% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translateY(-20vh) scale(1.2) rotate(360deg);
    }
}

/* ============ HERO ENTRANCE ANIMATIONS ============ */
.hero-animate .hero-badge {
    opacity: 0;
    transform: translateY(30px);
    animation: heroReveal 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.1s forwards;
}

.hero-animate .hero-title {
    opacity: 0;
    transform: translateY(40px);
    animation: heroReveal 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.25s forwards;
}

.hero-animate .hero-accent-line {
    opacity: 0;
    width: 0;
    animation: accentLineReveal 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.45s forwards;
}

.hero-animate .hero-subtitle {
    opacity: 0;
    transform: translateY(30px);
    animation: heroReveal 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.5s forwards;
}

.hero-animate .hero-cta {
    opacity: 0;
    transform: translateY(30px);
    animation: heroReveal 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.65s forwards;
}

.hero-animate .hero-stats {
    opacity: 0;
    transform: translateY(20px);
    animation: heroReveal 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.8s forwards;
}

.hero-animate .hero-visual {
    opacity: 0;
    transform: translateY(50px) perspective(1000px) rotateX(5deg);
    animation: dashboardReveal 1s cubic-bezier(0.16, 1, 0.3, 1) 0.4s forwards;
}

@keyframes heroReveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes accentLineReveal {
    to {
        opacity: 1;
        width: 60px;
    }
}

@keyframes dashboardReveal {
    to {
        opacity: 1;
        transform: translateY(0) perspective(1000px) rotateX(0deg);
    }
}

/* ============ DASHBOARD PREVIEW ENHANCEMENTS ============ */
.dashboard-preview {
    transition: transform 0.15s ease-out, box-shadow 0.4s ease;
    position: relative;
    transform-style: preserve-3d;
}

.dashboard-preview:hover {
    box-shadow: 0 50px 100px -20px rgba(196, 106, 74, 0.15), var(--shadow-lg, 0 25px 50px -12px rgba(120, 80, 40, 0.12));
}

/* Light reflection overlay */
.dashboard-reflection {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: inherit;
    pointer-events: none;
    z-index: 10;
    transition: background 0.3s ease;
}

/* Glare spot */
.dashboard-glare {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: inherit;
    pointer-events: none;
    z-index: 11;
    transition: background 0.15s ease;
}

/* Shimmer effect on preview cards */
.preview-card {
    position: relative;
    overflow: hidden;
}

.preview-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent 0%, rgba(196, 106, 74, 0.05) 50%, transparent 100%);
    animation: shimmerSlide 4s ease-in-out infinite;
    pointer-events: none;
}

.preview-card:nth-child(1)::after { animation-delay: 0s; }
.preview-card:nth-child(2)::after { animation-delay: 0.5s; }
.preview-card:nth-child(3)::after { animation-delay: 1s; }
.preview-card:nth-child(4)::after { animation-delay: 1.5s; }

@keyframes shimmerSlide {
    0%, 100% { left: -100%; }
    50% { left: 100%; }
}

/* Typing cursor animation for sidebar fields */
.field-typing-cursor {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    width: 2px;
    height: 60%;
    background: var(--btn-primary, #C46A4A);
    border-radius: 1px;
    opacity: 0;
    animation: typingCursor 4s ease-in-out infinite;
}

@keyframes typingCursor {
    0% { left: 8px; opacity: 0; }
    5% { opacity: 1; }
    15% { left: 70%; opacity: 1; }
    20% { opacity: 0; }
    100% { opacity: 0; left: 70%; }
}

/* Badge pulse animation */
@keyframes badgePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.85; transform: scale(1.05); }
}

/* ============ ENHANCED SCROLL REVEAL SYSTEM ============ */
.reveal {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity, transform;
}

.reveal.from-left {
    transform: translateX(-60px);
}

.reveal.from-right {
    transform: translateX(60px);
}

.reveal.from-scale {
    transform: scale(0.9);
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0) translateX(0) scale(1);
}

/* Stagger delays for children */
.stagger-children .reveal:nth-child(1) { transition-delay: 0.05s; }
.stagger-children .reveal:nth-child(2) { transition-delay: 0.12s; }
.stagger-children .reveal:nth-child(3) { transition-delay: 0.19s; }
.stagger-children .reveal:nth-child(4) { transition-delay: 0.26s; }
.stagger-children .reveal:nth-child(5) { transition-delay: 0.33s; }
.stagger-children .reveal:nth-child(6) { transition-delay: 0.4s; }

/* ============ FEATURE CARD ENHANCEMENTS ============ */
.feature-card {
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* Mouse-following radial glow on cards */
.feature-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: inherit;
    background: radial-gradient(
        circle 200px at var(--mouse-x, 50%) var(--mouse-y, 50%),
        rgba(196, 106, 74, 0.08) 0%,
        transparent 100%
    );
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
    z-index: 0;
}

.feature-card:hover::before {
    opacity: 1;
}

/* Animated gradient border on hover */
.feature-card::after {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    border-radius: inherit;
    background: linear-gradient(135deg, transparent 0%, transparent 40%, rgba(196, 106, 74, 0.4) 50%, transparent 60%, transparent 100%);
    background-size: 300% 300%;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    padding: 1px;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
    animation: borderRotate 4s linear infinite paused;
    z-index: 1;
}

.feature-card:hover::after {
    opacity: 1;
    animation-play-state: running;
}

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

/* Feature icon pulse on card hover */
.feature-card:hover .feature-icon {
    transform: scale(1.1);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============ STEP CARD ENHANCEMENTS ============ */
.step-number {
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.4s ease;
}

.step-card:hover .step-number {
    transform: scale(1.1) rotate(-5deg);
    box-shadow: 0 8px 24px rgba(196, 106, 74, 0.3);
}

/* Connecting line between steps */
.steps-grid::before {
    content: '';
    position: absolute;
    top: 28px;
    left: calc(16.66% + 28px);
    right: calc(16.66% + 28px);
    height: 2px;
    background: linear-gradient(90deg, var(--btn-primary, #C46A4A), var(--border-color, #e0d5c8), var(--btn-primary, #C46A4A));
    z-index: 0;
    opacity: 0.4;
}

/* ============ SHOWCASE SECTION ENHANCEMENTS ============ */
.showcase-mockup {
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.5s ease;
}

.showcase-mockup:hover {
    transform: translateY(-6px) scale(1.01);
}

.showcase-tag {
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: default;
}

.showcase-tag:hover {
    background: rgba(196, 106, 74, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(196, 106, 74, 0.15);
}

/* ============ CARRIER MARQUEE ============ */
.carrier-marquee-wrapper {
    overflow: hidden;
    position: relative;
    width: 100%;
    mask-image: linear-gradient(to right, transparent 0%, black 10%, black 90%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 10%, black 90%, transparent 100%);
}

.carrier-marquee-track {
    display: flex;
    gap: 1.25rem;
    animation: marqueeScroll 30s linear infinite;
    width: max-content;
}

.carrier-marquee-track:hover {
    animation-play-state: paused;
}

@keyframes marqueeScroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* ============ PRICING CARD ENHANCEMENTS ============ */
.pricing-card {
    position: relative;
    overflow: hidden;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s ease !important;
}

.pricing-card::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(196, 106, 74, 0.06) 0%, transparent 50%);
    animation: pricingGlow 6s ease-in-out infinite;
    pointer-events: none;
}

@keyframes pricingGlow {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 0.8; transform: scale(1.1); }
}

.pricing-card:hover {
    transform: translateY(-8px) !important;
    box-shadow: 0 30px 80px rgba(196, 106, 74, 0.2) !important;
}

.pricing-features li {
    transition: transform 0.3s ease;
}

.pricing-features li:hover {
    transform: translateX(4px);
}

/* ============ BUTTON ENHANCEMENTS ============ */
.btn-primary-hero,
.btn-subscribe,
.btn-login {
    position: relative;
    overflow: hidden;
}

.btn-primary-hero::after,
.btn-subscribe::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
    pointer-events: none;
}

.btn-primary-hero:hover::after,
.btn-subscribe:hover::after {
    width: 300px;
    height: 300px;
}

.btn-primary-hero .fa-arrow-right {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-primary-hero:hover .fa-arrow-right {
    transform: translateX(4px);
}

/* ============ SECTION HEADER ANIMATIONS ============ */
.section-badge {
    transition: all 0.3s ease;
}

.section-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(196, 106, 74, 0.2);
}

/* ============ GRADIENT TEXT SHIMMER ============ */
.gradient-text-shimmer {
    background: linear-gradient(
        135deg,
        #C46A4A 0%,
        #D9876B 25%,
        #e6a88e 50%,
        #D9876B 75%,
        #C46A4A 100%
    );
    background-size: 400% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: textShimmer 8s ease-in-out infinite;
}

@keyframes textShimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* ============ STAT COUNTER ANIMATION ============ */
.stat-value {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.stat:hover .stat-value {
    transform: scale(1.1);
}

.stat-divider {
    transition: height 0.3s ease, background 0.3s ease;
}

/* ============ FOOTER ENHANCEMENTS ============ */
.footer-brand img,
.footer-brand span {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.footer-brand:hover img {
    transform: scale(1.05);
}

/* ============ SMOOTH LOADING OVERLAY ============ */
.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary, #faf7f2);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    pointer-events: none;
}

.page-loader.loaded {
    opacity: 0;
    visibility: hidden;
}

.loader-logo {
    animation: loaderAlive 1.8s ease-in-out infinite;
}

@keyframes loaderAlive {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        opacity: 0.7;
    }
    15% {
        transform: scale(1.08) rotate(-2deg);
        opacity: 0.9;
    }
    30% {
        transform: scale(1.05) rotate(2.5deg);
        opacity: 1;
    }
    45% {
        transform: scale(1.1) rotate(-1.5deg);
        opacity: 1;
    }
    60% {
        transform: scale(1.06) rotate(1deg);
        opacity: 0.95;
    }
    75% {
        transform: scale(1.03) rotate(-0.5deg);
        opacity: 0.85;
    }
}

/* ============ NAVBAR SCROLL ENHANCEMENT ============ */
.navbar.scrolled {
    padding: 0.4rem 2rem;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.08);
}

.navbar .logo img {
    transition: height 0.3s ease;
}

.navbar.scrolled .logo img {
    height: 42px;
}

/* ============ FLOATING GLOW ORBS (Background decoration) ============ */
.glow-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
    z-index: 0;
    opacity: 0.5;
    animation: orbFloat 12s ease-in-out infinite;
}

.glow-orb--primary {
    background: rgba(196, 106, 74, 0.12);
    width: 400px;
    height: 400px;
}

.glow-orb--secondary {
    background: rgba(217, 135, 107, 0.08);
    width: 300px;
    height: 300px;
}

.glow-orb--tertiary {
    background: rgba(230, 168, 142, 0.06);
    width: 250px;
    height: 250px;
    animation-duration: 18s;
}

.glow-orb--section {
    background: rgba(196, 106, 74, 0.06);
    width: 350px;
    height: 350px;
    filter: blur(100px);
    opacity: 0.4;
    animation-duration: 15s;
}

[data-theme="dark"] .glow-orb--primary {
    background: rgba(217, 135, 107, 0.08);
}

[data-theme="dark"] .glow-orb--secondary {
    background: rgba(196, 106, 74, 0.06);
}

[data-theme="dark"] .glow-orb--tertiary {
    background: rgba(230, 168, 142, 0.04);
}

[data-theme="dark"] .glow-orb--section {
    background: rgba(217, 135, 107, 0.04);
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -20px) scale(1.05); }
    66% { transform: translate(-20px, 15px) scale(0.95); }
}

/* ============ FLOATING GEOMETRIC SHAPES ============ */
.floating-shape {
    position: absolute;
    pointer-events: none;
    z-index: 0;
    opacity: 0.06;
}

.floating-shape--0 {
    width: 120px;
    height: 120px;
    border: 2px solid var(--btn-primary, #C46A4A);
    border-radius: 24px;
    top: 15%;
    right: 8%;
    animation: shapeFloat0 20s ease-in-out infinite;
}

.floating-shape--1 {
    width: 80px;
    height: 80px;
    border: 2px solid var(--btn-primary, #C46A4A);
    border-radius: 50%;
    bottom: 20%;
    left: 5%;
    animation: shapeFloat1 16s ease-in-out infinite;
}

.floating-shape--2 {
    width: 60px;
    height: 60px;
    border: 2px solid var(--btn-primary, #C46A4A);
    border-radius: 12px;
    top: 60%;
    right: 15%;
    animation: shapeFloat2 22s ease-in-out infinite;
    transform: rotate(45deg);
}

@keyframes shapeFloat0 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(15px, -20px) rotate(15deg); }
    50% { transform: translate(-10px, 10px) rotate(-10deg); }
    75% { transform: translate(20px, 15px) rotate(8deg); }
}

@keyframes shapeFloat1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(20px, -15px) scale(1.1); }
    66% { transform: translate(-15px, 20px) scale(0.9); }
}

@keyframes shapeFloat2 {
    0%, 100% { transform: rotate(45deg) translate(0, 0); }
    33% { transform: rotate(55deg) translate(10px, -25px); }
    66% { transform: rotate(35deg) translate(-20px, 10px); }
}

[data-theme="dark"] .floating-shape {
    opacity: 0.04;
}

/* ============ SWIRL CANVAS BACKGROUND ============ */
.swirl-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* Ensure sections and content sit above the fixed swirl canvas */
.hero,
.features,
.how-it-works,
.showcase,
.carriers-section,
.pricing,
.footer,
.navbar {
    position: relative;
    z-index: 1;
}

/* Ribbon canvases in sections */
.ribbon-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* ============ SECTION ACTIVE TRANSITIONS ============ */
.section-active .section-header {
    animation: sectionPop 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes sectionPop {
    from { filter: blur(4px); }
    to { filter: blur(0); }
}

/* ============ RESPONSIVE ANIMATION ADJUSTMENTS ============ */
@media (max-width: 768px) {
    .steps-grid::before {
        display: none;
    }

    .hero-animate .hero-visual {
        transform: translateY(30px);
    }

    @keyframes dashboardReveal {
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .glow-orb,
    .aurora-bg,
    .dot-grid-canvas,
    .floating-shape,
    .swirl-canvas,
    .ribbon-canvas {
        display: none;
    }

    .carrier-marquee-track {
        animation-duration: 20s;
    }
}

@media (max-width: 480px) {
    .hero-particles {
        display: none;
    }

    .scroll-progress {
        height: 2px;
    }
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .hero-animate .hero-badge,
    .hero-animate .hero-title,
    .hero-animate .hero-accent-line,
    .hero-animate .hero-subtitle,
    .hero-animate .hero-cta,
    .hero-animate .hero-stats,
    .hero-animate .hero-visual {
        opacity: 1 !important;
        transform: none !important;
        animation: none !important;
    }

    .reveal {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }

    .particle,
    .glow-orb,
    .carrier-marquee-track,
    .aurora-blob,
    .floating-shape {
        animation: none !important;
    }

    .preview-card::after,
    .pricing-card::after {
        animation: none !important;
    }

    .scroll-progress {
        display: none;
    }

    .dot-grid-canvas,
    .aurora-bg,
    .swirl-canvas,
    .ribbon-canvas {
        display: none !important;
    }

    .field-typing-cursor {
        display: none !important;
    }
}
