/* ==========================================================================
   마음의 괴물을 다스리는 부처님 — site styles
   ========================================================================== */

/* 본문 서체 — Pretendard Variable 서브셋(자체 호스팅, 외부 CDN 없음). */
@font-face {
  font-family: "Pretendard Variable";
  src: url("fonts/pretendard-variable.woff2") format("woff2-variations");
  font-weight: 45 920;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg:          #faf7f2;
  --bg-alt:      #f3ede3;
  --surface:     #ffffff;
  --surface-2:   #f7f2ea;
  --border:      #e4d9c8;
  --text:        #2b2118;
  --text-soft:   #6b5c49;
  --text-dim:    #8a7a63;
  --accent:      #9a6b2f;
  --accent-2:    #4e6e5d;
  --accent-ink:  #ffffff;
  --accent-rgb:  154 107 47;
  --shadow:      0 10px 30px -18px rgba(80, 60, 30, .35);
  --radius:      14px;
  --radius-sm:   9px;
  --maxw:        1080px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Pretendard Variable", "Noto Sans KR", "Apple SD Gothic Neo",
          "Malgun Gothic", sans-serif;
  --serif: Georgia, "Times New Roman", "Pretendard Variable", serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg:          #16120d;
  --bg-alt:      #1d1811;
  --surface:     #221c14;
  --surface-2:   #2a2318;
  --border:      #3b3122;
  --text:        #f0e9dd;
  --text-soft:   #c2b39c;
  --text-dim:    #9d8e77;
  --accent:      #e0a75c;
  --accent-2:    #8fbfa6;
  --accent-ink:  #241a08;
  --accent-rgb:  224 167 92;
  --shadow:      0 12px 34px -18px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 84px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3 { line-height: 1.3; margin: 0 0 .6em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.9rem, 5vw, 3.1rem); font-weight: 800; }
h2 { font-size: clamp(1.45rem, 3.6vw, 2.1rem); font-weight: 750; }
h3 { font-size: 1.12rem; font-weight: 700; }
p  { margin: 0 0 1em; }
a  { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: 10px 18px; border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

/* ── Header ─────────────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex; align-items: center; gap: 18px;
  min-height: 64px;
}
.logo { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 800; }
.logo:hover { text-decoration: none; }
.logo-mark {
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 1.15rem; box-shadow: var(--shadow);
}
.logo-text { font-size: 1.02rem; letter-spacing: -.01em; }
.logo-text .accent { color: var(--accent); }

.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a {
  color: var(--text-soft); font-size: .93rem; font-weight: 600;
  padding: 8px 12px; border-radius: var(--radius-sm);
}
.nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }

/* ── 테마 선택 버튼 ───────────────────────────────────── */
.theme-set { display: flex; gap: 4px; padding: 3px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.theme-opt {
  width: 32px; height: 32px; border: 0; border-radius: 999px;
  background: transparent; cursor: pointer; font-size: .95rem; line-height: 1;
  opacity: .55; transition: background .12s ease, opacity .12s ease;
}
.theme-opt:hover { opacity: 1; }
.theme-opt[aria-pressed="true"] { background: var(--surface-2); opacity: 1; box-shadow: inset 0 0 0 1px var(--border); }

.menu-btn {
  display: none; margin-left: auto;
  width: 42px; height: 42px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface);
  cursor: pointer; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
}
.menu-btn span { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 2px; }

/* ── Hero ───────────────────────────────────────────────── */
.hero {
  position: relative; overflow: hidden;
  background:
    radial-gradient(1100px 460px at 78% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
    var(--bg-alt);
  border-bottom: 1px solid var(--border);
}
.hero-inner { padding: 72px 20px 60px; }
.hero-kicker {
  display: inline-block; margin: 0 0 14px;
  padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-soft); font-size: .82rem; font-weight: 700; letter-spacing: .04em;
}
.hero h1 { max-width: 22ch; }
.hero h1 .accent { color: var(--accent); }
.hero-sub {
  margin: -8px 0 18px; color: var(--accent);
  font-family: var(--serif); font-size: clamp(1.05rem, 2.6vw, 1.4rem); font-style: italic;
}
.hero-lead { max-width: 62ch; color: var(--text-soft); font-size: 1.08rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 26px 0 8px; }
.resume-box { margin: -10px 0 0; }
.resume-box .btn { font-size: .92rem; }

.hero-stats {
  display: flex; flex-wrap: wrap; gap: 26px;
  margin: 34px 0 0; padding: 22px 0 0; border-top: 1px solid var(--border);
}
.stat b { display: block; font-size: 1.7rem; font-weight: 800; color: var(--accent); line-height: 1.2; }
.stat span { color: var(--text-dim); font-size: .88rem; }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px; border-radius: 999px;
  font-size: .95rem; font-weight: 700; cursor: pointer;
  border: 1px solid transparent; transition: transform .12s ease, opacity .12s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn[disabled] { opacity: .5; cursor: default; }

/* ── Cards / sections ───────────────────────────────────── */
.section { padding: 56px 0; }
.section-alt { background: var(--bg-alt); border-block: 1px solid var(--border); }
.section-head { max-width: 62ch; margin-bottom: 26px; }
.section-head p { color: var(--text-soft); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
}
.card h3 { margin-bottom: .35em; }
.card p:last-child { margin-bottom: 0; }

.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

/* ── 오늘의 법구 ─────────────────────────────────────────── */
.daily {
  background:
    linear-gradient(150deg, color-mix(in srgb, var(--accent) 12%, var(--surface)), var(--surface));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 30px; box-shadow: var(--shadow);
}
.daily-label {
  display: inline-block; margin: 0 0 12px; padding: 5px 13px;
  border-radius: 999px; background: var(--accent); color: var(--accent-ink);
  font-size: .8rem; font-weight: 800; letter-spacing: .05em;
}
.daily-en {
  font-family: var(--serif); font-size: clamp(1.15rem, 2.6vw, 1.5rem);
  line-height: 1.65; margin: 0 0 14px;
}
.daily-ko { color: var(--text-soft); margin: 0 0 16px; }
.daily-meta { color: var(--text-dim); font-size: .88rem; }

/* ── 목차 ───────────────────────────────────────────────── */
.toc-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.toc-item {
  display: flex; gap: 14px; align-items: baseline;
  padding: 15px 18px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}
.toc-item:hover {
  text-decoration: none; border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
}
.toc-num {
  flex: none; width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--accent);
  font-weight: 800; font-size: .88rem;
}
.toc-main b { display: block; font-size: 1rem; }
.toc-main span { color: var(--text-dim); font-size: .82rem; }

