/* ==========================================================================
   Docs 형식 공통 부품 — docs.html 에서 시작해 다른 페이지도 같이 쓴다.
   색은 반드시 토큰에서만 가져온다 (docs/architecture.md §5).
   레이아웃: 히어로 → 3×2 색인 카드 → ≥1280px 왼쪽 sticky 목차 + 오른쪽 본문,
   <1280px 칩 열 목차. 각 섹션은 리드 → 핵심 숫자 → 그림(Fig. N) → 접힌 자세히.
   목차 스크롤 스파이와 그림 모션 게이트는 docs-kit.js.
   바깥 폭(거터·유형 상한)은 styles-v2.css 의 .page-shell + .layout-* 가 담당한다 —
   여기서는 폭 상한을 두지 않는다.
   ========================================================================== */

/* --------------------------------------------------------------------------
   색인 카드 — 번호 + 선 아이콘 + 제목만. 3열, 600px 아래 2열.
   -------------------------------------------------------------------------- */

.docs-index {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 clamp(28px, 5vw, 44px);
}

.docs-index-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid var(--pagu-line);
  border-radius: var(--pagu-radius-md);
  background: var(--pagu-panel);
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}

.docs-index-card:hover {
  border-color: var(--pagu-accent);
  background: var(--pagu-bg-subtle);
}

.docs-index-num {
  font-family: var(--pagu-font-mono);
  font-size: 12.5px;
  color: var(--pagu-muted);
  font-variant-numeric: tabular-nums;
}

.docs-index-icon {
  width: 20px;
  height: 20px;
  flex: none;
  color: var(--pagu-accent);
}

.docs-index-title {
  min-width: 0;
  color: var(--pagu-fg);
  font-size: 14.5px;
  font-weight: 700;
}

.docs-index-card:hover .docs-index-title {
  color: var(--pagu-accent-strong);
}

