/* Somali Capability Atlas — Step 1 styles.
   Design direction: modern, serious, scientific, Somali/African,
   trustworthy, clean, mobile-first, accessible.
   Palette: deep blue, earth/sand, white, limited green accents. */

:root {
  --primary: #1F3B57;      /* deep blue */
  --primary-ink: #F7F5F0;
  --accent: #C8A96A;       /* earth / sand */
  --accent-soft: #EDE3CE;
  --green: #3E7A5E;        /* limited green accent */
  --bg: #F7F5F0;
  --surface: #FFFFFF;
  --ink: #22303C;
  --muted: #5C6B77;
  --line: #E3DDD2;
  --danger: #A03A3A;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(34, 48, 60, 0.10);
  --focus: 2px solid #1F3B57;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.55;
  font-size: 16px;
}

a { color: var(--primary); }
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
  outline: var(--focus);
  outline-offset: 2px;
}

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--primary); color: var(--primary-ink);
  padding: 8px 14px; z-index: 100; border-radius: 0 0 6px 0;
}
.skip-link:focus { left: 0; }

.boot { color: var(--muted); padding: 48px 24px; text-align: center; }
.noscript-warning { padding: 24px; text-align: center; color: var(--danger); }

/* ---------- Layout ---------- */
.site-main { min-height: 70vh; }
.page-content {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}
.page-content.narrow { max-width: 560px; }

