/* Poppins (SIL Open Font License, see fonts/OFL.txt) */
@font-face { font-family: "Poppins"; font-weight: 400; font-display: swap; src: url("fonts/poppins-400.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-weight: 600; font-display: swap; src: url("fonts/poppins-600.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-weight: 900; font-display: swap; src: url("fonts/poppins-900.woff2") format("woff2"); }

:root {
  /* Vates palette */
  --space: #141228;
  --space-deep: #0e0c1f;
  --panel: rgba(26, 27, 56, 0.72);
  --glass-line: rgba(143, 132, 255, 0.18);
  --line-soft: rgba(143, 132, 255, 0.10);
  --ink: #fffce4;
  --ink-2: rgba(255, 252, 228, 0.74);
  --ink-3: rgba(255, 252, 228, 0.52);
  --red: #be1621;
  --violet: #8f84ff;

  /* what was downloaded (validated: dark surface, CVD-safe) */
  --k-package: #8f84ff;
  --k-iso: #cf8c22;
  --k-metadata: #5a86c8;

  /* status: always with an icon and a word */
  --ok: #2ca878;
  --warn: #ef7f18;
  --bad: #f2555f;
  --off: #8a89a6;

  --edge: clamp(18px, 3vw, 44px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font: 400 15px/1.5 "Poppins", system-ui, sans-serif;
  background:
    radial-gradient(ellipse 70% 60% at 50% 42%, #1c1a3d 0%, rgba(20, 18, 40, 0) 70%),
    radial-gradient(ellipse 120% 90% at 50% 50%, var(--space) 55%, var(--space-deep) 100%);
  background-color: var(--space);
}
a { color: var(--violet); text-underline-offset: 3px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 3px; border-radius: 4px; }
button { font: inherit; color: inherit; }

/* The map is the page */
.map-wrap { position: fixed; inset: 0; }
#map { width: 100%; height: 100%; display: block; touch-action: none; -webkit-user-select: none; user-select: none; }
#map.zoomed { cursor: grab; }
#map.dragging { cursor: grabbing; }

/* Zoom buttons: middle of the right edge, over the Pacific east of Australia */
.zoom { position: absolute; z-index: 3; right: var(--edge); top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 6px; }
.zoom button {
  cursor: pointer; width: 36px; height: 36px; padding: 0; display: grid; place-items: center; border-radius: 50%;
  border: 1px solid var(--glass-line); background: rgba(26, 27, 56, 0.55); color: var(--ink-2);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  transition: background-color 150ms, color 150ms, border-color 150ms, opacity 150ms;
}
.zoom button:hover:not(:disabled) { color: var(--ink); border-color: rgba(143, 132, 255, 0.45); }
.zoom button:disabled { cursor: default; opacity: 0.4; }
/* Hidden at the world view, but its slot stays: + and - never move under the pointer */
.zoom button[hidden] { display: grid; visibility: hidden; }

/* Corners */
.corner { position: fixed; top: var(--edge); z-index: 3; }
.tl { left: var(--edge); display: flex; align-items: center; gap: 18px; }
.tr { right: var(--edge); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 900; font-size: 17px; letter-spacing: -0.01em; }
.brand img { display: block; }
.conn { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2);
  padding: 4px 12px 4px 10px; border: 1px solid var(--glass-line); border-radius: 999px; background: rgba(20, 18, 40, 0.5); }
.conn-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--off); }
.conn[data-state="live"] .conn-dot { background: var(--ok); animation: breathe 2s ease-out infinite; }
.conn[data-state="lost"] .conn-dot { background: var(--warn); }
@keyframes breathe { 0% { box-shadow: 0 0 0 0 rgba(44, 168, 120, 0.6); } 100% { box-shadow: 0 0 0 7px rgba(44, 168, 120, 0); } }
.by { display: flex; align-items: center; gap: 8px; color: var(--ink-2); text-decoration: none; font-size: 13px; }
.by:hover { color: var(--ink); }
.vates-logo { width: 64px; height: 22px; background: currentColor;
  -webkit-mask: url("img/vates.svg") center / 64px no-repeat; mask: url("img/vates.svg") center / 64px no-repeat; }

/* Bottom overlay: the figures on the left, the legend on the right */
.overlay { position: fixed; left: var(--edge); right: var(--edge); bottom: var(--edge); z-index: 2;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; pointer-events: none; }
.overlay a, .overlay button, .overlay .pulse { pointer-events: auto; }

