/* ============================================================
   13 — Knowledge Base · "Roast Log"
   Lab notebook meets docs site. Mono chrome, serif prose, warm paper.
   Fonts: JetBrains Mono (chrome) + Source Serif 4 (answers).
   ============================================================ */

@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/fonts/JetBrainsMono-Variable.woff2") format("woff2");
  font-weight: 400 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Source Serif 4";
  src: url("/assets/fonts/SourceSerif4-Variable.woff") format("woff");
  font-weight: 300 700; font-style: normal; font-display: swap;
}

:root {
  --bg: #FCFAF6;
  --surface: #FFFFFF;
  --rail: #F3EFE7;
  --hairline: #E4DED1;
  --ink: #201C16;
  --muted: #6F675A;
  --roast: #8A4B22;
  --roast-light: #F5E9DF;
  --accepted: #2C7A50;

  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

/* The UA's `[hidden] { display: none }` loses to any author `display` rule
   below, and every demo here toggles `element.hidden` to show and hide
   panels. Without this, hiding silently stops working. */
[hidden] { display: none !important; }

/* A long unbroken token -- a pasted URL, a 200-character "word" -- must wrap
   rather than push its container past its grid track and break the row.
   `anywhere` rather than `break-word` on purpose: only `anywhere` reduces the
   element's min-content width, and a grid or flex item defaults to
   `min-width: auto`, which refuses to shrink below its longest word. With
   `break-word` alone, demo-06 and demo-10 still blew 1.4k px past the viewport.
   The `min-width: 0` below is the other half of the same fix. */
h1, h2, h3, h4, p, li, a, span, strong, em, code, label, time,
button, input, textarea { overflow-wrap: anywhere; }
.card, .post, .listing, .idea, .topic, .question, .profile-card, .submission,
.lesson, .resource, .nominee, .archive-item, .member-card, .comment, .reply,
.answer, .idea-body-wrap { min-width: 0; }


body {
  margin: 0;
  padding-block-end: 104px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16.5px;
  line-height: 1.7;
}

.wrap { max-width: 1060px; margin-inline: auto; padding: 0 20px; }

h1, h2 { margin: 0; font-weight: 600; letter-spacing: -0.015em; }
p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }
a { color: var(--roast); }

:focus-visible { outline: 2px solid var(--roast); outline-offset: 3px; border-radius: 6px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.topbar {
  padding-block: clamp(36px, 6vw, 64px) 22px;
  display: flex; flex-wrap: wrap; gap: 18px;
  justify-content: space-between; align-items: flex-end;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 26px;
}
.topbar h1 { font-size: clamp(28px, 3.8vw, 42px); line-height: 1.1; }
.topbar > div > p { color: var(--muted); max-width: 50ch; margin-top: 12px; font-size: 15px; }

.identity-picker { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.13em; text-transform: uppercase; color: var(--muted); }
.identity-picker select {
  font: inherit; font-size: 13px; letter-spacing: 0; text-transform: none;
  margin-left: 6px; min-height: 44px; padding: 9px 12px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--hairline); border-radius: 8px;
}

/* ---------- Docs layout: sticky ask-form rail beside the thread ---------- */

@media (min-width: 940px) {
  /* Both pinned to row 2. Without the explicit row the rail (which comes
     first in the DOM) takes row 2 col 2, and sparse auto-placement cannot put
     the list back in row 2 col 1 — it dropped to row 3, leaving a 368px hole
     under the masthead. */
  .roast-band   { grid-column: 1 / -1; grid-row: 2; }
  .question-list { grid-column: 1; grid-row: 3; }
  .new-question { grid-column: 2; grid-row: 3; position: sticky; top: 24px; align-self: start; }
  .wrap { display: grid; grid-template-columns: minmax(0, 1fr) 20rem; column-gap: 40px; align-items: start; }
  .topbar { grid-column: 1 / -1; }
}

.new-question {
  background: var(--rail);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 20px 22px;
  margin-bottom: 26px;
}
.new-question h2 {
  font-family: var(--mono); font-weight: 700;
  font-size: 11.5px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--roast); margin-bottom: 16px;
}

.field { display: block; margin-bottom: 14px; }
.field label {
  font-family: var(--mono); display: block;
  font-size: 10px; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 6px;
}
.field input, .field textarea {
  width: 100%; font: inherit; font-size: 15px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 8px; padding: 11px 13px; min-height: 44px;
}
.field textarea { resize: vertical; min-height: 5.5rem; }
.field input:focus, .field textarea:focus { border-color: var(--roast); }

.btn {
  font-family: var(--mono); font-size: 12px; font-weight: 700; cursor: pointer;
  letter-spacing: 0.1em; text-transform: uppercase;
  min-height: 44px; padding: 12px 20px;
  background: var(--roast); color: #FFFFFF;
  border: 0; border-radius: 8px;
  transition: transform 140ms ease, box-shadow 140ms ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 12px 24px -14px var(--roast); }

.btn-ghost {
  font-family: var(--mono); font-size: 11px; cursor: pointer;
  letter-spacing: 0.08em;
  min-height: 44px; padding: 9px 14px;
  background: transparent; color: var(--muted);
  border: 1px solid var(--hairline); border-radius: 8px;
  transition: color 140ms ease, border-color 140ms ease;
}
.btn-ghost:hover { color: var(--roast); border-color: var(--roast); }

