/* ==========================================================================
   한국어 블로그 아카이브 — 공통 스타일시트
   따뜻하고 차분한 에디토리얼 톤 · 미술관 도록을 닮은 정돈된 레이아웃
   순수 CSS · 외부 의존성 없음 (file:// 로컬 구동)
   ========================================================================== */

/* --------------------------------------------------------------------------
   디자인 토큰
   -------------------------------------------------------------------------- */
:root {
  /* 색 */
  --bg: #faf9f7;
  --surface: #ffffff;
  --ink: #1a1a18;
  --ink-soft: #45433d;
  --ink-faint: #6b6962;
  --accent: #cc5333;
  --accent-soft: #f5e6df;
  --line: #e6e3dd;
  --code-bg: #f4f2ee;
  --quote-bg: #f6f4f0;

  /* 코드 블록(pre) 전용 어두운 팔레트 */
  --pre-bg: #20201d;
  --pre-ink: #ece9e2;
  --pre-faint: #9b988f;

  /* 타이포그래피 */
  --font-sans: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Pretendard", "Segoe UI", "Noto Sans KR", sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", "Fira Code", "D2Coding",
    ui-monospace, Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  /* 레이아웃 */
  --measure: 720px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;

  /* 입체감 */
  --shadow-sm: 0 1px 2px rgba(26, 26, 24, 0.04),
    0 2px 6px rgba(26, 26, 24, 0.04);
  --shadow-md: 0 6px 16px rgba(26, 26, 24, 0.07),
    0 2px 6px rgba(26, 26, 24, 0.05);
  --shadow-lg: 0 14px 34px rgba(26, 26, 24, 0.12),
    0 4px 10px rgba(26, 26, 24, 0.07);

  /* 모션 */
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
}

/* --------------------------------------------------------------------------
   리셋 & 기본
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.8;
  letter-spacing: 0.005em;
  word-break: keep-all;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img {
  max-width: 100%;
  height: auto;
}

::selection {
  background: var(--accent-soft);
  color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

/* ==========================================================================
   개별 글 페이지
   ========================================================================== */

/* --------------------------------------------------------------------------
   상단 네비게이션 바
   -------------------------------------------------------------------------- */
nav.topnav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 24px;
  background: rgba(250, 249, 247, 0.85);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

nav.topnav a.back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px 6px 11px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease),
    transform 0.18s var(--ease);
}

nav.topnav a.back::before {
  content: "\2190"; /* ← */
  font-size: 1.05em;
  line-height: 1;
  transition: transform 0.18s var(--ease);
}

nav.topnav a.back:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  transform: translateY(-1px);
}

nav.topnav a.back:hover::before {
  transform: translateX(-3px);
}

nav.topnav .crumb {
  font-size: 0.86rem;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* --------------------------------------------------------------------------
   글 컨테이너 & 머리말
   -------------------------------------------------------------------------- */
article {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 56px 24px 32px;
}

header.post-head {
  margin-bottom: 44px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--line);
}

.post-head .eyebrow {
  display: inline-block;
  margin-bottom: 18px;
  padding: 4px 12px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
}

.post-head h1 {
  margin: 0 0 18px;
  font-size: 2.5rem;
  line-height: 1.28;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.post-head p.post-meta {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink-faint);
  letter-spacing: 0.01em;
}

/* --------------------------------------------------------------------------
   본문
   -------------------------------------------------------------------------- */
.post-body {
  color: var(--ink-soft);
  font-size: 1.0625rem;
  line-height: 1.85;
}

.post-body > *:first-child {
  margin-top: 0;
}

.post-body h2 {
  margin: 2.6em 0 0.7em;
  font-size: 1.7rem;
  line-height: 1.35;
  font-weight: 750;
  letter-spacing: -0.015em;
  color: var(--ink);
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--line);
}

