/**
 * D&D AI RPG - World Map System Styles
 * 100x100 grid-based exploration with fog of war
 */

/* ============================================================================
   WORLD MAP PANEL
   ============================================================================ */

.world-map-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 80px; /* Leave space for action buttons at bottom */
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    z-index: 1500; /* Lower than dialogue (3000) and combat (2000), but above panels (1000) */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    pointer-events: auto; /* Ensure it captures clicks when visible */
}

.world-map-panel.hidden {
    display: none;
    pointer-events: none; /* Ensure no blocking when hidden */
}

/* ============================================================================
   MAP HEADER
   ============================================================================ */

.map-header {
    background: linear-gradient(135deg, #27ae60 0%, #229954 100%);
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid #1e8449;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.map-header h2 {
    color: white;
    margin: 0;
    font-size: 28px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.map-coordinates {
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 20px;
    border-radius: 10px;
    color: white;
    font-size: 16px;
    font-weight: bold;
    font-family: 'Courier New', monospace;
}

.close-map-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 28px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
}

.close-map-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* ============================================================================
   MAP CONTROLS
   ============================================================================ */

.map-controls {
    background: rgba(0, 0, 0, 0.4);
    padding: 15px 20px;
    border-bottom: 2px solid #34495e;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    position: relative;
    z-index: 100;
}

.zoom-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.zoom-btn {
    background: rgba(52, 152, 219, 0.3);
    border: 2px solid #3498db;
    color: white;
    font-size: 20px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zoom-btn:hover:not(:disabled) {
    background: rgba(52, 152, 219, 0.5);
    border-color: #5dade2;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}

.zoom-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.center-btn {
    background: rgba(46, 204, 113, 0.3);
    border: 2px solid #2ecc71;
    color: white;
    font-size: 20px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.center-btn:hover {
    background: rgba(46, 204, 113, 0.5);
    border-color: #58d68d;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(46, 204, 113, 0.4);
}

.close-btn {
    background: rgba(231, 76, 60, 0.3);
    border: 2px solid #e74c3c;
    color: white;
    font-size: 28px;
    font-weight: bold;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.close-btn:hover {
    background: rgba(231, 76, 60, 0.6);
    border-color: #ec7063;
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 5px 15px rgba(231, 76, 60, 0.5);
}

.zoom-level {
    color: #3498db;
    font-size: 16px;
    font-weight: bold;
    min-width: 60px;
    text-align: center;
}

.exploration-stats {
    display: flex;
    gap: 20px;
    align-items: center;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    font-size: 14px;
}

.stat-icon {
    font-size: 20px;
}

.stat-value {
    font-weight: bold;
    color: #f39c12;
}

.legend-toggle {
    background: rgba(155, 89, 182, 0.3);
    border: 2px solid #9b59b6;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
}

.legend-toggle:hover {
    background: rgba(155, 89, 182, 0.5);
    border-color: #bb8fce;
    transform: translateY(-2px);
}

/* ============================================================================
   MAP CONTAINER
   ============================================================================ */

.map-container {
    flex: 1;
    display: flex;
    position: relative;
    background: radial-gradient(circle at center, rgba(52, 73, 94, 0.3) 0%, rgba(0, 0, 0, 0.5) 100%);
    overflow: hidden;
}

.map-canvas-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    cursor: grab;
}

.map-canvas-wrapper.dragging {
    cursor: grabbing;
}

#world-map-canvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    pointer-events: none;
}

.player-marker {
    position: absolute;
    width: 32px;
    height: 32px;
    background: radial-gradient(circle, #f39c12, #e67e22);
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 0 20px rgba(243, 156, 18, 0.8);
    animation: playerPulse 2s infinite;
    z-index: 10;
    pointer-events: none;
}

@keyframes playerPulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(243, 156, 18, 0.8);
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        box-shadow: 0 0 30px rgba(243, 156, 18, 1);
        transform: translate(-50%, -50%) scale(1.1);
    }
}

/* ============================================================================
   MINIMAP
   ============================================================================ */

.minimap-container {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 200px;
    height: 200px;
    background: rgba(0, 0, 0, 0.8);
    border: 3px solid #3498db;
    border-radius: 10px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.7);
    z-index: 100;
}

.minimap-header {
    background: rgba(52, 152, 219, 0.3);
    padding: 8px;
    text-align: center;
    color: #3498db;
    font-size: 12px;
    font-weight: bold;
    border-bottom: 2px solid #3498db;
}

#minimap-canvas {
    display: block;
    width: 100%;
    height: calc(100% - 32px);
    image-rendering: pixelated;
}