@media (max-width: 600px) {
  .docs-index {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .docs-index-card {
    min-height: 44px;
    padding: 8px 10px;
    gap: 8px;
  }

  .docs-index-icon {
    width: 18px;
    height: 18px;
  }
}

/* --------------------------------------------------------------------------
   본문 레이아웃 — 넓은 화면: 왼쪽 sticky 목차 + 오른쪽 글
   -------------------------------------------------------------------------- */

.docs-toc > ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.docs-article {
  min-width: 0;
}

@media (min-width: 1280px) {
  .docs-layout {
    display: grid;
    grid-template-columns: 176px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
  }

  .docs-toc {
    position: sticky;
    /* .site-header (min-height 64px) 아래에 붙는다 */
    top: 88px;
    /* 첫 .docs-section 의 margin-top(24px)과 같게 둬서 첫 헤어라인 높이를 맞춘다 */
    margin-top: 24px;
    max-height: calc(100vh - 112px);
    overflow-y: auto;
    border-top: 1px solid var(--pagu-line);
    /* 목차 첫 글자가 섹션 "01" 라벨(헤어라인+12px)과 같은 높이에 오게 */
    padding-top: 1px;
  }

  .docs-toc > ol > li + li {
    border-top: 1px solid var(--pagu-line);
  }

  .docs-toc-link {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 11px 0 9px;
    color: var(--pagu-fg);
    font-size: 14px;
    font-weight: 700;
  }

  .docs-toc-num {
    font-family: var(--pagu-font-mono);
    font-size: 11.5px;
    color: var(--pagu-muted);
    font-variant-numeric: tabular-nums;
  }

  .docs-toc-icon {
    width: 17px;
    height: 17px;
    flex: none;
    color: var(--pagu-muted);
  }

  .docs-toc-text {
    min-width: 0;
  }

  .docs-toc-link:hover {
    color: var(--pagu-accent-strong);
  }

  .docs-toc-link:hover .docs-toc-icon {
    color: var(--pagu-accent);
  }

  .docs-toc-link[aria-current="true"] {
    color: var(--pagu-accent);
  }

  .docs-toc-link[aria-current="true"] .docs-toc-icon {
    color: var(--pagu-accent);
  }
}

/* 데이터 페이지는 ≥1600px 에서 목차를 조금 더 넓힌다 (읽기 페이지는 176+24 유지) */
@media (min-width: 1600px) {
  .layout-data .docs-layout {
    grid-template-columns: 192px minmax(0, 1fr);
    gap: 32px;
  }
}

/* 좁은 화면: 목차는 헤더 밑에 붙는 가로 스크롤 칩 열 (칩 높이 44px) */
@media (max-width: 1279.98px) {
  .docs-toc {
    position: sticky;
    top: 64px;
    z-index: 20;
    margin: -4px 0 8px;
    padding: 8px 0;
    background: var(--bg);
  }

  .docs-toc > ol {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .docs-toc > ol::-webkit-scrollbar {
    display: none;
  }

  .docs-toc-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 44px;
    padding: 9px 15px;
    border: 1px solid var(--pagu-line);
    border-radius: var(--pagu-radius-sm);
    background: var(--pagu-panel);
    color: var(--pagu-muted);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
  }

  .docs-toc-num {
    font-family: var(--pagu-font-mono);
    font-size: 11.5px;
    color: var(--pagu-muted);
    font-variant-numeric: tabular-nums;
  }

  .docs-toc-icon {
    display: none;
  }

  .docs-toc-link[aria-current="true"] {
    color: var(--pagu-accent);
    border-color: var(--pagu-accent);
    background: var(--pagu-accent-weak);
  }
}

/* site-header 는 860px 이하에서 min-height 58px */
@media (max-width: 860px) {
  .docs-toc {
    top: 58px;
  }
}

/* --------------------------------------------------------------------------
   목차 링크 — 본문 인라인 링크 규칙(main :is(…li…) a[href]:not(…))이 목차
   안의 링크에도 밑줄과 강조색을 입힌다. 그 규칙의 특이성이 아주 높아(0,6,4)
   목차에서는 선언을 !important로 되돌린다. 포커스 아웃라인은 건드리지 않는다.
   -------------------------------------------------------------------------- */

.docs-toc a[href] {
  color: var(--pagu-muted) !important;
  text-decoration: none !important;
}

.docs-toc a[href].docs-toc-link {
  color: var(--pagu-fg) !important;
}

.docs-toc a[href]:hover {
  color: var(--pagu-accent-strong) !important;
}

.docs-toc a[href][aria-current="true"] {
  color: var(--pagu-accent) !important;
}

/* --------------------------------------------------------------------------
   섹션 — 번호 라벨 위 h2, 섹션 위 1px 헤어라인. 타입 스케일 1.25 (16→20→25).
   -------------------------------------------------------------------------- */

/* 섹션 간격 — 첫 섹션 24px, 이후 섹션은 40px (<768px 32px) */
.docs-section {
  margin-top: 40px;
  padding-top: 12px;
  border-top: 1px solid var(--pagu-line);
  scroll-margin-top: 96px;
}

/* 앞에 같은 칸의 .docs-section 이 하나도 없는 첫 .docs-section — page-title 처럼
   다른 <section> 이 먼저 와도 잡히게 :first-of-type 대신 형제 부정을 쓴다.
   docs-layout 없이 main 에 바로 놓인 섹션(defi-dashboard·labs)도 같은 취급 */
.docs-article > .docs-section:not(.docs-section ~ .docs-section),
.page-shell > .docs-section:not(.docs-section ~ .docs-section) {
  margin-top: 24px;
}

@media (max-width: 767.98px) {
  .docs-section {
    margin-top: 32px;
  }
}

.docs-section h2,
.docs-section h3 {
  scroll-margin-top: 96px;
}

@media (max-width: 1279.98px) {
  .docs-section,
  .docs-section h2,
  .docs-section h3 {
    /* sticky 헤더(58px) + 칩 열(약 60px) 아래로 앵커가 내려오게 */
    scroll-margin-top: 132px;
  }
}

.docs-num {
  margin: 0 0 6px;
  font-family: var(--pagu-font-mono);
  font-size: 13px;
  color: var(--pagu-muted);
  font-variant-numeric: tabular-nums;
}

.docs-section h2 {
  margin-bottom: 10px;
  font-size: 25px;
  font-weight: 800;
}

.docs-lead {
  margin: 0 0 18px;
  color: var(--text-sub);
  font-size: 15.5px;
  line-height: 1.55;
}

.docs-section h3 {
  margin: 32px 0 12px;
  font-size: 20px;
  font-weight: 750;
}

.docs-section > p,
.docs-section > ul,
.docs-section > ol,
.docs-more p,
.docs-more > ul,
.docs-more > ol {
  margin: 0 0 14px;
  color: var(--text-sub);
  font-size: 16px;
  line-height: 1.65;
}

.docs-section ul,
.docs-section ol {
  padding-left: 1.3em;
}

.docs-section li {
  margin-bottom: 6px;
}

.docs-section strong {
  color: var(--pagu-fg);
}

.docs-section code {
  font-family: var(--pagu-font-mono);
  font-size: 0.92em;
}

/* --------------------------------------------------------------------------
   핵심 숫자 — 큰 값 + 짧은 라벨의 타일 2~3개.
   -------------------------------------------------------------------------- */

.docs-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 20px;
}

