/* 시화전 — 공통 스타일 */
:root {
  --ink: #2a2420;
  --ink-soft: #5d524a;
  --paper: #fffaf0;
  --paper-edge: #e9dcc3;
  --accent: #b2483a;
  --night: #1d1a22;
  --serif: "Gowun Dodum", "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --hand: "Nanum Pen Script", "Gowun Dodum", cursive;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--serif);
  color: var(--ink);
  background: var(--night);
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
/* 키보드(탭)로 이동할 때 지금 위치가 잘 보이게 */
a:focus-visible { outline: 3px solid #f2a541; outline-offset: 3px; border-radius: 6px; }
.dot:focus-visible { border-radius: 50%; }
.card:focus-visible { outline-offset: 5px; border-radius: 2px; }
img { display: block; }

.art {
  position: fixed; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: 70% 50%;
  z-index: 0;
}
.veil {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(90deg, rgba(0,0,0,.18) 0%, rgba(0,0,0,0) 55%);
}

/* ---------- 시 페이지 ---------- */
.poem-page .bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px max(16px, 3vw);
  background: linear-gradient(rgba(0,0,0,.55), rgba(0,0,0,0));
  color: #fff; font-size: .92rem; text-shadow: 0 1px 3px rgba(0,0,0,.6);
}
.bar a:hover { text-decoration: underline; }
.bar .where em { font-style: normal; opacity: .75; margin-left: .3em; }
.bar .count { font-variant-numeric: tabular-nums; opacity: .9; }

.wall {
  position: relative; z-index: 2;
  min-height: 100vh; min-height: 100svh;
  padding: 84px max(16px, 5vw) 150px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 18px;
}
.frame {
  position: relative;
  width: min(520px, 100%);
  padding: 44px 40px 34px;
  background:
    linear-gradient(rgba(255,250,240,.93), rgba(255,247,232,.93)),
    repeating-linear-gradient(0deg, transparent 0 27px, rgba(0,0,0,.025) 27px 28px);
  border: 1px solid var(--paper-edge);
  border-radius: 3px;
  box-shadow: 0 2px 0 rgba(255,255,255,.6) inset, 0 18px 40px rgba(0,0,0,.35), 0 3px 8px rgba(0,0,0,.25);
  backdrop-filter: blur(3px);
  transform: rotate(-.6deg);
  animation: hang .7s ease-out both;
}
@keyframes hang {
  from { opacity: 0; transform: translateY(-14px) rotate(-1.6deg); }
  to   { opacity: 1; transform: translateY(0) rotate(-.6deg); }
}
.pin {
  position: absolute; top: -9px; width: 18px; height: 18px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff9a8a, var(--accent) 60%, #6e241b);
  box-shadow: 0 3px 5px rgba(0,0,0,.4);
}
.pin.l { left: 24px; } .pin.r { right: 24px; }
.part-tag {
  margin: 0 0 6px; font-size: .8rem; letter-spacing: .14em; color: var(--accent);
}
.frame h1 {
  margin: 0 0 22px; font-size: clamp(1.35rem, 3.6vw, 1.7rem); line-height: 1.4; font-weight: 700;
  word-break: keep-all; padding-bottom: 14px; border-bottom: 1px solid rgba(0,0,0,.12);
}
.verse p { margin: 0 0 1.2em; font-size: 1.03rem; word-break: keep-all; overflow-wrap: anywhere; }
.verse p:last-child { margin-bottom: 0; }
sup.fn a { color: var(--accent); font-size: .7em; padding: 0 1px; }
.footnotes {
  margin: 26px 0 0; padding: 12px 0 0 1.2em; border-top: 1px solid rgba(0,0,0,.15);
  font-size: .82rem; color: var(--ink-soft); line-height: 1.6;
}
.footnotes a { color: var(--accent); }
.sign { margin: 22px 0 0; text-align: right; font-family: var(--hand); font-size: 1.45rem; color: var(--ink-soft); }

.dots { display: flex; gap: 7px; flex-wrap: wrap; padding-left: 8px; }
.dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: rgba(255,255,255,.55); box-shadow: 0 1px 3px rgba(0,0,0,.5);
  transition: transform .15s, background .15s;
}
.dot:hover { transform: scale(1.5); background: #fff; }
.dot.on { background: #fff; transform: scale(1.35); outline: 2px solid rgba(255,255,255,.55); outline-offset: 2px; }

/* 하단 네비게이션 */
.pager {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px;
  width: min(880px, 100%); margin: 0 auto;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
}
.pager::before {
  content: ""; position: fixed; left: 0; right: 0; bottom: 0; height: 110px; z-index: -1;
  background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.6)); pointer-events: none;
}
.nav {
  display: flex; flex-direction: column; justify-content: center; gap: 1px;
  min-width: 0; padding: 9px 16px; border-radius: 10px;
  background: rgba(255,250,240,.92); color: var(--ink);
  box-shadow: 0 6px 18px rgba(0,0,0,.3);
  transition: transform .15s, background .15s;
}
.nav:hover { transform: translateY(-2px); background: #fff; }
.nav .dir { font-size: .72rem; letter-spacing: .06em; color: var(--accent); }
.nav .nt { font-size: .95rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav.next { text-align: right; }
.nav.list { align-items: center; padding-inline: 20px; }
.nav.ghost { visibility: hidden; background: none; box-shadow: none; }

/* ---------- 차례(인덱스) ---------- */
.index-page { background: #f4ecdd; }
.hero { position: relative; min-height: 78vh; min-height: 78svh; display: grid; place-items: center; overflow: hidden; color: #fff; }
.hero .art { position: absolute; object-position: 60% 50%; }
.hero .veil { position: absolute; background: rgba(20,12,24,.5); }
.hero-in { position: relative; z-index: 2; text-align: center; padding: 80px 20px 70px; max-width: 760px; }
.eyebrow { margin: 0 0 14px; letter-spacing: .3em; font-size: .78rem; opacity: .85; }
.hero h1 { margin: 0; font-family: var(--hand); font-size: clamp(3.2rem, 11vw, 6.4rem); line-height: 1.05; font-weight: 400; text-shadow: 0 4px 24px rgba(0,0,0,.5); }
.by { margin: 14px 0 4px; font-size: 1.1rem; }
.note { margin: 0; font-size: .92rem; opacity: .85; }
.cta { margin-top: 30px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn {
  padding: 12px 24px; border-radius: 999px; background: #fffaf0; color: var(--ink);
  font-weight: 700; box-shadow: 0 8px 20px rgba(0,0,0,.3); transition: transform .15s;
}
.btn:hover { transform: translateY(-2px); }
.btn.ghost { background: transparent; color: #fff; border: 1.5px solid rgba(255,255,255,.8); box-shadow: none; }

.chips { position: sticky; top: 0; z-index: 20; background: rgba(244,236,221,.92); backdrop-filter: blur(8px); border-bottom: 1px solid rgba(0,0,0,.1); }
.chips div { display: flex; gap: 8px; padding: 10px 16px; overflow-x: auto; max-width: 1100px; margin: 0 auto; scrollbar-width: none; }
.chips a { flex: none; padding: 6px 16px; border-radius: 999px; background: #fff; border: 1px solid rgba(0,0,0,.12); font-size: .92rem; }
.chips a b { color: var(--accent); margin-right: .3em; }
.chips a:hover { background: var(--ink); color: #fff; }
.chips a:hover b { color: #ffd0c8; }
.chips .all { margin-left: auto; background: transparent; }

main { max-width: 1100px; margin: 0 auto; padding: 0 16px 60px; }
.part { padding-top: 70px; scroll-margin-top: 50px; }
.part-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; padding-bottom: 12px; border-bottom: 2px solid var(--ink); }
.part-head .pn { font-family: var(--hand); font-size: 2.2rem; color: var(--accent); }
.part-head h2 { margin: 0; font-family: var(--hand); font-size: 3.4rem; line-height: 1; font-weight: 400; }
.part-head .pe { font-family: var(--hand); font-size: 1.8rem; color: var(--ink-soft); }
.start { margin-left: auto; font-size: .9rem; color: var(--accent); font-weight: 700; }
.start:hover { text-decoration: underline; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 22px; }
.card {
  position: relative; display: flex; flex-direction: column;
  background: #fffaf0; padding: 10px 10px 14px; border: 1px solid var(--paper-edge);
  box-shadow: 0 6px 16px rgba(60,40,20,.18);
  transition: transform .2s, box-shadow .2s;
}
.card:nth-child(odd) { transform: rotate(-.8deg); }
.card:nth-child(even) { transform: rotate(.7deg); }
.card:hover { transform: translateY(-5px) rotate(0); box-shadow: 0 16px 28px rgba(60,40,20,.28); }
.thumb { display: block; aspect-ratio: 4 / 3; overflow: hidden; background: #ddd; }
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: 70% 50%; transition: transform .4s; }
.card:hover .thumb img { transform: scale(1.06); }
.card .no { margin: 10px 4px 0; font-size: .75rem; color: var(--accent); letter-spacing: .1em; }
.card .t { margin: 2px 4px 0; font-weight: 700; line-height: 1.45; word-break: keep-all; }

.toc { padding-top: 90px; }
.toc h2 { font-family: var(--hand); font-size: 3rem; font-weight: 400; margin: 0 0 14px; }
.toc-list { list-style: none; margin: 0; padding: 0; columns: 2 320px; column-gap: 40px; }
.toc-list > li { break-inside: avoid; margin-bottom: 22px; font-weight: 700; }
.toc-list > li > a:hover { color: var(--accent); }
.toc-list small { font-weight: 400; color: var(--ink-soft); }
.toc-list ol { list-style: none; margin: 6px 0 0; padding: 0; font-weight: 400; }
.toc-list ol a { display: block; padding: 3px 0; border-bottom: 1px dotted rgba(0,0,0,.2); }
.toc-list ol a:hover { color: var(--accent); }
.toc-list ol span { display: inline-block; width: 2em; color: var(--accent); font-size: .8rem; }

.foot { display: flex; align-items: center; justify-content: center; min-height: 48px; padding: 12px 16px; text-align: center; font-size: .82rem; line-height: 1.4; color: var(--ink-soft); background: #e9dfcb; }
.foot p { margin: 0; }

/* ---------- 모바일 ---------- */
@media (max-width: 640px) {
  .wall { padding-top: 68px; padding-bottom: 130px; }
  /* 모바일: 종이가 거의 불투명하니 무거운 배경 흐림은 끔 */
  .frame { padding: 36px 24px 26px; background: linear-gradient(rgba(255,250,240,.95), rgba(255,247,232,.95)); backdrop-filter: none; }
  .art { object-position: 78% 50%; }
  .nav { padding: 8px 12px; }
  .nav .nt { font-size: .86rem; }
  .pager { grid-template-columns: 1fr auto 1fr; }
  .bar .where { font-size: .82rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .frame { animation: none; }
}

/* 서시 부제 */
.frame .hanja { margin: -8px 0 6px; font-size: 1.5rem; letter-spacing: .2em; color: var(--ink); }
.frame .sub { margin: 0 0 18px; font-family: var(--hand); font-size: 1.45rem; line-height: 1.5; color: var(--ink-soft); }

/* 404 안내 페이지 */
.notfound .hero { min-height: 100vh; min-height: 100svh; }

/* ---------- 인쇄: 시 본문만 종이에 ---------- */
@media print {
  body, .index-page { background: #fff; }
  .art, .veil, .bar, .pager, .dots, .pin, .chips, .cta, .foot { display: none !important; }
  .wall { min-height: 0; padding: 0; display: block; }
  .frame { width: auto; padding: 0; border: 0; box-shadow: none; background: none; transform: none; animation: none; backdrop-filter: none; }
  .verse p { break-inside: avoid; font-size: 12pt; }
  .hero { min-height: 0; color: var(--ink); }
  .hero-in { padding: 0 0 20px; }
  .hero h1 { text-shadow: none; }
  .card { box-shadow: none; transform: none; break-inside: avoid; }
  a { color: inherit; }
}
