/* ---------------------------------------------------------------------------
   TTPwire — design system
   ----------------------------------------------------------------------------
   Editorial newswire feel with a cyber-research edge. Cream paper background,
   near-black ink, a single hot accent, and three carefully chosen typeface
   roles:
     • Serif (newsroom)        → headlines, masthead
     • Sans  (system stack)    → body, UI
     • Mono  (system stack)    → technique IDs, metadata, codes

   Type comes from system stacks — no Google Fonts dependency, instant load,
   privacy-friendly. The serif uses the Iowan/Charter family which ships on
   modern macOS / iOS and falls back to Charter / Cambria / Georgia.

   No JS framework, no utility-class soup — just hand-written CSS.
--------------------------------------------------------------------------- */

:root {
  --paper:       #FBF8F1;   /* cream — body bg */
  --paper-edge:  #F2EDE2;   /* subtle off-paper for cards / footer */
  --surface:     #FFFFFF;   /* "elevated" surface — picker, inputs, lists */
  --ink:         #15110D;   /* nearly black, warm */
  --ink-soft:    #4A4540;   /* secondary text */
  --ink-mute:    #8B847C;   /* tertiary */
  --rule:        #DCD5C7;   /* hairlines */
  --accent:      #C0392B;   /* punchy newsroom red */
  --accent-ink:  #FFFFFF;
  --accent-soft: #F8E5E1;
  --highlight:   #FFE9A8;   /* yellow marker */
  --good:        #2D6A4F;
  --warn:        #C77700;
  --bad:         #C0392B;

  --serif:  "Iowan Old Style", "Charter", "Cambria", "Georgia", "Times New Roman", serif;
  --sans:   ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono:   ui-monospace, "SF Mono", "Menlo", "Cascadia Mono", "JetBrains Mono", "Fira Mono", "Roboto Mono", "DejaVu Sans Mono", monospace;

  --radius:  4px;
  --gutter:  clamp(16px, 4vw, 32px);
  --max:     1180px;

  --shadow-sm: 0 1px 0 rgba(21, 17, 13, 0.04);
  --shadow:    0 1px 2px rgba(21, 17, 13, 0.06), 0 8px 24px -16px rgba(21, 17, 13, 0.16);
}

@media (prefers-color-scheme: dark) {
  /* Only kicks in if the OS asks. Editorial design holds up well. */
  :root {
    --paper:       #15110D;
    --paper-edge:  #1B1612;
    --surface:     #221C16;
    --ink:         #F1ECE0;
    --ink-soft:    #BDB6AB;
    --ink-mute:    #79726A;
    --rule:        #2A241E;
    --accent:      #E66457;
    --accent-soft: #2A1916;
    --highlight:   #5F4A1C;
  }
}

/* -------- reset -------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 32px 0; }

body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; }
a:hover { color: var(--accent); text-decoration-color: var(--accent); }

/* -------- masthead -------- */
.masthead {
  border-bottom: 2px solid var(--ink);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 50;
}
.masthead-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 14px var(--gutter);
  display: flex;
  align-items: baseline;
  gap: 24px;
}
.wordmark {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--ink);
  display: inline-flex;
  align-items: baseline;
}
.wordmark::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  margin-left: 4px;
  margin-bottom: 3px;
  align-self: center;
}
.wordmark .wordmark-tail {
  font-style: italic;
  font-weight: 400;
  color: var(--ink-soft);
}
.masthead-tag {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
  margin-left: auto;
  align-self: center;
}
.masthead nav { display: flex; gap: 18px; align-self: center; }
.masthead nav a {
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  padding: 6px 0;
  border-bottom: 2px solid transparent;
}
.masthead nav a:hover { border-bottom-color: var(--accent); color: var(--accent); }

@media (max-width: 640px) {
  .masthead-tag { display: none; }
  .wordmark { font-size: 22px; }
}

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }
main { padding: 48px 0 96px; min-height: 70vh; }

