/* =====================================================
   MAIRUIK - Animations & Effects
   Beijing Mairuikang Medical Equipment Co., Ltd.
   ===================================================== */

/* =====================================================
   KEYFRAME ANIMATIONS
   ===================================================== */

/* Fade In Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

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

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

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

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Slide Animations */
@keyframes slideInUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

@keyframes slideInDown {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

/* Bounce Animations */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-30px);
    }
    60% {
        transform: translateY(-15px);
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes bounceInUp {
    0% {
        opacity: 0;
        transform: translateY(40px);
    }
    60% {
        opacity: 1;
        transform: translateY(-10px);
    }
    80% {
        transform: translateY(5px);
    }
    100% {
        transform: translateY(0);
    }
}

/* Rotate Animations */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes heartbeat {
    0% {
        transform: scale(1);
    }
    14% {
        transform: scale(1.1);
    }
    28% {
        transform: scale(1);
    }
    42% {
        transform: scale(1.1);
    }
    70% {
        transform: scale(1);
    }
}

/* Float Animation */
@keyframes float {
    0% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-20px);
    }
    100% {
        transform: translateY(0px);
    }
}

@keyframes floatSlow {
    0% {
        transform: translateY(0px) rotate(0deg);
    }
    50% {
        transform: translateY(-15px) rotate(5deg);
    }
    100% {
        transform: translateY(0px) rotate(0deg);
    }
}

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

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

/* Typing Animation */
@keyframes typing {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink {
    50% {
        border-color: transparent;
    }
}

/* Zoom Animations */
@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.3);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes zoomOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.3);
    }
}

/* Flip Animation */
@keyframes flip {
    from {
        transform: perspective(400px) rotateY(0);
    }
    to {
        transform: perspective(400px) rotateY(360deg);
    }
}

/* Roll Animation */
@keyframes rollIn {
    from {
        opacity: 0;
        transform: translateX(-100%) rotate(-120deg);
    }
    to {
        opacity: 1;
        transform: translateX(0) rotate(0);
    }
}

/* Light Speed Animation */
@keyframes lightSpeedIn {
    from {
        transform: translateX(100%) skewX(-30deg);
        opacity: 0;
    }
    to {
        transform: translateX(0) skewX(0);
        opacity: 1;
    }
}

/* Special Effects */
@keyframes ripple {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

@keyframes rotateScale {
    0% {
        transform: rotate(0deg) scale(1);
    }
    50% {
        transform: rotate(180deg) scale(1.2);
    }
    100% {
        transform: rotate(360deg) scale(1);
    }
}

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

/* Particle Animation */
@keyframes particleFloat {
    0%, 100% {
        transform: translate(0, 0);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty));
        opacity: 0;
    }
}

/* =====================================================
   SCROLL ANIMATIONS (Intersection Observer)
   ===================================================== */

.scroll-animate {
    opacity: 0;
    transform: translateY(50px);
    transition: all 0.8s cubic-bezier(0.5, 0, 0, 1);
}

.scroll-animate.visible {
    opacity: 1;
    transform: translateY(0);
}

.scroll-animate-left {
    opacity: 0;
    transform: translateX(-50px);
    transition: all 0.8s cubic-bezier(0.5, 0, 0, 1);
}

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

.scroll-animate-right {
    opacity: 0;
    transform: translateX(50px);
    transition: all 0.8s cubic-bezier(0.5, 0, 0, 1);
}

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

.scroll-animate-scale {
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.8s cubic-bezier(0.5, 0, 0, 1);
}

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

.scroll-animate-fade {
    opacity: 0;
    transition: opacity 0.8s ease;
}

.scroll-animate-fade.visible {
    opacity: 1;
}

/* Staggered Animation */
.stagger-item {
    opacity: 0;
    transform: translateY(30px);
}

.stagger-item.visible {
    animation: fadeInUp 0.6s ease forwards;
}

.stagger-item:nth-child(1) { animation-delay: 0.1s; }
.stagger-item:nth-child(2) { animation-delay: 0.2s; }
.stagger-item:nth-child(3) { animation-delay: 0.3s; }
.stagger-item:nth-child(4) { animation-delay: 0.4s; }
.stagger-item:nth-child(5) { animation-delay: 0.5s; }
.stagger-item:nth-child(6) { animation-delay: 0.6s; }
.stagger-item:nth-child(7) { animation-delay: 0.7s; }
.stagger-item:nth-child(8) { animation-delay: 0.8s; }

/* =====================================================
   HOVER EFFECTS
   ===================================================== */

/* Scale on Hover */
.hover-scale {
    transition: transform 0.3s ease;
}

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

/* Lift on Hover */
.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

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

.hover-glow:hover {
    box-shadow: 0 0 30px rgba(0, 102, 204, 0.5);
}

/* Rotate on Hover */
.hover-rotate {
    transition: transform 0.3s ease;
}

.hover-rotate:hover {
    transform: rotate(5deg);
}

