/* netmapper UI. Dark by default, light when the visitor asks for it. */

:root {
  --bg: #11151c;
  --panel: #171d26;
  --panel-2: #1e2633;
  --line: #2a3442;
  --text: #e6ebf2;
  --muted: #98a4b5;
  --accent: #4da3ff;
  --danger: #e06666;
  --ok: #3fbf7f;
  --radius: 8px;
  --bar-height: 52px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f8fb;
    --panel: #ffffff;
    --panel-2: #eef2f7;
    --line: #d7dfea;
    --text: #17202c;
    --muted: #5b6878;
    --accent: #1667c9;
    --danger: #b3261e;
    --ok: #1f8a5b;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

/* --- header --------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--bar-height);
  padding: 0 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 2;
}

.wordmark {
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
  font-size: 17px;
}
.wordmark:hover { text-decoration: none; color: var(--accent); }

.stats {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

/* Filled by app.js once clerk-js has settled, so it is empty on first paint
   and must take up no room until it is not. */
.auth {
  display: flex;
  align-items: center;
  gap: 12px;
}
.auth:empty { display: none; }

.who {
  color: var(--muted);
  font-size: 13px;
  max-width: 22ch;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 640px) {
  .who { display: none; }
  .stats { font-size: 12px; }
}

form.inline { display: inline; margin: 0; }

/* --- buttons and fields --------------------------------------------------- */

.button,
button {
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 7px 12px;
}
.button:hover, button:hover { border-color: var(--accent); text-decoration: none; }

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.linkish {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  text-decoration: none;
}
.linkish:hover { text-decoration: underline; }
.linkish.danger { color: var(--danger); }

input[type="text"],
input[type="email"],
input[type="password"] {
  font: inherit;
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
}
input:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- pages ---------------------------------------------------------------- */

.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 16px 64px;
}
.page.narrow { max-width: 420px; }

h1 { font-size: 24px; margin: 0 0 6px; letter-spacing: -0.01em; }
h2 { font-size: 17px; margin: 32px 0 10px; }
.lede { color: var(--muted); margin: 0 0 20px; }
.footnote { color: var(--muted); margin-top: 20px; font-size: 14px; }
.hint-text { color: var(--muted); font-size: 13px; margin: 2px 0 0; }
.empty { color: var(--muted); }

.stack { display: flex; flex-direction: column; gap: 6px; }
.stack label { font-size: 13px; color: var(--muted); margin-top: 8px; }
.stack .button { margin-top: 18px; }

.row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.row input[type="text"] { flex: 1 1 220px; width: auto; }

.error {
  background: color-mix(in srgb, var(--danger) 16%, transparent);
  border: 1px solid var(--danger);
  color: var(--text);
  border-radius: var(--radius);
  padding: 9px 12px;
  margin: 0 0 16px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- new key -------------------------------------------------------------- */

.newkey {
  background: var(--panel);
  border: 1px solid var(--ok);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
}
.newkey h2 { margin: 0 0 4px; font-size: 16px; }
.newkey p { margin: 0 0 10px; color: var(--muted); }

.keyrow {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.keyrow code {
  flex: 1 1 320px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 11px;
  word-break: break-all;
  user-select: all;
}

/* --- tables --------------------------------------------------------------- */

.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  display: block;
  overflow-x: auto;
  white-space: nowrap;
}
.grid th, .grid td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.grid th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.grid td.right, .grid th.right { text-align: right; font-variant-numeric: tabular-nums; }
.grid tr.muted td { color: var(--muted); }

.badge {
  display: inline-block;
  font-size: 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 7px;
  color: var(--muted);
}

.status { font-size: 12px; }
.status-done { color: var(--ok); }
.status-failed { color: var(--danger); }
.status-queued, .status-processing { color: var(--muted); }

/* --- map ------------------------------------------------------------------ */

body.map-page {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.map-shell {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

#map { position: absolute; inset: 0; }

.hint {
  position: absolute;
  left: 50%;
  top: 14px;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--muted);
  z-index: 1;
  pointer-events: none;
}

/* Shown over the map to anyone who is not signed in, and raised again when a
   session expires while the page is open. */
.signin-card {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  width: min(360px, calc(100% - 32px));
  text-align: center;
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.signin-card[hidden] { display: none; }
.signin-card h2 { margin: 0 0 6px; font-size: 17px; }
.signin-card p { margin: 0; color: var(--muted); font-size: 14px; }
.signin-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px !important;
}

.legend {
  position: absolute;
  left: 10px;
  bottom: 28px;
  margin: 0;
  padding: 8px 10px;
  list-style: none;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--muted);
  z-index: 1;
}
.legend .dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: baseline;
}
.dot.open { background: #3fbf7f; }
.dot.wep { background: #e05252; }
.dot.wpa { background: #e0a23c; }
.dot.other { background: #8a93a3; }

@media (max-width: 480px) {
  .legend { gap: 8px; bottom: 24px; font-size: 11px; }
}

/* MapLibre popups inherit the page palette. */
.maplibregl-popup-content {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}
.maplibregl-popup-tip { display: none; }

.popup h3 { margin: 0 0 6px; font-size: 14px; word-break: break-word; }
.popup h3.hidden-ssid { color: var(--muted); font-style: italic; }
.popup dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  font-size: 12.5px;
}
.popup dt { color: var(--muted); }
.popup dd { margin: 0; word-break: break-word; }

/* --- toast ---------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: 9px 14px;
  font-size: 13px;
  z-index: 10;
  max-width: calc(100vw - 32px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}
.toast[hidden] { display: none; }
