/* 넘겨 보기 — flipbook.js 와 한 벌. 색은 tokens.css 에서만 가져온다. */

html.fb-open, html.fb-open body { overflow: hidden; }

.fb {
  position: fixed; inset: 0; z-index: 80;
  display: flex; flex-direction: column;
  background: var(--bg); color: var(--fg);
  animation: fb-in .22s ease;
}
.fb.closing { animation: fb-out .22s ease forwards; }
@keyframes fb-in { from { opacity: 0; } }
@keyframes fb-out { to { opacity: 0; } }

/* 머리 */
.fb-top {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 8px;
}
.fb-ttl {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--font-display); font-size: 14px; color: var(--fg2);
}
.fb-close {
  flex: none; font: inherit; font-size: 12.5px; color: var(--fg2);
  background: none; border: 1px solid var(--rule); border-radius: 20px; padding: 6px 12px; cursor: pointer;
}
.fb-close:hover { color: var(--fg); border-color: var(--fg3); }
.fb-bar { flex: none; height: 2px; margin: 0 16px; background: var(--rule-soft); border-radius: 2px; overflow: hidden; }
.fb-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s ease; }

/* 무대 — 쪽들이 겹쳐 있고 지금 쪽만 보인다 */
.fb-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.fb-pg { position: absolute; inset: 0; visibility: hidden; background: var(--bg); }
.fb-pg.on { visibility: visible; z-index: 2; }

/* 두 박자 넘김 — 후도령 실측(10/3 프레임 측정)에 곡선을 맞춘 값: 나감·들어옴 각 .345s */
.fb-pg.leave-l { animation: fb-leave-l .345s cubic-bezier(.1,.1,.6,1) forwards; }
.fb-pg.leave-r { animation: fb-leave-r .345s cubic-bezier(.1,.1,.6,1) forwards; }
.fb-pg.enter-r { animation: fb-enter-r .345s cubic-bezier(.1,.1,.6,1) both; }
.fb-pg.enter-l { animation: fb-enter-l .345s cubic-bezier(.1,.1,.6,1) both; }
@keyframes fb-leave-l { to { transform: translateX(-100%); opacity: 0; } }
@keyframes fb-leave-r { to { transform: translateX(100%); opacity: 0; } }
@keyframes fb-enter-r { from { transform: translateX(100%); opacity: 0; } }
@keyframes fb-enter-l { from { transform: translateX(-100%); opacity: 0; } }

/* 글 쪽 — 쪽 안에서 세로로 읽는다 */
.fb-page .fb-in {
  height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 18px 16px 28px;
}
.fb-page .fb-in > * { max-width: 600px; margin-left: auto; margin-right: auto; }
.fb-page h2 {
  font-family: var(--font-display); font-weight: 700; font-size: 20px; line-height: 1.45;
  color: var(--fg); margin: 0 0 14px; text-wrap: balance;
}
.fb-page .sec-chip { display: table; margin-bottom: 8px; }
.fb .sec { opacity: 1; transform: none; animation: none; margin: 0; }
.fb .sec h2 { display: none; }
.fb .sec p { font-size: 15.5px; line-height: 1.9; margin: 0 0 1em; color: var(--fg); white-space: pre-wrap; }
.fb .chart { margin: 4px 0 8px; }

/* 신관 말풍선 */
.fb-say { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 18px; }
.fb-face {
  flex: none; width: 52px; height: 52px; border-radius: 50%;
  background: var(--surface-2) center 22% / 190% auto no-repeat;
  border: 1px solid var(--accent-dim);
}
.fb-bubble {
  position: relative; min-width: 0;
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: 14px 14px 14px 4px; padding: 9px 13px 10px;
  font-family: var(--font-display); font-size: 15px; line-height: 1.55; color: var(--fg);
}
.fb-bubble b {
  display: block; font-family: var(--font-body); font-weight: 500;
  font-size: 11px; color: var(--accent); margin-bottom: 2px;
}