/* -------- typography -------- */
h1, h2, h3, h4 {
  font-family: var(--serif);
  letter-spacing: -0.01em;
  line-height: 1.18;
  margin: 0 0 0.4em;
  font-weight: 700;
}
h1 { font-size: clamp(34px, 4vw, 52px); }
h2 { font-size: clamp(24px, 2.4vw, 30px); margin-top: 2em; }
h3 { font-size: 20px; margin-top: 1.4em; }
p  { margin: 0 0 1em; }
small, .small { font-size: 12.5px; color: var(--ink-soft); }
.muted { color: var(--ink-mute); }
.kicker {
  font-family: var(--mono);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--accent);
  font-weight: 600;
  display: inline-block;
  margin-bottom: 8px;
}

code, pre, .mono { font-family: var(--mono); }
code { background: var(--paper-edge); padding: 1px 5px; border-radius: 3px; font-size: 0.92em; }

::selection { background: var(--highlight); color: var(--ink); }

/* -------- hero (landing) -------- */
.hero {
  border-bottom: 1px solid var(--rule);
  padding-bottom: 48px;
  margin-bottom: 32px;
}
.hero--single { max-width: 38em; }
.hero h1 { margin-bottom: 0.3em; }
.hero p.lede {
  font-family: var(--serif);
  font-size: clamp(18px, 1.5vw, 22px);
  color: var(--ink-soft);
  line-height: 1.45;
  max-width: 36em;
}
.cta-row { margin-top: 28px; display: flex; gap: 14px; flex-wrap: wrap; }

/* "Trending — last 24h" strip on the landing page. Sits between the hero
   and the article list, gives instant signal that the wire is alive
   without resorting to a "stats" panel. */
.trending {
  margin: 32px 0 48px;
  padding: 18px 20px;
  background: var(--paper-edge);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.trending-label { display: block; margin-bottom: 10px; }
.trending-pills { display: flex; flex-wrap: wrap; gap: 6px 6px; }
.trending-pills .tag.big { font-size: 13.5px; padding: 6px 12px; background: var(--surface); }

/* -------- buttons -------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: var(--radius);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.05s ease, box-shadow 0.15s ease, background 0.15s ease;
  line-height: 1;
  white-space: nowrap;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn.ghost { border-color: var(--rule); }
.btn.ghost:hover { background: var(--paper-edge); color: var(--ink); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.btn-arrow::after { content: "→"; font-family: var(--mono); margin-left: 4px; }

/* -------- explainer (landing how-it-works) -------- */
.explainer {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 32px;
  margin: 48px 0;
}
.explainer .step .num {
  font-family: var(--serif);
  font-size: 36px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  display: inline-block;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 4px;
  margin-bottom: 12px;
}
.explainer h3 { margin: 0 0 6px; font-size: 17px; }
.explainer p  { margin: 0; font-size: 14px; color: var(--ink-soft); }
@media (max-width: 800px) { .explainer { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .explainer { grid-template-columns: 1fr; } }

/* -------- article cards / list -------- */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-top: 2px solid var(--ink);
  padding-top: 16px;
  margin: 48px 0 24px;
}
.section-head h2 { margin: 0; font-size: 24px; }
.section-head .meta {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-mute);
}

.article-list { list-style: none; padding: 0; margin: 0; }
.article-list li { padding: 22px 0; border-bottom: 1px solid var(--rule); display: grid; grid-template-columns: 1fr auto; gap: 12px 32px; align-items: start; }
.article-list li:last-child { border-bottom: 0; }
.article-list .title-line a {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  text-decoration: none;
  line-height: 1.3;
  color: var(--ink);
}
.article-list .title-line a:hover { color: var(--accent); text-decoration: underline; text-decoration-thickness: 2px; }
.article-list .source-line {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-mute);
  margin-top: 8px;
}
.article-list .source-line .feed { color: var(--accent); font-weight: 600; }
.article-list .tags { margin-top: 8px; }
.article-list .when {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-mute);
  white-space: nowrap;
  text-align: right;
  align-self: start;
}

/* -------- technique tag chip -------- */
.tag {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 2px 8px 3px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink);
  margin: 2px 4px 2px 0;
  text-decoration: none;
}
.tag:hover { border-color: var(--accent); color: var(--accent); }
.tag .score { color: var(--ink-mute); font-size: 10.5px; }
.tag.big { font-size: 13px; padding: 4px 10px 5px; }

