/* ============================================================
   02 — Discussion · "Field Journal"
   Warm paper, serif, reading-forward. No cards, no float, no shadow.
   Font: Source Serif 4 (self-hosted .woff — note format differs).
   ============================================================ */

@font-face {
  font-family: "Source Serif 4";
  src: url("/assets/fonts/SourceSerif4-Variable.woff") format("woff");
  font-weight: 200 900; font-style: normal; font-display: swap;
}

:root {
  --bg: #FBF7F0;
  --surface: #FFFDF9;
  --rule: #E3DAC9;
  --ink: #2B2A26;
  --muted: #6B6559;
  --accent: #9C5B34;
  --accent-soft: #F0E2D6;

  --serif: "Source Serif 4", Georgia, "Iowan Old Style", serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

* { 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: 72px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.75;
}

/* Narrow, centred reading column — deliberately the calmest demo. */
.wrap { max-width: 68ch; margin-inline: auto; padding: 0 24px; }

h1, h2 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.01em; margin: 0; }
p { margin: 0 0 14px; }
p:last-child { margin-bottom: 0; }
a { color: var(--accent); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

/* ---------- Masthead ---------- */

.topbar {
  padding-block: clamp(30px, 4.5vw, 56px) 26px;
  border-bottom: 2px solid var(--ink);
  margin-bottom: 8px;
}
.topbar h1 {
  font-size: clamp(30px, 4.6vw, 44px);
  line-height: 1.14;
  margin-bottom: 10px;
}
.topbar > div > p { color: var(--muted); font-size: 16px; margin: 0; }

.identity-picker {
  font-family: var(--mono);
  font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); margin-top: 20px;
}
.identity-picker select {
  font-family: var(--serif); font-size: 15px; letter-spacing: 0;
  text-transform: none; margin-left: 6px;
  min-height: 44px; padding: 6px 10px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--rule); border-radius: 3px;
}
.identity-picker small { display: block; margin-top: 8px; letter-spacing: 0; text-transform: none; font-family: var(--serif); font-size: 13px; }

/* ---------- Composer ---------- */

.new-topic {
  border-bottom: 1px solid var(--rule);
  padding-block: 28px 32px;
  margin-bottom: 8px;
}
.new-topic h2 { font-size: 20px; margin-bottom: 16px; }
.field { display: block; margin-bottom: 14px; }
.field label {
  display: block; font-family: var(--mono);
  font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%; font-family: var(--serif); font-size: 16px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: 3px; padding: 10px 12px; min-height: 44px;
}
.field textarea { resize: vertical; min-height: 5.5rem; line-height: 1.6; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }

.btn {
  font-family: var(--serif); font-size: 16px; font-weight: 600; cursor: pointer;
  min-height: 44px; padding: 11px 22px;
  background: var(--ink); color: var(--bg);
  border: 0; border-radius: 3px;
  transition: background-color 160ms ease;
}
.btn:hover { background: var(--accent); }

.btn-ghost, .reply-toggle {
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer;
  min-height: 44px; padding: 8px 0;
  background: none; color: var(--accent);
  border: 0; border-bottom: 1px solid transparent;
}
.btn-ghost:hover, .reply-toggle:hover { border-bottom-color: var(--accent); }

/* ---------- Topics (constrained: style only) ---------- */

.topic-list { list-style: none; margin: 0; padding: 0; }

/* Rules, not cards. Paper doesn't float. */
.topic {
  position: relative;
  padding-block: 28px;
  border-bottom: 1px solid var(--rule);
}

.category-tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

/* Hanging-indent category tag in the left margin on wide screens,
   so the reading column stays pure. */
@media (min-width: 1100px) {
  .category-tag {
    position: absolute;
    left: -9.5rem; top: 32px;
    width: 8rem; text-align: right;
    margin: 0;
  }
}

.topic-title { font-size: 23px; line-height: 1.25; margin-bottom: 6px; }
.topic-meta { font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-bottom: 10px; }
.topic-meta strong { color: var(--ink); font-weight: 500; }
.topic-body { margin-bottom: 12px; }

/* ---------- Replies (constrained) ---------- */

.replies {
  list-style: none;
  margin: 16px 0 0; padding: 0;
  display: grid; gap: 14px;
}
.reply {
  padding-left: 18px;
  border-left: 2px solid var(--accent);
}
.reply-meta { font-family: var(--mono); font-size: 11px; color: var(--muted); margin: 0; }
.reply-meta strong { color: var(--ink); font-weight: 500; }
.reply-body { margin: 4px 0 0; font-size: 16px; }

.reply-actions { display: flex; gap: 10px; margin-top: 6px; }
.reply-actions button {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.08em; text-transform: uppercase;
  background: none; border: 0; color: var(--muted);
  cursor: pointer; text-decoration: underline;
  /* a real hit area: the bare glyph measured 38x12 */
  min-height: 44px; padding: 6px 4px;
}
.reply-actions button:hover { color: var(--accent); }

/* ---------- Reply composer ---------- */

.new-reply {
  position: fixed; left: 16px; right: 16px; bottom: 88px;
  max-width: 620px; margin-inline: auto; z-index: 40;
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--accent);
  border-radius: 3px; padding: 16px;
  box-shadow: 0 18px 40px -26px rgba(43,42,38,0.5);
}
.reply-panel-body { flex: 1; }
.reply-target-label { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.new-reply textarea {
  width: 100%; font-family: var(--serif); font-size: 16px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--rule);
  border-radius: 3px; padding: 10px 12px; resize: vertical; min-height: 3.2rem;
}

