/* ============================================================
   FlipStudio — Shared Flipbook Engine (viewer styles)
   Used identically in Studio preview and in exported books.
   Theme is driven by CSS variables set from the manifest.
   ============================================================ */

.fb-root {
  --fb-accent: #c9a24b;
  --fb-accent-soft: rgba(201,162,75,0.15);
  --fb-bg: #0d0e12;
  --fb-bg2: #171921;
  --fb-text: #f4f4f6;
  --fb-muted: rgba(244,244,246,0.55);
  --fb-glass: rgba(255,255,255,0.05);
  --fb-glass-brd: rgba(255,255,255,0.11);
  --fb-shadow: 0 30px 80px rgba(0,0,0,0.55);
  --fb-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  position: relative; width: 100%; height: 100%; min-height: 100%;
  display: flex; flex-direction: column;
  font-family: var(--fb-font); color: var(--fb-text);
  background: radial-gradient(120% 120% at 50% 0%, var(--fb-bg2) 0%, var(--fb-bg) 60%);
  overflow: hidden; -webkit-tap-highlight-color: transparent; user-select: none;
}
.fb-root *, .fb-root *::before, .fb-root *::after { box-sizing: border-box; }

/* ── Top bar ─────────────────────────────────────────────── */
.fb-bar {
  position: relative; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  height: 54px; padding: 0 14px; flex-shrink: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.5), transparent);
}
.fb-title {
  font-size: 13px; letter-spacing: 2.5px; text-transform: uppercase;
  color: var(--fb-accent); font-weight: 500; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 40%;
}
.fb-bar-spacer { flex: 1; }
.fb-tools { display: flex; align-items: center; gap: 5px; }
.fb-sep { width: 1px; height: 22px; background: var(--fb-glass-brd); margin: 0 4px; }

