/* =========================================================
   Флипбук каталога Восток-Сервис
   Используется и на standalone /catalog.html,
   и встраивается в главную секцию #catalog.
   ========================================================= */

/* ---------- Inline секция на главной ---------- */
.catalog {
  padding: clamp(48px, 8vh, 96px) 0 clamp(40px, 6vh, 72px);
  position: relative;
}
.catalog-stage--inline {
  position: relative;
  width: 100%;
  margin: 0 auto;
  padding: 0 60px;
  height: clamp(480px, 70vh, 780px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.catalog-toolbar--inline {
  margin-top: 20px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.catalog-toolbar--inline .catalog-toolbar__inner {
  max-width: 900px;
  margin: 0 auto;
}
.catalog-download-inline {
  padding: 8px 14px !important;
  font-size: 13.5px !important;
}

@media (max-width: 900px) {
  .catalog { padding: 8px 0 12px; }
  .catalog .section-head {
    margin-bottom: 4px;
  }
  .catalog .section-title {
    margin: 4px 0;
  }
  .catalog .section-subtitle {
    font-size: 14px;
  }
  .catalog-stage--inline {
    padding: 0 8px;
    /* Высота подбирается по пропорции страницы (1.4),
       чтобы книга заполняла стейдж без «воздуха». */
    aspect-ratio: 10 / 14;
    height: auto;
    max-height: 75vh;
  }
  .catalog-toolbar--inline {
    margin-top: 10px;
    padding: 10px 14px;
  }
  /* на мобильных прячем счётчик и слайдер, оставляем только кнопку */
  .catalog-toolbar--inline .page-counter,
  .catalog-toolbar--inline .page-slider {
    display: none;
  }
  .catalog-toolbar--inline .catalog-toolbar__inner {
    display: flex;
    justify-content: center;
  }
  .catalog-download-inline {
    padding: 10px 20px !important;
    font-size: 14px !important;
  }
}

.catalog-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- Header ---------- */
.catalog-header {
  position: relative;
  z-index: 20;
  height: 64px;
  background: rgba(5, 13, 36, 0.85);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.catalog-header__inner {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 100%;
}
.catalog-header .brand__logo { height: 24px; }

.catalog-title {
  margin: 0 auto;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  color: var(--text);
}
.catalog-title__kicker {
  color: var(--text-mute);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}
.catalog-title__main {
  font-weight: 800;
  font-size: 16px;
  background: linear-gradient(90deg, var(--brand-2), var(--brand-3));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.catalog-header__actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.catalog-download {
  padding: 8px 14px !important;
}
.catalog-close {
  width: 40px;
  height: 40px;
  padding: 0 !important;
  border-radius: 12px !important;
  display: grid;
  place-items: center;
}

/* ---------- Main stage ---------- */
.catalog-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.catalog-stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 60px;
  min-height: 0;
}

/* ---------- Flip arrows ---------- */
.flip-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(10, 22, 48, 0.7);
  border: 1px solid var(--border-hi);
  color: #fff;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 10;
  transition: transform 0.25s var(--ease), background 0.25s, border-color 0.25s,
    opacity 0.25s;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.flip-arrow:hover {
  background: rgba(29, 78, 158, 0.85);
  border-color: var(--brand-2);
  transform: translateY(-50%) scale(1.06);
}
.flip-arrow:active { transform: translateY(-50%) scale(0.96); }
.flip-arrow:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: translateY(-50%);
}
.flip-arrow--prev { left: 12px; }
.flip-arrow--next { right: 12px; }

/* ---------- The book ---------- */
.flipbook {
  width: 100%;
  height: 100%;
  max-width: 1400px;
  margin: 0 auto;
  display: block;
}
.flipbook .stf__parent {
  margin: 0 auto;
}

/* страница = прямоугольник белого листа */
.flip-page {
  background: #fff;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.flip-page canvas,
.flip-page__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}
.flip-page .page-number {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 600;
  color: #6c7a95;
  letter-spacing: 0.05em;
  opacity: 0.8;
  pointer-events: none;
}
.flip-page--cover {
  background: linear-gradient(135deg, #0b1a3a 0%, #1d4e9e 70%, #4a8bff 100%);
  color: #fff;
}
.flip-page--cover .page-number { display: none; }
.flip-page--pending {
  background:
    linear-gradient(135deg, #f3f6fb 0%, #e8edf5 100%);
}
.flip-page--pending::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    120deg,
    transparent 0%,
    rgba(74, 139, 255, 0.12) 45%,
    transparent 90%
  );
  background-size: 250% 100%;
  animation: pageShimmer 1.6s linear infinite;
}
@keyframes pageShimmer {
  0% { background-position: 150% 0; }
  100% { background-position: -50% 0; }
}

/* ---------- Loader ---------- */
.catalog-loader {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: rgba(5, 13, 36, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.5s ease, visibility 0.5s;
}
.catalog-loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.catalog-loader__ring {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 3px solid rgba(74, 139, 255, 0.2);
  border-top-color: var(--brand-2);
  animation: ringSpin 1s linear infinite;
}
@keyframes ringSpin { to { transform: rotate(360deg); } }
.catalog-loader__text {
  text-align: center;
  color: var(--text);
  font-weight: 600;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.catalog-loader__hint {
  font-weight: 400;
  color: var(--text-mute);
  font-size: 13px;
}
.catalog-loader__bar {
  width: min(280px, 80%);
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  position: relative;
}
.catalog-loader__bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: linear-gradient(90deg, var(--brand-2), var(--brand-3));
  border-radius: inherit;
  transition: width 0.25s ease;
}
/* Когда ширина 0 — показываем бесконечную анимацию "идёт работа" */
.catalog-loader__bar-fill:not([style*="width"]),
.catalog-loader__bar-fill[style*="width: 0%"] {
  width: 30%;
  animation: barIndeterminate 1.4s ease-in-out infinite;
}
@keyframes barIndeterminate {
  0% { left: -30%; }
  100% { left: 100%; }
}

/* ---------- Swipe hint ---------- */
.swipe-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: 999px;
  background: rgba(10, 22, 48, 0.85);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  z-index: 15;
  border: 1px solid var(--border-hi);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  animation: swipeHintFade 4.5s ease forwards;
}
.swipe-hint__icon { display: inline-flex; animation: swipeFloat 1.4s ease-in-out infinite; }
@keyframes swipeFloat {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-6px); }
}
@keyframes swipeHintFade {
  0%, 10% { opacity: 0; }
  20%, 70% { opacity: 1; }
  100% { opacity: 0; visibility: hidden; }
}

/* ---------- Toolbar ---------- */
.catalog-toolbar {
  flex-shrink: 0;
  padding: 10px 0 14px;
  background: linear-gradient(180deg, transparent 0%, rgba(5, 13, 36, 0.75) 45%, #040a1c 100%);
  border-top: 1px solid var(--border);
}
.catalog-toolbar__inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
}
.page-counter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  min-width: 70px;
}
.page-counter__sep { color: var(--text-dim); font-weight: 500; }

