/* ─────────────────────────────────────────────────────────────
   오픈챗 아카이브
   news.smol.ai 참조 — 텍스트 중심 / 장식 최소 / 좁은 본문 폭
   ───────────────────────────────────────────────────────────── */

:root {
  /* 시스템 폰트 스택 (한국어 우선순위 포함, 외부 폰트 의존 없음) */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Pretendard Variable",
    "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #ffffff;
  --bg-subtle: #fafafa;
  --fg: #09090b;
  --fg-muted: #6b7280;
  --fg-faint: #9ca3af;
  --line: rgba(0, 0, 0, 0.12);
  --line-strong: rgba(0, 0, 0, 0.22);
  --hover: rgba(0, 0, 0, 0.035);
  --invert-bg: #09090b;
  --invert-fg: #ffffff;

  --chip-bg: #eff6ff;
  --chip-line: #bfdbfe;
  --chip-fg: #1d4ed8;

  --measure: 65ch;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #09090b;
    --bg-subtle: #141417;
    --fg: #f4f4f5;
    --fg-muted: #9ca3af;
    --fg-faint: #6b7280;
    --line: rgba(255, 255, 255, 0.14);
    --line-strong: rgba(255, 255, 255, 0.28);
    --hover: rgba(255, 255, 255, 0.05);
    --invert-bg: #f4f4f5;
    --invert-fg: #09090b;
    --chip-bg: rgba(30, 64, 175, 0.22);
    --chip-line: rgba(96, 165, 250, 0.35);
    --chip-fg: #93c5fd;
  }
}

:root[data-theme="dark"] {
  --bg: #09090b;
  --bg-subtle: #141417;
  --fg: #f4f4f5;
  --fg-muted: #9ca3af;
  --fg-faint: #6b7280;
  --line: rgba(255, 255, 255, 0.14);
  --line-strong: rgba(255, 255, 255, 0.28);
  --hover: rgba(255, 255, 255, 0.05);
  --invert-bg: #f4f4f5;
  --invert-fg: #09090b;
  --chip-bg: rgba(30, 64, 175, 0.22);
  --chip-line: rgba(96, 165, 250, 0.35);
  --chip-fg: #93c5fd;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  letter-spacing: -0.011em;
  word-break: keep-all;      /* 한국어 어절 단위 줄바꿈 */
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── (2) 좁은 본문 폭 · 가운데 정렬 · 넉넉한 여백 ────────── */

.wrap {
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 1.5rem;
}

a { color: inherit; text-decoration: none; }

.u {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, currentColor 28%, transparent);
  transition: text-decoration-color 0.2s ease, color 0.2s ease;
}

.u:hover,
.u:focus-visible {
  color: var(--fg);
  text-decoration-color: currentColor;
}

/* ── (1) 헤더: 반전 블록 로고 + 소문자 nav + 구분선 ─────── */

header {
  border-bottom: 1px solid var(--line);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 0;
}