.docs-stat {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--pagu-line);
  border-radius: var(--pagu-radius-md);
  background: var(--pagu-panel);
}

.docs-stat-v {
  color: var(--pagu-fg);
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.docs-stat-v b {
  font-weight: inherit;
}

.docs-stat-u {
  font-size: 13px;
  font-weight: 650;
  color: var(--pagu-muted);
}

.docs-stat-l {
  margin-top: 2px;
  color: var(--pagu-muted);
  font-size: 12.5px;
  line-height: 1.4;
}

/* <768px 는 2칸. 타일이 3·5장이면 2칸으로는 마지막 줄에 하나만 남으므로 3칸을 유지한다
   (카드 격자 규칙: 마지막 줄에 혼자 남는 카드를 두지 않는다 — docs/architecture.md "페이지 폭"). */
@media (max-width: 767.98px) {
  .docs-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .docs-stats:has(> :nth-child(3):last-child),
  .docs-stats:has(> :nth-child(5):last-child) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .docs-stat {
    padding: 10px 11px;
  }

  .docs-stat-v {
    font-size: 18px;
  }

  .docs-stat-l {
    font-size: 11.5px;
  }
}

/* --------------------------------------------------------------------------
   Fig. N — 그림틀. 그림 안 요소 스타일은 페이지마다 따로 (docs-figs.css 등).
   -------------------------------------------------------------------------- */

.docs-fig {
  margin: 0 0 22px;
  padding: 16px 18px 14px;
  border: 1px solid var(--pagu-line);
  border-radius: var(--pagu-radius-md);
  background: var(--pagu-panel);
  min-width: 0;
}

.docs-fig-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
}

.docs-fig-no {
  flex: none;
  font-family: var(--pagu-font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--pagu-accent);
  font-variant-numeric: tabular-nums;
}

.docs-fig .docs-fig-title {
  margin: 0;
  font-size: 16px;
  font-weight: 750;
  color: var(--pagu-fg);
}

.docs-fig figcaption {
  margin-top: 12px;
  color: var(--pagu-muted);
  font-size: 13px;
  line-height: 1.55;
}

/* --------------------------------------------------------------------------
   검증 표 보기 — 접힌 details. 열면 표와 긴 설명이 그대로 들어 있다.
   -------------------------------------------------------------------------- */

.docs-more {
  margin: 6px 0 0;
  border-top: 1px solid var(--pagu-line);
}

.docs-more > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 2px;
  cursor: pointer;
  color: var(--pagu-muted);
  font-size: 14px;
  font-weight: 650;
  list-style: none;
}

.docs-more > summary::-webkit-details-marker {
  display: none;
}

.docs-more > summary::before {
  content: "▸";
  color: var(--pagu-muted);
  font-size: 12px;
  transition: transform var(--fast) var(--ease);
}

.docs-more[open] > summary::before {
  transform: rotate(90deg);
}

