/* ============================================================
   AI데이터센터 시스템 아키텍처 — 강의 사이트 디자인 시스템
   ============================================================ */

:root {
  /* 종이처럼 읽히는 밝은 바탕 + 차가운 회청색 텍스트 */
  --bg:        #f7f8fa;
  --bg-sunk:   #eceef2;
  --surface:   #ffffff;
  --surface-2: #f2f4f7;
  --border:    #dde1e8;
  --border-str:#c3cad6;

  --text:      #1a1f2b;
  --text-2:    #4a5468;
  --text-3:    #77819a;

  /* 강조색: 계산(청록) / 메모리(호박) / 네트워크(보라) / 전력(주홍) */
  --accent:      #0f6fd6;
  --accent-soft: #e4efFB;
  --compute:     #0e7c86;
  --memory:      #b26b00;
  --network:     #6b4fc9;
  --power:       #c2410c;

  --ok:   #0e7c5a;
  --warn: #b26b00;

  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", "D2Coding", Menlo, Consolas, monospace;
  --sans: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
          "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;

  --r:   10px;
  --r-lg:16px;
  --shadow:   0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --shadow-lg:0 8px 24px rgba(16,24,40,.10), 0 2px 6px rgba(16,24,40,.06);

  --sidebar: 274px;
  --measure: 74ch;
}

html[data-theme="dark"] {
  --bg:        #0e1116;
  --bg-sunk:   #080a0e;
  --surface:   #161b22;
  --surface-2: #1c222c;
  --border:    #272e3a;
  --border-str:#3a4453;

  --text:      #e6e9ef;
  --text-2:    #a8b2c4;
  --text-3:    #79839a;

  --accent:      #58a6ff;
  --accent-soft: #12243c;
  --compute:     #3fbfc9;
  --memory:      #e0a33a;
  --network:     #a78bfa;
  --power:       #fb923c;

  --ok:   #3fb98a;
  --warn: #e0a33a;

  --shadow:    0 1px 2px rgba(0,0,0,.4);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 88px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;      /* 한글 단어 중간에서 안 끊기게 */
  overflow-wrap: anywhere;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------------------------------------------------- 상단 바 */

.topbar {
  position: sticky; top: 0; z-index: 50;
  height: 60px;
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .brand {
  font-weight: 700; font-size: 15px; letter-spacing: -.01em;
  color: var(--text); display: flex; align-items: center; gap: 9px;
  white-space: nowrap;
}
.topbar .brand .mark {
  width: 22px; height: 22px; border-radius: 6px; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--network));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
}
.topbar .spacer { flex: 1; }

.iconbtn {
  height: 34px; min-width: 34px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text-2);
  font: inherit; font-size: 13px; cursor: pointer;
}
.iconbtn:hover { border-color: var(--border-str); color: var(--text); }

#navtoggle { display: none; }

/* ---------------------------------------------------- 레이아웃 */

.shell { display: flex; align-items: flex-start; }

.sidebar {
  position: sticky; top: 60px;
  width: var(--sidebar); flex: none;
  height: calc(100vh - 60px);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 20px 12px 60px 18px;
  border-right: 1px solid var(--border);
  background: var(--bg);
}
.sidebar::-webkit-scrollbar { width: 9px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-str); border-radius: 9px;
  border: 3px solid var(--bg); }

.nav-mod {
  margin: 20px 0 7px; padding-left: 8px;
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-3);
}
.nav-mod:first-child { margin-top: 2px; }