/* ---------- Navigation ---------- */
.site-nav {
  background: var(--primary);
  color: var(--primary-ink);
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow);
}
.nav-inner {
  max-width: 1080px; margin: 0 auto;
  display: flex; flex-wrap: wrap; align-items: center;
  padding: 10px 16px; gap: 8px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand-mark {
  background: var(--accent); color: var(--primary);
  font-weight: 700; border-radius: 8px;
  padding: 4px 8px; font-size: 13px; letter-spacing: 0.5px;
}
.brand-name { font-weight: 600; font-size: 15px; }
.nav-toggle {
  margin-left: auto; background: none; color: inherit;
  border: 1px solid rgba(247, 245, 240, 0.4); border-radius: 6px;
  padding: 6px 12px; font-size: 14px; cursor: pointer;
}
.nav-links {
  display: none; width: 100%;
  flex-direction: column; gap: 2px; padding: 8px 0 12px;
}
.nav-links.open { display: flex; }
.nav-link {
  color: var(--primary-ink); text-decoration: none;
  padding: 8px 10px; border-radius: 6px; font-size: 15px;
}
.nav-link:hover { background: rgba(247, 245, 240, 0.12); }
.nav-link.active { background: var(--accent); color: var(--primary); font-weight: 600; }
.nav-auth { display: flex; align-items: center; gap: 8px; padding: 8px 0 12px; width: 100%; flex-wrap: wrap; }
.nav-user { color: var(--accent); text-decoration: none; font-weight: 600; }

@media (min-width: 880px) {
  .nav-toggle { display: none; }
  .nav-links {
    display: flex; flex-direction: row; width: auto;
    gap: 2px; padding: 0; flex-wrap: wrap;
  }
  .nav-auth { width: auto; margin-left: auto; padding: 0; }
}

/* ---------- Hero ---------- */
.hero { padding: 32px 0 8px; }
.hero-title {
  font-size: clamp(26px, 5vw, 40px);
  line-height: 1.15; margin: 0 0 12px; color: var(--primary);
}
.hero-sub { font-size: clamp(15px, 2.5vw, 18px); color: var(--muted); margin: 0 0 20px; max-width: 640px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.hero-explain { color: var(--muted); max-width: 640px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block; border: none; cursor: pointer;
  border-radius: 8px; padding: 10px 16px;
  font-size: 15px; font-weight: 600; text-decoration: none;
  transition: background-color 0.15s ease;
}
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: #2A4D70; }
.btn-secondary { background: var(--accent-soft); color: var(--primary); }
.btn-secondary:hover { background: var(--accent); }
.btn-ghost { background: transparent; color: var(--primary-ink); border: 1px solid rgba(247,245,240,0.4); }
.btn-ghost:hover { background: rgba(247,245,240,0.12); }
.btn-danger { background: var(--danger); color: #fff; }
.link { color: var(--primary); }

/* ---------- Page header ---------- */
.page-header { margin-bottom: 20px; }
.page-header h1 { color: var(--primary); font-size: clamp(22px, 4vw, 30px); margin: 0 0 6px; }
.page-subtitle { color: var(--muted); margin: 0 0 12px; }

/* ---------- Stats ---------- */
.stat-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin: 24px 0;
}
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.stat-value { font-size: 24px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ---------- Philosophy strip ---------- */
.philosophy-strip {
  border-left: 4px solid var(--accent);
  background: var(--surface); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.philosophy-main { font-size: 18px; font-weight: 600; color: var(--primary); margin: 0 0 6px; }

/* ---------- Cards ---------- */
.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.card h3 { margin: 8px 0 6px; color: var(--primary); font-size: 17px; }
.card p { margin: 6px 0; font-size: 14px; color: var(--muted); }
.card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card-top h3 { margin: 0; }
.cap-code { font-size: 12px; color: var(--muted); white-space: nowrap; }
.card-meta { font-size: 13px; color: var(--muted); }
.card-count { font-size: 12px; color: var(--muted); }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; font-size: 12px; padding: 3px 8px;
  border-radius: 999px; margin: 2px 4px 2px 0;
}
.badge-muted { background: var(--accent-soft); color: var(--primary); }
.badge-accent { background: var(--accent); color: var(--primary); font-weight: 600; }
.badge-row { margin: 8px 0; }

/* ---------- Filters ---------- */
.filter-bar {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.filter { display: flex; flex-direction: column; gap: 4px; }
.filter-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
select, input, textarea {
  font: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 9px 10px; background: #fff; width: 100%;
}
textarea { resize: vertical; }
.result-count { color: var(--muted); font-size: 14px; }

/* ---------- Empty states ---------- */
.empty-state {
  text-align: center; padding: 48px 20px;
  background: var(--surface); border: 1px dashed var(--line);
  border-radius: var(--radius); color: var(--muted);
}
.empty-state h2 { color: var(--primary); font-size: 18px; margin: 12px 0 8px; }
.empty-state p { max-width: 460px; margin: 0 auto; }
.empty-icon {
  width: 44px; height: 44px; margin: 0 auto;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: var(--accent-soft);
}

/* ---------- Field rows (definition lists) ---------- */
.field-row {
  display: flex; gap: 12px; padding: 7px 0;
  border-bottom: 1px solid var(--line); margin: 0;
}
.field-row dt { flex: 0 0 40%; font-size: 13px; color: var(--muted); margin: 0; }
.field-row dd { margin: 0; font-size: 14px; }
.field-blank dd { color: var(--muted); font-style: italic; }

/* ---------- Forms ---------- */
.form-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px; margin-bottom: 20px;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.error-list { color: var(--danger); font-size: 14px; margin: 0; padding-left: 18px; }
.msg-ok { color: var(--green); font-weight: 600; margin: 8px 0; }
.msg-error { color: var(--danger); font-weight: 600; margin: 8px 0; }
.feedback { min-height: 0; }
.token-display {
  font-family: ui-monospace, monospace; font-size: 13px;
  background: var(--accent-soft); border-radius: 6px; padding: 10px;
  overflow-wrap: anywhere;
}
.hidden { display: none; }
.read-only-block { margin-bottom: 20px; }

/* ---------- Export rows ---------- */
.export-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.export-name { flex: 1 1 160px; font-weight: 600; }
.export-row .btn { padding: 7px 12px; font-size: 13px; }

/* ---------- About tables & lists ---------- */
.about-block { margin: 28px 0; }
.about-block h3 { color: var(--primary); margin: 20px 0 8px; }
.enum-table {
  border-collapse: collapse; width: 100%; max-width: 560px;
  background: var(--surface); font-size: 14px;
  border: 1px solid var(--line); border-radius: var(--radius);
}
.enum-table th, .enum-table td {
  text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line);
}
.enum-table th { color: var(--muted); font-weight: 600; white-space: nowrap; }
.principles { padding-left: 18px; }
.principles li { margin: 6px 0; font-weight: 500; }
.role-list { padding-left: 18px; font-size: 14px; }
.role-list li { margin: 6px 0; }

/* ---------- Footer ---------- */
.site-footer { background: var(--primary); color: var(--primary-ink); margin-top: 40px; }
.footer-inner { max-width: 1080px; margin: 0 auto; padding: 28px 20px; }
.footer-philosophy { font-size: 17px; font-weight: 600; margin: 0 0 8px; color: var(--accent); }
.footer-meta { font-size: 13px; margin: 0 0 8px; opacity: 0.85; }
.footer-links a { color: var(--primary-ink); }
.footer-links { font-size: 13px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---- Capability detail page (Stage 2) ---- */
.detail-section { margin: 24px 0; padding-top: 16px; border-top: 1px solid var(--border); }
.detail-section h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); margin: 0 0 10px; }
.detail-row { display: flex; gap: 12px; margin: 6px 0; }
.detail-label { flex: 0 0 180px; color: var(--muted); font-size: 14px; }
.detail-list { margin: 6px 0; padding-left: 20px; }
.notice { background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: 8px; padding: 12px 16px; }
.notice p { margin: 6px 0; }
.btn-small { padding: 4px 10px; font-size: 13px; }
.filter-wide { flex: 1 1 220px; }

/* Stage 6: capability x location matrix (wider than enum tables). */
.census-matrix { max-width: 100%; }
.census-matrix td, .census-matrix th { white-space: normal; }
