/* Weblog page styles (templates/blog/index.html), served via asset_url('css/blog.css'). */
[hidden] { display: none !important; }

/* Weblog (design v2). Shared pieces come from styles.css: .page, .page-head,
   .eyebrow, .lede, .sec-title, .rows, .chip, .input, .btn. Everything here
   is page layout plus the article prose (.md-body). New page-only pieces are
   prefixed .bl-. */

.bl-state { padding: 2rem 0; font-size: var(--fs-sm); color: var(--fg-dim); }
#blog-error.bl-state { color: var(--err); }

/* eyebrow / meta links (weblog / tag …) */
.bl-crumb { display: inline-flex; align-items: center; min-height: 32px; color: var(--accent); border-bottom: none;
            text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 3px; }
.bl-crumb:hover { color: var(--accent); text-decoration-color: currentColor; }
.bl-author { display: inline-flex; align-items: center; min-height: 32px; color: inherit; border-bottom: none;
             text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.bl-author:hover { color: var(--accent); text-decoration-color: currentColor; }
@media (max-width: 720px) { .bl-author { min-height: 40px; } }
.bl-head .eyebrow { display: flex; flex-wrap: wrap; align-items: center; gap: 0 0.5em; }
.bl-head h1, .md-body h1 { hyphens: manual; -webkit-hyphens: manual; }
.bl-head .lede a { white-space: nowrap; }

/* ── index: search · filters · list ─────────────────────────────── */
.bl-layout { display: flex; flex-direction: column; }
.bl-search { position: relative; }
.bl-search .input { padding-right: 46px; }
.bl-search .input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
#search-clear { position: absolute; top: 0; right: 0; width: 44px; height: 44px; padding: 0;
                display: inline-flex; align-items: center; justify-content: center; color: var(--fg-dim); cursor: pointer; }
#search-clear:hover { color: var(--fg); }

/* phones / tablets: the filters fold into one closed row under the search */
.bl-filters { margin-top: 0.6rem; }
.bl-filters > summary { display: flex; align-items: center; gap: 0.6rem; min-height: 44px; padding: 0 0.85rem;
                        list-style: none; cursor: pointer; border: 1px solid var(--border); border-radius: 3px;
                        font-size: var(--fs-sm); color: var(--fg-mid); }
.bl-filters > summary::-webkit-details-marker { display: none; }
.bl-filters > summary:hover { color: var(--fg); border-color: var(--border-strong); }
.bl-filters > summary::after, .bl-toc > summary::after {
  content: ''; flex-shrink: 0; width: 7px; height: 7px; margin-left: auto;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg); transition: transform 0.15s; }
.bl-filters[open] > summary::after, .bl-toc[open] > summary::after { transform: translateY(2px) rotate(-135deg); }
.bl-active { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--accent); }
.bl-filters-body { display: flex; flex-direction: column; gap: 2rem; padding: 1.4rem 0 0.4rem; }
.bl-side-sec .sec-title { margin-bottom: 0.8rem; }

.bl-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.bl-chips .chip { text-decoration: none; }
.bl-links { list-style: none; }
.bl-links a { display: inline-flex; align-items: center; min-height: 32px; font-size: var(--fs-sm); color: var(--fg-mid); border-bottom: none; }
.bl-links a:hover { color: var(--accent); }

/* mini calendar */
.cal-header { display: flex; align-items: center; gap: 4px; margin-bottom: 0.3rem; }
.cal-month-label { flex: 1; min-width: 0; text-align: center; font-family: var(--font-mono); font-size: var(--fs-xs);
                   color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-nav { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; min-height: 32px; padding: 0;
           background: none; border: 1px solid transparent; border-radius: 3px; cursor: pointer;
           color: var(--fg-dim); font: 1rem/1 var(--font-mono); }
.cal-nav:hover { color: var(--fg); border-color: var(--border-strong); }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.cal-day-hdr { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--fg-dim); text-align: center;
               padding: 2px 0; white-space: nowrap; overflow: hidden; }
.cal-day { display: flex; align-items: center; justify-content: center; min-height: 32px; min-width: 0;
           font-family: var(--font-mono); font-size: var(--fs-xs); border-radius: 3px; color: var(--fg-dim); }