.sidebar a.nav-item {
  display: grid; grid-template-columns: 26px 1fr; gap: 8px; align-items: baseline;
  padding: 6px 9px; border-radius: 7px;
  color: var(--text-2); font-size: 13.5px; line-height: 1.45;
}
.sidebar a.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidebar a.nav-item .wk {
  font: 600 11px/1.6 var(--mono); color: var(--text-3);
  background: var(--surface-2); border-radius: 4px; text-align: center;
}
.sidebar a.nav-item[aria-current="page"] {
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.sidebar a.nav-item[aria-current="page"] .wk { background: var(--accent); color: #fff; }
.sidebar a.nav-item.stub { opacity: .55; }
.sidebar a.nav-item.stub .wk::after { content: ""; }

.main { flex: 1; min-width: 0; padding: 40px 40px 120px; }
.wrap { max-width: 960px; margin: 0 auto; }

/* ---------------------------------------------------- 타이포 */

h1, h2, h3, h4 { line-height: 1.35; letter-spacing: -.02em; color: var(--text); }
h1 { font-size: 34px; margin: 0 0 10px; font-weight: 750; }
h2 {
  font-size: 22px; font-weight: 700;
  margin: 56px 0 16px; padding-top: 20px;
  border-top: 1px solid var(--border);
}
h2:first-of-type { border-top: 0; padding-top: 0; margin-top: 40px; }
h3 { font-size: 17px; font-weight: 680; margin: 32px 0 10px; }
p  { margin: 0 0 16px; max-width: var(--measure); color: var(--text); }
ul, ol { margin: 0 0 16px; padding-left: 22px; max-width: var(--measure); }
li { margin: 5px 0; }
li::marker { color: var(--text-3); }
strong { font-weight: 660; }

code {
  font-family: var(--mono); font-size: .875em;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 5px; padding: .1em .38em;
}
pre {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 14px 16px; overflow-x: auto;
  font-family: var(--mono); font-size: 13px; line-height: 1.65;
  box-shadow: var(--shadow);
}
pre code { background: none; border: 0; padding: 0; font-size: inherit; }

/* ---------------------------------------------------- 주차 헤더 */

.wk-head { margin-bottom: 34px; }
.crumbs {
  font-size: 12.5px; color: var(--text-3);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.crumbs .sep { opacity: .5; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 650; letter-spacing: .01em;
  border: 1px solid var(--border-str); color: var(--text-2);
  background: var(--surface);
}
.pill.a { border-color: color-mix(in srgb, var(--compute) 45%, transparent); color: var(--compute); }
.pill.b { border-color: color-mix(in srgb, var(--memory) 45%, transparent);  color: var(--memory); }
.pill.c { border-color: color-mix(in srgb, var(--network) 45%, transparent); color: var(--network); }
.pill.d { border-color: color-mix(in srgb, var(--power) 45%, transparent);   color: var(--power); }

.lede { font-size: 18px; line-height: 1.7; color: var(--text-2); max-width: var(--measure); }

/* 학습목표 박스 */
.goals {
  margin: 26px 0 0; padding: 18px 22px;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--r); box-shadow: var(--shadow);
}
.goals h4 { margin: 0 0 8px; font-size: 12px; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-3); }
.goals ol { margin: 0; padding-left: 20px; }
.goals li { font-size: 14.5px; color: var(--text-2); }

/* ---------------------------------------------------- 콜아웃 */

.callout {
  margin: 24px 0; padding: 16px 18px 16px 20px;
  border-radius: var(--r); border: 1px solid var(--border);
  border-left: 3px solid var(--text-3);
  background: var(--surface); box-shadow: var(--shadow);
  max-width: var(--measure);
}
.callout > .t {
  font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 6px;
}
.callout p:last-child, .callout ul:last-child, .callout ol:last-child { margin-bottom: 0; }
.callout.key   { border-left-color: var(--accent);  }
.callout.key   > .t { color: var(--accent); }
.callout.warn  { border-left-color: var(--warn); background: color-mix(in srgb, var(--warn) 6%, var(--surface)); }
.callout.warn  > .t { color: var(--warn); }
.callout.lab   { border-left-color: var(--compute); background: color-mix(in srgb, var(--compute) 6%, var(--surface)); }
.callout.lab   > .t { color: var(--compute); }
.callout.disc  { border-left-color: var(--network); background: color-mix(in srgb, var(--network) 6%, var(--surface)); }
.callout.disc  > .t { color: var(--network); }

/* ---------------------------------------------------- 그림 */

figure {
  margin: 30px 0; padding: 0;
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); overflow: hidden; box-shadow: var(--shadow);
}
figure .imgbox {
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); padding: 14px;
  border-bottom: 1px solid var(--border);
}
figure img { display: block; max-width: 100%; height: auto; border-radius: 6px; cursor: zoom-in; }
/* 세로로 아주 긴 그림(다이샷 등)이 페이지를 잡아먹지 않게. 클릭하면 원본 크기로 열린다 */
figure .imgbox img { max-height: 520px; object-fit: contain; }
figure.plain .imgbox { background: var(--surface); }
figcaption { padding: 14px 18px 16px; font-size: 14.5px; line-height: 1.72; color: var(--text-2); }
figcaption p { margin: 0 0 9px; max-width: none; font-size: inherit; line-height: inherit;
  color: var(--text-2); }
