/*!
 * FlipBook.js のスタイル
 * このファイルは flipbook.js と対で読み込んでください。
 */

.fb-container {
  --fb-bg: #2b2f36;
  --fb-page-bg: #ffffff;
  --fb-ink: #1c1f24;
  --fb-muted: #8b93a1;
  --fb-accent: #3b6fe0;
  --fb-panel-bg: #ffffff;
  --fb-border: rgba(0, 0, 0, 0.12);
  --fb-shadow: rgba(0, 0, 0, 0.35);

  position: relative;
  width: 100%;
  height: 100%;
  min-height: 320px;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Segoe UI", Roboto, sans-serif;
  color: var(--fb-ink);
}

@media (prefers-color-scheme: dark) {
  .fb-container {
    --fb-bg: #14161a;
    --fb-page-bg: #f4f2ec;
    --fb-ink: #eef0f3;
    --fb-muted: #8b93a1;
    --fb-accent: #6c9bff;
    --fb-panel-bg: #1f2229;
    --fb-border: rgba(255, 255, 255, 0.12);
    --fb-shadow: rgba(0, 0, 0, 0.6);
  }
}

.fb-container * { box-sizing: border-box; }

.fb-root {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: var(--fb-bg);
  border-radius: 10px;
  overflow: hidden;
  outline: none;
}

.fb-viewport {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  cursor: grab;
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.04) 0%, rgba(0, 0, 0, 0.08) 100%);
}
.fb-viewport.fb-zoomed { cursor: grab; }

.fb-zoom-layer {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  will-change: transform;
}

.fb-book {
  position: relative;
  perspective: 2200px;
  margin: auto;
  filter: drop-shadow(0 18px 34px var(--fb-shadow));
}

.fb-slot {
  position: absolute;
  top: 0;
  height: 100%;
  background: var(--fb-page-bg);
  overflow: hidden;
}
.fb-slot-left { border-radius: 6px 0 0 6px; box-shadow: inset -6px 0 18px -12px rgba(0,0,0,0.45); }
.fb-slot-right { border-radius: 0 6px 6px 0; box-shadow: inset 6px 0 18px -12px rgba(0,0,0,0.45); }
.fb-mode-single .fb-slot-right { border-radius: 6px; box-shadow: none; }

.fb-page-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--fb-page-bg);
  user-select: none;
  -webkit-user-drag: none;
}

.fb-html-page {
  width: 100%;
  height: 100%;
  overflow: auto;
  background: var(--fb-page-bg);
  padding: 6% 7%;
  font-size: 14px;
  line-height: 1.7;
}

.fb-leaf-layer {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  pointer-events: none;
}

.fb-leaf {
  position: absolute;
  top: 0;
  transform-style: preserve-3d;
  will-change: transform;
  z-index: 5;
}

.fb-leaf-face {
  position: absolute;
  inset: 0;
  background: var(--fb-page-bg);
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.fb-leaf-back { transform: rotateY(180deg); }

.fb-leaf-face::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(0,0,0,0.18), rgba(0,0,0,0) 18%, rgba(0,0,0,0) 82%, rgba(0,0,0,0.18));
}

.fb-edge {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 18%;
  min-width: 32px;
  background: transparent;
  border: none;
  cursor: pointer;
  z-index: 6;
  opacity: 0;
  transition: opacity 0.15s ease;
  color: #fff;
  font-size: 28px;
}
.fb-edge:hover { opacity: 0.85; background: linear-gradient(90deg, rgba(0,0,0,0.12), transparent); }
.fb-edge-prev { left: 0; }
.fb-edge-next { right: 0; background: linear-gradient(270deg, transparent, transparent); }
.fb-edge-next:hover { background: linear-gradient(270deg, rgba(0,0,0,0.12), transparent); }

