/* =====================================================================
   KPI demo - interactive KP map and the screens built around it
   Purpose : The map component drawn by js/core/kpmap.js (canvas, view
             switch, tooltip, keyboard list), the segmented view switches
             in panel headings, the command centre's glance card (small
             ranked list beside the map), the domain map picker, map
             legends, and the sign-in hero map.
             v0.5: touch behaviour (pinch, twist, tap cards), gesture
             hints, zoom and turn buttons on every map, larger buttons on
             touch screens.
   Related : js/core/kpmap.js, modules/command.js, modules/district.js,
             modules/login.js, css/tokens.css (--map-*), css/pages.css
   Version : 0.5
   ===================================================================== */
/* ---------- the map component ---------- */
.kpm { position: relative; min-height: 220px; border-radius: var(--r-md); }   /* the host sets the size */
/* inside pages a one-finger swipe up or down still scrolls the page; two fingers work the map. The full-screen
   sign-in map, and any map once zoomed in, take every touch. */
.kpm-cv { position: absolute; left: 0; top: 0; display: block; touch-action: pan-y; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.kpm.greedy .kpm-cv, .kpm.zoomed .kpm-cv { touch-action: none; }
.kpm.kbd { outline: 3px solid var(--focus); outline-offset: 2px; }
.kpm-tip { position: absolute; left: 0; top: 0; z-index: 3; pointer-events: none; background: #102824; color: #eef7f5; font-size: 12.5px; line-height: 1.45;
  padding: 7px 10px; border-radius: 8px; max-width: 270px; box-shadow: var(--shadow-pop); opacity: 0; transition: opacity .12s; }
.kpm-tip.on { opacity: 1; }
.kpm-tip b { color: #fff; font-weight: 650; }
.kpm-tip .kpm-muted { color: #a9cdc5; }
.kpm-tip .kpm-row { display: flex; align-items: center; gap: 6px; }
/* after a tap (touch), the tooltip stays as a small card with a button to open the district */
.kpm-tip.pinned { pointer-events: auto; padding: 9px 11px 10px; }
.kpm-tip.pinned .kpm-click { display: none; }
.kpm-tip .kpm-open { display: flex; align-items: center; justify-content: center; width: 100%; margin-top: 8px; min-height: 36px; border: 0; border-radius: 8px;
  background: var(--logo-hi); color: #072a26; font: 700 13px/1.2 var(--f-text); padding: 6px 10px; cursor: pointer; }
.kpm-tip .kpm-open:hover { background: #8ff0e0; }
.kpm-tip .kpm-open:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
/* short gesture hint ("Use Ctrl + scroll to zoom the map") */
.kpm-hint { position: absolute; left: 50%; top: 50%; z-index: 4; transform: translate(-50%, -50%); pointer-events: none; opacity: 0; transition: opacity .2s;
  background: rgba(10, 30, 27, .82); color: #fff; font: 650 13.5px/1.35 var(--f-text); padding: 10px 16px; border-radius: 12px; text-align: center; max-width: 80%;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.kpm-hint.on { opacity: 1; }
.kpm-ctl { position: absolute; top: 4px; right: 4px; z-index: 2; display: flex; gap: 4px; align-items: center; }
.kpm-seg, .seg { display: inline-flex; padding: 2px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); flex: none; }
.kpm-seg button, .seg button { display: inline-flex; align-items: center; gap: 5px; border: 0; background: transparent; border-radius: 7px; padding: 3px 10px; min-height: 26px;
  font-size: 12.5px; font-weight: 650; color: var(--ink-2); white-space: nowrap; }
.seg button svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.kpm-seg button[aria-pressed="true"], .seg button[aria-pressed="true"] { background: var(--surface); color: var(--brand-ink); box-shadow: 0 0 0 1px var(--line-2), 0 1px 2px rgba(0, 0, 0, .06); }
.kpm-seg button:hover, .seg button:hover { color: var(--brand-ink); }
.kpm-btn { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2);
  font-size: 17px; font-weight: 700; line-height: 1; padding: 0; }
.kpm-btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.kpm-btn:hover { color: var(--brand-ink); border-color: var(--line-2); }
.kpm-btn[aria-disabled="true"] { opacity: .45; cursor: default; }
.kpm-btn[aria-disabled="true"]:hover { color: var(--ink-2); border-color: var(--line); }
/* touch screens: bigger targets for the map buttons */
@media (pointer: coarse) {
  .kpm-btn { width: 38px; height: 38px; font-size: 20px; border-radius: 10px; }
  .kpm-btn svg { width: 18px; height: 18px; }
  .kpm-seg button { min-height: 34px; padding: 3px 12px; }
}
.kpm-keys { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* on the dark sign-in panel */
.kpm.on-dark .kpm-seg { background: rgba(255, 255, 255, .07); border-color: rgba(255, 255, 255, .14); }
.kpm.on-dark .kpm-seg button { color: #cfe5df; }
.kpm.on-dark .kpm-seg button[aria-pressed="true"] { background: rgba(255, 255, 255, .16); color: #fff; box-shadow: none; }
.kpm.on-dark .kpm-btn { background: rgba(255, 255, 255, .07); border-color: rgba(255, 255, 255, .14); color: #cfe5df; }
.kpm.on-dark .kpm-btn:hover { color: #fff; }
.kpm.on-dark .kpm-btn[aria-disabled="true"]:hover { color: #cfe5df; }

/* ---------- map panels ---------- */
.panel-head .seg { margin-left: auto; }
.map-box { position: relative; height: 420px; }
.map-box.tall { height: min(68vh, 640px); min-height: 440px; }
.map-box.short { height: 300px; }
.map-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--ink-2); margin-top: 10px; align-items: center; }
.map-legend .row { gap: 5px; }
.map-legend .ramp { display: inline-flex; height: 10px; border-radius: 3px; overflow: hidden; vertical-align: middle; }
.map-legend .ramp i { display: block; width: 16px; height: 10px; }
.map-legend .off { width: 12px; height: 12px; border-radius: 50%; background: var(--map-off); display: inline-block; }
.map-note { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

/* glance card: small ranked list beside a big map */
.glance { display: grid; grid-template-columns: minmax(150px, 190px) minmax(0, 1fr); gap: 14px; align-items: stretch; }
.glance .map-box { height: 430px; }
.dlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.dlist button { width: 100%; display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; align-items: center; gap: 6px; border: 0; background: transparent;
  border-radius: 7px; padding: 5px 6px; text-align: left; font-size: 12.5px; color: var(--ink); line-height: 1.2; }
.dlist button:hover, .dlist button.on { background: var(--brand-tint); }
.dlist .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.dlist .sc { font-family: var(--f-display); font-weight: 850; font-size: 14px; font-variant-numeric: tabular-nums; }
.dlist-hd { font-size: 11.5px; color: var(--muted); padding: 0 6px 4px; display: flex; justify-content: space-between; }

/* domain map: picker row */
.dom-pick { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.dom-pick button { border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); border-radius: 99px; padding: 2px 9px; font-size: 12px; font-weight: 650;
  font-variant-numeric: tabular-nums; min-height: 26px; }
.dom-pick button:hover { border-color: var(--brand); color: var(--brand-ink); }
.dom-pick button[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.dom-now { font-size: 13px; color: var(--ink-2); margin: -2px 0 8px; }
.dom-now b { color: var(--ink); }

/* districts page: metric switch */
.map-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.map-tools .ctl select { max-width: 230px; }

/* the sign-in map fills the screen: see css/pages.css (sign-in) */

@media (max-width: 1500px) {
  .glance { grid-template-columns: minmax(124px, 140px) minmax(0, 1fr); }
}
/* command centre: below 1500 px the two status panels stack (keeps every matrix cell a 24 px target);
   the glance card then shows its list in two columns beside a taller map */
@media (max-width: 1499px) {
  .cc-row > .span-5, .cc-row > .span-7 { grid-column: span 12; }
}
@media (max-width: 1499px) and (min-width: 1101px) {
  .cc-row .glance { grid-template-columns: minmax(250px, 320px) minmax(0, 1fr); }
  .cc-row .glance .dlist { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; }
  .cc-row .glance .map-box { height: 480px; }
}
@media (max-width: 1100px) {
  .glance { grid-template-columns: minmax(0, 1fr); }
  .glance .dlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 2px 8px; }
  .glance .map-box, .map-box { height: 360px; }
}
@media (max-width: 700px) {
  .glance .map-box, .map-box, .map-box.tall { height: 320px; min-height: 0; }
}
/* districts page: the larger ranked list */
.dlist.big { gap: 3px; }
.dlist.big button { grid-template-columns: 18px minmax(0, 1fr) auto; padding: 7px 8px; font-size: 13.5px; }
.dlist.big .nm small { display: block; font-size: 11.5px; color: var(--muted); font-weight: 400; margin-top: 1px; }
.dlist.big .sc { font-size: 16px; }
