/* truthY — design tokens follow the bottleNeck shortcut.css convention */
:root, :root[data-theme="dark"] {
  --bg-page: #16161c;
  --bg-card: #1f1f27;
  --bg-hover: #262630;
  --border: #32323e;
  --text: #f2f2f5;
  --text-dim: #a5a5b3;
  --text-faint: #74747f;
  --accent: #ffde87;
  --primary: #494bcb;
  --ok: #2e9e44;
  --warn: #ca8a04;
  --err: #dc2626;
  --mortar: #101014;      /* Y-badge text; fixed dark */
  --wall-bg: #101014;     /* brick-wall grout */
  --field-bg: #14141a;    /* form inputs */
  --track: #101014;       /* score-bar track */
  --radius: 10px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Archivo Black', 'Inter', sans-serif;
}

:root[data-theme="light"] {
  --bg-page: #f4f5f7;
  --bg-card: #ffffff;
  --bg-hover: #eceef2;
  --border: #dcdfe6;
  --text: #1a1b22;
  --text-dim: #565a6b;
  --text-faint: #8a8f9e;
  --accent: #ffce55;
  --primary: #494bcb;
  --wall-bg: #d5d8e0;     /* light grout so colored bricks pop */
  --field-bg: #ffffff;
  --track: #e2e4ea;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg-page); color: var(--text);
  font-family: var(--font); line-height: 1.5;
}
a { color: inherit; }

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; border-bottom: 1px solid var(--border);
  background: var(--bg-card); position: sticky; top: 0; z-index: 20;
}
.brand { font-family: var(--font-display); font-size: 24px; text-decoration: none; letter-spacing: .5px; white-space: nowrap; }
.brand-truth { color: var(--text); }
.brand-y {
  color: #14141a; background: var(--accent);
  display: inline-block; padding: 0 7px; margin-left: 1px; border-radius: 6px;
  transform: translateY(1px);
}
.theme-toggle {
  background: var(--bg-hover); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
  margin-left: 6px; line-height: 1;
}
.theme-toggle:hover { filter: brightness(1.12); }
.theme-toggle .icon-light { display: none; }
.theme-toggle .icon-dark { display: inline; }
:root[data-theme="light"] .theme-toggle .icon-light { display: inline; }
:root[data-theme="light"] .theme-toggle .icon-dark { display: none; }
.nav { display: flex; gap: 8px; align-items: center; }
.nav a {
  text-decoration: none; color: var(--text); font-weight: 600; font-size: 14px;
  padding: 7px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-hover);
}
.nav a:hover { filter: brightness(1.1); }
.nav a.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.nav .btn.small { text-decoration: none; }
.logout-form { display: inline; margin: 0; }
.topbar-actions { display: flex; gap: 8px; align-items: center; margin-left: 14px; }
.btn.small { padding: 7px 13px; font-size: 13px; display: inline-flex; align-items: center; gap: 7px; }
.btn[disabled] { opacity: .55; cursor: default; }
.spinner {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.25); border-top-color: var(--accent);
  animation: nf-spin .8s linear infinite; display: none;
}
.working .spinner { display: inline-block; }
@keyframes nf-spin { to { transform: rotate(360deg); } }
.job-note { font-size: 12px; color: var(--text-faint); max-width: 340px; }
.job-note.warn { color: var(--warn); }
.cap-badge {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 8px;
  border-radius: 20px; margin-left: 8px; vertical-align: middle;
}
.cap-badge.ok { background: rgba(46,158,68,.18); color: #5fce77; }
.cap-badge.no { background: rgba(202,138,4,.18); color: #eab547; }

.content { max-width: 1160px; margin: 0 auto; padding: 32px 28px 64px; }
.footer {
  max-width: 1160px; margin: 0 auto; padding: 20px 28px 40px;
  color: var(--text-faint); font-size: 12.5px; border-top: 1px solid var(--border);
}
.footer-stamp { display: inline-block; margin-top: 6px; color: var(--text-dim); }

.page-head h1 { font-family: var(--font-display); font-size: 32px; margin: 6px 0 8px; letter-spacing: .3px; }
.page-head .sub { color: var(--text-dim); max-width: 760px; margin: 0 0 10px; }
.outlets-line {
  color: var(--text-faint); font-size: 12.5px; line-height: 1.5;
  max-width: 900px; margin: 8px 0 0;
  border-top: 1px solid var(--border); padding-top: 10px;
}
.outlets-line .footer-stamp { color: var(--text-dim); }
.stamp { display: inline-block; margin-left: 10px; color: var(--text-faint); font-size: 12.5px; }
.crumb { color: var(--text-dim); font-size: 13.5px; text-decoration: none; }
.crumb:hover { color: var(--text); }

/* ---- the brick wall ---- */
.wall {
  display: flex; flex-wrap: wrap; gap: 10px;
  background: var(--wall-bg); padding: 18px; border-radius: 14px;
  margin-top: 20px;
}
.brick {
  --brick: #1273b5;
  /* flex set inline per brick: grow scales with outlet_count so the most
     widely-covered stories are the biggest bricks on the wall */
  position: relative; flex: 1 1 240px; min-height: 128px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 18px 20px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--brick) 100%, white 8%), var(--brick) 55%, color-mix(in srgb, var(--brick) 84%, black 16%));
  border-radius: 6px; text-decoration: none; color: #fff;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.25), 0 1px 2px rgba(0,0,0,.5);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.brick:hover {
  transform: translateY(-4px) scale(1.02);
  filter: brightness(1.08);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.25), 0 10px 24px rgba(0,0,0,.55);
  z-index: 5;
}
.brick-label {
  font-family: var(--font-display); font-size: 24px; text-align: center;
  text-transform: uppercase; letter-spacing: .5px; line-height: 1.15;
  text-shadow: 0 2px 4px rgba(0,0,0,.35);
}
.brick-outlets { font-size: 12px; font-weight: 600; opacity: .85; }

