/**
 * Archive Pages - Unified Styles
 * Consistent design for all post type archives and taxonomies
 * Refines colors, filters, and overall UX
 */

/* ==========================================================================
   ARCHIVE HEADER
   ========================================================================== */

.archive-header {
    position: relative;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: var(--white);
    padding: var(--space-20) 0;
    overflow: hidden;
}

/* Subtle pattern overlay */
.archive-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v6h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.3;
    z-index: 0;
}

.archive-header .container {
    position: relative;
    z-index: 1;
}

.archive-title {
    font-family: var(--font-heading);
    font-size: var(--font-5xl);
    font-weight: 700;
    margin: 0 0 var(--space-3);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.archive-description {
    font-size: var(--font-xl);
    line-height: 1.6;
    opacity: 0.95;
    max-width: 700px;
    margin: 0 auto var(--space-8);
}

/* ==========================================================================
   POST-TYPE SPECIFIC HERO BACKGROUNDS
   ========================================================================== */

.post-type-archive-monastic_site .archive-header {
    background-image: linear-gradient(rgba(45, 80, 22, 0.75), rgba(26, 48, 9, 0.85)),
                      url('/wp-content/uploads/2025/11/IMG_3639.jpg');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

.post-type-archive-pilgrimage_route .archive-header {
    background-image: linear-gradient(rgba(45, 80, 22, 0.75), rgba(26, 48, 9, 0.85)),
                      url('/wp-content/uploads/2025/11/IMG_3632.jpg');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

.post-type-archive-christian_site .archive-header {
    background-image: linear-gradient(rgba(45, 80, 22, 0.75), rgba(26, 48, 9, 0.85)),
                      url('/wp-content/uploads/2025/11/IMG_1813.jpg');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

/* Ensure text visibility on hero backgrounds */
.post-type-archive-monastic_site .archive-title,
.post-type-archive-pilgrimage_route .archive-title,
.post-type-archive-christian_site .archive-title,
.post-type-archive-monastic_site .archive-description,
.post-type-archive-pilgrimage_route .archive-description,
.post-type-archive-christian_site .archive-description {
    color: var(--white);
}

/* Mobile optimization for hero backgrounds */
@media (max-width: 768px) {
    .post-type-archive-monastic_site .archive-header,
    .post-type-archive-pilgrimage_route .archive-header,
    .post-type-archive-christian_site .archive-header {
        background-attachment: scroll;
        background-position: center 40%;
    }
}

/* Archive stats (for county pages) */
.archive-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-4);
    margin-top: var(--space-8);
}

.stat-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    text-align: center;
    transition: all 0.3s ease;
}

.stat-card:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.stat-number {
    display: block;
    font-size: var(--font-4xl);
    font-weight: 700;
    margin-bottom: var(--space-2);
}

.stat-label {
    font-size: var(--font-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

/* ==========================================================================
   ARCHIVE FILTERS - REFINED
   ========================================================================== */

.archive-filters {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    margin-top: calc(var(--space-8) * -1);
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 10;
}

.filter-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.filter-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-3);
    align-items: center;
}

/* Refined Filter Selects */
.filter-select {
    appearance: none;
    background-color: var(--gray-50);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%232d5016' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 12px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 0.875rem 2.5rem 0.875rem 1rem;
    font-size: var(--font-base);
    font-weight: 500;
    color: var(--gray-900);
    transition: all 0.2s ease;
    cursor: pointer;
    min-width: 0; /* Allow shrinking */
}

.filter-select:hover {
    border-color: var(--primary-light);
    background-color: var(--white);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--white);
    box-shadow: 0 0 0 3px rgba(45, 80, 22, 0.1);
}

.filter-select option {
    padding: 0.5rem;
}

/* Filter Actions */
.filter-actions {
    display: flex;
    gap: var(--space-3);
    align-items: center;
}

.filter-actions .btn {
    white-space: nowrap;
}

