/* ==========================================================================
   하네스 엔지니어링 with Claude Code — 강의 사이트 공통 스타일
   ========================================================================== */
@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css");

:root {
  --font-sans: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, "D2Coding", monospace;

  --bg: #f7f7f5;
  --bg-elev: #ffffff;
  --bg-code: #f0f0ee;
  --fg: #1c1c1e;
  --fg-muted: #6b6b70;
  --line: #e3e3e0;
  --accent: #5b5fc7;
  --accent-soft: rgba(91, 95, 199, 0.10);
  --ok: #2e9e6a;
  --ok-soft: rgba(46, 158, 106, 0.12);
  --warn: #d28a17;
  --warn-soft: rgba(210, 138, 23, 0.12);
  --danger: #d6455d;
  --danger-soft: rgba(214, 69, 93, 0.10);
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.05);
  --radius: 12px;
  --sidebar-w: 280px;
  --content-w: 900px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101014;
    --bg-elev: #17171d;
    --bg-code: #1e1e26;
    --fg: #ececf1;
    --fg-muted: #9a9aa6;
    --line: #2a2a33;
    --accent: #8b8ff0;
    --accent-soft: rgba(139, 143, 240, 0.14);
    --ok: #4fc48f;
    --ok-soft: rgba(79, 196, 143, 0.14);
    --warn: #e6a53a;
    --warn-soft: rgba(230, 165, 58, 0.14);
    --danger: #f06a80;
    --danger-soft: rgba(240, 106, 128, 0.14);
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  }
}
:root[data-theme="dark"] {
  --bg: #101014; --bg-elev: #17171d; --bg-code: #1e1e26;
  --fg: #ececf1; --fg-muted: #9a9aa6; --line: #2a2a33;
  --accent: #8b8ff0; --accent-soft: rgba(139, 143, 240, 0.14);
  --ok: #4fc48f; --ok-soft: rgba(79, 196, 143, 0.14);
  --warn: #e6a53a; --warn-soft: rgba(230, 165, 58, 0.14);
  --danger: #f06a80; --danger-soft: rgba(240, 106, 128, 0.14);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; overflow-x: hidden; background: var(--bg); color: var(--fg);
  font-family: var(--font-sans); font-size: 16px; line-height: 1.7;
  -webkit-font-smoothing: antialiased; word-break: keep-all;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; border-radius: 8px; }
h1, h2, h3, h4 { line-height: 1.3; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 2rem; font-weight: 800; }
h2 { font-size: 1.45rem; font-weight: 700; margin-top: 2.6rem; padding-bottom: .4rem; border-bottom: 1px solid var(--line); }
h3 { font-size: 1.15rem; font-weight: 700; margin-top: 1.8rem; }
h4 { font-size: 1rem; font-weight: 700; margin-top: 1.4rem; }
p { margin: .9rem 0; }
ul, ol { padding-left: 1.4rem; }
li { margin: .25rem 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }
blockquote { margin: 1rem 0; padding: .2rem 1rem; border-left: 3px solid var(--accent); color: var(--fg-muted); }
kbd { font-family: var(--font-mono); font-size: .85em; padding: .1em .4em; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--bg-elev); }

/* code */
code { font-family: var(--font-mono); font-size: .875em; background: var(--bg-code); padding: .12em .4em; border-radius: 5px; }
pre { position: relative; background: var(--bg-code); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.1rem; overflow-x: auto; line-height: 1.55; margin: 1rem 0; }
pre code { background: none; padding: 0; font-size: .85rem; }
pre .copy { position: absolute; top: 8px; right: 8px; font: 600 .72rem var(--font-sans); color: var(--fg-muted); background: var(--bg-elev); border: 1px solid var(--line); border-radius: 6px; padding: .2rem .55rem; cursor: pointer; opacity: 0; transition: opacity .15s; }
pre:hover .copy { opacity: 1; }
pre .copy.done { color: var(--ok); }