button.cal-day { width: 100%; padding: 0; background: none; border: 1px solid transparent; }
.cal-day.has-post { color: var(--fg); background: var(--bg-tag); cursor: pointer; font-weight: 600; }
.cal-day.has-post:hover { border-color: var(--fg-mid); }
.cal-day.active-day { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.cal-day.today { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }

/* post list */
.bl-list { margin-top: 2.2rem; min-width: 0; }
.bl-list-head { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.2rem; }
.bl-list-head .sec-title { flex: 1; margin: 0; }
.bl-list-head .sec-title .idx { order: 2; }
.bl-list-head .sec-title::after { order: 3; }
.bl-rows { border-top: none; }
.bl-rows li { padding: 1rem 0; }
.bl-rows .rows-meta { display: flex; flex-direction: column; line-height: 1.6; }
.bl-pin { color: var(--accent); }
.bl-rows .pl-title, .bl-mini .pl-title { display: block; padding: 0.25rem 0; font-size: 1.0625rem; font-weight: 550;
                    line-height: 1.45; color: var(--fg); overflow-wrap: anywhere; }
.bl-rows .pl-title:hover, .bl-mini .pl-title:hover { color: var(--accent); }
.pl-desc { max-width: var(--measure); margin-top: 0.1rem; font-size: 0.9375rem; line-height: 1.55; color: var(--fg-mid);
           display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pl-tags { display: flex; flex-wrap: wrap; align-items: center; margin-top: 0.25rem;
           font-family: var(--font-mono); font-size: var(--fs-xs); }
.bl-rows .pl-tag, .bl-tags .pl-tag {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0;
  color: var(--fg-dim); border-bottom: none; cursor: pointer; text-decoration: none; }
/* separator after each tag (not before), so a wrapped line starts with a tag */
.pl-tag:not(:last-child)::after { content: '·'; display: inline-block; padding: 0 0.5em; color: var(--fg-dim); }
.bl-rows .pl-tag:hover, .bl-tags .pl-tag:hover { color: var(--fg); }
.bl-rows .pl-tag[aria-pressed="true"] { color: var(--accent); }
.pl-empty { padding: 1rem 0; color: var(--fg-dim); }
#no-results { padding: 1.2rem 0; font-size: var(--fs-sm); color: var(--fg-dim); }
.list-sentinel { height: 1px; }
mark { background: var(--accent); color: var(--on-accent); border-radius: 2px; padding: 0 1px; }

/* desktop: filters become a right column, always open */
@media (min-width: 1000px) {
  .bl-layout { display: grid; grid-template-columns: minmax(0, 1fr) 16rem; grid-template-rows: auto 1fr;
               column-gap: 4rem; align-items: start; }
  .bl-search { grid-column: 1; grid-row: 1; }
  .bl-list   { grid-column: 1; grid-row: 2; }
  .bl-filters { grid-column: 2; grid-row: 1 / span 2; margin-top: 0; }
  html.js .bl-filters > summary { display: none; }
  .bl-filters-body { padding-top: 0.6rem; }
  .bl-side-cal { order: -1; }
}

/* ── post ──────────────────────────────────────────────────────── */
.bl-post-aside { display: none; }
@media (min-width: 1200px) {
  .bl-post-grid { display: grid; grid-template-columns: minmax(0, 1fr) 15rem; column-gap: 4rem; }
  .bl-post-aside { display: block; }
}
.bl-post-main { min-width: 0; max-width: 47rem; }   /* ≈ 70ch of the 17 px article text */

.bl-post-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0 0.5rem;
                margin-bottom: 1rem; font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--fg-dim); letter-spacing: 0.02em; }
.bl-post-meta .pm-sep { color: var(--fg-dim); opacity: 0.6; }
.bl-tags { display: flex; flex-wrap: wrap; align-items: center; flex-basis: 100%; }

/* article prose */
.md-body { font-size: 1.0625rem; line-height: 1.75; color: var(--fg-mid);
           overflow-wrap: break-word; counter-reset: h2; }
.md-body p, .md-body ul, .md-body ol, .md-body table, .md-body blockquote { margin: 0 0 1.15em; }
.md-body h1 { margin: 0 0 1.6rem; font-size: clamp(1.75rem, 1.2rem + 2vw, 2.6rem); font-weight: 650; line-height: 1.14;
              letter-spacing: -0.015em; text-transform: none; color: var(--fg); overflow-wrap: break-word; text-wrap: balance; }
.md-body .md-published { display: none; }   /* the date is in the meta line above */
.md-body > h1 + p:not(.md-published), .md-body > .md-published + p { font-size: 1.1875rem; line-height: 1.65; color: var(--fg); }
.md-body h2 { counter-increment: h2; margin: 3rem 0 1rem; font-size: 1.375rem; font-weight: 620; line-height: 1.3;
              letter-spacing: -0.01em; text-transform: none; color: var(--fg); overflow-wrap: break-word; }
.md-body h2::before { content: counter(h2, decimal-leading-zero); display: inline-block; margin-right: 0.75rem;
                      font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 400; letter-spacing: 0;
                      color: var(--accent); vertical-align: 0.3em; }
