/*!
 * sajutaro.kr — single post unified template
 * Loaded from single-saju.php (template_include filter)
 */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

:root {
  --p9:  #1e0a3c; --p8: #2d1060; --p7: #4c1d95; --p6: #6d28d9;
  --p5:  #7c3aed; --p4: #8b5cf6; --p3: #a78bfa; --p2: #c4b5fd; --p1: #ede9fe;
  --ink: #1a1a2e; --sub: #4b5563; --muted: #6b7280; --border: #e5e7eb;
  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  /* 데스크톱: 본문(860) + 간격(32) + 목차(300) = 1192px 컨테이너 */
  --content-max: 860px;
  --toc-sidebar-w: 340px;
  --toc-toc-gap: 32px;
  --shell-max: 1192px;
  --shell-edge-pad: 32px;
}

body {
  font-family: var(--font); color: var(--ink); background: #fff;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
img { display: block; max-width: 100%; }

/* footer 전용 가운데 정렬 컨테이너 (헤로/본문 시스템과 분리) */
.sf-inner { max-width: 1200px; margin: 0 auto; padding: 0 32px; }

/* 접근성: skip link */
.skip-link {
  position: absolute; left: -9999px; top: -9999px;
  background: var(--p7); color: #fff; padding: 12px 18px;
  border-radius: 0 0 8px 0; font-weight: 700; z-index: 999;
}
.skip-link:focus { left: 0; top: 0; }

/* ── HEADER ─── */
.sh {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  padding: 0 32px; height: 64px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(10,5,28,.88); backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.sh-logo { font-size: 18px; font-weight: 800; color: #fff; letter-spacing: -.5px; }
.sh-logo span { color: var(--p3); }
.sh-nav { display: flex; gap: 28px; align-items: center; }
.sh-nav a { font-size: 14px; font-weight: 500; color: rgba(255,255,255,.65); transition: color .2s; }
.sh-nav a:hover, .sh-nav a.active { color: #fff; }
.sh-nav .sh-cta {
  background: var(--p5); color: #fff; padding: 8px 20px;
  border-radius: 100px; font-weight: 700; font-size: 14px;
  transition: background .2s, transform .15s;
}
.sh-nav .sh-cta:hover { background: var(--p6); transform: translateY(-1px); }

/* ── POST HERO ─── */
.post-hero {
  padding: 130px 0 64px;
  background: linear-gradient(155deg, #070414 0%, #140a2e 40%, #2d1060 75%, #4c1d95 100%);
  position: relative; overflow: hidden;
}
.post-hero::before {
  content: ''; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: 72px 72px; pointer-events: none;
}
.hero-glow {
  position: absolute; border-radius: 50%; pointer-events: none; filter: blur(70px);
  width: 500px; height: 500px; top: -200px; right: -100px;
  background: radial-gradient(circle, rgba(109,40,217,.4) 0%, transparent 70%);
}
.post-hero-inner {
  position: relative; z-index: 2;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 32px;
  box-sizing: border-box;
}
.post-cat-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 14px; border-radius: 100px;
  background: rgba(167,139,250,.2); border: 1px solid rgba(167,139,250,.35);
  font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  color: var(--p2); margin-bottom: 22px;
}
.post-hero h1 {
  font-size: clamp(22px, 5vw, 48px); font-weight: 900;
  color: #fff; line-height: 1.25; letter-spacing: -1px; margin-bottom: 24px;
  word-break: keep-all;
}
.post-meta-row { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.post-meta-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: rgba(255,255,255,.5); font-weight: 500;
}
.post-meta-item svg { opacity: .6; flex-shrink: 0; }

/* ── 본문 + 목차 래퍼 (단순 패스스루) ─── */
.post-shell { max-width: none; margin: 0; padding: 0; }

/* ── CONTENT OUTER ─── */
.post-outer {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 52px 32px 100px;
  box-sizing: border-box;
}

/* ── BACK LINK ─── */
.back-link {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600; color: var(--p5);
  padding: 10px 20px; border-radius: 100px;
  border: 1.5px solid var(--p2); background: var(--p1);
  transition: all .18s; margin-bottom: 40px;
  min-height: 44px;
}
.back-link:hover { background: var(--p5); color: #fff; border-color: var(--p5); }

/* ── TOC SIDEBAR — 데스크톱: 1192px 컨테이너 우측에 fixed ─── */
.toc-sidebar {
  position: fixed;
  top: 88px;
  /* 컨테이너 우측 = (100vw - shell)/2 + content + gap. 좁으면 본문 옆 32px에 맞춤 */
  left: max(
    calc(var(--shell-edge-pad) + var(--content-max) + var(--toc-toc-gap)),
    calc((100vw - var(--shell-max)) / 2 + var(--content-max) + var(--toc-toc-gap))
  );
  width: var(--toc-sidebar-w);
  max-height: calc(100vh - 104px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--p2) transparent;
  z-index: 50;
  transition: top .15s ease;
}
.toc-sidebar::-webkit-scrollbar { width: 3px; }
.toc-sidebar::-webkit-scrollbar-thumb { background: var(--p2); border-radius: 4px; }

/* ez-toc in sidebar */
.toc-sidebar #ez-toc-container {
  position: relative !important;
  left: auto !important;
  right: auto !important;
  transform: none !important;
  background: #faf9ff !important;
  border: 1px solid #e0d9fb !important;
  border-radius: 14px !important;
  padding: 18px 16px 14px !important;
  margin: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  float: none !important;
}
.toc-sidebar #ez-toc-container .ez-toc-title-container { margin-bottom: 12px !important; }
.toc-sidebar #ez-toc-container .ez-toc-title {
  font-size: 12px !important; font-weight: 800 !important;
  letter-spacing: 1.5px !important; text-transform: uppercase !important;
  color: var(--p7) !important;
}
.toc-sidebar #ez-toc-container nav { margin-top: 4px !important; }
.toc-sidebar #ez-toc-container nav ul {
  list-style: none !important; margin: 0 !important; padding: 0 !important;
}
.toc-sidebar #ez-toc-container nav ul ul {
  padding-left: 14px !important; margin-top: 2px !important;
}
.toc-sidebar #ez-toc-container nav li { margin: 0 !important; padding: 0 !important; }
.toc-sidebar #ez-toc-container nav a {
  display: block !important;
  font-size: 13px !important; font-weight: 500 !important;
  color: var(--sub) !important;
  text-decoration: none !important;
  padding: 5px 8px !important;
  border-radius: 7px !important;
  line-height: 1.45 !important;
  transition: background .15s, color .15s !important;
}
.toc-sidebar #ez-toc-container nav a:hover,
.toc-sidebar #ez-toc-container nav a.active {
  background: var(--p1) !important; color: var(--p6) !important;
  font-weight: 600 !important;
}
.toc-sidebar #ez-toc-container nav a.toc-active {
  background: var(--p1) !important; color: var(--p5) !important;
  font-weight: 700 !important;
}

