/* ──────────────────────────────────────────────────────────────
   Flipbook viewer - stiluri comune (tool page + viewer public)
   Font neutru intentionat: viewerul public nu poarta branding.
   ────────────────────────────────────────────────────────────── */

.fb-root {
  --fb-ui: #2b2b2d;
  --fb-ui-soft: #97999e;
  --fb-accent: #f2f2f3;
  --fb-stage-a: #f4f4f5;
  --fb-stage-b: #e2e3e6;
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: linear-gradient(180deg, var(--fb-stage-a), var(--fb-stage-b));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

.fb-root:fullscreen,
.fb-root:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
}

/* ── Zona de vizualizare ── */

.fb-viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: stretch;
}

.fb-stage {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: grab;
}

.fb-stage.is-grabbing { cursor: grabbing; }
.fb-stage.is-zoomed { cursor: move; }

.fb-zoomer {
  position: relative;
  transform-origin: 50% 50%;
  will-change: transform;
}

.fb-book {
  position: relative;
  perspective: 2800px;
  transform-style: preserve-3d;
}

/* ── Foi ── */

.fb-leaf {
  position: absolute;
  top: 0;
  left: 50%;
  width: 50%;
  height: 100%;
  transform-style: preserve-3d;
  transform-origin: left center;
}

.fb-book.is-single .fb-leaf {
  left: 0;
  width: 100%;
}

.fb-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #fff;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.19);
}

.fb-face.is-back { transform: rotateY(180deg); }

.fb-face.is-empty { background: #f3f3f4; box-shadow: none; }

.fb-face .fb-media {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
  -webkit-user-drag: none;
  user-select: none;
}

/* umbra fixa de la cotor */
.fb-gutter {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    to right,
    rgba(0, 0, 0, 0.20) 0%,
    rgba(0, 0, 0, 0.07) 2.5%,
    rgba(0, 0, 0, 0) 9%
  );
}

/* Verso-ul e rotit de doua ori (foaia -180, fata +180), deci marginea lui
   locala din stanga ajunge pe exterior si cea din dreapta la cotor.
   Umbrele lui trebuie oglindite, altfel coperta din spate primeste aceeasi
   umbra ca prima coperta in loc de inversul ei. */
.fb-face.is-back .fb-gutter {
  background: linear-gradient(
    to left,
    rgba(0, 0, 0, 0.20) 0%,
    rgba(0, 0, 0, 0.07) 2.5%,
    rgba(0, 0, 0, 0) 9%
  );
}

.fb-book.is-single .fb-gutter { display: none; }

/* umbra dinamica din timpul intoarcerii */
.fb-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(
    to right,
    rgba(0, 0, 0, 0.55) 0%,
    rgba(0, 0, 0, 0.28) 30%,
    rgba(0, 0, 0, 0.12) 70%,
    rgba(0, 0, 0, 0.04) 100%
  );
}

.fb-face.is-back .fb-shade {
  background: linear-gradient(
    to left,
    rgba(0, 0, 0, 0.55) 0%,
    rgba(0, 0, 0, 0.28) 30%,
    rgba(0, 0, 0, 0.12) 70%,
    rgba(0, 0, 0, 0.04) 100%
  );
}

/* ── Sageti ── */

.fb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
  width: 62px;
  height: 96px;
  border: 0;
  padding: 0;
  background: none;
  color: rgba(0, 0, 0, 0.24);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.18s, opacity 0.18s;
}

.fb-nav svg { width: 30px; height: 52px; display: block; }
.fb-nav:hover { color: rgba(0, 0, 0, 0.55); }
.fb-nav.is-prev { left: 4px; }
.fb-nav.is-next { right: 4px; }

.fb-nav[disabled] {
  opacity: 0.22;
  cursor: default;
  color: rgba(0, 0, 0, 0.24);
}

/* ── Bara de jos ── */

.fb-toolbar {
  position: relative;
  z-index: 30;
  flex: 0 0 auto;
  background: var(--fb-ui);
  color: #fff;
}