.btn-clear-filters {
    background: transparent;
    border: 2px solid var(--gray-300);
    color: var(--gray-700);
    padding: 0.875rem 1.5rem;
    border-radius: var(--radius-lg);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-clear-filters:hover {
    border-color: var(--gray-400);
    background: var(--gray-50);
    color: var(--gray-900);
}

.btn-apply-filters {
    background: var(--primary-color);
    border: 2px solid var(--primary-color);
    color: var(--white);
    padding: 0.875rem 2rem;
    border-radius: var(--radius-lg);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-apply-filters:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Active filter indicator */
.filter-select.has-value {
    border-color: var(--primary-color);
    background-color: var(--white);
}

/* Filter count badge */
.filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--secondary-color);
    color: var(--white);
    font-size: var(--font-xs);
    font-weight: 700;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-full);
    margin-left: var(--space-2);
}

/* ==========================================================================
   TAB FILTERS (for county pages)
   ========================================================================== */

.filter-tabs {
    background: var(--white);
    padding: var(--space-2);
    border-radius: var(--radius-lg);
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-6);
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
}

.filter-tab {
    flex: 1 1 auto;
    min-width: 120px;
    padding: 0.875rem 1.5rem;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: var(--font-base);
    color: var(--gray-700);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.filter-tab:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.filter-tab.active {
    background: var(--primary-color);
    color: var(--white);
    box-shadow: var(--shadow-sm);
}

.filter-tab .count {
    display: inline-block;
    margin-left: var(--space-2);
    font-size: var(--font-sm);
    opacity: 0.8;
}

/* ==========================================================================
   ARCHIVE CONTENT
   ========================================================================== */

.archive-content {
    padding: var(--space-12) 0;
}

/* Results header */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
    gap: var(--space-4);
}

.results-count {
    font-size: var(--font-lg);
    color: var(--gray-700);
}

.results-count strong {
    color: var(--primary-color);
    font-weight: 700;
}

.view-toggle {
    display: flex;
    gap: var(--space-2);
    background: var(--gray-100);
    padding: 0.25rem;
    border-radius: var(--radius);
}

.view-toggle-btn {
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--gray-600);
}

.view-toggle-btn:hover {
    color: var(--gray-900);
}

.view-toggle-btn.active {
    background: var(--white);
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   SITES GRID - REFINED CARDS
   ========================================================================== */

.sites-grid,
.routes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: var(--space-6);
    margin-bottom: var(--space-12);
}

.site-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.site-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    border-color: var(--primary-light);
}

