/* NetHack+ Figure 1 and Figure 7 (settings gallery). Reads the tokens in style.css; the panels are
   always the dark "dungeon" surface, so the colours below are chosen for that surface in both themes. */
.kn-gallery, .kn-fig1, .kn-tip {
  --kn-cur: #f2c14e;          /* the value shown on the map */
  --kn-van: #3987e5;          /* vanilla */
  --kn-oth: #686e95;          /* other values */
  --kn-locked: #d95926;       /* door states: validated all-pairs on the dungeon surface */
  --kn-closed: #3987e5;
  --kn-open: #199e70;
  --kn-way: #6c7299;
  --kn-trap: #d55181;
  --kn-mon: #e66767;
}

/* ---------- NetHack colours (0–15) on the dungeon surface ---------- */
.kc0 { color: #4b5180; } .kc1 { color: #e66767; } .kc2 { color: #3fbf6a; } .kc3 { color: #c98500; }
.kc4 { color: #3987e5; } .kc5 { color: #c26be0; } .kc6 { color: #2fb5c9; } .kc7 { color: #b9bdd3; }
.kc8 { color: #5a5f85; } .kc9 { color: #f08a4b; } .kc10 { color: #7be08f; } .kc11 { color: #f2c14e; }
.kc12 { color: #7aa7ff; } .kc13 { color: #e58ff2; } .kc14 { color: #6fe0ef; } .kc15 { color: #ffffff; }

/* ---------- inspectable map ---------- */
.kn-map { font-size: inherit; overflow: visible; white-space: normal; }
.kn-gridwrap { position: relative; display: block; outline: none; border-radius: 6px; cursor: crosshair; touch-action: manipulation; }
.kn-gridwrap:focus-visible { box-shadow: 0 0 0 2px var(--gold); }
.kn-grid { display: inline-block; white-space: pre; line-height: 1.2; letter-spacing: 0; font-family: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace; color: #c9cbd9; }
.kn-measure { position: absolute; visibility: hidden; white-space: pre; left: -9999px; top: 0; }
.kn-cursor { position: absolute; pointer-events: none; border: 1.5px solid var(--gold); border-radius: 2px; opacity: 0; box-sizing: border-box; }
.kn-cursor.on { opacity: 1; }
.kn-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.kn-me { background: #e4e6f2; color: #15172e !important; border-radius: 2px; }
.kn-dim { opacity: 0.5; }

/* focus treatments: what each setting changes */
.kn-f-room { background: rgba(57, 135, 229, 0.30); color: #cfe0fb !important; }
.kn-f-wall { color: #9aa2c8 !important; }
.kn-f-corr { color: #6fe0ef !important; background: rgba(47, 181, 201, 0.24); }
.kn-f-mon { background: var(--kn-mon); color: #fff !important; border-radius: 2px; }
.kn-f-mon.sel { background: var(--kn-cur); color: #15172e !important; box-shadow: 0 0 0 2px var(--kn-cur); }
.kn-f-trap { background: var(--kn-trap); color: #fff !important; border-radius: 2px; }
.kn-f-pet { background: var(--kn-cur); color: #15172e !important; border-radius: 2px; box-shadow: 0 0 0 2px rgba(242, 193, 78, 0.45); }
.kn-d-locked { background: var(--kn-locked); color: #fff !important; border-radius: 2px; }
.kn-d-closed { color: #9cc3ff !important; box-shadow: inset 0 0 0 1.5px var(--kn-closed); border-radius: 2px; }
.kn-d-open { color: #3ed1a0 !important; background: rgba(25, 158, 112, 0.28); border-radius: 2px; }
.kn-d-doorway, .kn-d-broken { color: #8a90ab !important; outline: 1px dashed var(--kn-way); outline-offset: -1px; border-radius: 2px; }

/* ---------- tooltip ---------- */
.kn-tip {
  position: fixed; z-index: 50; pointer-events: none; max-width: min(320px, calc(100vw - 16px));
  font-family: var(--mono); font-size: 11.5px; line-height: 1.5; background: #fff; color: #15172e;
  padding: 8px 11px; border-radius: 7px; box-shadow: 0 8px 28px rgba(0, 0, 0, .38); opacity: 0; transition: opacity .1s;
}
.kn-tip.on { opacity: 1; }
.kn-tip-h { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.kn-tip-h b { font-weight: 600; }
.kn-tip-g { display: inline-grid; place-items: center; min-width: 20px; height: 20px; border-radius: 4px; background: #15172e; color: #f2f3f8; font-family: "SFMono-Regular", Menlo, monospace; font-size: 13px; }
.kn-tip-x { color: #5a6074; margin-top: 3px; }
.kn-tip-r { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.kn-tip-r i { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
.kn-tip-r span { margin-left: auto; padding-left: 14px; font-variant-numeric: tabular-nums; }
.kn-tip-r.b { font-weight: 600; }

/* ---------- Figure 1 ---------- */
.kn-fig1 { padding: 18px 20px; }

/* ---------- gallery controls ---------- */
.kn-gallery { font-family: var(--mono); font-size: 12px; color: var(--dungeon-muted); }
.kn-tabs { display: grid; gap: 10px; margin-bottom: 14px; }
.kn-group { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; }
.kn-glabel { flex: 0 0 auto; min-width: 19em; color: var(--dungeon-muted); }
.kn-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.kn-pills button, .kn-play {
  font: inherit; color: var(--dungeon-ink); background: transparent; border: 1px solid var(--dungeon-rule);
  border-radius: 999px; padding: 5px 11px; cursor: pointer; line-height: 1.3;
}
.kn-pills button:hover, .kn-play:hover { border-color: var(--dungeon-muted); color: #fff; }
.kn-pills button[aria-pressed="true"] { background: var(--dungeon-2); border-color: var(--gold); color: #fff; }
.kn-values { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding-top: 12px; border-top: 1px solid var(--dungeon-rule); margin-bottom: 14px; }
.kn-lbl { color: var(--dungeon-muted); }
.kn-seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--dungeon-rule); border-radius: 8px; overflow: hidden; }
.kn-seg button { font: inherit; color: var(--dungeon-ink); background: transparent; border: 0; border-right: 1px solid var(--dungeon-rule); padding: 6px 12px; cursor: pointer; }
.kn-seg button:last-child { border-right: 0; }
.kn-seg button:hover { color: #fff; background: var(--dungeon-2); }
.kn-seg button[aria-pressed="true"] { background: var(--kn-cur); color: #15172e; }
.kn-van-tag { font-size: 10.5px; opacity: .75; }
.kn-play { border-radius: 8px; padding: 6px 12px; color: var(--dungeon-muted); }

/* ---------- body: map left, comparison right ---------- */
.kn-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
@media (min-width: 900px) { .kn-body { grid-template-columns: minmax(0, 1.62fr) minmax(0, 1fr); gap: 24px; } }
.kn-left, .kn-right { min-width: 0; }
.kn-mhead { color: var(--dungeon-ink); font-size: 12.5px; margin-bottom: 8px; min-height: 1.5em; }
.kn-mhead code { background: none; padding: 0; font-size: 1em; color: #fff; }
.kn-status { font-family: "SFMono-Regular", Menlo, monospace; font-size: 11.5px; color: var(--dungeon-muted); margin-top: 8px; white-space: pre-wrap; }
.kn-mcap { font-family: var(--serif); font-size: 14.5px; line-height: 1.5; color: var(--dungeon-ink); margin: 6px 0 0; min-height: 1.5em; }
.kn-right { border-top: 1px solid var(--dungeon-rule); padding-top: 14px; }
@media (min-width: 900px) { .kn-right { border-top: 0; padding-top: 0; border-left: 1px solid var(--dungeon-rule); padding-left: 22px; } }

.kn-phead h4 { font-family: var(--mono); font-size: 12.5px; font-weight: 500; color: var(--dungeon-ink); margin: 0 0 3px; }
.kn-phead p { font-family: var(--serif); font-size: 13.5px; line-height: 1.45; color: var(--dungeon-muted); margin: 0 0 8px; }
.kn-phead + * { margin-top: 0; }
.kn-right > .kn-phead:not(:first-child) { margin-top: 18px; }
.kn-h5, .kn-kinds h5 { font-family: var(--mono); font-size: 11.5px; font-weight: 500; color: var(--dungeon-ink); margin: 14px 0 6px; }

/* legend */
.kn-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11px; color: var(--dungeon-muted); margin: 4px 0 8px; }
.kn-legend span { display: inline-flex; align-items: center; }
.kn-sw { display: inline-block; margin-right: 6px; border-radius: 2px; }
.kn-sw.line { width: 14px; height: 2.5px; }
.kn-sw.bar { width: 10px; height: 10px; border-radius: 3px; }
.kn-sw.tick { width: 2px; height: 12px; background: var(--dungeon-ink); border-radius: 1px; }

/* bar rows */
.kn-bars { display: grid; gap: 5px; margin: 2px 0 4px; }
.kn-bar { display: grid; grid-template-columns: 8.6em minmax(0, 1fr) 3.2em; align-items: center; gap: 8px; font-size: 11.5px; color: var(--dungeon-muted); border-radius: 4px; outline: none; }
.kn-bar.cur { color: var(--dungeon-ink); }
.kn-bar.cur .kn-bar-l, .kn-bar.cur .kn-bar-v { color: #fff; font-weight: 600; }
.kn-bar-l { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kn-bar-t { position: relative; height: 14px; }
.kn-bar-f { position: absolute; left: 0; top: 2px; bottom: 2px; border-radius: 0 4px 4px 0; min-width: 1px; }
.kn-bar-m { position: absolute; top: -1px; bottom: -1px; width: 2px; margin-left: -1px; background: var(--dungeon-ink); border-radius: 1px; box-shadow: 0 0 0 1.5px var(--dungeon); }
.kn-bar-v { text-align: right; font-variant-numeric: tabular-nums; }

/* vanilla vs this value */
.kn-vs { width: 100%; border-collapse: collapse; font-size: 11.5px; margin-top: 12px; }
.kn-vs th, .kn-vs td { padding: 5px 6px; border-bottom: 1px solid var(--dungeon-rule); color: var(--dungeon-muted); font-weight: 400; text-align: left; }
.kn-vs th { font-size: 11px; }
.kn-vs .num { text-align: right; font-variant-numeric: tabular-nums; }
.kn-vs td.cur, .kn-vs th.cur { color: #fff; }
.kn-vs tr.main td { color: var(--dungeon-ink); }
.kn-vs tr.main td.cur { font-weight: 600; color: #fff; }
.kn-delta { color: var(--dungeon-muted); font-weight: 400; margin-left: 4px; }

/* chips */
.kn-chips, .kn-kinds > div { display: flex; flex-wrap: wrap; gap: 5px; }
.kn-chip { font: inherit; font-size: 11px; color: var(--dungeon-ink); background: var(--dungeon-2); border: 1px solid var(--dungeon-rule); border-radius: 6px; padding: 3px 8px; display: inline-flex; align-items: center; gap: 6px; }
button.kn-chip { cursor: pointer; }
button.kn-chip:hover { border-color: var(--dungeon-muted); }
button.kn-chip[aria-pressed="true"] { border-color: var(--kn-cur); color: #fff; }
.kn-chip span { color: var(--dungeon-muted); }
.kn-chip b.kn-f-trap { font-weight: 400; padding: 0 3px; font-family: "SFMono-Regular", Menlo, monospace; }
.kn-none { color: var(--dungeon-muted); font-size: 11px; }

/* doors */
.kn-door { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; box-sizing: border-box; }
.kn-door.locked { background: var(--kn-locked); }
.kn-door.closed { border: 2px solid var(--kn-closed); }
.kn-door.open { background: var(--kn-open); }
.kn-door.doorway { background: transparent; border: 1px dashed var(--kn-way); }
.kn-dblocks { display: grid; gap: 10px; margin: 4px 0 6px; }
.kn-dblock { border: 1px solid var(--dungeon-rule); border-radius: 8px; padding: 9px 11px; }
.kn-dhead { color: var(--dungeon-ink); font-size: 11.5px; margin-bottom: 6px; }
.kn-dcells { display: flex; flex-wrap: wrap; gap: 3px; }
.kn-dcells .kn-door { margin: 0; width: 14px; height: 14px; }
.kn-dcount { margin-top: 6px; font-size: 11px; }

/* monster cards */
.kn-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kn-card { border: 1px solid var(--dungeon-rule); border-radius: 8px; padding: 9px 10px; border-top: 3px solid var(--kn-oth); min-width: 0; }
.kn-card.van { border-top-color: var(--kn-van); }
.kn-card.cur { border-top-color: var(--kn-cur); }
.kn-card-h { display: grid; grid-template-columns: auto 1fr; gap: 2px 7px; align-items: center; margin-bottom: 6px; }
.kn-card-l { grid-column: 1 / -1; font-size: 10.5px; color: var(--dungeon-muted); }
.kn-card-g { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 4px; background: var(--kn-mon); color: #fff; font-family: "SFMono-Regular", Menlo, monospace; font-size: 13px; }
.kn-card-h b { color: #fff; font-weight: 600; font-size: 12.5px; overflow-wrap: anywhere; }
.kn-card dl { display: grid; grid-template-columns: 1fr auto; gap: 1px 8px; margin: 0; font-size: 11px; }
.kn-card dt { color: var(--dungeon-muted); }
.kn-card dd { margin: 0; text-align: right; color: var(--dungeon-ink); font-variant-numeric: tabular-nums; }
.kn-card-a { margin-top: 6px; font-size: 10.5px; color: var(--dungeon-muted); }

/* level histogram */
.kn-hist { display: grid; gap: 4px; }
.kn-hrow { display: grid; grid-template-columns: 8.6em minmax(0, 1fr); align-items: end; gap: 8px; font-size: 11.5px; }
.kn-hrow.cur .kn-bar-l { color: #fff; font-weight: 600; }
.kn-hcols { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 3px; height: 26px; align-items: end; border-bottom: 1px solid var(--dungeon-rule); }
.kn-hcol { height: 100%; display: flex; align-items: flex-end; }
.kn-hcol > span { display: block; width: 100%; border-radius: 3px 3px 0 0; }
.kn-hax .kn-hcols { height: auto; border: 0; }
.kn-hax .kn-hcol { justify-content: center; font-size: 10.5px; color: var(--dungeon-muted); }

/* svg charts on the dungeon surface */
.kn-cbox { position: relative; margin: 2px 0 4px; }
.kn-chart { display: block; max-width: 100%; height: auto; overflow: visible; }
.kn-chart .kn-ax { font-family: var(--mono); font-size: 10.5px; fill: var(--dungeon-muted); }
.kn-chart .kn-ax.b { fill: #fff; font-weight: 600; }
.kn-chart .kn-dl { font-family: var(--mono); font-size: 10.5px; fill: var(--dungeon-ink); }
.kn-grid-l line, .kn-base { stroke: var(--dungeon-rule); stroke-width: 1; }
.kn-ref { stroke: var(--dungeon-muted); stroke-width: 1; opacity: .55; }
.kn-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.kn-line.oth { opacity: .75; stroke-width: 1.5; }
.kn-end { stroke: var(--dungeon); stroke-width: 2; }
.kn-tcur { stroke: var(--kn-cur); stroke-width: 1; opacity: 0; }
.kn-tcur.on { opacity: .7; }
.kn-hcur { stroke: #fff; stroke-width: 1; opacity: 0; }
.kn-hcur.on { opacity: .5; }
.kn-bcur { fill: rgba(242, 193, 78, .14); opacity: 0; }
.kn-bcur.on { opacity: 1; }

@media (max-width: 600px) {
  .kn-glabel { min-width: 0; flex-basis: 100%; }
  .kn-seg button { padding: 6px 9px; }
  .kn-cards { grid-template-columns: 1fr; }
  .kn-bar { grid-template-columns: 8.4em minmax(0, 1fr) 2.9em; gap: 6px; }
  .kn-hrow { grid-template-columns: 8.4em minmax(0, 1fr); gap: 6px; }
}

.kn-sw-neutral { background: var(--dungeon-muted); opacity: .6; }
.kn-chart .kn-dl.oth { fill: var(--dungeon-muted); }
.kn-chart .kn-reflbl { paint-order: stroke; stroke: var(--dungeon); stroke-width: 4px; stroke-linejoin: round; }
.kn-chart .kn-dl { paint-order: stroke; stroke: var(--dungeon); stroke-width: 3px; stroke-linejoin: round; }