.fb-progress {
  position: relative;
  height: 7px;
  background: #57585c;
  cursor: pointer;
}

.fb-progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0;
  background: var(--fb-accent);
}

.fb-progress-knob {
  position: absolute;
  top: 50%;
  left: 0;
  width: 15px;
  height: 15px;
  margin-left: -7.5px;
  border-radius: 50%;
  background: #fff;
  transform: translateY(-50%);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

.fb-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
}

.fb-counter {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.2px;
  white-space: nowrap;
  min-width: 96px;
}

.fb-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.fb-btn {
  width: 42px;
  height: 42px;
  border: 0;
  padding: 0;
  border-radius: 8px;
  background: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.16s, opacity 0.16s;
}

.fb-btn svg { width: 23px; height: 23px; display: block; }
.fb-btn:hover { background: rgba(255, 255, 255, 0.13); }
.fb-btn[disabled] { opacity: 0.3; cursor: default; background: none; }
.fb-btn.is-on { background: rgba(255, 255, 255, 0.2); }

.fb-zoom-group {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: 8px;
}

.fb-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 132px;
  height: 7px;
  border-radius: 4px;
  background: #6d6f74;
  outline: none;
  cursor: pointer;
}

.fb-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #fff;
  border: 0;
  cursor: pointer;
}

.fb-slider::-moz-range-thumb {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #fff;
  border: 0;
  cursor: pointer;
}

/* ── Lightbox cu toate paginile ── */

.fb-thumbs {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: rgba(22, 22, 24, 0.94);
  display: none;
  flex-direction: column;
}

.fb-thumbs.is-open { display: flex; }

.fb-thumbs-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  color: #fff;
  font-size: 14px;
  letter-spacing: 0.3px;
}

.fb-thumbs-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 18px;
  padding: 4px 20px 28px;
}

.fb-thumb {
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.fb-thumb-frame {
  width: 100%;
  aspect-ratio: var(--fb-thumb-ratio, 0.707);
  background: #fff;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: outline-color 0.16s, transform 0.16s;
}

.fb-thumb:hover .fb-thumb-frame { transform: translateY(-3px); }
.fb-thumb.is-current .fb-thumb-frame { outline-color: #fff; }

.fb-thumb-frame .fb-media {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
}

.fb-thumb-num {
  color: #b9babd;
  font-size: 12px;
  letter-spacing: 0.4px;
}

.fb-thumb.is-current .fb-thumb-num { color: #fff; }

/* ── Stari ── */

.fb-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background: linear-gradient(180deg, var(--fb-stage-a), var(--fb-stage-b));
}

.fb-overlay.is-on { display: flex; }

.fb-spinner {
  width: 30px;
  height: 30px;
  border: 2px solid rgba(0, 0, 0, 0.16);
  border-top-color: rgba(0, 0, 0, 0.62);
  border-radius: 50%;
  animation: fb-spin 0.72s linear infinite;
}

@keyframes fb-spin { to { transform: rotate(360deg); } }

.fb-overlay-text {
  font-size: 15px;
  line-height: 1.5;
  color: #4a4a4d;
  max-width: 30rem;
  margin: 0;
}

.fb-overlay-title {
  font-size: 21px;
  font-weight: 600;
  color: #1d1d1f;
  margin: 0;
}

/* ── Mobil ── */

@media screen and (max-width: 767px) {
  .fb-nav { width: 40px; height: 74px; }
  .fb-nav svg { width: 20px; height: 38px; }
  .fb-nav.is-prev { left: 0; }
  .fb-nav.is-next { right: 0; }

  .fb-bar { padding: 9px 12px; gap: 8px; }
  .fb-counter { font-size: 15px; min-width: 0; }
  .fb-btn { width: 38px; height: 38px; }
  .fb-btn svg { width: 20px; height: 20px; }
  .fb-zoom-group { gap: 4px; margin-right: 2px; }
  .fb-slider { display: none; }
  .fb-thumbs-grid {
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 12px;
    padding: 4px 12px 20px;
  }
}