/* Color Change on Hover */
.hover-color-change {
    transition: color 0.3s ease, background-color 0.3s ease;
}

/* Border Animation on Hover */
.hover-border-animate {
    position: relative;
}

.hover-border-animate::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    transition: width 0.3s ease;
}

.hover-border-animate:hover::after {
    width: 100%;
}

/* Image Hover Effects */
.img-hover-zoom {
    overflow: hidden;
}

.img-hover-zoom img {
    transition: transform 0.5s ease;
}

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

.img-hover-brightness {
    transition: filter 0.3s ease;
}

.img-hover-brightness:hover {
    filter: brightness(1.2);
}

/* =====================================================
   PARALLAX EFFECTS
   ===================================================== */

.parallax-bg {
    background-attachment: fixed;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
}

.parallax-slow {
    transform: translateY(calc(var(--scroll-y, 0) * 0.3px));
}

.parallax-medium {
    transform: translateY(calc(var(--scroll-y, 0) * 0.5px));
}

.parallax-fast {
    transform: translateY(calc(var(--scroll-y, 0) * 0.7px));
}

/* =====================================================
   LOADING ANIMATIONS
   ===================================================== */

.loader-dots {
    display: flex;
    gap: 8px;
}

.loader-dots span {
    width: 12px;
    height: 12px;
    background-color: var(--color-primary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loader-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.loader-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

.loader-pulse {
    width: 40px;
    height: 40px;
    margin: 0 auto;
    background-color: var(--color-primary);
    border-radius: 100%;
    animation: pulse 1s infinite ease-in-out;
}

.loader-ring {
    width: 40px;
    height: 40px;
    margin: 0 auto;
    border: 4px solid var(--color-gray-300);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s infinite linear;
}

.loader-double {
    width: 40px;
    height: 40px;
    margin: 0 auto;
    border: 4px solid var(--color-primary);
    border-radius: 50%;
    opacity: 0.8;
    animation: pulse 1s infinite ease-in-out;
}

.loader-double::before,
.loader-double::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border: 4px solid transparent;
    border-top-color: var(--color-secondary);
    border-radius: 50%;
    animation: spin 1.5s infinite linear reverse;
}

/* =====================================================
   TEXT ANIMATIONS
   ===================================================== */

.text-reveal {
    overflow: hidden;
}

.text-reveal span {
    display: inline-block;
    transform: translateY(100%);
    animation: textReveal 0.8s forwards;
}

@keyframes textReveal {
    to {
        transform: translateY(0);
    }
}

/* Typewriter Effect */
.typewriter {
    overflow: hidden;
    white-space: nowrap;
    border-right: 3px solid var(--color-primary);
    animation: typing 3.5s steps(40, end), blink 0.75s step-end infinite;
}

/* Gradient Text Animation */
.gradient-text {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 50%, var(--color-accent) 100%);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 3s ease infinite;
}

/* =====================================================
   BUTTON ANIMATIONS
   ===================================================== */

.btn-animate {
    position: relative;
    overflow: hidden;
}

.btn-animate::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.btn-animate:hover::before {
    width: 300px;
    height: 300px;
}

/* Button Ripple Effect */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple span {
    position: absolute;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.5);
    transform: scale(0);
    animation: ripple 0.6s linear;
    pointer-events: none;
}

/* =====================================================
   CARD ANIMATIONS
   ===================================================== */

.card-flip {
    perspective: 1000px;
}

.card-flip-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.card-flip:hover .card-flip-inner {
    transform: rotateY(180deg);
}

.card-flip-front,
.card-flip-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
}

.card-flip-back {
    transform: rotateY(180deg);
}

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

.card-shine::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.3) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    transform: rotate(30deg);
    transition: transform 0.6s;
    pointer-events: none;
}

.card-shine:hover::before {
    transform: rotate(30deg) translateX(100%);
}

/* =====================================================
   MENU ANIMATIONS
   ===================================================== */

.menu-item-animate {
    opacity: 0;
    transform: translateX(-20px);
    animation: slideInLeft 0.5s forwards;
}

.menu-item-animate:nth-child(1) { animation-delay: 0.1s; }
.menu-item-animate:nth-child(2) { animation-delay: 0.2s; }
.menu-item-animate:nth-child(3) { animation-delay: 0.3s; }
.menu-item-animate:nth-child(4) { animation-delay: 0.4s; }
.menu-item-animate:nth-child(5) { animation-delay: 0.5s; }
.menu-item-animate:nth-child(6) { animation-delay: 0.6s; }