.docs-more > summary:hover {
  color: var(--pagu-accent-strong);
}

.docs-more[open] {
  padding-bottom: 8px;
}

/* 수식 블록 — monospace, 가로 스크롤 */
.docs-formula {
  margin: 0 0 14px;
  padding: 14px 16px;
  border: 1px solid var(--pagu-line);
  border-radius: var(--pagu-radius-sm);
  background: var(--pagu-bg-subtle);
  color: var(--pagu-fg);
  font-family: var(--pagu-font-mono);
  font-size: 13.5px;
  line-height: 1.7;
  overflow-x: auto;
  white-space: pre;
}

/* 표 — 칸 안에서 가로 스크롤, 숫자는 오른쪽 정렬 + tabular-nums */
.docs-table-wrap {
  margin: 0 0 16px;
  overflow-x: auto;
  border: 1px solid var(--pagu-line);
  border-radius: var(--pagu-radius-md);
}

.docs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.5;
}

.docs-table th,
.docs-table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--pagu-line);
  vertical-align: top;
}

/* styles-v2.css 가 thead th / tbody td 의 첫 칸 외를 오른쪽 정렬한다(선택자 0,1,2).
   이 표는 글자 칸이 많아 왼쪽 정렬이 기본이다 — 같은 특이성 + 나중에 오는 규칙으로 되돌린다. */
.docs-table thead th,
.docs-table tbody td {
  text-align: left;
}

.docs-table thead th.num,
.docs-table tbody td.num {
  text-align: right;
}

.docs-table thead th {
  background: var(--pagu-bg-subtle);
  color: var(--pagu-muted);
  font-size: 12.5px;
  font-weight: 650;
  white-space: nowrap;
}

.docs-table tbody tr:last-child td {
  border-bottom: 0;
}

.docs-table .num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  white-space: nowrap;
}

/* 주의 콜아웃 — 실제 위험(단위 환산·IL·구간 이탈·V4 미지원)에만 */
.docs-caution {
  padding: 12px 16px;
  margin: 0 0 14px;
  border-left: 3px solid var(--pagu-warn);
  border-radius: 0 var(--pagu-radius-sm) var(--pagu-radius-sm) 0;
  background: var(--pagu-warn-weak);
  color: var(--pagu-fg);
  font-size: 14.5px;
}

.docs-caution strong {
  color: var(--pagu-warn);
}

/* --------------------------------------------------------------------------
   모션 끄기 (모든 페이지의 Fig.) — OS 가 "움직임 줄이기"면 그림 안의 모든 애니메이션·전환을 끈다.
   JS 가 .motion-on 을 안 붙이는 것과 별개로 CSS 측에서도 한 번 더 막는다.
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .docs-fig *,
  .docs-fig *::before,
  .docs-fig *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* 2026-10-30 - the section number and heading share one baseline. */
