/* Postern portal stylesheet -- single dark theme, no inline styles permitted
  by CSP (default-src 'self'). Order: tokens -> reset -> brand -> chrome ->
  background -> cards -> footer -> flag rules (via flags/flags.css link).
  Tokens are inherited from the hole UI's dark theme so a future light variant
  is a token-swap exercise rather than a rewrite. */

/* Tokens ===== */
:root, [data-theme="dark"] {
  --bg-base: #0e0e1a;
  --bg-deep: #0a0a16;
  --bg-card: rgba(14, 14, 26, 0.78);
  --bg-input: rgba(22, 22, 40, 0.7);
  --bg-conn: rgba(22, 22, 40, 0.55);
  --bg-conn-hover: rgba(22, 22, 40, 0.75);

  --border-dim: #1a1a2a;
  --border-card: rgba(42, 42, 74, 0.6);
  --border-input: #2a2a4a;
  --border-strong: #3a3a6a;

  --text-strong: #ffffff;
  --text: #e0e0e0;
  --text-dim: #cccccc;
  --text-muted: #888888;
  --text-faint: #666666;
  --text-faintest: #555555;
  --text-darkest: #444444;

  --accent: #6c63ff;
  --accent-2: #22d3ee;
  --accent-text: #a5b4fc;
  --accent-soft: rgba(108, 99, 255, 0.18);
  --accent-softer: rgba(108, 99, 255, 0.12);
  --accent-faint: rgba(108, 99, 255, 0.08);
  --accent-glow: rgba(108, 99, 255, 0.35);

  --status-ok: #22c55e;
  --status-warn: #f59e0b;
  --status-err: #f87171;
  --status-off: #444444;

  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "Fira Code", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;

  --radius-card: 10px;
  --radius-input: 6px;
  --radius-brand: 11px;
  --radius-chip: 999px;

  --shadow-brand: 0 8px 32px var(--accent-glow);
  --blur-card: blur(14px);
}

@font-face {
  font-family: "Inter";
  src: url("/static/fonts/InterVariable.woff2") format("woff2-variations"),
    url("/static/fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Fira Code";
  src: url("/static/fonts/FiraCode-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* Reset / base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }
body {
  background: var(--bg-base);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;       /* GoL canvas is full-bleed; cards float over it */
  position: relative;
}

a { color: var(--accent-text); text-decoration: none; }
a:hover { color: var(--text-strong); }
button { font-family: inherit; }

/* GoL background + overlay ===== */
#gol-canvas {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block; z-index: 0;
}
.gol-overlay {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background:
    radial-gradient(60% 50% at 50% 50%, var(--accent-soft) 0%, rgba(108, 99, 255, 0) 70%),
    radial-gradient(120% 90% at 50% 50%, transparent 30%, rgba(14, 14, 26, 0.85) 100%);
}

/* Brand header ===== */
.brand-head {
  position: relative;
  z-index: 2;
  display: flex; align-items: center; gap: 14px;
  margin: 0 auto 24px;
  max-width: 700px;
  padding: 0;
  color: var(--text-strong);
}
.brand-head .brand-mark {
  width: 44px; height: 44px;
  border-radius: var(--radius-brand);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-brand);
  flex-shrink: 0;
  overflow: hidden;
}
.brand-head .brand-mark img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.brand-head .brand-name {
  font-size: 26px; font-weight: 600; letter-spacing: -0.02em; color: var(--text-strong);
}

/* User chip (top-right on dashboard) ===== */
.user-chip {
  position: fixed; top: 18px; right: 22px; z-index: 3;
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; color: var(--text-dim);
  background: rgba(14, 14, 26, 0.75);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-chip);
  padding: 5px 5px 5px 12px;
  backdrop-filter: var(--blur-card);
  -webkit-backdrop-filter: var(--blur-card);
}
.user-chip .avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--text-strong);
  font-size: 11px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.user-chip form { display: inline-flex; }
