/* =====================================================================
   KPI demo - map window (v0.7)
   Purpose : The window that shows any chart or table on a 3D map: a dark
             stage (the same in light and dark mode, so the glowing
             columns read), a ranked list beside it, figures and a legend.
             The tokens set on .mapwin give the map (kpmap reads them) and
             the controls inside their dark colours.
   Related : js/core/mapwin.js, js/core/kpmap.js, css/map.css
   Version : 0.7
   ===================================================================== */
.scrim-d.mw-scrim { background: rgba(2, 16, 14, .72); }   /* no blur: a blurred backdrop over moving maps costs frames */
/* dark stage tokens: the map window and the API map panels on dashboards */
.modal.mapwin, .dark-stage {
  --ink: #e8f3f0; --ink-2: #b9d2cc; --muted: #93b3ab; --surface: #0e2e2a; --surface-2: #133834; --line: rgba(255, 255, 255, .1); --line-2: rgba(255, 255, 255, .2);
  --axis: rgba(255, 255, 255, .28); --grid: rgba(255, 255, 255, .08); --brand-tint: rgba(143, 240, 224, .12); --brand-ink: #9ff3e5;
  --map-off: #1d3a35; --map-halo: #05201c;
  --q1: #1d5549; --q2: #23685a; --q3: #2b7d6a; --q4: #379c85; --q5: #4fb59a; --q6: #7ccdb7; --q7: #b0e8d8;
  --good: #22a722; --warn: #fab219; --serious: #ef8a5f; --critical: #e5534b;
}
.dark-stage { background: radial-gradient(110% 90% at 30% 15%, #14504a 0%, #0b2d29 50%, #061c19 100%); color: var(--ink); }
.modal.mapwin {
  position: fixed; z-index: 92; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(1260px, 96vw); height: min(880px, 94vh); max-height: none; padding: 0; overflow: hidden;
  display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto;
  background: radial-gradient(110% 80% at 32% 18%, #14504a 0%, #0b2d29 46%, #061c19 100%);
  color: var(--ink); border: 1px solid rgba(143, 240, 224, .18); border-radius: 18px; box-shadow: 0 32px 90px rgba(0, 0, 0, .5);
  animation: mwIn .34s var(--ease);
}
@keyframes mwIn { from { opacity: 0; transform: translate(-50%, -48%) scale(.985); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

.mw-head { display: flex; align-items: flex-start; gap: 16px; padding: 18px 22px 10px; }
.mw-ttl { flex: 1; min-width: 0; }
.mw-k { font-size: 12.5px; color: #e4d36b; font-weight: 600; letter-spacing: .01em; }
.mw-head h2 { font-family: var(--f-display); font-size: clamp(19px, 2.2vw, 25px); font-weight: 650; line-height: 1.2; margin: 2px 0 4px; color: #fff; }
.mw-sub { color: var(--muted); font-size: 13px; margin: 0; max-width: 72ch; }
.mw-x { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .06); color: #dcefe9; }
.mw-x:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.mw-x svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; }

.mw-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 4px 22px 12px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.mw-pick { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); min-width: 0; }
.mw-pick b { color: #fff; font-weight: 650; }
.mw-pick select { appearance: none; -webkit-appearance: none; background: rgba(255, 255, 255, .07) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' fill='none' stroke='%23cfe5df' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 9px center / 16px;
  color: #fff; border: 1px solid rgba(255, 255, 255, .18); border-radius: 9px; padding: 7px 34px 7px 11px; font: inherit; font-weight: 600; max-width: min(460px, 70vw); }
.mw-pick select option { color: #13201c; background: #fff; }
.mapwin .seg { background: rgba(255, 255, 255, .07); border-color: rgba(255, 255, 255, .16); }
.mapwin .seg button { color: #cfe5df; }
.mapwin .seg button[aria-pressed="true"] { background: rgba(143, 240, 224, .18); color: #fff; box-shadow: none; }
.mw-bar .spacer { flex: 1; }
.mapwin [hidden] { display: none !important; }

.mw-body { display: grid; grid-template-columns: minmax(0, 1fr) 330px; min-height: 0; }
.mw-stage { position: relative; min-height: 0; }
.mw-map { position: absolute; inset: 0; }
.mw-map .kpm-ctl { top: 12px; right: 12px; }
.mw-stats { position: absolute; left: 16px; top: 14px; display: flex; flex-wrap: wrap; gap: 8px; max-width: calc(100% - 200px); pointer-events: none; }
.mw-stat { background: rgba(4, 22, 19, .8); border: 1px solid rgba(255, 255, 255, .1); border-radius: 12px; padding: 7px 12px 8px; min-width: 104px; }
.mw-stat span { display: block; font-size: 11.5px; color: var(--muted); }
.mw-stat b { display: block; font-family: var(--f-display); font-size: 20px; font-weight: 750; color: #fff; line-height: 1.15; font-variant-numeric: tabular-nums; }
.mw-stat em { font-style: normal; font-size: 12px; color: #9ff3e5; }
.mw-legend { position: absolute; left: 16px; bottom: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 12px; color: var(--ink-2); background: rgba(4, 22, 19, .55); border-radius: 10px; padding: 7px 11px; max-width: calc(100% - 32px); }
.mw-legend .row { display: inline-flex; align-items: center; gap: 5px; }
.mw-legend .ramp { display: inline-flex; height: 10px; border-radius: 5px; overflow: hidden; width: 120px; }
.mw-legend .ramp i { flex: 1; }
.mw-legend .lo, .mw-legend .hi { font-weight: 650; color: #fff; font-variant-numeric: tabular-nums; }
.mw-legend .cap { color: var(--muted); }

.mw-side { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid rgba(255, 255, 255, .08); background: rgba(2, 14, 12, .28); }
.mw-side-hd { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px 8px 16px; }
.mw-side-hd h3 { font-size: 13.5px; font-weight: 650; color: #fff; margin: 0; }
.mapwin .btn.quiet { color: #cfe5df; }
.mapwin .btn.quiet:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.mw-rank { list-style: none; margin: 0; padding: 0 8px 12px; overflow: auto; min-height: 0; flex: 1; counter-reset: none; }
.mw-rank li { margin: 0; }
.mw-rank button { display: grid; grid-template-columns: 22px minmax(0, 1fr) 70px auto; align-items: center; gap: 8px; width: 100%; text-align: left; border: 0; background: transparent; color: var(--ink); border-radius: 9px; padding: 7px 8px; font: inherit; font-size: 13px; }
.mw-rank button:hover, .mw-rank button.on, .mw-rank button:focus-visible { background: rgba(143, 240, 224, .1); }
.mw-rank button.sel { box-shadow: inset 3px 0 0 #e4d36b; background: rgba(228, 211, 107, .08); }
.mw-rank .rk { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; }
.mw-rank .nm { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mw-rank .bar { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .07); overflow: hidden; }
.mw-rank .bar i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, #379c85, #9ff3e5); transition: width .5s var(--ease); }
.mw-rank .v { font-weight: 650; font-variant-numeric: tabular-nums; color: #fff; white-space: nowrap; }

.mw-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 11px 22px 14px; border-top: 1px solid rgba(255, 255, 255, .08); }
.mw-note { flex: 1; min-width: 200px; margin: 0; font-size: 12.5px; color: var(--muted); }
.mapwin .btn { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .18); color: #e8f3f0; }
.mapwin .btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.mapwin .btn.primary { background: #6fecd8; border-color: #6fecd8; color: #062a25; }
.mapwin .btn.primary:hover { background: #9ff3e5; border-color: #9ff3e5; color: #062a25; }
.mapwin .apipill, .mapwin .pill.api { box-shadow: 0 0 0 1px rgba(0, 0, 0, .2); }

/* the PMRU API map panel on dashboards (v0.7) */
.apimap-pick { display: flex; flex-wrap: wrap; margin: 2px 0 10px; max-width: 100%; }
.apimap-pick button { white-space: normal; text-align: left; }
.apimap-stage { position: relative; border-radius: 12px; overflow: hidden; }
.apimap-stage .map-box { height: clamp(340px, 46vh, 460px); }
.apimap-stage .mw-stats { top: 12px; left: 12px; }
.apimap-stage .mw-legend { left: 12px; bottom: 12px; }
@media (max-width: 700px) { .apimap-stage .mw-stats { display: none; } }

/* the button that opens the window, on every chart and table */
.mw-btn svg { stroke-width: 1.7; }
.mw-btn:hover { color: var(--brand-ink); background: var(--brand-tint); }
.map-expand { position: absolute; z-index: 2; left: 8px; top: 6px; display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 4px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: 12.5px; font-weight: 600; }
.map-expand:hover { color: var(--brand-ink); border-color: var(--brand); }
.map-expand svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 900px) {
  .modal.mapwin { width: 100vw; height: 100dvh; height: 100vh; border-radius: 0; border: 0; }
  .mw-body { grid-template-columns: 1fr; grid-template-rows: minmax(300px, 1fr) minmax(0, 38%); }
  .mw-side { border-left: 0; border-top: 1px solid rgba(255, 255, 255, .08); }
  .mw-stats { max-width: calc(100% - 32px); top: 52px; }
  .mw-stat { min-width: 0; padding: 5px 9px 6px; }
  .mw-stat b { font-size: 16px; }
  .mw-legend .cap { display: none; }
  .mw-head { padding: 14px 14px 6px; }
  .mw-bar, .mw-foot { padding-left: 14px; padding-right: 14px; }
}
@media (prefers-reduced-motion: reduce) { .modal.mapwin { animation: none; } .mw-rank .bar i { transition: none; } }
