/* =============================================================================
   HFTF Reddit Hub — shared design system
   ONE source of truth for the whole hub: the dashboard (:8080) AND the
   Knowledge-Base console (:8092). Every page links this in <head>, then nav.css.
   Dashboard pages load it same-origin (app.css); KB pages load it cross-origin
   from http://localhost:8080/app.css.

   Pages should carry ONLY page-specific rules in their own <style>. Do NOT
   re-declare tokens, body, .wrap, .page-head, .card, .chip, .btn, etc. here.
   The look is HFTF house style: paper ground, Courier Prime, #215de2 accent —
   a calm, text-forward control surface for an internal, agent-operated hub.
   ============================================================================= */

/* --- Design tokens ---------------------------------------------------------- */
:root {
  /* Surfaces & text */
  --paper: #f6f7f9;     /* page ground */
  --card: #ffffff;      /* raised surface */
  --inset: #f8f9fc;     /* recessed surface (wells, code, table heads) */
  --ink: #1a1a1a;       /* primary text */
  --muted: #6b6b6b;     /* secondary text */
  --faint: #9aa0a6;     /* tertiary / disabled */
  --line: #e5e1d8;      /* hairline borders (warm) */
  --line-cool: #e2e5ed; /* hairline on cool/inset surfaces */

  /* Brand */
  --accent: #215de2;
  --accent-ink: #1546ad;   /* hover/active */
  --accent-bg: #eef3fd;    /* tint fill */
  --accent-border: #c9d8f7;

  /* Semantic (status + verdicts share one palette) */
  --ok: #1a7f37;   --ok-bg: #edf7f0;   --ok-border: #a8d5b5;   /* shipped / love / keep / yes */
  --warn: #b7791f; --warn-bg: #fef9ec; --warn-border: #e5c97a; /* building / maybe / scoping */
  --bad: #c0392b;  --bad-bg: #fdeceb;  --bad-border: #f0b3ac;  /* cut / hide / no / parked */
  --neutral: #9ca3af; --neutral-bg: #f3f4f6; --neutral-border: #d1d5db; /* pass / archived / template */

  /* Type */
  --mono: 'Courier Prime', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Radii */
  --r-sm: 6px;
  --r: 8px;
  --r-lg: 10px;
  --pill: 999px;

  /* Elevation (subtle — this is a flat, papery UI) */
  --shadow-sm: 0 1px 2px rgba(20, 23, 28, 0.04);
  --shadow: 0 1px 2px rgba(20, 23, 28, 0.05), 0 2px 6px rgba(20, 23, 28, 0.05);

  /* Motion */
  --t: 0.15s ease;

  /* Layout */
  --wrap: 1120px;
}

/* --- Reset & base ----------------------------------------------------------- */
* { box-sizing: border-box; }
html { scrollbar-gutter: stable; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; }
a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

/* Subreddit links (concept cards, archive, fit map) → reddit.com/r/<name>. Keep the
   surrounding text colour; signal "link" with a dotted underline that solidifies + turns
   accent on hover, so it's clickable without shouting in a muted meta line or a title. */
.sub-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}
.sub-link:hover { color: var(--accent); text-decoration-style: solid; }

/* Visible, consistent focus ring for keyboard users across the whole hub. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}
:focus:not(:focus-visible) { outline: none; }

/* --- Layout shell ----------------------------------------------------------- */
.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 28px 24px 72px;
}
.wrap.wrap--wide { max-width: 1200px; }
.wrap.wrap--narrow { max-width: 920px; }

/* --- Page header (shared by every page) ------------------------------------- */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 14px;
  margin-bottom: 22px;
}
.page-head h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.page-head .dot { color: var(--accent); }   /* the ▣ glyph */
.page-head .page-sub {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 13px;
  margin: 8px 0 0;
  max-width: 78ch;
}
.head-right {
  display: flex;
  align-items: center;
  gap: 14px;
}
.updated {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

/* Back-to-section eyebrow — sits above the h1 inside .page-head (e.g. "‹ Knowledge Base"
   on the KB sub-pages). Signals where a leaf page lives and offers a one-click return. */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
}
.eyebrow:hover { color: var(--accent); text-decoration: none; }
.page-head .eyebrow { flex-basis: 100%; margin-bottom: 5px; }

