/* ==========================================================================
   EU Transparency Tracker — design system
   Dark by default, opt-in light theme (data-theme="light" on <html>).
   ========================================================================== */

:root {
  /* Brand */
  --eu-blue: #2f6fed;
  --eu-blue-deep: #1a4fc4;
  --eu-gold: #f5c518;

  /* Dark theme (default) */
  --bg: #0d1117;
  --bg-elev: #161b22;
  --bg-elev-2: #1c232d;
  --border: #2a323d;
  --border-strong: #3a4451;
  --text: #e6edf3;
  --text-muted: #9aa7b4;
  --text-faint: #6b7681;
  --accent: var(--eu-blue);
  --accent-contrast: #ffffff;
  --link: #58a6ff;

  /* Confidence colours */
  --c-verified: #3fb950;      /* register-verified */
  --c-corroborated: #58a6ff;  /* independently-corroborated */
  --c-flagged: #f0883e;       /* discrepancy-flagged */
  --c-unverified: #8b949e;    /* unverified */

  /* Category accents */
  --cat-consultancy: #d29922;
  --cat-inhouse: #58a6ff;
  --cat-ngo: #3fb950;
  --cat-thinktank: #bc8cff;
  --cat-religious: #db61a2;
  --cat-public: #79c0ff;
  --cat-other: #8b949e;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  --maxw: 1200px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
}

html[data-theme="light"] {
  --bg: #f6f8fa;
  --bg-elev: #ffffff;
  --bg-elev-2: #f0f3f6;
  --border: #d0d7de;
  --border-strong: #b8c0c9;
  --text: #1c2128;
  --text-muted: #57606a;
  --text-faint: #8b949e;
  --link: #0969da;
  --shadow: 0 4px 20px rgba(140, 149, 159, 0.2);
  --c-unverified: #6e7781;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.4rem; }

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

/* Skip link (accessibility) */
.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 200;
  background: var(--accent); color: #fff; padding: 10px 16px; border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

/* -------------------------------------------------------------------------- */
/* Header / nav                                                               */
/* -------------------------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav {
  display: flex; align-items: center; gap: 18px;
  height: 60px; max-width: var(--maxw); margin: 0 auto; padding: 0 20px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); font-size: 1.05rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 7px; flex: none;
  background: linear-gradient(135deg, var(--eu-blue), var(--eu-blue-deep));
  display: grid; place-items: center; color: var(--eu-gold); font-weight: 800; font-size: 1rem;
}
.nav-links { display: flex; gap: 4px; margin-left: 6px; }
.nav-links a {
  color: var(--text-muted); padding: 8px 12px; border-radius: var(--radius-sm); font-size: .93rem; font-weight: 500;
}
.nav-links a:hover { color: var(--text); background: var(--bg-elev); text-decoration: none; }
.nav-links a.active { color: var(--text); background: var(--bg-elev-2); }
.nav-spacer { flex: 1; }
.nav-tools { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  background: var(--bg-elev); color: var(--text-muted); border: 1px solid var(--border);
  border-radius: var(--radius-sm); height: 36px; min-width: 36px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; font-size: .9rem; font-family: inherit;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }

select.lang-select {
  background: var(--bg-elev); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); height: 36px; padding: 0 8px; font-size: .9rem; cursor: pointer; font-family: inherit;
}

.hamburger { display: none; }

@media (max-width: 820px) {
  .nav-links {
    position: fixed; inset: 60px 0 auto 0; flex-direction: column; gap: 0;
    background: var(--bg-elev); border-bottom: 1px solid var(--border);
    padding: 8px; transform: translateY(-120%); transition: transform .22s ease; box-shadow: var(--shadow);
  }
  .nav-links.open { transform: translateY(0); }
  .nav-links a { padding: 12px; border-radius: 0; }
  .hamburger { display: inline-flex; }
}

/* -------------------------------------------------------------------------- */
/* Buttons, inputs                                                            */
/* -------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-family: inherit;
  background: var(--accent); color: var(--accent-contrast); border: 1px solid transparent;
  padding: 9px 16px; border-radius: var(--radius-sm); font-size: .92rem; font-weight: 600;
}
.btn:hover { background: var(--eu-blue-deep); text-decoration: none; }
.btn.secondary { background: var(--bg-elev); color: var(--text); border-color: var(--border); }
.btn.secondary:hover { border-color: var(--border-strong); background: var(--bg-elev-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

input, select, textarea {
  background: var(--bg-elev); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 11px; font-size: .95rem; font-family: inherit; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
label { display: block; font-size: .82rem; color: var(--text-muted); margin-bottom: 5px; font-weight: 600; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* -------------------------------------------------------------------------- */
/* Cards, grid, badges                                                        */
/* -------------------------------------------------------------------------- */
.card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px;
}
.grid { display: grid; gap: 16px; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.stat-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

.reg-card { display: flex; flex-direction: column; gap: 10px; transition: border-color .15s, transform .15s; }
.reg-card:hover { border-color: var(--border-strong); transform: translateY(-2px); text-decoration: none; }
.reg-card .rc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.reg-card h3 { font-size: 1.05rem; margin: 0; color: var(--text); }
.reg-card .rc-acronym { color: var(--text-faint); font-size: .82rem; }
.reg-card .rc-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: .72rem; font-weight: 600;
  padding: 3px 9px; border-radius: 100px; border: 1px solid var(--border); color: var(--text-muted);
  background: var(--bg-elev-2); white-space: nowrap;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: .82rem;
  padding: 5px 11px; border-radius: 100px; border: 1px solid var(--border);
  background: var(--bg-elev); color: var(--text-muted); cursor: pointer; user-select: none;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { background: var(--accent); color: #fff; border-color: transparent; }

/* Confidence indicator */
.conf { color: var(--c-unverified); }
.conf[data-c="register-verified"] { color: var(--c-verified); }
.conf[data-c="independently-corroborated"] { color: var(--c-corroborated); }
.conf[data-c="discrepancy-flagged"] { color: var(--c-flagged); }

/* Category left-accent */
.cat-consultancy_law_firm { --cat: var(--cat-consultancy); }
.cat-in_house_trade { --cat: var(--cat-inhouse); }
.cat-ngo { --cat: var(--cat-ngo); }
.cat-think_tank_academic { --cat: var(--cat-thinktank); }
.cat-religious { --cat: var(--cat-religious); }
.cat-public_authority { --cat: var(--cat-public); }
.cat-other, .cat- { --cat: var(--cat-other); }
.reg-card { border-left: 3px solid var(--cat, var(--border)); }

/* -------------------------------------------------------------------------- */
/* Layout helpers                                                              */
/* -------------------------------------------------------------------------- */
main { flex: 1; padding: 28px 0 60px; }
.page-head { margin-bottom: 22px; }
.page-head p.lede { color: var(--text-muted); max-width: 70ch; margin: 6px 0 0; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mono { font-family: var(--mono); font-size: .85em; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.divider { height: 1px; background: var(--border); border: 0; margin: 24px 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* Filters bar */
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 12px; margin-bottom: 20px; }
@media (max-width: 720px) { .filters { grid-template-columns: 1fr 1fr; } }

/* Stats */
.stat { text-align: center; padding: 20px 14px; }
.stat .num { font-size: 2rem; font-weight: 800; color: var(--text); line-height: 1; }
.stat .lbl { color: var(--text-muted); font-size: .82rem; margin-top: 6px; }

.bar-row { display: grid; grid-template-columns: 200px 1fr auto; gap: 12px; align-items: center; margin-bottom: 8px; font-size: .9rem; }
.bar-track { background: var(--bg-elev-2); border-radius: 100px; height: 12px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--eu-blue), var(--eu-blue-deep)); border-radius: 100px; }
@media (max-width: 640px) { .bar-row { grid-template-columns: 120px 1fr auto; } }

/* Profile */
.profile-head { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.profile-head .ph-main { flex: 1; min-width: 260px; }
.profile-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; margin-top: 24px; }
@media (max-width: 900px) { .profile-grid { grid-template-columns: 1fr; } }
.section { margin-bottom: 28px; }
.section > h2 { font-size: 1.15rem; padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }

.timeline { border-left: 2px solid var(--border); padding-left: 18px; display: flex; flex-direction: column; gap: 16px; }
.timeline .tl-item { position: relative; }
.timeline .tl-item::before {
  content: ""; position: absolute; left: -25px; top: 5px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--accent); border: 2px solid var(--bg);
}
.timeline .tl-date { font-size: .78rem; color: var(--text-faint); font-family: var(--mono); }

.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; font-size: .92rem; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; }

