/* PRAE CASEFILES — 10-Year Enterprise Comic Reader Engine Styles */
:root {
  --reader-bg: #0a0c0d;
  --reader-surface: #121517;
  --reader-surface-2: #191d20;
  --reader-border: #3a2b29;
  --reader-red: #e94738;
  --reader-red-soft: #ff9586;
  --reader-bone: #eee9de;
  --reader-muted: #9e9b95;
}

body.reader-body {
  margin: 0;
  background: var(--reader-bg);
  color: var(--reader-bone);
  font-family: Tahoma, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* Topbar: 52px on Desktop, 48px + 44px on Mobile */
.reader-topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(16, 18, 20, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--reader-border);
}

.reader-bar-main {
  height: 52px;
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 clamp(14px, 3vw, 36px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.reader-brand-group {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.reader-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid #4d3935;
  background: #171314;
  color: var(--reader-red-soft);
  font-size: 13px;
  white-space: nowrap;
  border-radius: 4px;
}

.reader-back:hover {
  border-color: var(--reader-red);
  color: #fff;
}

.reader-ep-title {
  font-family: PraeSerif, Georgia, serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--reader-bone);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader-ep-title span {
  color: var(--reader-red-soft);
  font-family: 'Courier New', monospace;
  font-size: 12px;
  letter-spacing: 0.08em;
  margin-right: 8px;
}

/* Navigation & Zoom Controls */
.reader-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.reader-btn {
  background: var(--reader-surface-2);
  color: var(--reader-bone);
  border: 1px solid #483b38;
  padding: 6px 11px;
  font-size: 13px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s;
}

.reader-btn:hover:not(:disabled) {
  border-color: var(--reader-red);
  background: #251b1a;
}

.reader-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.reader-btn[aria-pressed="true"] {
  border-color: var(--reader-red);
  background: #2f1b19;
  color: #fff;
}

.reader-page-select {
  background: #141719;
  color: var(--reader-bone);
  border: 1px solid #483b38;
  padding: 5px 8px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
}

.reader-zoom-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding-left: 6px;
  border-left: 1px solid #352b29;
}

.reader-zoom-readout {
  font: 12px/1 'Courier New', monospace;
  min-width: 44px;
  text-align: center;
  color: var(--reader-red-soft);
}

/* Mobile secondary menu details */
.reader-more {
  position: relative;
}

.reader-more summary {
  list-style: none;
  cursor: pointer;
}

.reader-more summary::-webkit-details-marker {
  display: none;
}

.reader-more-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: #16191c;
  border: 1px solid var(--reader-border);
  border-radius: 6px;
  padding: 12px;
  min-width: 230px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.75);
  display: grid;
  gap: 10px;
  z-index: 80;
}

.reader-more-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--reader-muted);
}

/* Progress Bar */
.reader-progress-track {
  height: 3px;
  background: #1a1d1f;
  width: 100%;
}

.reader-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #8e1b1b, var(--reader-red));
  width: 6.25%;
  transition: width 0.2s ease-out;
}

/* Main Stage: Slide Mode vs Webtoon Scroll Mode */
.reader-stage-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 18px clamp(8px, 2.5vw, 32px);
}

/* Carousel / Slide Deck Layout */
.reader-carousel {
  width: 100%;
  max-width: 1420px;
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 150px;
  align-items: center;
  gap: 20px;
}

.reader-side-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: none;
  border: 0;
  padding: 6px;
  color: var(--reader-muted);
  cursor: pointer;
  opacity: 0.34;
  transition: opacity 0.2s, transform 0.2s;
}

.reader-side-preview:hover:not(:disabled) {
  opacity: 0.78;
  transform: translateY(-2px);
}

.reader-side-preview:disabled {
  opacity: 0.08;
  cursor: default;
}