/* ── 검색 ───────────────────────────────────────────────── */
.search-box { display: flex; gap: 10px; margin-bottom: 18px; }
.search-box input {
  flex: 1; padding: 13px 18px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 1rem; font-family: inherit;
}
.search-box input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.search-results { display: grid; gap: 10px; max-height: 460px; overflow: auto; }
.search-hit {
  padding: 13px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}
.search-hit:hover { border-color: var(--accent); text-decoration: none; }
.search-hit .hit-num { color: var(--accent); font-weight: 800; margin-right: 8px; }
.search-hit .hit-en { display: block; font-family: var(--serif); font-size: .92rem; }
.search-hit .hit-ko { display: block; color: var(--text-dim); font-size: .86rem; }
.search-note { color: var(--text-dim); font-size: .9rem; }

/* ── 챕터 페이지 ────────────────────────────────────────── */
.crumbs { padding: 18px 20px 0; color: var(--text-dim); font-size: .86rem; }
.crumbs a { color: var(--text-soft); }

.chapter { padding: 26px 20px 60px; }
.chapter-head { margin-bottom: 30px; }
.chapter-kicker { color: var(--accent); font-weight: 800; letter-spacing: .08em; font-size: .85rem; margin: 0 0 8px; }
.chapter-sub { color: var(--text-dim); margin-bottom: 10px; }
.chapter-sub .pali { font-style: italic; }
.chapter-theme {
  display: inline-block; padding: 8px 16px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: .9rem; color: var(--text-soft); margin-bottom: 16px;
}
.chapter-intro {
  border-left: 3px solid var(--accent); padding: 4px 0 4px 18px;
  color: var(--text-soft); max-width: 68ch;
}
.intro-en { font-family: var(--serif); font-size: .95rem; color: var(--text-dim); }
.practice {
  margin: 18px 0; padding: 16px 20px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent-2) 12%, var(--surface));
  border: 1px solid var(--border); max-width: 68ch;
}
.practice-label { font-weight: 800; color: var(--accent-2); margin: 0 0 4px; }
.practice p { margin-bottom: .3em; }
.practice-en { font-family: var(--serif); font-size: .92rem; color: var(--text-dim); }
.chapter-tools { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

/* ── 게송 ───────────────────────────────────────────────── */
.verses { display: grid; gap: 14px; }
.verse {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 22px;
}
.verse:target { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.verse-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.verse-num {
  display: inline-grid; place-items: center;
  min-width: 44px; height: 30px; padding: 0 10px;
  border-radius: 999px; background: var(--accent); color: var(--accent-ink);
  font-weight: 800; font-size: .84rem;
}
.tts-btn {
  margin-left: auto; padding: 5px 13px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-soft); font-size: .78rem; font-weight: 700; cursor: pointer;
}
.tts-btn:hover { color: var(--text); border-color: var(--accent); }
.tts-btn[data-speaking="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.verse-pali {
  font-family: var(--serif); font-style: italic; font-size: 1.02rem;
  color: var(--accent-2); margin: 0 0 12px; line-height: 1.85;
}
[data-hide-pali="true"] .verse-pali { display: none; }
.copy-btn {
  margin-left: 8px; padding: 5px 13px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-soft); font-size: .78rem; font-weight: 700; cursor: pointer;
}
.copy-btn:hover { color: var(--text); border-color: var(--accent); }
.verse-en {
  font-family: var(--serif); font-size: 1.08rem; line-height: 1.8;
  margin: 0 0 12px; color: var(--text);
}
.verse-ko {
  margin: 0; padding-top: 12px; border-top: 1px dashed var(--border);
  color: var(--text-soft);
}
[data-hide-ko="true"] .verse-ko { display: none; }

