/* AMFT Outlier Viewer — dark theme matching dashboard aesthetic */

:root {
  --bg-0:        #0f1115;
  --bg-1:        #161922;
  --bg-2:        #1d2230;
  --bg-3:        #252a39;
  --border:      #2a3043;
  --text-0:      #e7e9ee;
  --text-1:      #a8aebd;
  --text-2:      #6b7184;
  --accent:      #c69b6d;   /* warm beige - AMFT brand */
  --accent-2:    #d4a878;
  --hot:         #e85d5d;   /* high-score badge */
  --warm:        #f0a868;   /* mid-score badge */
  --cool:        #6ba0c4;   /* low-score / ica badge */
  --ok:          #6dcc9d;
  --shadow:      0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.5);
  --radius:      8px;
  --radius-lg:   12px;
  --gap:         16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--text-0);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* ── Top bar ──────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: baseline; gap: 12px; }
.brand-mark {
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--accent);
  padding: 4px 8px;
  background: rgba(198,155,109,0.1);
  border: 1px solid rgba(198,155,109,0.3);
  border-radius: 4px;
}
.brand-title { font-size: 18px; font-weight: 600; }
.topbar-nav { display: flex; gap: 14px; align-items: center; }
.nav-link, .nav-btn {
  color: var(--text-1);
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.nav-link:hover, .nav-btn:hover { color: var(--text-0); border-color: var(--accent); text-decoration: none; }

/* ── Explainer ────────────────────────────────────────────────────── */
.explainer { padding: 16px 24px 0; }
.explainer details {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-1);
}
.explainer summary { cursor: pointer; color: var(--text-0); list-style: none; }
.explainer summary::-webkit-details-marker { display: none; }
.explainer summary::before { content: "▸ "; color: var(--accent); }
.explainer details[open] summary::before { content: "▾ "; }
.explainer p, .explainer ul { margin: 8px 0; }
.explainer li { margin: 4px 0; }
.explainer strong { color: var(--text-0); }

/* ── Filters ──────────────────────────────────────────────────────── */
.filters {
  padding: 16px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}
