/* Sparrow invite page.
 *
 * Everything is here rather than in the markup because the page ships under
 * `default-src 'none'; script-src 'self'; style-src 'self'; …` — that CSP
 * bans style attributes and <style> blocks along with inline script, and the
 * ban is what keeps an injected string from turning into running code on the
 * one page in this system that holds a private key.
 *
 * No @font-face and no font CDN: an external font is a third-party origin
 * that learns the invite page was opened. System stacks only. */

:root {
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --text-1: #eef1f8;
  --text-2: #9aa3b8;
  --text-3: #5d6577;
  --accent: #4c8dff;
  --accent-hi: #6ea3ff;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --card: rgba(255, 255, 255, 0.06);
  --card-border: rgba(255, 255, 255, 0.09);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #131a33 0%, #0b101f 55%, #080b16 100%);
  background-attachment: fixed;
  color: var(--text-1);
  font: 400 16px/1.55 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  padding: 0 16px env(safe-area-inset-bottom) 16px;
}

/* ── masthead ───────────────────────────────────────────────────────────── */

.masthead {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 560px;
  margin: 0 auto;
  padding: 26px 4px 20px;
  color: var(--text-1);
}

.mark { display: block; flex: none; }

.wordmark {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* ── layout ─────────────────────────────────────────────────────────────── */

main {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#screen-result {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#regions {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

[hidden] { display: none !important; }

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 20px;
}

.card-success { border-color: rgba(52, 211, 153, 0.35); }
.card-error   { border-color: rgba(248, 113, 113, 0.35); }

h1 {
  margin: 0 0 10px;
  font-size: 21px;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: -0.01em;
}

h2 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
}

p { margin: 0 0 12px; color: var(--text-2); }
p:last-child { margin-bottom: 0; }

strong { color: var(--text-1); font-weight: 600; }

code, .mono, pre { font-family: var(--font-mono); }

code {
  font-size: 0.9em;
  color: var(--text-1);
  background: rgba(255, 255, 255, 0.07);
  border-radius: 5px;
  padding: 1px 5px;
}

.muted { color: var(--text-2); }
.fineprint { margin-top: 14px; color: var(--text-3); font-size: 13px; }

.warn-line {
  color: var(--text-1);
  background: rgba(251, 191, 36, 0.08);
  border-left: 2px solid var(--amber);
  border-radius: 0 8px 8px 0;
  padding: 10px 12px;
  font-size: 14px;
}

a { color: var(--accent); }
a:hover { color: var(--accent-hi); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── form ───────────────────────────────────────────────────────────────── */

.field-label {
  display: block;
  margin: 18px 0 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-1);
}

input[type="text"] {
  display: block;
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text-1);
  /* 16px minimum, or iOS Safari zooms the whole page on focus. */
  font: 400 16px/46px var(--font-mono);
}

input[type="text"]::placeholder { color: var(--text-3); }
input[type="text"]:focus { border-color: var(--accent); outline: none; }

.hint { margin: 8px 0 0; font-size: 13px; color: var(--text-3); }
.hint .mono { color: var(--text-2); }

.field-error {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--red);
}

button {
  font: 500 15px/1 var(--font-ui);
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  min-height: 46px;
  padding: 0 22px;
  transition: background 160ms, color 160ms, border-color 160ms;
}

.btn-primary {
  display: block;
  width: 100%;
  margin-top: 18px;
  background: var(--accent);
  color: #05122e;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hi); }
.btn-primary:disabled { background: var(--text-3); color: #10141f; cursor: default; }

.btn-secondary {
  display: block;
  width: 100%;
  margin-top: 12px;
  background: transparent;
  border-color: rgba(255, 255, 255, 0.16);
  color: var(--text-1);
}
.btn-secondary:hover { background: rgba(255, 255, 255, 0.07); }

.row { display: flex; flex-direction: column; }
.row .btn-primary, .row .btn-secondary { margin-top: 12px; }

@media (min-width: 460px) {
  .row { flex-direction: row; gap: 10px; }
  .row .btn-primary, .row .btn-secondary { width: auto; flex: 1; }
}

/* ── working ────────────────────────────────────────────────────────────── */

.spinner {
  width: 22px;
  height: 22px;
  margin-bottom: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--accent);
  animation: spin 800ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2400ms; }
}

/* ── region cards ───────────────────────────────────────────────────────── */

.region-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.region-head h2 { margin: 0; }

.region-endpoint { font-size: 12px; color: var(--text-3); }

.qr-wrap { text-align: center; }

/* White quiet zone is not decoration — scanners need the light background and
   the 4-module margin the generator leaves around the code. */
.qr {
  display: inline-block;
  background: #ffffff;
  border-radius: 10px;
  padding: 10px;
  line-height: 0;
}

.qr svg {
  display: block;
  width: 200px;
  height: 200px;
}

.qr-caption {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--text-3);
}

.act-status {
  margin: 10px 0 0;
  min-height: 18px;
  font-size: 13px;
  color: var(--green);
}

.conf-details { margin-top: 14px; }

.conf-details summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--text-2);
}
.conf-details summary:hover { color: var(--text-1); }

pre.conf {
  margin: 10px 0 0;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.32);
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
  -webkit-user-select: all;
  user-select: all;
}

/* ── footer ─────────────────────────────────────────────────────────────── */

.footer {
  max-width: 560px;
  margin: 0 auto;
  padding: 26px 4px 32px;
}

.footer p {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-3);
}

/* ── root "nothing here" page ───────────────────────────────────────────── */

.centered {
  max-width: 560px;
  margin: 0 auto;
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
