/* Site styles. One typeface (Bricolage Grotesque, self-hosted), one accent green.
   The text-message bubble is the only rounded, playful shape; everything else stays plain. */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #ffffff;
  --mist: #edf3f0;
  --ink: #17332b;
  --muted: #4e635b;
  --rule: #d3ddd8;
  --field: #6f8a7f;
  --green: #187a50;
  --green-deep: #0f5c3b;
  --bubble-in: #e1e9e5;
  --danger: #b3261e;
  --font: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.65;
}

a { color: var(--green); text-underline-offset: 0.2em; }
a:hover { color: var(--green-deep); }

:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

h1, h2, h3 { line-height: 1.15; letter-spacing: -0.015em; }

.wrap {
  width: 100%;
  max-width: 68rem;
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2rem);
}

.muted { color: var(--muted); }

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  padding: 0.6rem 1rem;
  background: var(--ink);
  color: #fff;
  z-index: 10;
}
.skip:focus { left: 0; }

/* ---------- header ---------- */
.site-header { border-bottom: 1px solid var(--rule); }

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  padding-block: 1rem;
}

.wordmark {
  font-weight: 750;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
}
.wordmark:hover { color: var(--ink); }

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav a {
  display: inline-block;
  padding: 0.2rem 0;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.nav a:hover { border-bottom-color: var(--rule); color: var(--ink); }
.nav a[aria-current="page"] { border-bottom-color: var(--green); font-weight: 650; }

.nav .nav-action {
  padding: 0.3rem 0.95rem;
  background: var(--green);
  color: #fff;
  font-weight: 650;
  border-bottom: 0;
  border-radius: 0.4rem;
}
.nav .nav-action:hover { background: var(--green-deep); color: #fff; }

/* ---------- page body ---------- */
main { flex: 1; padding-block: clamp(2rem, 6vw, 4.5rem); }

.narrow { max-width: 44rem; }

.prose { max-width: 42rem; }
.prose h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(2.1rem, 5.5vw, 3.1rem);
  font-weight: 750;
  letter-spacing: -0.025em;
  line-height: 1.08;
}
.prose h2 { margin: 2.75rem 0 0.5rem; font-size: 1.55rem; font-weight: 700; }
.prose h3 { margin: 2rem 0 0.25rem; font-size: 1.15rem; font-weight: 700; }
.prose p { margin: 0.75rem 0; }
.prose .updated { margin: 0 0 2rem; color: var(--muted); }
.prose .intro { font-size: 1.25rem; color: var(--ink); margin-top: 1.25rem; }
.prose .bubble { margin: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-block;
  padding: 0.7rem 1.3rem;
  border: 2px solid var(--green);
  border-radius: 0.5rem;
  background: var(--green);
  color: #fff;
  font: inherit;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--green-deep); border-color: var(--green-deep); color: #fff; }

.btn-quiet { background: transparent; color: var(--green); }
.btn-quiet:hover { background: var(--mist); color: var(--green-deep); border-color: var(--green-deep); }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1rem; margin-top: 1.75rem; }

/* ---------- home hero ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: clamp(2rem, 6vw, 5rem);
  align-items: center;
}

.display {
  margin: 0 0 1.25rem;
  font-size: clamp(2.6rem, 7.5vw, 5rem);
  font-weight: 780;
  letter-spacing: -0.035em;
  line-height: 1;
  overflow-wrap: anywhere;
}

.lede { margin: 0; max-width: 33rem; font-size: 1.3rem; line-height: 1.5; color: var(--muted); }

/* ---------- text-message bubbles ---------- */
.demo { margin: 0; padding: 1.5rem; background: var(--mist); border-radius: 1.5rem; }
.demo figcaption { margin-top: 1.1rem; color: var(--muted); font-size: 0.95rem; }

.thread-demo, .messages { display: flex; flex-direction: column; gap: 0.5rem; }