/* tables */
.table-wrap { overflow-x: auto; margin: 1rem 0; }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th, td { text-align: left; padding: .55rem .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--bg-elev); font-weight: 700; white-space: nowrap; }
tbody tr:hover { background: var(--accent-soft); }

/* layout */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem; height: 56px; padding: 0 1.25rem; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar .brand { font-weight: 800; letter-spacing: -0.01em; color: var(--fg); display: flex; align-items: center; gap: .5rem; }
.topbar .brand small { font-weight: 500; color: var(--fg-muted); font-size: .8rem; }
.topbar .spacer { flex: 1; }
.topbar .btn { font-size: .85rem; padding: .35rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-elev); color: var(--fg); cursor: pointer; }
.topbar .btn:hover { border-color: var(--accent); text-decoration: none; }
.menu-toggle { display: none; }

.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: calc(100vh - 56px); }
.shell > * { min-width: 0; }
.sidebar { position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; padding: 1.25rem 1rem 2rem; border-right: 1px solid var(--line); background: var(--bg); }
.sidebar .chapter { margin-top: 1.1rem; }
.sidebar .chapter:first-child { margin-top: 0; }
.sidebar .chapter-title { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--fg-muted); padding: 0 .5rem .35rem; }
.sidebar a.item { display: flex; align-items: baseline; gap: .5rem; padding: .35rem .5rem; border-radius: 7px; color: var(--fg); font-size: .9rem; line-height: 1.35; }
.sidebar a.item:hover { background: var(--accent-soft); text-decoration: none; }
.sidebar a.item.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.sidebar a.item.planned { color: var(--fg-muted); }
.sidebar a.item .num { font-family: var(--font-mono); font-size: .72rem; color: var(--fg-muted); flex: 0 0 auto; }
.sidebar a.item.planned::after { content: "예정"; font-size: .65rem; margin-left: auto; padding: .05em .4em; border: 1px solid var(--line); border-radius: 999px; color: var(--fg-muted); }

.content { padding: 2.5rem 3rem 5rem; max-width: var(--content-w); width: 100%; min-width: 0; margin: 0 auto; }
.content p, .content li, .content figcaption { overflow-wrap: anywhere; }
.content.wide { max-width: 1200px; }