.page-slider {
  position: relative;
}
#page-slider {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    var(--brand-2) 0%,
    var(--brand-2) var(--progress, 0%),
    rgba(255, 255, 255, 0.1) var(--progress, 0%),
    rgba(255, 255, 255, 0.1) 100%
  );
  outline: none;
  cursor: pointer;
}
#page-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--brand-2);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s;
}
#page-slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
#page-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--brand-2);
  cursor: pointer;
}
#page-slider::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.catalog-hints {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 12.5px;
  white-space: nowrap;
}
.hint-key {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border: 1px solid var(--border-hi);
  border-radius: 6px;
  background: var(--surface);
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .catalog-header { height: 58px; }
  .catalog-title { display: none; }
  .catalog-download span { display: none; }
  .catalog-download { width: 40px; height: 40px; padding: 0 !important; border-radius: 12px !important; display: grid; place-items: center; }
  .catalog-stage { padding: 10px 6px; }
  .flip-arrow {
    width: 40px;
    height: 40px;
  }
  .flip-arrow--prev { left: 6px; }
  .flip-arrow--next { right: 6px; }
  .catalog-hints { display: none; }
  .catalog-toolbar__inner { grid-template-columns: auto 1fr; }
}
@media (max-width: 480px) {
  .flip-arrow { display: none; } /* мобильные — только свайп */
  .catalog-stage { padding: 8px 4px; }
}