/* -------- article detail page -------- */
.article-detail header { border-bottom: 1px solid var(--rule); padding-bottom: 24px; margin-bottom: 32px; }
.article-detail h1 { font-size: clamp(28px, 3.4vw, 42px); margin: 8px 0 12px; }
.article-detail .meta {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-mute);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.article-detail .meta a { color: var(--accent); }

.classification-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 16px 0 24px;
}
.classification-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  background: var(--paper-edge);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
}
.classification-row .id   { font-family: var(--mono); font-weight: 600; }
.classification-row .name { color: var(--ink-soft); margin-left: 8px; }
.classification-row .score-bar {
  position: relative;
  width: 140px;
  height: 6px;
  background: var(--rule);
  border-radius: 3px;
  overflow: hidden;
  margin-left: auto;
}
.classification-row .score-bar > span { position: absolute; inset: 0 auto 0 0; background: var(--accent); }
.classification-row .score-num { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); margin-left: 12px; }
.classification-row .chunk-snippet { color: var(--ink-mute); font-size: 12.5px; line-height: 1.5; margin-top: 6px; grid-column: 1 / -1; font-family: var(--mono); }
.classification-row .actions { grid-column: 1 / -1; padding-top: 8px; border-top: 1px dashed var(--rule); margin-top: 6px; display: flex; gap: 8px; align-items: center; }
.classification-row form.inline { display: inline; }

/* "Mark wrong" expanded panel: lives inside the classification row, lets
   the user pick the *correct* techniques + leave a note. Submits as a
   single POST with repeated proposed_techniques form values. */
.feedback-panel {
  grid-column: 1 / -1;
  padding: 14px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  margin-top: 8px;
}
.feedback-prompt { margin: 0 0 10px; font-size: 13.5px; color: var(--ink-soft); }
.feedback-search input {
  width: 100%;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 14px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  margin-bottom: 10px;
}
.feedback-search input:focus { outline: 0; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.18); }
.feedback-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.feedback-chips .chip-x {
  background: transparent; border: 0; cursor: pointer; color: var(--ink-mute);
  font-size: 16px; line-height: 1; padding: 0 0 0 6px;
}
.feedback-chips .chip-x:hover { color: var(--accent); }

.feedback-list {
  list-style: none; padding: 0; margin: 0 0 12px; max-height: 280px; overflow-y: auto;
  border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface);
}
.feedback-list li {
  display: grid; grid-template-columns: 86px auto 1fr; gap: 10px; padding: 9px 12px;
  border-bottom: 1px solid var(--rule); cursor: pointer; align-items: baseline;
}
.feedback-list li:last-child { border-bottom: 0; }
.feedback-list li:hover { background: var(--paper-edge); }
.feedback-list li.active { background: var(--accent-soft); }
.feedback-list .id { font-family: var(--mono); font-weight: 600; font-size: 13px; }
.feedback-list .name { font-weight: 600; font-size: 13.5px; }
.feedback-list .desc {
  color: var(--ink-soft); font-size: 12.5px;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}

.feedback-note {
  width: 100%;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 13.5px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  resize: vertical;
  min-height: 60px;
  margin-bottom: 10px;
}
.feedback-note:focus { outline: 0; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.18); }
.feedback-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Inline confirmation / error states after a fetch-based feedback submit.
   Replaces the row's action bar — no page navigation. */
.feedback-confirm, .feedback-error {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  font-size: 13px;
  color: var(--ink);
}
.feedback-confirm .feedback-confirm-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--good); color: #fff; font-size: 13px; font-weight: 700;
}
.feedback-error { color: var(--bad); }

/* -------- forms -------- */
.form-page { max-width: 860px; }
.form-page > header { border-bottom: 1px solid var(--rule); padding-bottom: 24px; margin-bottom: 32px; }
.form-page h1 { margin: 0 0 8px; }
.form-page .lede { font-family: var(--serif); font-size: 19px; color: var(--ink-soft); line-height: 1.45; max-width: 36em; }

.field { margin: 24px 0; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field .hint { display: block; color: var(--ink-mute); font-size: 12.5px; margin-top: 6px; }
.field input[type="email"],
.field input[type="text"],
.field input[type="search"],
.field select,
.field textarea {
  width: 100%;
  padding: 11px 14px;
  font-family: var(--sans);
  font-size: 15px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 0;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.18);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 600px) { .field-row { grid-template-columns: 1fr; } }

