/* ==========================================================================
   Vatnik Prize — design system
   Dark by default; [data-theme="light"] overrides for opt-in light mode.
   ========================================================================== */

:root {
  --bg: #0a0c0f;
  --bg-elevated: #12151b;
  --bg-card: #161a21;
  --bg-hover: #1c212a;
  --border: #262c36;
  --border-strong: #343c49;
  --text: #e7e9ec;
  --text-dim: #9aa4b2;
  --text-faint: #6b7684;
  --accent: #2dd4e8;
  --accent-strong: #67e8f9;
  --accent-text: #04262b;
  --danger: #f0555a;
  --warning: #f0a94e;
  --success: #4ade80;
  --conf-verified: #4ade80;
  --conf-high: #f0a94e;
  --conf-medium: #e8d24e;
  --conf-suspected: #8a94a3;
  --kremlin: #f0555a;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --radius: 10px;
  --radius-sm: 6px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Consolas, monospace;
  --max-width: 1180px;
}

:root[data-theme="light"] {
  --bg: #f6f7f8;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #eef0f2;
  --border: #e1e4e9;
  --border-strong: #cbd0d8;
  --text: #14171c;
  --text-dim: #4b5563;
  --text-faint: #6b7280;
  --accent: #0891b2;
  --accent-strong: #0e7490;
  --accent-text: #ffffff;
  --danger: #dc2626;
  --warning: #c2740a;
  --success: #16a34a;
  --conf-verified: #16a34a;
  --conf-high: #c2740a;
  --conf-medium: #a16207;
  --conf-suspected: #64748b;
  --kremlin: #dc2626;
  --shadow: 0 4px 16px rgba(20, 23, 28, 0.08);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
:root[data-theme="light"] html,
html:has([data-theme="light"]) { color-scheme: light; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-text);
  padding: 8px 16px;
  z-index: 100;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

h1, h2, h3 { font-weight: 600; line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: 1.65rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1em; color: var(--text-dim); }
.muted { color: var(--text-faint); font-size: 0.85rem; }
code, .mono { font-family: var(--font-mono); }

/* ---------- header ---------- */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 62px;
}
.brand {
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 1.05rem;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand-accent { color: var(--accent); }
.nav-menu {
  display: flex;
  gap: 4px;
  margin-left: 12px;
  flex: 1;
}
.nav-menu a {
  color: var(--text-dim);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
}
.nav-menu a:hover { color: var(--text); background: var(--bg-hover); text-decoration: none; }
.nav-menu a.active { color: var(--text); background: var(--bg-hover); }
.header-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.nav-toggle { display: none; }

.lang-select {
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  height: 36px;
}

@media (max-width: 720px) {
  .nav-toggle { display: flex; }
  .nav-menu {
    display: none;
    position: absolute;
    top: 62px;
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 8px;
  }
  .nav-menu.open { display: flex; }
}

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 48px;
  padding: 24px 0 40px;
  color: var(--text-faint);
  font-size: 0.85rem;
}

/* ---------- buttons / inputs ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}
.btn:hover { background: var(--bg-hover); }
.btn-ghost { background: transparent; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-strong); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

input[type="search"], input[type="text"], select {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
}
input[type="search"]:focus, input[type="text"]:focus, select:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
label { font-size: 0.75rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; }

/* ---------- badges ---------- */
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-role {
  background: var(--bg-hover);
  color: var(--text-dim);
  border-color: var(--border-strong);
  font-weight: 500;
  text-transform: capitalize;
}
.conf-verified { background: rgba(74, 222, 128, 0.12); color: var(--conf-verified); border-color: rgba(74, 222, 128, 0.35); }
.conf-high { background: rgba(240, 169, 78, 0.12); color: var(--conf-high); border-color: rgba(240, 169, 78, 0.35); }
.conf-medium { background: rgba(232, 210, 78, 0.12); color: var(--conf-medium); border-color: rgba(232, 210, 78, 0.35); }
.conf-suspected { background: rgba(138, 148, 163, 0.15); color: var(--conf-suspected); border-color: rgba(138, 148, 163, 0.35); }
.badge-kremlin { background: rgba(240, 85, 90, 0.12); color: var(--kremlin); border-color: rgba(240, 85, 90, 0.35); }

/* ---------- stats strip ---------- */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 24px 0;
}
.stat-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-tile .value { font-size: 1.5rem; font-weight: 700; font-family: var(--font-mono); }
.stat-tile .label { font-size: 0.75rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.03em; }

/* ---------- search / filters ---------- */
.search-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.search-panel input[type="search"] { width: 100%; margin-bottom: 12px; }
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-end;
}
.filter-group { display: flex; flex-direction: column; gap: 6px; }
.filter-label { font-size: 0.75rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; }
.filter-checks { display: flex; gap: 10px; flex-wrap: wrap; }
.filter-checks label {
  display: flex;
  align-items: center;
  gap: 5px;
  text-transform: none;
  font-size: 0.85rem;
  color: var(--text-dim);
  cursor: pointer;
}
.filter-actions { flex-direction: row; gap: 8px; margin-left: auto; }

.results-meta { color: var(--text-faint); font-size: 0.85rem; margin: 8px 0 16px; }

