/* ==========================================================================
   Blog — reading layout on the quiet personal system (tokens from base.css)
   ========================================================================== */

.blog {
  --measure: 42rem;
}

.blog .eyebrow {
  font-size: 13px;
  color: var(--mute);
  margin: 0 0 12px;
}

.blog .eyebrow a {
  color: var(--mute);
}

.blog-head h1,
.post-head h1 {
  font: 700 clamp(28px, 5vw, 44px)/1.1 var(--sans);
  letter-spacing: -0.02em;
  margin: 0 0 12px;
  text-wrap: balance;
}

.blog .lead {
  font-size: 18px;
  line-height: 1.5;
  color: var(--mute);
  margin: 0 0 20px;
  max-width: var(--measure);
  text-wrap: pretty;
}

.blog-tools {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 20px 0 16px;
}

.blog-search {
  display: flex;
  gap: 8px;
  flex: 1;
  max-width: 28rem;
}

.blog-search input[type=search] {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 6px;
}

.feed-link {
  font-size: 13px;
  color: var(--mute);
}

.blog-cats {
  margin-bottom: 32px;
}

.chips .chip span {
  color: var(--mute);
  margin-left: 4px;
}

.chips a[aria-current=page] span {
  color: var(--hl);
}

.author-head {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 12px;
}

.author-head h1 {
  margin: 0;
}

.author-head .avatar {
  width: 56px;
  height: 56px;
}

/* --- cards ---------------------------------------------------------------- */

.featured {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  margin-bottom: 40px;
}

.featured .post-card.big {
  grid-column: 1 / -1;
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 32px 24px;
  border-top: 1px solid var(--rule);
  padding-top: 32px;
}

.post-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 0;
  padding-top: 0;
}

.post-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.post-card-img {
  display: block;
  border-radius: 8px;
  overflow: hidden;
  background: var(--card);
  aspect-ratio: 16 / 9;
}

.post-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.post-card:hover .post-card-img img {
  transform: scale(1.02);
}

.post-card.big .post-card-img {
  aspect-ratio: 2 / 1;
}

.post-card-title {
  font: 700 19px/1.25 var(--sans);
  margin: 0;
  text-wrap: balance;
}

.post-card.big .post-card-title {
  font-size: clamp(22px, 3.4vw, 30px);
}

.post-card-title a {
  text-decoration: none;
}

.post-card-title a:hover {
  text-decoration: underline;
  text-decoration-color: var(--ink);
}

.post-card-summary {
  margin: 0;
  color: var(--mute);
  font-size: 14px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-meta {
  margin: 0;
  font-size: 12px;
  color: var(--mute);
}

.post-meta a {
  color: var(--mute);
}

/* --- article -------------------------------------------------------------- */

.preview-banner {
  margin-bottom: 24px;
}

.blog-post {
  max-width: var(--measure);
  margin: 0 auto;
}

.post-head {
  margin-bottom: 28px;
}

.byline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
  font-size: 13px;
  color: var(--mute);
}

.byline-author {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}

.post-cover {
  margin: 0 0 32px;
}

.post-cover img,
.blog-img img,
.blog-gallery img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  background: var(--card);
}

@media (min-width: 900px) {
  .post-cover,
  .blog-img.size-wide {
    margin-left: calc((var(--measure) - var(--col)) / 2);
    margin-right: calc((var(--measure) - var(--col)) / 2);
  }
}

.blog-img.size-full {
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
}

.blog-img.size-full img {
  border-radius: 0;
}

.series-box {
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 14px 18px;
  margin: 0 0 24px;
  background: var(--card);
  font-size: 14px;
}

.series-box p {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--mute);
}

.series-box ol {
  margin: 0;
  padding-left: 1.3rem;
}

.post-toc {
  margin: 0 0 28px;
}

.post-toc strong {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mute);
  margin-bottom: 6px;
}

.post-toc .toc-l3 { margin-left: 1rem; }
.post-toc .toc-l4 { margin-left: 2rem; }

/* --- prose ---------------------------------------------------------------- */

.post-body {
  font-size: 17px;
  line-height: 1.7;
  overflow-wrap: break-word;
}

.post-body > * {
  margin: 0 0 1.25em;
}

