/* ==========================================================================
   Reader — reader.css
   Fullscreen Reading Stage, Dual Spread, Text Overlay Layers & Lock Screen
   ========================================================================== */

.reader-modal {
  position: fixed;
  inset: 0;
  z-index: 1500;
  background: #06090e;
  display: none;
  flex-direction: column;
}

.reader-modal.active {
  display: flex;
}

/* Header */
.reader-header {
  height: 56px;
  background: rgba(11, 15, 23, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 10;
}

.reader-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.reader-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1rem;
  max-width: 350px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader-header-center {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.reader-header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Reading Stage */
.page-loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  width: 100%;
  color: var(--text-muted);
  gap: 1rem;
}

.spinner-orb {
  font-size: 2.5rem;
  animation: pulseRotate 1.5s infinite ease-in-out;
}

@keyframes pulseRotate {
  0% { transform: scale(0.9) rotate(0deg); opacity: 0.7; }
  50% { transform: scale(1.15) rotate(180deg); opacity: 1; }
  100% { transform: scale(0.9) rotate(360deg); opacity: 0.7; }
}
.reader-stage-container {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
  padding: 1rem 0 4rem;
}

.reader-spread-layout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  height: 100%;
  max-width: 100%;
  transition: transform 0.2s ease-out;
  transform-origin: center center;
}

.reader-spread-layout.single-view .reader-stage-slot {
  width: 95vw;
  max-width: 95vw;
  flex: 0 1 auto;
}

.reader-spread-layout.spread-view .reader-stage-slot {
  width: 48vw;
  max-width: 48vw;
  flex: 1 1 48vw;
}

.reader-spread-layout.zoomed {
  cursor: grab;
}

.reader-spread-layout.panning {
  cursor: grabbing !important;
  user-select: none;
}

.reader-stage-slot {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.reader-stage-slot > .dialog-dom-container:not(:last-child) {
  display: none !important;
}

/* Visual Novel Reading Stage & Layout */
.dialog-dom-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  max-height: calc(100vh - 120px);
  max-width: 100%;
  width: fit-content;
  position: relative;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
  border-radius: 6px;
  overflow: visible;
  background: #090d16;
}

.dialog-scene-wrapper {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: visible;
  max-width: 100%;
  width: 100%;
}

.dialog-scene-stage {
  position: relative;
  display: inline-block;
  line-height: 0;
  max-width: 100%;
}

.dialog-scene-stage img.reader-base-image {
  max-height: calc(72vh - 80px);
  width: auto;
  height: auto;
  max-width: 100%;
  object-fit: contain;
  display: block;
}

.dialog-dom-container.no-bottom-frame .dialog-scene-stage img.reader-base-image {
  max-height: calc(100vh - 140px);
}

/* Character Card / Clean Frame (e.g. Рамка 5) */
.clean-frame-img {
  position: absolute;
  pointer-events: none;
  z-index: 10;
  object-fit: fill;
  max-width: none;
  max-height: none;
}

.clean-frame-text-slot {
  position: absolute;
  z-index: 30;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  pointer-events: auto !important;
  scrollbar-width: thin;
  scrollbar-color: #6366f1 rgba(0, 0, 0, 0.25);
  line-height: 1.4;
  background: transparent !important;
}

.clean-frame-text-content {
  width: 100%;
  min-height: auto;
  margin: 0;
  word-break: normal;
  overflow-wrap: break-word;
  box-sizing: border-box;
  white-space: pre-line;
  line-height: 1.35;
  padding: 0 4px 8px 4px;
  paint-order: stroke fill;
  -webkit-text-stroke-linejoin: round;
  stroke-linejoin: round;
}

/* Bottom Visual Novel Dialogue Frame */
.dialog-frame-wrapper {
  flex: 0 0 auto;
  position: relative;
  width: 100%;
  aspect-ratio: 1024 / 194;
  background: #151824;
  overflow: hidden;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 4px;
  cursor: pointer;
  container-type: inline-size;
  z-index: 20;
}

