/* /server — live map and server status. Uses the shared tokens in /assets/base.css. */
:root {
  /* The map card stays dark in both modes, like the hub cards. */
  --map-bg: oklch(15% 0.003 100);
  --map-chip: oklch(17% 0.003 100 / 0.78);
  --map-chip-line: oklch(100% 0 0 / 0.1);
  --map-ink: oklch(97% 0.002 100);
  --map-muted: oklch(100% 0 0 / 0.62);
  --online: var(--color-tile-6);
  --busy: var(--color-tile-2);
  --offline: var(--color-faint);
  --warn: oklch(70% 0.15 70);
}

.wrap--wide { max-width: 1280px; }

/* ---------- status pill in the bar ---------- */
.state {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 10px; border-radius: var(--radius-pill);
  border: 1px solid var(--line); font-size: var(--text-xs); font-weight: 500;
}
.state i { width: 8px; height: 8px; border-radius: 50%; background: var(--offline); }
.state[data-state="online"] i { background: var(--online); box-shadow: 0 0 0 0 color-mix(in oklch, var(--online) 60%, transparent); animation: beat 2.4s var(--ease-out) infinite; }
.state[data-state="busy"] i { background: var(--busy); }
.state[data-state="loading"] { color: var(--muted); }
@keyframes beat { 0% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--online) 55%, transparent); } 70%, 100% { box-shadow: 0 0 0 7px transparent; } }

/* ---------- heading ---------- */
.head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-lg);
  flex-wrap: wrap; margin: var(--space-md) 0 var(--space-lg);
}
.head .title { margin: 0 0 4px; }
.sub { margin: 0; color: var(--muted); }

.address {
  appearance: none; cursor: pointer; text-align: left;
  display: grid; grid-template-columns: auto auto; column-gap: var(--space-md); align-items: baseline;
  padding: 10px 16px; border-radius: var(--radius-tile);
  border: 1px solid var(--line); background: var(--surface);
  transition: border-color var(--dur-micro);
}
.address:hover { border-color: var(--fg); }
.address__label { grid-column: 1 / -1; font-size: var(--text-3xs); color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.address__value { font-family: var(--mono); font-size: var(--text-md); font-weight: 500; }
.address__hint { font-size: var(--text-xs); color: var(--muted); }

/* ---------- map + side ---------- */
.board {
  display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--space-md);
  height: min(72vh, 760px); min-height: 460px;
}
.mapcard {
  position: relative; overflow: hidden; isolation: isolate;
  border-radius: var(--radius-card); background: var(--map-bg); box-shadow: var(--shadow-card);
}
.map { position: absolute; inset: 0; background: var(--map-bg); font: inherit; }
.map:focus-visible { outline-offset: -3px; }
.mapcard__error {
  position: absolute; inset: 0; display: grid; place-items: center; margin: 0;
  color: var(--map-muted); z-index: 500;
}