/* hover TLDR tooltip */
.brick .tldr {
  position: absolute; left: 50%; bottom: calc(100% + 10px); transform: translateX(-50%);
  width: 300px; padding: 12px 14px; border-radius: 10px;
  background: #0c0c10; color: #f2f2f5; border: 1px solid rgba(255,255,255,.12);
  font-size: 13px; line-height: 1.45; text-align: left;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .15s ease .1s; z-index: 30;
  box-shadow: 0 12px 28px rgba(0,0,0,.6);
}
.brick .tldr strong { display: block; margin-bottom: 4px; color: var(--accent); }
.brick .tldr::after {
  content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 7px solid transparent; border-top-color: #0c0c10;
}
.brick:hover .tldr { opacity: 1; visibility: visible; }
.wall .brick:nth-child(-n+4) .tldr { bottom: auto; top: calc(100% + 10px); }
.wall .brick:nth-child(-n+4) .tldr::after {
  top: auto; bottom: 100%; border-top-color: transparent; border-bottom-color: #0c0c10;
}

/* ---- topic detail ---- */
.swatch {
  display: inline-block; width: 22px; height: 22px; border-radius: 5px;
  background: var(--brick); margin-right: 10px; vertical-align: baseline;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.3);
}
.consensus-line { color: var(--text-dim); border-left: 3px solid var(--ok); padding-left: 12px; }
.topic-hits {
  display: inline-block; vertical-align: middle; margin-left: 14px;
  font-family: var(--font); font-size: 14px; font-weight: 700;
  color: var(--text-dim); background: var(--bg-hover);
  border: 1px solid var(--border); border-radius: 20px; padding: 4px 14px;
  text-transform: none; letter-spacing: 0;
}
.topic-hits .hc-hits { color: var(--ok); }
.topic-hits .hc-strikes { color: var(--err); }

