/* Lazy Loading Styles */
img.lazy-loading {
    background: linear-gradient(90deg, #f1f5f9, #e2e8f0, #f1f5f9);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

img.lazy-loading.loaded {
    animation: fadeIn 0.4s ease;
}

img.lazy-loading.error {
    opacity: 0.5;
    filter: grayscale(1);
}

/* Bookmark Button */
.bookmark-btn {
    background: #f1f5f9;
    color: #1e3a8a;
    border: 2px solid #e2e8f0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.bookmark-btn:hover {
    background: #e0e7ff;
    border-color: #3b82f6;
    transform: translateY(-3px);
}

.bookmark-btn.bookmarked {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.bookmark-btn.bookmarked:hover {
    background: #2563eb;
}

.bookmark-btn:active {
    transform: scale(0.95);
}

/* Bookmark Toast */
.bookmark-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1e3a8a;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 2rem;
    box-shadow: 0 8px 24px rgba(30, 58, 138, 0.3);
    z-index: 10000;
    font-weight: 600;
    font-size: 0.95rem;
    opacity: 0;
    transition: all 0.3s ease;
}

.bookmark-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Reading Progress Bar */
#reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 4px;
    width: 100%;
    background: linear-gradient(90deg, #3b82f6 var(--progress, 0%), transparent var(--progress, 0%));
    z-index: 1500;
    transition: background 0.1s linear;
}

/* Smooth Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes shimmer {
    0% {
        background-position: 0% 0%;
    }
    100% {
        background-position: 200% 0%;
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Apply animations to elements */
.post-card {
    animation: fadeInUp 0.5s ease backwards;
}

.post-card:nth-child(1) { animation-delay: 0.05s; }
.post-card:nth-child(2) { animation-delay: 0.1s; }
.post-card:nth-child(3) { animation-delay: 0.15s; }
.post-card:nth-child(4) { animation-delay: 0.2s; }
.post-card:nth-child(5) { animation-delay: 0.25s; }
.post-card:nth-child(6) { animation-delay: 0.3s; }

.horizontal-post-card {
    animation: slideInLeft 0.5s ease backwards;
}

.horizontal-post-card:nth-child(1) { animation-delay: 0.1s; }
.horizontal-post-card:nth-child(2) { animation-delay: 0.2s; }
.horizontal-post-card:nth-child(3) { animation-delay: 0.3s; }

.category-section h2 {
    animation: slideInRight 0.6s ease;
}

/* Micro-interactions */
.post-card,
.horizontal-post-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.post-card:hover {
    transform: translateY(-8px) scale(1.02);
}

.horizontal-post-card:hover {
    transform: translateX(8px);
}

button, a {
    transition: all 0.2s ease;
}

button:active, a:active {
    transform: scale(0.97);
}

/* Smooth scroll */
html {
    scroll-behavior: smooth;
}

/* Focus visible improvements */
*:focus-visible {
    outline: 3px solid #3b82f6;
    outline-offset: 3px;
    border-radius: 0.25rem;
}

/* Dark mode adjustments */
.dark-mode .bookmark-btn {
    background: #334155;
    color: #60a5fa;
    border-color: #475569;
}

.dark-mode .bookmark-btn:hover {
    background: #475569;
    border-color: #60a5fa;
}

.dark-mode .bookmark-btn.bookmarked {
    background: #60a5fa;
    color: #0f172a;
    border-color: #60a5fa;
}

.dark-mode .bookmark-toast {
    background: #60a5fa;
    color: #0f172a;
}

.dark-mode #reading-progress {
    background: linear-gradient(90deg, #60a5fa var(--progress, 0%), transparent var(--progress, 0%));
}

/* Responsive */
@media (max-width: 768px) {
    .bookmark-toast {
        bottom: 1rem;
        font-size: 0.85rem;
        padding: 0.6rem 1.2rem;
    }
}
