/*
 * The Slate relay status page (ADR-91). Styled as a natural extension of the
 * desktop app's design system (ADR-46/47): the catppuccin-frappe palette in
 * dark, latte in light, Slate's Inter + JetBrains Mono stacks (via the same
 * system fallback the Mantine theme uses — the strict CSP forbids CDN fonts),
 * cool near-monochrome with a single slate-blue accent. Restraint is the point:
 * a zero-knowledge relay's front door should feel quiet and honest.
 */

:root {
  color-scheme: dark light;

  /* frappe (dark) — sourced from apps/client/src/lib/mantine.ts */
  --bg: #303446; /* base */
  --bg-2: #292c3c; /* mantle */
  --surface: #414559; /* surface0 */
  --border: #51576d; /* surface1 */
  --border-soft: #414559;
  --text: #c6d0f5; /* text */
  --dim: #a5adce; /* subtext */
  --faint: #838ba7; /* overlay */
  --accent: #8caaee; /* blue */
  --ok: #a6d189; /* green */
  --bad: #e78284; /* red */

  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --radius: 12px;
  --line: 1px solid var(--border);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.02) inset, 0 8px 30px -18px rgba(0, 0, 0, 0.6);
}

@media (prefers-color-scheme: light) {
  :root {
    /* latte (light) */
    --bg: #eff1f5; /* base */
    --bg-2: #e6e9ef; /* mantle */
    --surface: #ffffff; /* surface */
    --border: #ccd0da; /* surface1 */
    --border-soft: #dce0e8;
    --text: #4c4f69; /* text */
    --dim: #6c6f85; /* subtext1 */
    --faint: #8c8fa1; /* subtext0 */
    --accent: #1e66f5; /* blue */
    --ok: #40a02b; /* green */
    --bad: #d20f39; /* red */
    --shadow: 0 8px 30px -20px rgba(76, 79, 105, 0.35);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(1100px 520px at 50% -12%, var(--bg-2) 0%, transparent 62%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding: clamp(20px, 6vh, 72px) clamp(16px, 4vw, 40px);
}

.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* ── Frame ─────────────────────────────────────────────────────────────── */
#status-root {
  display: block;
  max-width: 660px;
  margin: 0 auto;
}

.dash {
  display: flex;
  flex-direction: column;
  gap: clamp(22px, 4vw, 34px);
  animation: rise 0.5s var(--ease) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ── Top bar ───────────────────────────────────────────────────────────── */
.bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 18px;
  border-bottom: var(--line);
}

.brand {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--dim);
  white-space: nowrap;
}

.brand__mark {
  color: var(--accent);
}

.brand__sep {
  color: var(--faint);
  margin: 0 1px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 5px 12px 5px 10px;
  border: 1px solid color-mix(in srgb, var(--ok) 42%, var(--border));
  border-radius: 999px;
  background: color-mix(in srgb, var(--ok) 12%, transparent);
  color: color-mix(in srgb, var(--ok) 68%, var(--text));
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  white-space: nowrap;
}

.pill__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent);
  animation: beat 2.4s var(--ease) infinite;
}

@keyframes beat {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent);
  }
  70% {
    box-shadow: 0 0 0 7px transparent;
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

.ver {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--faint);
  white-space: nowrap;
}

.ver__sep {
  margin: 0 6px;
  opacity: 0.6;
}

.ver__commit {
  color: var(--dim);
}

/* ── Lead / trust statement ────────────────────────────────────────────── */
.lead {
  margin: 0;
  font-size: clamp(17px, 2.6vw, 20px);
  line-height: 1.55;
  color: var(--dim);
  max-width: 54ch;
}

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

/* ── Runtime stats ─────────────────────────────────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: 1.3fr 1fr 0.8fr;
  gap: 12px;
}

.stat {
  background: var(--surface);
  border: var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 15px 16px;
  min-width: 0;
}

.stat__k {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--faint);
  margin-bottom: 8px;
}

.stat__v {
  display: block;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--text);
  overflow-wrap: anywhere;
}

.stat:first-child .stat__v {
  color: color-mix(in srgb, var(--accent) 34%, var(--text));
}

.stat__v--sm {
  font-size: 14px;
  color: var(--dim);
  font-weight: 500;
}

/* ── Configured limits ─────────────────────────────────────────────────── */
.limits {
  background: var(--surface);
  border: var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px 16px;
}

.limits__h {
  margin: 0 0 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--faint);
}

.limits__grid {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 24px;
}

.limit {
  display: flex;
  flex-direction: column;
  gap: 3px;
  border-left: 2px solid var(--border);
  padding-left: 12px;
}

.limit dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
}

.limit dd {
  margin: 0;
  font-size: 16px;
  color: var(--text);
}

.limits__note {
  margin: 16px 0 0;
  font-size: 12px;
  color: var(--faint);
  font-style: italic;
}

/* ── Footer / receipts ─────────────────────────────────────────────────── */
.foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 16px;
  border-top: var(--line);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--faint);
}

.foot__link {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s var(--ease);
}

.foot__link:hover {
  border-bottom-color: color-mix(in srgb, var(--accent) 55%, transparent);
}

.foot__sep {
  opacity: 0.5;
}

.foot__receipt code {
  color: var(--dim);
}

.page-foot {
  text-align: center;
  margin: 30px 0 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--faint);
  opacity: 0.75;
}

.page-foot b {
  color: var(--dim);
  font-weight: 600;
}

/* ── Offline state ─────────────────────────────────────────────────────── */
.banner {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 9px 12px;
  background: color-mix(in srgb, var(--bad) 16%, var(--bg-2));
  color: var(--bad);
  border-bottom: 1px solid color-mix(in srgb, var(--bad) 40%, var(--border));
  font-family: var(--mono);
  font-size: 12.5px;
  transform: translateY(-100%);
  transition: transform 0.35s var(--ease);
}

.banner__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bad);
  animation: beat 1.6s var(--ease) infinite;
}

body.is-offline .banner {
  transform: none;
}

body.is-offline #status-root {
  opacity: 0.5;
  filter: saturate(0.55);
  transition:
    opacity 0.35s var(--ease),
    filter 0.35s var(--ease);
}

body.is-offline .pill {
  border-color: color-mix(in srgb, var(--bad) 45%, var(--border));
  background: color-mix(in srgb, var(--bad) 12%, transparent);
  color: color-mix(in srgb, var(--bad) 72%, var(--text));
}

body.is-offline .pill__dot {
  background: var(--bad);
}

/* ── Responsive & motion ───────────────────────────────────────────────── */
@media (max-width: 560px) {
  .stats {
    grid-template-columns: 1fr 1fr;
  }
  .stats .stat:first-child {
    grid-column: 1 / -1;
  }
  .limits__grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
