/* ========================================
   폰트 설정
   ======================================== */

/* D2Coding 폰트 로드 */
@import url('https://cdn.jsdelivr.net/gh/wan2land/d2coding/d2coding-subset.css');

/* 코드 블럭 및 인라인 코드에 D2Coding 적용 */
.md-typeset code,
.md-typeset pre,
.md-typeset kbd {
  font-family: 'D2Coding', 'D2 Coding', 'Consolas', 'Monaco', 'Courier New', monospace;
  font-variant-ligatures: none;
}

/* 코드 블럭 가독성 개선 */
.md-typeset pre > code {
  font-size: 0.85em;
  line-height: 1.6;
}

/* 인라인 코드 */
.md-typeset code {
  font-size: 0.875em;
}

/* ========================================
   Navigation 개선
   ======================================== */

/* 네비게이션 섹션 구분 강화 */
.md-nav__item--section {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
}

.md-nav__item--section > .md-nav__link {
  font-weight: 700;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--md-primary-fg-color);
}

/* 현재 활성화된 섹션 강조 */
.md-nav__item--active > .md-nav__link {
  color: var(--md-primary-fg-color);
  font-weight: 600;
}

/* 현재 페이지 강조 */
.md-nav__link--active {
  color: var(--md-primary-fg-color) !important;
  font-weight: 600;
  border-left: 3px solid var(--md-primary-fg-color);
  padding-left: 0.5rem;
}

/* 네비게이션 항목 간격 */
.md-nav__item {
  padding-top: 0.125rem;
  padding-bottom: 0.125rem;
}

/* 중첩된 네비게이션 들여쓰기 */
.md-nav--secondary .md-nav__item {
  padding-left: 0.5rem;
}

/* 탭 스타일 개선 */
.md-tabs__link {
  font-weight: 500;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.md-tabs__link--active,
.md-tabs__link:hover {
  opacity: 1;
}

/* 다크모드 네비게이션 */
[data-md-color-scheme="slate"] .md-nav__item--section > .md-nav__link {
  color: var(--md-primary-fg-color);
}

[data-md-color-scheme="slate"] .md-nav__link--active {
  border-left-color: var(--md-accent-fg-color);
  color: var(--md-accent-fg-color) !important;
}

/* ========================================
   헤더 구분 강화
   ======================================== */

/* H1 - 페이지 타이틀 */
.md-typeset h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 0;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--md-primary-fg-color);
  color: var(--md-primary-fg-color);
}

/* H2 - 주요 섹션 */
.md-typeset h2 {
  font-size: 1.375rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.875rem;
  padding-top: 0.5rem;
  padding-bottom: 0.375rem;
  border-bottom: 2px solid var(--md-default-fg-color--lighter);
  color: var(--md-typeset-color);
}

/* H3 - 서브섹션 */
.md-typeset h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.625rem;
  padding-left: 0.625rem;
  border-left: 4px solid var(--md-primary-fg-color);
  color: var(--md-typeset-color);
}

/* H4 - 세부 항목 */
.md-typeset h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  color: var(--md-default-fg-color--light);
}

/* H5, H6 */
.md-typeset h5,
.md-typeset h6 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  color: var(--md-default-fg-color--light);
}

/* ========================================
   전체 가독성 개선
   ======================================== */

/* 본문 폰트 크기 및 행간 */
.md-typeset {
  font-size: 0.875rem;
  line-height: 1.7;
}

/* 단락 간격 */
.md-typeset p {
  margin-bottom: 1.25rem;
}

/* 코드 폰트 크기 */
.md-typeset code {
  font-size: 0.875em;
}

/* 코드 블록 행간 */
.md-typeset pre code {
  line-height: 1.5;
}

/* 인라인 코드 가독성 */
.md-typeset code:not(.highlight code) {
  padding: 0.125rem 0.375rem;
  background-color: var(--md-code-bg-color);
  border-radius: 0.25rem;
}

/* 리스트 항목 간격 */
.md-typeset ul li,
.md-typeset ol li {
  margin-top: 0.375rem;
  margin-bottom: 0.375rem;
  line-height: 1.6;
}

/* 중첩 리스트 여백 */
.md-typeset ul ul,
.md-typeset ol ol,
.md-typeset ul ol,
.md-typeset ol ul {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}


/* Blockquote 개선 */
.md-typeset blockquote {
  font-size: 0.8125rem;
  line-height: 1.4;
}

