/* TR1 위키 — 독립 문서 사이트 스타일. docs/wiki-design.md
 *
 * 게임 CSS(core.bundle.css · home.css)를 **일부러 쓰지 않는다.** 위키는 views/wiki-layout.php 라는
 * 자기 레이아웃을 갖고, 색·폰트 토큰(tokens.css)과 아이콘(icons.css)만 게임과 공유한다.
 * 그래서 이 파일은 리셋부터 컴포넌트까지 자급자족해야 한다 — .panel 같은 게임 클래스는 여기 없다.
 *
 * 색감은 게임의 다크 판타지를 잇되, 레이아웃·서체·간격은 읽기용으로 다시 잡았다.
 * 게임이 "빽빽한 정보 대시보드"라면 위키는 "넓고 조용한 읽는 화면"이다.
 */

/* ── 리셋 (게임 레이아웃 CSS 를 안 싣는 대신) ─────────────── */
*, *::before, *::after { box-sizing: border-box; }

.wiki-body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-0);
  color: var(--text-1);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 16px;          /* 게임(0.8rem 대)보다 크게 — 긴 글을 읽는 화면이다 */
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.wiki-body a { color: inherit; }

/* 스크린리더 전용 / 건너뛰기 링크 — 접근성이자 크롤러가 좋아하는 구조다. */
.wk-sr {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}
.wk-skip {
  position: absolute; left: -999px; top: 0; z-index: 100;
  padding: 0.6rem 1rem; background: var(--accent); color: #1a1206;
  font-weight: 700; text-decoration: none;
}
.wk-skip:focus { left: 0; }

/* ── 상단 헤더 ─────────────────────────────────────────────── */
.wk-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--border);
  /* 게임 상단바보다 한 톤 깊게 — 여기가 다른 곳이라는 신호를 색으로 준다. */
  background: rgba(10, 13, 22, 0.92);
  backdrop-filter: blur(8px);
}
.wk-header__inner {
  max-width: 84rem;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.wk-brand { display: flex; align-items: baseline; gap: 0.45rem; text-decoration: none; flex: none; }
.wk-brand__mark {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--accent);
}
.wk-brand__name {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  color: var(--text-2);
}
.wk-header__tagline {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding-left: 1rem;
  border-left: 1px solid var(--border);
  color: var(--text-2);
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wk-header__nav { flex: none; }
.wk-header__link {
  display: inline-block;
  padding: 0.4rem 0.95rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: rgba(var(--accent-rgb), 0.14);
  color: var(--accent-hi);
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.wk-header__link:hover { background: rgba(var(--accent-rgb), 0.26); }

/* ── 본체 2열 ──────────────────────────────────────────────── */
.wk-shell {
  flex: 1;
  width: 100%;
  max-width: 84rem;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 3rem;
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr);
  gap: 2.5rem;
  align-items: start;
}
@media (max-width: 900px) {
  .wk-shell { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
}

/* ── 좌측 목차 ─────────────────────────────────────────────── */
.wk-nav {
  position: sticky;
  top: 4.5rem;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
  padding-right: 0.4rem;
  font-size: 0.9rem;
}
@media (max-width: 900px) {
  .wk-nav { position: static; max-height: none; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
}

.wk-nav__filter { margin-bottom: 0.9rem; }
.wk-nav__filter-input {
  width: 100%;
  padding: 0.45rem 0.7rem;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-0);
  font: inherit;
  font-size: 0.85rem;
}
.wk-nav__filter-input::placeholder { color: var(--text-2); }
.wk-nav__filter-input:focus { outline: none; border-color: var(--accent); }

.wk-nav__home {
  display: block;
  margin-bottom: 0.5rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-weight: 600;
  text-decoration: none;
}
.wk-nav__home:hover { background: var(--bg-1); color: var(--text-0); }
.wk-nav__home.is-active { background: rgba(var(--accent-rgb), 0.16); color: var(--accent-hi); }

.wk-nav__empty { margin: 0.8rem 0.6rem; color: var(--text-2); font-size: 0.85rem; }

.wk-cat { border-top: 1px solid var(--border); }
.wk-cat:first-of-type { border-top: 0; }
.wk-cat__head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.6rem;
  cursor: pointer;
  list-style: none;
  color: var(--text-1);
  font-size: 0.88rem;
  font-weight: 700;
}
.wk-cat__head::-webkit-details-marker { display: none; }
.wk-cat__head:hover { color: var(--text-0); }
.wk-cat__head::before {
  content: "▸";
  flex: none;
  color: var(--text-2);
  font-size: 0.72rem;
  transition: transform 0.12s ease;
}
.wk-cat[open] > .wk-cat__head::before { transform: rotate(90deg); }
.wk-cat__label { flex: 1; min-width: 0; }
.wk-cat__count { flex: none; color: var(--text-2); font-size: 0.72rem; font-variant-numeric: tabular-nums; }

.wk-cat__list { list-style: none; margin: 0 0 0.5rem; padding: 0 0 0 0.85rem; }
.wk-doclink {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.6rem;
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-1);
  font-size: 0.86rem;
  text-decoration: none;
}
.wk-doclink:hover { background: var(--bg-1); color: var(--text-0); }
.wk-doclink.is-active {
  border-left-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.14);
  color: var(--accent-hi);
  font-weight: 700;
}
.wk-doclink.is-pending { color: var(--text-2); }
.wk-doclink__title { flex: 1; min-width: 0; }

