/* Quiet Editorial — post page.
 *
 * Every value here comes from docs/design-language.md. No hex values:
 * colors come from theme-quiet-editorial.css only.
 */

* { box-sizing: border-box; }

html { background: var(--wc-paper); }

body {
  margin: 0;
  background: var(--wc-paper);
  color: var(--wc-ink);
  font-family: var(--wc-serif);
  font-size: 18px;
  transition: background var(--wc-dur-base) var(--qe-ease),
              color var(--wc-dur-base) var(--qe-ease);
}

.mono { font-family: var(--wc-mono); }

/* ── header bar ─────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 48px;
  border-bottom: 1px solid var(--wc-line);
}

.wordmark { font-size: 17px; font-weight: 600; letter-spacing: 0.04em; }

.nav { display: flex; gap: 24px; font-size: 14px; letter-spacing: 0.06em; color: var(--qe-nav); }
.nav a { color: inherit; text-decoration: none; cursor: pointer; }
.nav a:hover { color: var(--wc-accent); }

/* ── the frame ──────────────────────────────────────────────── */

/* The grid never changes. Hiding a rail hides the rail's contents,
   never its track, so the reading column keeps its width and its
   x-position under every toggle. */
.frame {
  display: grid;
  grid-template-columns: 190px 600px 310px 36px;
  gap: 24px;
  padding: 32px;
  justify-content: center;
  align-items: start;
}

/* Rails stay with the reader on a long post. The reading column is
   untouched by this: sticky positioning changes nothing in the grid. */
.railcol {
  padding-top: 8px;
  position: sticky;
  top: 32px;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  scrollbar-width: thin;
}
.railcol::-webkit-scrollbar { width: 6px; }
.railcol::-webkit-scrollbar-thumb { background: var(--wc-line); border-radius: 3px; }

/* ── left rail ──────────────────────────────────────────────── */

.leftrail { display: flex; flex-direction: column; gap: 26px; }
.leftrail.hidden > * { display: none; }

.section { display: flex; flex-direction: column; gap: 12px; }

.seclabel {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--wc-faint);
}
.seclabel .txt { font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; }
.seclabel .count { font-size: 12px; color: var(--wc-accent); margin-left: 4px; }
.seclabel svg { transition: transform var(--wc-dur-fast) var(--qe-ease); }
.seclabel.closed svg { transform: rotate(-90deg); }
.seclabel:hover { color: var(--wc-muted); }

.secbody { display: flex; flex-direction: column; gap: 9px; padding-left: 16px; }
.secbody.closed { display: none; }

.toc a {
  font-size: 14px;
  font-style: italic;
  color: var(--wc-muted);
  text-decoration: none;
  cursor: pointer;
  line-height: 1.35;
}
.toc a:hover { color: var(--wc-accent); }
.toc a.here { color: var(--wc-ink); font-style: normal; }
.toc .sub { display: flex; flex-direction: column; gap: 7px; padding-left: 14px; }
.toc .sub a { font-size: 13px; color: var(--wc-faint); }

.version {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
  cursor: pointer;
  padding: 3px 0;
}
.version .n { color: var(--wc-muted); font-variant-numeric: tabular-nums; }
.version .note { font-size: 12px; font-style: italic; color: var(--wc-faint); }
.version:hover .n { color: var(--wc-accent); }
.version.current .n { color: var(--wc-accent); }

/* ── reading column ─────────────────────────────────────────── */

.column { display: flex; flex-direction: column; gap: 20px; width: 600px; }

/* Wide content fits the measure instead of pushing past it.
 *
 * A published picture is a 2x asset: 1304px wide for a 600px column, so
 * its intrinsic width is more than twice the measure. Without this rule
 * it renders at natural size and spills over the discussion rail. First
 * seen on v3 of "Filing bugs at the speed of speech", the first post to
 * carry a picture.
 *
 * height: auto is belt and braces. The renderer writes no width or
 * height attribute today, so the aspect ratio is kept anyway; the line
 * costs nothing and keeps the rule correct if that ever changes.
 *
 * A table or a code block cannot scale down without becoming
 * unreadable, so it scrolls inside its own box instead.
 */
