/* ============================================================
   blog.css — blog index, article, the 210x290mm sheet, print
   ============================================================ */

/* =========================================================
   1. BLOG INDEX
   ========================================================= */
.blog-hero { padding-block: clamp(48px, 8vw, 88px) clamp(24px, 4vw, 40px); }
.blog-hero__inner { max-width: 720px; }
.blog-hero h1 { margin: 0.2em 0 0.3em; }
.blog-hero p { color: var(--text-soft); font-family: var(--font-serif); font-size: 1.2rem; line-height: 1.5; }

/* Flagship series feature card */
.series-feature {
  display: grid; grid-template-columns: 1fr; gap: 22px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px; box-shadow: var(--shadow-sm);
  margin-bottom: 40px; position: relative; overflow: hidden;
}
.series-feature::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px;
  background: radial-gradient(circle at center, var(--accent-soft), transparent 70%);
  pointer-events: none;
}
@media (min-width: 780px) { .series-feature { grid-template-columns: 1.5fr 1fr; align-items: center; } }
.series-feature h2 { font-size: 1.6rem; margin: 8px 0 10px; }
.series-feature p { color: var(--text-soft); margin-bottom: 16px; }
.series-feature__mini {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  transform: perspective(700px) rotateY(-8deg);
}
.mini-sheet {
  aspect-ratio: 210 / 290; background: #fff; border: 1px solid var(--sheet-line);
  border-radius: 3px; box-shadow: var(--shadow-md); padding: 8px;
  display: flex; flex-direction: column; gap: 3px;
}
.mini-sheet i { display: block; height: 2px; border-radius: 2px; background: #e7e2d6; }
.mini-sheet i.h { height: 4px; width: 60%; background: var(--accent); opacity: 0.7; margin-bottom: 2px; }
.mini-sheet i.s { width: 90%; } .mini-sheet i.m { width: 70%; } .mini-sheet i.l { width: 100%; }

/* Filter / control bar */
.blog-controls {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  margin-bottom: 26px; padding-bottom: 18px; border-bottom: 1px solid var(--border);
}
.filter-group { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-btn {
  font-family: var(--font-sans); font-size: 0.85rem; font-weight: 600;
  padding: 0.4em 0.85em; border-radius: 999px; cursor: pointer;
  background: transparent; color: var(--text-soft); border: 1px solid var(--border);
  transition: all 0.15s ease;
}
.filter-btn:hover { color: var(--text); border-color: var(--border-strong); }
.filter-btn[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.filter-btn__count {
  display: inline-block; margin-left: 0.5em; padding: 0.1em 0.5em;
  font-size: 0.75rem; font-weight: 700; line-height: 1.4; border-radius: 999px;
  background: var(--surface); color: var(--text-soft);
}
.filter-btn[aria-pressed="true"] .filter-btn__count { background: rgba(255, 255, 255, 0.22); color: #fff; }
.search-box {
  display: flex; align-items: center; gap: 8px; padding: 0.45em 0.85em;
  border: 1px solid var(--border); border-radius: 999px; background: var(--bg-elev);
  min-width: 220px;
}
.search-box:focus-within { border-color: var(--accent); }
.search-box svg { width: 16px; height: 16px; color: var(--text-faint); flex-shrink: 0; }
.search-box input {
  border: 0; background: transparent; color: var(--text); font-family: var(--font-sans);
  font-size: 0.9rem; width: 100%; outline: none;
}

/* Post list — editorial index style */
.post-list { list-style: none; display: flex; flex-direction: column; }
.post-row {
  display: grid; grid-template-columns: 1fr; gap: 6px;
  padding: 24px 0; border-bottom: 1px solid var(--border);
  transition: opacity 0.2s ease;
}
.post-row a.post-row__link { text-decoration: none; color: inherit; display: block; }
.post-row a.post-row__link:hover .post-row__title { color: var(--accent); }
.post-row__meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  font-family: var(--font-sans); font-size: 0.8rem; color: var(--text-faint);
  margin-bottom: 4px;
}
.post-row__date { font-family: var(--font-mono); color: var(--text-soft); }
.post-row__series { color: var(--accent); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; font-size: 0.74rem; }
.post-row__title { font-family: var(--font-serif); font-size: 1.5rem; line-height: 1.2; color: var(--text); margin-bottom: 4px; transition: color 0.15s ease; }
.post-row__excerpt { color: var(--text-soft); max-width: 68ch; font-size: 0.98rem; }
.post-row__tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
@media (min-width: 780px) {
  .post-row { grid-template-columns: 130px 1fr; column-gap: 28px; }
  .post-row__aside { padding-top: 4px; }
  .post-row__meta { flex-direction: column; align-items: flex-start; gap: 6px; margin: 0; }
}

/* States */
.state-msg {
  text-align: center; padding: 64px 20px; color: var(--text-soft);
  border: 1px dashed var(--border); border-radius: var(--radius-lg); background: var(--bg-elev);
}
.state-msg h3 { margin-bottom: 8px; }
.state-msg code { background: var(--surface); padding: 0.15em 0.45em; border-radius: 5px; color: var(--accent-ink); }
.is-hidden { display: none !important; }

/* =========================================================
   2. POST ARTICLE (responsive prose)
   ========================================================= */
.post { padding-block: clamp(32px, 5vw, 56px) clamp(48px, 8vw, 88px); }
.post__back {
  display: inline-flex; align-items: center; gap: 0.5ch; font-size: 0.88rem;
  font-weight: 600; color: var(--text-soft); margin-bottom: 26px;
}
.post__back:hover { color: var(--accent); text-decoration: none; }

.post-header { max-width: var(--measure); margin-bottom: 12px; }
.post-header__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 16px; font-family: var(--font-sans); font-size: 0.82rem; color: var(--text-faint); }
.post-header__meta .dot-sep { color: var(--border-strong); }
.post-header h1 { font-size: clamp(2rem, 5vw, 3rem); margin-bottom: 0.35em; }
.post-header__standfirst { font-family: var(--font-serif); font-size: 1.25rem; line-height: 1.5; color: var(--text-soft); }
.post-header__times {
  margin-top: 18px; padding: 12px 16px; border-radius: 10px; background: var(--surface);
  border: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 6px 24px;
  font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-soft);
}
.post-header__times b { color: var(--text-faint); font-weight: 600; letter-spacing: 0.04em; }

/* Prose typography — serif reading column */
.post-prose { max-width: var(--measure); font-family: var(--font-serif); font-size: 1.16rem; line-height: 1.72; color: var(--text); }
.post-prose > * + * { margin-top: 1.2em; }
.post-prose h2 { font-size: 1.7rem; margin-top: 1.8em; margin-bottom: 0.1em; padding-top: 0.4em; }
.post-prose h3 { font-size: 1.3rem; margin-top: 1.5em; }
.post-prose h2 + p, .post-prose h3 + p { margin-top: 0.5em; }
.post-prose a { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.post-prose strong { font-weight: 700; }
.post-prose ul, .post-prose ol { padding-left: 1.4em; }
.post-prose li + li { margin-top: 0.4em; }
.post-prose blockquote {
  border-left: 3px solid var(--accent); padding: 0.2em 0 0.2em 1.1em;
  color: var(--text-soft); font-style: italic;
}
.post-prose img { border-radius: 10px; border: 1px solid var(--border); margin-inline: auto; }
.post-prose figure { margin-block: 1.6em; }
.post-prose figcaption { font-family: var(--font-sans); font-size: 0.82rem; color: var(--text-faint); text-align: center; margin-top: 8px; }
.post-prose hr { border: 0; border-top: 1px solid var(--border); margin-block: 2em; }
.post-prose code { background: var(--surface); padding: 0.12em 0.4em; border-radius: 5px; font-size: 0.86em; color: var(--accent-ink); }
.post-prose pre {
  background: #1c1a15; color: #ece7dc; border-radius: 12px; padding: 18px 20px;
  overflow-x: auto; font-size: 0.85rem; line-height: 1.6; border: 1px solid var(--border);
}
.post-prose pre code { background: transparent; padding: 0; color: inherit; font-size: inherit; }
.post-prose table { width: 100%; border-collapse: collapse; font-family: var(--font-sans); font-size: 0.92rem; }
.post-prose th, .post-prose td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.post-prose th { font-weight: 700; color: var(--text); }
/* display math in prose: allow horizontal scroll when wide */
.post-prose mjx-container[display="true"] { overflow-x: auto; overflow-y: hidden; padding-block: 4px; }

/* Post footer nav */
.post-footer-nav { max-width: var(--measure); margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; }

/* =========================================================
   3. THE SHEET — 210 x 290 mm printable one-pager
   ========================================================= */
.sheet-stage { position: relative; margin: 2.4rem 0; overflow: hidden; }
.sheet-stage__label {
  font-family: var(--font-sans); font-size: 0.76rem; color: var(--text-faint);
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
}
.sheet-stage__label .line { flex: 1; height: 1px; background: var(--border); }
.sheet-stage__label .btn-print {
  font-weight: 600; color: var(--accent-ink); cursor: pointer; background: none;
  border: 0; font-family: var(--font-sans); font-size: 0.78rem; display: inline-flex; gap: 5px; align-items: center;
}
.sheet-stage__label .btn-print svg { width: 14px; height: 14px; }

/* The physical sheet. Fixed true dimensions; post.js scales it to fit. */
.sheet {
  width: 210mm; min-height: 290mm;
  background: var(--sheet-bg); color: var(--sheet-ink);
  padding: 17mm 16mm 15mm;
  box-shadow: var(--shadow-lg);
  transform-origin: top left;
  display: flex; flex-direction: column;
  font-family: var(--font-sans); font-size: 15px; line-height: 1.5;
  position: relative;
}
.sheet::before { /* thin trim frame */
  content: ""; position: absolute; inset: 7mm; border: 1px solid var(--sheet-line); pointer-events: none;
}
.sheet__head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding-bottom: 8px; border-bottom: 2px solid var(--sheet-ink); }
.sheet__series { font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--sheet-accent); }
.sheet__no { font-family: var(--font-mono); font-size: 11px; color: var(--sheet-soft); }
.sheet__title { font-family: var(--font-serif); font-size: 30px; line-height: 1.08; margin: 12px 0 4px; color: var(--sheet-ink); font-weight: 600; }
.sheet__subtitle { font-family: var(--font-serif); font-size: 15px; font-style: italic; color: var(--sheet-soft); margin-bottom: 12px; }
.sheet__body { flex: 1; }