figcaption p:last-of-type { margin-bottom: 0; }
figcaption .cap-t { display: block; font-weight: 660; color: var(--text); margin-bottom: 5px; }
figcaption ul { margin: 8px 0 0; padding-left: 20px; max-width: none; font-size: 14px; }
figcaption li { margin: 3px 0; }
figcaption .src {
  display: block; margin-top: 7px; font-size: 11.5px; color: var(--text-3);
}
figcaption .src a { color: var(--text-3); text-decoration: underline;
  text-decoration-color: var(--border-str); text-underline-offset: 2px; }
figcaption .src a:hover { color: var(--accent); }
figcaption .lic {
  display: inline-block; margin-left: 6px; padding: 0 6px;
  border: 1px solid var(--border-str); border-radius: 4px;
  font: 600 10px/1.7 var(--mono); color: var(--text-3);
}
figcaption .lic.free { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }

/* SVG 자작 도해 — 본문보다 넓게 빼서 글씨가 커 보이게 한다 */
figure.diagram { background: var(--surface); }
figure.diagram .imgbox { background: var(--surface); padding: 20px 16px; }
figure.diagram svg { width: 100%; height: auto; display: block; }
@media (min-width: 1400px) {
  figure.diagram { width: calc(100% + 150px); margin-left: -75px; }
}
@media (min-width: 1700px) {
  figure.diagram { width: calc(100% + 260px); margin-left: -130px; }
}

.figrow { display: grid; gap: 18px; grid-template-columns: 1fr 1fr; margin: 30px 0; }
.figrow.c3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1100px) { .figrow.c3 { grid-template-columns: repeat(2, 1fr); } }
.figrow figure { margin: 0; display: flex; flex-direction: column; }
/* 세로 사진과 가로 사진이 나란히 올 때 높이를 맞춰 준다 */
.figrow .imgbox { flex: 1; }
.figrow img { max-height: 300px; object-fit: contain; }
.figrow.c3 img { max-height: 210px; }
@media (max-width: 760px) { .figrow { grid-template-columns: 1fr; } }

/* 라이트박스 */
#lb {
  position: fixed; inset: 0; z-index: 200; display: none;
  align-items: center; justify-content: center;
  background: rgba(8,10,14,.88); padding: 32px; cursor: zoom-out;
}
#lb.on { display: flex; }
#lb img { max-width: 100%; max-height: 100%; border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6); }

/* ---------------------------------------------------- 표 */

.tablewrap { overflow-x: auto; margin: 26px 0; border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border);
  vertical-align: top; }
th { background: var(--surface-2); font-weight: 660; font-size: 12.5px;
  letter-spacing: .01em; color: var(--text-2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--accent) 4%, transparent); }
td.num, th.num { text-align: right; font-family: var(--mono); font-size: 13px;
  font-variant-numeric: tabular-nums; white-space: nowrap; }
td .u { color: var(--text-3); font-size: .85em; }

/* ---------------------------------------------------- 카드 / 인덱스 */

.cards { display: grid; gap: 16px; margin: 26px 0; }
.cards.c2 { grid-template-columns: repeat(2, 1fr); }
.cards.c3 { grid-template-columns: repeat(3, 1fr); }
.cards.c4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 980px) { .cards.c3, .cards.c4 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 640px) { .cards { grid-template-columns: 1fr !important; } }