.column img { max-width: 100%; height: auto; }
.column pre,
.column table { max-width: 100%; overflow-x: auto; }

.masthead {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  padding: 8px 0 6px;
}

h1 { font-size: 48px; line-height: 1.1; font-weight: 400; margin: 0; }
.subtitle { font-size: 16px; font-style: italic; color: var(--wc-muted); }

/* meta tray — a centered row framed by thin rules */
.tray {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  font-size: 13px;
  color: var(--wc-faint);
  margin-top: 6px;
}
.tray .rule { height: 1px; background: var(--wc-line); flex-grow: 1; }
.tray .item { display: flex; align-items: center; gap: 6px; }
.tray svg { stroke: var(--wc-accent); }

h2 {
  font-size: 25px;
  font-weight: 500;
  color: var(--wc-ink);
  margin: 8px 0 0;
  scroll-margin-top: 24px;
}
h3 {
  font-size: 19px;
  font-weight: 500;
  color: var(--wc-ink);
  margin: 4px 0 0;
  scroll-margin-top: 24px;
}

.column p { font-size: 18px; line-height: 1.68; color: var(--wc-body); margin: 0; }
.column p a { color: var(--wc-accent); }
.column p a:hover { color: var(--qe-accent-deep); }

.column code {
  font-family: var(--wc-mono);
  font-size: 15px;
  color: var(--wc-ink);
  background: var(--wc-panel);
  border-radius: 4px;
  padding: 1px 5px;
}

.pull {
  border-left: 2px solid var(--wc-line-strong);
  padding-left: 18px;
  font-style: italic;
  color: var(--wc-muted);
  line-height: 1.6;
}

.column wc-block-diagram,
.column wc-flowchart,
.column wc-state-machine,
.column wc-swimlane,
.column wc-sequence {
  border-top: 1px solid var(--wc-line);
  border-bottom: 1px solid var(--wc-line);
  margin: 4px 0;
}

.endnote {
  font-size: 13px;
  font-style: italic;
  color: var(--wc-faint);
  text-align: center;
  padding: 24px 0 8px;
}

/* ── anchored quotes ────────────────────────────────────────── */

.q { padding: 1px 0; cursor: pointer; transition: background var(--wc-dur-fast) var(--qe-ease); }
.q.one { background: var(--qe-highlight); }
.q.two { background: var(--qe-highlight-2); border-bottom: 2px solid var(--wc-accent); }
.q.tail { background: var(--qe-highlight); border-bottom: 2px solid var(--wc-line-strong); }

body[data-focus='mira'] .q.two { background: var(--qe-highlight-focus); border-bottom-color: var(--qe-accent-deep); box-shadow: 0 0 0 2px var(--qe-highlight-focus); }
body[data-focus='dev'] .q.two { background: var(--qe-highlight-focus-2); border-bottom-color: var(--qe-accent-deep); }
body[data-focus='dev'] .q.tail { background: var(--qe-highlight-focus-2); border-bottom-color: var(--wc-accent); }