/* Sheet-scoped prose (compact, dense — cheat-sheet feel) */
.sheet__body h2 { font-family: var(--font-sans); font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--sheet-accent); margin: 16px 0 6px; padding-bottom: 3px; border-bottom: 1px solid var(--sheet-line); }
.sheet__body h3 { font-family: var(--font-sans); font-size: 13px; font-weight: 700; color: var(--sheet-ink); margin: 12px 0 4px; }
.sheet__body p { margin: 6px 0; color: var(--sheet-ink); }
.sheet__body ul, .sheet__body ol { margin: 6px 0; padding-left: 18px; }
.sheet__body li { margin: 3px 0; }
.sheet__body strong { font-weight: 700; }
.sheet__body code { font-family: var(--font-mono); font-size: 12.5px; background: #f3f0e8; padding: 0.1em 0.35em; border-radius: 4px; color: #8a2f1a; }
.sheet__body a { color: var(--sheet-accent); }
.sheet__body hr { border: 0; border-top: 1px solid var(--sheet-line); margin: 12px 0; }

/* Two-column region inside a sheet: wrap content in <div class="cols"> */
.sheet__body .cols { column-count: 2; column-gap: 10mm; column-rule: 1px solid var(--sheet-line); }
.sheet__body .cols > *:first-child { margin-top: 0; }

/* Key-equation callout box */
.sheet__body .keybox {
  break-inside: avoid; margin: 10px 0; padding: 10px 14px; border-radius: 6px;
  background: #faf6ee; border: 1px solid var(--sheet-line); border-left: 4px solid var(--sheet-accent);
}
.sheet__body .keybox .label { font-family: var(--font-sans); font-size: 10px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--sheet-accent); display: block; margin-bottom: 4px; }
.sheet__body mjx-container[display="true"] { margin: 8px 0 !important; }