/* 뱃지는 줄바꿈되지 않는다(프로젝트 공통 규약). */
.wk-tag {
  flex: none;
  white-space: nowrap;
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-1);
  color: var(--text-2);
  font-size: 0.62rem;
  font-weight: 600;
}

/* ── 본문 공통 ─────────────────────────────────────────────── */
.wk-main { min-width: 0; }

.wk-btn {
  display: inline-block;
  padding: 0.45rem 1rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-0);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
}
.wk-btn:hover { border-color: var(--accent); color: var(--accent-hi); }

.wk-empty {
  padding: 2.5rem 1.5rem;
  background: var(--bg-1);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  text-align: center;
}
.wk-empty__title { color: var(--text-0); font-size: 1.05rem; font-weight: 700; }
.wk-empty__desc { margin: 0.5rem auto 1.2rem; max-width: 32rem; color: var(--text-2); font-size: 0.92rem; }

/* ── 위키 홈 ───────────────────────────────────────────────── */
.wk-home__head { margin-bottom: 2rem; }
.wk-home__title {
  margin: 0;
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-0);
}
.wk-home__lead { margin: 0.6rem 0 0; max-width: 42rem; color: var(--text-1); font-size: 1rem; }
.wk-home__progress {
  display: inline-block;
  margin: 1rem 0 0;
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-1);
  color: var(--text-2);
  font-size: 0.82rem;
}
.wk-home__progress b { color: var(--accent-hi); font-variant-numeric: tabular-nums; }

.wk-home__grid {
  display: grid;
  /* 열 수가 출렁이면 카드 높이가 흔들린다 — 최소폭을 못박고 auto-fill 로 채운다. */
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 1rem;
  /* 카드가 자기 내용만큼만 높아지게. 기본값(stretch)이면 문서 3개짜리 카드가
     같은 줄의 5개짜리에 맞춰 늘어나 아래가 빈다. */
  align-items: start;
}
.wk-card {
  padding: 1rem 1.1rem 1.1rem;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.wk-card__title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0 0 0.6rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 700;
}
.wk-card__count { color: var(--text-2); font-size: 0.75rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.wk-card__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.1rem; }
.wk-card__link {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.28rem 0.35rem;
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-size: 0.9rem;
  text-decoration: none;
}
.wk-card__link:hover { background: var(--bg-2); color: var(--text-0); }
.wk-card__link.is-pending { color: var(--text-2); }

/* ── 문서 ──────────────────────────────────────────────────── */
.wk-doc { max-width: 48rem; }

.wk-crumb { margin-bottom: 0.8rem; color: var(--text-2); font-size: 0.8rem; }
.wk-crumb a { color: var(--accent); text-decoration: none; }
.wk-crumb a:hover { text-decoration: underline; }
.wk-crumb span[aria-hidden] { margin: 0 0.35rem; }