.md-body hr + h2 { margin-top: 0; }
.md-body h3 { margin: 2.2rem 0 0.6rem; font-size: 1.125rem; font-weight: 620; line-height: 1.4; color: var(--fg); overflow-wrap: break-word; }
.md-body h4, .md-body h5, .md-body h6 { margin: 1.6rem 0 0.4rem; font-size: 1rem; font-weight: 620; color: var(--fg); }
.md-body h2 + h3 { margin-top: 1.2rem; }
.md-body strong { font-weight: 650; color: var(--fg); }
.md-body hr { border: 0; border-top: 1px solid var(--border); margin: 2.8rem 0 2.4rem; }
.md-body ul, .md-body ol { padding-left: 1.35rem; }
.md-body ul { list-style: none; }
.md-body ul > li { position: relative; }
.md-body ul > li::before { content: '-'; position: absolute; left: -1.15rem; color: var(--accent); }
.md-body ol > li::marker { color: var(--fg-dim); font-family: var(--font-mono); font-size: 0.85em; }
.md-body li { margin-bottom: 0.4em; }
.md-body li > p { margin-bottom: 0.5em; }
.md-body li > ul, .md-body li > ol { margin: 0.4em 0 0; }
.md-body img, .md-body video { max-width: 100%; height: auto; border-radius: 3px; }
.md-body blockquote { padding: 0.1rem 0 0.1rem 1.1rem; border-left: 2px solid var(--accent); color: var(--fg-mid); }
.md-body blockquote > :last-child { margin-bottom: 0; }
.md-body :not(pre) > code { padding: 0.1em 0.36em; border-radius: 3px; background: var(--bg-tag); color: var(--fg);
                            font-family: var(--font-mono); font-size: 0.84em; overflow-wrap: anywhere; }

/* code blocks: a label strip (language + copy) over the code */
.md-body pre { position: relative; margin: 1.6rem 0; padding: 0.95rem 1.1rem; overflow-x: auto;
               background: var(--bg-pre); border: 1px solid var(--border); border-radius: 4px;
               font-family: var(--font-mono); font-size: 0.84rem; line-height: 1.65; color: var(--fg); }
.md-body pre code { background: none; padding: 0; font-size: inherit; }
.md-body pre.code-block { padding: 40px 0 0; overflow: hidden; }
.md-body pre.code-block code { display: block; padding: 0.95rem 1.1rem 1.05rem; border-top: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 0.84rem; line-height: 1.65; color: var(--fg); background: none;
  overflow-x: auto; white-space: pre; word-break: normal; overflow-wrap: normal; }
.code-lang-label { position: absolute; top: 0; left: 1.1rem; height: 40px; display: inline-flex; align-items: center;
  font: var(--fs-xs)/1 var(--font-mono); letter-spacing: 0.04em; text-transform: lowercase; color: var(--fg-dim); pointer-events: none; }
/* YAML true/false/null (VS Code constant colour; syntax colours have no token) */
.yaml-bool { color: #0000ff; }
[data-theme="dark"] .yaml-bool { color: #569cd6; }
.copy-btn { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; padding: 0;
            display: inline-flex; align-items: center; justify-content: center;
            color: var(--fg-dim); border: 1px solid transparent; background: none;
            border-radius: 3px; cursor: pointer; transition: color .15s, border-color .15s; }
.copy-btn:hover { color: var(--fg); border-color: var(--border-strong); }
.copy-btn.copied { color: var(--ok); border-color: var(--ok); }
.copy-btn.copy-failed { color: var(--err); border-color: var(--err); }
.copy-btn svg { width: 14px; height: 14px; pointer-events: none; }

/* tables: hairlines only, scroll sideways on phones */
.md-body table { display: block; max-width: 100%; overflow-x: auto; margin: 1.6rem 0; border-collapse: collapse;
                 font-size: var(--fs-sm); line-height: 1.5; -webkit-overflow-scrolling: touch; }
.md-body th, .md-body td { padding: 0.55rem 1.1rem 0.55rem 0; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.md-body th { font-weight: 400; font-size: var(--fs-xs); letter-spacing: 0.04em; color: var(--fg-dim);
              border-bottom-color: var(--border-strong); }
.md-body th:last-child, .md-body td:last-child { padding-right: 0; }

.mermaid { margin: 1.6rem 0; text-align: center; overflow-x: auto; }
.mermaid svg { max-width: 100%; height: auto; }

/* table of contents: right column ≥ 1200 px, a closed <details> in the article below that */
.bl-toc > summary { display: flex; align-items: center; gap: 0.75rem; min-height: 44px; list-style: none; cursor: pointer;
                    font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); }
.bl-toc > summary::-webkit-details-marker { display: none; }
.bl-toc > summary::after { margin-left: 0; color: var(--fg-dim); }
.bl-toc-rule { flex: 1; height: 1px; background: var(--border); }
.md-body .bl-toc { margin: 0 0 1.6rem; }
.md-body .bl-toc + h2 { margin-top: 0; }
.toc-nav { padding: 0.2rem 0 0.6rem; }
.md-body .toc-nav a, .toc-nav a {
  display: flex; align-items: baseline; gap: 0.7rem; min-height: 32px; padding: 0.35rem 0 0.35rem 0.7rem;
  border-left: 2px solid var(--border); font-size: var(--fs-sm); line-height: 1.4; color: var(--fg-mid);
  text-decoration: none; overflow-wrap: anywhere; transition: color .15s, border-color .15s; }
.toc-nav a:hover { color: var(--fg); }
.toc-nav a:focus-visible { outline-offset: -2px; }
.toc-nav a[aria-current] { color: var(--fg); border-left-color: var(--accent); }
.toc-idx { flex-shrink: 0; min-width: 1.4rem; font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--fg-dim); }
.toc-nav a.toc-h3, .md-body .toc-nav a.toc-h3 { padding-left: calc(0.7rem + 1.4rem + 0.7rem); font-size: 0.8125rem; color: var(--fg-dim); }
.bl-post-aside { align-self: stretch; }
.bl-post-aside .bl-toc { position: sticky; top: 80px; max-height: calc(100vh - 100px); overflow-y: auto; scrollbar-width: thin; }

/* after the article: like · series · related · older/newer */
.like-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem;
             margin-top: 2.8rem; padding-top: 1.6rem; border-top: 1px solid var(--border); }