.sheet__foot {
  margin-top: 14px; padding-top: 8px; border-top: 1px solid var(--sheet-line);
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--font-sans); font-size: 10px; color: var(--sheet-soft);
}
.sheet__foot .brand { font-weight: 600; }

/* =========================================================
   4. SHEET IMAGES — two-part post structure (JPEG embeds)
   ========================================================= */

/* Section divider between prose and sheets */
.sheet-images-section { margin-top: 3rem; }
.sheet-images-section__divider {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 28px;
}
.sheet-images-section__label {
  font-family: var(--font-sans); font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent);
  white-space: nowrap;
}
.sheet-images-section__line {
  flex: 1; height: 1px; background: var(--border);
}

/* Individual sheet image block */
.sheet-image-block {
  margin-bottom: 2.5rem;
}
.sheet-image-block__header {
  display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: 12px;
  margin-bottom: 16px;
}
.sheet-image-block__info {
  display: flex; align-items: center; gap: 14px;
  font-family: var(--font-sans); font-size: 0.82rem;
}
.sheet-image-block__series {
  font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--accent); font-size: 0.74rem;
}
.sheet-image-block__page {
  color: var(--text-faint); font-weight: 500;
}

/* Download button — highly visible */
.sheet-download-btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 0.65em 1.4em;
  font-family: var(--font-sans); font-size: 0.92rem; font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 75%, #000));
  border: none; border-radius: 10px;
  text-decoration: none; cursor: pointer;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 40%, transparent);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
  position: relative; overflow: hidden;
}
.sheet-download-btn::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.18), transparent 60%);
  pointer-events: none;
}
.sheet-download-btn:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 50%, transparent);
  filter: brightness(1.08);
  text-decoration: none;
  color: #fff;
}
.sheet-download-btn:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 30%, transparent);
}
.sheet-download-btn svg { flex-shrink: 0; }