.dialog-frame-wrapper.hidden {
  display: none !important;
}

.dialog-bg-slot {
  position: absolute;
  background: #ffffff;
  z-index: 2;
  pointer-events: none;
}

.dialog-portrait-slot {
  position: absolute;
  top: 0.5%;
  height: 99%;
  background: #14141e;
  overflow: hidden;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dialog-portrait-slot.hidden {
  display: none !important;
}

.dialog-portrait-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dialog-portrait-slot img.portrait-crop-css {
  position: absolute !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: fill !important;
  pointer-events: none !important;
  display: block !important;
}

.dialog-frame-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  z-index: 10;
  pointer-events: none;
}

.dialog-text-slot {
  position: absolute;
  z-index: 20;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0.35rem 0.8rem;
  overflow: hidden !important;
  pointer-events: auto !important;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

.dialog-text-slot::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

/* Фирменная светящаяся полоса прокрутки (только для карточек персонажей Clean Frame) */
.clean-frame-text-slot::-webkit-scrollbar {
  width: 7px;
}

.clean-frame-text-slot::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  margin: 4px 0;
}

.clean-frame-text-slot::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #6366f1, #06b6d4);
  border-radius: 8px;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.6);
  animation: scrollThumbGlow 2.5s infinite ease-in-out;
}

.clean-frame-text-slot::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #818cf8, #22d3ee);
  box-shadow: 0 0 14px rgba(6, 182, 212, 0.95);
}

@keyframes scrollThumbGlow {
  0% {
    box-shadow: 0 0 4px rgba(99, 102, 241, 0.5);
  }
  50% {
    box-shadow: 0 0 12px rgba(6, 182, 212, 0.9), 0 0 4px #6366f1;
  }
  100% {
    box-shadow: 0 0 4px rgba(99, 102, 241, 0.5);
  }
}

.dialog-text-content {
  width: 100%;
  word-break: break-word;
  box-sizing: border-box;
  cursor: default;
  user-select: text;
  white-space: pre-line;
  line-height: 1.48;
  margin: auto 0;
  font-size: 24px;
  font-size: clamp(16px, 2.38cqw, 26px);
}

/* Четкая контрастная обводка для имени персонажа */
.dialog-char-name {
  display: inline-block;
  color: #ffca28;
  font-weight: 800;
  margin-right: 8px;
  -webkit-text-stroke: 1.2px #000000;
  text-shadow: 
    -1px -1px 0 #000000,  
     1px -1px 0 #000000,
    -1px  1px 0 #000000,
     1px  1px 0 #000000,
     0 2px 4px rgba(0, 0, 0, 0.9);
  letter-spacing: 0.5px;
}

/* Canvas Floating Overlay Text Boxes */
.canvas-overlays-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 12;
  overflow: hidden;
}

.canvas-text-box {
  position: absolute;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: pre-line;
  word-break: break-word;
  pointer-events: auto;
}


/* Lock Screen */
.reader-lock-screen {
  background: rgba(18, 24, 38, 0.95);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: var(--radius-lg);
  padding: 3rem 2rem;
  text-align: center;
  max-width: 480px;
  box-shadow: 0 15px 45px rgba(0, 0, 0, 0.8);
  animation: modal-pop 0.3s ease;
}

.lock-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  animation: pulse-glow 2s infinite alternate;
}

.reader-lock-screen h2 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
  color: #fff;
}

.reader-lock-screen p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

.lock-price-badge {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: var(--radius-full);
  color: #fde68a;
  font-size: 1rem;
  margin-bottom: 1.5rem;
}

/* Auto-hiding Bottom Bar & Trigger Area */
.reader-bottom-trigger {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 80px;
  z-index: 50;
  pointer-events: auto;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.reader-bottom-bar {
  margin-bottom: 16px;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 0.5rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.08);
  opacity: 0;
  transform: translateY(120%);
  transition: opacity 0.28s cubic-bezier(0.4, 0, 0.2, 1), transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.reader-bottom-trigger:hover .reader-bottom-bar,
.reader-bottom-bar:hover,
.reader-bottom-bar.force-show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

#reader-modal:not(.active) .reader-bottom-trigger {
  display: none !important;
  pointer-events: none !important;
}