.card {
  display: block; padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow);
  color: var(--text); transition: border-color .14s, transform .14s, box-shadow .14s;
}
a.card:hover { text-decoration: none; border-color: var(--border-str);
  transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.card .k { font: 600 11px/1.6 var(--mono); color: var(--text-3);
  letter-spacing: .04em; text-transform: uppercase; }
.card h3 { margin: 4px 0 6px; font-size: 15.5px; }
.card p { margin: 0; font-size: 13.5px; color: var(--text-2); line-height: 1.6; }
.card .q { margin-top: 10px; font-size: 12.5px; color: var(--text-3); font-style: italic; }

.mod-a { border-top: 3px solid var(--compute); }
.mod-b { border-top: 3px solid var(--memory); }
.mod-c { border-top: 3px solid var(--network); }
.mod-d { border-top: 3px solid var(--power); }

/* 주차 그리드 */
.weeks { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px,1fr)); gap: 12px; }
a.wkcard {
  display: block; padding: 13px 15px; border-radius: var(--r);
  border: 1px solid var(--border); background: var(--surface);
  box-shadow: var(--shadow); color: var(--text);
}
a.wkcard:hover { text-decoration: none; border-color: var(--border-str); transform: translateY(-2px);
  box-shadow: var(--shadow-lg); }
a.wkcard.stub { opacity: .62; }
a.wkcard .n { font: 700 11px/1.6 var(--mono); color: var(--text-3); }
a.wkcard .ttl { font-size: 14px; font-weight: 620; line-height: 1.45; margin-top: 2px; }

/* ---------------------------------------------------- 하단 이동 */

.pager { display: flex; gap: 14px; margin-top: 64px; padding-top: 22px;
  border-top: 1px solid var(--border); }
.pager a {
  flex: 1; padding: 14px 16px; border: 1px solid var(--border);
  border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow);
  color: var(--text);
}
.pager a:hover { text-decoration: none; border-color: var(--border-str); }
.pager .lbl { font-size: 11.5px; color: var(--text-3); display: block; margin-bottom: 2px; }
.pager .t { font-size: 14px; font-weight: 620; }
.pager a.next { text-align: right; }

/* 목차(오른쪽) */
.toc {
  position: sticky; top: 84px; align-self: flex-start;
  width: 208px; flex: none; margin-left: 30px;
  font-size: 13px; max-height: calc(100vh - 120px); overflow-y: auto;
  padding-bottom: 30px;
}
.toc .t { font-size: 11px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-3); margin-bottom: 8px; }
.toc a { display: block; padding: 4px 10px; color: var(--text-2);
  border-left: 2px solid var(--border); line-height: 1.5; }
.toc a:hover { color: var(--text); text-decoration: none; border-left-color: var(--border-str); }
.toc a.on { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
@media (max-width: 1280px) { .toc { display: none; } }

.cols { display: flex; align-items: flex-start; }

/* ---------------------------------------------------- 기타 */

.meta-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; }

.note { font-size: 13px; color: var(--text-3); max-width: var(--measure); }

hr { border: 0; border-top: 1px solid var(--border); margin: 40px 0; }

.kbd { font: 600 11.5px/1.7 var(--mono); border: 1px solid var(--border-str);
  border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; background: var(--surface); }

/* 좁은 화면 */
@media (max-width: 900px) {
  #navtoggle { display: inline-flex; }
  .sidebar {
    position: fixed; left: 0; top: 60px; z-index: 60;
    transform: translateX(-100%); transition: transform .18s ease;
    box-shadow: var(--shadow-lg); background: var(--bg);
  }
  body.nav-open .sidebar { transform: none; }
  .main { padding: 28px 20px 100px; }
  h1 { font-size: 27px; }
}

@media print {
  .topbar, .sidebar, .toc, .pager { display: none !important; }
  .main { padding: 0; }
  figure, .card, pre, .tablewrap { break-inside: avoid; box-shadow: none; }
  a { color: inherit; }
}

/* ── 공개판에서 제조사 인용 그림 자리에 들어가는 링크 카드 ── */
figure.cited .citedbox {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; min-height: 150px; padding: 30px 22px; text-align: center;
  background: repeating-linear-gradient(135deg,
    var(--card) 0 11px, var(--bg) 11px 22px);
  border-bottom: 1px solid var(--border);
}
figure.cited .citedmark {
  font-size: 11.5px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 3px 11px;
  background: var(--card);
}
figure.cited .citedbox a { font-size: 14.5px; font-weight: 600; }
.mod-e { border-top: 3px solid var(--accent); }
.pill.e, .k .e { color: var(--accent); }
.cards.c5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 1100px) { .cards.c5 { grid-template-columns: repeat(2, 1fr); } }
