/* Online reader (flipbook) used by content/flip_*.inc.php */

@font-face {
  font-family: 'Lexend';
  src: url('../fonts/Lexend-Regular.woff2') format('woff2'),
       url('../fonts/Lexend-Regular.ttf') format('truetype');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Lexend';
  src: url('../fonts/Lexend-Medium.woff2') format('woff2'),
       url('../fonts/Lexend-Medium.ttf') format('truetype');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Lexend';
  src: url('../fonts/Lexend-SemiBold.woff2') format('woff2'),
       url('../fonts/Lexend-SemiBold.ttf') format('truetype');
  font-weight: 600; font-style: normal; font-display: swap;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  background: #2d2d2d;
  font-family: 'Lexend', Arial, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Shell */
.fb-shell {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #2d2d2d;
}

/* Stage: arrows + book */
.fb-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  overflow: hidden;
}

/* Side arrows: always visible, greyed out at the first/last page */
.fb-arrow {
  flex: 0 0 64px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
}

.fb-arrow span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  font-size: 1.3rem;
  transition: background 0.2s ease, transform 0.2s ease;
}

.fb-arrow:hover span { background: rgba(255, 255, 255, 0.26); }
.fb-arrow:active span { transform: scale(0.94); }
.fb-arrow:focus-visible { outline: none; }
.fb-arrow:focus-visible span { outline: 2px solid #fff; outline-offset: 2px; }
.fb-arrow:disabled { cursor: default; }
.fb-arrow:disabled span { opacity: 0.25; background: rgba(255, 255, 255, 0.12); }

/* Viewport */
.fb-viewport {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  cursor: zoom-in;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: opacity 0.12s ease;
}

.fb-viewport.zoomed { cursor: grab; }
.fb-viewport.dragging { cursor: grabbing; }
.fb-viewport.swapping { opacity: 0; }

#flipbook {
  transform-origin: top left;
}

#flipbook.smooth {
  transition: transform 0.18s ease;
}

#flipbook .page { background: #fff; }
#flipbook .page:nth-child(odd)  { box-shadow: inset -8px 0 20px rgba(0,0,0,0.15); }
#flipbook .page:nth-child(even) { box-shadow: inset  8px 0 20px rgba(0,0,0,0.15); }

#flipbook img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  -webkit-user-drag: none;
  pointer-events: none;
}

/* Hint while zoomed */
.fb-hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.78rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 6;
}

.fb-hint.show { opacity: 1; }

/* Toolbar */
.fb-toolbar {
  flex-shrink: 0;
  height: 52px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 16px;
  background: #222;
  border-top: 1px solid rgba(255,255,255,0.06);
  gap: 12px;
}

.fb-page-num {
  color: rgba(255,255,255,0.75);
  font-size: 0.88em;
  font-weight: 500;
  letter-spacing: 0.3px;
  justify-self: start;
  white-space: nowrap;
}

.fb-zoom {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.07);
  border-radius: 6px;
  padding: 4px 6px;
}

.fb-zoom-btn,
.fb-icon-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.fb-zoom-btn { width: 30px; height: 30px; font-size: 1rem; }
.fb-icon-btn { width: 34px; height: 34px; font-size: 1.05rem; }

.fb-zoom-btn:hover,
.fb-icon-btn:hover { color: #fff; background: rgba(255,255,255,0.12); }

.fb-zoom-btn:disabled { opacity: 0.3; cursor: default; background: none; }

.fb-zoom-btn:focus-visible,
.fb-icon-btn:focus-visible,
.fb-zoom-level:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

.fb-zoom-level {
  background: none;
  border: 0;
  color: rgba(255,255,255,0.8);
  font: inherit;
  font-size: 0.82em;
  font-weight: 500;
  min-width: 46px;
  text-align: center;
  cursor: pointer;
  border-radius: 4px;
}

.fb-zoom-level:hover { color: #fff; }

.fb-toolbar-right {
  display: flex;
  justify-content: flex-end;
}

/* Fullscreen */
.fb-shell:fullscreen          { background: #2d2d2d; width: 100%; height: 100%; }
.fb-shell:-webkit-full-screen { background: #2d2d2d; width: 100%; height: 100%; }

/* Narrow screens: arrows float over the book so it gets the full width */
@media (max-width: 700px) {
  .fb-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    z-index: 5;
  }
  .fb-arrow span { width: 40px; height: 40px; background: rgba(0, 0, 0, 0.45); font-size: 1.15rem; }
  .fb-arrow:disabled { display: none; }
  #prev { left: 4px; }
  #next { right: 4px; }
  .fb-toolbar { padding: 0 10px; gap: 8px; }
}
