/* ── Reader Page ──────────────────────────────────── */

/* Zoom bar — desktop only */
.reader-zoom-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
}
@media (max-width: 768px) {
  .reader-zoom-bar { display: none; }
}
.reader-zoom-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-medium);
  background: rgba(255,255,255,0.04);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.reader-zoom-btn:hover {
  background: rgba(108, 99, 255, 0.15);
  border-color: var(--accent-primary);
}
#zoomSlider {
  width: 100px;
  accent-color: var(--accent-primary);
}
.reader-zoom-value {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 2.5rem;
}

#readerContent {
  overflow: visible;
}

.comic-info-bar {
    background: rgba(14, 14, 26, 0.9);
    border-bottom: 1px solid var(--border-subtle);
    padding: 1rem 0;
    backdrop-filter: blur(12px);
    position: sticky;
    top: var(--nav-height);
    z-index: 100;
}

.comic-thumb {
    width: 48px;
    height: 64px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.reader-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: calc(100vh - var(--nav-height) - 80px);
    max-width: 1400px;
    margin: 0 auto;
}

/* Chapter Sidebar */
.chapter-list {
    border-right: 1px solid var(--border-subtle);
    padding: 1.5rem 1rem;
    overflow-y: auto;
    max-height: calc(100vh - var(--nav-height) - 80px);
    position: sticky;
    top: calc(var(--nav-height) + 80px);
}

.chapter-list-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.chapter-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
    transition: var(--transition);
    margin-bottom: 0.2rem;
}

.chapter-item:hover {
    background: rgba(108, 99, 255, 0.1);
}

.chapter-item.active {
    background: rgba(108, 99, 255, 0.18);
}

.chapter-item.chapter-locked {
    opacity: 0.85;
}

.chapter-item.chapter-locked .chapter-name {
    color: var(--text-muted);
}

.chapter-lock {
    font-size: 0.9rem;
    flex-shrink: 0;
}

.btn-link {
    background: none;
    border: none;
    color: var(--accent-primary);
    cursor: pointer;
    text-decoration: underline;
    font-size: inherit;
}

.chapter-num {
    font-family: var(--font-heading);
    font-size: 0.75rem;
    color: var(--accent-primary);
    font-weight: 700;
    min-width: 30px;
}

.chapter-name {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chapter-reads {
    font-size: 0.72rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* Reader Main */
.reader-main {
    display: flex;
    flex-direction: column;
    background: var(--bg-base);
    min-height: 600px;
}

.reader-welcome,
.reader-loading,
.reader-error {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

.reader-welcome.hidden,
.reader-loading.hidden,
.reader-error.hidden,
#readerContent.hidden {
    display: none !important;
}

.reader-welcome .welcome-icon { font-size: 4rem; margin-bottom: 1rem; }
.reader-welcome h2 { margin-bottom: 0.5rem; }
.reader-welcome .welcome-desc { max-width: 360px; margin: 0 auto 1.5rem; }

.reader-loading .spinner { width: 48px; height: 48px; border-width: 4px; }
.reader-loading p { margin-top: 0.5rem; }

.reader-error .error-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.reader-error .error-msg { font-size: 1.1rem; max-width: 400px; margin: 0 auto; }
.reader-error .error-actions { flex-wrap: wrap; }

/* Auth promo block (create account to continue) */
.reader-auth-promo {
  max-width: 360px;
  padding: 1.5rem;
  background: var(--bg-elevated);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-medium);
}
.auth-promo-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.auth-promo-title { font-size: 1.35rem; margin-bottom: 0.35rem; }
.auth-promo-desc { color: var(--text-secondary); font-size: 0.95rem; margin-bottom: 1.25rem; }
.auth-promo-benefits {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
  text-align: left;
}
.auth-promo-benefits li {
  padding: 0.4rem 0;
  padding-left: 1.5rem;
  position: relative;
  color: var(--text-primary);
}
.auth-promo-benefits li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--accent-cyan);
  font-weight: 700;
}
.auth-promo-benefits li strong { color: var(--accent-primary); }

.comic-info-bar .info-row { flex-wrap: wrap; }
.comic-info-bar h1 { font-size: 1.4rem; margin-bottom: 0.2rem; }
.comic-info-bar h1.comic-title-truncate { cursor: default; }
.comic-info-bar h1.comic-title-truncate[data-full] { cursor: pointer; }
.comic-info-bar .meta-row { flex-wrap: wrap; }
.comic-info-bar .read-btn { margin-left: auto; }

.decision-hint { font-size: 0.8rem; color: var(--text-muted); font-weight: 400; }
.decision-pts { font-size: 0.85rem; color: var(--text-muted); display: block; margin-top: 0.25rem; }
.decision-status { font-size: 0.75rem; color: var(--text-muted); font-style: italic; display: block; margin-top: 0.2rem; }

/* Barre de progression : fond selon % financé (0–1000 pts) */
.decision-option {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.decision-option::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--progress, 0%);
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  z-index: 0;
  pointer-events: none;
  transition: width 0.4s ease;
}
.decision-option.left::before {
  background: rgba(108, 99, 255, 0.18);
}
.decision-option.right::before {
  background: rgba(0, 212, 255, 0.15);
}
.decision-option > * {
  position: relative;
  z-index: 1;
}

