/* ============================================================
   SIBA CATALOG FLIPBOOK VIEWER — viewer.css
   Bağımsız, Bootstrap'a bağımlı değil.
   Vurgu rengi: #0d67c3 (Fluidra mavisi)
   ============================================================ */

/* ---- OVERLAY ---- */
#cv-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(10, 10, 18, 0.94);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#cv-overlay.cv-active {
  opacity: 1;
  pointer-events: all;
}

/* ---- HEADER BAR ---- */
#cv-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: linear-gradient(135deg, #0d67c3 0%, #0a4f9a 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
  z-index: 2;
  gap: 12px;
}

#cv-title {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 220px);
  letter-spacing: 0.02em;
}

#cv-header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ---- GENERIC BUTTON ---- */
.cv-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  padding: 5px 11px;
  cursor: pointer;
  transition: background 0.18s, transform 0.1s;
  user-select: none;
  white-space: nowrap;
  height: 34px;
}

.cv-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

.cv-btn:active {
  transform: scale(0.95);
}

.cv-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.cv-btn svg {
  flex-shrink: 0;
}

/* Close button special */
#cv-close-btn {
  background: rgba(220, 50, 50, 0.25);
  border-color: rgba(220, 50, 50, 0.45);
}

#cv-close-btn:hover {
  background: rgba(220, 50, 50, 0.55);
}

/* ---- BOOK STAGE ---- */
#cv-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 64px 12px 72px;
  box-sizing: border-box;
  overflow: hidden;
}

/* Zoom > 1: scroll modunu aç, taşan içerik kaydırılabilsin */
#cv-stage.cv-zoomed {
  overflow: auto;
  align-items: safe center;
  justify-content: safe center;
}

/* ---- BOOK CONTAINER ---- */
#cv-book {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Width/height set by JS based on page size */
}

/* ---- SPREAD (two pages side by side) ---- */
#cv-spread {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 0;
  perspective: 2200px;
  position: relative;
}

/* ---- PAGE WRAPPER ---- */
.cv-page-slot {
  position: relative;
  overflow: hidden;
  background: #fff;
  flex-shrink: 0;
}

.cv-page-slot.cv-left {
  border-radius: 4px 0 0 4px;
  box-shadow: -4px 4px 24px rgba(0, 0, 0, 0.55),
              inset -2px 0 6px rgba(0, 0, 0, 0.12);
}

.cv-page-slot.cv-right {
  border-radius: 0 4px 4px 0;
  box-shadow: 4px 4px 24px rgba(0, 0, 0, 0.55),
              inset 2px 0 6px rgba(0, 0, 0, 0.12);
}

/* spine shadow */
#cv-spread::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  background: linear-gradient(to right,
    rgba(0,0,0,0.22) 0%,
    rgba(0,0,0,0.06) 40%,
    rgba(0,0,0,0.06) 60%,
    rgba(0,0,0,0.22) 100%);
  pointer-events: none;
  z-index: 5;
}

/* ---- CANVAS ---- */
.cv-page-slot canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---- FLIP ANIMATION ---- */

/* Flipping page that sits on top during animation */
.cv-flip-leaf {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  transform-origin: left center;   /* override in JS for direction */
  backface-visibility: hidden;
  transform-style: preserve-3d;
  /* GPU layer promotion — eliminates jank during 3D flip */
  will-change: transform;
  z-index: 10;
  pointer-events: none;
  background: #fff;
  overflow: hidden;
}

/* Forward flip: right page flips left */
@keyframes cv-flip-forward {
  0%   { transform: rotateY(0deg); }
  100% { transform: rotateY(-180deg); }
}

/* Backward flip: left page flips right */
@keyframes cv-flip-backward {
  0%   { transform: rotateY(0deg); }
  100% { transform: rotateY(180deg); }
}

/*
 * Duration: 0.48s (was 0.6s) — snappier feel.
 * Easing: cubic-bezier(0.25,0.46,0.45,0.94) — ease-out curve,
 *   fast start + smooth deceleration vs. Material symmetric curve.
 * NOTE FOR JS: FLIP_DURATION constant must be updated from 620 to 500.
 */
.cv-flip-leaf.cv-flipping-forward {
  animation: cv-flip-forward 0.48s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.cv-flip-leaf.cv-flipping-backward {
  animation: cv-flip-backward 0.48s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* gradient shadow on flip leaf — opacity animates compositor-only for depth illusion */
.cv-flip-leaf::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to left, rgba(0,0,0,0.15) 0%, transparent 60%);
  pointer-events: none;
  /* Compositor-only opacity fade: visible at start, fades as page completes flip */
  animation: cv-flip-shadow-fade 0.48s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes cv-flip-shadow-fade {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* ---- BOTTOM CONTROLS ---- */
#cv-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: rgba(15, 20, 35, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 0 20px;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.4);
  z-index: 2;
}

#cv-page-info {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.82);
  min-width: 90px;
  text-align: center;
  letter-spacing: 0.03em;
}

/* ---- ZOOM CONTROLS in header ---- */
#cv-zoom-info {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.72);
  min-width: 38px;
  text-align: center;
}

/* ---- LOADING SPINNER ---- */
#cv-loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 18, 0.82);
  z-index: 20;
  gap: 18px;
  transition: opacity 0.25s;
}

#cv-loader.cv-hidden {
  opacity: 0;
  pointer-events: none;
}

.cv-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.15);
  border-top-color: #0d67c3;
  border-radius: 50%;
  animation: cv-spin 0.8s linear infinite;
}

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

#cv-loader-text {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 0.03em;
}

/* ---- MOBILE: single page ---- */
@media (max-width: 680px) {
  #cv-title {
    font-size: 13px;
    max-width: calc(100% - 180px);
  }

  #cv-header {
    height: 46px;
    padding: 0 10px;
  }

  .cv-btn {
    font-size: 12px;
    padding: 4px 8px;
    height: 30px;
  }

  #cv-controls {
    height: 52px;
    gap: 10px;
  }

  #cv-page-info {
    font-size: 12px;
    min-width: 70px;
  }

  #cv-stage {
    padding: 54px 8px 60px;
  }

  /* Hide right slot on mobile — single page mode */
  .cv-page-slot.cv-right {
    display: none;
  }

  .cv-page-slot.cv-left {
    border-radius: 4px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.55);
  }

  #cv-spread::after {
    display: none;
  }

  /* Zoom buttons less important on mobile */
  #cv-zoom-group {
    display: none;
  }
}

@media (max-width: 400px) {
  #cv-page-info {
    display: none;
  }
}