.docs-index { gap: 8px; margin-bottom: 16px; }
.docs-index-card { min-height: 40px; padding: 8px 12px; gap: 8px; }
.docs-index-icon { color: var(--pagu-muted); width: 16px; height: 16px; }
.docs-index-title { font-size: 13px; font-weight: 650; }
.docs-toc { top: var(--pagu-header-height); margin: 0 0 8px; padding: 4px 0; }
.docs-toc > ol { gap: 0; }
.docs-toc-link { min-height: 32px; padding: 6px 10px; gap: 6px; border-radius: 0; font-size: 12px; font-weight: 600; }
.docs-toc-link[aria-current="true"] { background: var(--pagu-bg-subtle); }
.docs-toc-num { font-size: 12px; }
.docs-toc-icon { width: 14px; height: 14px; }
.docs-section { margin-top: var(--pagu-section-gap); padding-top: 8px; scroll-margin-top: 116px; }
.docs-article > .docs-section:not(.docs-section ~ .docs-section),
.page-shell > .docs-section:not(.docs-section ~ .docs-section) { margin-top: 0; }
.docs-section > .docs-num { display: inline; margin: 0 8px 0 0; font-size: 12px; line-height: 24px; }
.docs-section > h2 { display: inline; margin: 0; font-size: 17px; font-weight: 700; line-height: 24px; }
.docs-section > h2 + :not(.docs-lead) { margin-top: 8px; }
.docs-section > .docs-lead { margin: 4px 0 8px; font-size: 13px; line-height: 1.45; }
.docs-section h3 { margin: 16px 0 8px; font-size: 15px; font-weight: 650; }
.docs-section > p, .docs-section > ul, .docs-section > ol,
.docs-more p, .docs-more > ul, .docs-more > ol { font-size: 13px; line-height: 1.5; margin-bottom: 8px; }
.docs-section li { margin-bottom: 4px; }
.docs-stats { gap: 0; margin-bottom: 12px; border: 1px solid var(--pagu-line); border-radius: var(--pagu-radius-md); }
.docs-stat { padding: 8px 12px; border: 0; border-radius: 0; text-align: right; }
.docs-stat + .docs-stat { border-left: 1px solid var(--pagu-line); }
.docs-stat-v { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.docs-stat-l, .docs-stat-u { font-size: 12px; }
/* A preceding rail already separates the first section from the page head. */
:is(.pdx-now, .rates-shell) .docs-article > .docs-section:first-child { border-top: 0; }
@media (min-width: 1024px) {
  .page-title-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; }
  .page-title .page-title-row > p { margin: 0; }
  :is(#pdxRatioStats, #ratesSummary) .docs-stat { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding-block: 6px; }
  :is(#pdxRatioStats, #ratesSummary) .docs-stat-l { order: -1; margin: 0; text-align: left; }
  :is(#pdxRatioStats, #ratesSummary) .docs-stat-v { margin: 0; white-space: nowrap; }
}
.docs-fig { padding: 10px 12px; margin-bottom: 12px; border-radius: var(--pagu-radius-md); }
.docs-fig-head { gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.docs-fig-no { color: var(--pagu-muted); font-size: 12px; font-weight: 500; }
.docs-fig .docs-fig-title { font-size: 14px; font-weight: 650; }
.docs-fig figcaption { margin-top: 8px; font-size: 12px; line-height: 1.45; }
.docs-more > summary { min-height: var(--pagu-control-height); padding: 6px 0; font-size: 12px; font-weight: 600; }
.docs-formula { padding: 10px 12px; margin-bottom: 8px; font-size: 12px; line-height: 1.6; }
.docs-table-wrap { margin-bottom: 8px; }
.docs-table { font-size: 13px; line-height: 1.45; }
.docs-table th, .docs-table td { padding: 8px 10px; }
.docs-table thead th { font-size: 12px; }
.docs-section .docs-caution { margin: 8px 0; padding: 8px 12px; font-size: 13px; border-left-width: 2px; background: var(--pagu-bg-subtle); }
@media (min-width: 1280px) {
  .docs-layout, .layout-data .docs-layout { grid-template-columns: 144px minmax(0, 1fr); gap: 16px; }
  :is(.pdx-now, .rates-shell) .docs-toc { padding-top: 0; }
  .docs-section > .docs-lead { display: inline; margin-left: 12px; line-height: 24px; }
  .docs-lead + :is(.docs-fig, .docs-stats, .docs-formula, .docs-caution) { margin-top: 8px; }
  .docs-toc { top: calc(var(--pagu-header-height) + 12px); margin-top: 0; padding-top: 2px; max-height: calc(100vh - 80px); }
  .docs-toc-link { padding: 8px 0; }
  .docs-section, .docs-section h2, .docs-section h3 { scroll-margin-top: 76px; }
}
@media (max-width: 767px) {
  .docs-fig { padding: 10px; }
  .docs-stat { padding: 8px; }
  .docs-stat-v { font-size: 18px; }
  .docs-section > p, .docs-section > ul, .docs-section > ol, .docs-more p { font-size: 14px; }
  .docs-section > .docs-lead { font-size: 13px; }
}
@media (max-width: 767px), (pointer: coarse) {
  .docs-toc-link, .docs-index-card, .docs-more > summary { min-height: 44px; }
}
