/* ============================================================
   Tanzania YouTube Production Bible — style.css
   숭블리 · 탄자니아 유튜브 제작 바이블 공통 스타일
   모바일 우선 · 반응형 · 다크모드 · 인쇄(PDF) 지원
   ============================================================ */

@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css");

/* ---------- 1. 디자인 토큰 ---------- */
:root {
  --font-sans: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    "Apple SD Gothic Neo", "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;

  --bg: #fafafa;
  --bg-elev: #ffffff;
  --bg-subtle: #f4f4f5;
  --bg-inset: #eeeeef;
  --text: #18181b;
  --text-2: #52525b;
  --text-3: #a1a1aa;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;

  --accent: #e8590c;          /* 사바나 선셋 오렌지 */
  --accent-soft: #fff0e6;
  --accent-text: #c2410c;
  --green: #16a34a;
  --green-soft: #ecfdf3;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --purple: #7c3aed;
  --purple-soft: #f5f3ff;
  --yellow-soft: #fefce8;
  --yellow-text: #a16207;
  --red-soft: #fef2f2;
  --red-text: #b91c1c;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.12);
  --header-h: 56px;
  --maxw: 860px;
}

html[data-theme="dark"] {
  --bg: #101012;
  --bg-elev: #18181b;
  --bg-subtle: #1f1f23;
  --bg-inset: #26262b;
  --text: #f4f4f5;
  --text-2: #a1a1aa;
  --text-3: #6b6b74;
  --border: #27272a;
  --border-strong: #3f3f46;

  --accent: #ff7a2f;
  --accent-soft: #2b1a10;
  --accent-text: #ffa066;
  --green: #4ade80;
  --green-soft: #10231a;
  --blue: #60a5fa;
  --blue-soft: #121c2e;
  --purple: #a78bfa;
  --purple-soft: #1d1730;
  --yellow-soft: #23200f;
  --yellow-text: #facc15;
  --red-soft: #2a1414;
  --red-text: #f87171;

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

/* ---------- 2. 베이스 ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}
img { max-width: 100%; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.3; letter-spacing: -0.02em; margin: 0 0 .5em; }
p { margin: 0 0 1em; }
::selection { background: var(--accent); color: #fff; }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 20px 80px; }

/* ---------- 3. 상단 고정 헤더 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  display: flex; align-items: center; gap: 8px;
  padding: 0 14px;
  background: color-mix(in srgb, var(--bg-elev) 85%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .brand {
  font-weight: 800; font-size: 15px; color: var(--text);
  display: flex; align-items: center; gap: 8px; text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
}
.topbar .brand .logo {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, var(--accent), #f5a623);
  display: grid; place-items: center; color: #fff; font-size: 13px;
}
.topbar .actions { display: flex; gap: 6px; flex: none; }
.iconbtn {
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-elev);
  color: var(--text-2); font-size: 16px; cursor: pointer;
  display: grid; place-items: center;
  transition: background .15s, color .15s;
}
.iconbtn:hover { background: var(--bg-subtle); color: var(--text); }

/* 상단 진행률 바 */
.progressbar {
  position: sticky; top: var(--header-h); z-index: 99;
  height: 3px; background: var(--bg-subtle);
}
.progressbar .fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), #f5a623);
  transition: width .3s ease;
}

