@charset "UTF-8";

/* Pretendard: 한글 가독성을 위한 본문 폰트 (동적 서브셋) */
@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.css");

:root {
  --bg: #eceef1;
  --card: #ffffff;
  --text: #2b2f36;
  --heading: #15181d;
  --muted: #6b7280;
  --border: #e6e8eb;
  --border-strong: #d7dadf;
  --accent: #2f9e8f;          /* 링크/포인트(브랜드 틸) */
  --accent-soft: #80ed99;     /* 밑줄/인용 포인트(브랜드 민트) */
  --code-bg: #f2f4f6;
  --code-text: #b03060;

  --font-sans: "Pretendard Variable", Pretendard, -apple-system,
    BlinkMacSystemFont, "Apple SD Gothic Neo", system-ui, "Segoe UI", Roboto,
    "Noto Sans KR", "Malgun Gothic", sans-serif;
  --font-mono: "SFMono-Regular", "JetBrains Mono", "D2Coding", Menlo, Consolas,
    "Liberation Mono", monospace;

  --maxw: 920px;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 17px;
  margin: 0;
  padding: 0;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@media screen and (max-width: 740px) {
  html {
    font-size: 15.5px;
  }
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.8;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

/* ── 상단 네비게이션: 홈으로 가기 (글 상세페이지 전용) ────────── */
.topnav {
  max-width: var(--maxw);
  margin: 1.6rem auto 0;
  padding: 0 4px;
}

.topnav a {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
  border-bottom: none;
  transition: color 0.15s ease;
}

.topnav a:hover {
  color: var(--accent);
}

@media screen and (max-width: 740px) {
  .topnav {
    max-width: none;
    margin: 0;
    padding: 1rem 1.25rem 0;
  }
}

/* ── 레이아웃: 가운데 정렬된 흰 리딩 카드 ───────────────────── */
article.article {
  width: 100%;
  margin: 0;
  color: var(--text);
}

article .box {
  width: 100%;
  max-width: var(--maxw);
  margin: 2.5rem auto;
  padding: 3.4rem 3.6rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(20, 23, 28, 0.04),
    0 10px 30px rgba(20, 23, 28, 0.05);
}

@media screen and (max-width: 740px) {
  article .box {
    max-width: none;
    margin: 0;
    padding: 1.8rem 1.25rem 2.4rem;
    border: none;
    border-radius: 0;
    box-shadow: none;
  }
}

/* ── 제목 ──────────────────────────────────────────────── */
article .box h1,
article .box h2,
article .box h3,
article .box h4 {
  color: var(--heading);
  font-family: var(--font-sans);
  line-height: 1.35;
  letter-spacing: -0.012em;
  word-break: keep-all;
}

article .box h1 {
  font-size: 2.05rem;
  font-weight: 800;
  line-height: 1.28;
  margin: 0 0 1.6rem;
}

article .box h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 3rem 0 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

article .box h3 {
  font-size: 1.22rem;
  font-weight: 700;
  margin: 2.2rem 0 0.8rem;
}

@media screen and (max-width: 740px) {
  article .box h1 {
    font-size: 1.65rem;
    word-break: keep-all;
  }
  article .box h2 {
    font-size: 1.32rem;
  }
}

/* 헤딩의 자동 생성 앵커는 보이지 않게 */
article .box h1 .anchor,
article .box h2 .anchor,
article .box h3 .anchor,
article .box h4 .anchor {
  display: none;
}

/* ── 본문 ──────────────────────────────────────────────── */
article .box p {
  margin: 1.25rem 0;
  line-height: 1.85;
}

article .box strong {
  font-weight: 700;
  color: var(--heading);
}

article .box a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(47, 158, 143, 0.35);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

article .box a:hover {
  border-bottom-color: var(--accent);
  background: rgba(128, 237, 153, 0.16);
}

article .box a:visited {
  color: #2a7d77;
}

/* ── 목록 ──────────────────────────────────────────────── */
article .box ul,
article .box ol {
  margin: 1.25rem 0;
  padding-left: 1.4rem;
}

article .box li {
  margin: 0.45rem 0;
  line-height: 1.8;
}

article .box li::marker {
  color: var(--muted);
}

/* 인덱스(글 목록) 페이지의 링크 리스트를 살짝 키워 가독성 확보 */
article li:not(:last-child) {
  margin-bottom: 0.6rem;
}

/* ── 인용구 ────────────────────────────────────────────── */
article .box blockquote {
  margin: 1.6rem 0;
  padding: 0.9rem 1.3rem;
  border-left: 3px solid var(--accent-soft);
  background: #f5faf7;
  border-radius: 0 10px 10px 0;
  color: #3c4148;
}

article .box blockquote p {
  margin: 0.4rem 0;
}

/* ── 코드 ──────────────────────────────────────────────── */
article .box code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--code-bg);
  color: var(--code-text);
  padding: 0.12em 0.4em;
  border-radius: 5px;
  word-break: break-all;
}