.fb-loading, .fb-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #cfd4dc;
  background: var(--fb-bg);
  z-index: 10;
  font-size: 14px;
  text-align: center;
  padding: 24px;
}
.fb-error { color: #ffb4b4; display: none; }

.fb-spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  animation: fb-spin 0.8s linear infinite;
}
@keyframes fb-spin { to { transform: rotate(360deg); } }

.fb-toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  background: rgba(0,0,0,0.25);
  flex-wrap: wrap;
}

.fb-btn {
  appearance: none;
  border: none;
  background: rgba(255,255,255,0.08);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.fb-btn:hover { background: rgba(255,255,255,0.18); }
.fb-btn:active { background: rgba(255,255,255,0.28); }

.fb-page-indicator {
  display: inline-flex;
  align-items: center;
  color: #fff;
  font-size: 13px;
  margin: 0 6px;
  gap: 2px;
}
.fb-page-input {
  width: 46px;
  text-align: center;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  color: #fff;
  padding: 6px 4px;
  font-size: 13px;
}
.fb-page-total { white-space: nowrap; }

.fb-zoom-level {
  color: #fff;
  font-size: 12px;
  min-width: 42px;
  text-align: center;
}

.fb-toolbar-sep {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,0.2);
  margin: 0 4px;
}

.fb-toc-panel {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(320px, 82%);
  background: var(--fb-panel-bg);
  color: var(--fb-ink);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 20;
  display: flex;
  flex-direction: column;
  box-shadow: -12px 0 30px rgba(0,0,0,0.25);
}
.fb-toc-panel.fb-open { transform: translateX(0); }

.fb-toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  font-weight: 600;
  border-bottom: 1px solid var(--fb-border);
}
.fb-toc-close {
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: var(--fb-muted);
  line-height: 1;
}

.fb-toc-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 6px 0;
}
.fb-toc-item {
  padding: 10px 16px;
  font-size: 13.5px;
  cursor: pointer;
  border-bottom: 1px solid var(--fb-border);
}
.fb-toc-item:hover { background: rgba(59, 111, 224, 0.08); color: var(--fb-accent); }

/* --- レスポンシブ --- */
@media (max-width: 760px) {
  .fb-toolbar { gap: 2px; padding: 6px 6px; }
  .fb-btn { width: 30px; height: 30px; font-size: 13px; }
  .fb-page-input { width: 38px; }
  .fb-toolbar-sep { display: none; }
}

/* ============================================================
 * モーダルビュアー
 * data-flipbook-open や FlipBook.openModal() で開く、
 * クリックした本だけを表示する全画面オーバーレイのスタイル
 * ============================================================ */
body.fb-modal-open { overflow: hidden; }

.fb-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 11, 14, 0.72);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4vh 4vw;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}
.fb-modal-overlay.fb-open {
  opacity: 1;
  pointer-events: auto;
}

.fb-modal-panel {
  position: relative;
  width: min(1100px, 100%);
  height: 100%;
  max-height: 92vh;
  background: #1b1d21;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  transform: scale(0.97);
  transition: transform 0.18s ease;
}
.fb-modal-overlay.fb-open .fb-modal-panel { transform: scale(1); }

.fb-modal-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  color: #eee;
  font-size: 14px;
  font-weight: 600;
  min-height: 20px;
}
.fb-modal-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fb-modal-close {
  appearance: none;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
  margin-left: 12px;
}
.fb-modal-close:hover { background: rgba(255, 255, 255, 0.18); }

.fb-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
}
.fb-modal-inner { width: 100%; height: 100%; }

/* data-flipbook-open で指定した要素（サムネイル等）のための最低限の見た目補助 */
[data-flipbook-open] { outline-offset: 3px; }
[data-flipbook-open]:focus-visible { outline: 2px solid var(--fb-accent, #3b6fe0); }

@media (max-width: 760px) {
  .fb-modal-overlay { padding: 0; }
  .fb-modal-panel { border-radius: 0; max-height: 100vh; }
}
