@layer reset, site, wiki;

/* RND-08: 위키 본문은 .wiki-content 안에서만, 클래스는 wiki- 접두사, 변수는 --wiki-* */
@layer wiki {
  :root {
    --wiki-text: #1f2328;
    --wiki-heading-line: #dfe3e8;
    --wiki-link: #0a6b9e;
    --wiki-link-missing: #d92d20;
    --wiki-link-hidden: #8a8f98;
    --wiki-code-bg: #eef0f3;
    --wiki-table-line: #cfd5dc;
    --wiki-table-head: #f1f3f5;
    --wiki-note-bg: #e8f2fc; --wiki-note-line: #3b82c4;
    --wiki-warning-bg: #fdecea; --wiki-warning-line: #d92d20;
    --wiki-tip-bg: #e7f6ee; --wiki-tip-line: #12a150;
    --wiki-quote-bg: #f5f6f8; --wiki-quote-line: #98a0ab;
    --wiki-info-bg: #f8f9fb; --wiki-info-head: #d9e8e6;
  }
  :root[data-theme="dark"] {
    --wiki-text: #e4e6ea; --wiki-heading-line: #3a4047; --wiki-link: #6cb8e6;
    --wiki-link-missing: #ff7b7b; --wiki-link-hidden: #8a929d;
    --wiki-code-bg: #2a2f35; --wiki-table-line: #3d444c; --wiki-table-head: #262b31;
    --wiki-note-bg: #172a3d; --wiki-note-line: #4b8fd0;
    --wiki-warning-bg: #3a1d1b; --wiki-warning-line: #ff7b7b;
    --wiki-tip-bg: #16322a; --wiki-tip-line: #3fbf7a;
    --wiki-quote-bg: #24282d; --wiki-quote-line: #6b7480;
    --wiki-info-bg: #22272c; --wiki-info-head: #1d3b38;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --wiki-text: #e4e6ea; --wiki-heading-line: #3a4047; --wiki-link: #6cb8e6;
      --wiki-link-missing: #ff7b7b; --wiki-link-hidden: #8a929d;
      --wiki-code-bg: #2a2f35; --wiki-table-line: #3d444c; --wiki-table-head: #262b31;
      --wiki-note-bg: #172a3d; --wiki-note-line: #4b8fd0;
      --wiki-warning-bg: #3a1d1b; --wiki-warning-line: #ff7b7b;
      --wiki-tip-bg: #16322a; --wiki-tip-line: #3fbf7a;
      --wiki-quote-bg: #24282d; --wiki-quote-line: #6b7480;
      --wiki-info-bg: #22272c; --wiki-info-head: #1d3b38;
    }
  }

  .wiki-content { color: var(--wiki-text); line-height: 1.8; overflow-wrap: anywhere; }
  .wiki-content::after { content: ""; display: block; clear: both; }
  .wiki-content h1, .wiki-content h2, .wiki-content h3, .wiki-content h4, .wiki-content h5, .wiki-content h6 {
    margin: 1.4em 0 .5em; line-height: 1.35;
  }
  /* 본문 큰 제목(#)도 문서 제목보다 작게, 단계가 구분되게 */
  .wiki-content h1 { font-size: 1.45rem; border-bottom: 2px solid var(--wiki-heading-line); padding-bottom: .2em; }
  .wiki-content h2 { font-size: 1.3rem; border-bottom: 1px solid var(--wiki-heading-line); padding-bottom: .2em; }
  .wiki-content h3 { font-size: 1.15rem; }
  .wiki-content h4 { font-size: 1.05rem; }
  .wiki-content h5 { font-size: 1rem; }
  .wiki-content h6 { font-size: .95rem; color: var(--site-muted, #6b7280); }
  .wiki-content p, .wiki-content ul, .wiki-content ol { margin: .6em 0; }
  .wiki-content a { color: var(--wiki-link); }
  .wiki-content code { background: var(--wiki-code-bg); padding: .1em .35em; border-radius: 4px; font-size: .9em; }
  .wiki-content pre { background: var(--wiki-code-bg); padding: 12px 14px; border-radius: 8px; overflow-x: auto; }
  .wiki-content pre code { background: none; padding: 0; }
  .wiki-content img { max-width: 100%; height: auto; border-radius: 6px; }
  .wiki-content hr { border: 0; border-top: 1px solid var(--wiki-heading-line); margin: 1.4em 0; }
  .wiki-content table { border-collapse: collapse; margin: .8em 0; display: block; overflow-x: auto; max-width: 100%; }
  .wiki-content th, .wiki-content td { border: 1px solid var(--wiki-table-line); padding: 6px 10px; }
  .wiki-content th { background: var(--wiki-table-head); }
  .wiki-content blockquote { margin: .8em 0; padding: .2em 1em; border-left: 4px solid var(--wiki-quote-line); color: inherit; }

  .wiki-content .wiki-link--missing { color: var(--wiki-link-missing); }
  .wiki-content .wiki-link--hidden { color: var(--wiki-link-hidden); }

  /* 배경색 글자: 렌더러가 밝기를 계산해 대비되는 글자색을 정한다 */
  .wiki-content .wiki-bg { padding: 0 .2em; border-radius: 3px; }
  .wiki-content .wiki-bg--light { color: #111827; }
  .wiki-content .wiki-bg--dark { color: #ffffff; }

  .wiki-box { margin: 1em 0; padding: .6em 1em; border-left: 5px solid; border-radius: 4px; }
  .wiki-box > :first-child { margin-top: 0; }
  .wiki-box > :last-child { margin-bottom: 0; }
  .wiki-box__title { font-weight: 700; margin-bottom: .2em; }
  .wiki-box--note { background: var(--wiki-note-bg); border-color: var(--wiki-note-line); }
  .wiki-box--warning { background: var(--wiki-warning-bg); border-color: var(--wiki-warning-line); }
  .wiki-box--tip { background: var(--wiki-tip-bg); border-color: var(--wiki-tip-line); }

  .wiki-fold { margin: 1em 0; border: 1px solid var(--wiki-table-line); border-radius: 6px; padding: .4em 1em; }
  .wiki-fold > summary { cursor: pointer; font-weight: 600; }

  .wiki-content .wiki-quote { background: var(--wiki-quote-bg); }
  .wiki-quote__by { text-align: right; color: var(--site-muted, #6b7280); font-size: .9em; }

  /* 정보 틀: 오른쪽 float, 640px 이하에서는 전체 폭 */
  .wiki-infobox { float: right; clear: right; width: 320px; max-width: 45%; margin: 0 0 1em 1.2em; background: var(--wiki-info-bg);
    border: 1px solid var(--wiki-table-line); border-radius: 8px; overflow: hidden; }
  .wiki-infobox__title { background: var(--wiki-info-head); text-align: center; font-weight: 700; padding: .5em; }
  .wiki-content .wiki-infobox table { display: table; width: 100%; margin: 0; }
  .wiki-content .wiki-infobox th { width: 36%; text-align: left; }
  .wiki-content .wiki-infobox th, .wiki-content .wiki-infobox td { border-left: 0; border-right: 0; }
  @media (max-width: 640px) {
    .wiki-infobox { float: none; width: 100%; max-width: none; margin: 1em 0; }
  }

  @media (prefers-reduced-motion: no-preference) {
    .wiki-fold > summary { transition: color .15s; }
  }
}
