/* Aftermath web map. Look follows the in-game menu: near-black translucent panels, white bold text,
   muted #aab2b6, accent #1e88e5, 2 px corners, #646d72 button borders. */

:root {
	--bg: #12161a;
	--text: #fff;
	--muted: #aab2b6;
	--chip-text: #c9d1d5;
	--accent: #1e88e5;
	--border: #646d72;
	--panel: rgba(0, 0, 0, 0.6);
	--radius: 2px;
	/* A dark outline that keeps text readable over any part of the map. */
	--outline: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000, 0 0 3px rgba(0, 0, 0, 0.8);
	--font: "Gotham", "Roboto", system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); }
body { font: 500 15px/1.25 var(--font); color: var(--text); -webkit-text-size-adjust: 100%; }
button, input { font: inherit; color: inherit; }

#app { position: fixed; inset: 0; overflow: hidden; }

.fatal { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; text-align: center; color: var(--muted); font-weight: 700; }

/* ---------- map ---------- */

.map {
	position: absolute; inset: 0; overflow: hidden; background: var(--bg);
	touch-action: none; /* we handle pan and pinch ourselves */
	user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
	cursor: grab; outline: none;
}
.map.dragging { cursor: grabbing; }
.map:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }

.tile-level { position: absolute; left: 0; top: 0; }
.tile {
	position: absolute; left: 0; top: 0; max-width: none;
	opacity: 0; transition: opacity 250ms ease-out;
	pointer-events: none; image-rendering: auto;
}
.tile.loaded { opacity: 1; }
.tile.failed { visibility: hidden; } /* never a broken-image icon */

.grid { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 20; }
.grid-line { position: absolute; left: 0; top: 0; background: rgba(255, 255, 255, 0.28); }
.grid-line.v { width: 1px; }
.grid-line.h { height: 1px; }
.grid-label { position: absolute; left: 0; top: 0; font-size: 14px; font-weight: 700; line-height: 1; white-space: nowrap; text-shadow: var(--outline); }

/* ---------- markers ---------- */

.markers { position: absolute; left: 0; top: 0; z-index: 30; }
.mk { position: absolute; left: 0; top: 0; width: 0; height: 0; }
.mk .sym { position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); cursor: pointer; }
.mk .hit::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; } /* larger touch target */

