/* ==========================================================================
   Mu Next Wiki — Monster Atlas
   Extends wiki.css: same world, same tokens. The one new thing on this page
   is the map stage — a dark in-game exhibit mounted inside a white plate,
   the way the wiki mounts any other record.

   Marker colors are a legend-keyed data encoding that lives only on the
   canvas and in the legend swatches; they are not UI chrome and do not
   touch the gold reservation.
   ========================================================================== */

:root {
  --mk-mob: #d94f4f;
  --mk-npc: #58a8e0;
  --mk-trap: #9aa4ad;
  --mk-safe: rgba(64, 120, 200, 0.28);
}

.atlas-body { min-height: 100vh; display: flex; flex-direction: column; }
.atlas-body .footer { margin-top: auto; }

.atlas {
  width: min(1560px, 100% - 32px);
  margin: 0 auto;
  padding: 28px 0 56px;
}

/* --- Page head ------------------------------------------------------------ */

.atlas__crumb {
  font-size: 13px;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin-bottom: 10px;
}

.atlas__crumb a { color: var(--blue); text-decoration: none; }
.atlas__crumb a:hover { text-decoration: underline; }
.atlas__crumb span { margin: 0 4px; color: var(--blue-soft); }

.atlas__head h1 {
  font-family: 'Constantine', 'Trajan Pro', 'Palatino Linotype', Georgia, serif;
  font-size: clamp(26px, 3vw, 34px);
  letter-spacing: var(--track-display);
  text-transform: uppercase;
  color: var(--blue);
  margin: 0 0 8px;
}

.atlas__lede {
  max-width: 46em;
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--muted);
  margin: 0 0 22px;
}

/* --- Three-panel grid ----------------------------------------------------- */

.atlas__grid {
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr) 288px;
  gap: 18px;
  align-items: start;
}

/* --- Map picker ----------------------------------------------------------- */

.mapnav {
  position: sticky;
  top: 76px;
  background: var(--plate);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.mapnav__scroll { max-height: calc(100vh - 100px); overflow-y: auto; padding: 6px; }

.mapnav h3 {
  font-family: 'Jost', sans-serif;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: var(--track-micro);
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 10px 5px;
  margin: 0;
}

.mapnav h3:first-child { padding-top: 8px; }

.mapnav button {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  border: 0;
  background: none;
  border-radius: 3px;
  padding: 7px 10px;
  font-family: 'Jost', sans-serif;
  font-size: 14.5px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s var(--ease);
}

.mapnav button:hover { background: var(--plate-warm); color: var(--blue); }

.mapnav button.is-on {
  background: rgba(33, 57, 113, 0.07);
  color: var(--blue);
  font-weight: 500;
  box-shadow: inset 2px 0 0 var(--blue);
}

.mapnav button small {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* --- The board ------------------------------------------------------------ */

.board {
  background: var(--plate);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.board__bar {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.board__title {
  font-family: 'Constantine', 'Trajan Pro', 'Palatino Linotype', Georgia, serif;
  font-size: 19px;
  letter-spacing: var(--track-ui);
  text-transform: uppercase;
  color: var(--blue-deep);
  margin: 0;
}

.board__meta { font-size: 13px; color: var(--muted); margin: 0; }

.board__layers { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }

.board__layers button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--plate);
  border-radius: 3px;
  padding: 4px 9px;
  font-family: 'Jost', sans-serif;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s var(--ease), border-color 0.15s var(--ease);
}

.board__layers button::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--sw, var(--blue));
  opacity: 0.35;
}

.board__layers button.is-on { color: var(--text); border-color: rgba(33, 57, 113, 0.35); }
.board__layers button.is-on::before { opacity: 1; }

/* The stage: the one dark surface on the page — it frames the game itself. */
.board__stage {
  position: relative;
  background: #0d1117;
  /* Height set from JS to keep the map square-ish inside the column. */
}

#mapCanvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#mapCanvas.is-panning { cursor: grabbing; }

.board__tip {
  position: absolute;
  display: none;
  pointer-events: none;
  z-index: 4;
  max-width: 260px;
  background: rgba(20, 30, 51, 0.97);
  border: 1px solid var(--plate-edge);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 9px 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
}

.board__tip.is-pinned { pointer-events: auto; }

.board__tip b {
  display: block;
  font-family: 'Constantine', 'Trajan Pro', 'Palatino Linotype', Georgia, serif;
  font-size: 13.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--blue-deep);
  margin-bottom: 3px;
}

