/* ============================================================
   Empyria IV — Nodes addon styles (engine v2)
   Loaded from index.html BEFORE css/dossier-live.css, which repositions
   #nk-ui-br / #nk-maptypes for the sea-chart skin. Class names are the
   same nk-* contract used by map-ui/ and dossier-chrome.js.
   ============================================================ */
:root {
  --nk-panel-width: 360px;
  --nk-town-label-up: 4px;
  --nk-font-type: "Special Elite", "Courier New", monospace;
  --nk-font-display: "Cinzel", "IM Fell English", Georgia, serif;
  --nk-panel-max-h: calc(100vh - 120px);
}

/* ---------- panes ---------- */
.nk-tiles { image-rendering: auto; }
.nk-overlay-canvas { pointer-events: none; }

/* ---------- bottom-right UI root (repositioned by dossier-live.css) ---------- */
#nk-ui-br {
  position: absolute; right: 12px; bottom: 12px; z-index: 1500;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
  pointer-events: none;
}

/* ---------- territory panel ---------- */
.nk-panel {
  width: var(--nk-panel-width); max-width: calc(100vw - 48px);
  max-height: var(--nk-panel-max-h);
  display: flex; flex-direction: column;
  color: #2c1308; pointer-events: auto; position: relative; z-index: 2;
  background: #e9dcb7; border: 1px solid rgba(90,58,22,.5); border-radius: 3px;
  box-shadow: 2px 3px 6px rgba(0,0,0,.25), inset 0 0 0 2px rgba(90,58,22,.18);
  font-family: var(--nk-font-type);
  overflow: hidden;
}
.nk-panel__body { padding: 10px 12px; overflow-y: auto; min-height: 0; scrollbar-width: thin; scrollbar-color: rgba(90,58,22,.55) transparent; }
.nk-panel__body::-webkit-scrollbar { width: 7px; }
.nk-panel__body::-webkit-scrollbar-thumb { background: rgba(90,58,22,.5); border-radius: 4px; }

