/*
 * pages.css - page sections: test page content blocks, home extras,
 * history, PDF generator, blog, static pages, 404 and style guide.
 */

/* ---------- Test page content blocks ---------- */
.steps { display: grid; gap: var(--s-3); margin-top: var(--s-4); }
.step { display: flex; gap: var(--s-4); align-items: flex-start; padding: var(--s-4); background: var(--bg); border: 1px solid var(--line); color: var(--ink-2); }
.step-num { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 32px; height: 32px; background: var(--ink); color: var(--white); font-weight: 800; font-variant-numeric: tabular-nums; }
.feature-card .card-title, .metric-card .card-title { margin-top: var(--s-1); }
.metric-formula { display: grid; gap: var(--s-1); margin-top: auto; padding-top: var(--s-3); border-top: 1px solid var(--line); font-size: 14px; font-weight: 600; color: var(--ink); }
.bands-grid { align-items: start; }
.bands-table td:last-child { color: var(--ink-2); font-size: 14px; }
.science-grid { display: grid; gap: var(--s-6); }
@media (min-width: 1024px) { .science-grid { grid-template-columns: 1fr 1fr; gap: var(--s-7) var(--s-8); } }
.science-item .sub-title { margin-bottom: var(--s-3); }
.tips { counter-reset: none; }
.tip-num { font-size: 32px; font-weight: 800; color: var(--accent); line-height: 1; font-variant-numeric: tabular-nums; }
.group-heading { display: flex; align-items: center; gap: var(--s-3); font-size: 18px; font-weight: 800; margin: var(--s-6) 0 var(--s-4); }
.group-heading:first-of-type { margin-top: 0; }
.card-test .card-title { margin-top: var(--s-2); }

/* PDF banner */
.pdf-banner { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-4); padding: var(--s-5); border: 1px solid var(--ink); background: var(--bg); color: var(--ink); }
.pdf-banner-text { display: grid; gap: var(--s-1); flex: 1 1 280px; }

/* Demo pair */
.demo-block { margin-top: var(--s-8); padding: var(--s-5); background: var(--bg); border: 1px solid var(--line); display: grid; gap: var(--s-4); }
.demo-pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.demo-card { display: grid; justify-items: center; gap: var(--s-3); padding: var(--s-6) var(--s-3); border: 1px solid var(--line); text-align: center; }
.demo-word { font-size: clamp(32px, 6vw, 56px); font-weight: 800; line-height: 1; }
.demo-answer { font-size: 14px; font-weight: 700; color: var(--ink); }
.demo-actions { display: flex; flex-wrap: wrap; gap: var(--s-3); }

/* Timeline */
.timeline-title { margin-top: var(--s-8); margin-bottom: var(--s-5); }
.timeline { display: grid; gap: var(--s-4); margin-bottom: var(--s-8); position: relative; }
@media (min-width: 768px) {
  .timeline { grid-template-columns: repeat(4, 1fr); gap: var(--s-5); padding-top: var(--s-5); border-top: 2px solid var(--ink); }
}
.timeline-item { position: relative; display: grid; gap: var(--s-2); align-content: start; padding: var(--s-4); background: var(--bg); border: 1px solid var(--line); }
@media (min-width: 768px) {
  .timeline-item::before { content: ""; position: absolute; top: calc(-1 * var(--s-5) - 7px); left: var(--s-4); width: 12px; height: 12px; background: var(--accent); border: 2px solid var(--ink); }
}
.timeline-year { font-size: 28px; font-weight: 800; color: var(--accent); line-height: 1; font-variant-numeric: tabular-nums; }
.timeline-title-text { font-weight: 800; }
.daily-card .card-title { font-size: 17px; }

/* CTA band */
.cta-band { background: var(--ink); color: var(--white); padding-block: var(--s-8); }
.cta-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-5); }
.cta-title { font-size: var(--fs-h2); font-weight: 800; letter-spacing: -.02em; line-height: 1.15; color: var(--white); }
.cta-text { color: var(--footer-muted); margin-top: var(--s-2); }
.cta-band .btn-primary:hover { border-color: var(--white); box-shadow: 4px 4px 0 var(--white); }

