/* ============================================================
   TAX.hk Visual Effects System - Apple-Inspired Design
   ============================================================ */

/* ===== Animated Gradient Backgrounds ===== */
@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes shimmer {
    0% { background-position: -200% center; }
    100% { background-position: 200% center; }
}

@keyframes gentleFloat {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    33% { transform: translateY(-8px) rotate(0.5deg); }
    66% { transform: translateY(4px) rotate(-0.3deg); }
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 12px rgba(34, 197, 94, 0.3); }
    50% { box-shadow: 0 0 24px rgba(34, 197, 94, 0.5); }
}

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

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes fadeInBlur {
    from { opacity: 0; filter: blur(10px); }
    to { opacity: 1; filter: blur(0); }
}

@keyframes rotateIn {
    from { opacity: 0; transform: rotate(-5deg) scale(0.95); }
    to { opacity: 1; transform: rotate(0deg) scale(1); }
}

@keyframes borderDraw {
    from { clip-path: inset(0 100% 0 0); }
    to { clip-path: inset(0 0 0 0); }
}

@keyframes textReveal {
    from { clip-path: inset(0 100% 0 0); opacity: 0; }
    to { clip-path: inset(0 0 0 0); opacity: 1; }
}

@keyframes orbFloat1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -40px) scale(1.05); }
    50% { transform: translate(-20px, -60px) scale(0.95); }
    75% { transform: translate(-40px, -20px) scale(1.02); }
}

@keyframes orbFloat2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(-30px, 30px) scale(0.97); }
    50% { transform: translate(40px, 50px) scale(1.03); }
    75% { transform: translate(20px, -30px) scale(0.98); }
}

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

@keyframes particleRise {
    0% { transform: translateY(0) scale(1); opacity: 0.6; }
    100% { transform: translateY(-100vh) scale(0); opacity: 0; }
}

/* ===== Glassmorphism Utilities ===== */
.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.glass-dark {
    background: rgba(30, 58, 95, 0.6);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.glass-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
}

/* ===== Text Gradient Shimmer ===== */
.text-shimmer {
    color: var(--cyan-light);
    -webkit-text-fill-color: var(--cyan-light);
}

