/**
 * Bharatank - Public Page Animations
 * Subtle, smooth micro-animations for enhanced UX
 */

/* Keyframe Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Page Load Animation */
body.public-page main {
    animation: fadeIn 0.4s ease-out;
}

/* Hero Section Animation */
body.public-page .hero-content {
    animation: fadeInUp 0.5s ease-out;
}

body.public-page .hero-title {
    animation: fadeInUp 0.5s ease-out 0.1s both;
}

body.public-page .hero-subtitle {
    animation: fadeInUp 0.5s ease-out 0.2s both;
}

body.public-page .search-box {
    animation: fadeInUp 0.5s ease-out 0.3s both;
}

body.public-page .trust-badges {
    animation: fadeInUp 0.5s ease-out 0.4s both;
}

/* Scroll Reveal Classes */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-on-scroll.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger Animation for Grid Items */
.animate-stagger>* {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.animate-stagger.is-visible>*:nth-child(1) {
    transition-delay: 0.05s;
}

.animate-stagger.is-visible>*:nth-child(2) {
    transition-delay: 0.1s;
}

.animate-stagger.is-visible>*:nth-child(3) {
    transition-delay: 0.15s;
}

.animate-stagger.is-visible>*:nth-child(4) {
    transition-delay: 0.2s;
}

.animate-stagger.is-visible>*:nth-child(5) {
    transition-delay: 0.25s;
}

.animate-stagger.is-visible>*:nth-child(6) {
    transition-delay: 0.3s;
}

.animate-stagger.is-visible>*:nth-child(7) {
    transition-delay: 0.35s;
}

.animate-stagger.is-visible>*:nth-child(8) {
    transition-delay: 0.4s;
}

.animate-stagger.is-visible>*:nth-child(9) {
    transition-delay: 0.45s;
}

.animate-stagger.is-visible>*:nth-child(10) {
    transition-delay: 0.5s;
}

.animate-stagger.is-visible>* {
    opacity: 1;
    transform: translateY(0);
}

/* Card Hover Effects */
body.public-page .card {
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

body.public-page .card:hover {
    transform: translateY(-4px);
}

body.public-page .institution-card {
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

body.public-page .institution-card:hover {
    transform: translateY(-6px);
}

/* Button Transitions */
body.public-page .btn {
    transition: all 0.2s ease;
}

body.public-page .btn:active {
    transform: scale(0.98);
}

/* Search Box Focus Animation */
body.public-page .search-box input {
    transition: box-shadow 0.3s ease, border-color 0.3s ease, transform 0.2s ease;
}

body.public-page .search-box input:focus {
    transform: scale(1.01);
}

/* Search Dropdown Animation - Handled in style.css */
/* No additional overrides needed here */

/* Search Item Hover */
body.public-page .search-item {
    transition: background-color 0.15s ease;
}

/* Feature Icon Hover */
body.public-page .feature-icon {
    transition: transform 0.3s ease, background-color 0.3s ease;
}

body.public-page .feature-card:hover .feature-icon {
    transform: scale(1.1);
}

/* Trust Badge Number Counter Effect */
body.public-page .trust-badge-number {
    transition: transform 0.3s ease;
}

body.public-page .trust-badge:hover .trust-badge-number {
    transform: scale(1.05);
}

/* Link Underline Animation */
body.public-page a.animated-link {
    position: relative;
    display: inline-block;
}

body.public-page a.animated-link::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -2px;
    left: 0;
    background: var(--accent-primary);
    transition: width 0.3s ease;
}

body.public-page a.animated-link:hover::after {
    width: 100%;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg,
            var(--bg-secondary) 25%,
            var(--bg-tertiary) 50%,
            var(--bg-secondary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-text:last-child {
    width: 60%;
}

.skeleton-card {
    height: 200px;
}

.skeleton-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

/* Loading Spinner */
.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-sm {
    width: 16px;
    height: 16px;
}

.spinner-lg {
    width: 40px;
    height: 40px;
    border-width: 3px;
}

/* Icon Spin Animation */
.animate-spin {
    animation: spin 1s linear infinite;
}

/* Load More Button Pulse */
.load-more-btn {
    transition: all 0.3s ease;
}

.load-more-btn:hover {
    box-shadow: 0 0 0 4px rgba(26, 115, 232, 0.15);
}

.load-more-btn.loading {
    pointer-events: none;
    opacity: 0.7;
}

/* Nearby Section Animation */
.nearby-section {
    animation: fadeInUp 0.5s ease-out 0.5s both;
}

.nearby-section .institution-card {
    opacity: 0;
    animation: fadeInUp 0.4s ease-out forwards;
}

.nearby-section .institution-card:nth-child(1) {
    animation-delay: 0.1s;
}

.nearby-section .institution-card:nth-child(2) {
    animation-delay: 0.15s;
}

.nearby-section .institution-card:nth-child(3) {
    animation-delay: 0.2s;
}

.nearby-section .institution-card:nth-child(4) {
    animation-delay: 0.25s;
}

.nearby-section .institution-card:nth-child(5) {
    animation-delay: 0.3s;
}

.nearby-section .institution-card:nth-child(6) {
    animation-delay: 0.35s;
}

.nearby-section .institution-card:nth-child(7) {
    animation-delay: 0.4s;
}

.nearby-section .institution-card:nth-child(8) {
    animation-delay: 0.45s;
}

.nearby-section .institution-card:nth-child(9) {
    animation-delay: 0.5s;
}

.nearby-section .institution-card:nth-child(10) {
    animation-delay: 0.55s;
}

/* Alert Slide In */
body.public-page .alert {
    animation: slideInRight 0.3s ease-out;
}

/* Form Focus Animation */
body.public-page .form-group {
    transition: transform 0.2s ease;
}

body.public-page .form-control:focus {
    animation: scaleIn 0.2s ease;
}

/* Avatar Hover */
body.public-page .avatar {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

body.public-page .avatar:hover {
    transform: scale(1.05);
}

/* Mobile Menu Animation */
body.public-page .mobile-menu {
    transition: transform 0.3s ease;
}

body.public-page .mobile-overlay {
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Reduced Motion Preference */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .animate-on-scroll {
        opacity: 1;
        transform: none;
    }

    .animate-stagger>* {
        opacity: 1;
        transform: none;
    }
}