/* ---------- Page heads (history, pdf, blog, static) ---------- */
.page-head { padding-block: var(--s-6) var(--s-6); }
.page-head .lead { margin-top: var(--s-4); max-width: 62ch; }
.page-head .hero-stats { margin-top: var(--s-6); }

/* ---------- History ---------- */
.history-app { min-height: 560px; }
.history-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-3); padding: var(--s-4) 0; }
.history-toolbar .field { min-width: 150px; flex: 1 1 150px; }
.history-toolbar .toolbar-icon { display: flex; align-items: center; justify-content: center; height: 40px; color: var(--ink-3); }
.history-toolbar-end { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-left: auto; }
.history-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); margin-top: var(--s-2); }
@media (min-width: 768px) { .history-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.history-chart { margin-top: var(--s-4); }
.history-records { margin-top: var(--s-5); }
.records-table td, .records-table th { white-space: nowrap; }
.records-table .row-actions { display: flex; gap: var(--s-1); justify-content: flex-end; }
.records-table .row-actions .icon-btn { width: 40px; height: 40px; }
.records-table tr.is-open .row-toggle .icon { transform: rotate(180deg); }
.record-detail td { background: var(--bg-soft); white-space: normal; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); margin-bottom: var(--s-4); }
@media (min-width: 768px) { .detail-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.detail-grid .stat-tile { background: var(--bg); }
.detail-grid .stat-value { font-size: 20px; }
.records-cards { display: grid; gap: var(--s-3); }
.record-card { padding: var(--s-4); border: 1px solid var(--line); background: var(--bg); display: grid; gap: var(--s-3); }
.record-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s-3); }
.record-card-metric { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.record-card-meta { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); font-size: 14px; color: var(--ink-2); }
.records-table-wrap { display: none; }
@media (min-width: 900px) {
  .records-table-wrap { display: block; }
  .records-cards { display: none; }
}
.empty-state { display: grid; justify-items: center; gap: var(--s-4); padding: var(--s-8) var(--s-4); text-align: center; border: 1px dashed var(--line); margin-top: var(--s-4); }
.empty-art { display: grid; grid-template-columns: repeat(3, 24px); gap: 6px; }
.empty-art span { width: 24px; height: 24px; border: 2px solid var(--line); }
.empty-art span:nth-child(1), .empty-art span:nth-child(5), .empty-art span:nth-child(9) { background: var(--accent-soft); border-color: var(--accent); }
.empty-art span:nth-child(3) { background: var(--ink); border-color: var(--ink); }
.empty-title { font-size: 20px; font-weight: 800; }

/* ---------- PDF page ---------- */
.template-card .preview { height: 150px; border: 1px solid var(--line); background: var(--bg-soft); padding: var(--s-3); display: grid; gap: 4px; align-content: start; overflow: hidden; }
.preview-line { height: 6px; background: var(--line); }
.preview-line.is-short { width: 55%; }
.preview-grid { display: grid; gap: 4px; }
.preview-grid span { height: 16px; border: 1px solid var(--line); background: var(--bg); display: flex; align-items: center; justify-content: center; font-size: 8px; font-weight: 800; letter-spacing: .02em; overflow: hidden; }
.preview-rows span { height: 10px; }
.template-specs { font-size: 13px; color: var(--ink-3); font-weight: 600; }
.template-card .btn { margin-top: auto; }
.generator { display: grid; gap: var(--s-6); padding: var(--s-5); border: 1px solid var(--ink); background: var(--bg); box-shadow: var(--shadow-panel); }
@media (min-width: 900px) { .generator { grid-template-columns: 1fr 1fr; padding: var(--s-6); } }
.generator-col { display: grid; gap: var(--s-5); align-content: start; }
.range-row { display: flex; align-items: center; gap: var(--s-4); }
.range-value { min-width: 3ch; font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; text-align: right; }
.generator-actions { display: flex; flex-wrap: wrap; gap: var(--s-3); grid-column: 1 / -1; padding-top: var(--s-4); border-top: 1px solid var(--line); }
.pdf-error { margin-bottom: var(--s-5); }
.howto-steps { counter-reset: none; }

/* ---------- Blog ---------- */
.chip-row { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-bottom: var(--s-6); }
.filter-chip {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 var(--s-4);
  border: 1px solid var(--ink);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}