.like-btn .like-heart { font-size: 1.05em; line-height: 1; }
.like-btn .like-count { font-family: var(--font-mono); font-size: var(--fs-xs); }
.like-btn.liked { color: var(--accent); border-color: var(--accent); cursor: default; }
.like-btn.liked:hover { background: none; }
.like-hint { font-size: var(--fs-xs); color: var(--fg-dim); }
.bl-sec, .post-prevnext { margin-top: 3rem; }
.bl-sec .sec-title, .post-prevnext .sec-title { margin-bottom: 0.4rem; }
.bl-series-name { margin: 0.6rem 0 0.4rem; font-size: var(--fs-sm); color: var(--fg-mid); }
.bl-series-name a { display: inline-flex; align-items: center; min-height: 32px; color: var(--fg); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; border-bottom: none; }
.bl-series-name a:hover { color: var(--accent); text-decoration-color: var(--accent); }
.bl-series-name .meta { margin-left: 0.4rem; }
.bl-mini li { padding: 0.45rem 0; }
.bl-mini .rows-meta { white-space: nowrap; }
.bl-mini .pl-title { padding: 0.3rem 0; font-size: 0.9875rem; font-weight: 500; }

/* scroll-to-top (base look in styles.css): keep it a real tap target */
#scroll-top { min-height: 32px; display: inline-flex; align-items: center; gap: 4px; border-radius: 3px; }

/* ── phones ─────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .bl-page { padding-top: 28px; }
  .bl-head { margin-bottom: 1.4rem; }
  #scroll-top { min-height: 40px; }
  .bl-crumb, .bl-links a, .bl-rows .pl-tag, .bl-tags .pl-tag, .bl-series-name a { min-height: 40px; }
  .bl-chips .chip, .clear-filters { min-height: 40px; }
  .bl-rows .pl-title, .bl-mini .pl-title { min-height: 40px; padding: 0.45rem 0; }
  .cal-nav { min-width: 40px; min-height: 40px; }
  .cal-day { min-height: 40px; }
  .copy-btn { width: 40px; height: 40px; }
  .md-body pre.code-block { padding-top: 48px; }
  .code-lang-label { height: 48px; left: 0.85rem; }
  .md-body pre.code-block code { padding-left: 0.85rem; padding-right: 0.85rem; }
  .md-body { font-size: 1rem; line-height: 1.7; }
  .md-body > h1 + p:not(.md-published), .md-body > .md-published + p { font-size: 1.0625rem; }
  .md-body h2 { margin-top: 2.4rem; font-size: 1.25rem; }
  .md-body h3 { font-size: 1.0625rem; }
  .md-body pre { font-size: 0.8rem; }
  .md-body pre.code-block code { font-size: 0.8rem; }
  .toc-nav a, .md-body .toc-nav a { min-height: 40px; align-items: center; }
}
@media (max-width: 520px) {
  .bl-rows li { padding: 0.8rem 0; }
  .bl-rows .rows-meta { flex-direction: row; flex-wrap: wrap; gap: 0 0.5rem; }
  .bl-rows .rows-meta > * + *::before { content: '·'; margin-right: 0.5rem; }
  .bl-mini li { padding: 0.5rem 0; }
}