.board__tip .r { display: flex; justify-content: space-between; gap: 16px; }
.board__tip .r span:last-child { font-variant-numeric: tabular-nums; color: var(--blue-deep); font-weight: 500; }
.board__tip .c { margin-top: 4px; font-size: 12px; color: var(--muted); }

.board__coord {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 3;
  background: rgba(13, 17, 23, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 3px;
  padding: 3px 8px;
  font-family: 'Jost', sans-serif;
  font-size: 12px;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.85);
}

.board__zoom {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.board__zoom button {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 3px;
  background: rgba(13, 17, 23, 0.72);
  color: rgba(255, 255, 255, 0.9);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s var(--ease);
}

.board__zoom button:hover { background: rgba(33, 57, 113, 0.85); }

.board__hint {
  margin: 0;
  padding: 8px 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  letter-spacing: 0.03em;
  color: var(--muted);
}

/* --- Roster --------------------------------------------------------------- */

.roster {
  position: sticky;
  top: 76px;
  background: var(--plate);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: var(--shadow-sm);
  max-height: calc(100vh - 100px);
  display: flex;
  flex-direction: column;
}

.roster__title {
  font-family: 'Constantine', 'Trajan Pro', 'Palatino Linotype', Georgia, serif;
  font-size: 14px;
  letter-spacing: var(--track-ui);
  text-transform: uppercase;
  color: var(--blue);
  margin: 0;
  padding: 13px 14px 2px;
}

.roster__tabs {
  display: flex;
  gap: 4px;
  margin: 9px 14px 8px;
  padding: 3px;
  background: var(--plate-warm);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
}

.roster__tabs button {
  flex: 1 1 0;
  border: 0;
  background: none;
  border-radius: 3px;
  padding: 6px 8px;
  font-family: 'Jost', sans-serif;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
}

.roster__tabs button:hover { color: var(--blue); }

.roster__tabs button.is-on {
  background: var(--plate);
  color: var(--blue-deep);
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(22, 38, 76, 0.12);
}

.roster__tabs button:disabled { opacity: 0.45; cursor: default; }

.roster__hint { font-size: 12px; color: var(--muted); margin: 0; padding: 0 14px 9px; }

.roster__empty { font-size: 13px; color: var(--muted); padding: 6px 14px 12px; margin: 0; }

.roster__list { list-style: none; margin: 0; padding: 0 6px 6px; overflow-y: auto; }

.roster__list li { border-top: 1px solid var(--line-soft); }
.roster__list li:first-child { border-top: 0; }

.roster__list button {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: center;
  gap: 9px;
  width: 100%;
  border: 0;
  background: none;
  border-radius: 3px;
  padding: 8px;
  font-family: 'Jost', sans-serif;
  font-size: 14px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.roster__list button:hover { background: var(--plate-warm); }
.roster__list button.is-on { background: rgba(33, 57, 113, 0.07); font-weight: 500; color: var(--blue-deep); }

.roster__swatch { width: 10px; height: 10px; border-radius: 50%; background: var(--mk-mob); }
.roster__swatch--npc { background: var(--mk-npc); }
.roster__swatch--trap { background: var(--mk-trap); border-radius: 2px; }
.roster__swatch--boss { background: var(--mk-mob); border-radius: 2px; transform: rotate(45deg); }

.roster__name { min-width: 0; }
.roster__name small { display: block; font-size: 11.5px; color: var(--muted); letter-spacing: 0.02em; }

.roster__count {
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* --- Responsive ----------------------------------------------------------- */

@media (max-width: 1180px) {
  .atlas__grid { grid-template-columns: 200px minmax(0, 1fr); }
  .roster { grid-column: 1 / -1; position: static; max-height: 420px; }
}

@media (max-width: 820px) {
  .atlas { padding-top: 18px; }
  .atlas__grid { grid-template-columns: 1fr; gap: 14px; }

  .mapnav { position: static; }
  .mapnav__scroll { max-height: none; display: flex; gap: 4px; overflow-x: auto; padding: 8px; }
  .mapnav h3 { display: none; }
  .mapnav button { width: auto; white-space: nowrap; padding: 7px 12px; }
  .mapnav button.is-on { box-shadow: inset 0 -2px 0 var(--blue); }

  .board__bar { padding: 10px 12px; }
  .board__layers { margin-left: 0; width: 100%; }
  .board__hint { display: none; }

  .roster { max-height: 340px; }
}
