/* ─────────────────────────────────────────────────────────────
   종이와 터미널.
   제목은 명조(사람의 목소리), 메타·코드는 고정폭(기계의 목소리),
   본문은 시스템 한글 sans — 폰트 안 받고 바로 뜨게.
   ───────────────────────────────────────────────────────────── */

:root {
  --serif: "Gowun Batang", "Nanum Myeongjo", "Apple SD Gothic Neo", serif;
  --sans: "Pretendard Variable", "Pretendard", -apple-system, BlinkMacSystemFont,
          "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --measure: 34rem;

  --bg:        #faf7f0;
  --bg-soft:   #f2ede1;
  --ink:       #221f1a;
  --ink-soft:  #46423a;
  --muted:     #8d8679;
  --faint:     #b3ac9d;
  --rule:      #e3ddcf;
  --accent:    #9a5a33;

  --code-key:     #93552f;
  --code-str:     #55703f;
  --code-num:     #7d6034;
  --code-name:    #46423a;
  --code-comment: #9d968a;
  --code-op:      #7c766b;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #17150f;
    --bg-soft:   #201d15;
    --ink:       #ebe6da;
    --ink-soft:  #c6c0b2;
    --muted:     #8f887a;
    --faint:     #6b6559;
    --rule:      #2f2b22;
    --accent:    #d09466;

    --code-key:     #d99a6c;
    --code-str:     #a8c08a;
    --code-num:     #cbb07d;
    --code-name:    #c6c0b2;
    --code-comment: #7d776b;
    --code-op:      #9a9488;
  }
}

/* ── 기본 ───────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.85;
  letter-spacing: -0.003em;
  /* 한글은 어절 단위로 끊는다. 이거 하나가 가독성 절반이다. */
  word-break: keep-all;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }

/* ── 레이아웃 ────────────────────────────────────────────────── */

header.site, main, footer.site {
  max-width: var(--measure);
  margin: 0 auto;
  padding-inline: 1.5rem;
}

/* ── 머리말 ─────────────────────────────────────────────────── */

header.site {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  padding-top: 3rem;
  padding-bottom: 3.5rem;
}

.wordmark {
  font-family: var(--serif);
  font-size: 1.0625rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  text-decoration: none;
  white-space: nowrap;
}

.is-home header.site {
  display: block;
  padding-top: 5rem;
  padding-bottom: 2rem;
}
.is-home .wordmark {
  display: block;
  font-size: clamp(1.5rem, 1.15rem + 1.6vw, 2rem);
  line-height: 1.35;
  margin-bottom: 0.75rem;
}