.reader-side-preview img {
  width: 100%;
  max-width: 136px;
  aspect-ratio: 848 / 1264;
  object-fit: cover;
  border: 1px solid #3f312e;
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.reader-side-preview span {
  font: 11px/1.3 'Courier New', monospace;
  letter-spacing: 0.08em;
}

/* Viewport for Zoom & Pan */
.reader-viewport {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  touch-action: pan-y pinch-zoom;
  min-height: calc(100vh - 140px);
}

.reader-viewport.is-zoomed {
  cursor: grab;
  touch-action: none;
}

.reader-viewport.is-zoomed.is-dragging {
  cursor: grabbing;
}

.reader-canvas {
  position: relative;
  transform-origin: center center;
  transition: transform 0.08s ease-out;
  will-change: transform;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reader-canvas.no-transition {
  transition: none;
}

.reader-main-img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(100%, 848px);
  max-height: calc(100vh - 126px);
  aspect-ratio: 848 / 1264;
  border: 1px solid #382c2a;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.85);
  background: #141618;
  pointer-events: none;
}

/* Fit Modes */
body.fit-width .reader-main-img {
  max-height: none;
  width: min(100%, 848px);
}

body.fit-page .reader-main-img {
  max-height: calc(100vh - 122px);
  max-width: min(100%, 848px);
}

/* Vertical Webtoon Mode */
.reader-webtoon-list {
  display: none;
  width: 100%;
  max-width: 848px;
  margin: 0 auto;
  flex-direction: column;
  gap: 14px;
}

body.mode-webtoon .reader-carousel {
  display: none;
}

body.mode-webtoon .reader-webtoon-list {
  display: flex;
}

.reader-webtoon-item {
  margin: 0;
  background: #121416;
  border: 1px solid #322725;
  position: relative;
}

.reader-webtoon-item img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 848 / 1264;
}

.reader-webtoon-badge {
  position: absolute;
  right: 12px;
  bottom: 12px;
  background: rgba(12, 14, 16, 0.82);
  border: 1px solid #4c3935;
  color: #d6cfc7;
  padding: 3px 8px;
  font: 11px/1.3 'Courier New', monospace;
  border-radius: 3px;
}

/* Thumbnail Filmstrip Drawer */
.reader-filmstrip {
  width: 100%;
  max-width: 1280px;
  margin: 12px auto 0;
  padding: 10px 14px;
  background: #121517;
  border: 1px solid #322624;
  border-radius: 6px;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-behavior: smooth;
}

.reader-thumb {
  flex: 0 0 64px;
  background: none;
  border: 2px solid transparent;
  padding: 0;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  opacity: 0.55;
  transition: opacity 0.15s, border-color 0.15s;
}

.reader-thumb:hover,
.reader-thumb.is-active {
  opacity: 1;
}

.reader-thumb.is-active {
  border-color: var(--reader-red);
}

.reader-thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 848 / 1264;
  object-fit: cover;
}

.reader-thumb span {
  position: absolute;
  inset: auto 0 0 0;
  background: rgba(10, 12, 13, 0.86);
  color: #eee;
  font: 10px/1.4 monospace;
  text-align: center;
}

/* End of Episode Card & Gemini VeO Teaser Slot */
.reader-endcard {
  width: 100%;
  max-width: 848px;
  margin: 26px auto 12px;
  padding: 24px clamp(18px, 4vw, 34px);
  background: linear-gradient(120deg, #1e1517, #121618);
  border: 1px solid #5c3b35;
  border-radius: 6px;
  display: grid;
  gap: 16px;
}

.reader-endcard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.reader-endcard h2 {
  font: 700 clamp(22px, 3vw, 30px)/1.35 PraeSerif, Georgia, serif;
  margin: 0;
}

.reader-endcard p {
  margin: 0;
  color: #cbc4be;
  font-size: 15px;
  line-height: 1.75;
}

.reader-endcard-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
}

.reader-video-box {
  width: 100%;
  border: 1px solid #4d3531;
  border-radius: 6px;
  overflow: hidden;
  background: #070809;
}

.reader-short-video {
  display: block;
  width: 100%;
  max-height: 480px;
  aspect-ratio: 16 / 9;
  background: #000;
}

.reader-hint-bar {
  text-align: center;
  font-size: 12px;
  color: var(--reader-muted);
  padding: 8px 16px 20px;
}

/* Responsive Tablet & Mobile Rules (48px + 44px bar standard) */
@media (max-width: 1024px) {
  .reader-carousel {
    grid-template-columns: minmax(0, 1fr);
  }
  .reader-side-preview {
    display: none;
  }
}

@media (max-width: 750px) {
  .reader-bar-main {
    height: auto;
    min-height: 48px;
    flex-wrap: wrap;
    padding: 6px 12px;
    gap: 6px;
  }
  .reader-brand-group {
    width: 100%;
    height: 42px;
    justify-content: space-between;
  }
  .reader-controls {
    width: 100%;
    height: 42px;
    justify-content: space-between;
    border-top: 1px solid #292220;
    padding-top: 4px;
  }
  .reader-desktop-only {
    display: none !important;
  }
  .reader-stage-wrap {
    padding: 8px 4px;
  }
  .reader-viewport {
    min-height: calc(100vh - 150px);
  }
  body.fit-page .reader-main-img {
    max-height: calc(100vh - 140px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .reader-progress-fill,
  .reader-canvas,
  .reader-side-preview {
    transition: none !important;
  }
}