.post-body h2,
.post-body h3,
.post-body h4 {
  line-height: 1.25;
  margin: 2em 0 0.6em;
  scroll-margin-top: 16px;
  text-wrap: balance;
}

.post-body h2 { font-size: 26px; letter-spacing: -0.01em; }
.post-body h3 { font-size: 21px; }
.post-body h4 { font-size: 17px; text-transform: uppercase; letter-spacing: 0.03em; }

.post-body .anchor {
  color: var(--mute);
  text-decoration: none;
  opacity: 0;
  font-weight: 400;
  transition: opacity 0.15s ease;
}

.post-body :is(h2, h3, h4):hover .anchor,
.post-body .anchor:focus-visible {
  opacity: 1;
}

.post-body a {
  text-decoration-color: var(--mute);
}

.post-body ul,
.post-body ol {
  padding-left: 1.4em;
}

.post-body li + li {
  margin-top: 0.35em;
}

.post-body .checklist {
  list-style: none;
  padding-left: 0;
}

.post-body .checklist li {
  display: flex;
  gap: 10px;
}

.post-body .checklist .check {
  flex: none;
  width: 1.1em;
  height: 1.1em;
  margin-top: 0.3em;
  border: 1.5px solid var(--mute);
  border-radius: 4px;
  display: grid;
  place-items: center;
  font-size: 0.75em;
  line-height: 1;
}

.post-body .checklist .done .check {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.post-body .checklist .done > :last-child {
  color: var(--mute);
}

.post-body blockquote {
  margin-left: 0;
  margin-right: 0;
  padding: 2px 0 2px 20px;
  border-left: 3px solid var(--ink);
  font-size: 19px;
  font-style: italic;
}

.post-body blockquote p {
  margin: 0;
}

.post-body blockquote footer {
  margin-top: 8px;
  font: normal 13px var(--mono);
  color: var(--mute);
}

.post-body code {
  font: 0.88em var(--mono);
  background: var(--hl);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.post-body mark {
  background: color-mix(in srgb, var(--warning) 30%, transparent);
  color: inherit;
  padding: 0 0.15em;
  border-radius: 3px;
}

.code-block {
  position: relative;
  margin-left: 0;
  margin-right: 0;
}

.code-block pre {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.55;
}

.code-block pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

.code-block[data-lang]::before {
  content: attr(data-lang);
  position: absolute;
  top: 6px;
  right: 54px;
  font: 11px var(--mono);
  color: var(--mute);
  text-transform: lowercase;
}

.code-block .copy {
  position: absolute;
  top: 4px;
  right: 6px;
  font: 11px var(--mono);
  padding: 3px 8px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--bg);
  color: var(--mute);
  cursor: pointer;
}

.code-block .copy:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.table-wrap {
  overflow-x: auto;
}

.post-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.post-body th,
.post-body td {
  text-align: left;
  padding: 8px 12px 8px 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

.post-body th {
  font: 600 12px var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--mute);
}

.post-body hr {
  border: 0;
  height: 1px;
  background: var(--rule);
  margin: 2.5em 0;
}

.post-body figure {
  margin-left: 0;
  margin-right: 0;
}

.post-body figcaption {
  margin-top: 8px;
  font: 13px/1.5 var(--mono);
  color: var(--mute);
  text-align: center;
}

.blog-gallery ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
}

.blog-gallery.cols-2 { --cols: 2; }
.blog-gallery.cols-3 { --cols: 3; }
.blog-gallery.cols-4 { --cols: 4; }

.blog-gallery li + li {
  margin-top: 0;
}

.blog-gallery figure {
  margin: 0;
}

.blog-gallery img {
  aspect-ratio: 1;
  object-fit: cover;
}

.callout {
  border: 1px solid var(--rule);
  border-left: 4px solid var(--tone, var(--ink));
  border-radius: 6px;
  background: var(--card);
  padding: 14px 18px;
  font-size: 16px;
}

.callout p {
  margin: 0;
}

.callout-title {
  display: block;
  font: 700 12px var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
  color: var(--tone, var(--ink));
}

.callout.tone-tip { --tone: var(--success); }
.callout.tone-warning { --tone: var(--warning); }
.callout.tone-danger { --tone: var(--danger); }