.fb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; min-width: 36px; padding: 0 9px;
  border: 1px solid transparent; background: transparent; color: var(--fb-text);
  border-radius: 9px; cursor: pointer; font: inherit; font-size: 12.5px; letter-spacing: .3px;
  transition: background .16s, border-color .16s, transform .1s, color .16s;
}
.fb-btn:hover { background: var(--fb-accent-soft); color: var(--fb-accent); }
.fb-btn:active { transform: scale(.93); }
.fb-btn svg { width: 18px; height: 18px; display: block; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.fb-btn.fb-on { color: var(--fb-accent); background: var(--fb-accent-soft); }
.fb-btn[hidden] { display: none; }
.fb-btn .fb-btn-lbl { font-size: 12.5px; }

.fb-logo { height: 30px; width: auto; max-width: 150px; object-fit: contain; margin-right: 4px; }
.fb-hasbg .fb-stage { background: var(--fb-bgimage) center/cover no-repeat; }
.fb-hasbg .fb-stage::after { background: rgba(0,0,0,0.45); }

/* ── Interactive hotspots (rendered per page via loadFromHTML) ── */
.fb-pg { position: relative; width: 100%; height: 100%; background: #fff; overflow: hidden; }
.fb-hotspot { position: absolute; display: block; border-radius: 3px; background: transparent; cursor: pointer; transition: background .15s, box-shadow .15s; }
.fb-hotspot:hover { background: rgba(79,142,247,0.22); box-shadow: 0 0 0 2px var(--fb-accent) inset; }
.fb-hotspot[data-type="video"]::after, .fb-hotspot[data-type="image"]::after { content: ""; position: absolute; inset: 0; background: rgba(0,0,0,0.28) center/26px no-repeat; opacity: 0; transition: opacity .15s; }
.fb-hotspot:hover::after { opacity: 1; }

/* ── Media lightbox (video/image/text popup) ─────────────── */
.fb-media { position: absolute; inset: 0; z-index: 72; background: rgba(0,0,0,0.9); display: none; align-items: center; justify-content: center; padding: 4vmin; }
.fb-media.fb-open { display: flex; }
.fb-media-box { max-width: 90%; max-height: 90%; display: flex; }
.fb-media-box iframe, .fb-media-box video, .fb-media-box img { max-width: 88vw; max-height: 84vh; width: auto; height: auto; border-radius: 10px; background: #000; }
.fb-media-box iframe { width: 80vw; height: 45vw; max-height: 84vh; }
.fb-textpop { background: var(--fb-bg2); color: var(--fb-text); padding: 26px 30px; border-radius: 12px; max-width: 560px; font-size: 15px; line-height: 1.6; max-height: 80vh; overflow-y: auto; }
.fb-media-close { position: absolute; top: 16px; right: 16px; border: 1px solid var(--fb-glass-brd) !important; }

/* reduced motion */
.fb-reduced .fb-book { filter: none; }

/* ── Stage ───────────────────────────────────────────────── */
.fb-stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 12px 58px 14px; }
.fb-stage::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(120% 100% at 50% 42%, transparent 55%, rgba(0,0,0,0.35) 100%); }
.fb-book { filter: drop-shadow(var(--fb-shadow)); touch-action: pan-y; position: relative; z-index: 1; }
.fb-book .stf__item { background: #fff; }
/* soft center gutter so a two-page spread reads like a real book */
.fb-book.fb-spread::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 44px; transform: translateX(-50%); z-index: 5; pointer-events: none; background: linear-gradient(90deg, transparent, rgba(0,0,0,0.22) 44%, rgba(0,0,0,0.28) 50%, rgba(0,0,0,0.22) 56%, transparent); }
.fb-page-img { width: 100%; height: 100%; object-fit: cover; display: block; background: #fff; }

.fb-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 30;
  width: 46px; height: 68px; border-radius: 12px;
  border: 1px solid var(--fb-glass-brd); background: rgba(0,0,0,0.34); backdrop-filter: blur(6px);
  color: var(--fb-text); cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .18s, opacity .18s, transform .1s;
}
.fb-nav:hover { background: var(--fb-accent); color: #111; }
.fb-nav:active { transform: translateY(-50%) scale(.92); }
.fb-nav[disabled] { opacity: .22; pointer-events: none; }
.fb-nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fb-prev { left: 8px; } .fb-next { right: 8px; }

/* ── Bottom bar (nav, FlipHTML5-style) ───────────────────── */
.fb-foot {
  position: relative; z-index: 40; display: flex; align-items: center; justify-content: center; gap: 10px;
  height: 52px; padding: 0 18px; flex-shrink: 0;
  background: linear-gradient(0deg, rgba(0,0,0,0.5), transparent);
}
.fb-foot .fb-btn { height: 32px; min-width: 32px; padding: 0 7px; }
.fb-foot .fb-btn svg { width: 16px; height: 16px; }
.fb-slider {
  flex: 1; max-width: 460px; height: 4px; border-radius: 4px; appearance: none; -webkit-appearance: none;
  background: var(--fb-glass-brd); cursor: pointer; outline: none;
}
.fb-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--fb-accent); border: 2px solid var(--fb-bg); cursor: pointer; }
.fb-slider::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--fb-accent); border: 2px solid var(--fb-bg); cursor: pointer; }
.fb-pagebox { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--fb-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fb-pagebox input {
  width: 44px; height: 30px; text-align: center; border: 1px solid var(--fb-glass-brd);
  background: var(--fb-glass); color: var(--fb-text); border-radius: 8px; font: inherit; font-size: 12.5px; outline: none;
}
.fb-pagebox input:focus { border-color: var(--fb-accent); }

/* ── Overlay panels ──────────────────────────────────────── */
.fb-panel { position: absolute; inset: 0; z-index: 60; display: flex; flex-direction: column; background: rgba(8,9,12,0.9); backdrop-filter: blur(14px); opacity: 0; pointer-events: none; transition: opacity .22s; }
.fb-panel.fb-open { opacity: 1; pointer-events: auto; }
.fb-panel-head { display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 18px; flex-shrink: 0; border-bottom: 1px solid var(--fb-glass-brd); }
.fb-panel-head h3 { font-size: 13px; letter-spacing: 2px; text-transform: uppercase; font-weight: 600; color: var(--fb-accent); }
.fb-panel-body { flex: 1; overflow-y: auto; padding: 16px 18px 28px; }
.fb-panel-head .fb-btn { border: 1px solid var(--fb-glass-brd); }
.fb-search-input { flex: 1; height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--fb-glass-brd); background: var(--fb-glass); color: var(--fb-text); font: inherit; font-size: 14px; outline: none; }
.fb-search-input:focus { border-color: var(--fb-accent); }