.brand {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  background: var(--invert-bg);
  color: var(--invert-fg);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

nav.top {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8125rem;
  color: var(--fg-muted);
  letter-spacing: 0;
}

nav.top .sep { color: var(--fg-faint); }

nav.top a[aria-current="page"] {
  color: var(--fg);
}

.theme-toggle {
  margin-left: 0.3rem;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 0.8125rem;
  color: var(--fg-muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, currentColor 28%, transparent);
}

.theme-toggle:hover { color: var(--fg); }
.theme-toggle .icon-dark { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-dark { display: inline; }
:root[data-theme="dark"] .theme-toggle .icon-light { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-dark { display: inline; }
  :root:not([data-theme="light"]) .theme-toggle .icon-light { display: none; }
}

/* ── (6) 히어로: 큰 제목 대비 ─────────────────────────── */

.hero { padding: 4rem 0 3rem; }

.hero h1 {
  display: inline-block;
  margin: 0 0 1.5rem;
  padding: 0.3rem 0.7rem;
  background: var(--invert-bg);
  color: var(--invert-fg);
  font-size: clamp(2.25rem, 6vw, 3.25rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.045em;
}

.hero .lede {
  margin: 0 0 0.75rem;
  color: var(--fg-muted);
  font-size: 0.9375rem;
  line-height: 1.8;
}

.hero .meta {
  margin: 0;
  color: var(--fg-faint);
  font-size: 0.75rem;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}

/* ── 섹션 헤더 ────────────────────────────────────────── */

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 1.75rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--line);
}

.section-head h2 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.section-head .aside {
  font-size: 0.75rem;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}

/* ── (3) 타임라인: 좌측 hairline + dot 마커 ───────────── */

.timeline {
  position: relative;
  list-style: none;
  margin: 0 0 4rem;
  padding: 0 0 0 1.5rem;
}

/* 세로 1px 라인 */
.timeline::before {
  content: "";
  position: absolute;
  top: 0.35rem;
  bottom: 0.35rem;
  left: 0;
  width: 1px;
  background: var(--line);
}

.item {
  position: relative;
  padding: 0.9rem 0;
}

.item + .item {
  border-top: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
}

/* 점 마커 */
.item::before {
  content: "";
  position: absolute;
  top: 1.55rem;
  left: -1.5rem;
  width: 5px;
  height: 5px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--fg-faint);
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.item:hover::before {
  background: var(--fg);
  transform: scale(1.4);
}

/* "날짜 — 제목" 한 줄 */
.row {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  line-height: 1.6;
}

.row .date {
  flex: none;
  font-size: 0.8125rem;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
  white-space: nowrap;
}

.row .dash {
  flex: none;
  color: var(--fg-faint);
  font-size: 0.8125rem;
}

.row .title {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.022em;
  transition: text-decoration-color 0.2s ease;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  text-decoration-color: transparent;
}

.item:hover .row .title {
  text-decoration-color: var(--line-strong);
}

.row .count {
  margin-left: auto;
  flex: none;
  font-size: 0.6875rem;
  color: var(--fg-faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ── (5) 태그 칩: 작은 파란 pill, 간격 확보 ───────────── */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.55rem;
}

.chip {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--chip-line);
  border-radius: 9999px;
  background: var(--chip-bg);
  color: var(--chip-fg);
  font-size: 0.6875rem;
  line-height: 1.6;
  letter-spacing: 0;
  white-space: nowrap;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

a.chip:hover {
  border-color: color-mix(in srgb, var(--chip-fg) 55%, transparent);
  background: color-mix(in srgb, var(--chip-bg) 70%, var(--chip-fg) 8%);
}

/* ── (4) 호버 미리보기: 평소 완전히 숨김 → 부드럽게 펼침 ── */

.preview {
  max-height: 0;
  opacity: 0;
  visibility: hidden;
  overflow: hidden;
  pointer-events: none;
  transition: max-height 0.28s ease, opacity 0.2s ease, visibility 0s linear 0.28s;
}

.item:hover .preview,
.item:focus-within .preview,
.item.is-open .preview {
  max-height: 22rem;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: max-height 0.32s ease, opacity 0.25s ease 0.05s, visibility 0s;
}

.preview-inner {
  margin-top: 0.7rem;
  padding: 0.75rem 0 0.2rem 0.9rem;
  border-left: 2px solid var(--line-strong);
}

.preview-inner p {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.85;
  color: var(--fg-muted);
}

.preview-inner .more {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--fg-faint);
}

/* ── 본문 (상세 페이지) ───────────────────────────────── */

.issue-head {
  padding: 3rem 0 1.75rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2rem;
}

.issue-head .kicker {
  font-size: 0.75rem;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
  margin-bottom: 0.6rem;
}

.issue-head h1 {
  margin: 0 0 0.9rem;
  font-size: clamp(1.6rem, 4.5vw, 2.125rem);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.035em;
}

.issue-head .standfirst {
  margin: 0 0 1.1rem;
  color: var(--fg-muted);
  font-size: 0.9375rem;
  line-height: 1.8;
}

.prose { font-size: 1rem; line-height: 1.9; }

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

.prose h2 {
  margin: 2.75rem 0 0.9rem;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.prose h3 {
  margin: 2rem 0 0.6rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--fg-muted);
  letter-spacing: -0.015em;
}

.prose p { margin: 0 0 1.15rem; }

.prose ul,
.prose ol { margin: 0 0 1.15rem; padding-left: 1.15rem; }

.prose li { margin: 0.35rem 0; }
.prose li::marker { color: var(--fg-faint); }

.prose a {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, currentColor 30%, transparent);
}

