/* ================================================================== *
 *  kbolyo — professional civic-intelligence theme
 * ================================================================== */
:root {
  --ink: #0f172a;
  --ink-soft: #5b6472;
  --ink-faint: #94a3b8;
  --bg: #f4f6f9;
  --card: #ffffff;
  --line: #e3e7ee;
  --line-strong: #cdd4df;
  --brand: #1e3a8a;          /* navy — primary actions */
  --brand-deep: #162d6b;
  --brand-soft: #eef2fb;
  --accent: #c81e3a;         /* Nepal crimson — used sparingly */
  --accent-soft: #fdeef0;
  --good: #15803d;
  --good-soft: #e9f6ee;
  --warn: #b45309;
  --warn-soft: #fdf2e3;
  --radius: 12px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .05);
  --shadow: 0 4px 14px -6px rgba(16, 24, 40, .15);
  --shadow-lg: 0 18px 40px -18px rgba(16, 24, 40, .28);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  line-height: 1.55;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-deep); }
img { max-width: 100%; display: block; }
h1, h2, h3 { letter-spacing: -.018em; line-height: 1.2; }
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* ---------- layout ---------- */
.container { width: min(1140px, 92vw); margin: 0 auto; }
.app-main { padding: 30px 0 90px; }
.muted { color: var(--ink-soft); }
.tiny { font-size: .8rem; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; gap: 20px; height: 62px; }
.brand { display: flex; align-items: center; gap: 11px; font-weight: 700; font-size: 1.15rem; letter-spacing: -.02em; color: var(--ink); }
.brand:hover { color: var(--ink); }
.brand .logo-img {
  width: 38px; height: 38px; border-radius: 9px; display: block;
}
.brand small { display: block; font-weight: 500; color: var(--ink-faint); font-size: .68rem; letter-spacing: 0; }