/* ---------- Questions ---------- */

.question-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 30px; }

.question {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 26px 28px;
}
.question-title { font-size: clamp(20px, 2.4vw, 25px); line-height: 1.3; margin-bottom: 8px; }
.q-meta {
  font-family: var(--mono); font-size: 10.5px;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 14px;
}
.q-meta strong { color: var(--ink); font-weight: 700; }

/* ---------- Answers ---------- */

.answers { list-style: none; margin: 22px 0 0; padding: 0; display: grid; gap: 14px; }

.answer {
  display: grid;
  grid-template-columns: 3.4rem 1fr;
  gap: 16px;
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--hairline);
  border-radius: 10px;
  padding: 16px 18px;
  transition: border-color 180ms ease, background 180ms ease;
}
.answer.is-accepted {
  border-left-color: var(--accepted);
  background: #F4FAF6;
}

.answer-votes { display: grid; gap: 6px; justify-items: center; align-content: start; }
.vote-count {
  font-family: var(--mono); font-size: 18px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.answer-votes .btn-ghost { width: 100%; padding: 8px 0; min-height: 44px; }

.a-body { font-size: 16px; margin-bottom: 10px; }
.a-meta {
  font-family: var(--mono); font-size: 10.5px;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted);
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin: 0;
}
.a-meta strong { color: var(--ink); font-weight: 700; }

.accepted-tag {
  font-family: var(--mono); font-size: 9.5px; font-weight: 700;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: #FFFFFF; background: var(--accepted);
  border-radius: 999px; padding: 3px 10px;
}

/* ---------- Answer panel ---------- */

.answer-panel {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 40;
  background: var(--surface);
  border-top: 1px solid var(--hairline);
  padding: 18px 20px;
  box-shadow: 0 -18px 40px -28px rgba(32,28,22,0.6);
}
.answer-panel-body { max-width: 1060px; margin-inline: auto; }
.answer-panel textarea {
  width: 100%; font: inherit; font-size: 15px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--hairline);
  border-radius: 8px; padding: 11px 13px; min-height: 44px; resize: vertical;
}
.answer-panel-actions, .reply-panel-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.reply-meta {
  font-family: var(--mono); font-size: 10.5px;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 8px;
}

/* ---------- Toasts ---------- */

.toast-stack { position: fixed; right: 16px; bottom: 116px; display: grid; gap: 8px; z-index: 50; }
.toast {
  font-family: var(--mono); font-size: 12px;
  background: var(--ink); color: var(--bg);
  border-radius: 8px; padding: 12px 16px;
  box-shadow: 0 16px 34px -20px rgba(32,28,22,0.7);
}
.toast.error { background: #A6382B; color: #FFFFFF; }

/* ---------- Motion ---------- */

.motion .question { opacity: 0; }

@media (max-width: 560px) {
  .answer { grid-template-columns: 1fr; }
  .answer-votes { grid-auto-flow: column; justify-content: start; gap: 12px; align-items: center; }
  .answer-votes .btn-ghost { width: auto; padding: 8px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .motion .question { opacity: 1 !important; transform: none !important; }
  .btn, .btn-ghost, .answer { transition: none !important; }
}


/* ---------- Roast profile band + log entry numbers ---------- */
/* First attempt overlaid a curve on the masthead; it cut straight through the
   identity picker and read as a rendering artifact. A band of its own instead:
   a temperature ramp under the header, which says "roasting" without fighting
   anything for space. */

.roast-band {
  display: flex; align-items: center; gap: 14px;
  margin: 0 0 26px;
  font-family: var(--mono); font-size: 9.5px; font-weight: 700;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted);
}
.roast-band .ramp {
  flex: 1; height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, #C9BFAE 0%, #C08A4A 42%, var(--roast) 72%, #4A2410 100%);
  position: relative;
}
.roast-band .ramp::after {
  content: "";
  position: absolute; left: 72%; top: -4px;
  width: 2px; height: 14px; background: var(--ink);
}
.roast-band .crack { color: var(--roast); }

.question-list { counter-reset: entry; }
.question { position: relative; padding-left: 64px; counter-increment: entry; }
.question::before {
  content: counter(entry, decimal-leading-zero);
  position: absolute; left: 24px; top: 27px;
  font-family: var(--mono); font-size: 19px; font-weight: 700;
  color: var(--roast); opacity: 0.45;
}
@media (max-width: 620px) {
  .question { padding-left: 26px; }
  .question::before { left: 10px; top: 10px; font-size: 13px; }
}


/* ---------- Compose affordance ---------- */
/* The roast log opens with the entries, not with an empty field. */
.compose-jump { margin: 0 0 20px; }
.btn-jump {
  font-family: var(--mono); font-size: 12px; font-weight: 700; cursor: pointer;
  letter-spacing: 0.1em; text-transform: uppercase;
  min-height: 44px; padding: 12px 20px;
  background: transparent; color: var(--roast);
  border: 1.5px solid var(--roast); border-radius: 999px;
}
.btn-jump:hover { background: var(--roast); color: var(--surface); }
.new-question { margin-top: 34px; }