/* picker card for stacked quotes */
.picker {
  align-self: center;
  background: var(--wc-card);
  border: 1px solid var(--wc-line);
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 3px 12px var(--qe-shadow);
  width: 400px;
}
.picker.hidden { display: none; }
.picker .head { font-size: 12px; letter-spacing: 0.1em; color: var(--wc-faint); text-transform: uppercase; }
.picker .row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--wc-body); cursor: pointer; }
.picker .row:hover { color: var(--wc-accent); }
.picker .row .quote {
  font-style: italic;
  color: var(--wc-muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.picker .row .who { margin-left: auto; flex-shrink: 0; white-space: nowrap; }
.avatar {
  width: 20px; height: 20px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 600; flex-shrink: 0;
  background: var(--qe-chip); color: var(--qe-chip-ink);
}
.avatar.b { background: var(--qe-chip-2); color: var(--qe-chip-2-ink); }

/* ── discussion rail ────────────────────────────────────────── */

.chanrail { display: flex; flex-direction: column; gap: 16px; }
.chanhead { display: flex; align-items: center; gap: 7px; color: var(--wc-accent); }
.chanhead .txt { font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; font-weight: 500; }
/* Collapsed keeps the header row with its count; clean read hides all. */
.chanrail.collapsed .chanbody { display: none; }
.chanrail.hidden > * { display: none; }
.chanbody { display: flex; flex-direction: column; gap: 16px; }

.msg {
  border-left: 2px solid var(--wc-line);
  padding-left: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background var(--wc-dur-fast) var(--qe-ease);
}
.msg .meta { font-size: 12px; color: var(--wc-faint); }
.msg .meta .who { font-weight: 600; color: var(--wc-muted); }
.msg .meta .anchor { color: var(--wc-accent); cursor: pointer; }
.msg .text { font-size: 14px; line-height: 1.55; color: var(--wc-body); }
.msg .act { font-size: 12px; color: var(--wc-accent); cursor: pointer; width: fit-content; }
.msg .act:hover { color: var(--qe-accent-deep); }
.msg .headrow { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.msg .dash { cursor: pointer; padding: 2px; color: var(--wc-faint); flex-shrink: 0; }
.msg .dash:hover { color: var(--wc-accent); }
.msg.anchored { border-left-color: var(--wc-accent); }
.msg.anchored .meta .who { color: var(--wc-ink); }

.msg.closed { display: none; }

.msg.focused {
  border-left: 3px solid var(--qe-accent-deep);
  background: var(--wc-panel);
  border-radius: 0 6px 6px 0;
  padding: 8px 10px 8px 13px;
}

.stub { font-size: 13px; font-style: italic; color: var(--wc-faint); cursor: pointer; }
.stub .show { color: var(--wc-accent); }

.thread {
  border-left: 2px solid var(--wc-line);
  margin-left: 6px;
  padding-left: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}
.thread.closed { display: none; }
.thread .reply { display: flex; flex-direction: column; gap: 3px; }
.thread .reply .meta .who { color: var(--wc-ink); }

.box {
  border: 1px solid var(--wc-line);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 12px;
  color: var(--wc-faint);
  font-style: italic;
}
.box.closed { display: none; }

.composer {
  border: 1px solid var(--wc-line);
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--wc-faint);
  font-style: italic;
  margin-top: 8px;
  cursor: pointer;
}
.composer:hover { border-color: var(--wc-line-strong); }
.composer.open {
  border-color: var(--wc-accent);
  background: var(--wc-card);
  color: var(--wc-body);
  font-style: normal;
  cursor: default;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.composer .draft { line-height: 1.55; }
.composer .foot { display: flex; justify-content: space-between; align-items: center; }
.composer .note { font-size: 11px; color: var(--wc-faint); font-style: italic; }
.composer .send {
  font-size: 12px;
  color: var(--wc-paper);
  background: var(--wc-accent);
  border-radius: 999px;
  padding: 4px 14px;
  cursor: pointer;
}
.composer .send:hover { background: var(--qe-accent-deep); }

/* ── control rail ───────────────────────────────────────────── */

.ctlrail { display: flex; flex-direction: column; gap: 12px; align-items: center; }

.ctl {
  position: relative;
  width: 32px; height: 32px;
  border: 1px solid var(--wc-line-strong);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--qe-nav);
  background: var(--wc-paper);
  transition: color var(--wc-dur-fast) var(--qe-ease),
              border-color var(--wc-dur-fast) var(--qe-ease),
              background var(--wc-dur-fast) var(--qe-ease);
}
.ctl:hover { color: var(--wc-accent); }
.ctl.on { border-color: var(--wc-accent); color: var(--wc-accent); background: var(--wc-panel); }
.ctl.inert { color: var(--wc-faint); cursor: default; }
.ctl.inert:hover { color: var(--wc-faint); }

.ctl::after {
  content: attr(data-tip);
  position: absolute;
  right: 40px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--qe-tip-bg);
  color: var(--qe-tip-ink);
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--wc-dur-fast) var(--qe-ease);
}
.ctl:hover::after { opacity: 1; }

.ctlsep { width: 20px; height: 1px; background: var(--wc-line); margin: 2px 0; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