.post-body h3 {
  margin: 2em 0 0.6em;
  font-size: 1.3rem;
  line-height: 1.4;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.post-body p {
  margin: 0 0 1.3em;
}

.post-body a {
  color: var(--accent);
  text-decoration: none;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-position: 0 95%;
  background-repeat: no-repeat;
  background-size: 100% 1px;
  padding-bottom: 1px;
  transition: background-size 0.2s var(--ease), color 0.2s var(--ease);
}

.post-body a:hover {
  color: #a83f24;
  background-size: 100% 2px;
}

.post-body strong {
  font-weight: 700;
  color: var(--ink);
}

.post-body em {
  font-style: italic;
}

.post-body ul,
.post-body ol {
  margin: 0 0 1.3em;
  padding-left: 1.4em;
}

.post-body li {
  margin: 0.4em 0;
  padding-left: 0.2em;
}

.post-body li::marker {
  color: var(--accent);
}

.post-body ul ul,
.post-body ul ol,
.post-body ol ul,
.post-body ol ol {
  margin: 0.4em 0;
}

/* 인용 — 좌측 액센트 바 */
.post-body blockquote {
  margin: 1.8em 0;
  padding: 0.9em 1.4em;
  background: var(--quote-bg);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ink-soft);
  font-style: italic;
}

.post-body blockquote p {
  margin: 0.5em 0;
}

.post-body blockquote p:first-child {
  margin-top: 0;
}

.post-body blockquote p:last-child {
  margin-bottom: 0;
}

/* 표 — 카드형 테두리 + 둥근 모서리 */
.post-body table {
  width: 100%;
  margin: 1.8em 0;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.95rem;
  line-height: 1.6;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.post-body table caption {
  caption-side: top;
  padding: 0 2px 0.7em;
  font-size: 0.86rem;
  color: var(--ink-faint);
  text-align: left;
  letter-spacing: 0.01em;
}

.post-body thead {
  background: var(--accent-soft);
}

.post-body th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 700;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.post-body td {
  padding: 11px 16px;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.post-body tbody tr:last-child td {
  border-bottom: none;
}

.post-body tbody tr:nth-child(even) {
  background: rgba(244, 242, 238, 0.5);
}

/* 코드 — 인라인 & 블록 */
.post-body code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--code-bg);
  color: #a83f24;
  padding: 0.15em 0.45em;
  border-radius: 5px;
  border: 1px solid var(--line);
  word-break: break-all;
}

.post-body pre {
  margin: 1.8em 0;
  padding: 20px 22px;
  background: var(--pre-bg);
  color: var(--pre-ink);
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.7;
  box-shadow: var(--shadow-md);
  -webkit-overflow-scrolling: touch;
}

.post-body pre code {
  font-family: var(--font-mono);
  background: none;
  color: inherit;
  padding: 0;
  border: none;
  border-radius: 0;
  font-size: inherit;
  word-break: normal;
  white-space: pre;
}

/* 그림 */
.post-body figure {
  margin: 2em 0;
  text-align: center;
}

.post-body figure img {
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.post-body figcaption {
  margin-top: 0.8em;
  font-size: 0.85rem;
  color: var(--ink-faint);
  font-style: italic;
  letter-spacing: 0.01em;
}

/* 구분선 */
.post-body hr {
  margin: 3em auto;
  width: 64px;
  height: 0;
  border: none;
  border-top: 2px solid var(--line);
  position: relative;
  overflow: visible;
}

.post-body hr::after {
  content: "\00A7"; /* § */
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg);
  padding: 0 0.5em;
  color: var(--ink-faint);
  font-size: 1rem;
}

/* --------------------------------------------------------------------------
   글 꼬리말
   -------------------------------------------------------------------------- */
footer.post-foot {
  max-width: var(--measure);
  margin: 48px auto 0;
  padding: 28px 24px 64px;
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
  color: var(--ink-faint);
  line-height: 1.7;
}

footer.post-foot a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.18s var(--ease);
}

footer.post-foot a:hover {
  border-color: var(--accent);
}

/* ==========================================================================
   인덱스 페이지
   ========================================================================== */

/* --------------------------------------------------------------------------
   아카이브 머리말
   -------------------------------------------------------------------------- */
header.archive-head {
  max-width: 960px;
  margin: 0 auto;
  padding: 72px 24px 36px;
  text-align: center;
}

.archive-head .archive-title {
  margin: 0 0 14px;
  font-size: 2.9rem;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--ink);
}

.archive-head .archive-sub {
  margin: 0 auto;
  max-width: 560px;
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--ink-faint);
}

/* --------------------------------------------------------------------------
   툴바 — 검색창 & 필터 탭
   -------------------------------------------------------------------------- */
.toolbar {
  max-width: 960px;
  margin: 0 auto;
  padding: 8px 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
}

input#search {
  width: 100%;
  max-width: 520px;
  padding: 13px 18px 13px 44px;
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  background-color: var(--surface);
  background-repeat: no-repeat;
  background-position: 16px center;
  background-size: 18px 18px;
  /* 돋보기 아이콘 (인라인 SVG, 외부 의존성 없음) */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b6962' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

