/* ============================================
   Turn The Page Club - Animations
   Bookmark effects, page curls, transitions
   ============================================ */

/* ============================================
   Keyframe Animations
   ============================================ */

/* Fade in from bottom */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade in from left */
@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Fade in from right */
@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

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

/* Gentle float animation for decorative elements */
@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Bookmark ribbon sway */
@keyframes ribbonSway {
    0%, 100% {
        transform: translateX(-50%) rotate(0deg);
    }
    25% {
        transform: translateX(-50%) rotate(2deg);
    }
    75% {
        transform: translateX(-50%) rotate(-2deg);
    }
}

/* Pulse animation for CTAs */
@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(139, 38, 53, 0.4);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(139, 38, 53, 0);
    }
}

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

/* Book page turn effect */
@keyframes pageTurn {
    0% {
        transform: perspective(1000px) rotateY(0deg);
    }
    100% {
        transform: perspective(1000px) rotateY(-180deg);
    }
}

/* Typewriter effect for hero text */
@keyframes typewriter {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

/* Blink cursor */
@keyframes blink {
    0%, 100% {
        border-color: transparent;
    }
    50% {
        border-color: var(--color-primary);
    }
}

/* Count up animation helper */
@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   Scroll-triggered Animations
   ============================================ */

/* Elements with these classes will animate when visible */
.animate-on-scroll {
    opacity: 0;
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-on-scroll.animate-fade-up {
    transform: translateY(30px);
}

.animate-on-scroll.animate-fade-left {
    transform: translateX(-30px);
}

.animate-on-scroll.animate-fade-right {
    transform: translateX(30px);
}

.animate-on-scroll.animate-scale {
    transform: scale(0.9);
}

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

/* Staggered animation delays for lists */
.stagger-children > *:nth-child(1) { transition-delay: 0.1s; }
.stagger-children > *:nth-child(2) { transition-delay: 0.2s; }
.stagger-children > *:nth-child(3) { transition-delay: 0.3s; }
.stagger-children > *:nth-child(4) { transition-delay: 0.4s; }
.stagger-children > *:nth-child(5) { transition-delay: 0.5s; }
.stagger-children > *:nth-child(6) { transition-delay: 0.6s; }

/* ============================================
   Bookmark Navigation Animations
   ============================================ */

/* Ribbon tail sway on hover */
.nav-link:hover::after {
    animation: ribbonSway 0.5s ease-in-out;
}

/* Active bookmark bounce */
.nav-link.active {
    animation: fadeInUp 0.3s ease;
}

/* ============================================
   Button Animations
   ============================================ */

/* Pulse effect for primary CTA */
.btn-pulse {
    animation: pulse 2s infinite;
}

/* Icon spin on hover */
.btn-icon-spin:hover svg {
    animation: spin 0.5s ease;
}

/* ============================================
   Card Hover Effects
   ============================================ */

/* Book spine slide effect */
.card-book::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    background: var(--color-accent);
    transition: width var(--transition-normal);
}

.card-book:hover::after {
    width: 8px;
}

/* Page curl effect on cards */
.card-page-curl {
    position: relative;
    overflow: hidden;
}

.card-page-curl::before {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 0;
    height: 0;
    background: linear-gradient(135deg, transparent 50%, var(--color-secondary-dark) 50%);
    transition: all var(--transition-normal);
}

.card-page-curl:hover::before {
    width: 30px;
    height: 30px;
    box-shadow: -2px -2px 5px rgba(0, 0, 0, 0.1);
}

/* ============================================
   Floating Book Decorations
   ============================================ */

.floating-book {
    animation: float 4s ease-in-out infinite;
}

.floating-book:nth-child(2) {
    animation-delay: 0.5s;
}

.floating-book:nth-child(3) {
    animation-delay: 1s;
}

.floating-book:nth-child(4) {
    animation-delay: 1.5s;
}

/* ============================================
   Hero Section Animations
   ============================================ */

.hero-content {
    animation: fadeInUp 0.8s ease;
}

.hero-tagline {
    animation: fadeInLeft 0.6s ease;
}

.hero h1 {
    animation: fadeInUp 0.8s ease 0.2s both;
}

.hero p {
    animation: fadeInUp 0.8s ease 0.4s both;
}

.hero-buttons {
    animation: fadeInUp 0.8s ease 0.6s both;
}

.hero-decoration {
    animation: fadeIn 1s ease 0.5s both;
}

/* ============================================
   Stats Counter Animation
   ============================================ */

.stat-item {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.6s ease;
}

.stat-item.visible {
    opacity: 1;
    transform: translateY(0);
}

.stat-number {
    display: inline-block;
}

.stat-number.counting {
    animation: countUp 0.3s ease;
}

/* ============================================
   Form Animations
   ============================================ */

/* Focus animation */
.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    animation: scaleIn 0.2s ease;
}

/* Error shake */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.form-group.error .form-input,
.form-group.error .form-textarea {
    animation: shake 0.3s ease;
}

/* Success checkmark */
.form-success {
    animation: fadeInUp 0.5s ease;
}

/* ============================================
   Page Transitions
   ============================================ */

/* Page load animation */
.page-transition {
    animation: fadeIn 0.5s ease;
}

/* Section transitions */
.section {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

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

/* ============================================
   Loading States
   ============================================ */

.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--color-secondary);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ============================================
   Testimonial Carousel Animations
   ============================================ */

.testimonial-card {
    animation: fadeIn 0.5s ease;
}

.testimonial-card.slide-in-left {
    animation: fadeInLeft 0.5s ease;
}

.testimonial-card.slide-in-right {
    animation: fadeInRight 0.5s ease;
}

/* ============================================
   Timeline Animations
   ============================================ */

.timeline-item {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s ease;
}

.timeline-item.visible {
    opacity: 1;
    transform: translateY(0);
}

.timeline-item:nth-child(even) {
    transform: translateX(-30px);
}

.timeline-item:nth-child(even).visible {
    transform: translateX(0);
}

/* ============================================
   Mobile Menu Animations
   ============================================ */

.nav-list.mobile-open {
    animation: fadeIn 0.3s ease;
}

.nav-list.mobile-open .nav-item {
    animation: fadeInUp 0.3s ease both;
}

.nav-list.mobile-open .nav-item:nth-child(1) { animation-delay: 0.1s; }
.nav-list.mobile-open .nav-item:nth-child(2) { animation-delay: 0.15s; }
.nav-list.mobile-open .nav-item:nth-child(3) { animation-delay: 0.2s; }
.nav-list.mobile-open .nav-item:nth-child(4) { animation-delay: 0.25s; }
.nav-list.mobile-open .nav-item:nth-child(5) { animation-delay: 0.3s; }
.nav-list.mobile-open .nav-item:nth-child(6) { animation-delay: 0.35s; }

/* ============================================
   Reduced Motion
   ============================================ */

@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;
    }

    .floating-book {
        animation: none;
    }
}
