/**
 * Karuna Commons - Microanimations
 * 
 * Subtle animations to add polish and improve UX.
 * All animations respect prefers-reduced-motion.
 */

/* =========================
   Respect Reduced Motion
   ========================= */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}


/* =========================
   Fade In on Load
   ========================= */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page-content {
    animation: fadeIn 0.4s ease-out;
}


/* =========================
   Card Hover Effects
   ========================= */

/* Card Hover Effects - Only for interactive cards */
.card-link:hover .card,
a.card:hover,
button.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

/* Image zoom on card hover */
.card-image {
    transition: transform 0.3s ease;
    overflow: hidden;
}

.card-link:hover .card .card-image,
a.card:hover .card-image,
button.card:hover .card-image {
    transform: scale(1.03);
}


/* =========================
   Button Effects
   ========================= */

.btn {
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

/* Ripple effect base */
.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 60%);
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.3s, transform 0.3s;
}

.btn:active::after {
    opacity: 1;
    transform: scale(2);
    transition: opacity 0s, transform 0s;
}


/* =========================
   Link Underline Animation
   ========================= */

.article-body a:not(.btn):not(.card) {
    position: relative;
    text-decoration: none;
}

.article-body a:not(.btn):not(.card):hover {
    text-decoration: none;
}

.article-body a:not(.btn):not(.card)::before {
    content: '';
    position: absolute;
    left: 0;
    bottom: -6px;
    width: 100%;
    height: 1px;
    background-color: currentColor;
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.25s ease;
}

.article-body a:not(.btn):not(.card):hover::before {
    transform: scaleX(1);
    transform-origin: left;
}


/* =========================
   Icon Hover Effects
   ========================= */

/* Bounce on hover for action icons */
.fa-heart:hover,
.fa-paw:hover {
    animation: iconBounce 0.4s ease;
}

@keyframes iconBounce {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }
}


/* =========================
   Dropdown Animation
   ========================= */

.dropdown {
    transform-origin: top center;
    animation: dropdownSlide 0.15s ease-out;
}

@keyframes dropdownSlide {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}


/* =========================
   Callout Attention
   ========================= */

.callout {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.callout:hover {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px var(--color-primary-light, rgba(37, 99, 235, 0.1));
}


/* =========================
   List Item Stagger
   ========================= */

.sitemap-section ul li,
.check-list li {
    opacity: 0;
    animation: staggerFadeIn 0.3s ease forwards;
}

.sitemap-section ul li:nth-child(1) {
    animation-delay: 0.05s;
}

.sitemap-section ul li:nth-child(2) {
    animation-delay: 0.1s;
}

.sitemap-section ul li:nth-child(3) {
    animation-delay: 0.15s;
}

.sitemap-section ul li:nth-child(4) {
    animation-delay: 0.2s;
}

.sitemap-section ul li:nth-child(5) {
    animation-delay: 0.25s;
}

.sitemap-section ul li:nth-child(n+6) {
    animation-delay: 0.3s;
}

@keyframes staggerFadeIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}


/* =========================
   Back to Top Animation
   ========================= */

.back-to-top {
    transition: all 0.3s ease;
}

.back-to-top:hover {
    transform: translateY(-4px) scale(1.05);
}


/* =========================
   Hero Section Animation
   ========================= */

.hero h1 {
    animation: heroTextIn 0.6s ease-out;
}

.hero p {
    animation: heroTextIn 0.6s ease-out 0.1s both;
}

.hero .btn {
    animation: heroTextIn 0.6s ease-out 0.2s both;
}

@keyframes heroTextIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* =========================
   Smooth Focus States
   ========================= */

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    transition: outline-offset 0.15s ease;
}

a:focus-visible:not(:active) {
    outline-offset: 4px;
}


/* =========================
   Loading Skeleton
   ========================= */

.skeleton {
    background: linear-gradient(90deg,
            var(--color-surface) 25%,
            var(--color-surface-alt) 50%,
            var(--color-surface) 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s infinite;
}

@keyframes skeletonShimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}