/* lecture header */
.lec-head { margin-bottom: 2rem; }
.lec-head .eyebrow { font-family: var(--font-mono); font-size: .8rem; color: var(--accent); font-weight: 600; }
.lec-head h1 { margin: .3rem 0 .6rem; }
.lec-head .lead { color: var(--fg-muted); font-size: 1.05rem; margin: 0; }
.meta { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.chip { font-size: .78rem; padding: .2rem .6rem; border-radius: 999px; background: var(--bg-elev); border: 1px solid var(--line); color: var(--fg-muted); }
.chip.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* callouts */
.callout { display: grid; grid-template-columns: auto 1fr; gap: .6rem; padding: .9rem 1rem; border-radius: 10px; margin: 1.2rem 0; border: 1px solid var(--line); background: var(--bg-elev); }
.callout .ico { font-size: 1.1rem; line-height: 1.5; }
.callout .body { min-width: 0; } .callout .body > :first-child { margin-top: 0; } .callout .body > :last-child { margin-bottom: 0; }
.callout.tip { background: var(--ok-soft); border-color: transparent; }
.callout.warn { background: var(--warn-soft); border-color: transparent; }
.callout.danger { background: var(--danger-soft); border-color: transparent; }
.callout.info { background: var(--accent-soft); border-color: transparent; }
.callout .title { font-weight: 700; margin-bottom: .2rem; }

/* steps */
.steps { counter-reset: step; list-style: none; padding: 0; margin: 1.2rem 0; }
.steps > li { counter-increment: step; position: relative; padding: .2rem 0 1.2rem 2.6rem; border-left: 2px solid var(--line); margin-left: 1rem; }
.steps > li:last-child { border-left-color: transparent; }
.steps > li::before { content: counter(step); position: absolute; left: -1.05rem; top: 0; width: 2rem; height: 2rem; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; font-size: .85rem; display: grid; place-items: center; }
.steps > li > strong:first-child { display: block; margin-bottom: .2rem; font-size: 1.02rem; }

/* cards (home) */
.hero { padding: 1rem 0 1.5rem; }
.hero h1 { font-size: 2.4rem; }
.hero .lead { font-size: 1.1rem; color: var(--fg-muted); max-width: 46rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin: 1rem 0; }
.card { display: block; background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; color: var(--fg); box-shadow: var(--shadow); transition: transform .15s, border-color .15s; }
a.card:hover { transform: translateY(-2px); border-color: var(--accent); text-decoration: none; }
.card .num { font-family: var(--font-mono); font-size: .75rem; color: var(--fg-muted); }
.card .title { font-weight: 700; margin: .2rem 0 .3rem; }
.card .desc { font-size: .88rem; color: var(--fg-muted); }
.card.planned { opacity: .62; box-shadow: none; }
.badge { display: inline-block; font-size: .7rem; font-weight: 700; padding: .1em .55em; border-radius: 999px; margin-left: .4rem; vertical-align: middle; }
.badge.ready { background: var(--ok-soft); color: var(--ok); }
.badge.planned { background: var(--bg-code); color: var(--fg-muted); }
.stat { display: flex; gap: 1.5rem; flex-wrap: wrap; margin: 1rem 0 2rem; }
.stat div { background: var(--bg-elev); border: 1px solid var(--line); border-radius: 10px; padding: .7rem 1.1rem; }
.stat b { font-size: 1.5rem; display: block; line-height: 1.2; }
.stat span { font-size: .8rem; color: var(--fg-muted); }

/* compare (2단 비교) */
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1.2rem 0; }
.compare > div { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.compare > div > h4 { margin-top: 0; }
.compare .a { border-top: 3px solid var(--danger); }
.compare .b { border-top: 3px solid var(--ok); }

/* file tree */
.tree { font-family: var(--font-mono); font-size: .83rem; line-height: 1.6; }

/* figure */
figure { margin: 1.4rem 0; }
figure img { border: 1px solid var(--line); box-shadow: var(--shadow); }
figcaption { font-size: .85rem; color: var(--fg-muted); margin-top: .5rem; text-align: center; }

/* details */
details { border: 1px solid var(--line); border-radius: 10px; padding: .6rem 1rem; margin: 1rem 0; background: var(--bg-elev); }
summary { cursor: pointer; font-weight: 700; }

/* pager */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 3.5rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.pager a { display: block; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 10px; color: var(--fg); background: var(--bg-elev); }
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager a small { display: block; color: var(--fg-muted); font-size: .75rem; }
.pager a.next { text-align: right; }

footer.site { padding: 2rem 3rem; border-top: 1px solid var(--line); color: var(--fg-muted); font-size: .82rem; grid-column: 1 / -1; }

/* responsive */
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 56px; width: min(85vw, 320px); transform: translateX(-100%); transition: transform .2s; z-index: 15; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .menu-toggle { display: inline-block; }
  .content { padding: 1.5rem 1.2rem 4rem; }
  .compare { grid-template-columns: 1fr; }
  .topbar .brand small { display: none; }
  .table-wrap table { min-width: 620px; }
  td, th { overflow-wrap: normal; }
  .topbar { gap: .6rem; padding: 0 .8rem; }
  .hero h1 { font-size: 1.8rem; }
  footer.site { padding: 1.5rem 1.2rem; }
}
@media print {
  .topbar, .sidebar, .pager, pre .copy { display: none !important; }
  .shell { display: block; }
  .content { max-width: none; padding: 0; }
}