/* Admonition 개선 */
.md-typeset .admonition {
  font-size: 0.875rem;
}

.md-typeset .admonition-title {
  font-weight: 600;
}

/* ========================================
   섹션 간격 개선
   ======================================== */

/* 섹션 사이 여백 */
.md-typeset h2 + p,
.md-typeset h2 + .admonition,
.md-typeset h2 + pre {
  margin-top: 1.25rem;
}

.md-typeset h3 + p,
.md-typeset h3 + .admonition,
.md-typeset h3 + pre {
  margin-top: 1rem;
}

/* 코드 블록 전후 여백 */
.md-typeset pre {
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
}

/* 리스트 간격 */
.md-typeset ul,
.md-typeset ol {
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.md-typeset li {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

/* API 테이블 헤더 항상 표시 */
.md-typeset .doc-md-description table {
  display: table !important;
  width: 100%;
  border-collapse: collapse;
}

.md-typeset .doc-md-description table thead {
  display: table-header-group !important;
}

.md-typeset .doc-md-description table tbody {
  display: table-row-group !important;
}

/* 빈 테이블도 표시 */
.md-typeset .doc-md-description table:empty::after {
  content: "";
  display: block;
  min-height: 2rem;
}

/* Parameters/Returns 테이블 헤더 강제 표시 */
.doc-parameters table,
.doc-returns table,
.doc-raises table {
  display: table !important;
  width: 100%;
}

.doc-parameters table thead,
.doc-returns table thead,
.doc-raises table thead {
  display: table-header-group !important;
  background-color: var(--md-default-bg-color);
  font-weight: 600;
}

.doc-parameters table th,
.doc-returns table th,
.doc-raises table th {
  padding: 0.5rem;
  text-align: left;
  border-bottom: 2px solid var(--md-default-fg-color--lightest);
}

.doc-parameters table td,
.doc-returns table td,
.doc-raises table td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--md-default-fg-color--lightest);
}

/* ========================================
   API Reference 가독성 개선
   ======================================== */

/* Symbol Type 배지 스타일 - mkdocstrings 실제 구조 */

/* Module */
.doc-heading .doc-kind-module::before {
  content: "Module";
  display: inline-block;
  padding: 0.25rem 0.5rem;
  margin-right: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 0.25rem;
  background-color: #e3f2fd;
  color: #1565c0;
}

/* Class */
.doc-heading .doc-kind-class::before {
  content: "Class";
  display: inline-block;
  padding: 0.25rem 0.5rem;
  margin-right: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 0.25rem;
  background-color: #f3e5f5;
  color: #7b1fa2;
}

/* Function */
.doc-heading .doc-kind-function::before {
  content: "Function";
  display: inline-block;
  padding: 0.25rem 0.5rem;
  margin-right: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 0.25rem;
  background-color: #e8f5e9;
  color: #2e7d32;
}

/* Method */
.doc-heading .doc-kind-method::before {
  content: "Method";
  display: inline-block;
  padding: 0.25rem 0.5rem;
  margin-right: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 0.25rem;
  background-color: #e8f5e9;
  color: #2e7d32;
}

/* Attribute */
.doc-heading .doc-kind-attribute::before {
  content: "Attribute";
  display: inline-block;
  padding: 0.25rem 0.5rem;
  margin-right: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 0.25rem;
  background-color: #fff3e0;
  color: #e65100;
}

/* Property */
.doc-heading .doc-kind-property::before {
  content: "Property";
  display: inline-block;
  padding: 0.25rem 0.5rem;
  margin-right: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 0.25rem;
  background-color: #fff3e0;
  color: #e65100;
}

/* 다크 모드 */
[data-md-color-scheme="slate"] .doc-heading .doc-kind-module::before {
  background-color: rgba(33, 150, 243, 0.2);
  color: #90caf9;
}

[data-md-color-scheme="slate"] .doc-heading .doc-kind-class::before {
  background-color: rgba(156, 39, 176, 0.2);
  color: #ce93d8;
}

[data-md-color-scheme="slate"] .doc-heading .doc-kind-function::before,
[data-md-color-scheme="slate"] .doc-heading .doc-kind-method::before {
  background-color: rgba(76, 175, 80, 0.2);
  color: #a5d6a7;
}

