/* 플립북 뷰어. 모든 규칙은 .fb 안에서만 적용된다.
 * 디자인: .theme-classic(기본) .theme-theater(극장) .theme-minimal(깔끔) .theme-festival(포스터) */
.fb {
  --fb-accent: #2f5d50;
  --fb-on-accent: #ffffff;
  --fb-bg: #e9e6df; --fb-stage: #d9d4c9; --fb-fg: #23211d; --fb-muted: #6b665c;
  --fb-btn-bg: var(--fb-accent); --fb-btn-fg: var(--fb-on-accent); --fb-btn-border: transparent;
  --fb-font: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  background: var(--fb-bg); color: var(--fb-fg); font-family: var(--fb-font);
  display: flex; flex-direction: column; box-sizing: border-box; position: relative;
}
.fb *, .fb *::before, .fb *::after { box-sizing: border-box; }
.fb [hidden] { display: none !important; }
@media (prefers-color-scheme: dark) {
  .fb.theme-classic { --fb-bg: #1b1d1c; --fb-stage: #252826; --fb-fg: #e8e5dd; --fb-muted: #a29d92; color-scheme: dark; }
  .fb.theme-minimal { --fb-bg: #151616; --fb-fg: #ececec; --fb-muted: #9a9a9a; color-scheme: dark; }
}
.fb.theme-theater {
  --fb-bg: #0f0e0d; --fb-stage: transparent; --fb-fg: #eee8dc; --fb-muted: #a79f90;
  --fb-btn-bg: transparent; --fb-btn-fg: #eee8dc; --fb-btn-border: rgba(238,232,220,.35);
  background: radial-gradient(ellipse at 50% 35%, #3a332b 0%, #171512 55%, #0b0a09 100%);
  color-scheme: dark;
}
.fb.theme-minimal {
  --fb-bg: #ffffff; --fb-stage: transparent; --fb-fg: #1a1a1a; --fb-muted: #777;
  --fb-btn-bg: transparent; --fb-btn-fg: var(--fb-fg); --fb-btn-border: transparent;
}
.fb.theme-festival {
  --fb-bg: var(--fb-accent); --fb-stage: transparent; --fb-fg: var(--fb-on-accent); --fb-muted: var(--fb-on-accent);
  --fb-btn-bg: var(--fb-on-accent); --fb-btn-fg: var(--fb-accent); --fb-btn-border: transparent;
}

.fb-bar { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 14px max(16px, env(safe-area-inset-left)); }
.fb-title { font-size: 1rem; font-weight: 600; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fb-pdf { color: inherit; font-size: .9rem; white-space: nowrap; opacity: .85; }
.theme-theater .fb-bar { justify-content: center; padding-top: 22px; }
.theme-theater .fb-title { font-weight: 400; letter-spacing: .12em; font-size: .95rem; }
.theme-theater .fb-pdf { position: absolute; right: 16px; }
.theme-minimal .fb-bar { border-bottom: 1px solid rgba(128,128,128,.2); }
.theme-festival .fb-bar { padding-top: 22px; }
.theme-festival .fb-title { font-size: clamp(1.2rem, 3.2vw, 1.9rem); font-weight: 800; letter-spacing: -.01em; white-space: normal; }

.fb-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 0 16px 24px; position: relative; }
.fb-stage { width: 100%; max-width: 1200px; background: var(--fb-stage); border-radius: 6px; padding: 24px 16px; }
.theme-theater .fb-stage, .theme-minimal .fb-stage, .theme-festival .fb-stage { padding: 12px 0; }
.fb-book { margin: 0 auto; }
.fb-page { background: #fff; overflow: hidden; }
.fb-page img { width: 100%; height: 100%; object-fit: contain; display: block; user-select: none; -webkit-user-drag: none; }
.theme-theater .fb-book { filter: drop-shadow(0 18px 40px rgba(0,0,0,.6)); }
.theme-festival .fb-book { filter: drop-shadow(0 10px 24px rgba(0,0,0,.25)); }

.fb-controls { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; }
.fb-controls button, .fb-controls a {
  font: inherit; font-size: .9rem; padding: 8px 14px; border-radius: 4px; cursor: pointer; text-decoration: none;
  background: var(--fb-btn-bg); color: var(--fb-btn-fg); border: 1px solid var(--fb-btn-border);
}
.theme-theater .fb-controls button, .theme-theater .fb-controls a { border-radius: 999px; }
.theme-minimal .fb-controls button, .theme-minimal .fb-controls a { padding: 6px 10px; }
.theme-minimal .fb-controls button:hover { background: rgba(128,128,128,.12); }
.theme-festival .fb-controls button, .theme-festival .fb-controls a { font-weight: 700; border-radius: 999px; }
.fb-controls button:disabled { opacity: .35; cursor: default; }
.fb-controls button:focus-visible, .fb-controls a:focus-visible { outline: 2px solid var(--fb-fg); outline-offset: 2px; }
.fb-counter { min-width: 8ch; text-align: center; color: var(--fb-muted); font-variant-numeric: tabular-nums; }

.fb-thumbs { width: 100%; max-width: 1200px; display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 10px; }
.fb-thumbs button { border: 2px solid transparent; padding: 0; background: none; cursor: pointer; border-radius: 3px; color: inherit; font: inherit; }
.fb-thumbs button[aria-current="true"] { border-color: var(--fb-accent); }
.theme-festival .fb-thumbs button[aria-current="true"] { border-color: var(--fb-on-accent); }
.fb-thumbs img { width: 100%; display: block; }
.fb-thumbs span { display: block; font-size: .75rem; color: var(--fb-muted); padding: 2px 0; }
/* 깔끔: 목차가 늘 아래 띠로 보임 */
.fb.theme-minimal .fb-thumbs, .fb.theme-minimal .fb-thumbs[hidden] { display: flex !important; overflow-x: auto; gap: 8px; padding-bottom: 4px; }
.fb.theme-minimal .fb-thumbs button { flex: 0 0 64px; }
.fb.theme-minimal .fb-toggle { display: none; }

/* 홈페이지 안에 넣었을 때 (?embed=1) */
.fb.is-embed .fb-bar { display: none; }
.fb.is-embed .fb-main { padding: 8px 8px 12px; gap: 10px; }
.fb.is-embed .fb-stage { padding: 12px 8px; border-radius: 0; }

.fb:fullscreen { justify-content: center; }
.fb:fullscreen .fb-stage { max-width: none; background: transparent; }
.theme-minimal .fb-book { filter: drop-shadow(0 1px 8px rgba(0,0,0,.14)); }
.fb.theme-minimal .fb-thumbs { justify-content: safe center; }
