/* ratemygov — self-contained stylesheet. No external CDNs or fonts.
   Clean civic / government feel, mobile-first. */

:root {
  --ink: #1a1f2b;
  --ink-soft: #4a5568;
  --muted: #6b7280;
  --line: #d7dce5;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --gov: #1b3a6b;       /* deep institutional blue */
  --gov-dark: #142c52;
  --accent: #b3122f;    /* civic red */
  --ok: #1f7a4d;

  /* type badge colours */
  --t-pm: #5b2c83;
  --t-premier: #1f6f3c;   /* provincial green (BC) — distinct second root */
  --t-minister: #1b3a6b;
  --t-department: #0f6e6e;
  --t-unit: #8a5a00;
  --t-act: #8a1f5c;       /* legislation magenta/plum */
  --t-person: #4a5568;
}

* { box-sizing: border-box; }

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

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

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

.wrap {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ---------- header ---------- */
.site-header {
  background: var(--gov);
  color: #fff;
  border-bottom: 4px solid var(--accent);
}
.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 0.9rem;
  padding-bottom: 0.9rem;
}
.brand { color: #fff; display: flex; flex-direction: column; line-height: 1.2; }
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; }
.brand-tag { font-size: 0.82rem; color: #d4def0; }

/* ---------- search ---------- */
.search { display: flex; gap: 0.4rem; flex: 1 1 280px; max-width: 460px; }
.search input {
  flex: 1; min-width: 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 1rem;
  background: #fff; color: var(--ink);
}
.search button {
  padding: 0.55rem 1rem;
  border: 0; border-radius: 6px;
  background: var(--accent); color: #fff;
  font-size: 1rem; font-weight: 600; cursor: pointer;
}
.search button:hover { background: #8e0f26; }

.search-big { max-width: 600px; margin: 1.2rem auto 0; }

/* ---------- main / hero ---------- */
main { padding: 1.5rem 0 3rem; min-height: 50vh; }

.hero {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.8rem 1.4rem;
  text-align: center;
  margin-bottom: 1.5rem;
}
.hero h1 { margin: 0 0 0.4rem; font-size: 1.7rem; color: var(--gov-dark); }
.lede { color: var(--ink-soft); margin: 0 auto; max-width: 36rem; }

/* ---------- flash ---------- */
.flash {
  background: #eef6ff;
  border: 1px solid #b9d6f5;
  color: var(--gov-dark);
  padding: 0.7rem 1rem;
  border-radius: 8px;
  margin-bottom: 1.2rem;
}

/* ---------- empty state ---------- */
.empty {
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 2rem 1.4rem;
  text-align: center;
  color: var(--ink-soft);
}
.empty h1, .empty h2 { color: var(--gov-dark); margin-top: 0; }

/* ---------- summary cards ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.8rem;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
}
.card-num { font-size: 1.9rem; font-weight: 700; color: var(--gov); line-height: 1; }
.card-label { font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 0.35rem; }
.card-sync { text-align: left; }
.card-sub { font-size: 0.9rem; color: var(--ink-soft); margin-top: 0.3rem; }
.card-sub.small { font-size: 0.8rem; color: var(--muted); }

/* ---------- generic section ---------- */
section h2 { color: var(--gov-dark); font-size: 1.25rem; border-bottom: 2px solid var(--line); padding-bottom: 0.3rem; }
.muted { color: var(--muted); }
.count { color: var(--muted); font-weight: 400; font-size: 0.9rem; }

/* ---------- node lists ---------- */
.node-list, .result-list { list-style: none; padding: 0; margin: 0; }
.node-list li, .result-list li { border-bottom: 1px solid var(--line); }
.node-list li:last-child, .result-list li:last-child { border-bottom: 0; }
.node-list a {
  display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem;
  padding: 0.7rem 0.3rem; color: var(--ink);
}
.node-list a:hover { background: #f0f4fa; text-decoration: none; }
.node-name { font-weight: 600; }
.node-title { color: var(--muted); font-size: 0.92rem; }

/* ---------- result rows ---------- */
.result { padding: 0.8rem 0.3rem; border-bottom: 1px solid var(--line); }
.result-head { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; color: var(--ink); }
.result-head:hover { text-decoration: none; }

/* ---------- badges ---------- */
.badge {
  display: inline-block;
  font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: #fff; padding: 0.16rem 0.5rem; border-radius: 999px;
  white-space: nowrap;
}
.badge-pm { background: var(--t-pm); }
.badge-premier { background: var(--t-premier); }
.badge-minister { background: var(--t-minister); }
.badge-department { background: var(--t-department); }
.badge-unit { background: var(--t-unit); }
.badge-act { background: var(--t-act); }
.badge-person { background: var(--t-person); }

/* ---------- breadcrumb / escalation ---------- */
.breadcrumb {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem;
  margin-top: 0.5rem;
  font-size: 0.92rem;
}
.crumb {
  background: #eef2f8; border: 1px solid var(--line);
  border-radius: 6px; padding: 0.25rem 0.55rem; color: var(--gov-dark);
}
.crumb:hover { background: #e0e8f4; text-decoration: none; }
.crumb-title { color: var(--muted); font-weight: 400; }
.crumb-sep { color: var(--muted); font-weight: 700; }

/* ---------- node detail ---------- */
.node-detail > section { margin-bottom: 1.8rem; }
.node-detail-head { margin-bottom: 1.5rem; }
.node-detail-head h1 { margin: 0.4rem 0 0.2rem; color: var(--gov-dark); }
.node-detail-title { color: var(--ink-soft); margin: 0; font-size: 1.05rem; }
.status-line { color: var(--muted); font-size: 0.9rem; margin: 0.3rem 0 0; }

.escalation, .contact, .provenance-block, .children {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.1rem 1.2rem;
}
.escalation h2, .contact h2, .provenance-block h2, .children h2 { margin-top: 0; }

/* highlight the headline escalation block */
.escalation { border-left: 5px solid var(--accent); }

.meta-list, .contact-list {
  display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1rem; margin: 0;
}
.meta-list dt, .contact-list dt { color: var(--muted); font-weight: 600; }
.meta-list dd, .contact-list dd { margin: 0; word-break: break-word; }

/* ---------- footer ---------- */
.site-footer {
  background: var(--gov-dark);
  color: #cdd8ec;
  padding: 1.4rem 0;
  margin-top: 2rem;
}
.site-footer .wrap {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem;
}
.provenance { margin: 0; font-size: 0.85rem; max-width: 40rem; }
.sync-form { margin: 0; }
.sync-btn {
  background: transparent; color: #fff;
  border: 1px solid #5b76a8; border-radius: 6px;
  padding: 0.5rem 1rem; font-size: 0.9rem; cursor: pointer;
}
.sync-btn:hover { background: #21407a; }
.sync-btn.primary {
  background: var(--accent); border-color: var(--accent); font-weight: 600;
  margin-top: 1rem;
}
.sync-btn.primary:hover { background: #8e0f26; }

@media (max-width: 560px) {
  .site-header .wrap { flex-direction: column; align-items: stretch; }
  .search { max-width: none; }
  .meta-list, .contact-list { grid-template-columns: 1fr; gap: 0.1rem 0; }
  .meta-list dt, .contact-list dt { margin-top: 0.4rem; }
}

/* ---------------------------------------------------------------- tree view */
.tree-toolbar { display:flex; align-items:center; gap:.75rem; flex-wrap:wrap; margin:1rem 0; }
.btn-light { border:1px solid #ccd; background:#f3f5fb; border-radius:6px;
  padding:.4rem .7rem; cursor:pointer; font:inherit; }
.btn-light:hover { background:#e8ecf7; }
.tree-note, .tree-title { color:#667; font-size:.85rem; }
.hint { font-weight:700; }

ul.tree, ul.tree-children { list-style:none; margin:0; padding:0; }
ul.tree-children { margin-left:1.1rem; border-left:1px dashed #ccd; padding-left:.4rem; }
.tree-row { display:flex; align-items:center; gap:.5rem; padding:.18rem .25rem;
  border-radius:5px; }
.tree-row:hover { background:#f4f6fc; }
.tree-row.loading .toggle { opacity:.4; }
.toggle { width:1.5rem; height:1.5rem; flex:0 0 auto; border:1px solid #ccd;
  background:#fff; border-radius:4px; cursor:pointer; line-height:1; font-size:.8rem;
  color:#446; }
.toggle:disabled { visibility:hidden; }
.tree-name { font-weight:600; text-decoration:none; color:#1a2b6b; }
.tree-name:hover { text-decoration:underline; }
.tree-count { margin-left:auto; font-size:.75rem; color:#778;
  background:#eef0f7; border-radius:10px; padding:.05rem .5rem; }
.tree-more, .tree-error { font-size:.82rem; color:#667; padding:.25rem .5rem; }
.tree-error { color:#a33; }
