/* HnH Map Viewer Styles */

/* Map container */
.leaflet-map {
    width: 100%;
    height: 100%;
    background: #000;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0;
}

/* Custom marker styling - distinct visual appearance with dashed border and glow */
.custom-marker {
    position: relative;
    filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.5));
}

.custom-marker::after {
    content: "";
    position: absolute;
    inset: -6px;
    border: 2px dashed #43a047;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(67, 160, 71, 0.7);
    animation: custom-marker-pulse 2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes custom-marker-pulse {
    0%, 100% {
        opacity: 0.6;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}

/* Controls hint - subtle info panel without animation */
.controls-hint {
    background: rgba(255, 255, 255, 0.92) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.12) !important;
}

/* Override MudExpansionPanel default styling within controls hint */
.controls-hint .mud-expand-panel {
    background: transparent !important;
}

.controls-hint .mud-expand-panel-header {
    padding: 8px 12px !important;
    min-height: unset !important;
}

.controls-hint .mud-expand-panel-content {
    padding: 0 !important;
}

/* Leaflet container */
.leaflet-container {
    background: #000 !important;
}

/* Smooth tile opacity transitions - works in tandem with JS crossfade logic */
.leaflet-tile {
    /* Base transition for tiles not handled by JS crossfade (e.g., initial load) */
    transition: opacity 200ms ease-in;
    /* Start tiles slightly transparent for smoother fade-in */
    opacity: 0;
    /* Subtle shimmer effect while loading (only visible for tiles taking >2s) */
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.03) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    background-size: 200% 100%;
    animation: tile-shimmer 3s ease-in-out infinite;
}

/* Shimmer animation - very subtle, only noticeable on slow-loading tiles */
@keyframes tile-shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Loaded tiles are fully opaque and stop shimmering */
.leaflet-tile-loaded {
    opacity: 1 !important;
    animation: none !important;
    background: none !important;
}

/* Loading overlay - very subtle dim overlay when many tiles are loading */
.tile-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 300ms ease-in-out;
    pointer-events: none;
    z-index: 500;
}

/* Map tile grid lines */
.map-tile {
    border-bottom: 1px solid #404040;
    border-right: 1px solid #404040;
    color: #404040;
    font-size: 12px;
    box-sizing: border-box;
}

/* Map tile coordinate text */
.map-tile-text {
    position: absolute;
    left: 2px;
    top: 2px;
    color: #FDB800;
    font-size: 10px;
    text-shadow: -1px -1px #000, 1px 1px #000, -1px 1px #000, 1px -1px #000;
    pointer-events: none;
}

/* Leaflet tooltips */
.leaflet-tooltip {
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: #FDB800 !important;
    font-size: 10px !important;
    text-shadow: -1px -1px #000, 1px 1px #000, -1px 1px #000, 1px -1px #000 !important;
}

.leaflet-tooltip-top:before,
.leaflet-tooltip-bottom:before,
.leaflet-tooltip-left:before,
.leaflet-tooltip-right:before {
    border: none !important;
}

/* Character tooltips */
.character-tooltip {
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* Leaflet popups - default styling for resource markers */
.leaflet-popup-content-wrapper {
    background: transparent !important;
    box-shadow: none !important;
}

.leaflet-popup-content {
    font-size: 13px !important;
    color: #ffffff !important;
    text-shadow: -1px -1px #000, 1px 1px #000, -1px 1px #000, 1px -1px #000 !important;
    text-align: center !important;
}

.leaflet-popup-tip {
    display: none !important;
}

/* Custom marker popup - override defaults with opaque white background and clear text */
.custom-marker-popup .leaflet-popup-content-wrapper {
    background: white !important;
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.4) !important;
    border-radius: 8px !important;
    padding: 0 !important;
}

.custom-marker-popup .leaflet-popup-content {
    margin: 0 !important;
    font-size: 14px !important;
    color: #333 !important;
    text-shadow: none !important;
    text-align: left !important;
    line-height: 1.5 !important;
}

.custom-marker-popup .leaflet-popup-tip {
    display: block !important;
    background: white !important;
}

.custom-marker-popup .leaflet-popup-close-button {
    color: #666 !important;
    font-size: 18px !important;
    padding: 4px 8px !important;
    text-shadow: none !important;
}

.custom-marker-popup .leaflet-popup-close-button:hover {
    color: #333 !important;
}