.fb-toc-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 14px; margin-bottom: 6px; border-radius: 10px; background: var(--fb-glass); border: 1px solid transparent; color: var(--fb-text); cursor: pointer; font: inherit; font-size: 14px; transition: background .15s, border-color .15s; }
.fb-toc-item:hover { border-color: var(--fb-accent); background: var(--fb-accent-soft); }
.fb-toc-item .fb-toc-pg { margin-left: auto; color: var(--fb-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.fb-toc-item[data-depth="1"] { margin-left: 18px; font-size: 13px; opacity: .9; }
.fb-toc-item[data-depth="2"] { margin-left: 36px; font-size: 12.5px; opacity: .8; }
.fb-del { margin-left: auto; opacity: .5; }
.fb-del:hover { opacity: 1; color: #e06a5a; }

.fb-hit { padding: 12px 14px; margin-bottom: 8px; border-radius: 10px; background: var(--fb-glass); cursor: pointer; border: 1px solid transparent; transition: border-color .15s; }
.fb-hit:hover { border-color: var(--fb-accent); }
.fb-hit-pg { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--fb-accent); margin-bottom: 4px; }
.fb-hit-txt { font-size: 13px; color: var(--fb-muted); line-height: 1.5; }
.fb-hit-txt mark { background: var(--fb-accent); color: #111; border-radius: 3px; padding: 0 2px; }
.fb-empty { color: var(--fb-muted); font-size: 14px; text-align: center; padding: 40px 0; }

.fb-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 14px; }
.fb-thumb { position: relative; cursor: pointer; border-radius: 8px; overflow: hidden; border: 2px solid transparent; background: #222; aspect-ratio: 3/4; transition: border-color .15s, transform .12s; }
.fb-thumb:hover { transform: translateY(-3px); border-color: var(--fb-accent); }
.fb-thumb.fb-cur { border-color: var(--fb-accent); }
.fb-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fb-thumb span { position: absolute; left: 0; bottom: 0; right: 0; font-size: 11px; padding: 3px 6px; background: linear-gradient(0deg, rgba(0,0,0,.8), transparent); color: #fff; text-align: center; }

/* ── Share popover ───────────────────────────────────────── */
.fb-pop { position: absolute; z-index: 75; top: 58px; right: 12px; width: 290px; background: var(--fb-bg2); border: 1px solid var(--fb-glass-brd); border-radius: 14px; box-shadow: 0 24px 60px rgba(0,0,0,.6); padding: 16px; opacity: 0; transform: translateY(-8px); pointer-events: none; transition: opacity .18s, transform .18s; }
.fb-pop.fb-open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.fb-pop h4 { font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--fb-muted); margin-bottom: 10px; font-weight: 600; }
.fb-share-row { display: flex; gap: 8px; margin-bottom: 14px; }
.fb-share-row a { flex: 1; height: 40px; border-radius: 9px; display: flex; align-items: center; justify-content: center; background: var(--fb-glass); border: 1px solid var(--fb-glass-brd); color: var(--fb-text); text-decoration: none; transition: .15s; }
.fb-share-row a:hover { border-color: var(--fb-accent); color: var(--fb-accent); }
.fb-share-row svg { width: 18px; height: 18px; fill: currentColor; }
.fb-copy { display: flex; gap: 6px; margin-bottom: 12px; }
.fb-copy input { flex: 1; height: 36px; padding: 0 10px; border: 1px solid var(--fb-glass-brd); background: var(--fb-glass); color: var(--fb-text); border-radius: 8px; font: inherit; font-size: 12px; outline: none; }
.fb-copy button { height: 36px; padding: 0 12px; border: none; border-radius: 8px; background: var(--fb-accent); color: #111; font: inherit; font-weight: 600; font-size: 12px; cursor: pointer; }
.fb-qr { display: flex; justify-content: center; padding: 10px; background: #fff; border-radius: 10px; }
.fb-qr img, .fb-qr canvas { width: 150px; height: 150px; image-rendering: pixelated; }

/* zoom */
.fb-zoom { position: absolute; inset: 0; z-index: 70; background: rgba(0,0,0,.93); display: none; align-items: center; justify-content: center; overflow: hidden; }
.fb-zoom.fb-open { display: flex; }
.fb-zoom img { max-width: none; transform-origin: center; will-change: transform; cursor: grab; }
.fb-zoom-close { position: absolute; top: 16px; right: 16px; z-index: 2; }

/* loader / toast */
.fb-loader { position: absolute; inset: 0; z-index: 90; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; background: var(--fb-bg); transition: opacity .4s; }
.fb-loader.fb-hide { opacity: 0; pointer-events: none; }
.fb-spin { width: 40px; height: 40px; border: 3px solid var(--fb-glass-brd); border-top-color: var(--fb-accent); border-radius: 50%; animation: fb-rot .8s linear infinite; }
.fb-loader-txt { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--fb-muted); }
@keyframes fb-rot { to { transform: rotate(360deg); } }
.fb-toast { position: absolute; left: 50%; bottom: 74px; transform: translateX(-50%) translateY(12px); z-index: 80; background: rgba(0,0,0,.88); border: 1px solid var(--fb-glass-brd); color: var(--fb-text); font-size: 12.5px; padding: 9px 16px; border-radius: 20px; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
.fb-toast.fb-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* print */
.fb-print { display: none; }
@media print {
  .fb-bar, .fb-foot, .fb-nav, .fb-panel, .fb-loader, .fb-pop, .fb-book, .fb-stage { display: none !important; }
  .fb-print { display: block !important; }
  .fb-print img { width: 100%; page-break-after: always; display: block; }
  .fb-root { background: #fff !important; }
}

/* mobile */
@media (max-width: 700px) {
  .fb-stage { padding: 6px 8px; }
  .fb-nav { display: none; }
  .fb-title { font-size: 11px; letter-spacing: 1.5px; max-width: 34%; }
  .fb-btn .fb-btn-lbl { display: none; }
  .fb-sep { display: none; }
  .fb-tools { gap: 2px; }
  .fb-foot { gap: 6px; padding: 0 8px; }
}
