/*
 * The blog reader, on top of shared/site.css (its tokens, its type, its cards).
 * The .post-body rules are the ONLY place a post's own HTML is styled, and that
 * HTML comes from lib/blog.ts on the server, so every block the MatPilot blog
 * editor can make has a rule here: headings, lists, quote, code, divider,
 * callout, image, video, embed, link and poll.
 *
 * Contrast on --bg #080808: --ink 17.9:1, --ink-2 10.0:1, --ink-3 6.3:1,
 * --accent-ink 8.8:1 (gold). See ../DESIGN.md.
 */
.reader { padding-top: calc(var(--nav-h) + clamp(40px, 6vw, 88px)); min-height: 70vh; }
.reader-list .h2 { margin-top: 14px; }
.reader-list .lede { margin-top: 22px; }
.reader-tags { display: flex; flex-wrap: wrap; gap: 8px; margin: clamp(28px, 4vw, 44px) 0 clamp(24px, 3vw, 36px); }
.reader-tags:empty { margin: 0 0 clamp(28px, 4vw, 44px); }
.reader-tag {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: 2px; text-decoration: none;
  font: 600 13px/1 var(--label); letter-spacing: .06em; color: var(--ink-2);
}
.reader-tag:hover { border-color: var(--ink); color: var(--ink); }
.reader-tag.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.reader .posts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.reader-empty { padding: clamp(40px, 8vw, 96px) 0; color: var(--ink-2); font-size: 18px; }
.reader-actions { margin-top: 28px; }

/* ---------- one post ---------- */
.reader-post { max-width: 760px; }
.back { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; color: var(--ink-2); text-decoration: none; font-weight: 600; }
.back svg { width: 18px; height: 18px; transform: scaleX(-1); }
.back:hover { color: var(--ink); }
.reader-post > .post-meta { display: block; margin-top: clamp(18px, 3vw, 32px); padding: 0; }
.reader-title { margin-top: 14px; }
.reader-post .reader-tags { margin: 22px 0 0; }
.reader-cover { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; margin-top: clamp(28px, 4vw, 44px); background: var(--bg-2); }

.post-body { margin-top: clamp(28px, 4vw, 48px); color: var(--ink-2); font-size: clamp(1.02rem, .98rem + .25vw, 1.15rem); line-height: 1.72; overflow-wrap: anywhere; }
.post-body > * + * { margin-top: 1.1em; }
.post-body h1, .post-body h2, .post-body h3, .post-body h4 { color: var(--ink); font-family: var(--display); font-weight: 400; line-height: 1.05; margin-top: 1.6em; }
.post-body h1 { font-size: 2.4em; } .post-body h2 { font-size: 1.9em; } .post-body h3 { font-size: 1.5em; } .post-body h4 { font-size: 1.25em; }
.post-body strong, .post-body b { color: var(--ink); font-weight: 600; }
.post-body a { color: var(--accent-ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.post-body a:hover { color: var(--ink); }
.post-body ul, .post-body ol { padding-left: 1.3em; }
.post-body li + li { margin-top: .4em; }
.post-body blockquote { margin: 1.6em 0; padding-left: 22px; border-left: 2px solid var(--accent); }
.post-body blockquote p { font: italic 400 1.5em/1.3 var(--display); color: var(--ink); }
.post-body blockquote cite { display: block; margin-top: 12px; font: 600 12px/1.3 var(--label); letter-spacing: .16em; text-transform: uppercase; font-style: normal; color: var(--ink-3); }
.post-body code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88em; background: var(--bg-2); padding: 2px 6px; }
/* Wrap rather than scroll: a code line running off a phone hides its own start. */
.post-body pre { background: var(--bg-2); border: 1px solid var(--line); padding: 18px; white-space: pre-wrap; overflow-wrap: anywhere; }
.post-body pre code { background: transparent; padding: 0; }
.post-body hr { border: 0; border-top: 1px solid var(--line); margin: 2.2em 0; }
.post-body figure { margin: 1.8em 0; }
.post-body figure img, .post-body video { width: 100%; height: auto; background: var(--bg-2); }
.post-body figcaption { margin-top: 10px; font-size: 13.5px; color: var(--ink-3); }
.post-body .embed-frame { position: relative; aspect-ratio: 16 / 9; background: #000; }
.post-body .embed-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.post-body .callout { display: flex; gap: 14px; padding: 18px 20px; background: var(--bg-2); border-top: 2px solid var(--accent); }
.post-body .callout p { margin: 0; color: var(--ink); }
.post-body .callout-emoji { font-size: 1.3em; line-height: 1.3; }
.post-body .post-link a { font-weight: 600; }

/* the poll: results only after answering */
.post-body .post-poll { border: 1px solid var(--line-strong); padding: 20px; background: var(--bg-2); }
.post-body .poll-q { margin: 0 0 14px; color: var(--ink); font-weight: 600; }
.poll-options { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.poll-options li { position: relative; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; margin: 0; }
.poll-opt {
  width: 100%; min-height: 48px; padding: 10px 14px; text-align: left; cursor: pointer;
  background: var(--bg); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 2px; font: 500 15.5px/1.35 var(--sans);
}
.poll-opt:hover { border-color: var(--ink); }
.post-poll.voted .poll-opt { cursor: default; }
.post-poll.voted .poll-opt:hover { border-color: var(--line-strong); }
.post-poll.voted .poll-opt.chose { border-color: var(--accent); }
.poll-bar { display: none; position: absolute; left: 0; bottom: -6px; width: 100%; height: 3px; background: var(--line); }
.post-poll.voted .poll-bar { display: block; }
.poll-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .5s var(--ease); }
.poll-pct { min-width: 3.4em; text-align: right; font-weight: 600; font-size: 14px; color: var(--ink-2); visibility: hidden; }
.post-poll.voted .poll-pct { visibility: visible; }
.poll-total { margin: 14px 0 0; font-size: 13.5px; color: var(--ink-3); }

/* sharing */
.share { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: clamp(40px, 6vw, 64px); padding-top: 22px; border-top: 1px solid var(--line); }
.share .label { margin-right: 6px; }
.share-btn {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: 2px; background: transparent; color: var(--ink);
  font: 600 14px/1 var(--sans); text-decoration: none; cursor: pointer;
}
.share-btn:hover { border-color: var(--ink); }
.share-btn[hidden] { display: none; }
.share-done { display: none; font-size: 14px; font-weight: 600; color: var(--accent-ink); }
.share.copied .share-done { display: inline; }

.reader-more { margin-top: clamp(56px, 8vw, 96px); }
.reader-more .posts { margin-top: 18px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }
.reader-more .post-title { font-size: 1.6rem; }
.reader-cta { margin-top: clamp(56px, 8vw, 96px); padding: clamp(28px, 4vw, 44px); background: var(--bg-2); border-top: 2px solid var(--accent); }
.reader-cta .btn { margin-top: 22px; }
.reader-missing .btn { margin-top: 28px; }

@media (max-width: 900px) { .reader .posts { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .poll-bar i { transition: none; } }