.prose strong { font-weight: 600; }

.prose code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 0.08em 0.32em;
  border-radius: 3px;
  background: var(--bg-subtle);
  border: 1px solid var(--line);
}

.prose pre {
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg-subtle);
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.7;
}

.prose pre code { border: 0; padding: 0; background: none; font-size: 1em; }

.prose blockquote {
  margin: 0 0 1.15rem;
  padding: 0 0 0 1rem;
  border-left: 2px solid var(--line-strong);
  color: var(--fg-muted);
}

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

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin: 0 0 1.15rem;
}

.prose th,
.prose td {
  border-bottom: 1px solid var(--line);
  padding: 0.5rem 0.7rem 0.5rem 0;
  text-align: left;
  vertical-align: top;
}

.prose th {
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--fg-muted);
  border-bottom-color: var(--line-strong);
}

.tagline { display: flex; flex-wrap: wrap; gap: 0.375rem; }

/* ── 이전 / 다음 ──────────────────────────────────────── */

.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin: 3.5rem 0 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.pager a { flex: 1 1 12rem; min-width: 0; }

.pager .dir {
  display: block;
  font-size: 0.6875rem;
  color: var(--fg-faint);
  margin-bottom: 0.2rem;
  font-variant-numeric: tabular-nums;
}

.pager .t {
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: -0.015em;
}

.pager a:hover .t { text-decoration: underline; text-underline-offset: 3px; }
.pager .next { text-align: right; }

/* ── 태그 목록 · 검색 ─────────────────────────────────── */

.tag-cloud { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 4rem; }

.tag-cloud .chip { padding: 0.2rem 0.65rem; font-size: 0.75rem; }

.tag-cloud .n {
  margin-left: 0.35rem;
  opacity: 0.6;
  font-variant-numeric: tabular-nums;
}

.searchbar { display: flex; gap: 0.5rem; margin: 0 0 2rem; }

.searchbar input {
  flex: 1;
  min-width: 0;
  padding: 0.45rem 0.7rem;
  font: inherit;
  font-size: 0.875rem;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
}

.searchbar input::placeholder { color: var(--fg-faint); }

.searchbar input:focus {
  outline: none;
  border-color: var(--fg);
}

.searchbar button {
  padding: 0.45rem 0.9rem;
  font: inherit;
  font-size: 0.8125rem;
  color: var(--invert-fg);
  background: var(--invert-bg);
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}

.empty { padding: 2.5rem 0 4rem; color: var(--fg-muted); font-size: 0.9375rem; }

/* ── 푸터 ─────────────────────────────────────────────── */

footer {
  margin-top: auto;
  padding: 1.75rem 0 4rem;
  border-top: 1px solid var(--line);
  font-size: 0.75rem;
  color: var(--fg-faint);
  line-height: 1.9;
}

footer .foot-row { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; justify-content: space-between; }

/* ── 반응형 ───────────────────────────────────────────── */

@media (max-width: 640px) {
  body { font-size: 15px; }
  .hero { padding: 2.5rem 0 2rem; }
  .row { flex-wrap: wrap; gap: 0.35rem 0.5rem; }
  .row .dash { display: none; }
  .row .date { width: 100%; }
  .row .count { margin-left: 0; }
}

/* 터치 기기: 호버가 없으므로 탭으로 펼친다 */
@media (hover: none) {
  .item:hover .preview {
    max-height: 0;
    opacity: 0;
    visibility: hidden;
  }
  .item.is-open .preview {
    max-height: 22rem;
    opacity: 1;
    visibility: visible;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