.sym { display: inline-block; position: relative; border-radius: 50%; flex: none; }
.sym-dot { border: 1.5px solid #000; }
.sym-badge { border: 1.5px solid #fff; }
.sym-glyph { position: absolute; inset: 19%; -webkit-mask: no-repeat center / contain; mask: no-repeat center / contain; }
.sym-cluster {
	width: 26px; height: 26px; background: #1c2024; border: 1.5px solid #fff;
	display: flex; align-items: center; justify-content: center;
	font-size: 12px; font-weight: 700; line-height: 1; letter-spacing: -0.02em;
}

.mk-label {
	position: absolute; left: 0; transform: translateX(-50%);
	white-space: nowrap; font-weight: 700; line-height: 1.1; text-shadow: var(--outline);
	pointer-events: none;
}
.mk-badge .mk-label { color: #fff; font-size: 12px; }

.tooltip {
	position: absolute; left: 0; top: 0; z-index: 60; display: none; pointer-events: none;
	background: rgba(0, 0, 0, 0.82); border-radius: var(--radius); padding: 6px 9px; max-width: 260px;
}
.tt-name { font-weight: 700; font-size: 15px; }
.tt-type { color: var(--muted); font-size: 13px; margin-top: 1px; }
.tt-pos { color: var(--chip-text); font-size: 13px; margin-top: 3px; white-space: pre; font-variant-numeric: tabular-nums; }

/* ---------- pin ---------- */

.pin { position: absolute; left: 0; top: 0; z-index: 50; width: 0; height: 0; }
.pin-head {
	position: absolute; left: -9px; top: -22px; width: 18px; height: 18px;
	background: var(--accent); border: 2px solid #fff; border-radius: 50% 50% 50% 0;
	transform: rotate(-45deg); transform-origin: 50% 50%; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.pin-card {
	position: absolute; left: 0; bottom: 30px; transform: translateX(-50%);
	background: rgba(0, 0, 0, 0.82); border-radius: var(--radius); padding: 7px 8px;
	cursor: default; user-select: text; -webkit-user-select: text;
}
.pc-pos { white-space: pre; font-weight: 700; color: var(--chip-text); font-variant-numeric: tabular-nums; }
.pc-actions { display: flex; gap: 6px; margin-top: 6px; }
.pc-actions .btn { padding: 3px 10px; }
.pc-close { margin-left: auto; }
.pc-link {
	display: none; width: 240px; margin-top: 6px; padding: 3px 5px; font-size: 12px;
	background: #000; border: 1px solid var(--border); border-radius: var(--radius); color: var(--chip-text);
}

/* ---------- UI panels ---------- */

.ui { position: absolute; inset: 0; pointer-events: none; z-index: 100; }
.ui > * { pointer-events: auto; }

.btn {
	background: rgba(0, 0, 0, 0.6); border: 1px solid var(--border); border-radius: var(--radius);
	color: var(--text); font-weight: 700; cursor: pointer; padding: 4px 12px;
}
.btn:hover { border-color: #fff; }
.btn:focus-visible, .legend-row:focus-visible, .search-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Legend: no background, the text carries its own outline. Sits right of the row labels. */
.legend-wrap { position: absolute; left: 34px; top: 46px; }
.legend-toggle { display: none; }
.legend { display: flex; flex-direction: column; gap: 2px; text-shadow: var(--outline); }
.legend-title { color: var(--text); font-size: 14px; font-weight: 500; margin: 0 0 4px 4px; }
.legend-row {
	display: flex; align-items: center; gap: 10px; padding: 3px 4px; background: none; border: 0;
	cursor: pointer; text-align: left; border-radius: var(--radius);
}
.legend-row.off { opacity: 0.4; }
.legend-row .check {
	width: 18px; height: 18px; flex: none; position: relative;
	background: rgba(0, 0, 0, 0.55); border: 1px solid var(--border); border-radius: var(--radius);
}
.legend-row:not(.off) .check::after { content: ""; position: absolute; inset: 3px; background: var(--accent); border-radius: 1px; }
.swatch { width: 22px; height: 22px; flex: none; display: flex; align-items: center; justify-content: center; }
.legend-row .caption { font-size: 16px; font-weight: 500; white-space: nowrap; }

/* Search */
.search { position: absolute; right: 12px; top: 12px; width: 280px; }
.search-input {
	width: 100%; padding: 8px 10px; background: rgba(0, 0, 0, 0.7); border: 1px solid var(--border);
	border-radius: var(--radius); outline: none; font-weight: 500;
}
.search-input::placeholder { color: var(--muted); }
.search-results { list-style: none; margin: 2px 0 0; padding: 0; background: rgba(0, 0, 0, 0.82); border-radius: var(--radius); }
.search-results:empty { display: none; }
.search-item { display: grid; grid-template-columns: 22px 1fr; column-gap: 8px; align-items: center; padding: 6px 10px; cursor: pointer; }
.search-item .swatch { grid-row: span 2; }
.search-item.active, .search-item:hover { background: rgba(30, 136, 229, 0.35); }
.si-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.si-meta { color: var(--muted); font-size: 13px; }
.search-empty { padding: 8px 10px; color: var(--muted); }

/* Zoom buttons and info row */
.zoom-buttons { position: absolute; right: 12px; bottom: 56px; display: flex; flex-direction: column; gap: 4px; }
.zoom-buttons .btn { width: 36px; height: 36px; padding: 0; font-size: 20px; line-height: 1; }

.info-row { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 6px; align-items: stretch; }
.chip {
	background: var(--panel); border-radius: var(--radius); color: var(--chip-text);
	font-size: 15px; font-weight: 500; padding: 6px 12px; display: flex; align-items: center; white-space: nowrap;
}
.chip.btn { border: 1px solid var(--border); color: var(--chip-text); font-weight: 500; }
.readout { gap: 22px; font-variant-numeric: tabular-nums; min-width: 210px; }
.ro-x, .ro-z { min-width: 62px; }
.scale { flex-direction: column; align-items: center; justify-content: center; padding: 3px 12px 6px; min-width: 164px; }
.scale-label { font-size: 13px; line-height: 1.2; }
.scale-bar { display: block; height: 3px; margin-top: 3px; background: #fff; border-radius: 1px; }

/* ---------- narrow screens ---------- */

@media (max-width: 700px) {
	.legend-wrap { left: 28px; top: 28px; }
	.legend-toggle { display: block; }
	.legend { display: none; margin-top: 6px; }
	.legend-wrap.open .legend { display: flex; }
	.search { left: auto; right: 8px; top: 8px; width: min(52vw, 260px); }
	.info-row { right: 8px; bottom: 8px; left: 8px; justify-content: flex-end; flex-wrap: wrap; }
	.readout { min-width: 0; gap: 12px; }
	.chip { font-size: 13px; padding: 5px 8px; }
	.scale { min-width: 0; }
	.zoom-buttons { right: 8px; bottom: 96px; }
}
