/* The map (js/map.js, Pages/Map.razor). Leaflet's own styles load with it. */
.map-host {
    position: relative;
    isolation: isolate; /* keeps Leaflet's layers below the app bar and menus */
    height: clamp(420px, calc(100vh - 200px), 1100px);
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--mud-default-borderradius);
    background: var(--mud-palette-background-gray);
    overflow: hidden;
}

.map-host .leaflet-container {
    font: inherit;
}

.map-host .leaflet-tile-pane {
    image-rendering: pixelated; /* enlarged tiles stay crisp blocks */
}

.map-host .leaflet-bar a,
.map-host .map-coords {
    background-color: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    border-color: var(--mud-palette-lines-default);
}

.map-host .leaflet-bar a:hover,
.map-host .leaflet-bar a:focus,
.map-host .leaflet-bar a:active {
    background-color: color-mix(in srgb, var(--mud-palette-surface) 88%, var(--mud-palette-text-primary));
    color: var(--mud-palette-text-primary);
}

.map-host .leaflet-bar a.leaflet-disabled,
.map-host .leaflet-bar a.leaflet-disabled:hover {
    background-color: var(--mud-palette-surface);
    color: var(--mud-palette-text-disabled);
    opacity: 0.6;
}

.map-host .map-coords {
    margin-left: 10px;
    margin-bottom: 10px;
    padding: 2px 8px;
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--mud-default-borderradius);
    pointer-events: none;
}

.map-host .leaflet-popup-content-wrapper,
.map-host .leaflet-popup-tip {
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
}

.map-host .leaflet-popup-close-button {
    color: var(--mud-palette-text-secondary);
}

.map-host .leaflet-tooltip {
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    border-color: var(--mud-palette-lines-default);
}

.map-popup p {
    margin: 4px 0 0;
}

.map-popup .map-popup-meta {
    color: var(--mud-palette-text-secondary);
    font-size: 0.8rem;
}

.map-popup a.map-popup-link {
    display: inline-block;
    margin-top: 6px;
    color: var(--mud-palette-primary);
    text-decoration: underline;
}

.map-hover {
    width: max-content;
    max-width: 260px;
}

.map-hover p {
    margin: 2px 0 0;
    white-space: normal;
    color: var(--mud-palette-text-secondary);
}

.map-popup-command {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    user-select: all;
}

.map-popup-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.map-popup .map-popup-button-inline {
    padding: 3px 10px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--mud-default-borderradius);
    background: none;
    color: var(--mud-palette-text-primary);
    font: inherit;
    cursor: pointer;
}

.map-popup .map-popup-button-inline:hover,
.map-popup .map-popup-button-inline:focus-visible {
    background: color-mix(in srgb, var(--mud-palette-surface) 88%, var(--mud-palette-text-primary));
}

.map-host .map-pin {
    color: var(--mud-palette-error);
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}

/* Markers: a round badge per kind, drawn over the places. */
.map-host .map-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid #fff;
    color: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.map-host .map-marker.book { background: #7a4a12; }
.map-host .map-marker.seen { background: #1f5fa8; }
.map-host .map-marker.bed { background: #7b1fa2; }
.map-host .map-marker.spawn { background: #2e7d32; }

/* A cluster of markers: the same badge, bigger, with the count; the words are for screen readers. */
.map-host .map-cluster {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.85);
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

.map-host .map-cluster.book { background: #7a4a12; }
.map-host .map-cluster.seen { background: #1f5fa8; }
.map-host .map-cluster.bed { background: #7b1fa2; }
.map-host .map-cluster.sign { background: #5d6b73; }
.map-host .map-marker.sign { background: #5d6b73; }

.map-host .map-cluster .map-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* The played area: a white dashed line with a dark edge, readable over any terrain. */
.map-host path.map-scan {
    stroke: #fff;
    stroke-opacity: 0.95;
    fill: none;
    pointer-events: none;
    filter: drop-shadow(0 0 1px #000) drop-shadow(0 0 1px #000);
}

/* The activity heatmap: one pixel to a chunk, enlarged as crisp squares. */
.map-host .map-heat {
    image-rendering: pixelated;
}

.map-host .map-legend {
    margin-right: 10px;
    margin-bottom: 10px;
    padding: 6px 10px;
    width: 220px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--mud-default-borderradius);
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    font-size: 0.8rem;
    cursor: default;
}

.map-legend-bar {
    height: 10px;
    margin: 4px 0 2px;
    border: 1px solid var(--mud-palette-lines-default);
}

.map-legend-ends {
    display: flex;
    justify-content: space-between;
}

.map-legend-note {
    color: var(--mud-palette-text-secondary);
}

.map-popup-list {
    padding-left: 0;
    list-style: none;
}

.map-popup-list {
    margin: 4px 0;
    padding-left: 18px;
    max-height: 180px;
    overflow-y: auto;
}

/* The toolbar above the map (Pages/Map.razor) is a list toolbar (site.css); only the world select is narrower. */
.list-toolbar .map-world {
    flex: 0 1 180px;
    min-width: 140px;
}

.map-layer-check {
    margin: 0;
}

.map-seed {
    font-size: 0.8rem;
    overflow-wrap: anywhere;
}

.map-world-table th {
    width: 8.5rem;
    font-weight: 400;
    color: var(--mud-palette-text-secondary);
}
