/* ================================
   Animations & Transitions
   ================================ */

/* ===== 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);
    }
}

/* Fade Classes */
.fade-in {
    animation: fadeIn 0.6s ease-out;
}

.fade-in-up {
    animation: fadeInUp 0.6s ease-out;
}

.fade-in-down {
    animation: fadeInDown 0.6s ease-out;
}

.fade-in-left {
    animation: fadeInLeft 0.6s ease-out;
}

.fade-in-right {
    animation: fadeInRight 0.6s ease-out;
}

/* Stagger children animations */
.animate-children>* {
    opacity: 0;
    animation: fadeInUp 0.6s ease-out forwards;
}

.animate-children>*:nth-child(1) {
    animation-delay: 0.1s;
}

.animate-children>*:nth-child(2) {
    animation-delay: 0.2s;
}

.animate-children>*:nth-child(3) {
    animation-delay: 0.3s;
}

.animate-children>*:nth-child(4) {
    animation-delay: 0.4s;
}

.animate-children>*:nth-child(5) {
    animation-delay: 0.5s;
}

.animate-children>*:nth-child(6) {
    animation-delay: 0.6s;
}

.animate-children>*:nth-child(7) {
    animation-delay: 0.7s;
}

.animate-children>*:nth-child(8) {
    animation-delay: 0.8s;
}

/* ===== Scroll Reveal Animation ===== */
.scroll-reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

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

/* ===== Pulse Animation ===== */
@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

.pulse {
    animation: pulse 2s ease-in-out infinite;
}

/* ===== Scale Animation ===== */
@keyframes scaleIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.scale-in {
    animation: scaleIn 0.4s ease-out;
}

/* ===== Bounce Animation ===== */
@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-20px);
    }

    60% {
        transform: translateY(-10px);
    }
}

.bounce {
    animation: bounce 1.5s ease infinite;
}

/* ===== Shake Animation ===== */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-5px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(5px);
    }
}

.shake {
    animation: shake 0.5s ease;
}

/* ===== Rotate Animation ===== */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.rotate {
    animation: rotate 2s linear infinite;
}

/* ===== Shimmer Effect ===== */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }

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

.shimmer {
    background: linear-gradient(to right,
            var(--color-gray-light) 0%,
            #e0e0e0 20%,
            var(--color-gray-light) 40%,
            var(--color-gray-light) 100%);
    background-size: 1000px 100%;
    animation: shimmer 2s linear infinite;
}

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

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.gradient-animate {
    background-size: 200% 200%;
    animation: gradient 3s ease infinite;
}

/* ===== Hover Effects ===== */
.hover-lift {
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.hover-lift:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-2xl);
}

.hover-scale {
    transition: transform var(--transition-base);
}

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

.hover-brightness {
    transition: filter var(--transition-base);
}

.hover-brightness:hover {
    filter: brightness(1.1);
}

.hover-glow {
    transition: box-shadow var(--transition-base);
}

.hover-glow:hover {
    box-shadow: 0 0 20px rgba(220, 20, 60, 0.5);
}

/* ===== Loading Animations ===== */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--color-gray-light);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-small {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.spinner-large {
    width: 60px;
    height: 60px;
    border-width: 6px;
}

.dots-loading {
    display: flex;
    gap: var(--spacing-sm);
}

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

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

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

@keyframes bounce-dot {

    0%,
    80%,
    100% {
        transform: scale(0);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ===== Progress Bar ===== */
@keyframes progress {
    from {
        width: 0%;
    }
}

.progress-bar {
    height: 4px;
    background-color: var(--color-gray-light);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
    border-radius: var(--radius-full);
    animation: progress 1.5s ease-out;
    transition: width var(--transition-slow);
}

/* ===== Map Animations ===== */
@keyframes mapPulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.7;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.map-marker {
    animation: mapPulse 2s ease-in-out infinite;
}

/* Province hover effect */
.province-path {
    transition: fill var(--transition-base), stroke var(--transition-fast);
    cursor: pointer;
}

.province-path:hover {
    fill: var(--color-primary-light);
    stroke: var(--color-primary);
    stroke-width: 2;
}

/* ===== Tooltip Animations ===== */
@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -5px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

.tooltip {
    position: absolute;
    background-color: var(--color-dark);
    color: var(--color-white);
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    white-space: nowrap;
    pointer-events: none;
    z-index: var(--z-tooltip);
    animation: tooltipFadeIn 0.2s ease-out;
}

/* ===== Modal Animations ===== */
@keyframes modalFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

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

.modal-backdrop {
    animation: modalFadeIn 0.3s ease-out;
}

.modal-content {
    animation: modalSlideIn 0.3s ease-out;
}

/* ===== Scroll Indicators ===== */
@keyframes scrollIndicator {
    0% {
        transform: translateY(0);
        opacity: 1;
    }

    100% {
        transform: translateY(10px);
        opacity: 0;
    }
}

.scroll-indicator {
    animation: scrollIndicator 1.5s ease-in-out infinite;
}

/* ===== Number Counter Animation ===== */
@property --num {
    syntax: '<integer>';
    initial-value: 0;
    inherits: false;
}

.counter {
    animation: counter 2s ease-out;
    counter-reset: num var(--num);
}

.counter::after {
    content: counter(num);
}

@keyframes counter {
    from {
        --num: 0;
    }
}

/* ===== Parallax Effect ===== */
.parallax {
    will-change: transform;
    transition: transform 0.1s ease-out;
}

/* ===== Glassmorphism Effect ===== */
.glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
}

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

/* ===== Underline Effect ===== */
.underline-animate {
    position: relative;
    display: inline-block;
}

.underline-animate::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--color-primary);
    transition: width var(--transition-base);
}

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