/* ---------- 4. 챕터 표지(히어로) ---------- */
.hero {
  margin: 24px 0 32px;
  padding: 34px 28px;
  border-radius: var(--radius-lg);
  background: linear-gradient(140deg, #1c1917 0%, #44403c 55%, #7c2d12 100%);
  color: #fafaf9;
  position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(600px 200px at 90% -20%, rgba(245,166,35,.35), transparent),
    radial-gradient(400px 160px at -10% 110%, rgba(232,89,12,.3), transparent);
  pointer-events: none;
}
.hero .eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: #fdba74; margin-bottom: 14px;
}
.hero h1 { font-size: clamp(26px, 6vw, 40px); font-weight: 800; margin-bottom: 10px; }
.hero .subtitle { color: #d6d3d1; font-size: 15.5px; max-width: 560px; margin-bottom: 0; }
.hero .meta {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px;
  position: relative; z-index: 1;
}
.hero .meta span {
  font-size: 12.5px; font-weight: 600;
  padding: 5px 11px; border-radius: 999px;
  background: rgba(255,255,255,.12); backdrop-filter: blur(4px);
}

/* ---------- 5. 섹션 카드 ---------- */
.section {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.section > h2 {
  display: flex; align-items: center; gap: 10px;
  font-size: 19px; font-weight: 800;
  padding-bottom: 14px; margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.section > h2 .num {
  flex: none; width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent-text);
  font-size: 13px; font-weight: 800;
  display: grid; place-items: center;
}
.section h3 { font-size: 15.5px; font-weight: 700; margin: 20px 0 10px; }
.section h3:first-of-type { margin-top: 0; }

/* ---------- 6. 공용 컴포넌트 ---------- */
.callout {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border-radius: var(--radius);
  background: var(--bg-subtle); border: 1px solid var(--border);
  font-size: 14.5px; margin: 12px 0;
}
.callout .ico { flex: none; font-size: 18px; line-height: 1.4; }
.callout.accent { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.callout.warn { background: var(--yellow-soft); border-color: transparent; color: var(--yellow-text); }
.callout.danger { background: var(--red-soft); border-color: transparent; color: var(--red-text); }
.callout.ok { background: var(--green-soft); border-color: transparent; color: var(--green); }

.tag {
  display: inline-flex; align-items: center;
  font-size: 12px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px;
  background: var(--bg-inset); color: var(--text-2);
}
.tag.orange { background: var(--accent-soft); color: var(--accent-text); }
.tag.blue { background: var(--blue-soft); color: var(--blue); }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.purple { background: var(--purple-soft); color: var(--purple); }

/* 표 */
.tbl-wrap { overflow-x: auto; margin: 12px 0; border-radius: var(--radius); border: 1px solid var(--border); }
table { border-collapse: collapse; width: 100%; font-size: 14px; background: var(--bg-elev); }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th {
  background: var(--bg-subtle); font-size: 12.5px; font-weight: 700;
  color: var(--text-2); white-space: nowrap;
  text-transform: uppercase; letter-spacing: .04em;
}
tr:last-child td { border-bottom: none; }
td .mono, .mono { font-family: var(--font-mono); font-size: 12.5px; }

/* 콘티 컷 카드 */
.cut {
  border: 1px solid var(--border); border-radius: var(--radius);
  margin: 14px 0; overflow: hidden; background: var(--bg-elev);
}
.cut-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px; background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}
.cut-head .cutno {
  font-family: var(--font-mono); font-weight: 800; font-size: 14px;
  color: var(--accent-text); background: var(--accent-soft);
  padding: 3px 10px; border-radius: 7px;
}
.cut-head .cut-title { font-weight: 700; font-size: 14.5px; flex: 1; min-width: 140px; }
.cut-body { padding: 14px 16px; }
.cut-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px 16px; margin-bottom: 12px;
}
.cut-grid .kv { font-size: 13.5px; }
.cut-grid .kv b {
  display: block; font-size: 11px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 2px;
}
.cut-why {
  font-size: 13.5px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--blue-soft); color: var(--blue); margin-bottom: 8px;
}
.cut-edit {
  font-size: 13.5px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--purple-soft); color: var(--purple);
}
.cut-why b, .cut-edit b { font-weight: 800; }

/* 대본 블록 */
.script-block {
  border-left: 3px solid var(--accent);
  background: var(--bg-subtle);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 16px 18px; margin: 12px 0;
  font-size: 15px;
}
.script-block .cue {
  font-size: 12px; font-weight: 800; color: var(--accent-text);
  text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px;
}
.script-block p { margin: 0 0 .7em; }
.script-block p:last-child { margin-bottom: 0; }
.script-block .dir { color: var(--text-3); font-size: 13px; font-style: italic; }

/* 쇼츠 카드 */
.shorts-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  margin: 14px 0; overflow: hidden;
}
.shorts-card summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; background: var(--bg-subtle);
  font-weight: 700; font-size: 14.5px;
}
.shorts-card summary::-webkit-details-marker { display: none; }
.shorts-card summary .sno {
  flex: none; font-family: var(--font-mono); font-size: 12px; font-weight: 800;
  background: var(--text); color: var(--bg);
  padding: 3px 8px; border-radius: 6px;
}
.shorts-card summary::after { content: "▾"; margin-left: auto; color: var(--text-3); transition: transform .2s; }
.shorts-card[open] summary::after { transform: rotate(180deg); }
.shorts-card .shorts-body { padding: 14px 16px; border-top: 1px solid var(--border); font-size: 14px; }
.shorts-body .row { margin-bottom: 10px; }
.shorts-body .row b {
  display: inline-block; min-width: 64px; font-size: 12px; font-weight: 800;
  color: var(--text-3); text-transform: uppercase; letter-spacing: .05em;
}
.hashtags { color: var(--blue); font-size: 13px; word-break: break-all; }