.reader-nav-btn {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.reader-nav-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.1);
}

.reader-slider {
  width: 140px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.reader-counter {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 60px;
  text-align: center;
}

.reader-dialog-step-counter {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid rgba(245, 158, 11, 0.5);
  color: #ffca28;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: 0.3px;
  transition: all 0.2s ease;
  user-select: none;
}

.reader-dialog-step-counter:hover {
  background: rgba(245, 158, 11, 0.35);
  border-color: #ffca28;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.reader-bar-divider {
  width: 1px;
  height: 22px;
  background: rgba(255, 255, 255, 0.2);
  margin: 0 2px;
  flex-shrink: 0;
}

.reader-tool-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  transition: all 0.2s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.reader-tool-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.45);
  transform: translateY(-1px);
}

.reader-tool-spread {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.5);
  color: #a5b4fc;
}

.reader-tool-spread:hover {
  background: rgba(99, 102, 241, 0.35);
  border-color: #818cf8;
}

.reader-tool-spread-mode {
  background: rgba(168, 85, 247, 0.2);
  border-color: rgba(168, 85, 247, 0.5);
  color: #d8b4fe;
}

.reader-tool-spread-mode:hover {
  background: rgba(168, 85, 247, 0.35);
  border-color: #c084fc;
}

/* ==========================================================================
   Reader Loading Overlay & Real-time Progress Indicator
   ========================================================================== */
.reader-loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 9, 14, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 1;
  transition: opacity 0.25s ease-out;
}

.reader-loading-card {
  background: rgba(18, 24, 38, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75), 0 0 40px rgba(99, 102, 241, 0.25);
  border-radius: 20px;
  padding: 2.25rem 2.5rem;
  max-width: 440px;
  width: 90%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: readerCardPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes readerCardPop {
  0% { transform: scale(0.94); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.reader-loading-orb {
  font-size: 2.75rem;
  margin-bottom: 0.85rem;
  display: inline-block;
  animation: pulseRotate 1.8s infinite ease-in-out;
  filter: drop-shadow(0 0 18px rgba(168, 85, 247, 0.7));
}

.reader-loading-title {
  font-family: var(--font-heading, sans-serif);
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.35rem;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.reader-loading-bar-wrap {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
  margin: 1.15rem 0 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.reader-loading-bar {
  height: 100%;
  width: 15%;
  background: linear-gradient(90deg, #6366f1, #a855f7, #ec4899);
  border-radius: 999px;
  transition: width 0.22s ease-out;
  box-shadow: 0 0 14px rgba(168, 85, 247, 0.7);
}

.reader-loading-status {
  font-size: 0.85rem;
  color: var(--text-muted, #94a3b8);
  min-height: 1.25rem;
  line-height: 1.4;
}

/* Button loading state on catalog cards */
.btn-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.85;
  filter: brightness(1.15);
  box-shadow: 0 0 14px rgba(99, 102, 241, 0.45) !important;
}

.btn-loading .btn-spinner {
  display: inline-block;
  animation: spin 1s infinite linear;
  margin-right: 4px;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   Preview Watermark Badge (Orb Translations Preview)
   ========================================================================== */
.reader-preview-watermark {
  position: absolute;
  top: clamp(8px, 1.8%, 18px);
  left: clamp(8px, 1.8%, 18px);
  width: clamp(64px, 11%, 130px);
  min-width: 48px;
  max-width: 140px;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  z-index: 60;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 3px 10px rgba(0, 0, 0, 0.7));
  opacity: 0.94;
  transition: opacity 0.2s ease, left 0.2s ease, right 0.2s ease;
}

.reader-preview-watermark.watermark-right {
  left: auto;
  right: clamp(8px, 1.8%, 18px);
}