article .box pre {
  margin: 1.5rem 0;
  padding: 1rem 1.15rem;
  background: #f6f7f9;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: auto;
  line-height: 1.55;
  font-size: 0.84rem;
}

article .box pre code {
  background: none;
  color: #2b2f36;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
  word-break: normal;
  white-space: pre;
}

/* ── 표 ────────────────────────────────────────────────── */
article .box table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.94rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

article .box th,
article .box td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 0.6rem 0.85rem;
  text-align: left;
  line-height: 1.6;
  vertical-align: top;
}

article .box th:last-child,
article .box td:last-child {
  border-right: none;
}

article .box tbody tr:last-child td {
  border-bottom: none;
}

article .box thead th {
  background: #f1f3f5;
  font-weight: 700;
  color: var(--heading);
  white-space: nowrap;
}

/* 첫 열을 행 머리글처럼 강조 (비교 표 가독성) */
article .box tbody td:first-child {
  background: #f7f8fa;
  font-weight: 600;
}

article .box tbody tr:hover td {
  background: #fafbfc;
}

@media screen and (max-width: 740px) {
  article .box table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

/* ── 이미지 ────────────────────────────────────────────── */
article .box img {
  height: auto;
  max-width: 100%;
  display: block;
  margin: 1.6rem auto;
  border-radius: 8px;
}

/* ── 날짜 ──────────────────────────────────────────────── */
article .box .date {
  display: block;
  text-align: right;
  margin-top: 2.5rem;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

/* ── 푸터 ──────────────────────────────────────────────── */
footer {
  display: flex;
  margin: 0 0 3.5rem;
  width: 100%;
  color: #343a40;
  word-break: keep-all;
  min-width: 100px;
  gap: 20px;
  justify-content: center;
  align-items: center;
  opacity: 0.75;
  transition: opacity 0.15s ease;
}

footer:hover {
  opacity: 1;
}

/* 비교 표: 좁은 화면에서는 래퍼가 스크롤을 담당한다. */
.table-scroll {
  width: 100%;
  max-width: 100%;
  margin: 1.5rem 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

article .box .table-scroll table {
  margin: 0;
}

/* 4열 표만 최소 너비를 유지하고, 필요한 경우 가로로 스크롤한다. */
article .box .table-scroll.table-cols-4 table {
  min-width: 660px;
}

@media screen and (max-width: 740px) {
  article .box .table-scroll table {
    display: table;
    width: 100%;
    white-space: normal;
    font-size: 0.82rem;
  }

  article .box .table-scroll th,
  article .box .table-scroll td {
    padding: 0.5rem 0.45rem;
  }

  article .box .table-scroll th {
    white-space: normal;
  }

  article .box .table-scroll code {
    word-break: normal;
    overflow-wrap: normal;
    white-space: nowrap;
  }

  article .box .table-cols-2 table,
  article .box .table-cols-3 table {
    table-layout: fixed;
  }

  article .box .table-cols-2 th:first-child,
  article .box .table-cols-2 td:first-child {
    width: 62%;
  }

  article .box .table-cols-3 th:first-child,
  article .box .table-cols-3 td:first-child {
    width: 44%;
  }

  article .box .table-cols-3 th:not(:first-child),
  article .box .table-cols-3 td:not(:first-child) {
    width: 28%;
  }

  article .box .table-scroll.table-cols-4 {
    overflow: visible;
  }

  article .box .table-scroll.table-cols-4 table {
    display: block;
    min-width: 0;
    border: none;
    background: transparent;
  }

  article .box .table-cols-4 thead {
    display: none;
  }

  article .box .table-cols-4 tbody {
    display: grid;
    gap: 0.85rem;
  }

  article .box .table-cols-4 tr {
    display: block;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
  }

  article .box .table-cols-4 td {
    width: 100%;
    border-right: none;
  }

  article .box .table-cols-4 td:first-child {
    display: block;
    padding: 0.6rem 0.7rem;
    background: #f1f3f5;
    text-align: left !important;
  }

  article .box .table-cols-4 td:first-child::before {
    display: none;
  }

  article .box .table-cols-4 td:not(:first-child) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.8rem;
    align-items: baseline;
    padding: 0.55rem 0.7rem;
  }

  article .box .table-cols-4 td:not(:first-child)::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 600;
    text-align: left;
  }

  article .box .table-cols-4 td:not(:last-child) {
    border-bottom: 1px solid var(--border);
  }

  article .box .table-cols-4 td:last-child {
    border-bottom: none;
  }
}

/* ── 본문 각주와 원문 출처 ─────────────────────────────── */
article .box .citation {
  margin-left: 0.08em;
  vertical-align: super;
  line-height: 0;
}

article .box .citation-ref {
  border-bottom: none;
  color: #1976d2;
  font-size: 0.7em;
  font-weight: 650;
  white-space: nowrap;
}

article .box .citation-ref:hover,
article .box .citation-ref:focus-visible {
  border-bottom: none;
  background: rgba(25, 118, 210, 0.1);
  border-radius: 3px;
  outline: none;
}

article .box .source-note {
  margin: 0.55rem 0 1.35rem;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.6;
}

article .box .table-scroll + .source-note {
  margin-top: -0.8rem;
}

.article-sources {
  margin: 3rem 0 0;
  border-top: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 1rem;
}

article .box .article-sources-heading {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 1rem;
  line-height: 1.4;
}

.article-sources-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0.25rem;
  border: 0;
  background: transparent;
  color: var(--heading);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.article-sources-toggle:hover {
  background: #f7f8fa;
}

.article-sources-summary,
.article-sources-action {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.article-sources-label {
  font-weight: 700;
}

.article-sources-count,
.article-sources-action {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.article-sources-chevron {
  width: 0.48rem;
  height: 0.48rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.16s ease;
}

.article-sources[data-expanded="true"] .article-sources-chevron {
  transform: rotate(225deg) translate(-2px, -1px);
}

article .box .article-sources ol {
  margin: 0;
  padding: 0.25rem 0.25rem 1rem;
  list-style: none;
}

article .box .article-sources ol[hidden] {
  display: none;
}

article .box .article-sources li {
  display: grid;
  grid-template-columns: 2.2rem minmax(0, 1fr);
  gap: 0.3rem;
  margin: 0;
  padding: 0.48rem 0;
  line-height: 1.55;
}

article .box .article-sources .source-index {
  border-bottom: none;
  color: var(--muted);
  font-size: 0.78rem;
}

article .box .article-sources .source-link {
  border-bottom: none;
  color: var(--accent);
  font-size: 0.86rem;
}

.article-sources .source-name {
  font-weight: 700;
}

.article-sources time {
  margin-left: 0.5rem;
  color: var(--muted);
  font-size: 0.74rem;
  white-space: nowrap;
}

.citation-dialog {
  position: fixed;
  inset: auto 1.5rem 1.5rem auto;
  z-index: 1000;
  width: min(380px, calc(100vw - 2rem));
  max-height: min(70vh, 480px);
  margin: 0;
  padding: 1rem 1.1rem;
  overflow: auto;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: var(--card);
  color: var(--text);
  box-shadow: 0 16px 40px rgba(20, 23, 28, 0.2);
  font-family: var(--font-sans);
}

.citation-dialog:not([open]) {
  display: none;
}

.citation-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.citation-dialog-close {
  padding: 0.1rem 0.25rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 1.2rem;
  line-height: 1;
}

.citation-dialog-meta {
  margin-top: 0.65rem;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
}

.citation-dialog-title {
  margin-top: 0.45rem;
  font-size: 0.9rem;
  line-height: 1.6;
}

.citation-dialog-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

article .box .citation-dialog-open {
  padding: 0.5rem 0.7rem;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.citation-dialog-all {
  padding: 0.45rem 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 650;
}

@media screen and (max-width: 740px) {
  .citation-dialog {
    inset: auto 0.75rem 0.75rem;
    width: auto;
    max-height: 60vh;
  }

  article .box .article-sources li {
    grid-template-columns: 1.8rem minmax(0, 1fr);
  }

  .article-sources time {
    display: block;
    margin: 0.15rem 0 0;
  }
}
