/* Calgary Permit Mailer — design system */
:root {
  /* Editorial neutral palette — paper, graphite, mineral */
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #fbfaf7;
  --surface-3: #efece6;
  --line: #e5e2dc;
  --line-2: #d6d2c8;
  --ink: #18181b;
  --ink-2: #2e2d2a;
  --muted: #6b6a64;
  --muted-2: #9a9890;

  /* Single accent: deep indigo (trustworthy, not "techy") */
  --primary: #2c3e7b;
  --primary-hover: #20305e;
  --primary-soft: #eef1f8;
  --primary-line: #c7cfe1;

  /* Semantic — desaturated */
  --good: #2f7d5b;
  --good-soft: #e9f3ee;
  --warn: #a26200;
  --warn-soft: #f6efe1;
  --info: #355a8a;
  --info-soft: #e8eef6;
  --danger: #a23b2a;
  --danger-soft: #f5e8e4;

  --r: 8px;
  --r-sm: 6px;
  --r-lg: 12px;

  --shadow-1: 0 1px 0 rgba(24,24,27,0.04), 0 1px 2px rgba(24,24,27,0.04);
  --shadow-2: 0 1px 2px rgba(24,24,27,0.04), 0 6px 18px rgba(24,24,27,0.06);
  --shadow-3: 0 12px 32px rgba(24,24,27,0.10), 0 4px 12px rgba(24,24,27,0.06);

  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Source Serif 4", "Source Serif Pro", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.hidden { display: none !important; }

/* ============ Top bar ============ */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 12px; }
.brand-name {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.brand-sub {
  font-size: 12px; color: var(--muted);
  padding-left: 12px;
  border-left: 1px solid var(--line);
}
.topbar-spacer { flex: 1; }
.topbar-meta {
  display: flex; align-items: center; gap: 18px;
  font-size: 12.5px; color: var(--muted);
}
.feed-status { display: inline-flex; align-items: center; gap: 7px; }
.feed-status .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 3px var(--good-soft);
}
.feed-status[data-state="loading"] .dot {
  background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft);
  animation: pulse 1.4s ease-in-out infinite;
}
.feed-status[data-state="error"] .dot {
  background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft);
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.clock {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px; color: var(--ink-2);
}

/* ============ Layout ============ */
.shell {
  max-width: 1480px; margin: 0 auto;
  padding: 28px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 28px;
  align-items: start;
}
@media (max-width: 1080px) {
  .shell { grid-template-columns: 1fr; padding: 20px; gap: 20px; }
}

/* ============ Page intro ============ */
.intro { margin-bottom: 22px; }
.intro h1 {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
  color: var(--ink);
}
.intro p {
  margin: 0; max-width: 62ch;
  color: var(--muted); font-size: 14px;
}

/* ============ Card primitive ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.card-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.card-meta {
  font-size: 12px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.card-meta strong { color: var(--ink-2); font-weight: 600; }

/* ============ Toolbar ============ */
.toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.search { position: relative; flex: 1 1 220px; min-width: 200px; }
.search input {
  width: 100%; height: 34px;
  padding: 0 12px 0 34px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  font-size: 13px; color: var(--ink);
  transition: border-color .12s, box-shadow .12s;
}
.search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.search input::placeholder { color: var(--muted-2); }
.search svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 13px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: var(--r);
  font-size: 13px; font-weight: 500;
  transition: background .12s, border-color .12s, color .12s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: var(--line-2); color: var(--ink); }
.btn:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.btn[aria-pressed="true"] {
  background: var(--ink); color: white; border-color: var(--ink);
}
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn .count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--surface-3); color: var(--muted);
  border-radius: 999px; font-size: 11px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.btn[aria-pressed="true"] .count { background: rgba(255,255,255,0.18); color: white; }

.btn-primary {
  background: var(--primary); color: white;
  border-color: var(--primary);
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: white;
}
.btn-primary:disabled {
  background: var(--surface-3); color: var(--muted-2);
  border-color: var(--line); cursor: not-allowed;
}
.btn-danger {
  background: var(--danger); color: white;
  border-color: var(--danger);
  font-weight: 600;
}
.btn-danger:hover:not(:disabled) {
  background: #8c2f20; border-color: #8c2f20;
}

.toolbar-spacer { flex: 1; }
.toolbar-meta {
  font-size: 12.5px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.toolbar-meta strong { color: var(--ink); font-weight: 600; }
