/* blog.ksides.com — 디자인 근거는 blog-ops/ops/DESIGN.md
   기준 개념(taste): 미니멀 플랫 · 뉴트럴 바탕 + 포인트 컬러 하나(링크) · 산세리프 본문 · 모노스페이스는 코드와 날짜만
   (모노스페이스는 날짜·코드에만 — 한글을 고정폭으로 쓰면 자간이 벌어진다)
   · 위계 4단계 · 본문 행간 1.75 · 명도 대비 4.5:1 이상 */

:root {
  --bg: #fbfaf8;
  --text: #1c1b19;
  --muted: #5f5b55;      /* bg 대비 6.4:1 */
  --line: #e4e0d9;
  --line-strong: #c9c3b9;
  --code-bg: #f2efea;
  --accent: #1f5fbf;     /* 포인트 컬러: 링크에만 쓴다. bg 대비 5.8:1 */
  --flag: #8a5a00;

  --measure: 680px;      /* 17px 본문에서 한 줄 약 40자 (한국어 가독 35~45자) */
  --sans: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  --mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, "D2Coding", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151514;
    --text: #e7e5e0;
    --muted: #a39f97;
    --line: #2c2b28;
    --line-strong: #46443f;
    --code-bg: #1e1e1c;
    --accent: #7eaaff;
    --flag: #e0b25c;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.75 var(--sans);
  word-break: keep-all;          /* 한국어는 어절 단위로 줄바꿈 */
  overflow-wrap: anywhere;       /* 긴 URL·식별자는 어디서든 끊는다 */
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ── 뼈대 ─────────────────────────────────────── */
header.site, main, footer.site {
  max-width: calc(var(--measure) + 300px);
  margin: 0 auto;
  padding: 0 24px;
}

header.site {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-top: 28px;
  padding-bottom: 28px;
}
header.site .brand { color: var(--text); font-weight: 700; letter-spacing: -0.01em; }
header.site nav { display: flex; gap: 20px; font-size: 15px; }
header.site nav a { color: var(--muted); }
header.site nav a:hover { color: var(--text); text-decoration: none; }

footer.site {
  margin-top: 96px;
  padding-top: 24px;
  padding-bottom: 48px;
  color: var(--muted);
  font-size: 14px;
}
footer.site p { border-top: 1px solid var(--line); padding-top: 20px; margin: 0; max-width: var(--measure); }

.banner {
  margin: 0;
  padding: 8px 24px;
  background: var(--code-bg);
  color: var(--flag);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

/* ── 위계 ─────────────────────────────────────── */
h1, h2, h3 { line-height: 1.3; letter-spacing: -0.015em; }

.post-head { max-width: var(--measure); margin: 24px 0 48px; }
.post-head h1 { font-size: 2rem; font-weight: 750; margin: 0 0 16px; line-height: 1.25; }
.post-head .lede { color: var(--muted); font-size: 1.06rem; margin: 0 0 16px; }

.meta { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
time { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.post-head .meta { margin: 0 0 12px; }

.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 0; margin: 0; }
.tags a { font-size: 14px; color: var(--muted); }
.tags a::before { content: "#"; opacity: 0.6; }
.tags a:hover { color: var(--accent); }

/* ── 본문 ─────────────────────────────────────── */
.prose { max-width: var(--measure); min-width: 0; }
.prose > :first-child { margin-top: 0; }

.prose p, .prose ul, .prose ol, .prose .table, .prose pre, .prose blockquote { margin: 0 0 1.4em; }

.prose h2 { font-size: 1.5em; font-weight: 700; margin: 2.6em 0 0.8em; position: relative; }   /* 본문 대비 1.5배 */
.prose h3 { font-size: 1.25em; font-weight: 650; margin: 2em 0 0.6em; position: relative; }   /* 1.25배 */
.prose .anchor {
  position: absolute; left: -1.1em; width: 1em;
  color: var(--line-strong); font-weight: 400; opacity: 0;
}
.prose h2:hover .anchor, .prose h3:hover .anchor { opacity: 1; text-decoration: none; }

.prose strong { font-weight: 650; }

.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: 0.35em 0; }
.prose li::marker { color: var(--muted); }

.prose blockquote {
  margin-left: 0;
  padding: 2px 0 2px 20px;
  border-left: 2px solid var(--line-strong);
  color: var(--text);
}
/* 글 첫머리 인용은 후크 — 한 단계 크게 */
.prose > blockquote:first-child { font-size: 1.12em; font-weight: 500; }
.prose blockquote p:last-child { margin-bottom: 0; }

.prose hr { border: 0; border-top: 1px solid var(--line); margin: 3em 0; }

/* 코드: 모노스페이스는 여기와 날짜에만 */
.prose code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--code-bg);
  padding: 0.12em 0.36em;
  border-radius: 4px;
  white-space: nowrap;           /* /reload-plugins 가 하이픈에서 갈라지지 않게 (옛 블로그에서 겪음) */
}
.prose pre {
  position: relative;
  background: var(--code-bg);
  border-radius: 6px;
  padding: 16px 20px;
  overflow-x: auto;
  line-height: 1.6;
}
.prose pre code { background: none; padding: 0; font-size: 0.82em; white-space: pre; }
.prose pre[data-lang]::before {
  content: attr(data-lang);
  position: absolute; top: 6px; right: 10px;
  font: 11px/1 var(--mono); color: var(--muted);
}

