/**
 * Custom Archive Styles
 * Modern, responsive design with performance optimizations
 */

/* Container and Layout */
.custom-archive-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.custom-archive-header {
    margin-bottom: 3rem;
    text-align: center;
    padding: 2rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.archive-title {
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 700;
    margin: 0 0 1rem 0;
    /*color: var(--ct-color-text, #2c3e50);*/
    color: #653490;
    line-height: 1.2;
}

.archive-description {
    font-size: 1.1rem;
    color: var(--ct-color-text-alt, #666);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Posts Grid */
.custom-posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

@media (max-width: 768px) {
    .custom-posts-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

/* Post Cards */
.custom-post-card {
    background: #fff;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease !important;
    position: relative;
    overflow: hidden;
    min-width: 160px;
    box-shadow: 0 4px 15px rgba(0, 124, 186, 0.3);
}

/* Load More Button */
.load-more-container {
    text-align: center;
    padding: 2rem 0;
}

.load-more-btn {
    /*background: linear-gradient(135deg, var(--ct-color-primary, #007cba) 0%, #0056b3 100%);*/
    background: linear-gradient(135deg, #653490 0%, #4a2568 100%);
    color: #fff;
    border: none;
    padding: 1rem 2rem;
    border-radius: 4px;
    box-shadow: 0 4px 15px rgba(101, 52, 144, 0.3);
    /*box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.1);*/
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    will-change: transform;
    contain: layout style paint;
}

.load-more-btn:hover {
    transform: translateY(-2px);
    /*box-shadow: 0 6px 20px rgba(0, 124, 186, 0.4);*/
    box-shadow: 0 6px 20px rgba(101, 52, 144, 0.4);
}

.load-more-btn:active {
    transform: translateY(0);
}

.load-more-btn:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.load-more-btn.loading {
    pointer-events: none;
}

.btn-loader {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-loader svg {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Loading States and Animations */
.custom-post-card.loading {
    opacity: 0;
    transform: translateY(20px);
}

.custom-post-card.fade-in {
    animation: fadeInUp 0.6s ease forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Error States */
.load-more-error {
    background: #f8d7da;
    color: #721c24;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin: 1rem 0;
    border: 1px solid #f5c6cb;
    text-align: center;
    font-size: 0.9rem;
}

.no-posts {
    text-align: center;
    padding: 3rem;
    font-size: 1.1rem;
    color: var(--ct-color-text-alt, #666);
    background: #f8f9fa;
    border-radius: 8px;
    margin: 2rem 0;
}

/* Accessibility */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Focus States */
.custom-post-card a:focus {
    /*outline: 2px solid var(--ct-color-primary, #007cba);*/
    outline: 2px solid #653490;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Responsive Design */
@media (max-width: 480px) {
    .custom-archive-container {
        padding: 0 15px;
    }
    
    .custom-posts-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .post-content {
        padding: 1rem;
    }
    
    .post-title {
        font-size: 1.1rem;
    }
    
    .load-more-btn {
        padding: 0.875rem 1.5rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 320px) {
    .archive-title {
        font-size: 1.75rem;
    }
    
    .post-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* Print Styles */
@media print {
    .load-more-container,
    .custom-archive-header {
        display: none;
    }
    
    .custom-posts-grid {
        display: block;
    }
    
    .custom-post-card {
        break-inside: avoid;
        margin-bottom: 1rem;
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .custom-post-card {
        background: var(--ct-color-background-alt, #1a1a1a);
        color: var(--ct-color-text, #ffffff);
    }
    
    .archive-title {
        color: var(--ct-color-text, #ffffff);
    }
    
    .post-title a {
        color: var(--ct-color-text, #ffffff);
    }
    
    .post-thumbnail {
        background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
    }
    
    .no-posts {
        background: var(--ct-color-background-alt, #2d3748);
        color: var(--ct-color-text, #ffffff);
    }
}

/* Performance Optimizations */
.custom-posts-grid img {
    content-visibility: auto;
    contain-intrinsic-size: 350px 220px;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .custom-post-card,
    .post-featured-image,
    .load-more-btn {
        transition: none;
    }
    
    .custom-post-card:hover {
        transform: none;
    }
    
    .custom-post-card:hover .post-featured-image {
        transform: none;
    }
    
    .btn-loader svg {
        animation: none;
    }
    
    .custom-post-card.fade-in {
        animation: none;
        opacity: 1;
        transform: none;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .custom-post-card {
        border: 2px solid;
    }
    
    .load-more-btn {
        border: 2px solid;
    }
}

.custom-post-card:hover {
    transform: translateY(-4px) !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1), 0 4px 10px rgba(0, 0, 0, 0.05);
}

.custom-post-card:focus-within {
    /*outline: 3px solid var(--ct-color-primary, #007cba);*/
    outline: 3px solid #653490;
    outline-offset: 2px;
}

.post-card-inner {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Post Thumbnails */
.post-thumbnail {
    position: relative;
    aspect-ratio: 16/10;
    overflow: hidden;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.post-thumbnail a {
    display: block;
    height: 100%;
    width: 100%;
    position: relative;
}

.post-featured-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    will-change: transform;
}

.custom-post-card:hover .post-featured-image {
    transform: scale(1.05);
}

.post-thumbnail.no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    /*background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);*/
    background: linear-gradient(135deg, #653490 0%, #4a2568 100%);
}

.placeholder-image {
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 2rem;
    height: 100%;
}

.placeholder-image svg {
    width: 60px;
    height: 60px;
}

/* Image Error Handling */
.post-thumbnail.image-error {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 50%, #fecfef 100%);
}

.post-thumbnail.image-error::after {
    content: "📷";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    opacity: 0.6;
}

/* Post Content */
.post-content {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.post-title {
    margin: 0 0 1rem 0;
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.4;
}

.post-title a {
    color: var(--ct-color-text, #2c3e50);
    text-decoration: none;
    transition: color 0.2s ease;
}

.post-title a:hover,
.post-title a:focus {
    /*color: var(--ct-color-primary, #007cba);*/
    color: #653490;
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: var(--ct-color-text-alt, #666);
    flex-wrap: wrap;
}

.post-date {
    display: flex;
    align-items: center;
}

.post-date::before {
    content: "📅";
    margin-right: 0.5rem;
    font-size: 0.8em;
}

.post-categories a {
    /*color: var(--ct-color-primary, #007cba);*/
    color: #653490;
    text-decoration: none;
    font-weight: 500;
}

.post-categories a:hover {
    text-decoration: underline;
}

.post-excerpt {
    color: var(--ct-color-text-alt, #666);
    line-height: 1.6;
    margin-top: auto;
    font-size: 0.95rem;
}