.wk-doc__head { margin-bottom: 1.6rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.wk-doc__title {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.3;
  color: var(--text-0);
}
.wk-doc__summary { margin: 0.5rem 0 0; color: var(--text-2); font-size: 0.98rem; }

.wk-toc {
  margin: 0 0 1.8rem;
  padding: 0.8rem 1rem;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
}
.wk-toc__title {
  margin-bottom: 0.35rem;
  color: var(--text-2);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}
.wk-toc ul { list-style: none; margin: 0; padding: 0; }
.wk-toc a { color: var(--text-1); font-size: 0.88rem; line-height: 1.9; text-decoration: none; }
.wk-toc a:hover { color: var(--accent-hi); text-decoration: underline; }
.wk-toc__l3 { padding-left: 1rem; }

/* 본문 산출물 — libs/content/markdown.php 가 뱉는 클래스와 1:1 로 대응한다.
   렌더러의 출력 클래스를 고칠 때 이 블록도 같이 고쳐야 한다. */
.wk-prose { font-size: 1rem; line-height: 1.85; color: var(--text-1); }
.wk-prose > :first-child { margin-top: 0; }
.wk-prose p { margin: 0 0 1.1rem; }

.wiki-doc__h2 {
  margin: 2.4rem 0 0.9rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-0);
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.4;
  scroll-margin-top: 5rem;   /* sticky 헤더에 제목이 가리지 않게 */
}
.wiki-doc__h3 {
  margin: 1.9rem 0 0.6rem;
  color: var(--accent-hi);
  font-size: 1.12rem;
  font-weight: 700;
  scroll-margin-top: 5rem;
}
.wiki-doc__h4 {
  margin: 1.4rem 0 0.5rem;
  color: var(--text-0);
  font-size: 1rem;
  font-weight: 700;
  scroll-margin-top: 5rem;
}

.wiki-doc__list { margin: 0 0 1.1rem; padding-left: 1.4rem; }
.wiki-doc__list li { margin: 0.3rem 0; }
.wiki-doc__list--sub { margin: 0.3rem 0 0.4rem; padding-left: 1.2rem; }

.wiki-doc__link {
  color: var(--accent-hi);
  text-decoration: none;
  border-bottom: 1px solid rgba(var(--accent-hi-rgb), 0.4);
}
.wiki-doc__link:hover { border-bottom-color: var(--accent-hi); }

.wiki-doc__code {
  padding: 0.1rem 0.35rem;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--accent-hi);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.86em;
  white-space: nowrap;
}

.wiki-doc__pre {
  margin: 0 0 1.2rem;
  padding: 0.9rem 1rem;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow-x: auto;   /* 긴 코드가 본문 폭을 밀지 않게 */
}
.wiki-doc__pre code {
  color: var(--text-1);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.86rem;
  line-height: 1.7;
  white-space: pre;
}

.wiki-doc__quote {
  margin: 0 0 1.2rem;
  padding: 0.3rem 1.1rem;
  border-left: 3px solid var(--accent);
  background: rgba(var(--accent-rgb), 0.06);
  color: var(--text-2);
}
.wiki-doc__quote p:last-child { margin-bottom: 0; }
.wiki-doc__hr { margin: 2rem 0; border: 0; border-top: 1px solid var(--border); }

/* 표는 자기 컨테이너 안에서 스크롤한다 — 페이지 본문이 가로로 밀리면 안 된다. */
.wiki-doc__table-wrap { margin: 0 0 1.3rem; overflow-x: auto; }
.wiki-doc__table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.wiki-doc__table th,
.wiki-doc__table td { padding: 0.5rem 0.7rem; border: 1px solid var(--border); vertical-align: top; }
.wiki-doc__table th { background: var(--bg-2); color: var(--text-0); font-weight: 700; white-space: nowrap; }
.wiki-doc__table tbody tr:nth-child(even) td { background: rgba(255, 255, 255, 0.018); }

/* 이전/다음 */
.wk-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  margin-top: 2.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
}
@media (max-width: 560px) { .wk-pager { grid-template-columns: minmax(0, 1fr); } }
.wk-pager__link {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.7rem 0.9rem;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
}
.wk-pager__link:hover { border-color: var(--accent); }
.wk-pager__link--next { text-align: right; }
.wk-pager__dir { color: var(--text-2); font-size: 0.72rem; letter-spacing: 0.1em; }
.wk-pager__title { color: var(--text-1); font-size: 0.92rem; font-weight: 600; }

/* ── 푸터 ──────────────────────────────────────────────────── */
.wk-footer { border-top: 1px solid var(--border); background: var(--bg-1); }
.wk-footer__inner {
  max-width: 84rem;
  margin: 0 auto;
  padding: 1.1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--text-2);
  font-size: 0.84rem;
}
.wk-footer__link { color: var(--accent); text-decoration: none; }
.wk-footer__link:hover { text-decoration: underline; }
.wk-footer__nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.9rem;
}
