/* animations.css - File CSS chứa các animation */

/* Common animation container styling for both Three.js and Canvas animations */
.animation-container {
    margin: 0;
    background: #ffffff;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 550px; /* Kích thước cố định để tạo hình vuông */
    height: 550px; /* Kích thước cố định để tạo hình vuông */
    position: relative;
    margin: 2rem auto;
    border-radius: 5px;
    box-shadow: 0 5px 20px var(--shadow-color);
}

/* Canvas specific styling for chapter 2 tessellation */
.animation-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Responsive design cho animation */
@media (max-width: 600px) {
    .animation-container {
        width: 350px;
        height: 350px;
    }
}

/* Loader hiển thị trong khi loading Three.js */
.animation-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    color: var(--secondary-color);
    background: #ffffff;
    z-index: 10;
    transition: opacity 0.5s ease;
}

/* Hiệu ứng cho loading text */
.loading-text {
    position: relative;
    display: inline-block;
}

.loading-text::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -3px;
    left: 0;
    background-color: var(--accent-color);
    animation: loadingProgress 2s infinite ease-in-out;
}

@keyframes loadingProgress {
    0% { width: 0; left: 0; }
    50% { width: 100%; left: 0; }
    100% { width: 0; left: 100%; }
}

/* Fade in từ từ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-15px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(15px); }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInFromRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Áp dụng animation cho các phần tử */
.fade-in {
    animation: fadeIn 1.2s ease-in-out forwards;
}

.fade-in-delayed {
    opacity: 0;
    animation: fadeIn 1.2s ease-in-out forwards;
    animation-delay: 0.3s;
}

.fade-in-up {
    opacity: 0;
    animation: fadeInUp 1s ease-out forwards;
}

/* Animation cho verse */
.verse {
    opacity: 0;
    animation: fadeInUp 0.8s ease-out forwards;
}

/* Để các verse xuất hiện lần lượt */
.verse:nth-child(2) { animation-delay: 0.2s; }
.verse:nth-child(3) { animation-delay: 0.4s; }
.verse:nth-child(4) { animation-delay: 0.6s; }
.verse:nth-child(5) { animation-delay: 0.8s; }
.verse:nth-child(6) { animation-delay: 1s; }

/* Animation cho page transitions */
.page-transition {
    animation: fadeOut 0.5s ease-out forwards;
}

/* Prevent scroll during transitions */
body.page-transition {
    overflow: hidden;
}

/* Handle page arrival transition */
.container {
    animation: fadeIn 0.5s ease-out;
}

/* Hover animation cho các link */
.chapter-link {
    position: relative;
    overflow: hidden;
}

.chapter-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--accent-color);
    transition: width 0.3s ease;
}

.chapter-link:hover::after {
    width: 100%;
}

/* Subtle animation for quote */
.quote, .comment-quote {
    position: relative;
}

.quote::before, .comment-quote::before {
    content: '"';
    position: absolute;
    left: -0.7em;
    top: -0.3em;
    font-size: 2em;
    color: rgba(52, 152, 219, 0.2);
    font-family: Georgia, serif;
}


