/* estudy 지식 그래프 (graph.html) — 독립 페이지 스타일.
   사이트 셸(site/assets/css/site.css)과 같은 미니멀 언어: mono 우선 / 15~16px · 1.45 /
   흰 배경 · 검정 텍스트 / 장식 없음(그림자·그라디언트·radius 없음).
   테마: html[data-theme]=light|dark|system, localStorage 'estudy-theme' (메인 셸과 같은 계약).
   canvas 는 CSS 변수를 못 읽어 graph.js 가 getComputedStyle 로 --graph-* 를 가져간다. */
@import url("pretendard-subset.css");

@font-face {
  font-family: 'Geist Mono';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(../fonts/geist-mono/GeistMono-Variable.woff2) format('woff2');
}

:root {
  color-scheme: light;
  --font-mono: 'Geist Mono', 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, 'Pretendard Variable', Pretendard, monospace;
  --size: 15px;
  --leading: 1.45;

  --bg: #ffffff;
  --fg: #000000;
  --muted: #666666;
  --faint: #999999;
  --line: #dddddd;
  --link: #0000ee;
  --link-visited: #551a8b;
  --code-bg: #f5f5f5;

  /* 캔버스 토큰 (회색 계열 + accent 1개) */
  --graph-bg: var(--bg);
  --graph-edge: #bbbbbb;
  --graph-edge-alpha: 0.55;
  --graph-node: #999999;
  --graph-node-neighbor: #000000;
  --graph-node-current: var(--link);
  --graph-node-visited: var(--link-visited);
  --graph-label: var(--muted);      /* #666 on #fff = 5.7:1 */
  --graph-label-strong: var(--fg);
  --graph-dim-alpha: 0.15;
  --graph-glow: 0;                  /* 라이트: 글로우 없음 */
  --graph-stars: 0;                 /* 라이트: 배경 별 생략 */
  --graph-star: #9aa6bd;            /* 라이트에서도 토큰은 정의해 둔다(별 레이어는 꺼짐) */
  --graph-star-warm: #c9b79a;
}
[data-theme="dark"] {
  color-scheme: dark;
  /* 참조(Obsidian Advanced Graph View) 픽셀 분석 결과: 배경 #090717(딥 인디고), 노드=클러스터 색(청록~보라), 선은 아주 옅게 */
  --bg: #090717; --fg: #dfe4f5; --muted: #8e97c4; --faint: #6b74a0; --line: #1a1b30;
  --link: #8aa6ff; --link-visited: #b9a6ff; --code-bg: #10112a;
  --graph-edge: #8090d0; --graph-edge-alpha: 0.16;
  --graph-node: #9fb0d8; --graph-node-neighbor: #f2f6ff;
  --graph-node-current: #a9c6ff; --graph-node-visited: #b9a6ff;
  --graph-star: #cfe0ff; --graph-star-warm: #ffe6c0;
  --graph-label: #8e97c4;
  --graph-dim-alpha: 0.12; --graph-glow: 1; --graph-stars: 1;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #090717; --fg: #dfe4f5; --muted: #8e97c4; --faint: #6b74a0; --line: #1a1b30;
    --link: #8aa6ff; --link-visited: #b9a6ff; --code-bg: #10112a;
    --graph-edge: #8090d0; --graph-edge-alpha: 0.16;
    --graph-node: #9fb0d8; --graph-node-neighbor: #f2f6ff;
    --graph-node-current: #a9c6ff; --graph-node-visited: #b9a6ff;
    --graph-star: #cfe0ff; --graph-star-warm: #ffe6c0;
    --graph-label: #8e97c4;
    --graph-dim-alpha: 0.12; --graph-glow: 1; --graph-stars: 1;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: var(--size);
  line-height: var(--leading);
  font-weight: 400;
  word-break: keep-all;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}
a { color: var(--link); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }
button, input, select { font-family: inherit; font-size: inherit; line-height: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }

.skip {
  position: absolute; left: -9999px; top: 0; padding: 8px 12px;
  background: var(--bg); color: var(--fg); border: 1px solid var(--line); z-index: 10;
}
.skip:focus { left: 16px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- 상단: ← estudy · 제목 · (우측) 수치 · 테마 ---------- */
.gh-top {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
}
.gh-home { color: var(--muted); text-decoration: none; }
.gh-home:hover { color: var(--fg); text-decoration: underline; }
.gh-title { margin: 0; font-size: var(--size); font-weight: 700; line-height: var(--leading); }
.gh-stats { margin: 0 0 0 auto; color: var(--muted); white-space: nowrap; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0;
  border: 1px solid var(--line); border-radius: 50%; background: none; color: var(--fg); cursor: pointer;
}
.icon-btn:hover { background: var(--code-bg); }
.icon-btn svg { width: 17px; height: 17px; display: block; }
.theme-btn .ic { display: none; }
:root[data-mode="light"] .theme-btn .ic-light,
:root[data-mode="dark"] .theme-btn .ic-dark,
:root[data-mode="system"] .theme-btn .ic-system { display: block; }

/* ---------- 본문: 캔버스(전체 높이 고정) ---------- */
.gh-main {
  flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0;
}

.gh-canvas-wrap { position: relative; flex: 1 1 auto; min-height: 320px; overflow: hidden; }
#graph { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; outline: none; }
#graph.dragging { cursor: grabbing; }
#graph.over { cursor: pointer; }

/* 툴바: 한 줄, 캔버스 위에 떠 있되 카드 느낌 없음(배경 없음, 밑줄 1px) */
.gh-toolbar {
  position: absolute; left: 16px; top: 12px; right: 16px; z-index: 2;
  display: flex; gap: 12px; align-items: center; flex-wrap: nowrap; overflow: hidden;
  pointer-events: none;
}
.gh-toolbar > * { pointer-events: auto; }
#q {
  flex: 0 1 220px; min-width: 100px;
  padding: 3px 0; margin: 0; border: 0; border-bottom: 1px solid var(--line);
  background: none; color: var(--fg); -webkit-appearance: none; appearance: none;
}
#q:focus { border-bottom-color: var(--fg); outline: none; }
#q:focus-visible { outline: none; }
#q::placeholder { color: var(--faint); }
#q::-webkit-search-cancel-button { -webkit-appearance: none; }
#section, #ego-depth {
  padding: 3px 0; border: 0; border-bottom: 1px solid var(--line);
  background: none; color: var(--fg); max-width: 160px; cursor: pointer;
}
#section:focus, #ego-depth:focus { border-bottom-color: var(--fg); outline: none; }
.gh-btn {
  padding: 3px 0; border: 0; border-bottom: 1px solid transparent;
  background: none; color: var(--muted); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.gh-btn:hover { color: var(--fg); border-bottom-color: var(--fg); }
.gh-btn[aria-pressed="true"] { color: var(--fg); border-bottom-color: var(--fg); }
.gh-btn-primary { color: var(--link); }
.gh-btn:disabled { opacity: 0.4; cursor: default; }

/* 사이드: 테두리 1px + 여백 */
.gh-side {
  border-left: 1px solid var(--line); background: var(--bg);
  padding: 12px 16px 24px; overflow: auto; min-height: 0;
}
/* 넓은 화면: 캔버스 오른쪽에 고정 폭 사이드(요약/상세) */
@media (min-width: 821px) {
  .gh-main { flex-direction: row; }
  .gh-side { width: 320px; flex: 0 0 320px; border-top: 0; }
}
@media (max-width: 820px) { .gh-side { border-left: 0; border-top: 1px solid var(--line); } }
/* 요약: 수치 + 섹션 목록(그래프 색 점) */
.gh-facts { display: flex; flex-wrap: wrap; gap: 2px 14px; margin: 0 0 4px; }
.gh-facts > div { display: flex; gap: 5px; align-items: baseline; }
.gh-facts dt { color: var(--muted); }
.gh-facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.gh-h3 { margin: 14px 0 4px; font-size: var(--size); font-weight: 700; }
.gh-secs { list-style: none; margin: 0; padding: 0; }
.gh-secs li { display: flex; gap: 7px; align-items: baseline; padding: 1px 0; }
.gh-secs .sw { width: 7px; height: 7px; border-radius: 50%; flex: none; align-self: center; }
.gh-secs button {
  flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 0;
  color: var(--muted); cursor: pointer; font: inherit;
}
.gh-secs button:hover { color: var(--fg); text-decoration: underline; }
.gh-secs li.is-on button { color: var(--fg); font-weight: 700; }
.gh-secs .cnt { color: var(--faint); font-variant-numeric: tabular-nums; }
.gh-excerpt { margin: 0 0 10px; color: var(--muted); line-height: 1.55; }
.gh-excerpt:empty { display: none; }
.gh-list li.is-rel .sec { color: var(--faint); }
.gh-h2 { margin: 0; font-size: var(--size); font-weight: 700; line-height: var(--leading); }
.gh-meta { margin: 0 0 8px; color: var(--muted); word-break: break-all; min-height: 1em; }
.gh-meta:empty { display: none; }
.gh-focus { padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.gh-focus-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.gh-depth { display: inline-flex; gap: 4px; align-items: center; color: var(--muted); }

.gh-list { list-style: none; margin: 0; padding: 0; }
.gh-list li { display: flex; gap: 8px; align-items: baseline; padding: 1px 0; }
.gh-list a { text-decoration: none; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg); }
.gh-list a:hover { text-decoration: underline; }
.gh-list li.is-focus a { color: var(--link); }
.gh-list li.is-hub a { font-weight: 700; }
.gh-list li.is-current a { color: var(--link); }
.gh-list .sec, .gh-list .deg { color: var(--muted); white-space: nowrap; }
.gh-list .deg { min-width: 2.2em; text-align: right; }
.gh-list .gh-btn { color: var(--muted); }
.gh-list .gh-btn:hover { color: var(--fg); }
.gh-list-empty, .gh-list-more { color: var(--muted); padding: 4px 0; }
.gh-list-more button { background: none; border: 0; color: var(--link); cursor: pointer; padding: 0; text-decoration: underline; }

.gh-error { margin: 12px 16px; padding: 8px 12px; border: 1px solid var(--line); color: var(--muted); white-space: pre-wrap; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