/* ── MOBILE TOC FAB ─── */
.toc-fab {
  display: none;
  position: fixed; bottom: 28px; right: 20px; z-index: 200;
  background: var(--p5); color: #fff;
  border: none; cursor: pointer;
  font-family: var(--font); font-size: 13px; font-weight: 700;
  padding: 11px 18px; border-radius: 100px;
  box-shadow: 0 4px 20px rgba(124,58,237,.45);
  align-items: center; gap: 6px;
  transition: transform .15s, background .15s;
  min-height: 44px;
}
.toc-fab:active { background: var(--p6); transform: scale(.96); }

/* ── MOBILE TOC DRAWER ─── */
.toc-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.55); z-index: 300;
  -webkit-tap-highlight-color: transparent;
}
.toc-overlay.open { display: block; }
.toc-drawer {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: #fff; border-radius: 20px 20px 0 0;
  padding: 12px 20px 40px;
  max-height: 72vh; overflow-y: auto;
  transform: translateY(100%);
  transition: transform .32s cubic-bezier(.32,1,.42,1);
}
.toc-overlay.open .toc-drawer { transform: translateY(0); }
.toc-drawer-handle {
  width: 40px; height: 4px; background: #e5e7eb;
  border-radius: 2px; margin: 0 auto 20px;
}
.toc-drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.toc-drawer-label {
  font-size: 12px; font-weight: 800; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--p7);
}
.toc-drawer-close {
  background: #f3f4f6; border: none; cursor: pointer;
  width: 32px; height: 32px; border-radius: 50%;
  font-size: 16px; color: var(--muted); line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
/* TOC in drawer */
.toc-drawer-content #ez-toc-container {
  background: transparent !important; border: none !important;
  padding: 0 !important; margin: 0 !important;
  width: 100% !important; max-width: 100% !important;
  float: none !important;
}
.toc-drawer-content #ez-toc-container .ez-toc-title-container { display: none !important; }
.toc-drawer-content #ez-toc-container nav ul {
  list-style: none !important; margin: 0 !important; padding: 0 !important;
}
.toc-drawer-content #ez-toc-container nav ul ul {
  padding-left: 16px !important; margin-top: 2px !important;
}
.toc-drawer-content #ez-toc-container nav li { margin: 0 !important; padding: 0 !important; }
.toc-drawer-content #ez-toc-container nav a {
  display: block !important;
  font-size: 15px !important; font-weight: 500 !important;
  color: var(--sub) !important;
  padding: 10px 12px !important;
  border-radius: 10px !important;
  text-decoration: none !important;
  line-height: 1.4 !important;
  transition: background .12s !important;
  min-height: 44px; display: flex !important; align-items: center !important;
}
.toc-drawer-content #ez-toc-container nav a:active,
.toc-drawer-content #ez-toc-container nav a.toc-active {
  background: var(--p1) !important; color: var(--p5) !important;
  font-weight: 700 !important;
}

