/* PRISMA DESIGN TOKENS
   Ported from .scratch/prisma-v1/design/tokens.css (issue 39).
   Issue 29 builds the full UI kit on top of this file — extend it here,
   don't duplicate it. Tokens only + the shared kit-candidate atoms.
   Dark mode: the layout's head script sets html[data-theme] from the
   stored choice or prefers-color-scheme (ADR 0001). */
:root {
  color-scheme: light;

  --font-sans: "Hanken Grotesk", -apple-system, blinkmacsystemfont, "Segoe UI", roboto, sans-serif;
  --font-serif: "Fraunces", "Iowan Old Style", "New York", georgia, serif;
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;
  --text-3xl: 2.5rem;
  --weight-medium: 530;
  --weight-bold: 680;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 999px;
  --shadow-sm: 0 1px 2px rgb(16 14 30 / 5%);
  --shadow-md: 0 4px 16px rgb(16 14 30 / 7%);
  --shadow-pop: 0 12px 32px rgb(16 14 30 / 18%);
  --prism: linear-gradient(120deg, #4f46e5 0%, #8b5cf6 45%, #ec4899 100%);
  --prism-soft: linear-gradient(120deg, rgb(79 70 229 / 10%), rgb(139 92 246 / 10%), rgb(236 72 153 / 10%));
  --accent: #6d5ae8;
  --accent-ink: #fff;
  --bg: #f7f6fb;
  --surface: #fff;
  --surface-2: #f1effa;
  --ink: #1b1830;
  --ink-muted: #6b6786;
  --ink-faint: #9b97b2;
  --border: #e7e4f2;
  --border-strong: #d5d1e6;
  --state-draft: #8d89a3;
  --state-draft-bg: #efedf6;
  --state-pending: #b07c10;
  --state-pending-bg: #fdf3dd;
  --state-approved: #0e8a6c;
  --state-approved-bg: #def5ee;
  --state-scheduled: #3b5bdb;
  --state-scheduled-bg: #e4eafd;
  --state-publishing: #7c3aed;
  --state-publishing-bg: #efe7fd;
  --state-published: #15803d;
  --state-published-bg: #e0f3e5;
  --state-failed: #d92638;
  --state-failed-bg: #fde6e8;
  --state-active: var(--state-published);
  --state-active-bg: var(--state-published-bg);
  --state-paused: var(--state-draft);
  --state-paused-bg: var(--state-draft-bg);
  --state-connected: var(--state-published);
  --state-expiring: var(--state-pending);
  --state-broken: var(--state-failed);
  --ok: var(--state-published);
  --warn: var(--state-pending);
  --danger: var(--state-failed);
}

[data-theme="dark"] {
  color-scheme: dark;

  --accent: #8f7df2;
  --bg: #131120;
  --surface: #1c1930;
  --surface-2: #262240;
  --ink: #edebf7;
  --ink-muted: #a5a1c0;
  --ink-faint: #6f6b8d;
  --border: #2e2a4a;
  --border-strong: #3d3860;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 40%);
  --shadow-md: 0 4px 16px rgb(0 0 0 / 45%);
  --shadow-pop: 0 12px 32px rgb(0 0 0 / 60%);
  --state-draft: #9c98b5;
  --state-draft-bg: #2a2741;
  --state-pending: #e3b341;
  --state-pending-bg: #37301c;
  --state-approved: #34d39b;
  --state-approved-bg: #15342b;
  --state-scheduled: #7e9bff;
  --state-scheduled-bg: #20284a;
  --state-publishing: #b18aff;
  --state-publishing-bg: #2d2347;
  --state-published: #4ade80;
  --state-published-bg: #173326;
  --state-failed: #ff6b7a;
  --state-failed-bg: #3d1d24;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }

h1,
h2,
h3,
p { margin: 0; }

/* ---- shared atoms (UI-kit candidates) ---- */
.btn-prism {
  background: var(--prism);
  color: var(--accent-ink);
  border: 0;
  border-radius: var(--radius-full);
  padding: 10px 20px;
  font-weight: var(--weight-bold);
  font-size: var(--text-base);
  box-shadow: var(--shadow-md);
  transition: transform 0.12s, box-shadow 0.12s;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  white-space: nowrap;
}

.btn-prism:hover { transform: translateY(-1px); box-shadow: var(--shadow-pop); }

.btn-quiet {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 8px 16px;
  font-weight: var(--weight-medium);
  white-space: nowrap;
}

.btn-quiet:hover { border-color: var(--border-strong); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.btn-ink { background: var(--ink); color: var(--bg); border: 0; }
.btn-ink:hover { opacity: 0.85; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.state-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  text-transform: capitalize;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.state-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentcolor; }
.state-draft { color: var(--state-draft); background: var(--state-draft-bg); }
.state-pending { color: var(--state-pending); background: var(--state-pending-bg); }
.state-approved { color: var(--state-approved); background: var(--state-approved-bg); }
.state-scheduled { color: var(--state-scheduled); background: var(--state-scheduled-bg); }
.state-publishing { color: var(--state-publishing); background: var(--state-publishing-bg); }
.state-published { color: var(--state-published); background: var(--state-published-bg); }
.state-failed { color: var(--state-failed); background: var(--state-failed-bg); }
.state-active { color: var(--state-active); background: var(--state-active-bg); }
.state-paused { color: var(--state-paused); background: var(--state-paused-bg); }

.net {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: var(--weight-bold);
  background: var(--surface-2);
  color: var(--ink-muted);
  border: 1px solid var(--border);
}

.prism-text {
  background: var(--prism);

  /* unprefixed background-clip: text needs Chrome 120+, which is exactly
     the allow_browser :modern baseline — no -webkit- prefix required */
  background-clip: text;
  color: transparent;
}

.checkdot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex: none;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  border: 1.5px solid var(--border-strong);
  color: transparent;
}

.checkdot.done { background: var(--prism); border: 0; color: #fff; }

.avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  flex: none;
  display: inline-grid;
  place-items: center;
  font-size: 11px;
  font-weight: var(--weight-bold);
  color: #fff;
}

.input,
.textarea,
select.input {
  width: 100%;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font: inherit;
  outline: none;
}

.input:focus,
.textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.textarea { resize: vertical; min-height: 120px; line-height: 1.6; }
.field { display: block; margin-bottom: var(--space-4); }

.field > span {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--ink-muted);
  margin-bottom: var(--space-2);
}

.ptable { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }

.ptable th {
  text-align: left;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  font-weight: var(--weight-bold);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.ptable td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
.ptable tr:last-child td { border-bottom: 0; }

.toggle {
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--border-strong);
  border: 0;
  position: relative;
  flex: none;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: left 0.15s;
}

.toggle.on { background: var(--prism); }
.toggle.on::after { left: 19px; }
.meter { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--prism); border-radius: 999px; }

.sec-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 var(--space-3);
}

.kicker {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.health-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.health-dot.connected { background: var(--ok); }
.health-dot.expiring { background: var(--warn); }
.health-dot.broken { background: var(--danger); }
.thumb { border-radius: var(--radius-md); border: 1px solid var(--border); position: relative; overflow: hidden; }
.thumb i { position: absolute; inset: 0; opacity: 0.85; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
