/* The raid map (spec 31): card tiles on a dotted canvas, curved wires, a pan / zoom stage.
   Theme tokens only, so every screen theme recolours it. Loaded after main.css. */

/* ----- the full map: stage + detail panel */
.mapview { display: grid; gap: var(--sp-4); }
.mapview__main { display: grid; gap: var(--sp-3); }
@media (min-width: 900px) {
  .mapview__main { grid-template-columns: minmax(0, 1fr) 250px; align-items: stretch; }
}
.mapview__stage {
  position: relative; overflow: clip; touch-action: none; user-select: none; -webkit-user-select: none;
  height: clamp(300px, 92vw, 58dvh); min-height: 280px;
  background: var(--bg-deep);
  border: 1px solid var(--line-2);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cyan) 5%, transparent), inset 0 0 60px rgba(0, 0, 0, 0.45);
  cursor: grab; outline: none;
}
@media (min-width: 900px) { .mapview__stage { height: min(64dvh, 560px); } }
.mapview__stage.is-dragging { cursor: grabbing; }
.mapview__stage:focus-visible { border-color: var(--cyan); box-shadow: 0 0 0 2px var(--cyan-glow); }
/* corner ticks: the stage's boundary reads as a screen */
.mapview__stage::before, .mapview__stage::after {
  content: ""; position: absolute; width: 14px; height: 14px; pointer-events: none; z-index: 2;
  border: 2px solid var(--cyan-dim);
}
.mapview__stage::before { left: 3px; top: 3px; border-right: 0; border-bottom: 0; }
.mapview__stage::after { right: 3px; bottom: 3px; border-left: 0; border-top: 0; }
.nodemap.nodemap--full { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.mapview__hud {
  position: absolute; left: 10px; right: 10px; top: 8px; z-index: 2; pointer-events: none;
  display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2);
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; color: var(--text-faint);
}
.mapview__title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mapview__zoompct {
  color: var(--cyan); padding: 1px 6px; border: 1px solid var(--line-2); background: color-mix(in srgb, var(--bg-deep) 85%, transparent);
  font-variant-numeric: tabular-nums; min-width: 5ch; text-align: right;
}
.mapview__ctrls {
  position: absolute; right: 8px; bottom: 8px; z-index: 3;
  display: grid; gap: 4px;
}
.mapview__btn {
  display: grid; place-items: center; width: 40px; height: 40px; padding: 0;
  background: color-mix(in srgb, var(--panel) 92%, transparent); color: var(--cyan);
  border: 1px solid var(--line-2); cursor: pointer;
}
.mapview__btn .icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mapview__btn:hover { border-color: var(--cyan); background: var(--cyan-wash); }
.mapview__btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 1px; }
.mapview__btn--me { margin-top: 4px; }
@media (pointer: coarse) { .mapview__btn { width: 44px; height: 44px; } }

/* ----- canvas */
.nodemap__bg { fill: var(--bg-deep); }
.nodemap__dot { fill: color-mix(in srgb, var(--cyan) 22%, transparent); }
.nodemap__grid line { stroke: color-mix(in srgb, var(--cyan) 7%, transparent); stroke-width: 1; vector-effect: non-scaling-stroke; }
.nodemap__frame { fill: none; stroke: color-mix(in srgb, var(--cyan) 10%, transparent); stroke-width: 1; stroke-dasharray: 2 6; vector-effect: non-scaling-stroke; }

