/* Плеер книги: контейнер, полноэкранный режим и читалка на нарезанных WebP-страницах (player/reader.js) */
* {
  padding: 0;
  margin: 0;
}

[hidden] {
  display: none !important;
}

.new-player {
  height: 80vh;
  width: 100%;
  overflow: hidden;
  font-size: 10px;
  position: relative;
  z-index: 99;
  touch-action: none;
}

.stop-scroll {
  overflow-x: hidden;
}

.mob-full-screen {
  display: none;
}

@media (max-width: 768px) {
  .new-player {
    opacity: 0;
    left: -10000px;
    position: absolute;
  }
  .mob-full-screen {
    display: inline-block;
  }
}

.full-screen {
  top: 0;
  left: 0;
  position: fixed;
  height: 100%;
  width: 100%;
  display: block !important;
  opacity: 1;
}

.rd {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  z-index: 1;
}

.rd[hidden] {
  display: none !important;
}

.rd-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  outline: none;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
}

.rd-pages {
  position: relative;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: max-content;
  min-width: 100%;
  padding: 42px 0 64px;
}

.rd-page {
  position: relative;
  flex: none;
  width: var(--pw, 100%);
  margin: 0 0 12px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1), 0 2px 12px rgba(0, 0, 0, 0.18);
}

.rd-page img {
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.15s;
  -webkit-user-select: none;
  user-select: none;
}

.rd-page.rd-loaded img {
  opacity: 1;
}

.rd-page::before {
  content: attr(data-n);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font: 28px/1 sans-serif;
  color: #ccc;
}

.rd-page.rd-loaded::before {
  display: none;
}

.rd-page.rd-error::after {
  content: "Страница не загрузилась";
  position: absolute;
  top: 58%;
  left: 0;
  right: 0;
  text-align: center;
  font: 16px/1.2 sans-serif;
  color: #b33;
}

/* ---------- «стеклянные» панели: полупрозрачный фон + размытие, контент виден сквозь них ---------- */
.new-player {
  --glass: rgba(22, 24, 31, 0.55);
  --glass-bar: rgba(22, 24, 31, 0.4);
  --glass-line: rgba(255, 255, 255, 0.14);
  background: #fff;
  outline: 0;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .new-player {
    --glass: rgba(22, 24, 31, 0.9);
    --glass-bar: rgba(22, 24, 31, 0.9);
  }
}

/* верхняя панель: название книги и закрытие */
.new-player .player-header {
  position: relative;
  box-sizing: border-box;
  height: 30px;
  padding: 0 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid var(--glass-line);
  font-style: normal;
  overflow: hidden;
  z-index: 5;
}

.new-player.rd-mode .player-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
}

.new-player .player-header #title {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
  font: 600 14px/1.3 -apple-system, "Segoe UI", Roboto, sans-serif;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.new-player .close {
  top: 50%;
  right: 6px;
  width: 24px;
  height: 24px;
  margin-top: -12px;
  border-radius: 50%;
  outline: 0;
  background: rgba(255, 255, 255, 0.14);
  transition: background 0.15s;
}

.new-player .close.show {
  display: block;
}

.new-player .close:hover {
  background: rgba(255, 255, 255, 0.28);
}

.new-player .close:before,
.new-player .close:after {
  top: 50%;
  left: 50%;
  width: 12px;
  height: 2px;
  margin: -1px 0 0 -6px;
  border-radius: 1px;
}

/* нижние кнопки: плавающая полупрозрачная панель по центру, без сплошной полосы */
.rd-toolbar {
  position: absolute;
  left: 50%;
  bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 40px;
  padding: 0 6px;
  border: 1px solid var(--glass-line);
  border-radius: 20px;
  background: var(--glass-bar);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  backdrop-filter: blur(16px) saturate(1.4);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  color: #fff;
  font: 600 15px/1 -apple-system, "Segoe UI", Roboto, sans-serif;
  white-space: nowrap;
}

.rd-toolbar button {
  width: 34px;
  height: 34px;
  padding: 0 0 2px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  font: bold 24px/1 -apple-system, "Segoe UI", Roboto, sans-serif;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
}

.rd-toolbar button:hover:not([disabled]) {
  background: rgba(255, 255, 255, 0.2);
}

.rd-toolbar button:active:not([disabled]) {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(0.93);
}

.rd-toolbar button:focus-visible,
.rd-toolbar .rd-num:focus-visible,
.new-player .close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 1px;
}

.rd-toolbar button[disabled] {
  opacity: 0.3;
  cursor: default;
}

.rd-toolbar .rd-num {
  box-sizing: border-box;
  width: 48px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  text-align: center;
  font: 600 16px/1 -apple-system, "Segoe UI", Roboto, sans-serif; /* 16px, иначе iOS приближает страницу при фокусе */
  -moz-appearance: textfield;
}

.rd-toolbar .rd-num:focus {
  background: rgba(255, 255, 255, 0.26);
}

.rd-toolbar .rd-num::-webkit-outer-spin-button,
.rd-toolbar .rd-num::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.rd-toolbar .rd-count {
  min-width: 40px;
  padding-left: 2px;
  opacity: 0.85;
}

.rd-toolbar .rd-gap {
  width: 1px;
  height: 20px;
  margin: 0 4px;
  background: var(--glass-line);
}

@media (max-width: 768px) {
  /* баннер фиксированной высоты 181px (как в app.css): плеер всегда начинается под ним, реклама выше этой рамки обрезается и не заезжает на страницы */
  .new-player .player-banner {
    position: relative;
    overflow: hidden;
    contain: paint;      /* обрезает и absolute/fixed-элементы рекламы по рамке баннера */
    isolation: isolate;  /* любой z-index рекламы остаётся внутри баннера */
  }
  .new-player .player-header #title {
    font-size: 13px;
  }
  .rd-toolbar {
    gap: 0;
    padding: 0 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rd-toolbar button,
  .new-player .close {
    transition: none;
  }
}

/* обложка, пока проверяем наличие страниц книги; если страниц нет - сообщение вместо кнопки чтения */
.player-cover .rd-note {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(86%, 420px);
  transform: translate(-50%, -50%);
  box-sizing: border-box;
  padding: 18px 22px;
  border: 1px solid var(--glass-line);
  border-radius: 16px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  backdrop-filter: blur(16px) saturate(1.4);
  color: #fff;
  text-align: center;
  font: 600 16px/1.4 -apple-system, "Segoe UI", Roboto, sans-serif;
}

.player-cover.rd-unavailable .spinner {
  display: none;
}