.overview::before { content: ""; display: block; width: 44px; height: 3px; background: var(--red); border-radius: 2px; margin-bottom: 18px; }
.today { margin: 0; font-weight: 600; line-height: 0.95; }
.stacked .today-n { text-shadow: none; font-size: clamp(52px, 6.2vw, 104px);
  min-width: 4em; } /* room for six digits: the figures to its right stay put as it counts */
/* Over the map (wide screens): a narrow column in the Pacific, sized by the page */
@media (min-width: 761px) and (min-height: 561px) {
  body:not(.stacked) .overview { container-type: inline-size; }
  body:not(.stacked) .today-n { font-size: min(112px, 25cqi); }
  body:not(.stacked) .figures { gap: 12px 28px; }
  body:not(.stacked) .fig-rate { flex-basis: 100%; }
}
/* Stacked under the map: one compact row, the number left, the rest right */
.stacked .overview { display: grid; grid-template-columns: auto 1fr; column-gap: clamp(32px, 5vw, 72px); align-items: end; }
.stacked .overview::before { grid-column: 1 / -1; }
.stacked .today { grid-column: 1; grid-row: 2 / 4; align-self: end; }
.stacked .figures { grid-column: 2; grid-row: 2; margin: 0; }
.stacked .more { grid-column: 2; grid-row: 3; margin-top: 14px; }
.today-n { display: block; font-size: clamp(60px, 9.5vw, 148px); letter-spacing: -0.045em;
  text-shadow: 0 0 40px var(--space), 0 0 12px var(--space); }
.today-label { display: block; margin-top: 10px; font-size: clamp(17px, 1.6vw, 21px); font-weight: 400; color: var(--ink-2); letter-spacing: 0; }

.figures { display: flex; flex-wrap: wrap; gap: 14px 40px; margin: 26px 0 0; }
.figures dt { color: var(--ink-3); font-size: 13px; }
.figures dd { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.figures .per { font-size: 14px; font-weight: 400; color: var(--ink-2); }
/* Live values change in place: equal-width digits and a fixed slot, so the
   sparkline and the figures beside them never shift (Poppins' default digits
   range from 0.36em for "1" to 0.65em for "0"). */
#rate { font-variant-numeric: tabular-nums; }
.fig-rate dd { min-width: 168px; } /* fits "88.8 per second": the slack sits after the unit */
.fig-rate { display: grid; grid-template-columns: auto auto; column-gap: 14px; align-items: end; }
.fig-rate dt, .fig-rate dd { grid-column: 1; }
.pulse { grid-column: 2; grid-row: 1 / 3; width: 120px; height: 38px; align-self: end; margin-bottom: 4px; }
.pulse svg { display: block; width: 100%; height: 100%; overflow: visible; }

.more { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.more button {
  cursor: pointer; padding: 7px 16px; border-radius: 999px; font-size: 14px;
  border: 1px solid var(--glass-line); background: rgba(26, 27, 56, 0.55); color: var(--ink-2);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  transition: background-color 150ms, color 150ms, border-color 150ms;
}
.more button:hover { color: var(--ink); border-color: rgba(143, 132, 255, 0.45); }
.more button[aria-expanded="true"] { background: var(--violet); border-color: var(--violet); color: var(--space); }

/* Legend: bottom right, level with the figures */
.legend { font-size: 13px; color: var(--ink-2); text-align: right; }
.key { list-style: none; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 16px; margin: 0; padding: 0; }
.key li { display: flex; align-items: center; gap: 7px; }
.swatch { display: inline-block; width: 14px; height: 2px; border-radius: 1px; }
.k-package { background: var(--k-package); }
.k-iso { background: var(--k-iso); }
.k-metadata { background: var(--k-metadata); }
.credit { margin: 8px 0 0; font-size: 12px; color: var(--ink-3); }
.credit a { color: var(--ink-3); }
.credit a:hover { color: var(--ink); }

/* Tooltips */
.map-tip, .chart-tip {
  position: fixed; z-index: 20; pointer-events: none;
  background: rgba(26, 27, 56, 0.92); border: 1px solid var(--glass-line); border-radius: 10px;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  padding: 8px 12px; font-size: 13px; line-height: 1.45; color: var(--ink-2);
  box-shadow: 0 10px 30px rgba(5, 4, 20, 0.55); max-width: 280px;
}
.tip-value { color: var(--ink); font-weight: 600; font-size: 15px; }
.tip-row { display: flex; align-items: center; gap: 8px; }

/* Detail panel: slides in over the map when asked for */
.panel {
  position: fixed; z-index: 10; top: 12px; right: 12px; bottom: 12px; width: min(500px, calc(100vw - 24px));
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--glass-line); border-radius: 18px;
  -webkit-backdrop-filter: blur(18px) saturate(1.2); backdrop-filter: blur(18px) saturate(1.2);
  box-shadow: 0 24px 60px rgba(5, 4, 20, 0.6);
  animation: slide-in 260ms cubic-bezier(.2, .8, .2, 1);
}
.panel[hidden] { display: none; }
.panel[data-view="week"] { bottom: auto; }
@keyframes slide-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 22px 24px 6px; }
.panel h2 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.panel h3 { margin: 26px 0 0; font-size: 16px; font-weight: 600; }
.panel h3:first-child { margin-top: 0; }
.close { cursor: pointer; border: 0; background: transparent; color: var(--ink-2); width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; }
.close:hover { background: rgba(143, 132, 255, 0.15); color: var(--ink); }
.panel-body { overflow-y: auto; padding: 4px 24px 24px; scrollbar-width: thin; scrollbar-color: rgba(143, 132, 255, 0.3) transparent; }
.lede { margin: 4px 0 16px; color: var(--ink-2); font-size: 14px; }
.panel-foot { margin: 20px 0 0; font-size: 13px; color: var(--ink-3); }
.empty { color: var(--ink-3); margin: 0; }