.blog-board .diagram-board,
.blog-replay .diagram-board {
  max-width: 440px;
  margin: 0 auto;
}

.blog-replay {
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 16px;
  background: var(--card);
}

.replay-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
}

.replay-bar button {
  min-width: 40px;
  min-height: 36px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  font-size: 14px;
}

.replay-bar button:hover:not(:disabled) {
  border-color: var(--ink);
}

.replay-bar button:disabled {
  opacity: 0.4;
  cursor: default;
}

.replay-pos {
  min-width: 9ch;
  text-align: center;
  font: 13px var(--mono);
  color: var(--mute);
}

.play-cta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-radius: 8px;
  background: var(--hl);
}

.play-cta-game {
  font: 700 18px var(--sans);
}

.play-cta .btn {
  text-decoration: none;
}

.blog-yt .yt-load {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  padding: 0;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: #111;
  color: #fff;
}

.blog-yt .yt-load img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0.85;
  border-radius: 0;
}

.blog-yt .yt-play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 72px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.72);
  font-size: 22px;
  transition: background 0.15s ease;
}

.blog-yt .yt-load:hover .yt-play,
.blog-yt .yt-load:focus-visible .yt-play {
  background: #c00;
}

.blog-yt .yt-note {
  position: absolute;
  left: 10px;
  bottom: 8px;
  font: 11px var(--mono);
  opacity: 0.85;
}

.blog-yt iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: 8px;
}

.link-card {
  display: flex;
  gap: 0;
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
  text-decoration: none;
  background: var(--card);
  transition: border-color 0.15s ease;
}

.link-card:hover {
  border-color: var(--ink);
}

.link-card img {
  flex: none;
  width: 34%;
  max-width: 220px;
  object-fit: cover;
  background: var(--hl);
}

.lc-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  min-width: 0;
  font-size: 14px;
  line-height: 1.45;
}

.lc-body strong {
  font-size: 15px;
}

.lc-desc {
  color: var(--mute);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.lc-body small {
  font: 12px var(--mono);
  color: var(--mute);
}

.link-card.plain {
  display: block;
  padding: 12px 16px;
  font: 14px var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
}

.blog-inline-ad {
  margin: 2em 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* --- footer, related, comments ------------------------------------------ */

.post-foot {
  margin-top: 40px;
  display: grid;
  gap: 20px;
}

.series-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 14px;
  border-top: 1px solid var(--rule);
  padding-top: 16px;
}

.series-nav a[rel=next] {
  margin-left: auto;
  text-align: right;
}

.comments {
  max-width: var(--measure);
  margin-left: auto;
  margin-right: auto;
}

.comment-list,
.comment-replies {
  list-style: none;
  margin: 0;
  padding: 0;
}

.comment-list > .comment {
  border-top: 1px solid var(--rule);
  padding: 16px 0;
}

.comment-replies {
  margin-top: 12px;
  padding-left: 20px;
  border-left: 2px solid var(--rule);
}

.comment-replies .comment + .comment {
  margin-top: 14px;
}

.comment-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: var(--mute);
}

.comment-head a {
  color: var(--ink);
  font-weight: 600;
}

.comment-body {
  margin: 6px 0 0;
  font-size: 15px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.comment.pending .comment-body {
  opacity: 0.7;
}

.comment-actions {
  display: flex;
  gap: 14px;
  margin-top: 6px;
  font-size: 12px;
}

.comment-form {
  margin-top: 24px;
  max-width: none;
}

.comment-form .hint {
  font-size: 12px;
  color: var(--mute);
  margin: -0.5rem 0 0.85rem;
}

@media (max-width: 760px) {
  .featured,
  .post-grid,
  .post-grid.three {
    grid-template-columns: minmax(0, 1fr);
  }
  .post-body {
    font-size: 16px;
  }
  .blog-gallery.cols-3,
  .blog-gallery.cols-4 {
    --cols: 2;
  }
  .link-card {
    flex-direction: column;
  }
  .link-card img {
    width: 100%;
    max-width: none;
    aspect-ratio: 1.91 / 1;
  }
  .blog-tools {
    flex-wrap: wrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  .post-card-img img {
    transition: none;
  }
  .post-card:hover .post-card-img img {
    transform: none;
  }
}
