/* ====================================
   AMAZING ARTICLE ANIMATIONS & UX
   ==================================== */

/* Reading Progress Bar */
.reading-progress {
    position: fixed;
    top: 80px;
    left: 0;
    width: 0%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    z-index: 999;
    transition: width 0.1s ease-out;
    box-shadow: 0 2px 10px rgba(212, 175, 55, 0.5);
    animation: glow 2s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* Animated Background Particles */
.article-main::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 20% 50%, rgba(212, 175, 55, 0.03) 0%, transparent 50%),
                radial-gradient(circle at 80% 80%, rgba(139, 69, 19, 0.03) 0%, transparent 50%);
    animation: pulse 8s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Article Container Animations */
.article-main {
    position: relative;
    overflow-x: hidden;
}

.article {
    animation: fadeInUp 0.8s ease-out;
    position: relative;
    z-index: 1;
}

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

/* Header Animations - Staggered */
.article-header {
    animation: slideInFromLeft 0.8s ease-out;
}

@keyframes slideInFromLeft {
    from {
        opacity: 0;
        transform: translateX(-60px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.article-title {
    animation: fadeInScale 1s ease-out 0.2s backwards;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.article-meta {
    animation: fadeIn 1s ease-out 0.4s backwards;
}

.back-link {
    animation: slideInFromRight 0.8s ease-out 0.3s backwards;
    transition: all 0.3s ease;
}

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

.back-link:hover {
    transform: translateX(-5px);
    color: var(--primary-color);
}

/* Content Section Animations */
.article-content section {
    animation: fadeInUp 0.8s ease-out 0.5s backwards;
}

.article-content p,
.article-content ul,
.article-content ol,
.article-content h2,
.article-content h3 {
    opacity: 0;
    animation: fadeInSlide 0.6s ease-out forwards;
}

@keyframes fadeInSlide {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stagger animation delays for paragraphs */
.article-content p:nth-child(1) { animation-delay: 0.6s; transform: translateY(20px); }
.article-content p:nth-child(2) { animation-delay: 0.7s; transform: translateY(20px); }
.article-content p:nth-child(3) { animation-delay: 0.8s; transform: translateY(20px); }
.article-content h2 { animation-delay: 0.5s; transform: translateY(20px); }
.article-content h3 { animation-delay: 0.6s; transform: translateY(20px); }
.article-content ul, .article-content ol { animation-delay: 0.7s; transform: translateY(20px); }

/* Quote Animations */
.quote {
    animation: scaleIn 0.8s ease-out backwards;
    transition: all 0.4s ease;
    position: relative;
    overflow: hidden;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.quote::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.1), transparent);
    transition: left 0.8s ease;
}

.quote:hover::before {
    left: 100%;
}

.quote:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(212, 175, 55, 0.2);
}

/* Poem Animations */
.poem {
    animation: rotateIn 0.8s ease-out backwards;
    transform-origin: center;
    transition: all 0.4s ease;
}

@keyframes rotateIn {
    from {
        opacity: 0;
        transform: rotateX(-15deg);
    }
    to {
        opacity: 1;
        transform: rotateX(0);
    }
}

.poem:hover {
    transform: scale(1.02);
    box-shadow: 0 15px 40px rgba(139, 69, 19, 0.15);
}

.poem-lines {
    opacity: 0;
    animation: fadeIn 1s ease-out 0.5s forwards;
}

/* List Item Animations */
.article-content li {
    opacity: 0;
    transform: translateX(-20px);
    animation: slideInLeft 0.5s ease-out forwards;
}

@keyframes slideInLeft {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.article-content li:nth-child(1) { animation-delay: 0.8s; }
.article-content li:nth-child(2) { animation-delay: 0.9s; }
.article-content li:nth-child(3) { animation-delay: 1s; }
.article-content li:nth-child(4) { animation-delay: 1.1s; }
.article-content li:nth-child(5) { animation-delay: 1.2s; }
.article-content li:nth-child(6) { animation-delay: 1.3s; }

/* Translation Section Animation */
.translation-section {
    animation: fadeInUp 1s ease-out backwards;
    position: relative;
}

.translation-section::before {
    content: '';
    position: absolute;
    top: -20px;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary-color), transparent);
    animation: expandWidth 1.5s ease-out 0.5s forwards;
}

@keyframes expandWidth {
    to {
        width: 100%;
    }
}

/* Enhanced Interactive Elements */
.article-content a {
    position: relative;
    transition: all 0.3s ease;
    display: inline-block;
}

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

.article-content a:hover::after {
    width: 100%;
}

.article-content a:hover {
    color: var(--primary-color);
    transform: translateY(-2px);
}

/* Smooth Scroll Reveal */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s ease-out;
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

/* Article Lead Paragraph Special Animation */
.article-lead {
    font-size: 1.25rem;
    line-height: 1.8;
    color: var(--text-secondary);
    animation: highlightReveal 1.5s ease-out 0.8s backwards;
    position: relative;
}

@keyframes highlightReveal {
    from {
        opacity: 0;
        background-position: 0% 50%;
    }
    to {
        opacity: 1;
        background-position: 100% 50%;
    }
}

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

.poem-title,
.quote {
    animation-name: float, fadeInScale;
    animation-duration: 3s, 0.8s;
    animation-timing-function: ease-in-out, ease-out;
    animation-iteration-count: infinite, 1;
    animation-fill-mode: both;
}

/* Parallax Effect on Scroll */
@media (prefers-reduced-motion: no-preference) {
    .article-header {
        transform: translateZ(0);
        will-change: transform;
    }
}

/* Enhanced Button/Link Animations */
.back-link {
    position: relative;
    overflow: hidden;
}

.back-link::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(212, 175, 55, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.back-link:hover::before {
    width: 300px;
    height: 300px;
}

/* Loading Animation for Images */
.article-image {
    animation: fadeIn 0.8s ease-out;
    transition: transform 0.4s ease;
}

.article-image:hover {
    transform: scale(1.02);
}

/* Gradient Text Animation for Headings */
.article-title {
    background: linear-gradient(135deg, var(--text-primary), var(--primary-color));
    background-size: 200% 200%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradientShift 3s ease infinite, fadeInScale 1s ease-out 0.2s backwards;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* Scroll-triggered Fade Animation */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Enhanced Shadow on Hover */
.poem:hover,
.quote:hover {
    box-shadow: 0 20px 60px rgba(212, 175, 55, 0.3);
}

/* Navigation Smooth Transitions */
.nav-link {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Responsive Animation Adjustments */
@media (max-width: 768px) {
    .article-title {
        animation: fadeInScale 0.8s ease-out 0.2s backwards;
    }
    
    .article-content p,
    .article-content ul,
    .article-content li {
        animation-duration: 0.4s;
    }
    
    .poem:hover,
    .quote:hover {
        transform: none;
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