.chapter-nav {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin-top: 34px; padding-top: 22px; border-top: 1px solid var(--border);
}

/* ── 자료실 / 소개 페이지 ───────────────────────────────── */
.prose { max-width: 72ch; }
.prose h2 { margin-top: 1.8em; }
.prose ul { padding-left: 1.2em; }
.prose li { margin-bottom: .55em; }

.source-list { display: grid; gap: 14px; }
.source-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 22px;
}
.source-item h3 { margin-bottom: .2em; }
.source-item .source-url { font-size: .88rem; word-break: break-all; }
.source-item p { color: var(--text-soft); margin: .5em 0 0; }
.source-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.tag {
  padding: 3px 11px; border-radius: 999px; font-size: .76rem; font-weight: 700;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim);
}

/* ── Footer ─────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border); background: var(--bg-alt);
  padding: 36px 0 44px; margin-top: 20px;
}
.foot-title { font-weight: 800; margin-bottom: 8px; }
.foot-note { color: var(--text-dim); font-size: .88rem; }
.foot-links a { color: var(--text-soft); }

/* ── 읽기 진행률 · 맨 위로 ──────────────────────────────── */
.read-bar {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 60;
  background: transparent; pointer-events: none;
}
.read-bar-fill {
  display: block; height: 100%; width: 0;
  background: var(--accent); transition: width .1s linear;
}
.to-top {
  position: fixed; right: 20px; bottom: 84px; z-index: 55;
  width: 46px; height: 46px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 1.15rem; cursor: pointer;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.to-top.show { opacity: 1; pointer-events: auto; }

/* ── 모바일 하단 탭바 ──────────────────────────────────── */
.tab-bar { display: none; }
@media (max-width: 860px) {
  .tab-bar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 58;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(10px); border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tab-bar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    color: var(--text-soft); font-size: .68rem; font-weight: 700; padding: 4px 0;
  }
  .tab-bar a:hover { text-decoration: none; color: var(--accent); }
  .tab-bar a span:first-child { font-size: 1.15rem; line-height: 1.2; }
  body { padding-bottom: 76px; }
  .to-top { bottom: 96px; }
}

/* ── 암송 모드 ────────────────────────────────────────── */
[data-memorize="true"] .verse-en,
[data-memorize="true"] .verse-ko,
[data-memorize="true"] .verse-pali {
  filter: blur(7px); user-select: none; cursor: pointer; transition: filter .18s ease;
}
[data-memorize="true"] .verse.revealed .verse-en,
[data-memorize="true"] .verse.revealed .verse-ko,
[data-memorize="true"] .verse.revealed .verse-pali { filter: none; user-select: text; }

/* ── 반응형 ─────────────────────────────────────────────── */
@media (max-width: 860px) {
  .grid-3, .grid-2, .toc-grid { grid-template-columns: 1fr; }
  .theme-set { display: none; }
  .nav .theme-set { display: flex; margin-top: 10px; }
  .nav {
    display: none; position: absolute; top: 64px; left: 0; right: 0;
    flex-direction: column; gap: 0; padding: 10px 16px 16px;
    background: var(--bg); border-bottom: 1px solid var(--border);
  }
  .nav.open { display: flex; }
  .menu-btn { display: flex; }
  .hero-inner { padding: 52px 20px 44px; }
  .verse-en { font-size: 1rem; }
  .chapter-nav { flex-direction: column; }
}

/* ── 인쇄 ───────────────────────────────────────────────── */
@media print {
  .site-header, .site-footer, .chapter-tools, .tts-btn, .chapter-nav, .skip-link { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .verse, .card, .daily { border: 1px solid #ccc; box-shadow: none; break-inside: avoid; }
  .hero { background: none; }
  a { color: #000; }
}
