/* forum — hand-written stylesheet, no build step.
   Progressive enhancement: this file is the whole design system. */

:root {
  --bg: #fafaf7;
  --bg-raised: #ffffff;
  --text: #23272b;
  --text-muted: #5f6b76;
  --accent: #1a6b48;      /* deep green — neighborly, calm */
  --accent-contrast: #ffffff;
  --border: #d9dde1;
  --danger: #a3232e;
  --warning: #8a5a00;
  --radius: 6px;
  --content-width: 52rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191c1f;
    --bg-raised: #22262a;
    --text: #e6e4de;
    --text-muted: #9aa4ad;
    --accent: #58b98a;
    --accent-contrast: #10241a;
    --border: #3a4046;
    --danger: #e07b83;
    --warning: #e0a951;
  }
}

* { box-sizing: border-box; }

html { font-size: 100%; }

body {
  margin: 0;
  font-family: Lato, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

/* Layout */
.site-header {
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
}

.site-nav {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem 1rem;
  /* A moderator's nav has 7+ links; wrapping keeps the page from
     scrolling horizontally on phones (WCAG 1.4.10 reflow). */
  flex-wrap: wrap;
}

/* Keyboard users skip the nav; visible only while focused. */
.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--bg-raised);
  color: var(--accent);
  padding: 0.5rem 1rem;
  z-index: 10;
}
.skip-link:focus-visible { left: 0; }

/* Screen-reader-only text (e.g. table headers for action columns). */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.brand {
  font-weight: 700;
  font-size: 1.15rem;
  text-decoration: none;
  color: var(--text);
}

.content {
  flex: 1;
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 1rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 0.75rem 1rem;
}

/* Typography */
h1, h2, h3 { line-height: 1.25; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }

a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }

/* Lists */
.community-list {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.community-list li {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.community-list a {
  display: block;
  padding: 0.75rem 1rem;
  text-decoration: none;
  font-weight: 600;
}

/* Forms — the baseline interface of the whole app */
form { margin: 0; }

label { display: block; font-weight: 600; margin-bottom: 0.25rem; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea,
select {
  width: 100%;
  padding: 0.5rem 0.65rem;
  font: inherit;
  color: inherit;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

textarea { min-height: 8rem; resize: vertical; }

input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button, .button {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  padding: 0.5rem 1rem;
  color: var(--accent-contrast);
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
}

button:hover, .button:hover { filter: brightness(1.08); }

.button-secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

/* Nav */
.nav-spacer { flex: 1; }
.site-nav a { color: var(--text); }

.inline-form { display: inline; }

.button-link {
  background: none;
  border: none;
  /* Padding gives the button a usable touch/click target (bare text is
     well under the 44px WCAG target); the vertical negative margin keeps
     it from growing the line height of the rows it sits in. */
  padding: 0.35rem 0.4rem;
  margin: -0.35rem 0;
  border-radius: 4px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}

/* Vertical form stack */
.stack { display: grid; gap: 0.75rem; max-width: 28rem; }

/* Section (category) administration */
.category-admin-list { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.category-admin-row { padding: 1rem 0; border-bottom: 1px solid var(--border); }
.category-admin-form { max-width: 40rem; }
.category-admin-form label { display: grid; gap: 0.25rem; font-size: 0.9rem; }
.field-row { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.field-row > label { flex: 1 1 12rem; }
.field-row > label.field-narrow { flex: 0 0 6rem; }
.category-admin-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.category-admin-actions .muted { margin-right: auto; }

/* Tables */
/* Wide tables scroll inside their wrapper instead of stretching the
   page (WCAG 1.4.10 reflow on phones). */
.table-wrap { overflow-x: auto; }
.table { border-collapse: collapse; width: 100%; }
.table th, .table td {
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
}
.table th { font-size: 0.85rem; color: var(--text-muted); }

/* Breadcrumb + page head */
.breadcrumb { font-size: 0.85rem; color: var(--text-muted); margin: 0.5rem 0; }
.breadcrumb a { color: var(--text-muted); }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-head-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Category & thread lists */
.category-list, .thread-list {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.category-list li, .thread-list li {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}

.thread-list li.pinned { border-left: 3px solid var(--accent); }

.category-name, .thread-title {
  font-weight: 600;
  text-decoration: none;
  font-size: 1.05rem;
}

.category-list p { margin: 0.25rem 0; }
.thread-meta { font-size: 0.85rem; margin-top: 0.25rem; }
.category-count { font-size: 0.85rem; }

.search-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.search-form input { flex: 1; }
.search-snippet { margin: 0.35rem 0; }
.search-snippet mark {
  background: var(--accent);
  color: var(--bg);
  border-radius: 2px;
  padding: 0 0.15em;
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--accent-contrast);
  background: var(--accent);
  border-radius: 3px;
  padding: 0.1rem 0.4rem;
  vertical-align: middle;
}

/* Posts */
.post-list {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.post {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}

.post-deleted { background: transparent; border-style: dashed; }
.post-deleted .post-body { margin: 0; }

.post-meta {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

.post-meta a { text-decoration: none; }
.post-actions { margin-left: auto; display: flex; align-items: center; gap: 0.85rem; }

/* Post header: avatar on the left, then the meta line (name, bio, time,
   actions) filling the rest of the row on a single line. The divider
   sits under the whole header. */
.post-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
  margin-bottom: 0.5rem;
}
.post-head .post-meta {
  flex: 1;
  min-width: 0;
}
/* Posts without a .post-head (e.g. DM messages) keep the divider on
   their meta line. */
.post > .post-meta {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
  margin-bottom: 0.5rem;
}

/* A profile description shown under someone's name (posts, members
   list, DM views). */
.bio {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}
/* On a post the bio is an inline tagline on the meta line, so it needs
   no block spacing of its own. */
.post .bio { margin: 0; }

/* Round profile pictures. Pixel size comes from the img width/height
   attributes; these rules give the circle, crop and alignment. */
.avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  background: var(--border);
  vertical-align: middle;
}
.avatar-current {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
/* DM conversation heading: avatar beside the name/bio block. */
.dm-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.dm-head h1 { margin: 0; }

.post-body { overflow-wrap: anywhere; }
/* Notes are plain text (no markdown rendering): preserve the author's
   line breaks instead of collapsing them like normal HTML text. */
.note-body { white-space: pre-wrap; }
.post-body img { max-width: 100%; height: auto; }
.post-body pre { overflow-x: auto; padding: 0.5rem; background: var(--bg); border-radius: var(--radius); }
.post-body blockquote {
  margin: 0.5rem 0;
  padding-left: 0.75rem;
  border-left: 3px solid var(--border);
  color: var(--text-muted);
}

/* Moderation */
.mod-bar {
  display: flex;
  gap: 0.5rem;
  margin: 0.5rem 0 1rem;
}

.button-danger { color: var(--danger); border-color: var(--danger); }

.report-list { list-style: none; padding: 0; display: grid; gap: 1rem; }
.report {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}
.report-quote {
  margin: 0.5rem 0;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--border);
  color: var(--text-muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.report-actions { display: flex; gap: 0.5rem; }

/* Dim via the muted color, not opacity — opacity would push the text
   below AA contrast; the danger badge carries the signal anyway. */
.banned-row td { color: var(--text-muted); }
.badge-danger { background: var(--danger); }
.member-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.grant-form { display: inline-flex; gap: 0.3rem; align-items: center; }
.grant-form input[type="number"] { width: 4.5rem; padding: 0.35rem 0.5rem; }

/* Attachment gallery */
.post-attachments {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: flex-start;
  margin-top: 0.5rem;
}

.post-attachments img {
  max-width: 14rem;
  max-height: 10rem;
  width: auto;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  object-fit: cover;
}

.post-file {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  font-size: 0.9rem;
  white-space: nowrap;
}

.post-file:hover {
  background: var(--bg-hover, #f5f5f5);
}

.file-icon {
  flex-shrink: 0;
  opacity: 0.5;
}

.checkbox-row label { display: flex; gap: 0.5rem; align-items: baseline; font-weight: 400; }
.checkbox-row input[type="checkbox"] { width: auto; }

/* Settings sub-nav: switches between the Profile and Notifications
   sub-pages (in-page, deliberately not in the already-crowded top nav). */
.settings-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-top: 1rem;
}
.settings-nav a {
  padding: 0.5rem 0;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
}
.settings-nav a.active,
.settings-nav a[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

/* Settings page: each section is a self-contained card — its own form
   and its own save button — so it's visually obvious that saving one
   block affects only that block. */
.settings-section {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-top: 1.5rem;
}
.settings-section > h2 { margin-top: 0; }

/* Install guide: a collapsible info box in settings explaining how to
   add the site to the home screen on mobile. */
.install-guide {
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.install-guide summary { cursor: pointer; }
.install-guide p { margin: 0.5rem 0 0; }
.install-guide ul { margin: 0.25rem 0 0; padding-left: 1.25rem; }
.install-guide li { margin-bottom: 0.25rem; }

/* Push notification nudge: empty until app.js decides (client-side)
   it's worth htmx-loading; collapses to nothing when empty, so no
   [hidden]/display rule is needed for the pre-content state. */
.push-nudge {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}
.push-nudge:empty { display: none; }
.push-nudge p { margin: 0; flex: 1 1 16rem; }
.push-nudge #push-nudge-dismiss { margin-left: auto; font-size: 1.25rem; text-decoration: none; }

/* Reply + wide forms */
.stack-wide { max-width: none; }
.reply { margin-top: 1.5rem; }
.hint { font-size: 0.8rem; margin: 0.25rem 0 0; }

/* Pagination */
.pagination {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  margin: 1rem 0;
}

/* Utility */
.muted { color: var(--text-muted); }
.error-text { color: var(--danger); }
.success-text { color: var(--accent); }
/* Distinct from .error-text: an incomplete setup (e.g. a notification
   channel not yet enrolled), not a failure. */
.warn-text { color: var(--warning); }

/* Small screens */
@media (max-width: 40rem) {
  h1 { font-size: 1.35rem; }
  .content { padding: 0.75rem; }
}

/* Reactions */
.reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  margin-top: 0.3rem;
  align-items: center;
}
.reaction-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.15rem 0.45rem;
  font-size: 0.82rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 1rem;
  cursor: pointer;
  color: var(--text);
  min-height: 32px;
  min-width: 36px;
  justify-content: center;
}
.reaction-btn:hover {
  border-color: var(--accent);
}
.reaction-active {
  background: color-mix(in srgb, var(--accent) 15%, var(--bg));
  border-color: var(--accent);
  color: var(--accent);
}
.reaction-count {
  font-size: 0.72rem;
  font-weight: 600;
}
.reaction-pick {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  font-size: 0.78rem;
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-muted);
  min-height: 28px;
}
.reaction-pick:hover {
  border-color: var(--accent);
  border-style: solid;
  color: var(--accent);
}
.reactions-expanded .reaction-btn {
  min-height: 36px;
  min-width: 36px;
  font-size: 0.85rem;
}