/* ---------- profile grid / cards ---------- */
.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s;
}
.profile-card:hover { border-color: var(--border-strong); }
.card-top { display: flex; gap: 12px; align-items: center; }
.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-hover);
  border: 1px solid var(--border-strong);
  object-fit: cover;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--text-faint);
}
.card-name { font-weight: 600; font-size: 1rem; color: var(--text); }
.card-name a { color: inherit; }
.card-name a:hover { color: var(--accent); }
.card-aliases { font-size: 0.78rem; color: var(--text-faint); }
.card-bio { font-size: 0.85rem; color: var(--text-dim); flex: 1; }
.card-badges { display: flex; flex-wrap: wrap; gap: 6px; }

.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-card { height: 150px; border-radius: var(--radius); }

.empty-state, .error-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-faint);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  grid-column: 1 / -1;
}
.error-state { color: var(--danger); border-color: rgba(240, 85, 90, 0.35); }

.pagination { display: flex; justify-content: center; gap: 8px; margin: 28px 0; }
.pagination button.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* ---------- profile page ---------- */
.back-link { display: inline-block; margin: 20px 0; font-size: 0.85rem; color: var(--text-dim); }
.profile-header {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.avatar-lg {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--bg-hover);
  border: 1px solid var(--border-strong);
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-faint);
  flex-shrink: 0;
}
.profile-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.fact-label { font-size: 0.72rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.03em; }
.fact-value { font-size: 0.9rem; color: var(--text); }

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.panel-wide { grid-column: 1 / -1; }

table.data-table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
table.data-table th, table.data-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
table.data-table th { color: var(--text-faint); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; }

.social-links { display: flex; flex-wrap: wrap; gap: 8px; }
.social-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 0.82rem;
  color: var(--text);
}

.narrative-item, .source-item, .activity-item {
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}
.narrative-item:last-child, .source-item:last-child, .activity-item:last-child { border-bottom: none; }
.item-title { font-weight: 600; font-size: 0.92rem; }
.item-meta { font-size: 0.75rem; color: var(--text-faint); margin: 2px 0 6px; }
.item-quote {
  border-left: 2px solid var(--accent);
  padding-left: 12px;
  font-style: italic;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.connections-list { display: flex; flex-direction: column; gap: 8px; }
.connection-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* ---------- network page ---------- */
.network-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 20px 0;
  flex-wrap: wrap;
}
.network-canvas {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: 70vh;
  min-height: 420px;
  position: relative;
  overflow: hidden;
}
.network-canvas svg { width: 100%; height: 100%; cursor: grab; }
.network-canvas svg:active { cursor: grabbing; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.8rem; color: var(--text-dim); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.network-panel {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 260px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.network-panel.hidden { display: none; }
.network-panel h3 { margin-bottom: 4px; }
.network-panel .close-panel { position: absolute; top: 8px; right: 10px; background: none; border: none; color: var(--text-faint); cursor: pointer; font-size: 1rem; }
.node-label { font-size: 10px; fill: var(--text-dim); pointer-events: none; }
.node-tooltip { font-size: 0.75rem; }

/* ---------- stats page ---------- */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 20px 0 28px;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 0.85rem; }
.bar-row .bar-label { width: 130px; flex-shrink: 0; color: var(--text-dim); }
.bar-track { flex: 1; background: var(--bg-hover); border-radius: 4px; height: 10px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--accent); }
.conf-verified-fill { background: var(--conf-verified); }
.conf-high-fill { background: var(--conf-high); }
.conf-medium-fill { background: var(--conf-medium); }
.conf-suspected-fill { background: var(--conf-suspected); }
.bar-row .bar-count { width: 40px; text-align: right; color: var(--text-faint); font-family: var(--font-mono); font-size: 0.8rem; }

.ranked-list { list-style: none; margin: 0; padding: 0; }
.ranked-list li {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.ranked-list li:last-child { border-bottom: none; }
.ranked-list .rank { color: var(--text-faint); font-family: var(--font-mono); margin-right: 8px; }
.ranked-list .count { color: var(--text-faint); font-family: var(--font-mono); }

@media (max-width: 640px) {
  h1 { font-size: 1.35rem; }
  .profile-header { padding: 16px; }
  .filter-actions { margin-left: 0; }
}

/* ---------- RTL (Arabic) ---------- */
[dir="rtl"] .skip-link { left: auto; right: -9999px; }
[dir="rtl"] .skip-link:focus { right: 0; }
[dir="rtl"] .nav-menu { margin-left: 0; margin-right: 12px; }
[dir="rtl"] .filter-actions { margin-left: 0; margin-right: auto; }
[dir="rtl"] .item-quote { border-left: none; border-right: 2px solid var(--accent); padding-left: 0; padding-right: 12px; }
[dir="rtl"] .legend-dot { margin-right: 0; margin-left: 5px; }
[dir="rtl"] .network-panel { right: auto; left: 16px; }
[dir="rtl"] .network-panel .close-panel { right: auto; left: 10px; }
[dir="rtl"] .bar-row .bar-count { text-align: left; }
[dir="rtl"] .ranked-list .rank { margin-right: 0; margin-left: 8px; }

@media (max-width: 640px) {
  [dir="rtl"] .filter-actions { margin-right: 0; }
}