.filter-group { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-group label {
  display: flex;
  flex-direction: column;
  font-size: 11px;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.filter-group select, .filter-group input {
  background: var(--bg-2);
  color: var(--text-0);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  min-width: 130px;
  margin-top: 4px;
}
.filter-group select:focus, .filter-group input:focus { outline: none; border-color: var(--accent); }
.filter-summary {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-2);
}

/* ── Card grid ────────────────────────────────────────────────────── */
.grid {
  padding: 8px 24px 40px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}
.loading { color: var(--text-2); padding: 40px; text-align: center; grid-column: 1 / -1; }
.empty { color: var(--text-2); padding: 40px; text-align: center; grid-column: 1 / -1; }

.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
}
.card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
}
.card-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg-2);
  position: relative;
  overflow: hidden;
}
.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.card-badges {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px;
  pointer-events: none;
  flex-wrap: wrap;
}
.badge {
  display: inline-block;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
  background: rgba(15,17,21,0.92);
  color: var(--text-0);
  backdrop-filter: blur(10px);
  letter-spacing: 0.05em;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.badge-score { color: var(--text-0); }
.badge-score.hot { background: var(--hot); }
.badge-score.warm { background: var(--warm); color: #1a1209; }
.badge-score.cool { background: var(--bg-2); color: var(--text-1); }
.badge-tier { background: rgba(15,17,21,0.85); color: var(--accent); }
.badge-tier.lightweight { color: var(--text-2); }
.badge-tier.transcript_blocked { color: var(--hot); background: rgba(232,93,93,0.2); }

.card-body { padding: 14px 16px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.card-channel {
  font-size: 11px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-0);
  line-height: 1.35;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta {
  margin-top: auto;
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-2);
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.card-meta-item { display: flex; align-items: center; gap: 4px; }
.card-meta-item strong { color: var(--text-1); }
.ica-pill {
  background: var(--cool);
  color: #0f1115;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 700;
  font-size: 11px;
}
.ica-pill.high { background: var(--ok); }
.ica-pill.med { background: var(--warm); color: #1a1209; }
.ica-pill.low { background: var(--bg-3); color: var(--text-2); }

/* ── Modal ────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  z-index: 100;
  overflow-y: auto;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 900px;
  width: 100%;
  position: relative;
  box-shadow: var(--shadow-lg);
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-0);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { background: var(--bg-3); border-color: var(--accent); }
.modal-body { padding: 24px; }
.modal-body h2 { margin: 0 0 8px; font-size: 22px; }
.modal-body h3 { margin: 24px 0 8px; font-size: 14px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.08em; }
.modal-body p { margin: 8px 0; line-height: 1.6; color: var(--text-1); }
.modal-body img { max-width: 100%; border-radius: var(--radius); }
.modal-body .modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}
.modal-body .modal-meta .badge { background: var(--bg-2); padding: 6px 10px; }
.modal-body .quote {
  background: var(--bg-2);
  border-left: 3px solid var(--accent);
  padding: 12px 16px;
  margin: 12px 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-0);
  white-space: pre-wrap;
}
.modal-body .external-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 16px 0;
}
.modal-body .external-links a {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  font-size: 13px;
}
.modal-body .external-links a:hover { background: rgba(198,155,109,0.1); text-decoration: none; }

/* ── Doc iframe + teleprompter view ─────────────────────────────── */
.doc-iframe {
  width: 100%;
  height: 600px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-0);
  margin-top: 12px;
}
.teleprompter {
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-top: 12px;
  max-height: 600px;
  overflow-y: auto;
  font-size: 16px;
  line-height: 1.8;
  color: var(--text-0);
  font-family: Georgia, "Times New Roman", serif;
  white-space: pre-wrap;
}
.teleprompter::-webkit-scrollbar { width: 12px; }
.teleprompter::-webkit-scrollbar-track { background: var(--bg-1); }
.teleprompter::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 6px; border: 2px solid var(--bg-1); }
.tab-bar {
  display: flex;
  gap: 4px;
  margin-top: 16px;
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  background: none;
  color: var(--text-1);
  border: none;
  padding: 10px 16px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text-0); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Side-by-side comparison */
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 12px 0;
}
.compare-col {
  background: var(--bg-2);
  border-left: 3px solid var(--accent);
  padding: 14px 16px;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.compare-col.outlier { border-left-color: var(--cool); }
.compare-col.david { border-left-color: var(--accent); }
.compare-col h4 {
  margin: 0 0 8px;
  font-size: 11px;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.compare-col p { margin: 0; font-size: 13px; color: var(--text-0); line-height: 1.6; }
@media (max-width: 700px) {
  .compare-grid { grid-template-columns: 1fr; }
}

/* Outline list */
.outline-list {
  list-style: none;
  padding: 0;
  margin: 8px 0;
  counter-reset: outline;
}
.outline-list li {
  counter-increment: outline;
  padding: 10px 12px 10px 36px;
  margin: 6px 0;
  background: var(--bg-2);
  border-radius: var(--radius);
  position: relative;
  color: var(--text-0);
  font-size: 14px;
  line-height: 1.5;
}
.outline-list li::before {
  content: counter(outline);
  position: absolute;
  left: 10px;
  top: 10px;
  width: 20px;
  height: 20px;
  background: var(--accent);
  color: var(--bg-0);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Footer ───────────────────────────────────────────────────────── */
.footer {
  padding: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--text-2);
  border-top: 1px solid var(--border);
}

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .topbar { padding: 12px 16px; }
  .filters, .explainer, .grid { padding-left: 16px; padding-right: 16px; }
  .grid { grid-template-columns: 1fr; }
  .filter-group { width: 100%; }
  .filter-group label { flex: 1; min-width: 0; }
}
