/* ============================================================
   Visor de catálogos (flipbook)  ·  Higiofi
   Se carga solo en visor-catalogo.html
   ============================================================ */

/* ---- página --------------------------------------------------- */
.flipbook-page {
  min-height: 100vh;
  background: linear-gradient(180deg, #eef2f9 0%, #d9e3f2 100%);
  padding: 120px 16px 26px;
  display: flex;
  flex-direction: column;
}

/* ---- cabecera ------------------------------------------------- */
.flipbook-head {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.flipbook-volver {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--azul-oscuro);
  font-weight: 600;
  font-size: 14px;
  background: var(--blanco);
  border: 1px solid var(--gris-borde);
  padding: 9px 16px;
  border-radius: 999px;
  white-space: nowrap;
  transition: background 0.15s, transform 0.15s;
}
.flipbook-volver:hover {
  background: var(--azul-palido);
  transform: translateX(-2px);
}
.flipbook-volver svg {
  width: 16px;
  height: 16px;
}

.flipbook-titulo {
  margin: 0;
  font-size: clamp(15px, 2.4vw, 22px);
  font-weight: 600;
  color: var(--texto);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- viewport / escenario ------------------------------------ */
.flipbook-viewport {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.flipbook-stage {
  width: clamp(260px, min(96vw, calc((100vh - 300px) * 1.414)), 1150px);
  margin: 0 auto;
  position: relative;
}

#flipbook {
  margin: 0 auto;
}
#flipbook .page {
  background: var(--blanco);
  overflow: hidden;
}
#flipbook .page img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: fill;
  -webkit-user-drag: none;
  user-select: none;
}

.stf__parent {
  margin: 0 auto;
}
.stf__item {
  box-shadow: 0 6px 26px rgba(20, 30, 80, 0.22);
}

/* ---- cargando / error ---------------------------------------- */
.flipbook-loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--texto-muted);
  font-size: 14px;
}
.flipbook-loader.is-hidden {
  display: none;
}
.flipbook-spinner {
  width: 38px;
  height: 38px;
  border: 3px solid var(--azul-palido);
  border-top-color: var(--azul-medio);
  border-radius: 50%;
  animation: fb-spin 0.8s linear infinite;
}
@keyframes fb-spin {
  to {
    transform: rotate(360deg);
  }
}
.flipbook-error {
  max-width: 360px;
  text-align: center;
  color: var(--texto-muted);
  font-size: 15px;
  line-height: 1.5;
  padding: 30px 18px;
}

/* ---- barra de controles -------------------------------------- */
.flipbook-controls {
  margin: 16px auto 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--blanco);
  border: 1px solid var(--gris-borde);
  border-radius: 999px;
  padding: 8px 12px;
  box-shadow: var(--sombra);
}
.flipbook-controls[hidden] {
  display: none;
}

.fb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  background: var(--azul-frost);
  color: var(--azul-oscuro);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 999px;
  padding: 9px 14px;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
}
.fb-btn:hover {
  background: var(--azul-palido);
}
.fb-btn:active {
  transform: scale(0.95);
}
.fb-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.fb-btn--icon {
  width: 40px;
  height: 40px;
  padding: 0;
}
.fb-btn svg {
  width: 18px;
  height: 18px;
}

.fb-pages {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  color: var(--texto-muted);
  padding: 0 4px;
}
.fb-pages input {
  width: 54px;
  text-align: center;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--texto);
  border: 1px solid var(--gris-borde);
  border-radius: 8px;
  padding: 7px 4px;
  -moz-appearance: textfield;
}
.fb-pages input::-webkit-outer-spin-button,
.fb-pages input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ---- overlay de zoom ----------------------------------------- */
.fb-zoom-overlay {
  position: fixed;
  inset: 0;
  z-index: 4000;
  background: rgba(12, 18, 45, 0.93);
  display: flex;
  align-items: center;
  justify-content: center;
}
.fb-zoom-overlay[hidden] {
  display: none;
}

.fb-zoom-stage {
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  cursor: grab;
}
.fb-zoom-stage.is-panning {
  cursor: grabbing;
}
.fb-zoom-stage img {
  max-width: 94vw;
  max-height: 90vh;
  transform-origin: center center;
  transition: transform 0.12s ease-out;
  will-change: transform;
  -webkit-user-drag: none;
  user-select: none;
}
.fb-zoom-stage.is-active img {
  transition: none;
}

.fb-zoom-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fb-zoom-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.fb-zoom-toolbar {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  background: rgba(255, 255, 255, 0.14);
  padding: 6px;
  border-radius: 999px;
}
.fb-zoom-toolbar button {
  min-width: 50px;
  height: 40px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--azul-oscuro);
  font-family: inherit;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}
.fb-zoom-toolbar button:hover {
  background: #fff;
}

/* ---- pantalla completa --------------------------------------- */
.flipbook-page:fullscreen {
  padding-top: 26px;
  background: linear-gradient(180deg, #eef2f9 0%, #d9e3f2 100%);
}
.flipbook-page:fullscreen .flipbook-stage {
  width: clamp(260px, min(96vw, calc((100vh - 180px) * 1.414)), 1320px);
}

/* ---- responsive ---------------------------------------------- */
@media (max-width: 767px) {
  .flipbook-page {
    padding: 110px 12px 22px;
  }
  .flipbook-stage {
    width: clamp(220px, min(95vw, calc((100vh - 240px) * 0.707)), 760px);
  }
}

@media (max-width: 520px) {
  .flipbook-controls {
    gap: 5px;
    padding: 7px 9px;
  }
  .fb-btn {
    padding: 8px 11px;
    font-size: 13px;
  }
  .fb-btn--icon {
    width: 38px;
    height: 38px;
  }
  .fb-btn--label-hide span {
    display: none;
  }
}