/* 표: 열거 가능한 짧은 사실용. 좁으면 가로로 넘긴다 */
.prose .table { overflow-x: auto; }
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
}
.prose th, .prose td { overflow-wrap: break-word; padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.prose th { font-weight: 650; border-bottom-color: var(--line-strong); white-space: nowrap; }
.prose td:first-child, .prose th:first-child { padding-left: 0; }

/* ── 목차: 넓으면 오른쪽에 붙고, 좁으면 본문 위에 접힌다 ── */
.toc { font-size: 14px; line-height: 1.5; margin: 0 0 40px; max-width: var(--measure); }
.toc summary { cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.toc ol { list-style: none; padding: 0 0 0 12px; margin: 0; border-left: 1px solid var(--line); }
.toc li { margin: 6px 0; }
.toc li.d3 { padding-left: 12px; font-size: 13px; }
.toc a { color: var(--muted); }
.toc a:hover { color: var(--accent); text-decoration: none; }

@media (min-width: 1080px) {
  .post-grid { display: grid; grid-template-columns: minmax(0, var(--measure)) 220px; gap: 0 64px; align-items: start; }
  .post-grid .toc { grid-column: 2; grid-row: 1; position: sticky; top: 32px; margin: 0; max-height: calc(100vh - 64px); overflow-y: auto; }
  .post-grid .prose { grid-column: 1; grid-row: 1; }
}
@media (max-width: 1079px) {
  .toc details:not([open]) { margin-bottom: 0; }
}

/* ── 글 끝 프로젝트 소개 ─────────────────────── */
.project-note { max-width: var(--measure); margin-top: 64px; padding-top: 20px; border-top: 1px solid var(--line); font-size: 15px; }
.project-note .label { font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 6px; }
.project-note p { margin: 0; }

/* ── 목록 ─────────────────────────────────────── */
.intro { max-width: var(--measure); margin: 8px 0 56px; color: var(--muted); }
.intro p { margin: 0; }

.post-list { list-style: none; padding: 0; margin: 0; max-width: calc(var(--measure) + 120px); }
.post-list > li { display: grid; grid-template-columns: 7.5em minmax(0, 1fr); gap: 0 24px; padding: 22px 0; border-top: 1px solid var(--line); }
.post-list > li:first-child { border-top: 0; padding-top: 0; }
.post-list time { padding-top: 4px; }
.post-list h2 { font-size: 1.18rem; font-weight: 650; margin: 0 0 6px; }
.post-list h2 a { color: var(--text); }
.post-list h2 a:hover { color: var(--accent); text-decoration: none; }
.post-list p { margin: 0 0 8px; color: var(--muted); font-size: 15.5px; line-height: 1.65; }
.flag { font-size: 12px; font-weight: 600; color: var(--flag); margin-left: 6px; vertical-align: 2px; }
.empty { color: var(--muted); }

@media (max-width: 640px) {
  .post-list > li { grid-template-columns: 1fr; }
  .post-list time { padding: 0 0 4px; }
}

.prose .projects { list-style: none; padding: 0; margin: 0; }
.prose .projects li { margin: 0; padding: 20px 0; border-top: 1px solid var(--line); }
.projects h2 { font-size: 1.18rem; margin: 0 0 6px; }
.projects p { margin: 0 0 6px; }
.projects .related { font-size: 15px; color: var(--muted); }

.tag-index { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 10px 24px; max-width: var(--measure); }
.tag-index a { font-size: 16px; }
.tag-index a::before { content: "#"; opacity: 0.6; }
.tag-index span { font: 12px var(--mono); color: var(--muted); }

/* ── 작은 화면 ───────────────────────────────── */
@media (max-width: 640px) {
  body { font-size: 16px; }
  header.site { padding-top: 20px; padding-bottom: 20px; }
  .post-head h1 { font-size: 1.65rem; }
  .prose pre { margin-left: -24px; margin-right: -24px; border-radius: 0; padding: 14px 24px; }
}
