/* BINDER — 디자인 토큰 · 셸 레이아웃.
   컴포넌트 스타일은 wiki.css. 색은 전부 여기 토큰을 통해서만 쓴다 —
   그래야 다크 모드가 한 곳에서 끝난다. */

:root {
  color-scheme: light dark;

  /* ── 중립 ──────────────────────────────────────────── */
  --bg:        #ffffff;
  --bg-sunken: #f6f7f9;
  --surface:   #ffffff;
  --surface-2: #f4f6f9;
  --surface-3: #eaeef4;
  --line:      #e4e8ef;
  --line-2:    #d2d9e3;
  --fg:        #0f1420;
  --fg-2:      #39424f;
  --muted:     #6a7383;

  /* ── 강조 ──────────────────────────────────────────── */
  --accent:      #4f46e5;
  --accent-hi:   #6366f1;
  --accent-fg:   #ffffff;
  --accent-soft: #eef0fe;
  --accent-line: #cfd3fa;
  --accent-2:    #0e7490;

  /* ── 의미색 ────────────────────────────────────────── */
  --ok:     #157f3c;
  --ok-bg:  #e8f6ed;
  --ok-line:#b4e0c4;
  --warn:   #8a6100;
  --warn-bg:#fff7e4;
  --warn-line:#f0dfb0;
  --danger: #c0362f;
  --danger-bg:#fdecea;
  --danger-line:#f2bcb7;
  --info-bg: #eef3ff;
  --info-line:#d2dffb;

  --red:    var(--danger);
  --dashed: #8a6d1f;
  --dashed-fg: #7a6416;
  --demo:   #b3261e;
  --demo-bg:var(--danger-bg);
  --demo-line: var(--danger-line);
  --add-bg: var(--ok-bg);
  --add-fg: var(--ok);
  --add-line: var(--ok-line);
  --del-bg: var(--danger-bg);
  --del-fg: var(--demo);
  --del-line: var(--danger-line);
  --panel:      var(--surface-2);
  --panel-line: var(--line);
  --hl:      #ffe08a;
  --term-bg: #14161c;
  --term-fg: #e3e6ec;

  /* ── 형태 ──────────────────────────────────────────── */
  --r-xs: 6px;
  --r-sm: 8px;
  --r:    11px;
  --r-lg: 16px;
  --r-pill: 999px;
  --shadow-1: 0 1px 2px rgba(15, 20, 32, .05);
  --shadow-2: 0 4px 16px -6px rgba(15, 20, 32, .14), 0 1px 3px rgba(15, 20, 32, .05);
  --shadow-3: 0 18px 40px -20px rgba(15, 20, 32, .3);
  --ring: 0 0 0 3px rgba(99, 102, 241, .32);

  --sans: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
          "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;

  --max:  1340px;
  --side: 236px;
  --gut:  clamp(16px, 3vw, 28px);
  --header-h: 60px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0d1017;
    --bg-sunken: #0a0d13;
    --surface:   #141922;
    --surface-2: #1a202b;
    --surface-3: #232b38;
    --line:      #262e3b;
    --line-2:    #36404f;
    --fg:        #e9edf4;
    --fg-2:      #b9c2d0;
    --muted:     #8b95a6;

    --accent:      #7c7cf5;
    --accent-hi:   #9a9afb;
    --accent-fg:   #0d1017;
    --accent-soft: #1d2140;
    --accent-line: #343a70;
    --accent-2:    #35b6d4;

    --ok:     #56cc84;
    --ok-bg:  #11251a;
    --ok-line:#1f4d33;
    --warn:   #e3b25c;
    --warn-bg:#241d0d;
    --warn-line:#4a3c19;
    --danger: #f0837b;
    --danger-bg:#261414;
    --danger-line:#4d2724;
    --info-bg: #151d33;
    --info-line:#26315a;

    --demo:   #f0837b;
    --dashed: #b99a3f;
    --dashed-fg: #cfae4d;
    --hl:      #6a5410;
    --term-bg: #090b10;
    --term-fg: #dfe3ea;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 4px 16px -6px rgba(0, 0, 0, .6), 0 1px 3px rgba(0, 0, 0, .4);
    --shadow-3: 0 18px 40px -20px rgba(0, 0, 0, .8);
    --ring: 0 0 0 3px rgba(124, 124, 245, .35);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg-sunken);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.62;
  letter-spacing: -0.003em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;

  /* 한국어는 기본값이면 어절 한가운데서 끊긴다("넣었습 / 니다").
     keep-all 로 공백에서만 끊고, 안 끊기는 긴 토큰만 break-word 로 흘린다. */
  word-break: keep-all;
  overflow-wrap: break-word;
}

/* 서열·경로·로그는 어절 개념이 없다 — 기본 규칙으로 되돌린다. */
code, pre, kbd, samp, .mono, .seq, .joblog, .json, .diff {
  word-break: normal;
  overflow-wrap: normal;
}

a { color: var(--accent); text-underline-offset: 2px; }

/* ── 아이콘 ─────────────────────────────────────────────
   _icons.html 의 <symbol> 을 <use> 로 찍는다. 색은 currentColor 라
   부모의 color 만 바꾸면 따라온다 — 다크 모드에 손댈 것이 없다. */