header.site nav {
  display: flex;
  gap: 1.25rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
header.site nav a {
  color: var(--muted);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}
header.site nav a:hover {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

/* ── 소개 문단 ──────────────────────────────────────────────── */

.intro {
  margin: 0 0 3rem;
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1.8;
  max-width: 30rem;
}
.intro a { color: var(--accent); text-underline-offset: 0.2em; }

/* ── 글 목록 ────────────────────────────────────────────────── */

main { padding-bottom: 5rem; }

.page-title {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 400;
  margin: 0 0 3rem;
}

.year { margin-bottom: 3.5rem; }

.year-mark {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--faint);
  margin: 0 0 1rem;
  padding-bottom: 0.625rem;
  border-bottom: 1px solid var(--rule);
}

ul.posts { list-style: none; margin: 0; padding: 0; }

ul.posts li {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  column-gap: 1rem;
  padding: 1.125rem 0;
}
ul.posts li + li { border-top: 1px solid var(--rule); }

ul.posts a {
  font-family: var(--serif);
  font-size: 1.1875rem;
  font-weight: 400;
  line-height: 1.5;
  text-decoration: none;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-size: 0% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
ul.posts a:hover { background-size: 100% 1px; }

ul.posts time {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

ul.posts p {
  grid-column: 1 / -1;
  margin: 0.375rem 0 0;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.7;
}

.empty { color: var(--muted); }

/* ── 본문 ───────────────────────────────────────────────────── */

.post-head { margin-bottom: 3rem; }

article h1 {
  font-family: var(--serif);
  font-size: clamp(1.5625rem, 1.25rem + 1.5vw, 2.0625rem);
  font-weight: 400;
  line-height: 1.45;
  letter-spacing: -0.01em;
  margin: 0 0 0.625rem;
}

.post-head time {
  display: block;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

article h2, article h3 {
  font-family: var(--serif);
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: -0.005em;
}
article h2 { font-size: 1.375rem; margin: 3.25rem 0 1rem; }
article h3 { font-size: 1.125rem; margin: 2.25rem 0 0.75rem; color: var(--ink-soft); }

article p { margin: 0 0 1.5rem; }

article a {
  color: var(--ink);
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  transition: color 0.2s ease;
}
article a:hover { color: var(--accent); }

article ul, article ol { padding-left: 1.125rem; margin: 0 0 1.5rem; }
article li { margin-bottom: 0.5rem; }
article li::marker { color: var(--faint); }

article blockquote {
  margin: 2.25rem 0;
  padding: 0.25rem 0 0.25rem 1.25rem;
  border-left: 2px solid var(--accent);
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: 1.0625rem;
}
article blockquote p:last-child { margin-bottom: 0; }

article hr {
  border: 0;
  height: 1px;
  background: var(--rule);
  margin: 3rem 0;
}

article img { max-width: 100%; height: auto; border-radius: 2px; }

article strong { font-weight: 600; }

/* 코드 */
article code {
  font-family: var(--mono);
  font-size: 0.8125em;
  background: var(--bg-soft);
  padding: 0.15em 0.35em;
  border-radius: 3px;
  word-break: keep-all;
  overflow-wrap: break-word;
}

article pre {
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1rem 1.125rem;
  margin: 0 0 1.5rem;
  overflow-x: auto;
  font-size: 0.8125rem;
  line-height: 1.7;
  -webkit-overflow-scrolling: touch;
}
article pre code {
  background: none;
  padding: 0;
  font-size: 1em;
  word-break: normal;
}

/* 표 — 아래 문단과 붙지 않게 마진을 준다 */
article table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
  margin: 0 0 1.5rem;
  display: block;
  overflow-x: auto;
}
article th, article td {
  text-align: left;
  padding: 0.5rem 1rem 0.5rem 0;
  border-bottom: 1px solid var(--rule);
}
article th {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── 신택스 하이라이팅 (chroma, noClasses=false) ─────────────── */

.chroma { background: none; }
.chroma .line { display: flex; }
.chroma .k, .chroma .kc, .chroma .kd, .chroma .kn,
.chroma .kp, .chroma .kr, .chroma .kt { color: var(--code-key); font-weight: 500; }
.chroma .c, .chroma .ch, .chroma .cm, .chroma .c1,
.chroma .cs, .chroma .cp, .chroma .cpf { color: var(--code-comment); font-style: italic; }
.chroma .s, .chroma .sa, .chroma .sb, .chroma .sc, .chroma .dl, .chroma .sd,
.chroma .s2, .chroma .se, .chroma .sh, .chroma .si, .chroma .sx,
.chroma .sr, .chroma .s1, .chroma .ss { color: var(--code-str); }
.chroma .m, .chroma .mb, .chroma .mf, .chroma .mh,
.chroma .mi, .chroma .il, .chroma .mo { color: var(--code-num); }
.chroma .na, .chroma .nb, .chroma .bp, .chroma .nc, .chroma .no, .chroma .nd,
.chroma .ni, .chroma .ne, .chroma .nf, .chroma .fm, .chroma .nn,
.chroma .nl, .chroma .nv, .chroma .vc, .chroma .vg,
.chroma .vi, .chroma .vm { color: var(--code-name); }
.chroma .o, .chroma .ow, .chroma .p { color: var(--code-op); }
.chroma .gd { color: #b3543a; }
.chroma .gi { color: #55703f; }
.chroma .ge { font-style: italic; }
.chroma .gs { font-weight: 600; }

/* ── 글 사이 이동 ───────────────────────────────────────────── */

.post-nav {
  max-width: var(--measure);
  margin: 4rem auto 0;
  padding: 2rem 1.5rem 0;
  border-top: 1px solid var(--rule);
  display: grid;
  gap: 1.5rem;
}
.post-nav a {
  text-decoration: none;
  display: block;
}
.post-nav .label {
  display: block;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.post-nav .t {
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink-soft);
  transition: color 0.2s ease;
}
.post-nav a:hover .t { color: var(--accent); }

.notfound h1 { font-family: var(--serif); }
.notfound p { color: var(--muted); }
.notfound a { color: var(--accent); }

/* ── 꼬리말 ─────────────────────────────────────────────────── */

footer.site {
  padding-top: 2.5rem;
  padding-bottom: 4rem;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  color: var(--faint);
}

/* ── 움직임 — 차분하게, 한 번만 ─────────────────────────────── */

@media (prefers-reduced-motion: no-preference) {
  .intro, .year, article, .page-title {
    animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.3, 1) backwards;
  }
  .year { animation-delay: calc(var(--i, 0) * 90ms + 60ms); }
  .intro { animation-delay: 0ms; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ── 모바일 ─────────────────────────────────────────────────── */

@media (max-width: 34rem) {
  body { font-size: 16.5px; line-height: 1.8; }

  header.site { padding-top: 2rem; padding-bottom: 2.5rem; }
  .is-home header.site { padding-top: 3rem; }

  .intro { margin-bottom: 3rem; }

  ul.posts li {
    grid-template-columns: 1fr;
    row-gap: 0.25rem;
    padding: 1rem 0;
  }
  ul.posts time { order: -1; }
  ul.posts a { font-size: 1.0625rem; }

  article h2 { margin-top: 2.5rem; }

  /* 코드는 가로 스크롤을 화면 끝까지 쓴다 */
  article pre {
    margin-inline: -1.5rem;
    border-inline: 0;
    border-radius: 0;
    padding-inline: 1.5rem;
  }
}