.nav { display: flex; gap: 2px; margin-left: auto; align-items: center; }
.nav a, .nav button {
  font: inherit; font-weight: 550; font-size: .9rem; color: var(--ink-soft);
  padding: 8px 13px; border-radius: 8px; border: 0; background: transparent; cursor: pointer;
  transition: background .15s, color .15s;
}
.nav a:hover { background: #f1f3f7; color: var(--ink); }
.nav a.active { color: var(--brand); background: var(--brand-soft); }
.nav .nav-cta { margin-left: 6px; }

/* hamburger toggle — hidden on desktop, shown in the mobile media query */
.nav-toggle { display: none; }
.nav-burger { display: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-weight: 600; font-size: .9rem;
  padding: 9px 17px; border-radius: 9px; border: 1px solid transparent; cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:active { transform: translateY(.5px); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-deep); color: #fff; }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--ink-faint); background: #fafbfc; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #a8182f; color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: .82rem; }

/* ---------- hero / page header ---------- */
.hero {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 16px; padding: 28px 30px; margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.hero::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--accent);
}
.hero h1 { margin: 0 0 7px; font-size: clamp(1.5rem, 3vw, 2rem); }
.hero p { margin: 0; color: var(--ink-soft); max-width: 60ch; }
.hero .emoji { display: none; }
.hero-stats { display: flex; gap: 26px; margin-top: 18px; flex-wrap: wrap; }
.hero-stats .hs { display: flex; flex-direction: column; }
.hero-stats .hs b { font-size: 1.25rem; font-weight: 700; letter-spacing: -.02em; }
.hero-stats .hs span { font-size: .76rem; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .04em; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 1.5rem; }
.page-head .sub { color: var(--ink-soft); font-size: .9rem; margin-top: 3px; }
.eyebrow { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }

/* ---------- search ---------- */
.searchbar { display: flex; gap: 10px; margin: 0 0 8px; flex-wrap: wrap; }
.searchbar input[type=search] {
  flex: 1; min-width: 220px; padding: 11px 15px; border-radius: 9px;
  border: 1px solid var(--line-strong); font: inherit; background: #fff;
}
.searchbar input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.chips { display: flex; gap: 7px; flex-wrap: wrap; margin: 14px 0 22px; }
.chip {
  font-size: .8rem; font-weight: 550; padding: 6px 13px; border-radius: 999px;
  background: #fff; border: 1px solid var(--line-strong); color: var(--ink-soft); cursor: pointer;
  transition: all .14s;
}
.chip.active, .chip:hover { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- grid ---------- */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }

/* ---------- generic card / panel ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column;
  transition: transform .14s, box-shadow .14s, border-color .14s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm); }
.panel h3 { margin-top: 0; }

/* ---------- clip card ---------- */
.card-media { background: #0b1120; aspect-ratio: 16/9; display: grid; place-items: center; }
.card-media video, .card-media audio { width: 100%; }
.card-media .audio-wrap {
  width: 100%; height: 100%; padding: 14px;
  background: #0b1120;
  display: grid; place-items: center; gap: 10px; color: #fff;
}
.card-media .audio-wrap .wave { font-size: 2rem; opacity: .9; }
.card-media .audio-wrap audio { width: 100%; }
.card-body { padding: 15px 16px; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.card-title { font-weight: 650; font-size: 1rem; color: var(--ink); }
.card-minister { display: flex; align-items: center; gap: 8px; font-size: .83rem; color: var(--ink-soft); }
.transcript-snip {
  font-size: .85rem; color: var(--ink-soft); background: #f8fafc;
  border-left: 2px solid var(--brand); padding: 8px 11px; border-radius: 0 7px 7px 0;
}
.card-stats { display: flex; gap: 15px; font-size: .8rem; color: var(--ink-faint); margin-top: auto; padding-top: 4px; }
.card-stats span { display: inline-flex; align-items: center; gap: 4px; }

/* ---------- avatar ---------- */
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; color: #fff; font-size: .82rem;
  background: var(--brand); overflow: hidden;
}
.avatar.lg { width: 80px; height: 80px; font-size: 1.4rem; border-radius: 14px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- badges ---------- */
.badge {
  font-size: .72rem; font-weight: 600; padding: 3px 9px; border-radius: 6px;
  background: #eef1f6; color: var(--ink-soft); display: inline-flex; align-items: center; gap: 4px;
}
.badge.party { color: #fff; }
.badge.pending { background: var(--warn-soft); color: var(--warn); }
.badge.approved { background: var(--good-soft); color: var(--good); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }

/* ---------- interactions ---------- */
.actions { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.action-btn {
  font: inherit; font-weight: 600; font-size: .87rem; cursor: pointer;
  border: 1px solid var(--line-strong); background: #fff; color: var(--ink-soft);
  padding: 8px 14px; border-radius: 8px; display: inline-flex; gap: 6px; align-items: center;
  transition: all .14s;
}
.action-btn:hover { border-color: var(--accent); color: var(--accent); }
.action-btn.liked { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- detail ---------- */
.detail-grid { display: grid; grid-template-columns: 1.7fr 1fr; gap: 22px; align-items: start; }
.transcript-full { white-space: pre-wrap; line-height: 1.75; font-size: 1.02rem; color: #1f2937; }

/* ---------- comments ---------- */
.comment { display: flex; gap: 11px; padding: 13px 0; border-top: 1px solid var(--line); }
.comment:first-child { border-top: 0; }
.comment .body { font-size: .92rem; }
.comment .who { font-weight: 650; font-size: .85rem; color: var(--ink); }
.comment .when { font-size: .74rem; color: var(--ink-faint); }
.comment .replies { margin-left: 18px; border-left: 2px solid var(--line); padding-left: 13px; margin-top: 8px; }

/* ---------- forms ---------- */
.field-input {
  width: 100%; padding: 10px 13px; border-radius: 9px; border: 1px solid var(--line-strong);
  font: inherit; background: #fff; color: var(--ink);
}
.field-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.form-row { margin-bottom: 15px; }
.form-row label { display: block; font-weight: 600; font-size: .86rem; margin-bottom: 6px; color: var(--ink); }
.helptext { font-size: .79rem; color: var(--ink-faint); margin-top: 4px; }
.errorlist { font-size: .8rem; color: var(--accent); list-style: none; padding: 0; margin: 6px 0 0; }

/* ---------- handles ---------- */
.handle-row { display: flex; align-items: center; gap: 11px; padding: 11px 0; border-top: 1px solid var(--line); }
.handle-row:first-child { border-top: 0; }
.handle-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: #f1f3f7; font-size: 1rem; flex: none; }
.handle-meta { line-height: 1.3; }
.handle-meta .count { font-weight: 700; }

/* ---------- party ---------- */
.party-header {
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  background: #fff; box-shadow: var(--shadow-sm); margin-bottom: 22px;
}
.party-banner { height: 84px; position: relative; }
.party-header .body { padding: 0 24px 22px; display: flex; gap: 18px; align-items: flex-end; margin-top: -34px; }
.party-emblem {
  width: 88px; height: 88px; border-radius: 16px; flex: none;
  background: #fff; border: 3px solid #fff; box-shadow: var(--shadow);
  display: grid; place-items: center; font-weight: 800; font-size: 1.6rem; color: #fff; overflow: hidden;
}
.party-header h1 { margin: 0; font-size: 1.55rem; }
.party-meta { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 8px; font-size: .85rem; color: var(--ink-soft); }
.party-meta b { color: var(--ink); font-weight: 600; }

.official-card {
  display: flex; gap: 12px; align-items: center; padding: 13px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff;
  transition: border-color .14s, box-shadow .14s;
}
.official-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.official-card .role { font-size: .76rem; color: var(--accent); font-weight: 600; }
.official-card.lead { background: var(--brand-soft); }

.data-list { list-style: none; padding: 0; margin: 0; }
.data-list li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); font-size: .9rem; }
.data-list li:first-child { border-top: 0; }
.data-list li .k { color: var(--ink-soft); }
.data-list li .v { font-weight: 600; text-align: right; }

/* ---------- analytics ---------- */
.stat-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-bottom: 24px; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); position: relative; }
.stat-card .label { font-size: .76rem; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat-card .value { font-size: 1.9rem; font-weight: 750; letter-spacing: -.02em; margin-top: 4px; line-height: 1; }
.stat-card .ico { position: absolute; top: 16px; right: 16px; font-size: 1.1rem; opacity: .5; }

.bar-row { display: grid; grid-template-columns: 160px 1fr 56px; gap: 12px; align-items: center; padding: 7px 0; font-size: .88rem; }
.bar-track { background: #eef1f6; border-radius: 999px; height: 10px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--brand); }
.bar-row .num { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }

/* ---------- messages / toasts ---------- */
.toasts { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--good); border-radius: 10px;
  padding: 12px 16px; box-shadow: var(--shadow-lg); font-size: .9rem; max-width: 340px;
}
.toast.error { border-left-color: var(--accent); }
.toast.warning { border-left-color: var(--warn); }

/* ---------- misc ---------- */
.empty { text-align: center; padding: 56px 20px; color: var(--ink-soft); }
.empty .big { font-size: 2.6rem; opacity: .7; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 16px; }
.section-head h2 { margin: 0; font-size: 1.2rem; }
.load-more-wrap { text-align: center; padding: 26px 0; }
.divider { height: 1px; background: var(--line); margin: 18px 0; border: 0; }

/* ---------- mobile ---------- */
@media (max-width: 860px) {
  .app-main { padding: 20px 0 70px; }
  .detail-grid { grid-template-columns: 1fr; }
  .party-header .body { flex-direction: column; align-items: flex-start; }
  .hero { padding: 22px 20px; }
  .panel { padding: 18px; }

  /* hide the small tagline next to the wordmark to save room */
  .brand small { display: none; }

  /* hamburger button */
  .nav-burger {
    display: flex; flex-direction: column; justify-content: center; gap: 5px;
    margin-left: auto; width: 42px; height: 42px; padding: 10px; cursor: pointer;
    border: 1px solid var(--line-strong); border-radius: 9px; background: #fff;
  }
  .nav-burger span { display: block; height: 2px; background: var(--ink); border-radius: 2px; transition: transform .2s, opacity .2s; }

  /* nav becomes a full-width dropdown under the bar */
  .nav {
    position: absolute; left: 0; right: 0; top: 100%;
    flex-direction: column; align-items: stretch; gap: 2px; margin-left: 0;
    background: #fff; border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow); padding: 8px 16px 14px; display: none;
  }
  .nav-toggle:checked ~ .nav { display: flex; }
  .nav a, .nav button { width: 100%; padding: 12px; border-radius: 9px; font-size: .98rem; }
  .nav .nav-cta { margin: 4px 0 0; text-align: center; }

  /* morph burger into an X when open */
  .nav-toggle:checked ~ .nav-burger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav-toggle:checked ~ .nav-burger span:nth-child(2) { opacity: 0; }
  .nav-toggle:checked ~ .nav-burger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  /* tighter analytics bars on small screens */
  .bar-row { grid-template-columns: 96px 1fr 44px; gap: 8px; font-size: .82rem; }
  .stat-card .value { font-size: 1.6rem; }
}

@media (max-width: 420px) {
  .grid { grid-template-columns: 1fr; }
  .brand { font-size: 1.05rem; }
}