/* Card image */
.card-image {
    position: relative;
    height: 220px;
    overflow: hidden;
    background: var(--gray-200);
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.site-card:hover .card-image img {
    transform: scale(1.05);
}

/* Card content */
.card-content {
    padding: var(--space-5);
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Card meta badges */
.card-meta {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
    flex-wrap: wrap;
}

.post-type-label,
.county-label,
.site-type-label {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: var(--font-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Post type specific colors */
.post-type-label.monastic {
    background: rgba(45, 80, 22, 0.1);
    color: var(--primary-color);
}

.post-type-label.pilgrimage {
    background: rgba(200, 134, 13, 0.1);
    color: var(--secondary-color);
}

.post-type-label.christian {
    background: rgba(139, 69, 19, 0.1);
    color: var(--accent-color);
}

.county-label {
    background: var(--gray-100);
    color: var(--gray-700);
}

/* Card title */
.card-content h3 {
    font-family: var(--font-heading);
    font-size: var(--font-xl);
    line-height: 1.3;
    margin: 0 0 var(--space-3);
}

.card-content h3 a {
    color: var(--gray-900);
    text-decoration: none;
    transition: color 0.2s ease;
}

.card-content h3 a:hover {
    color: var(--primary-color);
}

/* Card metadata */
.card-metadata {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    font-size: var(--font-sm);
    color: var(--gray-600);
}

.metadata-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.metadata-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Card excerpt */
.card-excerpt {
    font-size: var(--font-sm);
    line-height: 1.6;
    color: var(--gray-700);
    margin-bottom: var(--space-4);
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Card actions */
.card-actions {
    display: flex;
    gap: var(--space-2);
    margin-top: auto;
}

.card-actions .btn {
    flex: 1;
    text-align: center;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: var(--font-sm);
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.btn-secondary:hover {
    background: var(--primary-color);
    color: var(--white);
}

/* ==========================================================================
   ARCHIVE MAP SECTION
   ========================================================================== */

.archive-map-section {
    background: var(--gray-50);
    padding: var(--space-12) 0;
    margin: var(--space-12) 0;
}

.archive-map-section .container {
    max-width: 1200px;
}

.archive-map-section h2 {
    font-family: var(--font-heading);
    font-size: var(--font-3xl);
    text-align: center;
    margin-bottom: var(--space-6);
    color: var(--gray-900);
}

.archive-map-container,
.archive-overview-map {
    height: 500px;
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-200);
}

/* ==========================================================================
   PAGINATION - REFINED
   ========================================================================== */

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-2);
    margin: var(--space-12) 0;
}

.pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 44px;
    padding: 0 1rem;
    border-radius: var(--radius);
    font-weight: 600;
    text-decoration: none;
    color: var(--gray-700);
    background: var(--white);
    border: 1px solid var(--gray-300);
    transition: all 0.2s ease;
}

.pagination .page-numbers:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: var(--gray-50);
}

.pagination .page-numbers.current {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}

.pagination .page-numbers.dots {
    border: none;
    background: transparent;
}

.pagination .prev,
.pagination .next {
    font-weight: 600;
}

/* ==========================================================================
   LOADING & EMPTY STATES
   ========================================================================== */

.loading-state {
    text-align: center;
    padding: var(--space-20) 0;
}

.loading-spinner {
    display: inline-block;
    width: 48px;
    height: 48px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty-state {
    text-align: center;
    padding: var(--space-20) 0;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: var(--space-4);
    opacity: 0.3;
}

.empty-state h3 {
    font-family: var(--font-heading);
    font-size: var(--font-2xl);
    margin-bottom: var(--space-3);
    color: var(--gray-900);
}

.empty-state p {
    font-size: var(--font-lg);
    color: var(--gray-600);
    max-width: 500px;
    margin: 0 auto;
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */

/* Tablet */
@media (max-width: 768px) {
    .archive-title {
        font-size: var(--font-4xl);
    }

    .archive-description {
        font-size: var(--font-lg);
    }

    .archive-filters {
        padding: var(--space-4);
    }

    .filter-row {
        grid-template-columns: 1fr;
    }

    .filter-actions {
        flex-direction: column;
    }

    .filter-actions .btn {
        width: 100%;
    }

    .filter-tabs {
        flex-direction: column;
    }

    .filter-tab {
        min-width: auto;
    }

    .sites-grid,
    .routes-grid {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .archive-map-container {
        height: 400px;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .archive-header {
        padding: var(--space-12) 0;
    }

    .archive-title {
        font-size: var(--font-3xl);
    }

    .archive-description {
        font-size: var(--font-base);
    }

    .archive-stats {
        grid-template-columns: 1fr;
    }

    .card-actions {
        flex-direction: column;
    }

    .archive-map-container {
        height: 300px;
    }

    .pagination .page-numbers {
        min-width: 36px;
        height: 36px;
        font-size: var(--font-sm);
    }
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
    .archive-filters,
    .filter-tabs,
    .pagination,
    .btn-secondary,
    .archive-map-section {
        display: none;
    }

    .site-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
    }

    .card-actions .btn-primary {
        display: none;
    }
}

/* ==========================================================================
   ACCESSIBILITY ENHANCEMENTS
   ========================================================================== */

/* Focus visible for keyboard navigation */
.filter-select:focus-visible,
.filter-tab:focus-visible,
.btn:focus-visible,
.pagination .page-numbers:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

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

    .loading-spinner {
        animation: none;
        border-top-color: transparent;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .site-card {
        border: 2px solid currentColor;
    }

    .btn {
        border: 2px solid currentColor;
    }
}