.text-gradient {
    background: linear-gradient(135deg, var(--primary) 0%, var(--teal) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.text-gradient-gold {
    background: linear-gradient(135deg, var(--accent) 0%, #e6c84a 50%, var(--accent-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== Scroll-Triggered Reveal Classes ===== */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.reveal-left {
    opacity: 0;
    transform: translateX(-40px);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-left.visible {
    opacity: 1;
    transform: translateX(0);
}

.reveal-right {
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-right.visible {
    opacity: 1;
    transform: translateX(0);
}

.reveal-scale {
    opacity: 0;
    transform: scale(0.92);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-scale.visible {
    opacity: 1;
    transform: scale(1);
}

.reveal-blur {
    opacity: 0;
    filter: blur(8px);
    transform: translateY(20px);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
                filter 0.8s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-blur.visible {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0);
}

/* Stagger delays for child elements */
.stagger-children .reveal:nth-child(1),
.stagger-children > *:nth-child(1) { transition-delay: 0ms; }
.stagger-children .reveal:nth-child(2),
.stagger-children > *:nth-child(2) { transition-delay: 100ms; }
.stagger-children .reveal:nth-child(3),
.stagger-children > *:nth-child(3) { transition-delay: 200ms; }
.stagger-children .reveal:nth-child(4),
.stagger-children > *:nth-child(4) { transition-delay: 300ms; }
.stagger-children .reveal:nth-child(5),
.stagger-children > *:nth-child(5) { transition-delay: 400ms; }
.stagger-children .reveal:nth-child(6),
.stagger-children > *:nth-child(6) { transition-delay: 500ms; }

/* ===== Enhanced Card 3D Tilt Effect ===== */
.tilt-card {
    transform-style: preserve-3d;
    transform: perspective(1000px);
    transition: transform 0.4s cubic-bezier(0.03, 0.98, 0.52, 0.99);
    will-change: transform;
}

.tilt-card:hover {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12), 0 8px 24px rgba(0, 0, 0, 0.06);
}

.tilt-card .tilt-inner {
    transform: translateZ(20px);
    transition: transform 0.4s cubic-bezier(0.03, 0.98, 0.52, 0.99);
}

/* ===== Magnetic Button Effect ===== */
.magnetic-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.03, 0.98, 0.52, 0.99);
    will-change: transform;
}

.magnetic-btn::after {
    content: '';
    position: absolute;
    inset: -10px;
    border-radius: inherit;
    z-index: -1;
    opacity: 0;
    background: radial-gradient(circle at var(--x, 50%) var(--y, 50%), rgba(201, 162, 39, 0.2), transparent 60%);
    transition: opacity 0.3s ease;
}

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

/* ===== Animated Border Gradient ===== */
.gradient-border {
    position: relative;
    border: none !important;
    background-clip: padding-box;
}

.gradient-border::before {
    content: '';
    position: absolute;
    inset: 0;
    padding: 2px;
    border-radius: inherit;
    background: linear-gradient(135deg, var(--teal), var(--accent), var(--primary));
    background-size: 300% 300%;
    animation: gradientShift 6s ease infinite;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

/* ===== Floating Orb Decorations ===== */
.floating-orbs {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.floating-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.15;
}

.floating-orb-1 {
    width: 400px;
    height: 400px;
    background: var(--accent);
    top: -10%;
    right: -5%;
    animation: orbFloat1 20s ease-in-out infinite;
}

.floating-orb-2 {
    width: 300px;
    height: 300px;
    background: var(--teal);
    bottom: -15%;
    left: -5%;
    animation: orbFloat2 25s ease-in-out infinite;
}

.floating-orb-3 {
    width: 200px;
    height: 200px;
    background: var(--primary-light);
    top: 40%;
    left: 30%;
    animation: orbFloat1 18s ease-in-out infinite reverse;
}

/* ===== Enhanced Hero Effects ===== */
.hero-enhanced {
    position: relative;
}

.hero-enhanced .hero-title {
    animation: slideInUp 1s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both;
}

.hero-enhanced .hero-subtitle {
    animation: slideInUp 1s cubic-bezier(0.16, 1, 0.3, 1) 0.4s both;
}

.hero-enhanced .hero-badge {
    animation: fadeInBlur 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
}

.hero-enhanced .hero-buttons {
    animation: slideInUp 1s cubic-bezier(0.16, 1, 0.3, 1) 0.6s both;
}

.hero-enhanced .hero-stats {
    animation: slideInUp 1s cubic-bezier(0.16, 1, 0.3, 1) 0.8s both;
}

.hero-enhanced .hero-visual {
    animation: scaleIn 1.2s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both;
}

/* ===== Smooth Hover Lift ===== */
.hover-lift {
    transition: transform 0.4s cubic-bezier(0.03, 0.98, 0.52, 0.99),
                box-shadow 0.4s cubic-bezier(0.03, 0.98, 0.52, 0.99);
}

.hover-lift:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
}

/* ===== Glow on Hover ===== */
.hover-glow {
    transition: box-shadow 0.4s ease;
}

.hover-glow:hover {
    box-shadow: 0 0 30px rgba(201, 162, 39, 0.2),
                0 10px 40px rgba(0, 0, 0, 0.1);
}

/* ===== Image Parallax Container ===== */
.parallax-container {
    overflow: hidden;
    position: relative;
}

.parallax-bg {
    position: absolute;
    inset: -20%;
    background-size: cover;
    background-position: center;
    will-change: transform;
    transition: transform 0.1s linear;
}

/* ===== Section Divider Waves ===== */
.wave-divider {
    position: relative;
}

.wave-divider::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 60px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 60'%3E%3Cpath fill='%23ffffff' d='M0,40 C360,80 720,0 1080,40 C1260,60 1380,50 1440,45 L1440,60 L0,60 Z'/%3E%3C/svg%3E") no-repeat bottom center;
    background-size: 100% 100%;
    pointer-events: none;
    z-index: 2;
}

.wave-divider-dark::after {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 60'%3E%3Cpath fill='%23ffffff' d='M0,40 C360,80 720,0 1080,40 C1260,60 1380,50 1440,45 L1440,60 L0,60 Z'/%3E%3C/svg%3E") no-repeat bottom center;
    background-size: 100% 100%;
}

.wave-divider-top::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 0;
    right: 0;
    height: 60px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 60'%3E%3Cpath fill='%23ffffff' d='M0,20 C360,-20 720,60 1080,20 C1260,0 1380,10 1440,15 L1440,0 L0,0 Z'/%3E%3C/svg%3E") no-repeat top center;
    background-size: 100% 100%;
    pointer-events: none;
    z-index: 2;
}

/* ===== Animated Counter Number ===== */
.counter-number {
    display: inline-block;
    font-variant-numeric: tabular-nums;
    transition: transform 0.3s ease;
}

.counter-number.counting {
    transform: scale(1.05);
}

/* ===== Interactive Card Shine Effect ===== */
.shine-effect {
    position: relative;
    overflow: hidden;
}

.shine-effect::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        to right,
        transparent 0%,
        rgba(255, 255, 255, 0) 40%,
        rgba(255, 255, 255, 0.15) 50%,
        rgba(255, 255, 255, 0) 60%,
        transparent 100%
    );
    transform: rotate(25deg) translateX(-100%);
    transition: none;
    pointer-events: none;
}

