/* ============================================================
   Writing / article pages - extends css/style.css tokens
   ============================================================ */

.article-wrap { max-width: 760px; margin: 0 auto; padding: 0 24px; }

/* ---------- writing index ---------- */
.writing-head { padding: 130px 0 30px; }
.writing-head h1 {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(34px, 5vw, 54px); letter-spacing: -0.01em; margin-bottom: 12px;
}
.writing-head p { color: var(--muted); max-width: 560px; }

.post-list { list-style: none; padding: 20px 0 120px; }
.post-list li { border-top: 1px solid var(--line); }
.post-list a {
  display: grid; grid-template-columns: 120px 1fr; gap: 24px;
  padding: 26px 8px; color: inherit; transition: background 0.2s, padding 0.2s;
}
.post-list a:hover { text-decoration: none; background: var(--panel); padding-left: 16px; padding-right: 16px; }
.post-date { font-family: var(--font-mono); font-size: 12px; color: var(--accent); padding-top: 4px; }
.post-meta h2 { font-family: var(--font-display); font-weight: 700; font-size: 22px; margin-bottom: 6px; }
.post-meta p { color: var(--muted); font-size: 14.5px; }
.post-tags { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.post-tags span {
  font-family: var(--font-mono); font-size: 11px; color: var(--accent);
  background: var(--accent-dim); border-radius: 20px; padding: 3px 11px;
}

/* ---------- article ---------- */
.article { padding: 120px 0 40px; }
.article-back {
  font-family: var(--font-mono); font-size: 13px; color: var(--muted);
  display: inline-block; margin-bottom: 28px;
}
.article-back:hover { color: var(--accent); text-decoration: none; }
.crumb { font-family: var(--font-mono); font-size: 13px; color: var(--faint); margin-bottom: 26px; }
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--accent); text-decoration: none; }
.crumb span { margin: 0 8px; color: var(--faint); }
.writing-head .crumb { margin-bottom: 16px; }
.article-meta { font-family: var(--font-mono); font-size: 12.5px; color: var(--faint); margin-bottom: 14px; }
.article-meta .accent { color: var(--accent); }
.article h1 {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(30px, 4.6vw, 46px); line-height: 1.08;
  letter-spacing: -0.015em; margin-bottom: 18px;
}
.article-dek { font-size: 19px; line-height: 1.55; color: var(--muted); margin-bottom: 14px; }
.article-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 40px; }
.article-tags span {
  font-family: var(--font-mono); font-size: 11px; color: var(--accent);
  background: var(--accent-dim); border-radius: 20px; padding: 4px 12px;
}

/* prose */
.prose { font-size: 17px; line-height: 1.75; color: #c4d0da; }
.prose > * { max-width: 680px; }
.prose h2 {
  font-family: var(--font-display); font-weight: 700; font-size: 26px;
  color: var(--text); margin: 52px 0 16px; letter-spacing: -0.01em;
}
.prose h2 .h2-no { font-family: var(--font-mono); font-size: 14px; color: var(--accent); margin-right: 10px; font-weight: 400; }
.prose h3 { font-family: var(--font-display); font-weight: 700; font-size: 19px; color: var(--text); margin: 32px 0 10px; }
.prose p { margin-bottom: 20px; }
.prose ul, .prose ol { margin: 0 0 20px 24px; }
.prose li { margin-bottom: 8px; }
.prose strong { color: var(--text); font-weight: 600; }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.prose code {
  font-family: var(--font-mono); font-size: 0.86em; color: var(--accent);
  background: var(--accent-dim); padding: 2px 6px; border-radius: 4px;
}
.prose pre {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 18px 20px; overflow-x: auto; margin-bottom: 24px; max-width: 100%;
}
.prose pre code { background: none; color: #c4d0da; padding: 0; font-size: 13.5px; line-height: 1.7; }
.prose pre code .kw { color: var(--accent); }
.prose pre code .cm { color: var(--faint); }
.prose pre code .nm { color: var(--amber); }

.callout {
  border-left: 3px solid var(--accent); background: var(--panel);
  padding: 16px 20px; border-radius: 0 8px 8px 0; margin-bottom: 24px;
}
.callout p { margin: 0; color: var(--muted); }
.callout strong { color: var(--accent); }

.lead-stat { display: flex; gap: 36px; flex-wrap: wrap; margin: 8px 0 40px; }
.lead-stat div { }
.lead-stat dt { font-family: var(--font-display); font-weight: 700; font-size: 28px; color: var(--accent); line-height: 1.1; }
.lead-stat dd { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); }

/* ---------- figures / diagrams ---------- */
figure.diagram {
  margin: 36px 0; max-width: 100% !important;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 26px 20px 8px; overflow: hidden;
}
figure.diagram svg { display: block; width: 100%; height: auto; }
figure.diagram figcaption {
  font-family: var(--font-mono); font-size: 12px; color: var(--faint);
  text-align: center; margin-top: 6px; padding: 10px 8px 6px;
  border-top: 1px solid var(--line);
}
.dg-label { font-family: var(--font-mono); fill: var(--text); }
.dg-sub { font-family: var(--font-mono); fill: var(--muted); }
.dg-accent { fill: var(--accent); }
.dg-amber { fill: var(--amber); }

/* ---------- interactive widget ---------- */
.widget {
  margin: 40px 0; max-width: 100% !important;
  background: var(--panel); border: 1px solid var(--line-bright); border-radius: 12px;
  padding: 24px;
}
.widget-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.widget-head h3 { font-family: var(--font-display); font-weight: 700; font-size: 17px; color: var(--text); }
.widget-readout { font-family: var(--font-mono); font-size: 13px; color: var(--muted); }
.widget-readout b { color: var(--amber); }
.widget svg { display: block; width: 100%; height: auto; }
.widget-controls { display: flex; gap: 24px; flex-wrap: wrap; align-items: center; margin-top: 18px; }
.ctrl { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 200px; }
.ctrl label { font-family: var(--font-mono); font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }
.ctrl label b { color: var(--accent); }
.ctrl input[type="range"] { -webkit-appearance: none; appearance: none; height: 4px; border-radius: 2px; background: var(--line-bright); outline: none; }
.ctrl input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); cursor: pointer; box-shadow: 0 0 8px rgba(61,220,151,0.5); }
.ctrl input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: var(--accent); cursor: pointer; }
.widget-btn {
  font-family: var(--font-mono); font-size: 13px; color: var(--amber);
  background: var(--amber-dim); border: 1px solid transparent; border-radius: 6px;
  padding: 9px 16px; cursor: pointer; transition: border-color 0.15s; white-space: nowrap;
}
.widget-btn:hover { border-color: var(--amber); }

