/* Daheyo Works 강의 자료
   home(www.daheyo.com)의 시각 언어를 잇는다: 읽고 형광펜으로 표시한 문서.
   강의 자료에서는 "막힌 자리"에만 형광펜을 칠한다. 다른 곳에는 노랑을 쓰지 않는다. */

:root {
  color-scheme: light;
  --ink: #14181b;
  --ink-soft: #4a545c;
  --ink-faint: #6b757d;
  --paper: #ffffff;
  --paper-sunk: #f4f6f7;
  --rule: #dfe4e7;
  --deep: #0b5f54;
  --deep-dark: #084840;
  --deep-wash: #e7f2f0;
  --mark: #f2c744;
  --mark-soft: #fdf3d2;
  --alarm: #a8321f;
  --code-bg: #f4f6f7;
  --code-ink: #14181b;

  --sans: 'IBM Plex Sans KR', system-ui, -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --step--1: clamp(0.84rem, 0.81rem + 0.14vw, 0.92rem);
  --step-0: clamp(1rem, 0.96rem + 0.2vw, 1.1rem);
  --step-1: clamp(1.18rem, 1.1rem + 0.4vw, 1.4rem);
  --step-2: clamp(1.45rem, 1.3rem + 0.8vw, 2rem);
  --step-3: clamp(1.9rem, 1.55rem + 1.8vw, 3rem);
  --step-4: clamp(2.3rem, 1.7rem + 3vw, 4.1rem);

  --measure: 40rem;
  --gutter: clamp(1rem, 0.6rem + 2vw, 2.5rem);
  --band: clamp(3.5rem, 2.4rem + 5vw, 7rem);
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --ink: #e6ecea;
  --ink-soft: #aab6b3;
  --ink-faint: #879391;
  --paper: #0e1716;
  --paper-sunk: #152120;
  --rule: #263532;
  --deep: #6cc9b8;
  --deep-dark: #8fd9cb;
  --deep-wash: #16302c;
  --mark: #f2c744;
  --mark-soft: #3a3214;
  --alarm: #f08a76;
  --code-bg: #152120;
  --code-ink: #e6ecea;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --ink: #e6ecea;
    --ink-soft: #aab6b3;
    --ink-faint: #879391;
    --paper: #0e1716;
    --paper-sunk: #152120;
    --rule: #263532;
    --deep: #6cc9b8;
    --deep-dark: #8fd9cb;
    --deep-wash: #16302c;
    --mark: #f2c744;
    --mark-soft: #3a3214;
    --alarm: #f08a76;
    --code-bg: #152120;
    --code-ink: #e6ecea;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 5rem; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.72;
  word-break: keep-all;
  overflow-wrap: break-word;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.02em; font-weight: 600; }
p, ul, ol, table, pre, figure, details, blockquote { margin: 0; }
a { color: var(--deep); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--deep); outline-offset: 3px; border-radius: 2px; }
code, kbd, pre { font-family: var(--mono); font-size: 0.9em; }
:not(pre) > code {
  background: var(--paper-sunk);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.05em 0.35em;
  word-break: break-all;
}
kbd {
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 0.35em;
  font-size: 0.82em;
}
.skip {
  position: absolute; left: -999px; top: 0;
  background: var(--ink); color: var(--paper); padding: 0.5rem 1rem; z-index: 50;
}
.skip:focus { left: 1rem; }

/* 형광펜. 막힌 순간의 문장에만 쓴다 */
.marked {
  background: linear-gradient(transparent 58%, var(--mark) 58%, var(--mark) 92%, transparent 92%);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  padding: 0 0.08em;
}
:root[data-theme='dark'] .marked { background: linear-gradient(transparent 62%, rgba(242, 199, 68, 0.55) 62%, rgba(242, 199, 68, 0.55) 94%, transparent 94%); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .marked { background: linear-gradient(transparent 62%, rgba(242, 199, 68, 0.55) 62%, rgba(242, 199, 68, 0.55) 94%, transparent 94%); }
}