table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
table.data th { color: var(--text-muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.table-wrap { overflow-x: auto; }

/* States */
.loading, .empty { text-align: center; color: var(--text-muted); padding: 50px 20px; }
.spinner {
  width: 34px; height: 34px; border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--bg-elev) 25%, var(--bg-elev-2) 50%, var(--bg-elev) 75%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { to { background-position: -200% 0; } }

.notice { padding: 12px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg-elev); font-size: .9rem; }
.notice.warn { border-color: var(--c-flagged); color: var(--c-flagged); background: color-mix(in srgb, var(--c-flagged) 10%, var(--bg-elev)); }
.notice.error { border-color: #f85149; color: #ff7b72; background: color-mix(in srgb, #f85149 10%, var(--bg-elev)); }
.notice.ok { border-color: var(--c-verified); color: var(--c-verified); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border); color: var(--text-muted); font-size: .85rem;
  padding: 26px 0; margin-top: auto;
}
.site-footer .container { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* Network graph */
#graph { width: 100%; height: 72vh; min-height: 480px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); }
#graph svg { display: block; width: 100%; height: 100%; cursor: grab; }
.node-label { font-size: 10px; fill: var(--text-muted); pointer-events: none; }
.link { stroke: var(--border-strong); stroke-opacity: .7; }
.node circle { cursor: pointer; stroke: var(--bg); stroke-width: 1.5px; }
.graph-tooltip {
  position: absolute; pointer-events: none; background: var(--bg-elev-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 8px 11px; font-size: .82rem; max-width: 260px; box-shadow: var(--shadow);
  opacity: 0; transition: opacity .12s; z-index: 50;
}
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .82rem; color: var(--text-muted); }
.legend .li { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 12px; height: 12px; border-radius: 50%; }

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