/* ----- wires */
.mlink { fill: none; stroke-linecap: round; vector-effect: non-scaling-stroke; stroke-width: 1.4; }
.mlink.is-untravelled { stroke: var(--cyan-dim); stroke-dasharray: 5 5; }
.mlink.is-unknown { stroke: var(--line-2); stroke-dasharray: 3 6; }
.mlink.is-walked { stroke: var(--cyan); stroke-width: 2; }
.mlink.is-here.is-untravelled { stroke: color-mix(in srgb, var(--cyan) 75%, var(--cyan-dim)); }
.mlink.is-here.is-unknown { stroke: var(--cyan-dim); }
.mlink--loud.is-untravelled, .mlink--loud.is-unknown { stroke-dasharray: 9 4; }
.mlink--quiet.is-untravelled, .mlink--quiet.is-unknown { stroke-dasharray: 1.5 5; stroke-width: 1.8; }
.mroute__glow { fill: none; stroke: var(--cyan); stroke-opacity: 0.22; stroke-width: 9; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.mroute__flow { fill: none; stroke: var(--cyan-hi); stroke-width: 2.4; stroke-linecap: round; stroke-dasharray: 10 7; vector-effect: non-scaling-stroke; animation: mroute-flow 0.9s linear infinite; }
@keyframes mroute-flow { from { stroke-dashoffset: 17; } to { stroke-dashoffset: 0; } }
html[data-motion="reduced"] .mroute__flow { animation: none; stroke-dasharray: none; }
@media (prefers-reduced-motion: reduce) { .mroute__flow { animation: none; stroke-dasharray: none; } }
.mnub { fill: var(--bg-deep); stroke: var(--cyan-dim); stroke-width: 1.2; }
.mnub.is-here { stroke: var(--cyan); }
.mnub.is-route { fill: var(--cyan-hi); stroke: var(--cyan-hi); }
.kindmark circle, .kindmark path { fill: var(--bg-deep); stroke-width: 1; }
.kindmark--quiet circle { stroke: var(--cyan-dim); }
.kindmark--loud path { stroke: var(--text-dim); }
.kindmark text { fill: var(--text-dim); font-family: var(--mono); font-size: 9px; font-weight: 800; }
.routenum circle { fill: var(--bg-deep); stroke: var(--cyan); stroke-width: 1.5; }
.routenum text { fill: var(--cyan); font-family: var(--mono); font-size: 10px; font-weight: 800; }
.routenum.is-route circle { fill: var(--cyan); }
.routenum.is-route text { fill: var(--on-cyan); }

/* ----- tiles */
.mnode { cursor: pointer; outline: none; }
.mnode__hit { fill: transparent; }
.mnode__body { fill: var(--panel); stroke: var(--cyan-dim); stroke-width: 1.6; stroke-linejoin: round; }
.mnode__inner { fill: none; stroke: color-mix(in srgb, var(--cyan) 45%, transparent); stroke-width: 1; stroke-linejoin: round; }
.mglyph path { fill: none; stroke: var(--cyan); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.mglyph--small path { stroke-width: 2.4; }
.mnode.is-known .mnode__body { fill: var(--panel); stroke: color-mix(in srgb, var(--cyan-dim) 80%, var(--line-2)); }
.mnode.is-known .mglyph path { stroke: color-mix(in srgb, var(--cyan) 70%, var(--text-dim)); }
.mnode.is-visited .mnode__body { fill: color-mix(in srgb, var(--cyan) 10%, var(--panel)); stroke: var(--cyan); }
.mnode.is-current .mnode__body { fill: color-mix(in srgb, var(--cyan) 26%, var(--panel)); stroke: var(--cyan-hi); stroke-width: 2.2; }
.mnode.is-current .mglyph path { stroke: var(--cyan-hi); }
.mnode__brackets { fill: none; stroke: var(--cyan-hi); stroke-width: 2.4; stroke-linecap: square; animation: mbrackets 2.4s ease-in-out infinite; }
@keyframes mbrackets { 50% { opacity: 0.45; } }
html[data-motion="reduced"] .mnode__brackets { animation: none; }
@media (prefers-reduced-motion: reduce) { .mnode__brackets { animation: none; } }
.mnode.is-unknown .mnode__body { fill: var(--bg-deep); stroke: var(--line-2); stroke-dasharray: 4 3; }
.mnode.is-unknown .mglyph path { stroke: var(--text-faint); }
.mnode.is-unknown.is-reachable .mnode__body { stroke: var(--cyan-dim); fill: color-mix(in srgb, var(--cyan) 5%, var(--bg-deep)); }
.mnode.is-unknown.is-reachable .mglyph path { stroke: var(--cyan); }
/* danger tint: a warmer body and red bars in the corner */
.mnode.danger-2:not(.is-current) .mnode__body { fill: color-mix(in srgb, var(--red) 6%, var(--panel)); }
.mnode.danger-3:not(.is-current) .mnode__body { fill: color-mix(in srgb, var(--red) 11%, var(--panel)); }
.mnode__pips rect { fill: var(--red); }
.mnode.danger-1 .mnode__pips rect { fill: color-mix(in srgb, var(--red) 70%, var(--text-dim)); }
/* exits */
.mnode.is-exit .mnode__body { stroke: var(--cyan-hi); }
.mnode.is-exit.is-closed .mnode__body { stroke: var(--red); stroke-dasharray: 5 3; }
.mnode.is-exit.is-closed .mnode__inner { stroke: color-mix(in srgb, var(--red) 50%, transparent); }
.mnode.is-exit.is-closed .mglyph path { stroke: var(--red); }
.mnode__cond circle { fill: var(--bg-deep); stroke: var(--cyan); stroke-width: 1.2; }
.mnode__cond .mglyph path { stroke: var(--cyan-hi); }
.mnode__tick circle { fill: var(--cyan-deep); stroke: var(--cyan); stroke-width: 1; }
.mnode__tick .mglyph path { stroke: var(--cyan-hi); }
.mnode__key circle { fill: var(--bg-deep); stroke: var(--text-dim); stroke-width: 1.2; }
.mnode__key .mglyph path { stroke: var(--text-dim); }
.mnode__key.has-key circle { fill: var(--cyan-deep); stroke: var(--cyan); }
.mnode__key.has-key .mglyph path { stroke: var(--cyan-hi); }
.mnode__key.is-marked circle { stroke: var(--t-epic); }
.mnode__key.is-marked .mglyph path { stroke: var(--t-epic); fill: color-mix(in srgb, var(--t-epic) 35%, transparent); }
.mnode__key.is-looted { opacity: 0.45; }
.mnode__keyn { fill: var(--text-dim); font-family: var(--mono); font-size: 9px; font-weight: 800; }
/* destination, selection, focus */
.mnode__destring { fill: none; stroke: var(--t-valuable); stroke-width: 1.6; stroke-dasharray: 6 4; }
.mnode__sel { fill: none; stroke: var(--cyan); stroke-width: 1.6; display: none; }
.mnode.is-selected .mnode__sel, .mnode:focus-visible .mnode__sel { display: block; }
.mnode:focus-visible .mnode__sel { stroke: var(--cyan-hi); stroke-width: 2.4; }
.mnode:hover .mnode__body { stroke: var(--cyan-hi); }

/* label plates */
.mplate rect { fill: color-mix(in srgb, var(--bg-deep) 88%, transparent); stroke: var(--line-2); stroke-width: 1; }
.mplate text { fill: var(--text); font-family: var(--mono); font-weight: 700; }
.mplate__short text { letter-spacing: 0.04em; }
.mnode.is-current .mplate rect { stroke: var(--cyan); fill: color-mix(in srgb, var(--cyan) 14%, var(--bg-deep)); }
.mnode.is-current .mplate text { fill: var(--cyan-hi); }
.mnode.is-known .mplate text { fill: var(--text-dim); }
.mnode.is-exit .mplate rect { stroke: var(--cyan-dim); }
.mnode.is-dest .mplate rect { stroke: var(--t-valuable); }
.mplate__q text { fill: var(--text-faint); }
.mplate__q rect { stroke-dasharray: 3 2; }
.mplate__short { display: none; }
.nodemap.is-far .mplate__full { display: none; }
.nodemap.is-far .mplate__short { display: inline; }
.nodemap.is-far .kindmark { display: none; }

/* chips above tiles */
.mchip rect { fill: var(--bg-deep); stroke: var(--cyan-dim); stroke-width: 1; }
.mchip text { fill: var(--cyan); font-family: var(--mono); font-weight: 800; letter-spacing: 0.06em; }
.mchip--you rect { fill: var(--cyan); stroke: var(--cyan-hi); }
.mchip--you text { fill: var(--on-cyan); }
.mchip--dest rect { stroke: var(--t-valuable); }
.mchip--dest text { fill: var(--t-valuable); }
.mchip--warn rect { stroke: var(--t-valuable); fill: color-mix(in srgb, var(--t-valuable) 12%, var(--bg-deep)); }
.mchip--warn text { fill: var(--t-valuable); }
.mchip--late rect, .mchip--closed rect { stroke: var(--red); fill: color-mix(in srgb, var(--red) 14%, var(--bg-deep)); }
.mchip--late text, .mchip--closed text { fill: var(--red); }
.mchip--sel rect { stroke: var(--cyan); }

/* ----- detail panel */
.mapdetail {
  display: grid; align-content: start; gap: var(--sp-2);
  padding: var(--sp-3); background: var(--panel-2); border: 1px solid var(--line); border-left: 2px solid var(--cyan-dim);
  font-size: var(--fs-s); min-height: 0;
}
.mapdetail p { margin: 0; }
.mapdetail h3 { font-size: var(--fs-m); color: var(--cyan); margin: 0; }
.mapdetail__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px var(--sp-2); }
.mapdetail__type { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-faint); }
.mapdetail__facts { display: grid; gap: 2px; color: var(--text-dim); }
.mapdetail__route { color: var(--text); }
.mapdetail__route strong { color: var(--cyan); }
.mapdetail__actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.mapdetail__hint { color: var(--text-faint); }
.mapdetail__dest { display: grid; gap: 4px; padding: var(--sp-2); border: 1px solid var(--t-valuable); background: var(--panel); }
.mapdetail__dest h3 { color: var(--t-valuable); font-size: var(--fs-s); }
.mapdetail .warn { color: var(--red); }
.mapdetail .ok { color: var(--cyan); }

