@font-face {
  font-family: 'Cinzel';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/cinzel-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Cinzel';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/cinzel-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Almendra';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/almendra-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Almendra';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/almendra-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #111;
  overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.map-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #111;
  background-image: url("img/logo.webp");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.map-container.panning { cursor: grabbing; }

.map-viewport {
  position: absolute;
  left: 0;
  top: 0;
  width: 6140px;
  height: 2504px;
  transform-origin: 0 0;
  will-change: transform;
}

#mapSvg {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
}

/* ---- vector layer ---- */
/* lakes are the hit area AND the indicator of their node: the shoreline is a soft halo in the status colour
   (thick blurred stroke, see #lakeglow) — the same glow the point markers have, no hard contour */
.lake {
  --c: 190, 190, 190;
  fill: rgba(var(--c), .26);
  stroke: rgba(var(--c), .9);
  stroke-width: 26;
  stroke-linejoin: round;
  filter: url(#lakeglow);
  transition: fill .25s ease, stroke-width .25s ease;
  cursor: pointer;
  pointer-events: auto;
}
.lake.status-green  { --c: 70, 230, 120; }
.lake.status-yellow { --c: 255, 195, 40; }
.lake.status-red    { --c: 240, 60, 60; }
.lake.status-unknown{ --c: 190, 190, 190; }
.lake:hover, .lake.active {
  fill: rgba(var(--c), .42);
  stroke-width: 44;
}
/* water bodies without a node: no status tint, just a light hover highlight like rivers */
.lake.passive { fill: rgba(140,200,255,0); stroke: none; filter: none; cursor: default; }
.lake.passive:hover { fill: rgba(140,200,255,.35); }
.river { fill: rgba(140,200,255,0); transition: fill .25s ease; pointer-events: auto; }
.river:hover { fill: rgba(140,200,255,.55); }

.lbl {
  font-family: 'Almendra', Georgia, "Times New Roman", serif;   /* true lowercase, like the painted labels */
  fill: #f3ead6;
  stroke: #1c1a14;
  stroke-width: 2.5px;
  paint-order: stroke fill;
  filter: url(#txtshadow);
  letter-spacing: .02em;
  pointer-events: none;
}
.lbl.k-region { font-family: 'Cinzel', Georgia, serif; letter-spacing: .16em; }   /* Cinzel = capitals + small caps */
.lbl.k-arc    { letter-spacing: .22em; }
.lbl.k-lake   { pointer-events: none; }   /* clicks go through the label to the lake polygon */
.dot { fill: #efe3c2; stroke: #3a2f1a; stroke-width: 4; }

/* ---- nodes layer (HTML, world coordinates) ---- */
.nodes-layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.node {
  position: absolute;
  transform: translate(-50%, -50%) scale(var(--inv, 1));   /* --inv = 1/scale: markers keep their screen size */
  opacity: 0.85;
  transition: opacity 0.2s ease;
  pointer-events: auto;
}
.node:hover, .node.hover, .node.active { opacity: 1; z-index: 10; }
/* invisible hit area around the marker: the glow itself (box-shadow) does not take clicks */
.node::before { content: ''; position: absolute; left: -16px; top: -16px; right: -16px; bottom: -16px; border-radius: 50%; }

.node .halo {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 26px 11px var(--col, rgba(160,160,160,0.3));
}
/* lake nodes: no point at all — the lake polygon is the marker; the node div only anchors the tooltip/card */
.node.on-lake { pointer-events: none; }
.node.on-lake::before { display: none; }
.node.on-lake .halo { display: none; }   /* the card keeps its own pointer-events via .node.active .details */
.status-green  .halo { --col: rgba(0, 200, 0, 0.55); }
.status-yellow .halo { --col: rgba(255, 184, 0, 0.55); }
.status-red    .halo { --col: rgba(235, 0, 0, 0.6); }
.status-unknown .halo { --col: rgba(160, 160, 160, 0.35); }
.node:hover .halo, .node.hover .halo { animation: pulse 1.5s infinite; }

/* ---- client model: a ring instead of a glowing blob ----
   active = ring with a lit core and a small glow; link = amber ring slowly "breathing" (asleep / soft-off, link only);
   off = dim dashed red ring, no glow; unknown = grey dashed ring */
.node.role-client .halo {
  width: 16px; height: 16px; box-sizing: border-box;
  background: transparent; border: 3px solid rgb(var(--rc, 160, 160, 160));
  box-shadow: none;
}
.node.role-client.state-active  .halo { --rc: 70, 230, 120; background: rgba(70, 230, 120, .75); box-shadow: 0 0 14px 5px rgba(0, 200, 0, .5); }
.node.role-client.state-link    .halo { --rc: 255, 195, 40; animation: breathe 3.2s ease-in-out infinite; }
.node.role-client.state-off     .halo { --rc: 240, 60, 60; border-style: dashed; opacity: .75; }
.node.role-client.state-unknown .halo { --rc: 170, 170, 170; border-style: dashed; opacity: .6; }
.node.role-client:hover .halo, .node.role-client.hover .halo { animation: none; transform: scale(1.35); transition: transform .2s ease; }
.node.role-client.state-link:hover .halo, .node.role-client.state-link.hover .halo { animation: breathe 3.2s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { box-shadow: 0 0 4px 1px rgba(255, 184, 0, .25); opacity: .55; }
  50%      { box-shadow: 0 0 16px 6px rgba(255, 184, 0, .55); opacity: 1; }
}
/* client lakes: the same idea on the shoreline — breathing when only the link is up, faded when off */
.lake.role-client.state-link { animation: lakebreathe 3.2s ease-in-out infinite; }
.lake.role-client.state-off  { fill: rgba(var(--c), .10); stroke: rgba(var(--c), .45); }
@keyframes lakebreathe { 0%, 100% { stroke: rgba(var(--c), .35); } 50% { stroke: rgba(var(--c), .95); } }
@media (prefers-reduced-motion: reduce) {
  .node.role-client.state-link .halo, .lake.role-client.state-link { animation: none; }
}
.node.hover .tooltip { opacity: 1; }
@keyframes pulse {
  0%   { box-shadow: 0 0 26px 11px var(--col); }
  50%  { box-shadow: 0 0 52px 22px var(--col); }
  100% { box-shadow: 0 0 26px 11px var(--col); }
}

.tooltip {
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.65);
  color: white;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 13px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.node:hover .tooltip { opacity: 1; }

.details {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(24, 24, 24, 0.95);
  border: 1px solid #444;
  border-radius: 6px;
  padding: 8px 12px;
  color: white;
  font-size: 13px;
  min-width: 200px;
  max-width: 280px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  transform-origin: top center;
  text-rendering: geometricPrecision;
}
.node.active .details { opacity: 1; pointer-events: auto; transform: translateX(-50%); }
.details-title { font-weight: bold; margin-bottom: 2px; }
.details-sub   { font-size: 11px; color: #9a9a9a; margin-bottom: 6px; }
.details-state { font-size: 12px; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; color: #ddd; }
.details-state .state-mark { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.details-state.s-green   .state-mark { background: rgb(70, 230, 120); }
.details-state.s-yellow  .state-mark { background: rgb(255, 195, 40); }
.details-state.s-red     .state-mark { background: rgb(240, 60, 60); }
.details-state.s-unknown .state-mark { background: rgb(160, 160, 160); }
/* the client's mark in the card is a ring, like its marker on the map */
.role-client .details-state .state-mark { background: none; border: 2px solid; }
.role-client .details-state.s-green   .state-mark { border-color: rgb(70, 230, 120); background: rgb(70, 230, 120); }
.role-client .details-state.s-yellow  .state-mark { border-color: rgb(255, 195, 40); }
.role-client .details-state.s-red     .state-mark { border-color: rgb(240, 60, 60); border-style: dashed; }
.role-client .details-state.s-unknown .state-mark { border-color: rgb(160, 160, 160); border-style: dashed; }
.details-desc  { font-size: 12px; margin-bottom: 6px; color: #ccc; }
.details-list  { list-style: none; padding: 0; margin: 0; }
.svc { margin-bottom: 4px; display: flex; flex-direction: column; }
.svc a { color: #9cd0ff; text-decoration: none; }
.svc a:hover { text-decoration: underline; }
.svc-dot { font-size: 14px; margin-right: 6px; }
.svc-meta { font-size: 11px; color: #888; }
.svc-empty { color: #777; font-size: 12px; }
.svc-lock { font-size: 11px; opacity: .8; margin-left: 4px; }
.hud-mode { color: #e0b05a; font-weight: 600; letter-spacing: .06em; }

/* ---- HUD ---- */
.hud {
  position: absolute;
  left: 10px;
  bottom: 8px;
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: #aaa;
  background: rgba(0,0,0,.45);
  padding: 4px 8px;
  border-radius: 4px;
  pointer-events: none;
}
.hud-status.ok   { color: #7fd67f; }
.hud-status.fail { color: #e08a8a; }