.widget .seg { display: inline-flex; border: 1px solid var(--line-bright); border-radius: 8px; overflow: hidden; }
.widget .seg button {
  font-family: var(--font-mono); font-size: 12px; background: var(--bg-raise); color: var(--muted);
  border: 0; border-right: 1px solid var(--line); padding: 9px 14px; cursor: pointer; transition: color 0.15s, background 0.15s;
}
.widget .seg button:last-child { border-right: 0; }
.widget .seg button:hover { color: var(--text); }
.widget .seg button.on { background: var(--accent-dim); color: var(--accent); }

.article-foot {
  margin-top: 60px; padding-top: 30px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px;
}
.article-foot p { color: var(--muted); font-size: 14px; margin: 0; }
.article-foot .accent { color: var(--accent); }

/* ---------- reading progress + section TOC ---------- */
.read-progress {
  position: fixed; top: 0; left: 0; height: 2px; width: 0; z-index: 100;
  background: var(--accent); box-shadow: 0 0 8px rgba(61, 220, 151, 0.6);
}
.toc {
  position: fixed; top: 130px; width: 190px; max-height: 70vh; overflow-y: auto;
  left: calc((100vw - 760px) / 2 - 220px); display: none; z-index: 40;
}
.toc-title {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--faint); margin-bottom: 10px;
}
.toc a {
  display: block; font-family: var(--font-mono); font-size: 12px; color: var(--muted);
  padding: 5px 0 5px 13px; border-left: 1px solid var(--line); line-height: 1.4;
  transition: color 0.15s, border-color 0.15s;
}
.toc a:hover { color: var(--text); text-decoration: none; }
.toc a.active { color: var(--accent); border-left-color: var(--accent); }
@media (min-width: 1200px) { .toc { display: block; } }

/* ---------- prev / next ---------- */
.article-more { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 30px 0 0; }
.article-more a { text-decoration: none; }
.more-card {
  display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 16px 18px; color: inherit; transition: border-color 0.2s, transform 0.2s;
}
.more-card:hover { border-color: var(--line-bright); transform: translateY(-2px); text-decoration: none; }
.more-dir { font-family: var(--font-mono); font-size: 11px; color: var(--accent); letter-spacing: 0.04em; }
.more-card h4 { font-family: var(--font-display); font-weight: 700; font-size: 15px; color: var(--text); margin-top: 7px; line-height: 1.3; }
@media (max-width: 640px) { .article-more { grid-template-columns: 1fr; } }

@media (max-width: 640px) {
  .post-list a { grid-template-columns: 1fr; gap: 6px; }
  .prose { font-size: 16px; }
  .widget-controls { flex-direction: column; align-items: stretch; }
}