.user-chip .logout {
  background: transparent; border: 0; color: var(--text-muted);
  font-size: 11px; padding: 3px 9px; border-radius: var(--radius-chip);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.user-chip .logout:hover { color: var(--text-strong); background: var(--accent-soft); }

/* Page (main) ===== */
.page {
  position: relative; z-index: 2;
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 24px 80px;   /* leave room for the fixed footer */
  gap: 22px;
}

/* Card base ===== */
.card-base {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  backdrop-filter: var(--blur-card);
  -webkit-backdrop-filter: var(--blur-card);
  padding: 24px 24px;
  display: flex; flex-direction: column;
}

.cards-row {
  display: flex; align-items: stretch; gap: 18px;
  width: 100%;
  justify-content: center;
}

/* Login / OTP auth card ----- */
.lc { width: 340px; }
.lc h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 4px; color: var(--text-strong); }
.lc .sub { font-size: 12px; color: var(--text-muted); margin-bottom: 20px; }
.lc label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-faintest); font-weight: 600;
  margin-bottom: 6px; display: block;
}
.lc input {
  width: 100%; padding: 9px 11px;
  background: var(--bg-input); border: 1px solid var(--border-input);
  color: var(--text);
  border-radius: var(--radius-input);
  font-size: 13px; font-family: inherit;
  outline: none;
}
.lc input:focus { border-color: var(--accent); }
.lc input[name="code"] {
  font-family: var(--font-mono);
  letter-spacing: 0.25em;
  text-align: center;
}
.lc .grow { flex: 1; }
.lc .message {
  margin-bottom: 12px;
  padding: 8px 11px;
  border-radius: var(--radius-input);
  font-size: 12px;
  border: 1px solid var(--border-card);
}
.lc .message-info { color: var(--accent-text); background: var(--accent-faint); border-color: var(--accent-soft); }
.lc .message-error { color: var(--status-err); background: rgba(248, 113, 113, 0.08); border-color: rgba(248, 113, 113, 0.3); }
.lc button.primary {
  margin-top: 14px; width: 100%; padding: 9px;
  background: var(--accent); color: var(--text-strong);
  border: 0; border-radius: var(--radius-input);
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s;
}
.lc button.primary:hover { filter: brightness(1.1); }

/* Identity ("you appear as") card ----- */
.ipc { width: 300px; }
.ipc .ipc-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-faintest); font-weight: 600;
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
}
.ipc .ipc-label .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--status-warn);
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.5);
}
.ipc .ipc-ip {
  font-family: var(--font-mono); font-size: 18px;
  color: var(--text); font-weight: 500;
  letter-spacing: -0.02em;
  margin-bottom: 14px; word-break: break-all;
}
.ipc .ipc-rows { display: flex; flex-direction: column; gap: 7px; font-size: 12px; flex: 1; }
.ipc .ipc-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ipc .ipc-row .k { color: var(--text-faint); font-size: 11px; }
.ipc .ipc-row .v {
  color: var(--text-dim); font-family: var(--font-mono); font-size: 11px;
  text-align: right;
  display: inline-flex; align-items: center; gap: 6px;
}
.ipc .ipc-foot {
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--border-card);
  font-size: 11px; color: var(--text-muted); line-height: 1.55;
}
.ipc .ipc-foot em { color: var(--accent-text); font-style: normal; font-weight: 500; }
.ipc .attr { font-size: 10px; color: var(--text-faint); margin-top: 8px; }
.ipc .attr a { color: var(--text-faint); }
.ipc .attr a:hover { color: var(--accent-text); }

/* Flags (used inline within identity card values) ===== */
.flag {
  display: inline-block;
  width: 16px; height: 11px;
  border-radius: 1px;
  box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.15);
  background-size: cover; background-position: center;
  flex-shrink: 0;
}