/* Vote mode: groupe de segments +10 | +100 | +1000 */
.vote-buttons:empty {
  display: none;
}
.vote-buttons {
  display: inline-flex;
  margin-top: 0.65rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid;
}
.decision-option.left .vote-buttons {
  border-color: rgba(108, 99, 255, 0.4);
}
.decision-option.right .vote-buttons {
  border-color: rgba(0, 212, 255, 0.4);
}
.vote-btn {
  font-size: 0.78rem;
  padding: 0.35rem 0.6rem;
  border: none;
  border-right: 1px solid;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-heading);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: transparent;
}
.vote-btn:last-child {
  border-right: none;
}
.decision-option.left .vote-btn {
  color: var(--accent-primary);
  border-right-color: rgba(108, 99, 255, 0.3);
}
.decision-option.left .vote-btn:hover:not(:disabled) {
  background: rgba(108, 99, 255, 0.15);
}
.decision-option.right .vote-btn {
  color: var(--accent-cyan);
  border-right-color: rgba(0, 212, 255, 0.3);
}
.decision-option.right .vote-btn:hover:not(:disabled) {
  background: rgba(0, 212, 255, 0.12);
}
.vote-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  color: var(--text-muted);
}

/* decision-option as div: clickable when winner */
.decision-option.decision-winner {
  cursor: pointer;
}

/* Winner: shimmer, no more votes */
.decision-btn.decision-winner {
    position: relative;
    overflow: hidden;
}
.decision-btn.decision-winner::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        110deg,
        transparent 25%,
        rgba(255, 255, 255, 0.15) 50%,
        transparent 75%
    );
    background-size: 200% 100%;
    animation: decision-shimmer 2s ease-in-out infinite;
    pointer-events: none;
}
@keyframes decision-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Loser: contenu adouci, boutons de vote mis en avant */
.decision-btn.decision-loser {
    filter: saturate(0.95);
    cursor: default;
}
.decision-btn.decision-loser > *:not(.vote-buttons) {
    opacity: 0.85;
}
.decision-btn.decision-loser .vote-buttons {
    opacity: 1;
}

/* Winner but chapter not generated: grayed, non-clickable */
.decision-btn.decision-locked {
    opacity: 0.5;
    filter: saturate(0.5);
    cursor: not-allowed;
    pointer-events: none;
}

/* Purchase modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-overlay.hidden { display: none; }
.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  max-width: 360px;
  width: 90%;
}
.modal-card h3 { margin-bottom: 0.5rem; }
.purchase-packs { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 1rem; }
.purchase-pack-btn {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem; border-radius: var(--radius-md);
  border: 1px solid var(--border-medium);
  background: transparent; color: inherit;
  cursor: pointer; transition: var(--transition);
  font-family: var(--font-heading);
}
.purchase-pack-btn:hover {
  border-color: var(--accent-primary);
  background: rgba(108,99,255,0.1);
}
.pack-bonus { color: var(--accent-cyan); font-size: 0.85rem; margin-left: 0.5rem; }
.pack-price { font-weight: 700; color: var(--accent-primary); }

/* Sentinel: triggers decision card reveal when user scrolls to end */
.decision-sentinel {
    height: 1px;
    width: 100%;
    pointer-events: none;
}

/* Panel images — width controlled by zoom (--reader-panel-width) */
.reader-container {
    max-width: var(--reader-panel-width, 480px);
    margin: 0 auto;
    width: 100%;
}

.panel-wrapper {
    position: relative;
    margin-bottom: 0;
    overflow: hidden;
}

.panel-wrapper+.panel-wrapper {
    border-top: 3px solid var(--bg-base);
}

.panel-image {
    width: 100%;
    display: block;
    transition: filter 0.3s ease;
}

.panel-image-fallback {
    width: 100%;
    aspect-ratio: 1/8;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.part-separator {
    height: 24px;
    background: linear-gradient(180deg, var(--bg-elevated) 0%, var(--bg-base) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.part-separator::after {
    content: '· · ·';
    color: var(--text-muted);
    font-size: 0.75rem;
    letter-spacing: 0.3em;
}

/* Lazy load placeholder */
.panel-placeholder {
    width: 100%;
    aspect-ratio: 1/8;
    background: linear-gradient(135deg, var(--bg-elevated), var(--bg-surface));
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

/* Chapter title */
.chapter-header {
    max-width: var(--reader-panel-width, 480px);
    margin: 1.5rem auto 0;
    padding: 1rem 1rem 0.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.chapter-header h2 {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

/* Mobile: comic-info-bar collapses on scroll for max webcomic space */
@media (max-width: 768px) {
    .comic-info-bar {
        max-height: 220px;
        overflow: hidden;
        transition: max-height 0.25s ease-out;
    }
    .comic-info-bar.comic-info-bar--scrolled {
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
        pointer-events: none;
        border-bottom-width: 0;
    }

    .reader-layout {
        grid-template-columns: 1fr;
    }

    .chapter-list {
        display: flex;
        gap: 0.5rem;
        overflow-x: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
        max-height: none;
        position: static;
        padding: 0.75rem 1rem;
    }

    .chapter-list-title {
        display: none;
    }

    .chapter-item {
        flex-shrink: 0;
        width: auto;
        padding: 0.4rem 0.75rem;
    }

    .chapter-name {
        display: none;
    }
}