/* Modern Animations and Effects */
:root {
    --primary-color: #d10000;
    --secondary-color: #1a1a1a;
    --accent-color: #f5a623;
    --text-color: #333;
    --light-gray: #f8f9fa;
    --dark-overlay: rgba(0, 0, 0, 0.7);
    --transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    --box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
}

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

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

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

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

/* Section Animations */
.home-section {
    opacity: 0;
    animation: fadeIn 0.6s ease-out forwards;
    animation-delay: calc(var(--section-index, 0) * 0.1s);
    transform: translateY(20px);
}

/* Card Hover Effects */
.grid-post, .featured-post {
    transition: var(--transition);
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.grid-post:hover, .featured-post:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
    z-index: 2;
}

.grid-post::before, .featured-post::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, rgba(209, 0, 0, 0.1), transparent);
    opacity: 0;
    transition: var(--transition);
    z-index: -1;
}

.grid-post:hover::before, .featured-post:hover::before {
    opacity: 1;
}

/* Image Zoom Effect */
.post-thumbnail {
    overflow: hidden;
    position: relative;
}

.post-thumbnail img {
    transition: transform 0.8s cubic-bezier(0.25, 0.8, 0.25, 1);
    will-change: transform;
}

.grid-post:hover .post-thumbnail img,
.featured-post:hover .post-thumbnail img {
    transform: scale(1.08);
}

/* Button Effects */
.view-all, .btn, button, input[type="submit"] {
    position: relative;
    overflow: hidden;
    transition: var(--transition);
    z-index: 1;
}

.view-all::after, .btn::after, button::after, input[type="submit"]::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 100%;
    background-color: var(--primary-color);
    transition: width 0.3s ease;
    z-index: -1;
}

.view-all:hover::after, .btn:hover::after, button:hover::after, input[type="submit"]:hover::after {
    width: 100%;
}

.view-all:hover, .btn:hover, button:hover, input[type="submit"]:hover {
    color: #fff !important;
}

/* Loading Animation */
@keyframes loading {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: loading 0.8s ease-in-out infinite;
    margin-right: 8px;
}

/* Text Animation */
.animate-text {
    display: inline-block;
    position: relative;
    overflow: hidden;
}

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

.animate-text:hover::after {
    width: 100%;
}

/* Section Title Animation */
.section-title {
    position: relative;
    display: inline-block;
    padding-bottom: 10px;
}

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

.section-title:hover::after {
    width: 100%;
}

/* Grid Layout Animation */
.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
}

.grid-post {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeIn 0.6s ease-out forwards;
    animation-delay: calc(var(--index, 0) * 0.1s);
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .posts-grid {
        grid-template-columns: repeat(auto-fill, minmax(100%, 1fr));
    }
    
    .section-title {
        font-size: 1.5rem;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #b30000;
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: var(--primary-color);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: var(--transition);
    z-index: 999;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    background: #b30000;
    transform: translateY(-3px) !important;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}
