/* 글 상세 공통: 본문 타이포그래피, 코드 블록, 목차, 시리즈, 이전/다음 글
   색·폰트는 design/assets/tokens.css를 그대로 쓰고, 코드 블록은 홈 터미널과 같은 팔레트 */

/* ---------- 읽기 진행률 ---------- */
.progress {
  position: fixed; left: 0; top: 0; z-index: 40;
  width: 100%; height: 3px; pointer-events: none;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transform-origin: 0 50%; transform: scaleX(0);
}

/* ---------- 태그 칩 ---------- */
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tags a {
  padding: 3px 11px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 13px; color: var(--muted);
}
.tags a::before { content: "#"; opacity: .6; }
.tags a:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 본문 ---------- */
.prose { font-size: 17px; line-height: 1.85; letter-spacing: -0.003em; }
.prose > :first-child { margin-top: 0; }
.prose p { margin: 0 0 1.35em; }
.prose h2, .prose h3 { position: relative; letter-spacing: -0.02em; line-height: 1.4; }
.prose h2 { margin: 2.6em 0 .9em; padding-bottom: .45em; font-size: 1.55em; border-bottom: 1px solid var(--line); }
.prose h3 { margin: 2em 0 .7em; font-size: 1.22em; }
.prose .anchor {
  position: absolute; left: -1.1em; padding-right: .3em;
  color: var(--accent); opacity: 0; font-weight: 600;
}
.prose h2:hover .anchor, .prose h3:hover .anchor { opacity: .7; }
.prose a:not(.anchor) { color: var(--accent); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent); text-underline-offset: 3px; }
.prose a:not(.anchor):hover { text-decoration-color: var(--accent); }
.prose strong { font-weight: 700; }
.prose ul, .prose ol { margin: 0 0 1.35em; padding-left: 1.4em; }
.prose li { margin: .3em 0; }
.prose li::marker { color: var(--accent); }
.prose hr { margin: 3em 0; border: 0; border-top: 1px dashed var(--line); }
.prose :not(pre) > code {
  padding: .15em .4em; border-radius: 6px;
  background: var(--accent-soft); color: var(--accent);
  font-family: var(--mono); font-size: .86em;
}
.prose blockquote {
  margin: 0 0 1.35em; padding: .2em 0 .2em 1.1em;
  border-left: 3px solid var(--accent); color: var(--muted);
}
.prose blockquote p:last-child { margin-bottom: 0; }

.prose figure { margin: 2em 0; }
.prose figcaption { margin-top: 10px; text-align: center; color: var(--muted); font-size: 14px; }
.chart {
  display: grid; gap: 12px; padding: 22px 24px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface);
  font-size: 14px;
}
.chart .bar { display: grid; grid-template-columns: 11ch 1fr 7ch; align-items: center; gap: 14px; }
.chart .bar i { display: block; height: 14px; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.chart .bar.bad i { background: color-mix(in srgb, var(--muted) 55%, transparent); }
.chart .bar b { text-align: right; font-family: var(--mono); font-weight: 400; font-size: 13px; color: var(--muted); }

.table-wrap { overflow-x: auto; margin: 0 0 1.5em; border: 1px solid var(--line); border-radius: 12px; }
.prose table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.6; }
.prose th, .prose td { padding: 10px 14px; text-align: left; white-space: nowrap; }
.prose th { background: var(--hover); font-weight: 700; }
.prose tr + tr td { border-top: 1px solid var(--line); }
.prose td.num, .prose th.num { text-align: right; font-family: var(--mono); font-size: 14px; }