/* ── 머리띠 ─────────────────────────────── */
.masthead {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--rule);
}
.masthead-inner {
  max-width: 76rem; margin: 0 auto;
  padding: 0.7rem var(--gutter);
  display: flex; align-items: center; gap: 1rem;
}
.brand { display: flex; align-items: center; gap: 0.55rem; color: var(--ink); text-decoration: none; font-weight: 600; font-size: var(--step--1); }
.brand img { width: 1.5rem; height: 1.5rem; }
.brand span { color: var(--ink-soft); font-weight: 400; }
.masthead nav { margin-left: auto; display: flex; gap: 0.5rem; align-items: center; }
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font: inherit; font-size: var(--step--1); font-weight: 500;
  color: var(--ink); background: transparent;
  border: 1px solid var(--rule); border-radius: 999px;
  padding: 0.3rem 0.85rem; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-soft); }
.btn-primary { background: var(--deep); border-color: var(--deep); color: #fff; }
.btn-primary:hover { background: var(--deep-dark); border-color: var(--deep-dark); }
:root[data-theme='dark'] .btn-primary { color: #0e1716; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .btn-primary { color: #0e1716; } }
.btn svg { width: 1em; height: 1em; }

/* ── 표지 ──────────────────────────────── */
.cover {
  max-width: 76rem; margin: 0 auto;
  padding: var(--band) var(--gutter) calc(var(--band) * 0.7);
  display: grid; gap: clamp(2rem, 4vw, 4rem);
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  align-items: center;
}
.cover h1 { font-size: var(--step-4); font-weight: 700; letter-spacing: -0.04em; line-height: 1.12; }
.cover h1 small { display: block; font-size: 0.42em; font-weight: 500; letter-spacing: -0.01em; color: var(--ink-soft); margin-bottom: 0.6em; }
.cover .lede { margin-top: 1.5rem; font-size: var(--step-1); line-height: 1.6; max-width: 32rem; color: var(--ink-soft); }
.cover .lede strong { color: var(--ink); font-weight: 600; }
.cover-meta { margin-top: 2rem; display: flex; flex-wrap: wrap; gap: 0.6rem 1.5rem; font-size: var(--step--1); color: var(--ink-soft); }
.cover-meta b { color: var(--ink); font-weight: 600; }
.cover-actions { margin-top: 1.75rem; display: flex; flex-wrap: wrap; gap: 0.6rem; }

/* 코드와 코드 바깥 고리 */
.ring { width: 100%; max-width: 26rem; justify-self: center; }
.ring svg { width: 100%; height: auto; display: block; overflow: visible; }
.ring .seg path { fill: var(--paper-sunk); stroke: var(--rule); stroke-width: 1; transition: fill 160ms ease; }
.ring .seg text { fill: var(--ink); font-family: var(--sans); font-size: 15px; font-weight: 600; text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.ring .seg .num { font-size: 11px; font-weight: 500; fill: var(--ink-soft); }
.ring .seg:hover path, .ring .seg:focus-visible path { fill: var(--mark); }
:root[data-theme='dark'] .ring .seg:hover text, :root[data-theme='dark'] .ring .seg:focus-visible text { fill: #14181b; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .ring .seg:hover text, :root:not([data-theme='light']) .ring .seg:focus-visible text { fill: #14181b; }
}
.ring .seg:focus-visible { outline: none; }
.ring .core circle { fill: var(--deep); }
.ring .core text { fill: #fff; font-family: var(--sans); text-anchor: middle; dominant-baseline: middle; }
:root[data-theme='dark'] .ring .core text { fill: #0e1716; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .ring .core text { fill: #0e1716; } }
.ring .core .big { font-size: 22px; font-weight: 700; }
.ring .core .small { font-size: 11.5px; font-weight: 500; }
.ring figcaption { margin-top: 1rem; text-align: center; font-size: var(--step--1); color: var(--ink-soft); }

/* ── 본문 배치 ─────────────────────────── */
.layout {
  max-width: 76rem; margin: 0 auto;
  padding: 0 var(--gutter) var(--band);
  display: grid; gap: clamp(2rem, 4vw, 4.5rem);
  grid-template-columns: 13.5rem minmax(0, 1fr);
  align-items: start;
}
.toc { position: sticky; top: 4.75rem; font-size: var(--step--1); }
.toc p { color: var(--ink-soft); margin-bottom: 0.6rem; font-weight: 500; }
.toc ol { list-style: none; padding: 0; border-left: 1px solid var(--rule); }
.toc li a {
  display: grid; grid-template-columns: 1.6rem 1fr; gap: 0.2rem;
  padding: 0.38rem 0 0.38rem 0.85rem; margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--ink-soft); text-decoration: none; line-height: 1.4;
}
.toc li a:hover { color: var(--ink); }
.toc li a[aria-current='true'] { color: var(--ink); border-left-color: var(--deep); font-weight: 600; }
.toc .n { color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.toc li.gap { margin-top: 0.7rem; }

/* 자료 페이지 본문(#content)에만 건다. 슬라이드도 main > section 구조라 범위를 좁혀 둔다 */
#content > section + section {
  border-top: 1px solid var(--rule);
  margin-top: calc(var(--band) * 0.7);
  padding-top: calc(var(--band) * 0.7);
}

.prose { max-width: var(--measure); }
.prose > * + * { margin-top: 1rem; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li + li { margin-top: 0.35rem; }

/* 파트 머리 */
.part-head { max-width: 46rem; }
.part-head .label { font-size: var(--step--1); font-weight: 600; color: var(--deep); }
.part-head h2 { font-size: var(--step-3); font-weight: 700; letter-spacing: -0.035em; margin-top: 0.2rem; }
.stuck {
  margin-top: 1.6rem;
  font-size: var(--step-2); font-weight: 600; line-height: 1.45; letter-spacing: -0.025em;
}
.stuck::before { content: '막히는 순간'; display: block; font-size: var(--step--1); font-weight: 500; letter-spacing: 0; color: var(--alarm); margin-bottom: 0.5rem; }
.stuck-note { margin-top: 0.9rem; color: var(--ink-soft); max-width: var(--measure); }
.verdict {
  margin-top: 1.75rem; max-width: var(--measure);
  padding: 1rem 1.2rem;
  border-left: 3px solid var(--deep);
  background: var(--deep-wash);
  font-weight: 500;
}
.verdict b { font-weight: 700; }

.block { margin-top: 2.75rem; }
.block > h3 { font-size: var(--step-1); font-weight: 700; margin-bottom: 1rem; }
.block > h3 + .prose { margin-top: 0; }

/* 따라 하기: 실제 순서가 있는 목록만 번호를 단다 */
.steps { list-style: none; padding: 0; counter-reset: step; max-width: 46rem; }
.steps > li { counter-increment: step; position: relative; padding-left: 2.6rem; }
.steps > li + li { margin-top: 1.5rem; }
.steps > li::before {
  content: counter(step);
  position: absolute; left: 0; top: 0.05rem;
  width: 1.75rem; height: 1.75rem; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 0.85rem; font-weight: 700;
  color: var(--deep); border: 1.5px solid var(--deep);
}
.steps > li > * + * { margin-top: 0.7rem; }
.steps .why { color: var(--ink-soft); font-size: var(--step--1); }

/* 코드 블록 */
.code {
  position: relative; max-width: 46rem;
  background: var(--code-bg); color: var(--code-ink);
  border: 1px solid var(--rule); border-radius: 8px;
}
.code .cap {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.35rem 0.5rem 0.35rem 0.9rem;
  border-bottom: 1px solid var(--rule);
  font-family: var(--mono); font-size: 0.78rem; color: var(--ink-soft);
}
.code pre { overflow-x: auto; padding: 0.9rem 1rem; line-height: 1.6; font-size: 0.86rem; tab-size: 2; }
.code .c { color: var(--ink-faint); }
.copy {
  font: inherit; font-family: var(--sans); font-size: 0.78rem; font-weight: 500;
  color: var(--ink-soft); background: var(--paper);
  border: 1px solid var(--rule); border-radius: 6px;
  padding: 0.15rem 0.6rem; cursor: pointer;
}
.copy:hover { color: var(--ink); border-color: var(--ink-soft); }
.copy[data-done] { color: var(--deep); border-color: var(--deep); }

/* AI에게 맡길 말 */
.prompt {
  max-width: 46rem;
  border: 1.5px solid var(--deep); border-radius: 10px;
  overflow: hidden;
}
.prompt .cap {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.55rem 0.6rem 0.55rem 1rem;
  background: var(--deep); color: #fff; font-size: var(--step--1); font-weight: 600;
}
:root[data-theme='dark'] .prompt .cap { color: #0e1716; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .prompt .cap { color: #0e1716; } }
.prompt .cap .copy { background: transparent; color: inherit; border-color: currentColor; opacity: 0.9; }
.prompt .cap .copy[data-done] { opacity: 1; }
.prompt p { padding: 1rem 1.1rem; line-height: 1.75; }

/* 막히면 */
.snags { max-width: 46rem; border-top: 1px solid var(--rule); }
.snags details { border-bottom: 1px solid var(--rule); }
.snags summary {
  cursor: pointer; list-style: none;
  padding: 0.85rem 2rem 0.85rem 0; position: relative;
  font-weight: 600; line-height: 1.5;
}
.snags summary::-webkit-details-marker { display: none; }
.snags summary::after {
  content: ''; position: absolute; right: 0.3rem; top: 1.25rem;
  width: 0.55rem; height: 0.55rem;
  border-right: 2px solid var(--ink-soft); border-bottom: 2px solid var(--ink-soft);
  transform: rotate(45deg); transition: transform 160ms ease;
}
.snags details[open] summary::after { transform: rotate(-135deg); top: 1.5rem; }
.snags .body { padding: 0 0 1.1rem; color: var(--ink-soft); max-width: var(--measure); }
.snags .body > * + * { margin-top: 0.6rem; }
.snags .body strong { color: var(--ink); }

/* 흐름 그림 */
.flow {
  max-width: 50rem;
  display: grid; gap: 0.75rem;
  padding: 1.25rem; border: 1px solid var(--rule); border-radius: 10px;
}
.flow + .flow { margin-top: 1rem; }
.flow-title { font-size: var(--step--1); font-weight: 700; }
.flow-title.bad { color: var(--alarm); }
.flow-title.good { color: var(--deep); }
.flow-row { display: flex; align-items: stretch; gap: 0; flex-wrap: nowrap; }
.node {
  flex: 1 1 0; min-width: 0;
  border: 1.5px solid var(--ink-soft); border-radius: 8px;
  padding: 0.65rem 0.75rem; background: var(--paper);
  font-size: var(--step--1); line-height: 1.45;
}
.node b { display: block; font-size: var(--step-0); }
.node.hot { border-color: var(--alarm); }
.node.safe { border-color: var(--deep); background: var(--deep-wash); }
.edge {
  flex: 0 0 auto; display: grid; place-items: center; min-width: 4.5rem;
  padding: 0 0.3rem; text-align: center;
  font-size: 0.78rem; color: var(--ink-soft); line-height: 1.3;
  position: relative;
}
.edge::after { content: '▶'; display: block; font-size: 0.75rem; color: var(--ink-soft); }
.edge.no::after { color: var(--alarm); }
.flow-note { font-size: var(--step--1); color: var(--ink-soft); }
.flow-note.bad { color: var(--alarm); font-weight: 500; }
.branch { display: grid; gap: 0.6rem; flex: 2 1 0; min-width: 0; }
.branch .flow-row { gap: 0; }

/* 표 */
.table-wrap { max-width: 50rem; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: var(--step--1); line-height: 1.55; }
th, td { text-align: left; vertical-align: top; padding: 0.7rem 0.8rem 0.7rem 0; border-bottom: 1px solid var(--rule); }
th { font-weight: 700; border-bottom-color: var(--ink-soft); white-space: nowrap; }
td:first-child { font-weight: 600; white-space: nowrap; }

/* 사례 */
.cases { list-style: none; padding: 0; max-width: 46rem; }
.cases li { padding: 0.75rem 0; border-bottom: 1px dashed var(--rule); }
.cases li:first-child { border-top: 1px dashed var(--rule); }
.cases a { font-weight: 600; }
.cases p { color: var(--ink-soft); font-size: var(--step--1); margin-top: 0.15rem; }

.aside-note { max-width: var(--measure); font-size: var(--step--1); color: var(--ink-soft); }

/* 체크리스트 */
.checklist { max-width: 46rem; }
.check-progress { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; font-size: var(--step--1); color: var(--ink-soft); }
.check-progress .bar { flex: 1; height: 6px; background: var(--paper-sunk); border-radius: 99px; overflow: hidden; border: 1px solid var(--rule); }
.check-progress .bar i { display: block; height: 100%; width: 0; background: var(--deep); transition: width 200ms ease; }
.check-group + .check-group { margin-top: 1.6rem; }
.check-group h3 { font-size: var(--step-0); font-weight: 700; margin-bottom: 0.4rem; }
.check-group ul { list-style: none; padding: 0; }
.check-group li label {
  display: grid; grid-template-columns: 1.4rem 1fr; gap: 0.6rem; align-items: start;
  padding: 0.5rem 0; cursor: pointer; line-height: 1.55;
}
.check-group input { width: 1.15rem; height: 1.15rem; margin: 0.22rem 0 0; accent-color: var(--deep); }
.check-group input:checked + span { color: var(--ink-faint); text-decoration: line-through; text-decoration-color: var(--ink-faint); }

/* 자주 묻는 질문 */
.faq { max-width: 46rem; }

/* 꼬리 */
.colophon { border-top: 1px solid var(--rule); background: var(--paper-sunk); }
.colophon-inner {
  max-width: 76rem; margin: 0 auto; padding: 2.5rem var(--gutter) 3rem;
  display: grid; gap: 2rem; grid-template-columns: minmax(0, 1fr) auto;
  font-size: var(--step--1); color: var(--ink-soft);
}
.colophon-inner p + p { margin-top: 0.5rem; }
.colophon .qr { width: 7.5rem; background: #fff; padding: 0.4rem; border-radius: 6px; border: 1px solid var(--rule); }
.colophon .qr img { width: 100%; display: block; }

/* 좁은 화면 */
@media (max-width: 900px) {
  /* 1fr만 쓰면 긴 코드 줄이 칸을 밀어 화면 밖으로 나간다. 최소 폭을 0으로 둔다 */
  .cover { grid-template-columns: minmax(0, 1fr); padding-top: 2.5rem; }
  .ring { max-width: 16rem; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .toc { position: static; }
  .toc ol { display: flex; gap: 0.4rem; overflow-x: auto; border-left: 0; padding-bottom: 0.4rem; }
  .toc li.gap { margin-top: 0; }
  .toc li a { display: inline-flex; gap: 0.3rem; border: 1px solid var(--rule); border-radius: 999px; padding: 0.3rem 0.8rem; white-space: nowrap; margin: 0; }
  .toc li a[aria-current='true'] { border-color: var(--deep); }
  .toc .n { min-width: 0; }
  .masthead .label-long { display: none; }
}
@media (max-width: 640px) {
  .flow-row { flex-direction: column; }
  .edge { min-width: 0; padding: 0.25rem 0; }
  .edge::after { content: '▼'; }
  .branch { flex: 1 1 auto; }
  .colophon-inner { grid-template-columns: 1fr; }
  .brand span { display: none; }
  td:first-child { white-space: normal; }
}

@media print {
  .masthead, .toc, .copy, .cover-actions, .ring, .colophon .qr { display: none !important; }
  .layout { display: block; }
  .snags details { break-inside: avoid; }
  .snags details > .body { display: block; }
  a { color: inherit; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