/* ---- 추가 컴포넌트 (02-01 부터 사용) ---- */
/* 사용자 프롬프트 박스 */
.prompt { display: grid; grid-template-columns: auto 1fr; gap: .6rem; align-items: start; background: var(--bg-elev); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 10px; padding: .8rem 1rem; margin: 1rem 0; font-family: var(--font-mono); font-size: .88rem; white-space: pre-wrap; }
.prompt .who { font-family: var(--font-sans); font-weight: 700; color: var(--accent); font-size: .8rem; padding-top: .15rem; }
/* 파이프라인 흐름도 */
.flow { display: flex; align-items: stretch; gap: .35rem; flex-wrap: nowrap; overflow-x: auto; margin: 1.2rem 0; padding-bottom: .3rem; }
.flow .node { flex: 1 1 0; min-width: 118px; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 10px; padding: .6rem .5rem; text-align: center; }
.flow .node b { display: block; font-family: var(--font-mono); font-size: .78rem; word-break: break-all; }
.flow .node small { display: block; color: var(--fg-muted); font-size: .75rem; margin-top: .2rem; }
.flow .node .skill { display: inline-block; margin-top: .4rem; font-size: .72rem; padding: .1em .5em; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-family: var(--font-mono); }
.flow .node.io { background: var(--bg-code); border-style: dashed; }
.flow .arrow { align-self: center; color: var(--fg-muted); font-size: 1.2rem; flex: 0 0 auto; }
@media (max-width: 700px) { .flow { flex-direction: column; overflow: visible; } .flow .node { min-width: 0; } .flow .arrow { transform: rotate(90deg); text-align: center; } }
/* 스크롤 가능한 긴 코드 */
pre.scroll { max-height: 420px; overflow: auto; }
/* 지표 카드 */
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .7rem; margin: 1rem 0; }
.kv div { background: var(--bg-elev); border: 1px solid var(--line); border-radius: 10px; padding: .6rem .9rem; }
.kv b { display: block; font-size: 1.25rem; line-height: 1.3; }
.kv span { font-size: .78rem; color: var(--fg-muted); }
/* 체크리스트 */
.check { list-style: none; padding: 0; }
.check li { padding-left: 1.6rem; position: relative; }
.check li::before { content: "☐"; position: absolute; left: 0; color: var(--accent); }
/* 인라인 SVG 다이어그램 */
.diagram { margin: 1.2rem 0; overflow-x: auto; }
.diagram svg { width: 100%; max-width: 900px; height: auto; display: block; font-family: var(--font-sans); }
.diagram .box { fill: var(--bg-elev); stroke: var(--line); stroke-width: 1.2; }
.diagram .box.accent { stroke: var(--accent); stroke-width: 1.6; }
.diagram .box.io { fill: var(--bg-code); stroke-dasharray: 4 3; }
.diagram .box.ok { stroke: var(--ok); } .diagram .box.warn { stroke: var(--warn); } .diagram .box.danger { stroke: var(--danger); }
.diagram .t { fill: var(--fg); font-size: 13px; }
.diagram .t.b { font-weight: 700; }
.diagram .t.mono { font-family: var(--font-mono); font-size: 10.5px; }
.diagram .t.muted { fill: var(--fg-muted); font-size: 11.5px; }
.diagram .t.ok { fill: var(--ok); font-weight: 700; } .diagram .t.warn { fill: var(--warn); font-weight: 700; } .diagram .t.danger { fill: var(--danger); font-weight: 700; }
.diagram .ln { stroke: var(--fg-muted); stroke-width: 1.4; fill: none; }
.diagram .ln.ok { stroke: var(--ok); } .diagram .ln.warn { stroke: var(--warn); } .diagram .ln.danger { stroke: var(--danger); }
.diagram marker path { fill: var(--fg-muted); }
.diagram marker.ok path { fill: var(--ok); } .diagram marker.warn path { fill: var(--warn); } .diagram marker.danger path { fill: var(--danger); }
/* 라벨 */
.lbl { display: inline-block; font-size: .72rem; font-weight: 700; padding: .05em .5em; border-radius: 999px; vertical-align: middle; }
.lbl.ok { background: var(--ok-soft); color: var(--ok); } .lbl.warn { background: var(--warn-soft); color: var(--warn); } .lbl.danger { background: var(--danger-soft); color: var(--danger); } .lbl.accent { background: var(--accent-soft); color: var(--accent); }
/* ---- 라이트박스 (그림 클릭 확대) ---- */
figure img, .diagram svg { cursor: zoom-in; }
figure { position: relative; }
figure .zoom-hint { position: absolute; top: 10px; right: 10px; font-size: .72rem; font-weight: 600; color: #fff; background: rgba(0,0,0,.55); padding: .2rem .55rem; border-radius: 999px; pointer-events: none; opacity: 0; transition: opacity .15s; }
figure:hover .zoom-hint { opacity: 1; }
.lb { position: fixed; inset: 0; z-index: 100; background: rgba(8,8,12,.92); display: none; flex-direction: column; }
.lb.open { display: flex; }
.lb .lb-bar { display: flex; align-items: center; gap: .6rem; padding: .5rem .8rem; color: #ddd; font-size: .85rem; flex: 0 0 auto; }
.lb .lb-bar .cap { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb .lb-bar button { background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.25); border-radius: 8px; padding: .3rem .7rem; cursor: pointer; font-size: .85rem; }
.lb .lb-bar button:hover { background: rgba(255,255,255,.2); }
.lb .lb-body { flex: 1; overflow: auto; display: flex; align-items: center; justify-content: center; padding: .5rem; }
.lb .lb-body.zoomed { display: block; padding: 0; }
.lb img { max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-in; border-radius: 4px; box-shadow: 0 10px 40px rgba(0,0,0,.6); }
.lb .lb-body.zoomed img { max-width: none; max-height: none; cursor: zoom-out; border-radius: 0; box-shadow: none; }
.lb svg { width: min(96vw, 1600px); height: auto; background: var(--bg); border-radius: 8px; padding: 1rem; }
.lb .nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.12); color: #fff; border: 0; width: 44px; height: 64px; border-radius: 10px; font-size: 1.6rem; cursor: pointer; }
.lb .nav:hover { background: rgba(255,255,255,.28); }
.lb .nav.prev { left: 10px; } .lb .nav.next { right: 10px; }
.lb .nav[disabled] { opacity: .25; cursor: default; }
@media (max-width: 700px) { .lb .nav { width: 34px; height: 50px; font-size: 1.2rem; } }
/* 라인 번호 코드 블록 */
pre.num code { display: block; }
pre.num .l { display: block; padding-left: 3.4em; text-indent: -3.4em; white-space: pre; }
pre.num .l .n { display: inline-block; width: 2.6em; margin-right: .8em; text-align: right; color: var(--fg-muted); user-select: none; text-indent: 0; }
pre.num .l.hl { background: var(--danger-soft); box-shadow: inset 3px 0 0 var(--danger); }
pre.num .l.hl2 { background: var(--warn-soft); box-shadow: inset 3px 0 0 var(--warn); }
/* 심각도 라벨 */
.sev { display: inline-block; font-size: .72rem; font-weight: 800; padding: .1em .55em; border-radius: 6px; letter-spacing: .02em; }
.sev.c { background: #b3122f; color: #fff; } .sev.h { background: var(--danger-soft); color: var(--danger); } .sev.m { background: var(--warn-soft); color: var(--warn); } .sev.l { background: var(--accent-soft); color: var(--accent); }

/* unified diff 색 구분 ({{DIFF:}} 빌더 출력) */
pre.diff code { display: block; }
pre.diff code > span { display: block; white-space: pre; padding: 0 .4em; margin: 0 -.4em; }
pre.diff .add { background: var(--ok-soft); color: var(--ok); }
pre.diff .del { background: var(--danger-soft); color: var(--danger); }
pre.diff .hunk { color: var(--accent); }
pre.diff .meta { color: var(--fg-muted); font-weight: 700; }