/* 썸네일 카드 */
.thumb-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.thumb-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.thumb-card .thumb-visual {
  aspect-ratio: 16/9; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  padding: 12px; text-align: center;
  background: linear-gradient(135deg, #292524, #7c2d12);
  color: #fff;
}
.thumb-visual .big { font-size: clamp(17px, 2.6vw, 22px); font-weight: 900; line-height: 1.2; text-shadow: 0 2px 8px rgba(0,0,0,.5); }
.thumb-visual .small { font-size: 12px; font-weight: 700; color: #fdba74; }
.thumb-card .thumb-info { padding: 12px 14px; font-size: 13px; }
.thumb-info div { margin-bottom: 5px; }
.thumb-info b { color: var(--text-3); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; margin-right: 6px; }

/* 체크리스트 */
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { border-bottom: 1px solid var(--border); }
.checklist li:last-child { border-bottom: none; }
.checklist label {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 11px 4px; cursor: pointer; font-size: 14.5px;
  transition: opacity .2s;
}
.checklist input[type="checkbox"] {
  flex: none; appearance: none; -webkit-appearance: none;
  width: 21px; height: 21px; margin-top: 1px;
  border: 2px solid var(--border-strong); border-radius: 7px;
  background: var(--bg-elev); cursor: pointer;
  display: grid; place-items: center;
  transition: background .15s, border-color .15s;
}
.checklist input[type="checkbox"]:checked {
  background: var(--accent); border-color: var(--accent);
}
.checklist input[type="checkbox"]:checked::after {
  content: "✓"; color: #fff; font-size: 13px; font-weight: 900;
}
.checklist input[type="checkbox"]:checked + span {
  text-decoration: line-through; color: var(--text-3);
}
.check-progress {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; margin-bottom: 12px;
  background: var(--bg-subtle); border-radius: var(--radius);
  font-size: 13px; font-weight: 700; color: var(--text-2);
}
.check-progress .bar { flex: 1; height: 8px; border-radius: 99px; background: var(--bg-inset); overflow: hidden; }
.check-progress .bar i { display: block; height: 100%; width: 0%; background: var(--accent); border-radius: 99px; transition: width .3s; }

/* 타임라인 */
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; }
.timeline li { position: relative; padding: 0 0 18px 26px; border-left: 2px solid var(--border); margin-left: 8px; }
.timeline li:last-child { padding-bottom: 4px; }
.timeline li::before {
  content: ""; position: absolute; left: -7px; top: 4px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--bg-elev);
  box-shadow: 0 0 0 1px var(--border);
}
.timeline .t-time { font-family: var(--font-mono); font-size: 12.5px; font-weight: 700; color: var(--accent-text); }
.timeline .t-title { font-weight: 700; font-size: 14.5px; margin: 2px 0; }
.timeline .t-desc { font-size: 13.5px; color: var(--text-2); }

/* ---------- 7. 목차(index) ---------- */
.part-title {
  display: flex; align-items: center; gap: 12px;
  margin: 36px 0 14px; font-size: 13px; font-weight: 800;
  color: var(--text-3); text-transform: uppercase; letter-spacing: .1em;
}
.part-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.toc-list { display: grid; gap: 10px; }
.toc-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: var(--radius);
  background: var(--bg-elev); border: 1px solid var(--border);
  color: var(--text); text-decoration: none;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.toc-item:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow); }
