/* Franki Research Library
   Light, publication-feel, mobile-first. */

:root {
  --bg: #fafaf7;
  --surface: #ffffff;
  --surface-alt: #f4f2ec;
  --border: #e6e2d7;
  --border-strong: #cfc9b9;
  --text: #1a1a1a;
  --text-muted: #6a675e;
  --text-subtle: #8c8878;
  --accent: #2a6f6b;          /* muted teal, reads well at small sizes */
  --accent-hover: #1f5552;
  --chip-bg: #eeeadf;
  --chip-bg-hover: #e2ddce;
  --chip-active: var(--accent);
  --chip-active-text: #ffffff;
  --verdict-confirmed: #2f7a3a;
  --verdict-confirmed-bg: #e4f2e5;
  --verdict-partial: #8a6a12;
  --verdict-partial-bg: #f6edd4;
  --verdict-unverified: #5f5f5f;
  --verdict-unverified-bg: #ececec;
  --verdict-misleading: #a14f17;
  --verdict-misleading-bg: #f7e6d4;
  --verdict-false: #a61e1e;
  --verdict-false-bg: #f7dada;
  --shadow-sm: 0 1px 2px rgba(26, 26, 26, 0.04);
  --shadow-md: 0 2px 8px rgba(26, 26, 26, 0.06);
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Source Serif 4", Georgia, "Times New Roman", serif;
  font-size: 18px;
  line-height: 1.65;
  font-feature-settings: "kern" 1, "liga" 1;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}

/* ---- Header ---- */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 28px 0 22px;
}

.header-inner {
  display: flex;
  gap: 18px;
  align-items: center;
}

.avatar {
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  width: 64px;
  height: 64px;
}

.wordmark {
  font-family: "Source Serif 4", Georgia, serif;
  font-weight: 600;
  font-size: 1.55rem;
  line-height: 1.15;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

.tagline {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-muted);
  font-size: 0.92rem;
  margin: 0;
  line-height: 1.4;
}

/* ---- Filter bar ---- */

.filter-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 0 18px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}

.filter-bar .wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-group.tags-group {
  gap: 5px;
}

.pill, .chip, .filter-search input {
  font-family: "Inter", -apple-system, sans-serif;
}

.pill {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  min-height: 36px;
}

.pill:hover {
  background: var(--chip-bg-hover);
  border-color: var(--border-strong);
}

.pill.active {
  background: var(--accent);
  color: var(--chip-active-text);
  border-color: var(--accent);
}

.pill .count, .chip .count {
  opacity: 0.7;
  font-weight: 400;
  margin-left: 2px;
}

.pill.active .count { opacity: 0.85; }

.chip {
  display: inline-flex;
  align-items: center;
  background: var(--chip-bg);
  border: 1px solid transparent;
  color: var(--text);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s;
  font-weight: 500;
  min-height: 28px;
}

.chip:hover {
  background: var(--chip-bg-hover);
  text-decoration: none;
}

.chip.active {
  background: var(--chip-active);
  color: var(--chip-active-text);
}

button.chip {
  font-family: inherit;
}

.filter-search input {
  width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg);
  font-size: 0.95rem;
  color: var(--text);
}

.filter-search input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-color: var(--accent);
}

.filter-active {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: "Inter", sans-serif;
}

.filter-active button.clear-one {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.85rem;
  text-decoration: underline;
  font-family: inherit;
  padding: 0 4px;
}

/* ---- Count bar ---- */

.count-bar {
  font-family: "Inter", sans-serif;
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: 20px 0 14px;
}

/* ---- Entry cards ---- */

.entries-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0 0 40px;
  border-top: 1px solid var(--border);
}

.card {
  padding: 22px 0;
  border-bottom: 1px solid var(--border);
}

.card-title {
  display: flex;
  gap: 10px;
  align-items: baseline;
  text-decoration: none;
  color: var(--text);
  font-family: "Source Serif 4", Georgia, serif;
  font-weight: 600;
  font-size: 1.25rem;
  line-height: 1.25;
  letter-spacing: -0.005em;
  margin-bottom: 6px;
}