.bubble {
  width: fit-content;
  max-width: 88%;
  margin: 0;
  padding: 0.6rem 0.95rem;
  border-radius: 1.25rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.bubble-in { align-self: flex-start; background: var(--bubble-in); border-bottom-left-radius: 0.35rem; }
.bubble-out { align-self: flex-end; background: var(--green); color: #fff; border-bottom-right-radius: 0.35rem; }

.bubble-meta { display: block; margin-top: 0.15rem; font-size: 0.75rem; line-height: 1.3; color: var(--muted); }
.bubble-out .bubble-meta { color: rgba(255, 255, 255, 0.92); }

/* The one moment of motion: the example conversation types itself in once. */
.demo-animate .bubble {
  animation: bubble-in 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: calc(var(--i, 0) * 1s + 0.35s);
}
@keyframes bubble-in {
  from { opacity: 0; transform: translateY(0.6rem) scale(0.95); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .demo-animate .bubble { animation: none; }
}

/* ---------- facts list (About page) ---------- */
.facts {
  display: grid;
  grid-template-columns: minmax(8rem, 12rem) 1fr;
  margin: 1rem 0 0;
  border-top: 1px solid var(--rule);
}
.facts dt, .facts dd { margin: 0; padding: 0.85rem 0; border-bottom: 1px solid var(--rule); }
.facts dt { font-weight: 650; padding-right: 1rem; }

/* ---------- forms ---------- */
label { display: block; margin-bottom: 0.35rem; font-weight: 650; }

input[type="text"], input[type="password"], textarea {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1.5px solid var(--field);
  border-radius: 0.5rem;
  background: #fff;
  color: var(--ink);
  font: inherit;
}
textarea { resize: vertical; }

.auth { max-width: 24rem; }
.auth h1 { margin: 0 0 0.25rem; font-size: 2.2rem; font-weight: 750; letter-spacing: -0.025em; }

.notice-error {
  margin: 1rem 0;
  padding: 0.1rem 0 0.1rem 0.8rem;
  border-left: 3px solid var(--danger);
  color: var(--danger);
  font-weight: 600;
}

/* ---------- inbox ---------- */
.page-title { margin: 0; font-size: clamp(2rem, 5vw, 2.75rem); font-weight: 750; letter-spacing: -0.025em; line-height: 1.1; }

.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem; margin-top: 1.75rem; }
.inline-form .grow { flex: 1 1 14rem; }

.conv-list { margin: 1.75rem 0 0; padding: 0; list-style: none; border-top: 1px solid var(--rule); }
.conv-list a {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.1rem 1rem;
  padding: 0.9rem 0.5rem;
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
  text-decoration: none;
}
.conv-list a:hover { background: var(--mist); color: var(--ink); }
.conv-name { font-weight: 650; font-variant-numeric: tabular-nums; }
.conv-unread .conv-name { font-weight: 780; }
.conv-new { color: var(--green); font-weight: 700; font-size: 0.95rem; }
.conv-snippet {
  grid-column: 1 / -1;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.empty { margin: 1.5rem 0; color: var(--muted); }

/* ---------- thread ---------- */
.thread-head h1 { margin: 0.2rem 0 0; font-size: clamp(1.8rem, 4.5vw, 2.4rem); font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.messages { margin: 1.5rem 0; min-height: 6rem; }
.composer { margin-top: 1rem; padding-top: 1.25rem; border-top: 1px solid var(--rule); }

/* ---------- footer ---------- */
.site-footer { margin-top: 2rem; padding-block: 2.5rem 2rem; background: var(--mist); }

.footer-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1.3fr;
  gap: 2rem;
}
.footer-grid h2 { margin: 0 0 0.5rem; font-size: 1rem; font-weight: 700; letter-spacing: 0; }
.footer-grid p { margin: 0 0 0.5rem; }
.footer-grid ul { margin: 0; padding: 0; list-style: none; }
.footer-grid li { margin: 0.25rem 0; }
.footer-name { font-size: 1.25rem; font-weight: 750; letter-spacing: -0.02em; }
.footer-note { margin: 2rem 0 0; padding-top: 1rem; border-top: 1px solid var(--rule); color: var(--muted); font-size: 0.9rem; }

/* ---------- small screens ---------- */
@media (max-width: 52rem) {
  .hero { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 36rem) {
  .facts { grid-template-columns: 1fr; }
  .facts dt { padding-bottom: 0; border-bottom: 0; }
  .facts dd { padding-top: 0.15rem; }
  .footer-grid { grid-template-columns: 1fr; }
  .demo { padding: 1.1rem; }
}

/* ======================================================================
   Accounts, chat, profiles, admin
   ====================================================================== */

/* forms */
.field { margin-bottom: 1.1rem; }
.hint { margin: 0.3rem 0 0; color: var(--muted); font-size: 0.9rem; font-weight: 400; }
.composer .hint { display: inline; margin-left: 0.5rem; }

input[type="text"], input[type="password"], input[type="number"], textarea {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1.5px solid var(--field);
  border-radius: 0.5rem;
  background: #fff;
  color: var(--ink);
  font: inherit;
}
.narrow-input { width: 9rem !important; }
.link-box { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9rem; }

.check { display: flex; align-items: flex-start; gap: 0.7rem; margin: 1.25rem 0; }
.check input { flex: none; width: 1.2rem; height: 1.2rem; margin-top: 0.3rem; accent-color: var(--green); }
.check label { margin: 0; font-weight: 400; }

.notice-error p, .notice-ok p { margin: 0.25rem 0; }
.notice-ok {
  margin: 1rem 0;
  padding: 0.1rem 0 0.1rem 0.8rem;
  border-left: 3px solid var(--green);
  color: var(--green-deep);
  font-weight: 600;
}

.section-title { margin: 2.5rem 0 0.75rem; font-size: 1.35rem; font-weight: 700; }

/* header extras */
.nav-form { margin: 0; }
.linklike {
  padding: 0.2rem 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.linklike:hover { border-bottom-color: var(--rule); }

.badge {
  display: inline-block;
  min-width: 1.35rem;
  padding: 0 0.4rem;
  border-radius: 1rem;
  background: var(--green);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
}
.badge-plain { background: var(--mist); color: var(--ink); border: 1px solid var(--rule); font-weight: 600; }
.badge-line { color: var(--muted); font-size: 0.95rem; }

/* avatars and people */
.avatar {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  background: var(--bubble-in);
  color: var(--green-deep);
  font-weight: 750;
}
.avatar-lg { width: 4.5rem; height: 4.5rem; font-size: 1.9rem; }

.profile-head { display: flex; align-items: center; gap: 1.25rem; margin-bottom: 1.5rem; }
.profile-head p { margin: 0.2rem 0 0; }
.bio { max-width: 38rem; font-size: 1.15rem; white-space: pre-wrap; overflow-wrap: anywhere; }

.person-list { margin: 1.5rem 0 0; padding: 0; list-style: none; border-top: 1px solid var(--rule); }
.person { display: flex; align-items: center; gap: 1rem; padding: 0.9rem 0.25rem; border-bottom: 1px solid var(--rule); }
.person-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.person-name { font-weight: 650; }
.person-bio { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }

/* buttons */
.btn-small { padding: 0.35rem 0.8rem; font-size: 0.95rem; }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #8c1d18; border-color: #8c1d18; }

/* chat */
.thread-head h1 a { color: inherit; text-decoration: none; }
.thread-head h1 a:hover { text-decoration: underline; }
.thread-head h1 { font-variant-numeric: normal; }

/* admin tables */
.table-wrap { margin-top: 1.25rem; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.97rem; }
.table th, .table td { padding: 0.65rem 0.75rem 0.65rem 0; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: middle; }
.table th { color: var(--muted); font-weight: 650; white-space: nowrap; }
.table form { margin: 0; display: flex; gap: 0.4rem; align-items: center; }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.row-actions input { padding: 0.35rem 0.6rem; }

@media (max-width: 36rem) {
  .person { flex-wrap: wrap; }
  .site-header .wrap { align-items: flex-start; }
  .nav { gap: 0.25rem 1.1rem; }
}

/* admin tables become stacked cards on phones */
@media (max-width: 40rem) {
  .table-wrap { overflow-x: visible; }
  .table thead { position: absolute; left: -999px; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 0.7rem 0; border-bottom: 1px solid var(--rule); }
  .table td { padding: 0.15rem 0; border: 0; }
  .table td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-weight: 650; }
  .table td:first-child { font-weight: 650; }
  .row-actions { margin-top: 0.4rem; }
  .row-actions form { flex-wrap: wrap; }
}