[data-md-color-scheme="slate"] .doc-heading .doc-kind-attribute::before,
[data-md-color-scheme="slate"] .doc-heading .doc-kind-property::before {
  background-color: rgba(255, 152, 0, 0.2);
  color: #ffcc80;
}

/* Source Code 버튼 스타일 (Material 디자인) */
details.quote summary {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  margin: 0.75rem 0;
  font-size: 0.8125rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.0125em;
  color: var(--md-primary-fg-color);
  background-color: transparent;
  border: 1px solid var(--md-primary-fg-color);
  border-radius: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

/* "Source code in" 헤더를 버튼처럼 */
.mkdocstrings-source summary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.875rem;
  margin: 0.5rem 0;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--md-default-fg-color);
  background-color: var(--md-code-bg-color);
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mkdocstrings-source summary:hover {
  border-color: var(--md-primary-fg-color);
  background-color: var(--md-default-bg-color);
}

.mkdocstrings-source[open] summary {
  margin-bottom: 0.75rem;
  border-color: var(--md-primary-fg-color);
}

details.quote summary:hover {
  background-color: var(--md-primary-fg-color);
  color: var(--md-primary-fg-color--dark);
}

details.quote[open] summary {
  margin-bottom: 1rem;
  background-color: var(--md-accent-fg-color);
  border-color: var(--md-accent-fg-color);
  color: var(--md-accent-fg-color--dark);
}

/* Source Code 내용 */
details.quote div[class*="highlight"] {
  margin-top: 0;
  border-radius: 0.25rem;
  overflow: auto;
  max-height: none !important;
}

details.quote {
  max-height: none !important;
}

/* mkdocstrings source code 섹션 높이 제한 제거 */
.doc-md-description details,
.doc-contents details {
  max-height: none !important;
}

.doc-md-description details > div,
.doc-contents details > div {
  max-height: none !important;
}

/* 함수 시그니처 간격 */
.doc-signature {
  padding: 1rem;
  background-color: var(--md-code-bg-color);
  border-radius: 0.5rem;
  margin-bottom: 1rem;
}

/* Parameter 리스트 간격 */
.doc-parameters {
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.doc-parameter {
  margin-bottom: 0.75rem;
  padding-left: 1rem;
}

/* Return 섹션 강조 */
.doc-returns {
  margin-top: 1rem;
  padding: 0.75rem;
  background-color: var(--md-default-bg-color);
  border-left: 0.25rem solid var(--md-primary-fg-color);
}

/* 예제 코드 블록 */
.doc-example {
  margin-top: 1rem;
}

/* 타입 주석 스타일 */
.doc-type {
  color: var(--md-code-hl-name-color);
  font-family: var(--md-code-font-family);
  font-size: 0.85em;
}

/* ========================================
   강조 요소
   ======================================== */

/* Blockquote 스타일 개선 */
.md-typeset blockquote {
  border-left: 4px solid var(--md-primary-fg-color);
  color: var(--md-default-fg-color--light);
  max-height: none;
  height: auto;
  font-size: 0.8125rem;
  line-height: 1.4;
}

/* Admonition 여백 */
.md-typeset .admonition {
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
}

/* Horizontal Rule */
.md-typeset hr {
  margin-top: 2rem;
  margin-bottom: 2rem;
  border: none;
  border-top: 1px solid var(--md-default-fg-color--lightest);
}

/* ========================================
   우측 ToC 텍스트 줄바꿈 방지
   ======================================== */

/* 우측 ToC 링크 텍스트 줄바꿈 방지 및 말줄임 */
.md-nav--secondary .md-nav__link {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* 우측 ToC 활성 항목도 동일 처리 */
.md-nav--secondary .md-nav__link--active {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 호버 시 전체 텍스트 보이기 (툴팁 효과) */
.md-nav--secondary .md-nav__link:hover {
  white-space: normal;
  overflow: visible;
  z-index: 10;
  position: relative;
  background-color: var(--md-default-bg-color);
  padding-right: 0.5rem;
}

/* ========================================
   다크 모드 조정
   ======================================== */

[data-md-color-scheme="slate"] {
  /* H1 다크 모드 */
  .md-typeset h1 {
    border-bottom-color: var(--md-primary-fg-color);
  }

  /* H2 다크 모드 */
  .md-typeset h2 {
    border-bottom-color: var(--md-default-fg-color--light);
  }

  /* H3 다크 모드 */
  .md-typeset h3 {
    border-left-color: var(--md-primary-fg-color);
  }
}
