/*
  Palette and shape mirror the mobile app (EireneApp/src/utils/colors.js) so a
  shared link feels like the same product.

  Note there are no inline styles anywhere in the templates: the pages' CSP
  sets style-src 'self' without 'unsafe-inline', which blocks style attributes
  as well as <style> blocks. Anything dynamic (comment indentation) is a class.
*/

:root {
  --bg: #0D1117;
  --section: #111820;
  --card: #161B22;
  --border: #30363D;
  --primary: #58A6FF;
  --green: #3FB950;
  --red: #F85149;
  --text: #E6EDF3;
  --muted: #8B949E;
  --dim: #484F58;
  --radius: 12px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  /* Bottom padding clears the sticky app CTA. */
  padding-bottom: 96px;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

/* ── chrome ─────────────────────────────────────────────────────────────── */

header.site {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--section);
}

.brand { font-weight: 800; letter-spacing: 2px; color: var(--text); }
.brand:hover { text-decoration: none; color: var(--primary); }
.site-nav a { font-size: 13px; font-weight: 600; }

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

.site-footer {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}

.site-footer p { margin: 4px 0; }

/* ── shared ─────────────────────────────────────────────────────────────── */

.card {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  color: inherit;
}

a.card:hover { border-color: var(--primary); text-decoration: none; }

.meta { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; }
.dot { color: var(--dim); }
.dim { color: var(--muted); }
.edited { font-style: italic; }

.section-title { font-size: 14px; font-weight: 700; color: var(--muted); margin: 24px 0 10px; }
.page-title { font-size: 22px; margin: 0 0 12px; }
.empty { color: var(--muted); font-size: 14px; padding: 12px 0; }

/* User-authored text. pre-wrap preserves the author's line breaks without
   converting anything to markup — the templates never emit raw HTML. The one
   element inside is a.mention, built from template markup by partials/body.html
   (never from a raw-HTML helper). */
.body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 10px 0;
  font-size: 15px;
}

/* @handle tags. Weighted rather than colored differently so a body full of
   tags doesn't read as a wall of links. */
.body .mention { font-weight: 600; }

.snippet {
  color: var(--muted);
  font-size: 14px;
  margin: 6px 0;
  overflow-wrap: anywhere;
}

.linkout { display: block; font-size: 13px; margin: 8px 0; overflow-wrap: anywhere; }

.chip {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--section);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.chip:hover { border-color: var(--primary); text-decoration: none; }
.chip.on { border-color: var(--primary); color: var(--primary); }

.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.pill {
  display: inline-block;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  color: var(--muted);
}
.pill.bill { border-color: #BC8CFF44; color: #BC8CFF; }

.score { font-weight: 700; }
.stats { font-size: 13px; color: var(--muted); display: flex; gap: 6px; margin: 8px 0; }

/* ── post card ──────────────────────────────────────────────────────────── */

.post { display: flex; gap: 12px; }
.gutter {
  flex: 0 0 44px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 2px;
  color: var(--muted);
  font-size: 13px;
}
.post-body { min-width: 0; flex: 1; }
.post-title { font-size: 16px; line-height: 1.35; margin: 6px 0; }
.post-title a { color: var(--text); }
.post-title a:hover { color: var(--primary); }

.thumb { position: relative; display: block; margin-top: 10px; }
.thumb img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 320px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.more-media {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 8px;
  border-radius: 8px;
  background: rgba(13, 17, 23, 0.85);
  font-size: 12px;
  font-weight: 700;
}

/* ── thread ─────────────────────────────────────────────────────────────── */

.thread-title { font-size: 22px; line-height: 1.3; margin: 8px 0; }

.media { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.media-item {
  display: block;
  width: 100%;
  height: auto;
  max-height: 420px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.media-item.video {
  padding: 22px;
  text-align: center;
  font-weight: 600;
  background: var(--section);
}

.billcard {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-color: #BC8CFF44;
  background: #BC8CFF11;
}
.billcard-label { font-weight: 700; color: #BC8CFF; font-size: 13px; }
.billcard-cta { font-size: 12px; color: var(--muted); }

/* ── comments ───────────────────────────────────────────────────────────── */

.comment {
  border-left: 2px solid var(--border);
  padding: 10px 0 2px 12px;
  margin-top: 10px;
}
.comment .body { font-size: 14px; margin: 6px 0; }

/* Indentation classes. tree.go clamps Depth to 0-5, so exactly these exist. */
.d0 { margin-left: 0; }
.d1 { margin-left: 12px; }
.d2 { margin-left: 24px; }
.d3 { margin-left: 36px; }
.d4 { margin-left: 48px; }
.d5 { margin-left: 60px; }

.truncated {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13px;
}

/* ── home / listings ────────────────────────────────────────────────────── */

.hero { padding: 8px 0 16px; }
.hero h1 { font-size: 26px; line-height: 1.25; margin: 0 0 8px; }
.hero p { color: var(--muted); font-size: 15px; margin: 0; }

.community-strip { display: flex; flex-wrap: wrap; gap: 8px; }
.community-row h2 { font-size: 16px; margin: 0 0 4px; }
.handle { color: var(--muted); font-size: 13px; margin: 2px 0; }
.bio { margin: 10px 0 0; overflow-wrap: anywhere; }

.sorts { display: flex; gap: 8px; margin: 4px 0 14px; }
.pager { display: flex; gap: 8px; justify-content: space-between; margin-top: 16px; }

/* ── profile ────────────────────────────────────────────────────────────── */

.profile-header { text-align: center; }
.profile-header h1 { font-size: 22px; margin: 10px 0 2px; }
.avatar {
  width: 84px;
  height: 84px;
  margin: 0 auto;
  border-radius: 50%;
  background: var(--section);
  border: 1px solid var(--border);
  color: var(--primary);
  font-size: 34px;
  font-weight: 800;
  line-height: 84px;
}
.avatar-img { object-fit: cover; display: block; }
.pubkey { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--dim); overflow-wrap: anywhere; }
.stat-row { display: flex; justify-content: center; gap: 20px; margin-top: 14px; font-size: 13px; color: var(--muted); }
.stat-row strong { color: var(--text); }

/* ── error ──────────────────────────────────────────────────────────────── */

.error-page { text-align: center; padding: 40px 20px; }
.error-code { font-size: 44px; font-weight: 800; color: var(--dim); margin: 0; }
.error-page h1 { font-size: 20px; margin: 6px 0 10px; }

/* ── app CTA ────────────────────────────────────────────────────────────── */

.appcta {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: var(--section);
  border-top: 1px solid var(--border);
}
.appcta-text { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); }
.appcta-text strong { color: var(--text); }

.btn {
  flex: none;
  padding: 10px 18px;
  border-radius: 24px;
  background: var(--primary);
  color: #0D1117;
  font-weight: 700;
  font-size: 14px;
}
.btn:hover { text-decoration: none; opacity: 0.9; }

@media (max-width: 520px) {
  .appcta { padding: 10px 14px; }
  .appcta-text span { display: none; }
  .thread-title { font-size: 19px; }
  .hero h1 { font-size: 22px; }
}
