/* Blog: index and article pages, generated by tools/blog/build.py. Written for the phone first: one thumb reach, list
   rows that show many titles per screen, categories that stay in reach, and larger screens only add room. */
.blog { background: #000; }
.blog .nav { background: rgba(0, 0, 0, 0.82); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); padding-bottom: 14px; }
.blog-main { padding: 84px 0 60px; }
.blog-head { display: grid; gap: 16px; padding: 0 var(--gutter); }
.blog-title { font-size: clamp(64px, 12vw, 180px); line-height: 0.82; margin-left: -0.02em; }
.blog-search { width: 100%; max-width: 640px; min-height: 52px; padding: 0 20px; border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 999px; background: #0d0d10; color: #fff; font: 500 17px var(--body); }
.blog-search::placeholder { color: var(--muted); }
/* The categories stay under the site navigation while the list scrolls. */
.blog-bar { position: sticky; top: var(--nav-height, 62px); z-index: 10; margin-top: 14px; padding: 8px var(--gutter); background: rgba(0, 0, 0, 0.9); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.blog-bar .filter { justify-content: flex-start; }
/* On phones the categories run edge to edge and carry their own side padding (base.css). */
@media (max-width: 720px) { .blog-bar { padding-inline: 0; } }
.blog-count { padding: 14px var(--gutter) 0; color: var(--muted); font-size: 16px; }
.blog-empty { display: grid; justify-items: start; gap: 16px; padding: 30px var(--gutter) 60px; font-size: 22px; }
.blog-empty[hidden], .blog-count[hidden], .shelf[hidden], .card[hidden], .shelf-all[hidden] { display: none; }

.shelves { display: grid; gap: clamp(36px, 5vw, 72px); padding: clamp(18px, 3vw, 36px) var(--gutter) 0; }
.shelf { scroll-margin-top: 130px; }
.shelf-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.shelf-title { font-size: clamp(23px, 2.6vw, 42px); font-weight: 800; line-height: 1.08; letter-spacing: -0.01em; }
.shelf-all { flex: none; padding: 8px 0; color: var(--ui); font-size: 16px; font-weight: 600; transition: color 0.2s, text-shadow 0.2s; }
.shelf-all:hover { color: #fff; text-shadow: var(--glow-ui); }
/* While browsing, each category previews four articles. Without the script every article stays listed. */
.is-browsing .shelf .card:nth-child(n + 5) { display: none; }

/* A card is a list row on phones, and stands up as a tile once there is room. */
.grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.card { display: grid; grid-template-columns: 92px minmax(0, 1fr); align-items: center; gap: 14px; min-height: 92px; min-width: 0; color: #fff; text-decoration: none; }
.card img { width: 100%; height: auto; aspect-ratio: 1; object-fit: contain; border-radius: 12px; background: #101014; transition: transform 0.35s var(--ease); }
.card:hover img { transform: scale(1.02); }
.card-text { display: grid; gap: 5px; }
.card-meta { color: var(--muted); font-size: 14px; }
.card-title { font-size: 18px; font-weight: 700; line-height: 1.2; transition: color 0.2s, text-shadow 0.2s; }
.card:hover .card-title { color: var(--ui); text-shadow: var(--glow-ui); }
@media (min-width: 721px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(26px, 2.6vw, 40px) clamp(16px, 1.6vw, 24px); }
  .card { display: flex; flex-direction: column; align-items: stretch; }
  .card-title { font-size: clamp(19px, 1.45vw, 23px); }
  .blog-bar .filter { flex-wrap: wrap; }
}
/* With room to spare, the categories become a side list that stays in view next to the articles. */
@media (min-width: 1100px) {
  .blog-main { display: grid; grid-template-columns: 270px minmax(0, 1fr); column-gap: clamp(24px, 3vw, 48px); align-content: start; padding-inline: var(--gutter); }
  .blog-head { grid-column: 1 / -1; padding: 0 0 clamp(20px, 2.4vw, 36px); }
  .blog-bar { grid-column: 1; grid-row: 2 / span 3; align-self: start; top: calc(var(--nav-height, 62px) + 8px); margin: 0; padding: 0; background: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .blog-bar .filter { display: grid; gap: 6px; }
  .blog-bar .chip { justify-content: space-between; }
  .blog-count, .shelves, .blog-empty { grid-column: 2; padding-inline: 0; }
  .blog-count { padding-top: 0; padding-bottom: 14px; }
  .shelves { padding-top: 0; }
}
@media (min-width: 1280px) {
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.blog-foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 26px; padding: 30px var(--gutter) 34px; border-top: 1px solid var(--line); color: var(--muted); font-size: 15px; }
.blog-foot a { color: var(--text); transition: color 0.2s, text-shadow 0.2s; }
.blog-foot a:hover { color: var(--ui); text-shadow: var(--glow-ui); }

/* Article page */
.progress { position: fixed; z-index: 30; inset: 0 0 auto; height: 3px; background: var(--ui); transform: scaleX(var(--read, 0)); transform-origin: left; }
.post { padding-top: 90px; }
.post-head { padding: 0 var(--gutter); max-width: 1180px; margin: 0 auto; }
.crumbs { color: var(--muted); font-size: 16px; }
.crumbs a { color: var(--text); transition: color 0.2s, text-shadow 0.2s; }
.crumbs a:hover { color: var(--ui); text-shadow: var(--glow-ui); }
.post-title { margin-top: 14px; font-size: clamp(34px, 5.2vw, 80px); font-weight: 800; line-height: 1.02; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.post-meta { margin-top: 16px; color: var(--muted); font-size: 17px; }
.post-cover { max-width: 1180px; margin: clamp(22px, 3vw, 40px) auto 0; padding: 0 var(--gutter); }
.post-cover img { width: 100%; height: auto; max-height: 76vh; object-fit: contain; border-radius: 16px; background: #0d0d10; }
.post-layout { display: grid; grid-template-columns: minmax(200px, 270px) minmax(0, 720px); justify-content: center; gap: clamp(30px, 5vw, 80px); max-width: 1180px; margin: clamp(30px, 4vw, 56px) auto 0; padding: 0 var(--gutter); }
.post-layout.no-toc { grid-template-columns: minmax(0, 720px); }
.toc { position: sticky; top: 84px; align-self: start; max-height: calc(100vh - 110px); overflow: auto; }
.toc summary { font-size: 16px; font-weight: 700; cursor: pointer; }
.toc ol { display: grid; gap: 2px; margin: 10px 0 0; padding: 0; list-style: none; }
.toc a { display: block; padding: 7px 0 7px 12px; border-left: 2px solid var(--line); color: var(--muted); font-size: 15px; line-height: 1.28; text-decoration: none; transition: color 0.15s, border-color 0.15s; }
.toc a:hover, .toc a.is-active { color: #fff; border-color: var(--ui); }
.toc a:hover { text-shadow: var(--glow-white); }
@media (max-width: 960px) {
  .post-layout { grid-template-columns: minmax(0, 1fr); gap: 26px; }
  .toc { position: static; max-height: none; padding: 14px 18px; border: 1px solid var(--line); border-radius: 14px; }
}

.prose { min-width: 0; color: #e6e6ea; font-size: clamp(19px, 1.35vw, 21px); line-height: 1.62; overflow-wrap: break-word; }
.prose > * + * { margin-top: 1.05em; }
.prose h2 { margin-top: 2em; color: #fff; font-size: clamp(27px, 2.5vw, 38px); overflow-wrap: break-word; font-weight: 800; line-height: 1.12; scroll-margin-top: 84px; }
.prose h3 { margin-top: 1.7em; color: #fff; font-size: clamp(21px, 1.7vw, 25px); overflow-wrap: break-word; font-weight: 700; line-height: 1.2; }
.prose h2 + *, .prose h3 + * { margin-top: 0.6em; }
.prose > :first-child { margin-top: 0; }
.prose strong { color: #fff; font-weight: 700; }
.prose a { color: var(--ui); transition: color 0.2s, text-shadow 0.2s; }
.prose a:hover { color: #fff; text-shadow: var(--glow-ui); }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: 0.5em; }
.prose li::marker { color: var(--muted); }
.prose figure { margin: 1.8em 0; }
.prose img { width: 100%; height: auto; max-height: 72vh; object-fit: contain; border-radius: 14px; background: #0d0d10; }

.post-cta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px; margin-top: clamp(50px, 6vw, 90px); padding: clamp(28px, 4vw, 56px) var(--gutter); background: var(--ui); color: #000; }
.post-cta-text { max-width: 18em; font-size: clamp(30px, 4.6vw, 78px); }
.post-cta .btn-primary { background: #000; color: #fff; }
.btn-cta { min-height: 60px; padding: 12px 34px; font-size: 18px; }
.steps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.step { display: grid; align-content: start; gap: 6px; padding: clamp(22px, 2.6vw, 36px) var(--gutter); color: #fff; text-decoration: none; transition: background 0.2s; }
.step:hover { background: #17171b; }
.step small { color: var(--muted); font-size: 15px; }
.step b { font-size: clamp(19px, 1.7vw, 26px); line-height: 1.18; }
.step-next { grid-column: 2; text-align: right; border-left: 1px solid var(--line); }
@media (max-width: 620px) { .steps { grid-template-columns: minmax(0, 1fr); } .step-next { grid-column: 1; text-align: left; border-left: 0; border-top: 1px solid var(--line); } }
.related { display: grid; justify-items: start; gap: 26px; padding: clamp(40px, 5vw, 70px) var(--gutter); }
.related .grid { width: 100%; }
.related-title { font-size: clamp(27px, 3.4vw, 54px); font-weight: 800; line-height: 1.05; letter-spacing: -0.02em; }

/* Phone reading bar: previous, contents and next, always under the thumb. */
.reader-bar { display: none; }
@media (max-width: 960px) {
  .blog:has(.reader-bar) { padding-bottom: 60px; }
  .reader-bar { position: fixed; z-index: 25; inset: auto 0 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); border-top: 1px solid var(--line); background: rgba(0, 0, 0, 0.92); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
  .reader-bar a, .reader-contents { display: grid; place-items: center; min-height: 56px; padding: 0 8px; border: 0; background: none; color: #fff; font: 600 16px var(--body); text-decoration: none; cursor: pointer; }
  .reader-contents[aria-expanded='true'] { color: var(--ui); }
  /* Contents opens as a sheet above the bar. */
  .toc.is-sheet { position: fixed; z-index: 24; inset: auto 0 57px; max-height: 62vh; overflow: auto; border-width: 1px 0 0; border-radius: 18px 18px 0 0; background: #0d0d10; }
}
@media (prefers-reduced-motion: reduce) { .card img, .step, .toc a { transition: none; } .card:hover img { transform: none; } }
