/* 
* Literario - The Literature Club
* Animations Stylesheet
*/

/* ===== KEYFRAMES ANIMATIONS ===== */

/* Quill Writing Animation */
@keyframes quillWrite {
    0% {
        transform: translateX(-100px) rotate(5deg);
    }
    20% {
        transform: translateX(-50px) rotate(0deg);
    }
    40% {
        transform: translateX(0) rotate(-5deg);
    }
    60% {
        transform: translateX(50px) rotate(0deg);
    }
    80% {
        transform: translateX(100px) rotate(5deg);
    }
    100% {
        transform: translateX(-100px) rotate(5deg);
    }
}

@keyframes inkTrail {
    0% {
        width: 0;
        left: 30%;
    }
    20% {
        width: 20%;
        left: 40%;
    }
    40% {
        width: 40%;
        left: 50%;
    }
    60% {
        width: 60%;
        left: 60%;
    }
    80% {
        width: 80%;
        left: 70%;
    }
    100% {
        width: 0;
        left: 30%;
    }
}

/* Bounce Animation for Scroll Indicator */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

/* Fade In Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Slide In Animation */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Pulse Animation */
@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

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

/* Typewriter Animation */
@keyframes typewriter {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blinkCursor {
    from, to {
        border-color: transparent;
    }
    50% {
        border-color: var(--secondary-color);
    }
}

/* Ink Drop Animation */
@keyframes inkDrop {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(20);
        opacity: 0;
    }
}

/* Page Turn Animation */
@keyframes pageTurn {
    0% {
        transform: rotateY(0deg);
    }
    100% {
        transform: rotateY(180deg);
    }
}

/* ===== ANIMATION CLASSES ===== */

/* Animated Text */
.animate-text {
    opacity: 0;
    animation: fadeIn 1s ease forwards;
}

.animate-text:nth-child(1) {
    animation-delay: 0.3s;
}

.animate-text:nth-child(2) {
    animation-delay: 0.6s;
}

.animate-text:nth-child(3) {
    animation-delay: 0.9s;
}

/* Slide In Animation */
.slide-in {
    opacity: 0;
}

.slide-in.active {
    animation: slideIn 0.8s ease forwards;
}

/* Fade In Animation */
.fade-in {
    opacity: 0;
}

.fade-in.active {
    animation: fadeIn 0.8s ease forwards;
}

/* Pulse Animation */
.pulse {
    animation: pulse 2s infinite ease-in-out;
}

/* Float Animation */
.float {
    animation: float 3s infinite ease-in-out;
}

/* Typewriter Animation */
.typewriter {
    overflow: hidden;
    white-space: nowrap;
    margin: 0 auto;
    border-right: 3px solid var(--secondary-color);
    animation: 
        typewriter 4s steps(40, end) 1s forwards,
        blinkCursor 0.75s step-end infinite;
}

/* Ink Drop Animation */
.ink-drop {
    position: absolute;
    width: 5px;
    height: 5px;
    background-color: var(--primary-color);
    border-radius: 50%;
    transform-origin: center;
    pointer-events: none;
}

.ink-drop.animate {
    animation: inkDrop 1s ease-out forwards;
}

/* Page Turn Animation */
.page-turn {
    perspective: 1000px;
}

.page-turn-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.8s;
    transform-style: preserve-3d;
}

.page-turn:hover .page-turn-inner {
    animation: pageTurn 1.5s ease forwards;
}

/* Feather Pen Cursor */
.feather-cursor {
    cursor: url('../images/feather-cursor.png'), auto;
}

/* Scroll Triggered Animations */
.scroll-animate {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

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

/* Staggered Animation for Multiple Elements */
.stagger-animate > * {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.stagger-animate.active > *:nth-child(1) {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.1s;
}

.stagger-animate.active > *:nth-child(2) {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.2s;
}

.stagger-animate.active > *:nth-child(3) {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.3s;
}

.stagger-animate.active > *:nth-child(4) {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.4s;
}

.stagger-animate.active > *:nth-child(5) {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.5s;
}

/* Reveal Animation */
.reveal {
    position: relative;
    overflow: hidden;
}

.reveal::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--primary-color);
    transform: translateX(-100%);
    transition: transform 0.5s ease;
}

.reveal.active::after {
    transform: translateX(100%);
}

/* Book Tilt Animation */
.book-tilt {
    transition: transform 0.3s ease;
    transform-origin: bottom center;
}

.book-tilt:hover {
    transform: rotate(-5deg) translateY(-10px);
}

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

.shine::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.3), transparent);
    transform: skewX(-25deg);
    transition: left 0.75s ease;
}

.shine:hover::before {
    left: 150%;
}

/* Parchment Unfolding Animation */
.parchment-unfold {
    transform-origin: top center;
    transform: perspective(800px) rotateX(-90deg);
    opacity: 0;
    transition: transform 1s ease, opacity 1s ease;
}

.parchment-unfold.active {
    transform: perspective(800px) rotateX(0);
    opacity: 1;
}

/* Ink Writing Animation for Text */
.ink-writing {
    position: relative;
    color: transparent;
    overflow: hidden;
}

.ink-writing::before {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    color: var(--primary-color);
    overflow: hidden;
    white-space: nowrap;
    animation: typewriter 4s steps(100, end) forwards;
}

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

.ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1);
    animation: ripple 1s ease-out;
}

@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(40);
        opacity: 0;
    }
}

/* Mandala Rotation */
.mandala-rotate {
    animation: rotate 20s linear infinite;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}