.error {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-left-width: 4px;
  color: #6E1A11;
  padding: 12px 14px;
  border-radius: var(--radius);
  margin: 16px 0;
  font-size: 14px;
}

/* -------- technique picker (subscribe) -------- */
.picker {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  margin-top: 8px;
  overflow: hidden;
}
.picker-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper-edge);
  flex-wrap: wrap;
}
.picker-search {
  flex: 1 1 280px;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 6px 10px;
}
.picker-search input {
  border: 0;
  outline: 0;
  flex: 1;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
}
.picker-search::before {
  content: "⌕";
  color: var(--ink-mute);
  margin-right: 8px;
  font-size: 16px;
}
.picker-stat {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.picker-tactics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--rule);
}
.picker-tactic {
  font-family: var(--mono);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.1s ease, border-color 0.1s ease;
}
.picker-tactic:hover { border-color: var(--ink); }
.picker-tactic[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.picker-list { max-height: 480px; overflow-y: auto; }
.picker-row {
  display: grid;
  grid-template-columns: 32px auto 1fr;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--rule);
  align-items: start;
  cursor: pointer;
}
.picker-row:hover { background: var(--paper-edge); }
.picker-row input[type="checkbox"] { margin-top: 4px; transform: scale(1.15); accent-color: var(--accent); }
.picker-row .id { font-family: var(--mono); font-weight: 600; font-size: 13px; min-width: 86px; }
.picker-row .id.subtech { color: var(--ink-soft); padding-left: 12px; position: relative; }
.picker-row .id.subtech::before { content: "└"; position: absolute; left: 0; color: var(--ink-mute); }
.picker-row .body { min-width: 0; }
.picker-row .name { font-weight: 600; font-size: 14px; line-height: 1.35; }
.picker-row .desc { color: var(--ink-soft); font-size: 12.5px; line-height: 1.4; margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.picker-row .tactic-badges { margin-top: 4px; }
.picker-row .tactic-badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-mute);
  margin-right: 6px;
}
.picker-row.is-checked { background: var(--accent-soft); }
.picker-row.is-checked:hover { background: var(--accent-soft); }
.picker-empty { padding: 28px; text-align: center; color: var(--ink-mute); font-size: 14px; }

.picker-actions {
  padding: 10px 12px;
  border-top: 1px solid var(--rule);
  background: var(--paper-edge);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--ink-soft);
  flex-wrap: wrap;
}
.picker-actions a { font-size: 12.5px; color: var(--accent); }

.firehose-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
  background: var(--paper-edge);
  margin-top: 16px;
}
.firehose-toggle input[type="checkbox"] { transform: scale(1.2); accent-color: var(--accent); }
.firehose-toggle .label { font-weight: 600; font-size: 14px; }
.firehose-toggle .hint { display: block; color: var(--ink-soft); font-size: 12.5px; margin-top: 2px; }

/* -------- empty state -------- */
.empty-card {
  border: 1px dashed var(--rule);
  background: var(--paper-edge);
  padding: 32px 24px;
  border-radius: var(--radius);
  text-align: center;
  color: var(--ink-soft);
}
.empty-card p { margin: 0 0 6px; }

/* -------- data table -------- */
table.data {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 24px;
  font-size: 13.5px;
}
table.data th, table.data td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.data th { font-family: var(--mono); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-mute); border-bottom-width: 2px; border-color: var(--ink); }
table.data tbody tr:hover { background: var(--paper-edge); }
table.data .num { font-family: var(--mono); text-align: right; }

/* -------- footer -------- */
.site-footer {
  border-top: 2px solid var(--ink);
  margin-top: 96px;
  padding: 32px 0 64px;
  background: var(--paper-edge);
  font-size: 13px;
  color: var(--ink-soft);
}
.site-footer .wrap { display: grid; grid-template-columns: 1fr auto; gap: 24px; }
.site-footer .colophon { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-mute); }
.site-footer .colophon span::before { content: "·"; margin: 0 8px; color: var(--ink-mute); }
.site-footer .colophon span:first-child::before { content: ""; margin: 0; }

/* -------- accessibility helpers -------- */
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 16px; top: 16px; background: var(--ink); color: var(--paper); padding: 8px 12px; z-index: 100; }