input#search::placeholder {
  color: var(--ink-faint);
}

input#search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.filter-tabs button.tab {
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 16px;
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: background 0.16s var(--ease), color 0.16s var(--ease),
    border-color 0.16s var(--ease), transform 0.16s var(--ease);
}

.filter-tabs button.tab:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.filter-tabs button.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

/* --------------------------------------------------------------------------
   카드 그리드
   -------------------------------------------------------------------------- */
.card-grid {
  max-width: 1080px;
  margin: 0 auto;
  padding: 8px 24px 80px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 22px;
}

a.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 26px 26px 22px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: transform 0.22s var(--ease), box-shadow 0.22s var(--ease),
    border-color 0.22s var(--ease);
}

a.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: #d8d3c9;
}

.card .card-section {
  align-self: flex-start;
  margin-bottom: 14px;
  padding: 3px 11px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
}

.card h3 {
  margin: 0 0 10px;
  font-size: 1.28rem;
  line-height: 1.4;
  font-weight: 750;
  letter-spacing: -0.012em;
  color: var(--ink);
}

.card .card-summary {
  margin: 0 0 18px;
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--ink-soft);
  /* 요약 3줄 클램프 */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card .card-meta {
  margin-top: auto;
  font-size: 0.82rem;
  color: var(--ink-faint);
  letter-spacing: 0.01em;
}

.card .card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.card .card-tags span {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--ink-faint);
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 9px;
  letter-spacing: 0.01em;
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}

a.card:hover .card-tags span {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-soft);
}

/* --------------------------------------------------------------------------
   검색 결과 없음
   -------------------------------------------------------------------------- */
.empty {
  max-width: 480px;
  margin: 40px auto 100px;
  padding: 48px 28px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 1.02rem;
  line-height: 1.7;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
}

.empty::before {
  content: "\1F50D"; /* 🔍 */
  display: block;
  font-size: 2rem;
  margin-bottom: 12px;
  opacity: 0.6;
}

/* ==========================================================================
   반응형 — 모바일 600px 이하
   ========================================================================== */
@media (max-width: 600px) {
  body {
    font-size: 16px;
  }

  nav.topnav {
    padding: 11px 16px;
    gap: 10px;
  }

  nav.topnav .crumb {
    font-size: 0.8rem;
  }

  article {
    padding: 36px 18px 24px;
  }

  header.post-head {
    margin-bottom: 32px;
    padding-bottom: 24px;
  }

  .post-head h1 {
    font-size: 1.85rem;
  }

  .post-body {
    font-size: 1rem;
  }

  .post-body h2 {
    font-size: 1.42rem;
    margin-top: 2.2em;
  }

  .post-body h3 {
    font-size: 1.18rem;
  }

  .post-body pre {
    padding: 16px;
    font-size: 0.84rem;
    border-radius: var(--radius-sm);
    /* 좁은 화면에서 코드 블록을 화면 가장자리까지 확장 */
    margin-left: -18px;
    margin-right: -18px;
    border-radius: 0;
  }

  .post-body table {
    font-size: 0.88rem;
  }

  .post-body th,
  .post-body td {
    padding: 9px 12px;
  }

  footer.post-foot {
    padding: 24px 18px 48px;
  }

  header.archive-head {
    padding: 48px 18px 28px;
  }

  .archive-head .archive-title {
    font-size: 2.1rem;
  }

  .archive-head .archive-sub {
    font-size: 0.98rem;
  }

  .toolbar {
    padding: 8px 18px 24px;
  }

  .card-grid {
    grid-template-columns: 1fr;
    padding: 8px 18px 64px;
    gap: 18px;
  }

  a.card {
    padding: 22px 22px 18px;
  }

  a.card:hover {
    transform: none;
  }
}

/* ==========================================================================
   인쇄
   ========================================================================== */
@media print {
  body {
    background: #fff;
    color: #000;
  }

  nav.topnav,
  .toolbar,
  footer.post-foot {
    display: none;
  }

  a.card,
  .post-body pre,
  .post-body table {
    box-shadow: none;
  }

  .post-body pre {
    background: var(--code-bg);
    color: var(--ink);
    border: 1px solid var(--line);
  }
}

/* ==========================================================================
   모션 민감 사용자 배려
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