.nk-h1 { font: 600 14px/1.2 var(--nk-font-display); margin: 0 0 6px; color: #2c1308; border-bottom: 1.5px solid rgba(90,58,22,.5); padding-bottom: 2px; letter-spacing: .06em; }
.nk-kv { list-style: none; margin: 0; padding: 0; display: block !important; }
.nk-kv li { display: block !important; margin: 4px 0; font-size: 12px; line-height: 1.35; color: #2c1308; white-space: normal; border-bottom: 1px dotted rgba(90,58,22,.35); padding-bottom: 3px; overflow-wrap: anywhere; }
.nk-kv b { color: #2c1308; font-family: var(--nk-font-type); }
.nk-gap { height: 8px; }

/* players roster: fixed-height scroll box + numeric counter */
.nk-players { margin: 8px 0 2px; border: 1px solid rgba(90,58,22,.35); border-radius: 2px; background: rgba(255,246,216,.35); }
.nk-players__head { display: flex; align-items: center; justify-content: space-between; padding: 5px 8px; font: 700 11px/1 var(--nk-font-type); letter-spacing: .12em; text-transform: uppercase; color: #2c1308; border-bottom: 1px solid rgba(90,58,22,.3); }
.nk-players__count { min-width: 22px; padding: 2px 7px; border-radius: 999px; text-align: center; font: 700 11px/1.3 var(--nk-font-type); color: #fff6d8; background: #7c1f16; letter-spacing: 0; }
.nk-players__list { list-style: none; margin: 0; padding: 4px 0; max-height: 168px; overflow-y: auto; display: block !important; scrollbar-width: thin; scrollbar-color: rgba(90,58,22,.55) transparent; }
.nk-players__list::-webkit-scrollbar { width: 7px; }
.nk-players__list::-webkit-scrollbar-thumb { background: rgba(90,58,22,.5); border-radius: 4px; }
.nk-player { display: flex !important; align-items: center; justify-content: space-between; gap: 8px; margin: 0; padding: 3px 8px; font: 12px/1.3 var(--nk-font-type); color: #2c1308; border-bottom: 1px dotted rgba(90,58,22,.25); overflow-wrap: anywhere; }
.nk-player:last-child { border-bottom: none; }
.nk-player.is-leader { font-weight: 700; }
.nk-player__role { flex: none; font: 700 9px/1 var(--nk-font-type); letter-spacing: .12em; text-transform: uppercase; color: #7c1f16; opacity: .85; }
.nk-players__empty { padding: 6px 8px; font: 11px/1.4 "IM Fell English", Georgia, serif; color: #5a4423; }

/* ---------- MAP TYPES card ---------- */
.nk-maptypes {
  width: var(--nk-panel-width); max-width: calc(100vw - 48px); pointer-events: auto; position: relative; z-index: 3; overflow: visible;
  background: #e9dcb7; border: 1px solid rgba(90,58,22,.5); border-radius: 3px;
  box-shadow: 2px 3px 6px rgba(0,0,0,.25), inset 0 0 0 2px rgba(90,58,22,.18);
  color: #2c1308; font-family: var(--nk-font-type);
}
.nk-maptypes__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-bottom: 1px solid rgba(90,58,22,.3); }
.nk-title { font: 700 12px/1 var(--nk-font-display); letter-spacing: .06em; color: #2c1308; border-bottom: 1.5px solid rgba(90,58,22,.5); padding-bottom: 2px; }
.nk-maptypes__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 10px; }

.nk-toggle {
  user-select: none; cursor: pointer; padding: 6px 10px; border-radius: 2px;
  font: 12px/1 var(--nk-font-type); background: rgba(44,19,8,.05); color: #2c1308; border: 1px solid rgba(90,58,22,.4);
  transition: background .15s ease, color .15s ease;
}
.nk-toggle:hover { background: rgba(44,19,8,.10); }
.nk-toggle.is-on { background: rgba(124,31,22,.16); border-color: #7c1f16; color: #7c1f16; text-transform: uppercase; letter-spacing: .05em; box-shadow: inset 0 0 0 1px #7c1f16; }

.nk-select { position: relative; pointer-events: auto; }
.nk-select__btn { cursor: pointer; padding: 6px 10px; border-radius: 2px; font: 12px/1 var(--nk-font-type); background: rgba(44,19,8,.05); color: #2c1308; border: 1px solid rgba(90,58,22,.4); }
.nk-caret { display: inline-block; margin-left: 6px; transition: transform .15s ease; }
.nk-select.open .nk-caret { transform: rotate(180deg); }
.nk-select__list {
  position: absolute; right: 0; top: calc(100% + 6px); max-height: min(60vh, 340px); overflow-y: auto; min-width: 220px; z-index: 5000; pointer-events: auto;
  background: #f4e9c8; border: 1px solid rgba(90,58,22,.4); border-radius: 3px; padding: 6px; box-shadow: 0 12px 36px rgba(0,0,0,.55); display: none;
}
.nk-select.open .nk-select__list { display: block; }
.nk-select__item { padding: 8px 10px; border-radius: 2px; color: #3a2a16; cursor: pointer; font: 12px/1.1 var(--nk-font-type); }
.nk-select__item:hover { background: rgba(44,19,8,.08); }
.nk-select__item.is-active { color: #7c1f16; font-weight: 700; }
.nk-select__item.is-disabled { opacity: .55; cursor: not-allowed; }

/* ---------- resource chips + tooltip ---------- */
.nk-res-chip { display: inline-flex; align-items: center; gap: 6px; padding: 1px 6px; margin: 2px 6px 0 0; font: 12px/1.2 var(--nk-font-type); color: #2c1308; background: #cdba8e; border: 1px solid rgba(90,58,22,.5); border-radius: 2px; vertical-align: baseline; }
.nk-res-chip--muted { opacity: .7; }
.nk-res-chip__img { width: 12px; height: 12px; display: block; -webkit-user-drag: none; user-select: none; }
.nk-res-chip__name { font-size: 12px; line-height: 1.2; }
#nk-tip {
  position: fixed; z-index: 50000; pointer-events: none; display: none; max-width: 320px; white-space: normal;
  background: #f4e9c8; color: #2c1308; border: 1px solid rgba(90,58,22,.4); border-radius: 2px; padding: 8px 10px;
  font: 12px/1.25 var(--nk-font-type); box-shadow: 0 8px 28px rgba(0,0,0,.35);
}
#nk-tip .nk-tip-h { font-weight: 700; margin: 0 0 4px; font-family: var(--nk-font-display); }
#nk-tip ul { margin: 0 0 6px 14px; padding: 0; }
#nk-tip li { margin: 2px 0; list-style: disc; display: list-item; }

/* ---------- capitals / labels (DOM markers) ---------- */
.nk-cap-wrap { transform: translate(-50%,-50%) scale(var(--nk-cap-scale, 1)); transform-origin: 50% 50%; display: flex; flex-direction: column; align-items: center; }
.nk-cap-img { width: 20px; height: 20px; display: block; -webkit-user-drag: none; user-select: none; }
.nk-cap-pane .nk-cap-res { display: none; }
.nk-cap-pane.is-hi .nk-cap-res { display: block; }
.nk-cap-pane.is-hi .nk-cap-img { margin-bottom: 40px; }

.nk-town-label {
  pointer-events: none; display: inline-block; text-align: center; white-space: nowrap;
  transform: translate(-50%,-100%) translateY(calc(-1 * var(--nk-town-label-up, 4px)));
  font: 600 12px/1.2 var(--nk-font-type); color: #fff6d8; background: rgba(44,19,8,.78); border: 1px solid rgba(90,58,22,.6); border-radius: 2px; padding: 2px 8px;
  text-shadow: 0 0 2px rgba(0,0,0,.85); box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.leaflet-pane.nk-plain .nk-town-label { background: none; border: none; padding: 0; text-shadow: 0 0 3px #000, 0 0 3px #000; box-shadow: none; color: #fff6d8; }
.nk-mode-nations .nk-town-label { font-size: 10px; padding: 1px 6px; }
.nk-nation-label {
  pointer-events: none; display: inline-block; text-align: center; white-space: nowrap;
  transform: translate(-50%,-100%) translateY(calc(-1 * var(--nk-town-label-up, 4px)));
  font: 700 13px/1.2 var(--nk-font-display); color: #fff6d8; background: #7c1f16; border: 1px solid rgba(255,246,216,.3); border-radius: 2px; padding: 2px 10px;
  text-shadow: 0 0 2px rgba(0,0,0,.85); box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.nk-port-icon, .nk-station-icon { -webkit-user-drag: none; user-select: none; }
/* the station fill takes the nation colour, i.e. the same colour as the territory
   under it: a thin parchment halo keeps the black outline readable (26 markers,
   so the filter cost is negligible) */
.nk-station-icon { filter: drop-shadow(0 0 1px #fff6d8) drop-shadow(0 0 1px #fff6d8); }

/* ---------- coords toast (popup) ---------- */
.leaflet-popup.nk-coords-toast .leaflet-popup-content-wrapper { background: #efe4c8; color: #2c1308; border: 1px solid rgba(90,58,22,.5); border-radius: 2px; box-shadow: 0 8px 20px -6px rgba(0,0,0,.6); padding: 0; }
.leaflet-popup.nk-coords-toast .leaflet-popup-content { margin: 6px 14px; font: 700 11px var(--nk-font-type); letter-spacing: .16em; text-transform: uppercase; white-space: nowrap; }
.leaflet-popup.nk-coords-toast .leaflet-popup-tip-container { display: none; }

/* ---------- loading card ---------- */
#nk-loading { position: absolute; inset: 0; z-index: 99999; display: none; align-items: center; justify-content: center; pointer-events: none; }
#nk-loading.is-dim { background: rgba(0,0,0,.35); }
#nk-loading-card {
  width: 360px; max-width: 90vw; display: flex; gap: 14px; align-items: center; padding: 16px 18px;
  background: #f4e9c8; color: #2c1308; border: 1px solid rgba(90,58,22,.4); border-radius: 3px;
  font: 600 13px/1.3 var(--nk-font-type); box-shadow: 0 18px 60px rgba(0,0,0,.55);
}
.nk-loading-text { min-width: 0; }
.nk-loading-kicker { font-size: 11px; letter-spacing: .12em; opacity: .8; }
#nk-loading-msg { margin-top: 6px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes nkSpin { to { transform: rotate(360deg); } }
.nk-spinner { flex: none; width: 38px; height: 38px; border-radius: 999px; border: 4px solid rgba(44,19,8,.18); border-top-color: #7c1f16; animation: nkSpin .9s linear infinite; }