/* ── ARTICLE CONTENT ─── */
.post-content { font-size: 17px; line-height: 1.85; color: #1f2937; min-width: 0; }
.post-content h2 {
  font-size: clamp(20px, 3vw, 28px); font-weight: 800; color: var(--ink);
  letter-spacing: -.7px; margin: 2.5em 0 .9em; padding-bottom: 10px;
  border-bottom: 2px solid var(--p1); word-break: keep-all;
}
.post-content h3 {
  font-size: clamp(17px, 2.5vw, 22px); font-weight: 700; color: var(--ink);
  letter-spacing: -.5px; margin: 2em 0 .7em; word-break: keep-all;
}
.post-content h4 { font-size: 17px; font-weight: 700; color: var(--ink); margin: 1.6em 0 .6em; }
.post-content p { margin-bottom: 1.4em; word-break: keep-all; }
.post-content ul, .post-content ol { margin: 1em 0 1.5em 1.5em; }
.post-content li { margin-bottom: .5em; word-break: keep-all; }
.post-content strong { color: var(--ink); font-weight: 700; }
.post-content em { color: var(--p6); font-style: normal; font-weight: 600; }
.post-content blockquote {
  margin: 2em 0; padding: 20px 24px;
  background: var(--p1); border-left: 4px solid var(--p4);
  border-radius: 0 12px 12px 0;
  font-size: 16px; color: var(--p7); font-weight: 600; line-height: 1.7;
}
.post-content blockquote p { margin-bottom: 0; }
.post-content img {
  width: 100%; border-radius: 12px; margin: 1.5em 0;
  box-shadow: 0 4px 24px rgba(0,0,0,.1);
}
.post-content a {
  color: var(--p5); text-decoration: underline; text-decoration-color: var(--p2);
  text-underline-offset: 3px; transition: color .15s;
}
.post-content a:hover { color: var(--p6); }
/* 테이블 모바일 스크롤 */
.post-content table {
  width: 100%; border-collapse: collapse; margin: 1.5em 0; font-size: 15px;
  display: block; overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.post-content th {
  background: var(--p1); color: var(--p7); font-weight: 700;
  padding: 10px 14px; border: 1px solid #d4d0fb; text-align: left;
  white-space: nowrap;
}
.post-content td { padding: 10px 14px; border: 1px solid var(--border); }
.post-content tr:nth-child(even) td { background: #fafafa; }
.post-content code {
  background: #f3f4f6; color: var(--p6); padding: 2px 7px; border-radius: 5px; font-size: 14px;
  word-break: break-all;
}
.post-content pre {
  background: #1e1e2e; border-radius: 10px; padding: 20px 24px;
  margin: 1.5em 0; overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.post-content pre code { background: none; color: #cdd6f4; font-size: 14px; line-height: 1.7; word-break: normal; }

/* 본문 내 ez-toc는 JS 이동 전까지 숨김 */
.post-content #ez-toc-container { display: none; }

/* ── DIVIDER ─── */
.post-divider { border: none; border-top: 1px solid var(--border); margin: 48px 0; }

/* ── RELATED POSTS ─── */
.related-section { border-top: 1px solid var(--border); padding-top: 52px; margin-top: 56px; }
.related-title { font-size: 20px; font-weight: 800; letter-spacing: -.5px; color: var(--ink); margin-bottom: 28px; }
.related-title span { color: var(--p5); }
.related-more-wrap { text-align: center; margin-top: 36px; }
.related-more-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 32px; border-radius: 100px;
  background: var(--p5); color: #fff;
  font-size: 15px; font-weight: 700;
  transition: background .18s, transform .15s;
  min-height: 48px;
}
.related-more-btn:hover { background: var(--p6); transform: translateY(-2px); color: #fff; }
.related-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.related-card {
  background: #fafafa; border: 1px solid var(--border);
  border-radius: 14px; overflow: hidden;
  transition: box-shadow .22s, transform .22s;
}
.related-card:hover { box-shadow: 0 8px 32px rgba(0,0,0,.1); transform: translateY(-3px); }
.related-card img { width: 100%; height: 140px; object-fit: cover; display: block; }
.related-card-ph {
  height: 140px; display: flex; align-items: center; justify-content: center;
  font-size: 32px; background: linear-gradient(135deg, var(--p1), #ddd6fe);
}
.related-card-body { padding: 14px 16px; }
.related-card-date { font-size: 11px; color: #9ca3af; margin-bottom: 6px; }
.related-card-title {
  font-size: 14px; font-weight: 700; color: var(--ink); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  word-break: keep-all;
}
.related-card:hover .related-card-title { color: var(--p5); }

/* ── FOOTER ─── */
.sf { background: #0d0a1f; padding: 52px 0; text-align: center; color: rgba(255,255,255,.35); font-size: 13px; line-height: 2; }
.sf a { color: rgba(255,255,255,.5); }
.sf a:hover { color: #fff; }

/* ── 반응형 ─── */
/* 데스크톱(>=1280px): 헤로·본문을 1192px 컨테이너 좌측 열로 이동, 목차는 우측 고정 */
@media (min-width: 1280px) {
  .post-hero-inner,
  .post-outer {
    /* 컨테이너(=1192px) 안 좌측 정렬 → margin-right: auto */
    max-width: var(--content-max);
    margin-left: max(var(--shell-edge-pad), calc((100vw - var(--shell-max)) / 2));
    margin-right: auto;
    padding-left: 0;
    padding-right: 0;
  }
  .post-outer { padding-top: 52px; padding-bottom: 100px; }
  .toc-sidebar { display: block; }
  .toc-fab { display: none; }
}
/* < 1280px: 헤로·본문 가운데 정렬 + 우하단 FAB */
@media (max-width: 1279.98px) {
  .toc-sidebar { display: none !important; }
  .toc-fab { display: flex; }
}

/* ez-toc 플러그인이 만들 수 있는 떠다니는 위젯/스티키 토글 차단 */
.ez-toc-sticky-toggle,
.ez-toc-sticky,
.ez-toc-floating,
#ez-toc-sticky-toggle,
#ez-toc-sticky-container { display: none !important; }
.toc-sidebar #ez-toc-container,
.toc-drawer-content #ez-toc-container {
  position: relative !important;
  inset: auto !important;
  transform: none !important;
}

@media (max-width: 860px) {
  .related-grid { grid-template-columns: 1fr 1fr; }
  .sh-nav a:not(.sh-cta) { display: none; }
}

@media (max-width: 640px) {
  .sf-inner { padding: 0 20px; }
  .sh { padding: 0 16px; }
  .sh-nav { gap: 0; }
  .sh-nav .sh-cta { padding: 7px 16px; font-size: 13px; }
  .post-outer { padding: 36px 20px 100px; }
  .post-hero { padding: 100px 0 44px; }
  .post-hero h1 { letter-spacing: -.5px; margin-bottom: 20px; }
  .post-meta-row { gap: 12px; }
  .post-meta-item { font-size: 12px; }
  .related-grid { grid-template-columns: 1fr; }
  .post-content { font-size: 16px; line-height: 1.8; }
  .post-content blockquote { padding: 16px 18px; font-size: 15px; }
  .back-link { margin-bottom: 28px; }
  .toc-fab { bottom: 20px; right: 16px; }
}

@media (max-width: 380px) {
  .sh-logo { font-size: 16px; }
  .sh-nav .sh-cta { padding: 7px 12px; font-size: 12px; }
}

/* iOS 스크롤 잠금 — body에 적용되는 클래스 */
body.toc-drawer-open {
  position: fixed;
  width: 100%;
  overflow: hidden;
}
