/* Base styles */
body {
    margin: 0;
    padding: 0;
    font-family: 'Arial', sans-serif;
    background-color: #333;
    color: #fff;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Map container */
#map {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

/* Story container */
#features {
    position: relative;
    z-index: 1;
    pointer-events: none;
    width: 100%;
}

/* Step styling */
.step {
    min-height: 100vh;
    margin-bottom: 0;
    padding: 2rem;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.3;
    transition: opacity 0.3s ease-in-out;
}

.step.is-active {
    opacity: 1;
}

/* Landcover image container */
.landcover-image-container {
    width: 100%;
    max-width: 1000px;
    margin: 20px auto;
    text-align: center;
    position: relative;
}

.landcover-layer {
    position: relative;
    width: 100%;
}

.landcover-image {
    width: 100%;
    height: auto;
    max-height: 750px;
    object-fit: contain;
    border: 2px solid #555;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

#landcover-2021 {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.landcover-controls {
    margin-top: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

.toggle-btn {
    background: #E10600;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: background-color 0.3s ease;
}

.toggle-btn:hover {
    background: #B80400;
}

.toggle-btn.paused {
    background: #666;
}

.year-indicator {
    background: rgba(0, 0, 0, 0.8);
    color: #E10600;
    padding: 8px 15px;
    border-radius: 5px;
    font-weight: bold;
    font-size: 16px;
    border: 1px solid #E10600;
}

/* Content box */
.narrative {
    max-width: 500px;
    background: rgba(0, 0, 0, 0.8);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    pointer-events: auto;
}

/* Typography */
.narrative h1, 
.narrative h2, 
.narrative h3 {
    color: #E10600;
    margin-top: 0;
    line-height: 1.2;
}

.narrative h1 {
    font-size: 2.2em;
    margin-bottom: 0.5em;
}

.content h2 {
    font-size: 1.8em;
    margin-bottom: 0.75em;
    border-bottom: 1px solid #E10600;
    padding-bottom: 0.3em;
}

.content p {
    margin-bottom: 1.2em;
    font-size: 1.1em;
}

/* Active step highlighting */
.step.is-active .content {
    border-left: 4px solid #E10600;
}

/* Loading state */
.map-loading {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: pulse 2s infinite;
}

.map-loading::before {
    content: '';
    width: 12px;
    height: 12px;
    border: 2px solid #E10600;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

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

@keyframes pulse {
    0% { opacity: 0.7; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .content {
        max-width: 90%;
        padding: 20px;
    }
    
    .content h1 {
        font-size: 1.8em;
    }
    
    .content h2 {
        font-size: 1.5em;
    }
    
    .map-loading {
        font-size: 12px;
        padding: 8px 16px;
    }
    
    .legend {
        position: fixed;
        bottom: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
        padding: 0.8rem;
        font-size: 0.9em;
    }
    
    .legend h4 {
        font-size: 1em;
        margin-bottom: 0.8rem;
    }
    
    .legend-item {
        margin-bottom: 0.4rem;
    }
    
    .legend-label {
        font-size: 0.8em;
    }
}

/* Legend styles */
.legend {
    position: fixed;
    top: 50%;
    left: 20px;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.9);
    padding: 1rem;
    border-radius: 8px;
    max-width: 300px;
    pointer-events: auto;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.legend.active {
    opacity: 1;
    visibility: visible;
}

.legend h4 {
    margin: 0 0 1rem 0;
    color: #E10600;
    font-size: 1.1em;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
    gap: 0.5rem;
}

.legend-color {
    flex-shrink: 0;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.legend-label {
    font-size: 0.9em;
    line-height: 1.3;
}

.legend-note {
    margin-top: 1rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 0.8em;
    line-height: 1.4;
    color: #ccc;
}

/* New legend layout classes */
.legend-group {
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.legend-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
    flex-wrap: wrap;
}

.legend-subitem {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex: 1;
    min-width: 140px;
}

.legend-subitem .legend-color {
    width: 15px !important;
    height: 15px !important;
}

.legend-subitem .legend-label {
    font-size: 0.8em;
}