.minimap-player {
    position: absolute;
    width: 6px;
    height: 6px;
    background: #f39c12;
    border: 1px solid white;
    border-radius: 50%;
    box-shadow: 0 0 5px #f39c12;
}

/* ============================================================================
   MAP LEGEND
   ============================================================================ */

.map-legend {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 250px;
    background: rgba(0, 0, 0, 0.9);
    border: 3px solid #9b59b6;
    border-radius: 10px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.7);
    z-index: 100;
    overflow: hidden;
}

.map-legend.hidden {
    display: none;
}

.legend-header {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
    padding: 12px;
    color: white;
    font-weight: bold;
    font-size: 16px;
    text-align: center;
}

.legend-content {
    padding: 15px;
    max-height: 400px;
    overflow-y: auto;
}

.legend-section {
    margin-bottom: 15px;
}

.legend-section h4 {
    color: #9b59b6;
    margin: 0 0 10px 0;
    font-size: 14px;
    border-bottom: 1px solid rgba(155, 89, 182, 0.3);
    padding-bottom: 5px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
    color: #ecf0f1;
    font-size: 12px;
}

.legend-color {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    flex-shrink: 0;
}

.legend-icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.legend-label {
    flex: 1;
}

/* Biome Colors */
.biome-plains { background: #8bc34a; }
.biome-forest { background: #2e7d32; }
.biome-mountain { background: #78909c; }
.biome-desert { background: #fdd835; }
.biome-hills { background: #9ccc65; }
.biome-swamp { background: #558b2f; }
.biome-tundra { background: #b0bec5; }
.biome-wasteland { background: #795548; }

/* ============================================================================
   TILE TOOLTIP
   ============================================================================ */

.tile-tooltip {
    position: fixed;
    background: linear-gradient(135deg, #2c3e50, #34495e);
    border: 3px solid #3498db;
    border-radius: 10px;
    padding: 15px;
    color: white;
    font-size: 14px;
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.8);
    min-width: 200px;
}

.tile-tooltip.hidden {
    display: none;
}

.tooltip-title {
    font-size: 16px;
    font-weight: bold;
    color: #f39c12;
    margin-bottom: 8px;
}

.tooltip-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tooltip-row:last-child {
    border-bottom: none;
}

.tooltip-label {
    color: #95a5a6;
}

.tooltip-value {
    color: white;
    font-weight: bold;
}

.tooltip-description {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    color: #bdc3c7;
    font-size: 12px;
    line-height: 1.4;
}

/* Danger level colors */
.danger-safe { color: #2ecc71; }
.danger-low { color: #f1c40f; }
.danger-medium { color: #e67e22; }
.danger-high { color: #e74c3c; }
.danger-deadly { color: #c0392b; font-weight: bold; }

/* ============================================================================
   TRAVEL ACTIONS
   ============================================================================ */

.travel-actions {
    background: rgba(0, 0, 0, 0.4);
    padding: 20px 40px;
    border-top: 2px solid #34495e;
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.travel-btn {
    background: linear-gradient(135deg, rgba(46, 204, 113, 0.3), rgba(39, 174, 96, 0.3));
    border: 2px solid #2ecc71;
    border-radius: 10px;
    padding: 12px 20px;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
}

.travel-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(46, 204, 113, 0.5), rgba(39, 174, 96, 0.5));
    border-color: #58d68d;
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(46, 204, 113, 0.4);
}

.travel-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.travel-icon {
    font-size: 20px;
}

.fast-travel-btn {
    border-color: #f39c12;
    background: linear-gradient(135deg, rgba(243, 156, 18, 0.3), rgba(230, 126, 34, 0.3));
}

.fast-travel-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(243, 156, 18, 0.5), rgba(230, 126, 34, 0.5));
    border-color: #f5b041;
}

.rest-btn {
    border-color: #3498db;
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.3), rgba(41, 128, 185, 0.3));
}

.rest-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.5), rgba(41, 128, 185, 0.5));
    border-color: #5dade2;
}

/* ============================================================================
   LOCATION INFO PANEL
   ============================================================================ */

.location-info {
    position: absolute;
    top: 80px;
    left: 20px;
    width: 300px;
    background: rgba(0, 0, 0, 0.9);
    border: 3px solid #27ae60;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.7);
    z-index: 100;
}

.location-info.hidden {
    display: none;
}

.location-name {
    font-size: 20px;
    font-weight: bold;
    color: #f39c12;
    margin-bottom: 10px;
}

.location-type {
    color: #3498db;
    font-size: 14px;
    margin-bottom: 15px;
}

.location-description {
    color: #ecf0f1;
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 15px;
}

.location-features {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
    color: #bdc3c7;
    font-size: 12px;
}

.feature-icon {
    color: #f39c12;
    font-size: 16px;
}

.location-actions {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.location-action-btn {
    background: linear-gradient(135deg, #3498db, #2980b9);
    border: none;
    color: white;
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
}

.location-action-btn:hover {
    background: linear-gradient(135deg, #5dade2, #3498db);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}

/* ============================================================================
   FOG OF WAR OVERLAY
   ============================================================================ */

.fog-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.undiscovered-tile {
    fill: rgba(0, 0, 0, 0.8);
    transition: fill 0.5s;
}

.revealed-tile {
    fill: transparent;
}

/* ============================================================================
   LOADING STATE
   ============================================================================ */

.map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 200;
}

.map-loading.hidden {
    display: none;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(255, 255, 255, 0.2);
    border-top-color: #27ae60;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.loading-text {
    color: white;
    font-size: 18px;
    font-weight: bold;
}

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

@media (max-width: 1024px) {
    .map-header {
        flex-direction: column;
        gap: 10px;
        padding: 15px 20px;
    }

    .map-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .exploration-stats {
        justify-content: space-around;
    }

    .minimap-container {
        width: 150px;
        height: 150px;
    }

    .map-legend,
    .location-info {
        width: 220px;
        font-size: 12px;
    }

    .travel-actions {
        padding: 15px 20px;
    }
}

@media (max-width: 768px) {
    .map-header h2 {
        font-size: 20px;
    }

    .map-coordinates {
        font-size: 14px;
        padding: 8px 15px;
    }

    .minimap-container {
        width: 120px;
        height: 120px;
        bottom: 10px;
        right: 10px;
    }

    .map-legend {
        width: 200px;
        top: 10px;
        left: 10px;
    }

    .location-info {
        position: relative;
        width: 100%;
        top: 0;
        left: 0;
        border-radius: 0;
    }

    .travel-actions {
        gap: 10px;
    }

    .travel-btn {
        flex: 1;
        min-width: 120px;
        padding: 10px 15px;
        font-size: 12px;
    }

    .tile-tooltip {
        font-size: 12px;
        padding: 10px;
        min-width: 150px;
    }
}

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

.map-canvas-wrapper:focus {
    outline: 3px solid #f39c12;
    outline-offset: -3px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */

@keyframes tileReveal {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.tile-revealed {
    animation: tileReveal 0.3s ease-out;
}

@keyframes markerBounce {
    0%, 100% {
        transform: translate(-50%, -50%) translateY(0);
    }
    50% {
        transform: translate(-50%, -50%) translateY(-5px);
    }
}

.structure-marker {
    animation: markerBounce 2s infinite;
}