.callout {
  display: flex; gap: 12px; margin: 0 0 1.5em; padding: 14px 18px;
  border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
  border-radius: 12px; background: color-mix(in srgb, var(--c) 8%, transparent);
  font-size: 15.5px; line-height: 1.75;
  --c: var(--accent-2);
}
.callout.warn { --c: #f59e0b; }
.callout .ic { flex: none; }
.callout p { margin: 0; }

/* ---------- 코드 블록 (항상 다크, 홈 터미널과 같은 창) ---------- */
.codeblock {
  --t-bg: #0d1117; --t-bar: #161b22; --t-line: #30363d; --t-fg: #c9d1d9; --t-dim: #6e7681;
  --t-green: #3fb950; --t-blue: #58a6ff; --t-yellow: #d29922; --t-purple: #bc8cff; --t-red: #ff7b72; --t-cyan: #39c5cf;
  margin: 0 0 1.6em; border-radius: 12px; overflow: hidden;
  background: var(--t-bg); color: var(--t-fg);
  box-shadow: 0 0 0 1px rgba(255,255,255,.06), var(--shadow);
}
.codeblock .cb-bar {
  display: flex; align-items: center; gap: 7px; height: 34px; padding: 0 8px 0 14px;
  background: var(--t-bar); border-bottom: 1px solid var(--t-line);
  font-family: var(--mono); font-size: 12px; color: var(--t-dim);
}
.codeblock .cb-bar .dot { width: 10px; height: 10px; border-radius: 50%; }
.codeblock .cb-bar .dot.r { background: #ff5f57; } .codeblock .cb-bar .dot.y { background: #febc2e; } .codeblock .cb-bar .dot.g { background: #28c840; }
.codeblock .cb-file { margin-left: 8px; color: var(--t-fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.codeblock .cb-lang { margin-left: auto; text-transform: lowercase; }
.codeblock .cb-copy {
  padding: 2px 9px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--t-line); background: transparent; color: var(--t-dim);
  font-family: var(--mono); font-size: 11.5px;
}
.codeblock .cb-copy:hover { color: var(--t-fg); border-color: var(--t-dim); }
.codeblock .cb-copy.done { color: var(--t-green); border-color: var(--t-green); }
.codeblock pre {
  margin: 0; padding: 16px 0; overflow-x: auto;
  font-family: var(--mono); font-size: 13.5px; line-height: 1.7;
  scrollbar-width: thin; scrollbar-color: var(--t-line) transparent;
}
.codeblock code { display: block; min-width: max-content; counter-reset: ln; }
.codeblock .ln { display: block; padding: 0 20px 0 0; }
.codeblock .ln::before {
  counter-increment: ln; content: counter(ln);
  display: inline-block; width: 3.2em; padding-right: 1.2em; text-align: right;
  color: var(--t-dim); opacity: .6; user-select: none;
}
.codeblock .ln.mark { background: rgba(88,166,255,.1); box-shadow: inset 3px 0 var(--t-blue); }
.codeblock .ln.del { background: rgba(255,123,114,.1); }
.codeblock .ln.del::before { content: "-"; counter-increment: ln; color: var(--t-red); opacity: 1; }
.codeblock .ln.add { background: rgba(63,185,80,.12); }
.codeblock .ln.add::before { content: "+"; counter-increment: ln; color: var(--t-green); opacity: 1; }
/* highlight.js 토큰 → 터미널 팔레트 */
.hljs-keyword, .hljs-built_in, .hljs-type { color: var(--t-red); }
.hljs-title, .hljs-title.function_, .hljs-title.class_ { color: var(--t-purple); }
.hljs-string, .hljs-regexp { color: #a5d6ff; }
.hljs-number, .hljs-literal, .hljs-variable.constant_ { color: var(--t-blue); }
.hljs-comment { color: var(--t-dim); font-style: italic; }
.hljs-meta, .hljs-attr, .hljs-attribute { color: var(--t-cyan); }
.hljs-params, .hljs-variable { color: var(--t-fg); }
.hljs-symbol, .hljs-bullet { color: var(--t-yellow); }

/* ---------- 목차 ---------- */
.toc { font-size: 14px; }
.toc-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-size: 12px; font-weight: 700; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; }
.toc-head .pct { font-family: var(--mono); font-weight: 400; letter-spacing: 0; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc a {
  display: block; padding: 5px 0 5px 14px; border-left: 2px solid var(--line);
  color: var(--muted); line-height: 1.45; transition: color .15s, border-color .15s;
}
.toc a.h3 { padding-left: 28px; font-size: 13.5px; }
.toc a:hover { color: var(--fg); }
.toc a.on { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.toc-top { display: inline-block; margin-top: 16px; font-size: 13px; color: var(--muted); }
.toc-top:hover { color: var(--accent); }

/* 좁은 화면: 본문 위 접이식 목차 */
.toc-inline {
  margin: 0 0 32px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
.toc-inline summary { padding: 12px 16px; cursor: pointer; font-weight: 700; font-size: 15px; }
.toc-inline .toc { padding: 0 16px 14px; }
.toc-inline .toc-head { display: none; }

/* ---------- 시리즈 ---------- */
.series { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); overflow: hidden; }
.series-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; }
.series-head .ico { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 10px; background: var(--accent-soft); font-size: 19px; }
.series-head small { display: block; color: var(--muted); font-size: 12.5px; }
.series-head b { display: block; font-size: 16px; line-height: 1.4; }
.series-head .step { margin-left: auto; font-family: var(--mono); font-size: 13px; color: var(--muted); white-space: nowrap; }
.series-bar { height: 3px; background: var(--line); }
.series-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.series ol { list-style: none; margin: 0; padding: 8px 10px 12px; counter-reset: s; }
.series li a, .series li span {
  display: flex; gap: 12px; padding: 7px 10px; border-radius: 8px; font-size: 14.5px;
}
.series li a::before, .series li span::before {
  counter-increment: s; content: counter(s);
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; margin-top: 1px;
  border: 1px solid var(--line); font-size: 12px; font-family: var(--mono); color: var(--muted);
}
.series li a:hover { background: var(--hover); }
.series li.now a { color: var(--accent); font-weight: 600; background: var(--accent-soft); }
.series li.now a::before { background: var(--accent); border-color: var(--accent); color: #fff; }
.series li.soon span { color: var(--muted); }
.series li.soon span::after { content: "예정"; margin-left: auto; font-size: 12px; color: var(--muted); }

/* ---------- 이전/다음 글 ---------- */
.pn { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pn a {
  display: flex; flex-direction: column; gap: 4px; padding: 18px 20px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.pn a:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: var(--shadow); }
.pn small { color: var(--muted); font-size: 13px; }
.pn b { font-size: 16px; line-height: 1.45; }
.pn .next { text-align: right; grid-column: 2; }
.pn .cmdline { margin-top: 6px; }

/* ---------- 작성자 ---------- */
.author { display: flex; gap: 18px; align-items: center; padding: 22px 24px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.author .av {
  display: grid; place-items: center; flex: none; width: 56px; height: 56px; border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  font-family: var(--mono); font-weight: 700; font-size: 24px;
}
.author b { font-size: 17px; }
.author p { margin: 2px 0 6px; color: var(--muted); font-size: 14.5px; }
.author .links { display: flex; gap: 14px; font-size: 13.5px; }
.author .links a { color: var(--accent); }

@container (max-width: 600px) {
  .prose { font-size: 16px; }
  .prose .anchor { display: none; }
  .pn { grid-template-columns: minmax(0, 1fr); }
  .pn .next { grid-column: auto; }
  .author { align-items: flex-start; }
}