.overlay { position: absolute; z-index: 500; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.overlay > * { pointer-events: auto; }
.overlay--tl { top: 14px; left: 14px; align-items: flex-start; }
.overlay--tr { top: 14px; right: 14px; align-items: flex-end; }
.overlay--bl { bottom: 14px; left: 14px; }

.chip, .seg {
  background: var(--map-chip); color: var(--map-ink);
  border: 1px solid var(--map-chip-line); border-radius: var(--radius-pill);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.chip { display: inline-flex; align-items: center; gap: 10px; padding: 6px 14px 6px 8px; font-size: var(--text-sm); }
.chip b { font-weight: 600; font-variant-numeric: tabular-nums; }
.chip__muted { color: var(--map-muted); }
.chip--mono { font-family: var(--mono); font-size: var(--text-2xs); padding: 5px 12px; color: var(--map-muted); font-variant-numeric: tabular-nums; }

/* Clock: a dial with a sun (or moon) that turns with the day. */
.clock__dial {
  --turn: 0deg;
  position: relative; width: 26px; height: 26px; border-radius: 50%; overflow: hidden;
  background: linear-gradient(to bottom, oklch(72% 0.1 230) 50%, oklch(30% 0.04 150) 50%);
  transition: background var(--dur-long);
}
.clock__dial[data-night="true"] { background: linear-gradient(to bottom, oklch(25% 0.06 270) 50%, oklch(22% 0.03 150) 50%); }
.clock__dial i {
  position: absolute; inset: 0; transform: rotate(calc(var(--turn) - 90deg)); transition: transform 2s linear;
}
.clock__dial i::before {
  content: ""; position: absolute; left: 50%; top: 2px; width: 8px; height: 8px; margin-left: -4px;
  border-radius: 2px; background: oklch(90% 0.15 95);
}
.clock__dial[data-night="true"] i::before { background: oklch(92% 0.01 260); }

.seg { display: inline-flex; padding: 3px; gap: 2px; }
.seg__btn {
  appearance: none; border: 0; background: none; color: var(--map-muted); cursor: pointer;
  padding: 6px 12px; border-radius: var(--radius-pill); font-size: var(--text-xs); font-weight: 500;
  transition: background var(--dur-micro), color var(--dur-micro);
}
.seg__btn:hover { color: var(--map-ink); }
.seg__btn[aria-checked="true"] { background: var(--map-ink); color: var(--map-bg); }
.seg--small .seg__btn { padding: 4px 10px; font-size: var(--text-2xs); }

/* Leaflet, restyled to the chips */
.leaflet-container { background: transparent; font-family: var(--font-sans); }
/* Half a pixel of overlap hides the hairline seams browsers leave between tiles on scaled displays.
   Leaflet 1.9 blends tiles with plus-lighter, which would turn that overlap into bright lines, so blend normally. */
.leaflet-container img.leaflet-tile { mix-blend-mode: normal; }
.leaflet-tile { image-rendering: pixelated; width: calc(var(--tile, 128px) + 0.5px) !important; height: calc(var(--tile, 128px) + 0.5px) !important; }
.leaflet-bar { border: 1px solid var(--map-chip-line) !important; border-radius: 14px !important; overflow: hidden; box-shadow: none !important; backdrop-filter: blur(10px); }
.leaflet-bar a, .leaflet-bar a:hover {
  width: 34px !important; height: 34px !important; line-height: 34px !important;
  background: var(--map-chip) !important; color: var(--map-ink) !important; border-bottom-color: var(--map-chip-line) !important;
}
.leaflet-bar a:hover { background: oklch(25% 0.003 100 / 0.9) !important; }
.leaflet-bar a.leaflet-disabled { color: var(--map-muted) !important; opacity: .5; }
.leaflet-bottom.leaflet-right { margin: 0 4px 4px 0; }

.poi { filter: drop-shadow(0 1px 2px oklch(0% 0 0 / 0.6)); }
.leaflet-tooltip.poi-label {
  background: var(--map-chip); color: var(--map-ink); border: 1px solid var(--map-chip-line);
  border-radius: 8px; padding: 2px 8px; font-size: var(--text-2xs); font-weight: 500; box-shadow: none;
}
.leaflet-tooltip.poi-label::before { display: none; }

/* Avatars on the map */
.pm { transition: transform 2s linear; }
.is-zooming .pm { transition: none; }
.pm img {
  width: 28px; height: 28px; border-radius: 7px; image-rendering: pixelated; display: block;
  box-shadow: 0 0 0 2px var(--map-ink), 0 4px 12px oklch(0% 0 0 / 0.5);
}
.pm span {
  position: absolute; top: 34px; left: 50%; transform: translateX(-50%); white-space: nowrap;
  background: var(--map-chip); color: var(--map-ink); border-radius: 6px; padding: 1px 7px;
  font-size: var(--text-3xs); font-weight: 600;
}

/* ---------- side panels ---------- */
.side { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: var(--space-md); min-height: 0; }
.panel {
  border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--bg);
  padding: var(--space-md) var(--space-md) var(--space-sm); min-height: 0; display: flex; flex-direction: column;
}
.panel__head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: var(--space-xs); }
.panel__head h2 { margin: 0; font-size: var(--text-md); font-weight: 600; letter-spacing: var(--tracking-body); }
.panel__count { color: var(--muted); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.panel__note { color: var(--muted); font-size: var(--text-2xs); display: inline-flex; align-items: center; gap: 6px; }
.panel__note::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--online); }
.empty { color: var(--muted); font-size: var(--text-sm); margin: 4px 0 6px; }

.players { list-style: none; margin: 0 -8px; padding: 0; max-height: 260px; overflow-y: auto; }
.player {
  appearance: none; border: 0; background: none; cursor: pointer; width: 100%; text-align: left;
  display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--radius-tile);
}
.player:hover { background: var(--surface); }
.player img { border-radius: 6px; image-rendering: pixelated; flex: none; }
.player__text { display: grid; min-width: 0; }
.player__text b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.player__text span { color: var(--muted); font-size: var(--text-2xs); font-variant-numeric: tabular-nums; }
.player__hp { margin-left: auto; color: var(--muted); font-size: var(--text-2xs); font-variant-numeric: tabular-nums; }

