/* Alberta Police Accountability Project — design system
   Sober, journalistic, accessible. Subject matter is serious; design is dignified. */

:root {
  /* EPS-inspired identity: dark navy blue + near-black, restrained gold accent, no red */
  --ink: #0b1322;
  --ink-2: #36404f;
  --muted: #69727f;
  --line: #e3e6ec;
  --line-2: #c9d0db;
  --paper: #ffffff;
  --paper-2: #f5f7fa;
  --paper-3: #eaeef4;

  --navy: #0d1f3c;        /* EPS deep blue */
  --navy-2: #1c3a63;
  --black: #080c14;
  --accent: #1f4e87;      /* EPS blue — interactive (buttons, links, kickers) */
  --accent-soft: #e6edf6;
  --gold: #b0863a;        /* sparing gold accent */
  --gold-soft: #f3ebd9;
  --severity: #0d1f3c;    /* deep navy stands in for the old severity-red */
  --severity-soft: #e5e9f1;
  --amber: #7c5e1c;
  --amber-soft: #f3ebd9;
  --green: #1f6f43;
  --green-soft: #e4f1ea;
  --blue: #1f5f8b;
  --blue-soft: #e6eff5;

  --radius: 8px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(16,20,30,.06), 0 6px 20px rgba(16,20,30,.06);
  --maxw: 1180px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--navy-2); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { line-height: 1.18; color: var(--ink); margin: 0 0 .5em; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: clamp(1.8rem, 3.4vw, 2.7rem); }
h2 { font-size: clamp(1.35rem, 2.4vw, 1.9rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1rem; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }
.narrow { max-width: 760px; }

/* ---------- Top bar ---------- */
.topbar { background: var(--navy); color: #fff; }
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 11px; color: #fff; font-weight: 800; letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand .mark {
  width: 30px; height: 30px; border-radius: 6px; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--navy-2), var(--black));
  box-shadow: inset 0 0 0 1px rgba(176,134,58,.45);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: .95rem;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}