/* 표지 · 갈래 · 맺음 — 신관 영상 위에 글 */
.fb-bg { position: absolute; inset: 0; overflow: hidden; background: var(--bg); }
.fb-bg video, .fb-bg img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fb-shade {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(16,14,12,.15) 0%, rgba(16,14,12,.1) 38%, rgba(16,14,12,.82) 72%, var(--bg) 100%);
}
.fb-cover-in, .fb-part-in {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 0 24px calc(34px + var(--safe-b));
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px;
}
.fb-cover h1, .fb-cover h2, .fb-part h2 {
  font-family: var(--font-display); font-weight: 700; color: var(--fg);
  margin: 0; text-wrap: balance; text-shadow: 0 2px 18px rgba(0,0,0,.6);
}
.fb-cover h1 { font-size: 28px; line-height: 1.3; }
.fb-cover h2, .fb-part h2 { font-size: 24px; line-height: 1.35; }
.fb-part-in { bottom: 18%; }
.fb-kicker {
  margin: 0; font-size: 12px; color: var(--accent);
  border: 1px solid var(--accent-dim); border-radius: 20px; padding: 2px 10px;
  background: rgba(16,14,12,.5);
}
.fb-who { margin: 0; font-size: 15px; color: var(--fg); }
.fb-meta { margin: 0; font-size: 13px; color: var(--fg2); }
.fb-hint { margin: 2px 0 0; font-size: 12px; color: var(--fg3); }
.fb-go {
  margin-top: 12px; width: 100%; max-width: 320px;
  font: inherit; font-size: 15.5px; font-weight: 600;
  color: var(--on-accent); background: var(--accent);
  border: 0; border-radius: 12px; padding: 14px 18px; cursor: pointer;
}
.fb-go:active { background: var(--accent-hi); }
.fb-ghost {
  width: 100%; max-width: 320px; font: inherit; font-size: 14px; color: var(--fg2);
  background: none; border: 1px solid var(--rule); border-radius: 12px; padding: 12px 18px; cursor: pointer;
}

/* 아래 넘김 막대 */
.fb-nav {
  flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px;
  padding: 10px 16px calc(10px + var(--safe-b));
  border-top: 1px solid var(--rule-soft); background: var(--bg);
}
.fb-nav button {
  font: inherit; font-size: 14px; color: var(--fg);
  background: var(--surface); border: 1px solid var(--rule); border-radius: 10px;
  padding: 11px 0; cursor: pointer;
}
.fb-nav .fb-next { color: var(--on-accent); background: var(--accent); border-color: var(--accent); font-weight: 600; }
.fb-nav button:disabled { opacity: .35; cursor: default; }
.fb-count {
  min-width: 5.5em; text-align: center; font-size: 13px; color: var(--fg2);
  font-variant-numeric: tabular-nums;
}

/* 펼쳐 보기 화면에 꽂는 버튼 */
.fb-open-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; margin: 4px 0 18px;
  font: inherit; font-size: 15px; font-weight: 600;
  color: var(--on-accent); background: var(--accent);
  border: 0; border-radius: 12px; padding: 13px 16px; cursor: pointer;
}
.fb-open-ico {
  width: 16px; height: 12px; flex: none; position: relative;
  border: 1.5px solid currentColor; border-radius: 2px;
}
.fb-open-ico::after {
  content: ""; position: absolute; left: 50%; top: -1px; bottom: -1px; width: 1.5px;
  background: currentColor; transform: translateX(-50%);
}

@media (min-width: 760px) {
  .fb-page h2 { font-size: 22px; }
  .fb-cover h1 { font-size: 34px; }
  .fb-nav { max-width: 640px; width: 100%; margin: 0 auto; border-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .fb, .fb.closing, .fb-pg.leave-l, .fb-pg.leave-r, .fb-pg.enter-r, .fb-pg.enter-l { animation: none; }
  .fb-bar i { transition: none; }
}