/* Mirror list */
.mirror-list { list-style: none; margin: 0; padding: 0; }
.mrow { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; column-gap: 12px; row-gap: 2px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.mrow .icon { grid-row: 1; padding-top: 4px; }
.mrow .name { color: var(--ink); text-decoration: none; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrow .name:hover { color: var(--violet); }
.mrow .n { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.mrow .where { grid-column: 2; color: var(--ink-3); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrow .spark { grid-column: 3; grid-row: 2; justify-self: end; }
.mrow .meter { grid-column: 2 / 4; height: 3px; margin-top: 6px; border-radius: 2px; background: var(--line-soft); overflow: hidden; }
.mrow .meter i { display: block; height: 100%; border-radius: 2px; background: var(--violet); }
.mrow.is-off .name, .mrow.is-bad .name { color: var(--ink-2); }
.spark { display: block; width: 96px; height: 20px; }
.spark path.l { fill: none; stroke: var(--violet); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark path.a { fill: rgba(143, 132, 255, 0.12); }

/* Charts */
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid line { stroke: var(--line-soft); stroke-width: 1; }
.chart .axis text, .chart .tick { fill: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .value-label { fill: var(--ink-2); font-size: 12px; font-weight: 600; }

/* Bar lists */
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: baseline; font-size: 14px; }
.bar-row .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .n { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.bar-row .track { grid-column: 1 / -1; height: 4px; }
.bar-row .track i { display: block; height: 100%; min-width: 2px; border-radius: 0 2px 2px 0; background: var(--violet); }

/* Small screens: the map on top, everything below, the page scrolls */
@media (max-width: 760px), (max-height: 560px) {
  body { overflow: auto; }
  .map-wrap { position: relative; inset: auto; width: 100%; height: 62vw; margin-top: 64px; }
  /* bottom right of the map, below New Zealand; finger-sized */
  .zoom { top: auto; bottom: 6px; transform: none; flex-direction: row; }
  .zoom button { width: 40px; height: 40px; }
  #map { touch-action: pan-y; } /* until zoomed in: the page scrolls */
  .corner { position: absolute; }
  .brand span { font-size: 15px; }
  .by-word { display: none; }
  .overlay { position: static; display: block; padding: 8px var(--edge) var(--edge); }
  .legend { margin-top: 32px; text-align: left; }
  .legend .key { justify-content: flex-start; }
  .figures { gap: 14px 28px; }
  .panel { top: 0; right: 0; bottom: 0; width: 100vw; border-radius: 0; }
}
@media (max-width: 480px) {
  .tl { gap: 10px; }
  .brand { font-size: 14px; gap: 8px; }
  .conn { padding: 6px; }
  #conn-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .vates-logo { width: 52px; -webkit-mask-size: 52px; mask-size: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  .conn[data-state="live"] .conn-dot, .panel { animation: none; }
}