.brand .name { font-size: 1.02rem; line-height: 1.05; }
.brand .name small { display: block; font-weight: 500; font-size: .68rem; color: #b9c4dc; letter-spacing: .02em; }
.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav a {
  color: #d7deec; padding: 8px 12px; border-radius: 6px; font-size: .92rem; font-weight: 500;
}
.nav a:hover { background: rgba(255,255,255,.09); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(255,255,255,.14); color: #fff; }
.nav .cta { background: var(--accent); color: #fff; font-weight: 700; }
.nav .cta:hover { background: #163a66; }
/* hamburger */
.navtoggle { display: none; background: transparent; border: 0; cursor: pointer; padding: 10px; width: 44px; height: 44px; position: relative; }
.navtoggle span { display: block; width: 22px; height: 2px; background: #fff; border-radius: 2px; margin: 4px auto; transition: transform .25s, opacity .2s; }
.topbar.nav-open .navtoggle span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.topbar.nav-open .navtoggle span:nth-child(2) { opacity: 0; }
.topbar.nav-open .navtoggle span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* sticky bottom quick-nav (mobile only) */
.bottomnav { display: none; }
body.no-scroll { overflow: hidden; }

@media (max-width: 900px) {
  .navtoggle { display: block; }
  .topbar .wrap { min-height: 58px; position: relative; }
  /* full-width slide-down overlay menu */
  .nav {
    position: fixed; top: 58px; left: 0; right: 0; bottom: 0;
    background: var(--navy); flex-direction: column; align-items: stretch;
    padding: 10px 16px calc(80px + env(safe-area-inset-bottom)); gap: 2px;
    overflow-y: auto; transform: translateY(-8px); opacity: 0; pointer-events: none;
    transition: opacity .2s, transform .2s; z-index: 60;
  }
  .topbar.nav-open .nav { opacity: 1; transform: none; pointer-events: auto; }
  .nav a { padding: 14px 12px; font-size: 1.05rem; border-bottom: 1px solid rgba(255,255,255,.08); border-radius: 0; }
  .nav .cta { margin-top: 12px; border-radius: 8px; text-align: center; border-bottom: 0; }

  /* bottom bar */
  .bottomnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
    background: rgba(255,255,255,.97); backdrop-filter: blur(8px);
    border-top: 1px solid var(--line-2); padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 14px rgba(16,20,30,.08);
  }
  .bottomnav a, .bottomnav .bmore {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; padding: 9px 2px; font-size: .68rem; font-weight: 600; color: var(--muted);
    background: transparent; border: 0; cursor: pointer; min-height: 54px; text-decoration: none;
  }
  .bottomnav a.active { color: var(--accent); }
  .bottomnav .bi { font-size: 1.15rem; line-height: 1; }
  body { padding-bottom: 64px; } /* room for the bottom bar */

  /* bigger tap targets & type on phones */
  .map-toolbar select, .map-toolbar input, .btn, .nav a { min-height: 44px; }
  .map-toolbar { gap: 8px; }
  .map-toolbar select { flex: 1 1 44%; font-size: .95rem; }
  body { font-size: 16.5px; }
  .card { padding: 16px; }
  #map { height: 60vh; }
}

/* ---------- Banner / disclaimer strip ---------- */
.strip {
  background: var(--paper-3); border-bottom: 1px solid var(--line);
  font-size: .82rem; color: var(--ink-2);
}
.strip .wrap { padding: 7px 22px; display: flex; gap: 8px; align-items: center; justify-content: center; text-align: center; }
.strip b { color: var(--ink); }

/* ---------- Hero ---------- */
.hero { background: linear-gradient(180deg, #0d1f3c, #080c14); color: #eef2f9; padding: 56px 0 40px; border-bottom: 3px solid var(--gold); }
.hero h1 { color: #fff; max-width: 18ch; }
.hero .lede { font-size: 1.12rem; color: #c7d2e6; max-width: 60ch; }
.hero .pills { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.16); color: #dbe4f3; padding: 6px 12px; border-radius: 999px; font-size: .85rem;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  background: var(--accent); color: #fff; border: 0; padding: 11px 18px; border-radius: 8px;
  font-weight: 700; font-size: .95rem; text-decoration: none;
}
.btn:hover { background: #163a66; text-decoration: none; }
.btn.ghost { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.4); }
.btn.ghost:hover { background: rgba(255,255,255,.1); }
.btn.dark { background: var(--navy); }
.btn.dark:hover { background: var(--navy-2); }
.btn.sm { padding: 7px 13px; font-size: .85rem; }

/* ---------- Sections ---------- */
section { padding: 44px 0; }
.section-head { margin-bottom: 22px; }
.section-head .kicker { text-transform: uppercase; letter-spacing: .08em; font-size: .76rem; font-weight: 700; color: var(--accent); margin-bottom: 6px; }
.section-head p { color: var(--ink-2); max-width: 70ch; }

/* ---------- Stat grid ---------- */
.statgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow); }
.stat .n { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; color: var(--navy); }
.stat .n.red { color: var(--accent); }
.stat .l { font-size: .86rem; color: var(--muted); }
@media (max-width: 860px){ .statgrid { grid-template-columns: repeat(2,1fr); } }

/* ---------- Map ---------- */
#map { height: 540px; width: 100%; border: 1px solid var(--line); border-radius: var(--radius-lg); z-index: 1; }
.map-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.map-toolbar select, .map-toolbar input {
  border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; font-size: .9rem; font-family: inherit; background: #fff; color: var(--ink);
}
.map-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .82rem; color: var(--ink-2); margin-top: 10px; }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg-dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.2); }
.leaflet-popup-content { font-family: var(--font); }
.popup-title { font-weight: 700; margin-bottom: 2px; }
.popup-meta { font-size: .8rem; color: var(--muted); margin-bottom: 6px; }

/* ---------- Cards / incident list ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 8px;
}
.card:hover { border-color: var(--line-2); }
.card .ctitle { font-size: 1.05rem; font-weight: 700; }
.card .cmeta { font-size: .82rem; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.card .csum { font-size: .92rem; color: var(--ink-2); }
.card .foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 6px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: .74rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; border: 1px solid transparent; letter-spacing: .01em; }
.badge.death { background: var(--severity); color: #fff; }
.badge.injury { background: var(--gold-soft); color: var(--amber); }
.badge.verified { background: var(--green-soft); color: var(--green); }
.badge.unverified { background: var(--paper-3); color: var(--ink-2); }
.badge.disputed { background: var(--gold-soft); color: var(--amber); }
.badge.invest { background: var(--blue-soft); color: var(--blue); }
.badge.charges { background: var(--severity-soft); color: var(--severity); }
.badge.nocharge { background: var(--paper-3); color: var(--ink-2); }
.badge.gray { background: var(--paper-3); color: var(--ink-2); }
.srccount { font-size: .76rem; color: var(--muted); }

/* ---------- Tables ---------- */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; background: #fff; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--paper-2); font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
td.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* ---------- Ranking ---------- */
.rankrow { display: grid; grid-template-columns: 44px 1fr auto; gap: 14px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px 18px; box-shadow: var(--shadow); margin-bottom: 12px; }
.rankrow .rk { font-size: 1.6rem; font-weight: 800; color: var(--muted); text-align: center; }
.rankrow .score { text-align: right; }
.rankrow .score .s { font-size: 1.5rem; font-weight: 800; }
.scorebar { height: 8px; background: var(--paper-3); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.scorebar > i { display: block; height: 100%; background: linear-gradient(90deg, #2f6f8b, #1c3a63 55%, #0d1f3c); }

/* ---------- Detail page ---------- */
.detail-head { border-left: 4px solid var(--accent); padding-left: 16px; margin-bottom: 8px; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 4px 18px; font-size: .94rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); }
.sourcelist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.sourcelist li { display: flex; gap: 10px; align-items: baseline; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper-2); }
.sourcelist .num { font-weight: 800; color: var(--accent); }
.sourcelist .outlet { font-weight: 600; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0 0 8px; padding: 0; border-left: 2px solid var(--line-2); }
.timeline li { position: relative; padding: 0 0 16px 22px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line-2); }
.timeline .tl-date { display: block; font-size: .78rem; font-weight: 700; color: var(--navy); letter-spacing: .01em; }
.timeline .tl-event { display: block; font-size: .94rem; color: var(--ink-2); }
.timeline .tl-src { color: var(--muted); text-decoration: none; font-size: .85rem; }
.detail-main h3 { margin-top: 26px; }
.detail-main .callout h3 { margin-top: 0; }

/* ---------- Funnel ---------- */
.funnel { display: flex; flex-direction: column; gap: 8px; max-width: 620px; }
.funnel .fstep { background: var(--navy); color: #fff; border-radius: 8px; padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 0 auto; }
.funnel .fstep .fn { font-size: 1.35rem; font-weight: 800; }
.funnel .fstep .fl { font-size: .9rem; opacity: .92; }
.funnel .fstep.f0 { width: 100%; }
.funnel .fstep.f1 { width: 78%; background: #29406e; }
.funnel .fstep.f2 { width: 52%; background: #2f6f8b; }
.funnel .fstep.f3 { width: 30%; background: var(--gold); }
.funnel .fdrop { text-align: center; font-size: .78rem; color: var(--muted); }

/* ---------- Content warning ---------- */
.cw { background: var(--amber-soft); border: 1px solid #e6cf99; border-radius: var(--radius); padding: 12px 14px; font-size: .88rem; color: #6b4a00; margin: 0 0 18px; }
.cw b { color: #5a3e00; }

/* ---------- Callouts ---------- */
.callout { border: 1px solid var(--line); border-left: 4px solid var(--navy); background: var(--paper-2); border-radius: var(--radius); padding: 16px 18px; margin: 18px 0; }
.callout.warn { border-left-color: var(--amber); background: var(--amber-soft); }
.callout.danger { border-left-color: var(--gold); background: var(--gold-soft); }
.callout h3 { margin-top: 0; }

/* ---------- Two-column ---------- */
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
@media (max-width: 860px){ .cols2 { grid-template-columns: 1fr; } .kv { grid-template-columns: 1fr; } }

/* ---------- Footer ---------- */
footer.site { background: var(--navy); color: #c7d2e6; padding: 40px 0 28px; margin-top: 40px; font-size: .9rem; }
footer.site a { color: #dbe4f3; }
footer.site .grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 28px; }
footer.site h4 { color: #fff; font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px; }
footer.site ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 7px; }
footer.site .fine { border-top: 1px solid rgba(255,255,255,.15); margin-top: 26px; padding-top: 16px; font-size: .8rem; color: #9fb0cd; }
@media (max-width: 860px){ footer.site .grid { grid-template-columns: 1fr; } }

/* ---------- Utility ---------- */
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }
.tag { display:inline-block; font-size:.74rem; background:var(--paper-3); color:var(--ink-2); padding:2px 8px; border-radius:6px; }
.empty { text-align: center; padding: 40px; color: var(--muted); border: 1px dashed var(--line-2); border-radius: var(--radius-lg); }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(10px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: .88rem; font-weight: 600; z-index: 90; opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.breadcrumb { font-size: .84rem; color: var(--muted); margin: 18px 0; }
.divider { height: 1px; background: var(--line); margin: 28px 0; border: 0; }

/* ---------- Avatars (photo or initials fallback) ---------- */
.avatar { width: 52px; height: 52px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 1.05rem; overflow: hidden; background: var(--navy-2); letter-spacing: -.02em; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 68px; height: 68px; font-size: 1.3rem; }
.avatar.sm { width: 38px; height: 38px; font-size: .85rem; }

/* ---------- Share button ---------- */
.share {
  display: inline-flex; align-items: center; gap: 6px; background: var(--paper-2); border: 1px solid var(--line-2);
  color: var(--ink-2); border-radius: 999px; padding: 6px 12px; font-size: .82rem; font-weight: 600; cursor: pointer; font-family: inherit;
}
.share:hover { background: var(--paper-3); }
.share svg { width: 14px; height: 14px; }

/* ---------- Quick facts ---------- */
.bignum { background: var(--navy); color: #fff; border-radius: var(--radius-lg); padding: 22px; position: relative; overflow: hidden; }
.bignum .n { font-size: 2.6rem; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.bignum .n.red { color: #e3b95f; }
.bignum .l { font-size: .92rem; color: #c7d2e6; margin-top: 8px; }
.bignum .src { font-size: .72rem; color: #8ea2c4; margin-top: 8px; }
.bignum .share { position: absolute; top: 12px; right: 12px; background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.2); color: #dbe4f3; }
.bignum .share:hover { background: rgba(255,255,255,.2); }

.scorecard { display: grid; grid-template-columns: 1fr auto 1fr; gap: 0; border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); background: #fff; }
.scorecard .col { padding: 18px 16px; }
.scorecard .col.head { text-align: center; }
.scorecard .agency { font-weight: 800; font-size: 1.05rem; }
.scorecard .mid { background: var(--paper-2); display: grid; align-content: center; text-align: center; font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.scorecard .row { display: contents; }
.scorecard .metric { padding: 11px 16px; border-top: 1px solid var(--line); font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.scorecard .metric.worse { color: var(--gold); }
.scorecard .metric.right { text-align: right; }
.scorecard .midlabel { padding: 11px 8px; border-top: 1px solid var(--line); background: var(--paper-2); font-size: .74rem; color: var(--ink-2); text-align: center; display: grid; align-content: center; }
@media (max-width: 560px) { .scorecard .metric { font-size: 1.05rem; padding: 9px 10px; } .scorecard .col { padding: 14px 10px; } }