.card-title:hover {
  color: var(--accent);
}

.type-icon {
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
}

.card-meta {
  font-family: "Inter", sans-serif;
  font-size: 0.85rem;
  color: var(--text-subtle);
  margin-bottom: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.meta-sep { opacity: 0.5; }

.card-summary {
  font-size: 1rem;
  color: var(--text);
  margin: 6px 0 10px;
  line-height: 1.55;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.empty-state {
  font-family: "Inter", sans-serif;
  color: var(--text-muted);
  text-align: center;
  padding: 40px 20px;
}

.empty-state a { color: var(--accent); }

/* ---- Entry page ---- */

.entry-page .site-header {
  padding: 20px 0 24px;
}

.breadcrumb {
  font-family: "Inter", sans-serif;
  font-size: 0.9rem;
  margin: 0 0 16px;
}

.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
}

.breadcrumb a:hover { text-decoration: underline; }

.entry-title {
  font-family: "Source Serif 4", Georgia, serif;
  font-weight: 700;
  font-size: 2rem;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0 0 14px;
}

.entry-title .type-icon { font-size: 1.4rem; margin-right: 4px; }

.entry-meta {
  font-family: "Inter", sans-serif;
  font-size: 0.9rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-bottom: 10px;
  align-items: center;
}

.entry-meta .meta-sep { display: inline; opacity: 0.4; }

.meta-ext {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.meta-ext:hover { text-decoration: underline; }

.entry-tags {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.entry-body {
  padding: 30px 20px 60px;
}

.entry-body .section {
  margin-bottom: 36px;
}

.entry-body h2 {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text);
  margin: 0 0 14px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.entry-body p {
  margin: 0 0 14px;
}

.entry-body ul, .entry-body ol {
  margin: 0 0 14px;
  padding-left: 22px;
}

.entry-body li { margin-bottom: 7px; }

.entry-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.entry-body a:hover { color: var(--accent-hover); }

.entry-body strong { font-weight: 600; }

/* Acronyms — click/hover to reveal expansion */
abbr[title] {
  text-decoration: underline dotted;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  cursor: help;
  -webkit-text-decoration-skip: none;
  text-decoration-skip-ink: none;
  position: relative;
}

abbr[title]:hover, abbr[title]:focus, abbr.abbr-open {
  color: var(--accent);
}

/* Mobile/touch popover — shown when abbr has .abbr-open (tapped) */
abbr.abbr-open::after {
  content: attr(title);
  position: absolute;
  left: 0;
  top: calc(100% + 4px);
  background: var(--text);
  color: var(--bg);
  padding: 8px 12px;
  border-radius: 6px;
  font-family: "Inter", -apple-system, sans-serif;
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: normal;
  white-space: normal;
  max-width: min(320px, calc(100vw - 40px));
  width: max-content;
  z-index: 20;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  text-decoration: none;
}

abbr.abbr-open::before {
  content: "";
  position: absolute;
  left: 10px;
  top: calc(100% + 0px);
  border: 4px solid transparent;
  border-bottom-color: var(--text);
  z-index: 21;
}

/* Tables (fact check, resources) */

.entry-body table {
  width: 100%;
  border-collapse: collapse;
  font-family: "Inter", sans-serif;
  font-size: 0.92rem;
  margin: 0 0 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.entry-body th {
  background: var(--surface-alt);
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.entry-body td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.5;
}

.entry-body tr:last-child td { border-bottom: none; }

/* Type-column icon in Related research / resources tables */
.res-type {
  font-size: 1.15rem;
  line-height: 1;
  display: inline-block;
  cursor: help;
}

/* Fact check verdict cells */

.verdict-confirmed {
  background: var(--verdict-confirmed-bg);
  color: var(--verdict-confirmed);
  font-weight: 600;
  white-space: nowrap;
}

.verdict-partial {
  background: var(--verdict-partial-bg);
  color: var(--verdict-partial);
  font-weight: 600;
  white-space: nowrap;
}

.verdict-unverified {
  background: var(--verdict-unverified-bg);
  color: var(--verdict-unverified);
  font-weight: 600;
  white-space: nowrap;
}

.verdict-misleading {
  background: var(--verdict-misleading-bg);
  color: var(--verdict-misleading);
  font-weight: 600;
  white-space: nowrap;
}

.verdict-false {
  background: var(--verdict-false-bg);
  color: var(--verdict-false);
  font-weight: 600;
  white-space: nowrap;
}

/* Full content details */

.section-full details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 18px;
}

.section-full summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.section-full summary::-webkit-details-marker { display: none; }

.section-full summary::before {
  content: "▸";
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: transform 0.15s;
}

.section-full details[open] summary::before {
  transform: rotate(90deg);
}

.section-full summary h2 {
  border-bottom: none;
  padding-bottom: 0;
  margin: 0;
}

.details-hint {
  font-family: "Inter", sans-serif;
  font-size: 0.8rem;
  color: var(--text-subtle);
  font-weight: 400;
}

.section-full details[open] .details-hint { display: none; }

.transcript-disclaimer {
  font-family: "Inter", sans-serif;
  font-size: 0.82rem;
  color: var(--text-subtle);
  margin: 12px 0;
  padding: 8px 12px;
  background: var(--surface-alt);
  border-left: 3px solid var(--border-strong);
  border-radius: 2px;
}

.full-content {
  margin-top: 16px;
  font-size: 0.97rem;
  line-height: 1.7;
  color: var(--text);
  max-height: none;
}

.full-content p {
  margin-bottom: 14px;
}

/* ---- Footer ---- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 0 36px;
  background: var(--surface);
  margin-top: 40px;
}

.site-footer p {
  font-family: "Inter", sans-serif;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
  text-align: center;
}

.site-footer a {
  color: var(--accent);
  text-decoration: none;
}

.site-footer a:hover { text-decoration: underline; }

/* ---- Responsive ---- */

@media (max-width: 640px) {
  body { font-size: 17px; }
  .wordmark { font-size: 1.35rem; }
  .tagline { font-size: 0.86rem; }
  .avatar { width: 56px; height: 56px; }
  .entry-title { font-size: 1.6rem; }
  .entry-body h2 { font-size: 1.2rem; }
  .filter-bar { padding: 12px 0; }
  .filter-group { gap: 5px; }
  .pill { padding: 6px 10px; font-size: 0.82rem; }
  .card-title { font-size: 1.1rem; }
  .entry-body table { font-size: 0.86rem; }
  .entry-body th, .entry-body td { padding: 8px 10px; }
}

@media (min-width: 900px) {
  .filter-bar .wrap {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "types search"
      "tags tags"
      "active active";
    gap: 10px 18px;
    align-items: center;
    max-width: 960px;
  }
  .filter-bar .filter-group:first-of-type { grid-area: types; }
  .filter-bar .filter-search { grid-area: search; }
  .filter-bar .tags-group { grid-area: tags; }
  .filter-active { grid-area: active; }
}

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

/* ── Text-to-speech "Listen" control ─────────────────────────── */
.tts-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 1.1rem;
}
.tts-btn,
.tts-stop {
  font: inherit;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 0.45rem 0.95rem;
  background: var(--surface);
  color: var(--text);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.tts-btn:hover,
.tts-stop:hover { background: var(--chip-bg); border-color: var(--accent); }
.tts-btn[data-state="playing"],
.tts-btn[data-state="paused"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.tts-btn[data-state="playing"]:hover,
.tts-btn[data-state="paused"]:hover { background: var(--accent-hover); }
.tts-icon { font-size: 1rem; }
.tts-stop[hidden] { display: none; }

/* The block currently being read aloud */
.tts-reading {
  background: var(--verdict-partial-bg);
  box-shadow: -0.45rem 0 0 var(--accent);
  border-radius: 2px;
  transition: background 0.2s;
}