/* Section label — small, tracked, muted (the recurring "h2" across pages). */
.section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin: 30px 0 12px;
}

/* --- Toolbar (filters / sort / search) -------------------------------------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-bottom: 20px;
}
.filter-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.filter-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-right: 2px;
}

/* --- Chips (filter / sort toggles) ------------------------------------------ */
.chip {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--pill);
  padding: 5px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t), border-color var(--t), color var(--t);
}
.chip:hover { background: var(--inset); border-color: var(--neutral); }
.chip[aria-pressed='true'] {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

/* --- Search input ----------------------------------------------------------- */
.search {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 6px 11px;
  outline: none;
  transition: border-color var(--t);
}
.search:focus { border-color: var(--accent); }
.search::placeholder { color: var(--faint); }

/* --- Buttons ---------------------------------------------------------------- */
.btn,
.btn-outline,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  padding: 8px 14px;
  border-radius: var(--r);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--t), border-color var(--t), color var(--t);
}
.btn { background: var(--accent); color: #fff; }
.btn:hover { background: var(--accent-ink); text-decoration: none; }
.btn-outline { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-outline:hover { background: var(--accent); color: #fff; text-decoration: none; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--ink); color: var(--paper); text-decoration: none; }
.btn-sm { padding: 5px 11px; font-size: 12px; }

/* --- Cards ------------------------------------------------------------------ */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 16px; }

/* A card that is the whole click target (launchpad / project tiles). */
.card-link {
  display: flex;
  flex-direction: column;
  color: inherit;
  text-decoration: none;
  transition: border-color var(--t), box-shadow var(--t), transform var(--t);
}
.card-link:hover {
  text-decoration: none;
  border-color: var(--accent-border);
  box-shadow: var(--shadow);
}

/* --- Pills & badges --------------------------------------------------------- */
.pill {
  display: inline-block;
  flex: none;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #fff;
  background: var(--neutral);
  border-radius: var(--pill);
  padding: 3px 9px;
  white-space: nowrap;
}
.badge {
  display: inline-block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--pill);
  padding: 2px 8px;
  white-space: nowrap;
}
.tag {
  font-size: 11px;
  color: var(--muted);
  background: var(--inset);
  border: 1px solid var(--line-cool);
  border-radius: 5px;
  padding: 2px 8px;
}

/* --- Meta text -------------------------------------------------------------- */
.meta {
  color: var(--muted);
  font-size: 12px;
  word-break: break-word;
}
.meta b { color: var(--ink); font-weight: 600; }
code,
.code {
  font-family: var(--mono);
  background: var(--inset);
  border: 1px solid var(--line-cool);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.92em;
}

/* --- Stat tiles (summary rows / counts) ------------------------------------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
.stat {
  background: var(--card);
  padding: 14px 16px;
}
.stat .num {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.stat .lbl {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
}

/* --- Empty state ------------------------------------------------------------ */
.empty {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 56px 16px;
}
.empty code { font-size: 12px; }

/* --- Data table (why-reddit comparison etc.) -------------------------------- */
table.data {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
table.data th,
table.data td {
  padding: 9px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
table.data thead th {
  background: var(--inset);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
table.data tr:last-child td { border-bottom: 0; }

/* --- Footer ----------------------------------------------------------------- */
.page-foot {
  margin-top: 44px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
}

/* --- Semantic helpers (status text / fills) --------------------------------- */
.is-ok { color: var(--ok); }
.is-warn { color: var(--warn); }
.is-bad { color: var(--bad); }
.is-muted { color: var(--muted); }

/* --- Responsive ------------------------------------------------------------- */
@media (max-width: 560px) {
  .wrap { padding: 18px 14px 56px; }
  .page-head { margin-bottom: 16px; }
  .page-head h1 { font-size: 18px; }
  .toolbar { gap: 8px 12px; }
}

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