/* Image frame */
.sheet-image-block__frame {
  border-radius: 12px; overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  background: var(--sheet-bg, #faf7f0);
}
.sheet-image-block__img {
  display: block; width: 100%; height: auto;
  border-radius: 0;  /* frame handles rounding */
  border: none;
}

/* =========================================================
   5. PRINT — export the sheet(s) at exact 210 x 290 mm
   ========================================================= */
@media print {
  @page { size: 210mm 290mm; margin: 0; }
  html, body { background: #fff !important; }
  .site-header, .site-footer, .skip-link, .post__back,
  .post-footer-nav, .sheet-stage__label { display: none !important; }

  /* Posts that carry sheets: print ONLY the sheets (the one-pager export) */
  body.has-sheets .post-header,
  body.has-sheets .post-prose > *:not(.sheet-stage) { display: none !important; }
  body.has-sheets .sheet-stage { margin: 0 !important; overflow: visible !important; height: auto !important; page-break-after: always; }

  .sheet {
    transform: none !important; box-shadow: none !important;
    width: 210mm !important; min-height: 290mm; margin: 0 !important;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .sheet__body .keybox, .sheet__body code { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  /* Posts without sheets: print the article cleanly */
  body:not(.has-sheets) .post-prose { max-width: none; font-size: 12pt; }
}

.post-prose video { display: block; width: 100%; border-radius: 10px; border: 1px solid var(--border); background: #151515; margin-inline: auto; }
.post-prose figcaption, .post-prose .caption { font-size: 0.8rem; color: var(--text-soft); text-align: center; margin-top: 0.4rem; }