/* Connections card ----- */
.cc { width: 100%; max-width: 560px; }
.cc-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-card);
  margin-bottom: 14px;
}
.cc-hdr .lbl {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-faintest); font-weight: 600;
}
.cc-hdr .count { font-family: var(--font-mono); font-size: 10px; color: var(--text-faint); }

.conn-list { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.conn {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px;
  background: var(--bg-conn);
  border: 1px solid rgba(42, 42, 74, 0.4);
  border-radius: 7px;
  transition: border-color 0.15s, background 0.15s;
}
.conn:hover { border-color: var(--border-strong); background: var(--bg-conn-hover); }
.conn .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--status-ok);
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
  flex-shrink: 0;
}
.conn .dot.dis { background: var(--status-off); box-shadow: none; }
.conn .info { flex: 1; min-width: 0; }
.conn .label {
  font-size: 13px; font-weight: 500; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.conn .meta { font-size: 10px; color: var(--text-faint); margin-top: 3px; font-family: var(--font-mono); }
.conn .meta.warn { color: var(--status-err); }
.conn.disabled .label { opacity: 0.5; }
.plugin-badge {
  font-size: 9px;
  background: #1e1e35;
  padding: 1px 6px; border-radius: 3px;
  color: #8b7cc8;
  font-family: var(--font-mono);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.dl-btn {
  background: transparent;
  border: 1px solid var(--border-input);
  color: var(--text-dim);
  font-size: 11px; padding: 5px 11px;
  border-radius: 5px;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.dl-btn:hover {
  border-color: var(--accent);
  color: var(--text-strong);
  background: var(--accent-softer);
}
.dl-btn svg { width: 12px; height: 12px; }

.empty-hint {
  margin-top: 14px; padding-top: 14px;
  border-top: 1px dashed rgba(42, 42, 74, 0.5);
  font-size: 11px; color: var(--text-faint); line-height: 1.55;
}
.empty-hint code {
  font-family: var(--font-mono);
  background: var(--accent-faint);
  color: var(--accent-text);
  padding: 1px 5px; border-radius: 3px;
  font-size: 10px;
}

/* Footer ===== */
.gol-foot {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 2;
  background: var(--bg-deep);
  border-top: 1px solid var(--border-dim);
  padding: 7px 14px;
  display: flex; align-items: center; justify-content: flex-end; gap: 14px;
  font-size: 11px; color: var(--text-faint);
}
.gol-foot .sep { width: 1px; height: 18px; background: var(--border-dim); flex-shrink: 0; }
.gol-foot .counters {
  font-family: var(--font-mono); color: var(--text-faintest); font-size: 10px;
  display: flex; gap: 14px;
}
.gol-foot .counters .k {
  color: var(--text-darkest);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-right: 4px;
}
.gol-foot .ctrls { display: flex; gap: 4px; }
.gol-foot .ctrls .icon-btn {
  background: transparent; border: 0; color: var(--text-faint);
  width: 24px; height: 24px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 3px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.gol-foot .ctrls .icon-btn:hover { color: #cfcfff; background: #161628; }
.gol-foot .ctrls .icon-btn svg { width: 14px; height: 14px; }
.gol-foot .repo {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-faint); text-decoration: none;
  font-size: 11px;
  transition: color 0.15s;
}
.gol-foot .repo:hover { color: var(--accent-text); }
.gol-foot .repo svg { width: 13px; height: 13px; }

@media (max-width: 720px) {
  .cards-row { flex-direction: column; align-items: center; }
  .lc, .ipc { width: 90%; max-width: 340px; }
  .user-chip { top: 10px; right: 12px; padding: 4px 4px 4px 10px; }
  .brand-head { margin-bottom: 16px; }
  .brand-head .brand-name { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  /* The GoL JS already short-circuits the rAF loop under reduced-motion. The
    CSS counterpart kills card hover transitions for parity. */
  .conn, .dl-btn, .user-chip .logout, .lc button.primary { transition: none; }
}