.panel--chat { overflow: hidden; }
.chat { list-style: none; margin: 0 -4px; padding: 0 4px; overflow-y: auto; flex: 1; min-height: 120px; display: flex; flex-direction: column; gap: 2px; }
.chat__line { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: start; padding: 4px 0; font-size: var(--text-sm); }
.chat__line--event { grid-template-columns: minmax(0, 1fr) auto; color: var(--muted); font-size: var(--text-xs); }
.chat__face { border-radius: 4px; image-rendering: pixelated; margin-top: 1px; }
.chat__body { margin: 0; overflow-wrap: anywhere; line-height: 1.4; }
.chat__body b { font-weight: 600; }
.chat__time { color: var(--color-faint); font-size: var(--text-3xs); font-variant-numeric: tabular-nums; padding-top: 3px; }

/* ---------- stat tiles ---------- */
.stats {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--space-md);
  margin-top: var(--space-md);
}
.tile {
  border: 1px solid var(--line); border-radius: var(--radius-card); padding: var(--space-md);
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.tile h3 { margin: 0; font-size: var(--text-xs); font-weight: 500; color: var(--muted); }
.tile__value { margin: 2px 0 0; font-size: var(--text-xl); letter-spacing: var(--tracking-display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tile__value b { font-weight: 600; }
.tile__value span { font-size: var(--text-sm); color: var(--muted); letter-spacing: var(--tracking-body); }
.tile__note { margin: 0; color: var(--muted); font-size: var(--text-2xs); min-height: 1.4em; }

/* Meter: the track is a lighter step of the fill; the fill turns orange then red as it nears the limit. */
.meter { --fill: 0; height: 6px; border-radius: var(--radius-pill); background: var(--line); overflow: hidden; margin: 4px 0 2px; }
.meter i { display: block; height: 100%; width: calc(var(--fill) * 100%); border-radius: inherit; background: var(--fg); transition: width var(--dur-long) var(--ease-out); }
.meter[data-level="warn"] i { background: var(--warn); }
.meter[data-level="high"] i { background: var(--bad); }

.spark { position: relative; height: 44px; margin-top: auto; padding-top: 8px; touch-action: none; }
.spark:empty { display: none; }
.spark svg { width: 100%; height: 44px; display: block; overflow: visible; }
.spark__line { fill: none; stroke: var(--muted); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.spark__area { fill: color-mix(in oklch, var(--muted) 12%, transparent); stroke: none; }
.spark__cross { stroke: var(--fg); stroke-width: 1; vector-effect: non-scaling-stroke; }
.spark__dot {
  position: absolute; width: 8px; height: 8px; margin: 4px 0 0 -4px; transform: translateY(-50%); border-radius: 50%;
  background: var(--fg); box-shadow: 0 0 0 2px var(--bg);
}
.spark__tip {
  position: absolute; bottom: calc(100% - 4px); transform: translateX(-50%); white-space: nowrap;
  background: var(--fg); color: var(--bg); padding: 3px 8px; border-radius: 6px; font-size: var(--text-3xs); font-weight: 500;
  font-variant-numeric: tabular-nums; pointer-events: none;
}
.spark__caption { position: absolute; right: 0; bottom: -16px; font-size: var(--text-3xs); color: var(--color-faint); }

/* ---------- about + mods ---------- */
.info { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: var(--space-md); margin-top: var(--space-xl); }
.facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 24px; margin: 4px 0 8px; font-size: var(--text-sm); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts a { text-decoration: none; border-bottom: 1px solid var(--line-strong); }
.facts a:hover { border-color: var(--fg); }

.filter {
  width: 100%; padding: 8px 12px; margin-bottom: 8px; border-radius: var(--radius-tile);
  border: 1px solid var(--line); background: var(--surface); font-size: var(--text-sm);
}
.filter:focus { outline: none; border-color: var(--fg); }
.filter:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 1px; }
.mods {
  list-style: none; margin: 0; padding: 0; columns: 3 160px; column-gap: 24px;
  max-height: 320px; overflow-y: auto; font-size: var(--text-sm);
}
.mods li { break-inside: avoid; padding: 3px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- smaller screens ---------- */
@media (max-width: 1080px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .board { grid-template-columns: 1fr; height: auto; }
  .mapcard { height: 64vh; min-height: 380px; }
  .side { grid-template-rows: none; }
  .chat { max-height: 320px; }
  .info { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overlay--tr { left: 14px; align-items: flex-start; top: 62px; }
  .overlay--tl { right: 14px; }
  .address { width: 100%; }
}