.toc-item .ch-no {
  flex: none; width: 40px; height: 40px; border-radius: 10px;
  background: var(--bg-subtle); color: var(--text-2);
  font-family: var(--font-mono); font-weight: 800; font-size: 13px;
  display: grid; place-items: center;
}
.toc-item:hover .ch-no { background: var(--accent-soft); color: var(--accent-text); }
.toc-item .ch-info { flex: 1; min-width: 0; }
.toc-item .ch-title { font-weight: 700; font-size: 15px; }
.toc-item .ch-desc { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toc-item .ch-day { flex: none; }
.toc-item .ch-check { flex: none; font-size: 12px; color: var(--text-3); font-weight: 700; }
.toc-item.done .ch-no { background: var(--green-soft); color: var(--green); }

/* index 히어로 통계 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin: 20px 0; }
.stat {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; text-align: center;
}
.stat .n { font-size: 24px; font-weight: 900; color: var(--accent-text); letter-spacing: -.02em; }
.stat .l { font-size: 12.5px; color: var(--text-2); font-weight: 600; margin-top: 2px; }

/* ---------- 8. 챕터 내 목차 & 네비게이션 ---------- */
.chapter-toc {
  display: flex; flex-wrap: wrap; gap: 7px;
  padding: 14px; margin: 0 0 24px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.chapter-toc a {
  font-size: 12.5px; font-weight: 700; color: var(--text-2);
  padding: 5px 11px; border-radius: 999px; background: var(--bg-subtle);
  text-decoration: none; transition: background .15s, color .15s;
}
.chapter-toc a:hover { background: var(--accent-soft); color: var(--accent-text); }

.pagenav { display: flex; gap: 12px; margin-top: 36px; }
.pagenav a {
  flex: 1; display: block; padding: 16px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-elev); text-decoration: none; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.pagenav a:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.pagenav .dir { font-size: 12px; font-weight: 700; color: var(--text-3); margin-bottom: 4px; }
.pagenav .ttl { font-weight: 700; font-size: 14.5px; }
.pagenav a.next { text-align: right; }
.pagenav a.disabled { opacity: .4; pointer-events: none; }

/* ---------- 9. 검색 오버레이 ---------- */
.search-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.45); backdrop-filter: blur(4px);
  display: none; padding: 10vh 16px 0;
}
.search-overlay.open { display: block; }
.search-panel {
  max-width: 560px; margin: 0 auto;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.search-panel input {
  width: 100%; border: none; outline: none;
  padding: 18px 20px; font-size: 16px;
  background: transparent; color: var(--text);
  font-family: var(--font-sans);
  border-bottom: 1px solid var(--border);
}
.search-results { max-height: 50vh; overflow-y: auto; }
.search-results a {
  display: block; padding: 13px 20px;
  border-bottom: 1px solid var(--border);
  color: var(--text); text-decoration: none;
}
.search-results a:last-child { border-bottom: none; }
.search-results a:hover, .search-results a.active { background: var(--bg-subtle); }
.search-results .r-title { font-weight: 700; font-size: 14.5px; }
.search-results .r-meta { font-size: 12.5px; color: var(--text-2); }
.search-empty { padding: 24px 20px; text-align: center; color: var(--text-3); font-size: 14px; }

/* ---------- 10. 반응형 ---------- */
@media (max-width: 640px) {
  body { font-size: 15px; }
  .container { padding: 0 14px 60px; }
  .section { padding: 18px 16px; border-radius: var(--radius); }
  .hero { padding: 26px 20px; margin-top: 16px; }
  .toc-item .ch-desc { display: none; }
  .cut-grid { grid-template-columns: 1fr 1fr; }
  .pagenav { flex-direction: column; }
  .pagenav a.next { text-align: left; }
}

/* ---------- 11. 인쇄 / PDF ---------- */
@media print {
  :root { --bg: #fff; --bg-elev: #fff; --bg-subtle: #f6f6f6; --text: #111; }
  html[data-theme="dark"] {
    --bg: #fff; --bg-elev: #fff; --bg-subtle: #f6f6f6; --bg-inset: #eee;
    --text: #111; --text-2: #444; --text-3: #888;
    --border: #ddd; --border-strong: #bbb;
    --accent: #e8590c; --accent-soft: #fff0e6; --accent-text: #c2410c;
  }
  body { background: #fff; font-size: 12.5px; }
  .topbar, .progressbar, .search-overlay, .pagenav, .noprint { display: none !important; }
  .container { max-width: 100%; padding: 0; }
  .section { box-shadow: none; break-inside: avoid; page-break-inside: avoid; margin-bottom: 14px; }
  .hero { background: #292524 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .shorts-card { break-inside: avoid; }
  .shorts-card .shorts-body { display: block !important; }
  details > .shorts-body { display: block; }
  a { color: inherit; }
}