/* ---------- Toasts ---------- */

.toast-stack { position: fixed; right: 16px; bottom: 88px; display: grid; gap: 8px; z-index: 50; }
.toast {
  font-family: var(--mono); font-size: 12px;
  background: var(--ink); color: var(--bg);
  border-radius: 3px; padding: 11px 16px;
  box-shadow: 0 14px 32px -18px rgba(43,42,38,0.7);
}
.toast.error { background: var(--accent); }

/* ---------- Motion ---------- */

.motion .topic { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .motion .topic { opacity: 1 !important; transform: none !important; }
  .btn, .btn-ghost, .reply-toggle { transition: none !important; }
}


/* ---------- Masthead + opening drop cap ---------- */
/* The page was correct and quiet to the point of being forgettable. A journal
   has a masthead: a rule, a standing line, a date. And the first paragraph of
   the first topic gets the opening flourish a printed page would give it. */

.topbar {
  border-bottom: 3px double var(--rule);
  padding-bottom: 22px;
}
.topbar::before {
  content: "The Trailhead Journal · Field notes from the group";
  /* The header is a flex row now, so the eyebrow is a flex item. Without
     this it shrinks to its own text width and the rule under it stops
     short of the page. */
  flex: 1 0 100%;
  display: block;
  font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.26em; text-transform: uppercase;
  color: var(--accent);
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--rule);
}
.topbar h1 { letter-spacing: -0.035em; }

.topic-list > .topic:first-child .topic-body::first-letter {
  float: left;
  font-size: 3.1em;
  line-height: 0.84;
  font-weight: 600;
  color: var(--accent);
  padding: 0.06em 0.1em 0 0;
}

/* Rule between entries, the way a journal separates them. */
.topic + .topic { border-top: 1px solid var(--rule); padding-top: 30px; }


/* ---------- Compose affordance ---------- */
/* The form now sits under the entries. This is what stands in its place: a
   single line, in the journal's own voice. */
.compose-jump { margin: 0 0 30px; }
.btn-jump {
  font: inherit; font-size: 15px; cursor: pointer;
  background: none; border: 0; padding: 6px 0;
  color: var(--accent);
  border-bottom: 1px solid var(--accent);
  min-height: 44px;
}
.btn-jump:hover { color: var(--ink); border-bottom-color: var(--ink); }
.new-topic { border-top: 3px double var(--rule); padding-top: 28px; margin-top: 40px; }


/* ---------- Masthead colophon ---------- */
/* A journal states its extent on the masthead. Rules, small caps, mono
   figures: the same voice as the rest of the page. */

.topbar { display: flex; flex-wrap: wrap; gap: 26px 48px; align-items: flex-end; justify-content: space-between; }
.topbar > div:first-child { flex: 1 1 22rem; }

.pl-stats {
  display: flex; gap: 0;
  border-top: 1px solid var(--ink);
  margin: 0;
}
.pl-stats div { padding: 10px 22px 2px 0; margin-right: 22px; border-right: 1px solid var(--rule); }
.pl-stats div:last-child { border-right: 0; margin-right: 0; padding-right: 0; }
.pl-stats dt {
  font-family: var(--mono); font-size: 9.5px;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 4px;
}
.pl-stats dd {
  margin: 0; font-size: 30px; line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

@media (max-width: 640px) {
  .pl-stats { flex-wrap: wrap; }
}


/* ---------- Marginalia ---------- */
/* It was a 68ch column with ~370px of dead paper each side and the category
   floating in the margin. A journal uses that margin: furniture on the left,
   the thread in the measure, the reply count set as a figure on the right.
   The reading measure is unchanged — the page around it is doing the work. */

@media (min-width: 940px) {
  .wrap { max-width: 1040px; }

  .topbar, .compose-jump, .new-topic, .foot { padding-left: 12.5rem; }

  .topic {
    display: grid;
    grid-template-columns: 10rem minmax(0, 58ch) minmax(0, 1fr);
    column-gap: 2rem;
    align-items: start;
  }
  /* Everything sits in the measure unless it is furniture. The two that are
     get moved out to the margins; nothing here needs a new attribute, which
     matters because #pl-topics > li is under a ShapeConstraint. */
  .topic > * { grid-column: 2; }

  .topic > .category-tag {
    position: static;
    grid-column: 1; grid-row: 1 / span 6;
    justify-self: end; text-align: right;
    padding-top: 7px;
  }
  /* Byline out to the right margin, hung on a rule, the way a printed sidenote
     sits against the text block. */
  .topic > .topic-meta {
    grid-column: 3; grid-row: 1 / span 6;
    align-self: start;
    margin: 0;
    padding-top: 7px; padding-left: 1.75rem;
    border-left: 1px solid var(--rule);
    line-height: 1.7;
  }
}


/* --- corrections after review --- */
@media (min-width: 940px) {
  /* The chrome above and below the list has to start on the same line as the
     topic text: column 1 is 10rem and the gap is 2rem, so 12rem exactly. It
     was 12.5rem and every heading sat 8px off the titles under it. */
  .topbar, .compose-jump, .new-topic, .foot { padding-left: 12rem; }

  /* Buttons stretched to the full 58ch measure, so "Reply" rendered centred
     in an invisible full-width control. */
  .topic > button { justify-self: start; }
}