/* Mobile Menu Animation */
.mobile-menu-animate {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.mobile-menu-animate.active {
    transform: translateX(0);
}

/* =====================================================
   DECORATIVE ANIMATIONS
   ===================================================== */

/* Floating Particles */
.particle {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: var(--color-primary);
    border-radius: 50%;
    opacity: 0.5;
    animation: particleFloat 5s infinite ease-in-out;
}

/* Rotating Circle */
.rotating-circle {
    position: absolute;
    width: 100px;
    height: 100px;
    border: 3px solid transparent;
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 3s linear infinite;
}

.rotating-circle::before {
    content: '';
    position: absolute;
    top: 5px;
    left: 5px;
    right: 5px;
    bottom: 5px;
    border: 3px solid transparent;
    border-top-color: var(--color-secondary);
    border-radius: 50%;
    animation: spin 2s linear infinite reverse;
}

/* Pulsing Dot */
.pulsing-dot {
    position: relative;
}

.pulsing-dot::before,
.pulsing-dot::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
}

.pulsing-dot::before {
    width: 100%;
    height: 100%;
    background-color: var(--color-primary);
    animation: pulse 2s infinite;
}

.pulsing-dot::after {
    width: 60%;
    height: 60%;
    background-color: var(--color-secondary);
    animation: pulse 2s infinite 0.5s;
}

/* =====================================================
   NUMBER COUNTER ANIMATION
   ===================================================== */

.counter {
    display: inline-block;
    font-variant-numeric: tabular-nums;
}

.counter-animate {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s ease;
}

.counter-animate.visible {
    opacity: 1;
    transform: translateY(0);
}

/* =====================================================
   SKELETON LOADING
   ===================================================== */

.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-gray-200) 0%,
        var(--color-gray-100) 50%,
        var(--color-gray-200) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.skeleton-text {
    height: 1em;
    border-radius: 4px;
    margin-bottom: 0.5em;
}

.skeleton-title {
    height: 1.5em;
    width: 60%;
    border-radius: 4px;
    margin-bottom: 1em;
}

.skeleton-image {
    height: 200px;
    border-radius: var(--radius-lg);
}

/* =====================================================
   SCROLL PROGRESS BAR
   ===================================================== */

.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 4px;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    z-index: 10000;
    transition: width 0.1s ease;
}

/* =====================================================
   MOUSE FOLLOWER
   ===================================================== */

.mouse-follower {
    position: fixed;
    width: 40px;
    height: 40px;
    border: 2px solid var(--color-primary);
    border-radius: 50%;
    pointer-events: none;
    transition: transform 0.1s ease, width 0.2s ease, height 0.2s ease;
    z-index: 9999;
    mix-blend-mode: difference;
}

.mouse-follower.active {
    transform: scale(0.8);
    background-color: rgba(0, 102, 204, 0.2);
}

/* =====================================================
   SPECIAL SCROLL EFFECTS
   ===================================================== */

/* Smooth Scroll Reveal */
[data-scroll] {
    transition: opacity 0.6s ease, transform 0.6s ease;
}

[data-scroll="in"] {
    opacity: 1;
    transform: translateY(0);
}

[data-scroll="out"] {
    opacity: 0;
    transform: translateY(50px);
}

/* Parallax Container */
.parallax-container {
    perspective: 1px;
    overflow-x: hidden;
    overflow-y: auto;
}

.parallax-layer {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
}

.parallax-layer-back {
    transform: translateZ(-1px) scale(2);
}

/* =====================================================
   AUDI-STYLE ANIMATIONS
   ===================================================== */

/* Hero Animation Sequence */
.hero-animate {
    opacity: 0;
    transform: translateY(40px);
}

.hero-animate.visible {
    animation: heroReveal 1s ease forwards;
}

.hero-animate:nth-child(1) { animation-delay: 0.2s; }
.hero-animate:nth-child(2) { animation-delay: 0.4s; }
.hero-animate:nth-child(3) { animation-delay: 0.6s; }
.hero-animate:nth-child(4) { animation-delay: 0.8s; }
.hero-animate:nth-child(5) { animation-delay: 1s; }

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

/* Line Draw Animation */
.line-draw {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: dash 2s forwards;
}

/* Page Transition */
.page-transition {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--color-dark);
    z-index: 10001;
    transform: translateX(-100%);
}

.page-transition.active {
    animation: pageSlideIn 0.5s ease forwards;
}

.page-transition.exit {
    animation: pageSlideOut 0.5s ease forwards;
}

@keyframes pageSlideIn {
    to {
        transform: translateX(0);
    }
}

@keyframes pageSlideOut {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(100%);
    }
}

/* =====================================================
   UTILITIES
   ===================================================== */

.animate-delay-1 { animation-delay: 0.1s; }
.animate-delay-2 { animation-delay: 0.2s; }
.animate-delay-3 { animation-delay: 0.3s; }
.animate-delay-4 { animation-delay: 0.4s; }
.animate-delay-5 { animation-delay: 0.5s; }

.animate-duration-fast { animation-duration: 0.3s; }
.animate-duration-normal { animation-duration: 0.6s; }
.animate-duration-slow { animation-duration: 1s; }

.animate-infinite { animation-iteration-count: infinite; }
.animate-alternate { animation-direction: alternate; }
.animate-reverse { animation-direction: reverse; }