.explainer {
  background: var(--bg-card); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: var(--radius);
  padding: 16px 20px; margin: 8px 0 20px; max-width: 780px;
}
.explainer h2 { margin: 0 0 8px; font-size: 15px; }
.explainer p { margin: 0 0 8px; font-size: 13.5px; color: var(--text-dim); }
.explainer p:last-child { margin-bottom: 0; }
.explainer strong { color: var(--text); }
.sub.small { font-size: 13px; color: var(--text-dim); max-width: 760px; }
.sub.small a { color: var(--accent); }
.th-sub { font-weight: 600; font-size: 10px; color: var(--text-faint); text-transform: none; letter-spacing: 0; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.story-table {
  width: 100%; border-collapse: collapse; margin-top: 18px;
  background: var(--bg-card); border-radius: var(--radius); overflow: hidden;
  font-size: 14px;
}
.story-table th {
  text-align: left; padding: 12px 14px; color: var(--text-faint);
  font-size: 12px; text-transform: uppercase; letter-spacing: .6px;
  border-bottom: 1px solid var(--border);
}
.story-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.story-table tbody tr:not(.group-row):hover td { background: var(--bg-hover); }
.group-row td {
  background: var(--bg-hover); color: var(--text-dim); font-size: 13px; padding: 9px 14px;
}
.group-tag {
  display: inline-block; font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .5px; padding: 2px 9px; border-radius: 20px; margin-right: 10px;
}
.tag-consensus { background: rgba(46,158,68,.18); color: #5fce77; }
.tag-divergent { background: rgba(220,38,38,.16); color: #f07575; }
.tag-strike { background: rgba(116,116,127,.18); color: var(--text-faint); }
.group-count { float: right; color: var(--text-faint); font-size: 12px; }
tbody.divergent td { opacity: .92; }
tbody.strikes td { opacity: .72; }
.strike-row .src-cell { font-weight: 600; color: var(--text-dim); }
.strike-note { color: var(--text-faint); font-size: 13px; font-style: italic; }
.scores-table .strike-col { color: var(--text-dim); }
.src-cell { font-weight: 700; white-space: nowrap; }
.headline { color: var(--text); font-weight: 600; text-decoration: none; }
.headline:hover { color: var(--accent); }
.summary { color: var(--text-dim); font-size: 13px; margin-top: 4px; max-width: 520px; }
.angle { color: var(--text-dim); font-size: 13px; max-width: 260px; }

.score {
  display: inline-block; min-width: 52px; text-align: center;
  font-weight: 800; font-size: 13px; padding: 3px 8px; border-radius: 7px;
}
.score.hi  { background: rgba(46,158,68,.18); color: #5fce77; }
.score.mid { background: rgba(202,138,4,.18); color: #eab547; }
.score.lo  { background: rgba(220,38,38,.16); color: #f07575; }
.score.na  { color: var(--text-faint); }
.score.muted { background: rgba(116,116,127,.18); color: var(--text-faint); }
tr.provisional td { opacity: .62; }
.vol-badge {
  display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .2px;
  padding: 1px 8px; border-radius: 20px; margin-left: 8px; vertical-align: middle;
  background: var(--bg-hover); color: var(--text-faint); border: 1px solid var(--border);
}
.alltime-tag {
  display: inline-block; font-family: var(--font); font-size: 13px; font-weight: 700;
  vertical-align: middle; margin-left: 10px; padding: 2px 10px; border-radius: 20px;
  background: var(--bg-hover); color: var(--text-dim); border: 1px solid var(--border);
  text-transform: uppercase; letter-spacing: .5px;
}
.prov-tag {
  display: inline-block; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; padding: 1px 7px; border-radius: 20px; margin-left: 8px;
  background: rgba(202,138,4,.16); color: #eab547; vertical-align: middle;
}
.bar-cell { width: 220px; }
.bar { background: var(--track); border-radius: 20px; height: 10px; overflow: hidden; margin-top: 5px; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, #e0342f, #f2930d 45%, #2e9e44 85%); border-radius: 20px; }

/* ---- settings / cards / forms ---- */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 22px; margin: 16px 0;
}
.card h2 { margin: 0 0 6px; font-size: 17px; }
.hint { color: var(--text-dim); font-size: 13px; }
.hint a { color: var(--accent); }
.radio, .check { display: flex; gap: 10px; margin: 14px 0; cursor: pointer; }
.radio input, .check input { margin-top: 4px; accent-color: var(--primary); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
input[type=password], input[type=text], input[type=number], select {
  background: var(--field-bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 12px; font-family: var(--font); font-size: 14px;
  min-width: 220px;
}
input[type=number] { min-width: 0; }
select { min-width: 0; }
.btn {
  background: var(--bg-hover); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 18px; font-weight: 700; font-size: 14px; cursor: pointer;
}
.btn:hover { filter: brightness(1.15); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.ghost { background: transparent; }
.flash.ok {
  background: rgba(46,158,68,.15); border: 1px solid rgba(46,158,68,.4);
  color: #5fce77; border-radius: 8px; padding: 10px 16px; margin: 12px 0;
}
.ok-text { color: #5fce77; font-size: 13px; }
.err-text { color: #f07575; font-size: 13px; }

.login-wrap {
  max-width: 440px; margin: 8vh auto 0; text-align: center;
}
.login-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px;
  padding: 40px 36px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.login-card h1 { font-family: var(--font-display); font-size: 30px; margin: 0 0 6px; }
.login-card p { color: var(--text-dim); margin: 0 0 26px; font-size: 14px; }
.google-btn {
  display: inline-flex; align-items: center; gap: 12px; cursor: pointer;
  background: #fff; color: #1f1f27; border: none; border-radius: 10px;
  padding: 13px 24px; font-family: var(--font); font-weight: 700; font-size: 15px;
  transition: filter .12s ease;
}
.google-btn:hover { filter: brightness(.94); }
.google-btn svg { width: 20px; height: 20px; }
.login-err { color: #f07575; font-size: 13.5px; margin-top: 18px; min-height: 18px; }
.login-note { color: var(--text-faint); font-size: 12.5px; margin-top: 22px; }
.empty-card {
  background: var(--bg-card); border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 40px; text-align: center; color: var(--text-dim); margin-top: 24px;
}
.empty-card code { background: var(--bg-hover); padding: 2px 8px; border-radius: 6px; }

@media (max-width: 720px) {
  .content { padding: 20px 14px 48px; }
  /* Header: brand on its own row, nav drops below and wraps freely. */
  .topbar { flex-wrap: wrap; padding: 12px 14px; row-gap: 10px; }
  .nav { flex-basis: 100%; justify-content: flex-start; }
  .topbar-actions { margin-left: 0; }
  .brick { flex-basis: 100% !important; min-height: 104px; }
  .bar-cell { display: none; }
  /* Keep "How they tell it" readable on mobile — the table scrolls
     horizontally inside .table-wrap instead of hiding the column. */
  .table-wrap .story-table { min-width: 680px; }
  .summary, .angle { max-width: 240px; }
  .nav { flex-wrap: wrap; gap: 4px; }
}

/* Phones: stack the comparison table into readable cards instead of a
   sideways-scrolling grid. Each row becomes a block; the score chip pins to
   the top-right, headline/summary/angle flow full width below the source. */
@media (max-width: 560px) {
  .table-wrap { overflow-x: visible; }
  .table-wrap .story-table { min-width: 0; }

  /* Topic comparison table → cards (excludes the leaderboard, which is styled
     separately below even though it shares the .story-table base class). */
  .story-table:not(.scores-table),
  .story-table:not(.scores-table) tbody,
  .story-table:not(.scores-table) tr,
  .story-table:not(.scores-table) td { display: block; width: auto; }
  .story-table:not(.scores-table) thead { display: none; }
  .story-table:not(.scores-table) .group-row td { padding: 10px 14px; }
  .story-table:not(.scores-table) tbody tr:not(.group-row) {
    position: relative;
    padding: 12px 14px 14px;
    border-bottom: 1px solid var(--border);
  }
  .story-table:not(.scores-table) tbody tr:not(.group-row) td { padding: 0; border: none; }
  .story-table:not(.scores-table) .src-cell { white-space: normal; padding-right: 68px; margin-bottom: 2px; }
  .story-table:not(.scores-table) tbody tr:not(.group-row) td:nth-child(2) {
    position: absolute; top: 12px; right: 14px; margin: 0;
  }
  .summary, .angle { max-width: none; }
  .story-table:not(.scores-table) .headline { display: block; margin-top: 3px; }
  .summary { margin-top: 5px; }
  .angle { margin-top: 7px; }
  .angle:not(:empty)::before { content: "How they tell it — "; color: var(--text-faint); }
  .strike-note { margin-top: 5px; }

  /* Leaderboard → labeled cards: rank + name, score chip, full-width bar,
     then the three count columns inline with labels (headers are hidden). */
  .scores-table, .scores-table tbody, .scores-table tr, .scores-table td { display: block; width: auto; }
  .scores-table thead { display: none; }
  .scores-table tbody tr { position: relative; padding: 14px 14px 12px; border-bottom: 1px solid var(--border); }
  .scores-table td { padding: 0; border: none; }
  .scores-table td:nth-child(1) { position: absolute; top: 14px; right: 14px; color: var(--text-faint); font-size: 13px; }
  .scores-table .src-cell { font-size: 16px; margin-bottom: 8px; padding-right: 34px; }
  .scores-table td:nth-child(3) { display: inline-block; margin-bottom: 10px; }
  .scores-table .bar-cell { display: block !important; margin-bottom: 12px; }
  .scores-table .bar { max-width: 100%; }
  .scores-table td:nth-child(5), .scores-table td:nth-child(6),
  .scores-table td:nth-child(7), .scores-table td:nth-child(8) {
    display: inline-block; margin-right: 16px; font-size: 14px; color: var(--text);
    font-variant-numeric: tabular-nums;
  }
  .scores-table td:nth-child(5)::before { content: "Topics "; color: var(--text-faint); }
  .scores-table td:nth-child(6)::before { content: "In consensus "; color: var(--text-faint); }
  .scores-table td:nth-child(7)::before { content: "Strikes "; color: var(--text-faint); }
  .scores-table td:nth-child(8)::before { content: "Articles "; color: var(--text-faint); }
}