.shine-effect:hover::after {
    transform: rotate(25deg) translateX(100%);
    transition: transform 0.8s ease;
}

/* ===== Particle Background ===== */
.particle-bg {
    position: relative;
    overflow: hidden;
}

.particle-bg .particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(201, 162, 39, 0.4);
    border-radius: 50%;
    animation: particleRise linear infinite;
}

/* ===== Animated Progress/Line ===== */
.animated-line {
    height: 3px;
    background: linear-gradient(90deg, var(--teal), var(--accent), var(--primary));
    background-size: 200% auto;
    animation: gradientShift 3s ease infinite;
    border-radius: 2px;
}

/* ===== Enhanced Section Labels ===== */
.section-label-animated {
    position: relative;
    overflow: hidden;
}

.section-label-animated::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 3s ease-in-out infinite;
}

/* ===== Smooth Number Ticker ===== */
.ticker {
    display: inline-flex;
    overflow: hidden;
    height: 1em;
    line-height: 1;
}

.ticker-digit {
    display: inline-block;
    animation: slideInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ===== Morphing Background Shapes ===== */
@keyframes morphShape {
    0%, 100% { border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%; }
    25% { border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%; }
    50% { border-radius: 50% 60% 30% 60% / 30% 50% 70% 60%; }
    75% { border-radius: 60% 30% 60% 50% / 60% 70% 40% 30%; }
}

.morph-shape {
    animation: morphShape 12s ease-in-out infinite;
}

/* ===== Cursor Trail (Desktop Only) ===== */
.cursor-glow {
    position: fixed;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(13, 137, 191, 0.04) 0%, transparent 70%);
    pointer-events: none;
    z-index: 9;
    transform: translate(-50%, -50%);
    transition: left 0.3s ease, top 0.3s ease, opacity 0.3s ease;
    opacity: 0;
    mix-blend-mode: normal;
}

.cursor-glow.active {
    opacity: 1;
}

@media (max-width: 768px) {
    .cursor-glow { display: none; }
}

/* ===== Smooth Page Load ===== */
.page-loaded main > section,
.page-loaded main > .hero {
    animation: fadeInBlur 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.page-loaded main > section:nth-child(2) { animation-delay: 0.1s; }
.page-loaded main > section:nth-child(3) { animation-delay: 0.15s; }

/* ===== Scroll Progress Indicator ===== */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--cyan));
    z-index: 10001;
    transition: width 0.15s ease-out;
}

/* ===== Enhanced Navbar Glass Effect ===== */
.navbar.scrolled {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    box-shadow: 0 4px 24px rgba(36, 94, 118, 0.08);
    border-bottom-color: transparent;
}