/* Leaflet controls */
.leaflet-control {
    margin: auto !important;
}

/* Hide Leaflet attribution */
.leaflet-control-attribution {
    display: none !important;
}

/* Context menu styling */
.context-menu {
    position: fixed;
    z-index: 2000;
    min-width: 200px;
}

/* Sidebar customization - needs !important to override MudBlazor defaults */
.mud-drawer {
    z-index: 1000 !important;
}

/* Ensure map is behind sidebar */
.leaflet-map {
    z-index: 0;
}

/* Autocomplete item images */
.marker-autocomplete-item img {
    width: 24px;
    height: 24px;
    margin-right: 8px;
    vertical-align: middle;
}

/* Leaflet zoom controls */
.leaflet-control-zoom {
    border: 2px solid rgba(0,0,0,0.2) !important;
    background: rgba(255, 255, 255, 0.9) !important;
}

/* Marker clustering (if needed) */
.marker-cluster-small {
    background-color: rgba(181, 226, 140, 0.6);
}

.marker-cluster-small div {
    background-color: rgba(110, 204, 57, 0.6);
}

.marker-cluster-medium {
    background-color: rgba(241, 211, 87, 0.6);
}

.marker-cluster-medium div {
    background-color: rgba(240, 194, 12, 0.6);
}

.marker-cluster-large {
    background-color: rgba(253, 156, 115, 0.6);
}

.marker-cluster-large div {
    background-color: rgba(241, 128, 23, 0.6);
}

/* Marker icons - smooth transitions during zoom and pan */
.leaflet-marker-icon {
    border: none !important;
    /* Smooth sub-pixel positioning during zoom */
    transform-origin: center center;
    transition: transform 200ms ease-out, opacity 200ms ease-out;
    will-change: transform;
}

/* Prevent marker pop/jump during zoom level changes */
.leaflet-zoom-animated .leaflet-marker-icon {
    transition: transform 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Animation for character movement */
@keyframes slideMarker {
    from {
        transform: translate(0, 0);
    }
    to {
        transform: translate(var(--slide-x), var(--slide-y));
    }
}

.character-sliding {
    animation: slideMarker linear;
}

/* Smooth marker fade during zoom transitions */
.leaflet-marker-pane {
    transition: opacity 150ms ease-out;
}

/* Popover z-index for toolbar dropdowns */
.map-toolbar .mud-select .mud-popover,
.map-toolbar .mud-autocomplete .mud-popover,
.map-toolbar .mud-menu .mud-popover {
    z-index: 2000 !important;
}

/* Ensure dialog containers don't have transforms that break fixed positioning */
.mud-dialog-container,
.mud-dialog {
    transform: none;
    overflow: visible;
}

/* Local positioning context for inline popovers inside dialogs */
.icon-autocomplete-context {
    position: relative;
}

.icon-autocomplete-context .mud-popover {
    position: absolute;
    z-index: 1500;
}

/* Icon autocomplete popover: keep within dialog and prefer input alignment */
.icon-autocomplete-popover {
    max-width: 100%;
    overflow-x: hidden;
    max-height: 300px;
    overflow-y: auto;
}

/* Ping marker styling - pulsing red circle with expanding rings */
.ping-icon-container {
    background: transparent !important;
    border: none !important;
}

.ping-marker {
    position: relative;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Core red circle */
.ping-core {
    position: absolute;
    width: 20px;
    height: 20px;
    background: #f44336;
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 0 10px rgba(244, 67, 54, 0.8);
    z-index: 2;
}

/* Expanding pulse rings */
.ping-pulse {
    position: absolute;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 3px solid #f44336;
    opacity: 1;
    animation: ping-pulse-animation 1.5s ease-out infinite;
    z-index: 1;
}

@keyframes ping-pulse-animation {
    0% {
        transform: scale(0.5);
        opacity: 1;
        border-width: 3px;
    }
    50% {
        opacity: 0.7;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
        border-width: 1px;
    }
}

/* Ping marker tooltip */
.ping-icon-container .leaflet-tooltip {
    background-color: rgba(244, 67, 54, 0.9) !important;
    border: 1px solid #fff !important;
    border-radius: 4px !important;
    padding: 4px 8px !important;
    color: #fff !important;
    font-size: 12px !important;
    font-weight: bold !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3) !important;
}