/* ----- legend and lists (the text version of the map) */
.maplegend__key summary { cursor: pointer; color: var(--cyan); font-size: var(--fs-s); min-height: 32px; display: flex; align-items: center; }
.maplegend__key .maplegend__keys { margin-top: var(--sp-2); }
.lg2 { display: inline-grid; place-items: center; width: 16px; height: 14px; flex: none; font-size: 10px; font-weight: 800; font-family: var(--mono); color: var(--text-dim); }
.lg2--you { background: color-mix(in srgb, var(--cyan) 30%, var(--panel)); border: 2px solid var(--cyan-hi); }
.lg2--visited { background: color-mix(in srgb, var(--cyan) 10%, var(--panel)); border: 1.5px solid var(--cyan); }
.lg2--known { background: var(--panel); border: 1.5px solid var(--cyan-dim); }
.lg2--unknown { border: 1px dashed var(--line-2); }
.lg2--exit { border: 1.5px solid var(--cyan-hi); box-shadow: inset 0 0 0 2px var(--panel), inset 0 0 0 3px var(--cyan-dim); }
.lg2--dest { border: 1.5px dashed var(--t-valuable); }
.lg2--pips { background: linear-gradient(90deg, var(--red) 0 3px, transparent 3px 5px, var(--red) 5px 8px, transparent 8px); width: 10px; height: 8px; }
.lg2--tick { color: var(--cyan-hi); background: var(--cyan-deep); border-radius: 50%; width: 14px; }
.lg2--keyb { border: 1.5px solid var(--text-dim); border-radius: 50%; width: 14px; }
.lg2--walked { height: 0; width: 22px; border-top: 2px solid var(--cyan); }
.lg2--dashed { height: 0; width: 22px; border-top: 2px dashed var(--cyan-dim); }
.lg2--route { height: 4px; width: 22px; background: var(--cyan-hi); box-shadow: 0 0 0 3px color-mix(in srgb, var(--cyan) 22%, transparent); }
.lg2--quiet { border: 1px solid var(--cyan-dim); border-radius: 50%; width: 14px; }
.lg2--loud { border: 1px solid var(--text-dim); transform: rotate(45deg) scale(0.8); }
.lg2--num { border: 1.5px solid var(--cyan); border-radius: 50%; color: var(--cyan); width: 15px; height: 15px; }
.maplegend__places li.is-route { color: var(--cyan-hi); }

/* ----- the mini map: same language, simplified */
.nodemap--compact .mlink { stroke-width: 1.2; }
.nodemap--compact .mroute__glow { stroke-width: 6; }
.nodemap--compact .mroute__flow { stroke-width: 2; }
.nodemap--compact .mnode { cursor: inherit; }
.minimap .nodemap--compact { width: 100%; height: auto; display: block; background: var(--bg-deep); }
.nodemap .mnode[role="button"]:focus-visible .mnode__hit { stroke: none; }
/* zoomed out: only the chips that matter at a glance */
.nodemap.is-far .mchip--warn, .nodemap.is-far .mchip--sel { display: none; }