.spritesheet { display: none; }
.i {
  width: 1.05em;
  height: 1.05em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.16em;
}

:where(a, button, input, select, textarea, summary):focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--r-xs);
}

::selection { background: var(--accent-soft); color: var(--fg); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── 헤더 ───────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.header-in {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gut);
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 9px;
  font-weight: 750;
  font-size: 18px;
  letter-spacing: -0.035em;
  text-decoration: none;
  color: var(--fg);
  white-space: nowrap;
}
.brand .mark {
  display: inline-grid;
  place-items: center;
  width: 27px; height: 27px;
  border-radius: 9px;
  background: linear-gradient(140deg, var(--accent-hi), var(--accent));
  color: #fff;
  align-self: center;
  box-shadow: var(--shadow-1);
}
.brand .mark .i { width: 16px; height: 16px; vertical-align: 0; stroke-width: 1.9; }
.brand .sub {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
}
@media (max-width: 640px) { .brand .sub { display: none; } }

.navtoggle {
  display: none;
  width: 34px; height: 34px;
  align-items: center; justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--fg);
  font-size: 15px;
  cursor: pointer;
}

/* ── 셸 ─────────────────────────────────────────────────── */
.site-shell {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gut);
  display: grid;
  grid-template-columns: var(--side) minmax(0, 1fr);
  gap: 34px;
  align-items: start;
}

.site-col { min-width: 0; }

.site-main {
  padding: 30px 0 72px;
  min-height: 60vh;
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 18px 0 40px;
  color: var(--muted);
  font-size: 13px;
}
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--fg); text-decoration: underline; }
.site-footer .sep { opacity: .4; margin: 0 6px; }

/* ── 사이드바 ───────────────────────────────────────────── */
.sidenav {
  position: sticky;
  top: calc(var(--header-h) + 18px);
  max-height: calc(100vh - var(--header-h) - 36px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px 0 32px;
  font-size: 14px;
  scrollbar-width: thin;
}

.navgroup { margin: 0 0 22px; }
.navgroup > .navlabel {
  display: block;
  margin: 0 10px 7px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}

.navlist { list-style: none; margin: 0; padding: 0; }
.navlist li { margin: 1px 0; }

.navlist a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 11px;
  border-radius: var(--r-sm);
  color: var(--fg-2);
  text-decoration: none;
  line-height: 1.35;
  transition: background .13s ease, color .13s ease;
}
.navlist a:hover { background: var(--surface-3); color: var(--fg); }
.navlist a .i {
  width: 17px;
  height: 17px;
  color: var(--muted);
  transition: color .13s ease;
}
.navlist a:hover .i { color: var(--fg-2); }
.navlist a .cnt {
  margin-left: auto;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.navlist a.on {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.navlist a.on .i, .navlist a.on .cnt { color: var(--accent); }

.navnew {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0 0 20px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  box-shadow: var(--shadow-1);
  transition: filter .13s ease, transform .13s ease;
}
.navnew:hover { filter: brightness(1.08); transform: translateY(-1px); }

/* ── 언어 전환 ──────────────────────────────────────────
   로그인 없이도 되어야 한다 — 열람이 공개라서. 세션에만 남는다. */
.langpick {
  display: inline-flex;
  margin: 4px 10px 0;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface-2);
}
.langpick a {
  padding: 3px 11px;
  border-radius: var(--r-pill);
  font-size: 12.5px;
  font-weight: 550;
  color: var(--muted);
  text-decoration: none;
  transition: background .13s ease, color .13s ease;
}
.langpick a:hover { color: var(--fg); }
.langpick a.on {
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-1);
}

.navscrim { display: none; }

/* 좁은 화면 — 사이드바를 드로어로 */
@media (max-width: 1000px) {
  .navtoggle { display: inline-flex; }
  .site-shell { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .sidenav {
    /* 헤더 아래에서 시작한다 — 열어 둔 채로도 ☰ 로 닫을 수 있어야 한다. */
    position: fixed;
    top: var(--header-h); bottom: 0; left: 0;
    z-index: 60;
    width: 272px;
    max-height: none;
    padding: 18px 14px 28px;
    background: var(--surface);
    border-right: 1px solid var(--line);
    box-shadow: var(--shadow-3);
    transform: translateX(-102%);
    transition: transform .22s cubic-bezier(.4, 0, .2, 1);
  }
  body.nav-open .sidenav { transform: none; }
  body.nav-open { overflow: hidden; }
  body.nav-open .navscrim {
    display: block;
    position: fixed;
    inset: var(--header-h) 0 0 0;
    z-index: 55;
    background: rgba(9, 12, 18, .46);
    backdrop-filter: blur(2px);
  }
}

/* 튜토리얼 — 사이드바 맨 위. 메뉴 항목이면서 온보딩 입구라 한 톤 다르게 둔다. */
.navtut {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 10px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--fg-2);
  font-size: 14px;
  font-weight: 550;
  text-decoration: none;
  transition: border-color .13s ease, color .13s ease, background .13s ease;
}
.navtut .i { width: 17px; height: 17px; color: var(--accent); }
.navtut:hover { border-color: var(--accent-line); color: var(--fg); background: var(--accent-soft); }
.navtut.on {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