/* ===== Floating Action Particles ===== */
.action-particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.action-particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    opacity: 0;
}

/* ===== Interactive Hover Underline ===== */
.hover-underline {
    position: relative;
    text-decoration: none;
}

.hover-underline::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--teal), var(--accent));
    transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.hover-underline:hover::after {
    width: 100%;
}

/* ===== Enhanced Back to Top ===== */
.back-to-top {
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s, background 0.3s, box-shadow 0.3s;
}

.back-to-top.visible {
    box-shadow: 0 4px 20px rgba(30, 58, 95, 0.3);
}

.back-to-top:hover {
    box-shadow: 0 8px 30px rgba(30, 58, 95, 0.4);
}

/* ===== Smooth Image Load ===== */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.5s ease;
}

img[loading="lazy"].loaded,
img.loaded {
    opacity: 1;
}

/* Force loaded state for images that are already cached */
img:not([loading="lazy"]) {
    opacity: 1;
}

/* ===== Typewriter Cursor ===== */
.typewriter-cursor {
    display: inline-block;
    width: 3px;
    height: 1em;
    background: var(--accent);
    margin-left: 2px;
    animation: blink 0.8s step-end infinite;
    vertical-align: text-bottom;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ===== Interactive Icon Bounce ===== */
.icon-bounce {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.icon-bounce:hover {
    transform: scale(1.15) rotate(-5deg);
}

/* ===== Stacked Card Effect ===== */
.stacked-cards {
    position: relative;
}

.stacked-cards::before,
.stacked-cards::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: inherit;
    z-index: -1;
    transition: transform 0.4s cubic-bezier(0.03, 0.98, 0.52, 0.99);
}

.stacked-cards::before {
    transform: rotate(2deg) translate(4px, 4px);
    opacity: 0.3;
}

.stacked-cards::after {
    transform: rotate(-1deg) translate(-2px, 6px);
    opacity: 0.15;
}

.stacked-cards:hover::before {
    transform: rotate(4deg) translate(8px, 8px);
}

.stacked-cards:hover::after {
    transform: rotate(-2deg) translate(-4px, 10px);
}

/* ===== Reduced Motion Preferences ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .reveal,
    .reveal-left,
    .reveal-right,
    .reveal-scale,
    .reveal-blur {
        opacity: 1;
        transform: none;
        filter: none;
    }

    .cursor-glow {
        display: none;
    }

    .floating-orb {
        animation: none;
    }
}

/* ===== Enhanced Global Card Interactions ===== */
.tool-card,
.article-card,
.consultant-card,
.testimonial-card,
.why-card,
.featured-consultant,
.value-card {
    transition: transform 0.4s cubic-bezier(0.03, 0.98, 0.52, 0.99),
                box-shadow 0.4s cubic-bezier(0.03, 0.98, 0.52, 0.99),
                border-color 0.3s ease;
}

.tool-card:hover,
.article-card:hover,
.featured-consultant:hover,
.value-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(36, 94, 118, 0.1);
}

/* ===== Enhanced Page Hero Sections ===== */
.page-hero,
.articles-hero {
    position: relative;
}

.page-hero h1,
.articles-hero h1 {
    animation: slideInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
}

.page-hero p,
.articles-hero p {
    animation: slideInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both;
}

/* ===== Smooth Focus Transitions ===== */
input:focus,
select:focus,
textarea:focus {
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

/* ===== Enhanced Footer Interactions ===== */
.footer-social a {
    transition: all 0.4s cubic-bezier(0.03, 0.98, 0.52, 0.99);
}

.footer-social a:hover {
    transform: translateY(-4px) scale(1.08);
}

/* ===== Responsive Adjustments ===== */
@media (max-width: 768px) {
    .floating-orb {
        opacity: 0.08;
    }

    .floating-orb-1 {
        width: 200px;
        height: 200px;
    }

    .floating-orb-2 {
        width: 150px;
        height: 150px;
    }

    .floating-orb-3 {
        display: none;
    }

    .wave-divider::after,
    .wave-divider-top::before {
        height: 30px;
    }
}
