/**
 * Home Page Performance Optimizations
 * 
 * Reduces visual issues and improves loading performance for the home page
 */

/* OPTIMIZED: Map container improvements */
.eternal-roam-home-interactive-map {
    position: relative;
    z-index: 1;
    /* Prevent flash of unstyled content */
    min-height: 600px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    overflow: hidden;
}

/* Loading state improvements */
.eternal-roam-map-loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    color: white;
    text-align: center;
}

.eternal-roam-map-loading-spinner .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* OPTIMIZED: Saints cards performance */
.saints-cards-section {
    /* Use transform3d for GPU acceleration */
    transform: translate3d(0, 0, 0);
    will-change: transform;
}

.saint-card {
    /* Optimize for animations */
    backface-visibility: hidden;
    perspective: 1000px;
    transform-style: preserve-3d;
}

.saint-image img {
    /* Improve image loading */
    loading: lazy;
    transition: opacity 0.3s ease;
}

.saint-image img.loading {
    opacity: 0.5;
}

.saint-image img.loaded {
    opacity: 1;
}

.saint-image img.error {
    opacity: 0.7;
    filter: grayscale(100%);
}

/* OPTIMIZED: Timeline performance */
.saints-timeline-section {
    /* GPU acceleration for smooth scrolling */
    transform: translate3d(0, 0, 0);
    will-change: scroll-position;
}

.timeline-track {
    /* Optimize timeline scrolling */
    contain: layout style paint;
}

.saint-node {
    /* Improve node rendering */
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
}

/* OPTIMIZED: Navigation buttons always visible */
.timeline-nav {
    position: fixed !important;
    z-index: 100 !important;
    opacity: 0.9 !important;
    pointer-events: auto !important;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    top: 50%;
    transform: translateY(-50%);
}

.timeline-nav:hover {
    opacity: 1 !important;
    background: rgba(255, 255, 255, 1);
    transform: translateY(-50%) scale(1.1);
}

.timeline-nav.prev {
    left: 15px !important;
    right: auto !important;
}

.timeline-nav.next {
    right: 15px !important;
    left: auto !important;
}

.timeline-nav i {
    font-size: 18px;
    color: #333;
}

/* OPTIMIZED: Better mobile responsiveness */
@media (max-width: 768px) {
    .eternal-roam-home-interactive-map {
        min-height: 400px;
    }
    
    .timeline-nav {
        width: 40px;
        height: 40px;
    }
    
    .timeline-nav i {
        font-size: 16px;
    }
    
    .timeline-nav.prev {
        left: 10px !important;
    }
    
    .timeline-nav.next {
        right: 10px !important;
    }
}

/* OPTIMIZED: Reduce layout shift during loading */
.saints-hand-container {
    min-height: 500px;
    position: relative;
}

.saints-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
}

/* OPTIMIZED: Map attribution hiding */
.leaflet-control-attribution,
.leaflet-control-attribution a,
.leaflet-bottom {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/* OPTIMIZED: Dropdown functionality fixes */
.dropdown-content {
    display: none;
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    width: 100% !important;
    z-index: 100 !important;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.dropdown-content.active {
    display: block !important;
}

.dropdown-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.dropdown-item:hover {
    background-color: #f8f9fa;
}

.dropdown-item.active {
    background-color: #667eea;
    color: white;
}

/* OPTIMIZED: Location details visibility */
#selected-location {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.placeholder-message {
    color: rgba(255, 255, 255, 0.9) !important;
    background-color: rgba(0, 0, 0, 0.25) !important;
    border-radius: 8px !important;
    padding: 1rem !important;
    text-align: center;
}

/* OPTIMIZED: Compact location items */
.location-item {
    padding: 0.5rem 0.75rem !important;
    gap: 0.5rem !important;
    margin-bottom: 0.3rem !important;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 6px;
}

.location-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.location-item.active {
    background-color: rgba(255, 255, 255, 0.2);
}

.location-name {
    font-size: 0.9rem !important;
    margin-bottom: 0.1rem !important;
    font-weight: 600;
}

.location-country {
    font-size: 0.8rem !important;
    opacity: 0.8;
}

.location-icon {
    width: 30px !important;
    height: 30px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    flex-shrink: 0;
}

.location-icon svg,
.location-icon i {
    width: 16px !important;
    height: 16px !important;
}

/* OPTIMIZED: Map markers */
.eternal-roam-custom-marker {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.eternal-roam-custom-marker:hover {
    transform: scale(1.1);
}

.eternal-roam-marker-inner {
    width: 24px !important;
    height: 24px !important;
    border-radius: 4px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.eternal-roam-marker-inner svg {
    width: 14px !important;
    height: 14px !important;
}

/* Marker colors */
.church-marker .eternal-roam-marker-inner {
    background-color: #8B4513;
}

.shrine-marker .eternal-roam-marker-inner {
    background-color: #4169E1;
}

.relic-marker .eternal-roam-marker-inner {
    background-color: #DAA520;
}

.route-marker .eternal-roam-marker-inner {
    background-color: #228B22;
}

/* OPTIMIZED: Loading performance classes */
.loading-optimized {
    contain: layout style paint;
    transform: translate3d(0, 0, 0);
}

.gpu-accelerated {
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* OPTIMIZED: Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .saint-card,
    .saint-node,
    .timeline-nav,
    .location-item {
        transition: none;
        animation: none;
    }
    
    .timeline-nav:hover {
        transform: translateY(-50%);
    }
}