.filter-chip:hover { background: var(--bg-soft); color: var(--ink); }
.filter-chip.is-active { background: var(--ink); color: var(--white); }
.post-card .card-title { font-size: 19px; line-height: 1.3; }
.post-cat { color: var(--accent); }
.post-meta { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); margin-top: auto; padding-top: var(--s-2); font-size: 13px; color: var(--ink-3); font-weight: 600; }
.post-meta > span { display: inline-flex; align-items: center; gap: 6px; }
.pagination { display: flex; align-items: center; justify-content: center; gap: var(--s-3); margin-top: var(--s-7); font-weight: 600; }
.blog-empty { padding: var(--s-6); border: 1px dashed var(--line); text-align: center; color: var(--ink-3); }
.is-filtered-out { display: none !important; }

.article-head { padding-block: var(--s-5) var(--s-6); }
.article-head .page-title { font-size: clamp(32px, 3.5vw + 14px, 52px); max-width: 22ch; margin-top: var(--s-4); }
.article-meta { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); margin-top: var(--s-4); font-size: 14px; color: var(--ink-3); font-weight: 600; }
.article-meta span { display: inline-flex; align-items: center; gap: 6px; }
.article-layout { display: grid; gap: var(--s-6); padding-bottom: var(--s-8); }
@media (min-width: 1024px) { .article-layout { grid-template-columns: minmax(0, 1fr) 260px; gap: var(--s-8); } }
.article-main { min-width: 0; }
.key-points { padding: var(--s-5); border: 1px solid var(--ink); background: var(--accent-soft); margin-bottom: var(--s-6); }
.key-points h2 { font-size: 16px; font-weight: 800; display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-3); }
.key-points ul { display: grid; gap: var(--s-2); }
.key-points li { display: flex; gap: var(--s-2); align-items: flex-start; font-weight: 500; }
.key-points li .icon { color: var(--accent); margin-top: 4px; }
.toc { padding: var(--s-4); border: 1px solid var(--line); background: var(--bg); }
.toc-title { margin-bottom: var(--s-3); }
.toc ol { display: grid; gap: var(--s-1); }
.toc a { display: block; padding: 4px 0 4px var(--s-3); border-left: 2px solid var(--line); color: var(--ink-2); text-decoration: none; font-size: 14px; font-weight: 600; line-height: 1.4; }
.toc a:hover, .toc a.is-active { border-left-color: var(--accent); color: var(--accent); }
.toc-inline { margin-bottom: var(--s-6); }
.toc-side { display: none; }
@media (min-width: 1024px) {
  .toc-inline { display: none; }
  .toc-side { display: block; position: sticky; top: 88px; align-self: start; }
}
.article-cta { margin-top: var(--s-7); display: grid; gap: var(--s-4); padding: var(--s-5); border: 1px solid var(--ink); box-shadow: var(--shadow-panel); background: var(--bg); }
.article-cta-head { display: flex; align-items: center; gap: var(--s-3); }
.reading-progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: calc(var(--z-header) + 1); background: transparent; pointer-events: none; }
.reading-progress span { display: block; height: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); }

/* ---------- Static pages ---------- */
.static-updated { margin-top: var(--s-3); font-size: 14px; color: var(--ink-3); font-weight: 600; }
.static-body { padding-bottom: var(--s-8); }

/* ---------- 404 ---------- */
.notfound { display: grid; gap: var(--s-4); justify-items: start; padding-bottom: var(--s-7); max-width: 640px; }
.notfound-mark { display: grid; grid-template-columns: repeat(2, 28px); gap: 4px; margin-bottom: var(--s-3); }
.notfound-mark span { width: 28px; height: 28px; border: 2px solid var(--ink); }
.notfound-mark span:nth-child(1) { background: var(--c-red); border-color: var(--c-red); }
.notfound-mark span:nth-child(4) { background: var(--c-yellow); border-color: var(--c-yellow); }
.compact-tests { margin-top: var(--s-4); }

/* ---------- Style guide (development only) ---------- */
.sg-block { padding-block: var(--s-6); border-top: 1px solid var(--line); display: grid; gap: var(--s-4); }
.sg-row { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; }
.sg-swatch { width: 120px; display: grid; gap: 4px; font-size: 12px; font-weight: 600; }
.sg-swatch span { height: 48px; border: 1px solid var(--line); }
.history-loading { padding: var(--s-5) 0; }
