/* comic-share.css — public webtoon reader at /c/:slug
 * Mainstream vertical webtoon style: seamless single-column panel stack,
 * centered 720px on desktop / 100vw on mobile. Black immersive background.
 * All UI sharp corners (border-radius: 0) per global rules.
 */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* HTML `hidden` attribute must beat any display: flex/grid below */
[hidden] { display: none !important; }

/* Scope global page reset to comic-share page only — desktop.html also loads this
   stylesheet to reuse .cs-* classes in the comic preview modal, so unscoped
   html/body/img/button rules would bleed into the desktop app and break light theme. */
body.cs-page {
  background: #0d0f17;
  color: #e0e0e0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'PingFang SC', 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.cs-page img { display: block; max-width: 100%; }
.cs-page button { font-family: inherit; cursor: pointer; border: 0; background: transparent; color: inherit; }

/* ── Header ── */
.cs-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: rgba(13, 15, 23, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.cs-logo {
  color: #e63946;
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.cs-header-title {
  flex: 1;
  text-align: center;
  font-size: 14px;
  color: #ccc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 12px;
}
.cs-cta {
  color: #e63946;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  flex-shrink: 0;
}
.cs-cta:hover { color: #ff6b6b; }

/* ── Layout (TOC + reader) ── */
.cs-layout {
  display: flex;
  align-items: flex-start;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 0 0;
  gap: 28px;
}
.cs-main {
  flex: 1;
  min-width: 0;
  max-width: 720px;
  margin: 0 auto;
}

/* ── TOC (desktop side rail) ── */
.cs-toc {
  position: sticky;
  top: 68px;
  width: 200px;
  flex-shrink: 0;
  padding: 8px 12px;
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}
.cs-toc-item {
  display: block;
  padding: 10px 12px;
  color: #888;
  font-size: 13px;
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.cs-toc-item.active {
  color: #e63946;
  border-left-color: #e63946;
}
.cs-toc-item:hover { color: #ccc; }
.cs-toc-act-num {
  display: block;
  font-size: 11px;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 2px;
}

/* ── Reader title block ── */
.cs-title-block {
  padding: 40px 24px 32px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 24px;
}
.cs-title {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
  margin-bottom: 12px;
  word-wrap: break-word;
}
.cs-author {
  font-size: 13px;
  color: #888;
  letter-spacing: 0.5px;
}
.cs-author strong { color: #ccc; font-weight: 500; }

/* ── Act divider ── */
.cs-act {
  margin-bottom: 16px;
}
.cs-act-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 32px 24px 24px;
  position: relative;
}
.cs-act-header::before,
.cs-act-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
}
.cs-act-header-text {
  font-size: 14px;
  color: #999;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-align: center;
  white-space: nowrap;
}
.cs-act-header-text strong {
  display: block;
  color: #e63946;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 4px;
}

/* ── Panel stack (webtoon core) ── */
.cs-panels {
  display: flex;
  flex-direction: column;
  background: #000;
}
.cs-panel {
  width: 100%;
  position: relative;
  cursor: zoom-in;
  background: #0a0a0a;
}
.cs-panel img {
  width: 100%;
  height: auto;
  display: block;
  margin: 0;
}
.cs-panel-empty {
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #444;
  font-size: 14px;
  background: #151822;
  border: 1px dashed #333;
}

/* ── Loading / NotFound ── */
.cs-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
}
.cs-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(230, 57, 70, 0.2);
  border-top-color: #e63946;
  animation: cs-spin 0.8s linear infinite;
}
@keyframes cs-spin { to { transform: rotate(360deg); } }
.cs-notfound {
  text-align: center;
  padding: 80px 24px;
}
.cs-notfound h1 {
  font-size: 24px;
  color: #fff;
  margin-bottom: 12px;
}
.cs-notfound p {
  color: #888;
  margin-bottom: 24px;
  font-size: 14px;
}

/* ── CTA (shared) ── */
.cs-cta-large {
  display: inline-block;
  padding: 12px 28px;
  background: linear-gradient(135deg, #e63946, #ff6b6b);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  letter-spacing: 0.5px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.cs-cta-large:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(230, 57, 70, 0.3);
}
.cs-cta-large:active {
  transform: translateY(0);
}

/* ── Footer ── */
.cs-footer {
  padding: 48px 24px 64px;
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin-top: 24px;
}
.cs-footer-credit {
  color: #666;
  font-size: 12px;
  margin-bottom: 20px;
  letter-spacing: 0.5px;
}

/* ── Lightbox ── */
.cs-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  cursor: zoom-out;
}
.cs-lightbox img {
  max-width: 100%;
  max-height: 100vh;
  object-fit: contain;
}
.cs-lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  font-size: 28px;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Mobile: hide desktop TOC, show hamburger ── */
@media (max-width: 900px) {
  .cs-layout { flex-direction: column; padding: 0; gap: 0; }
  .cs-toc {
    position: static;
    width: 100%;
    max-width: 100%;
    max-height: none;
    border-left: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding: 8px 16px;
    overflow-x: auto;
    white-space: nowrap;
    display: flex;
    gap: 0;
  }
  .cs-toc-item {
    display: inline-block;
    border-left: 0;
    border-bottom: 2px solid transparent;
    padding: 8px 14px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .cs-toc-item.active {
    border-left: 0;
    border-bottom-color: #e63946;
  }
  .cs-toc-act-num { display: none; }
  .cs-main { max-width: 100%; }
  .cs-title-block { padding: 28px 16px 20px; }
  .cs-title { font-size: 20px; }
  .cs-author { font-size: 12px; }

  .cs-header-title { font-size: 12px; }
  .cs-cta { font-size: 12px; }
  .cs-header { padding: 10px 14px; gap: 10px; }

  /* Act divider — drop flanking lines, center + allow wrap so long titles fit */
  .cs-act-header { padding: 24px 16px 16px; text-align: center; display: block; }
  .cs-act-header::before, .cs-act-header::after { display: none; }
  .cs-act-header-text {
    font-size: 12px;
    letter-spacing: 1px;
    white-space: normal;
    line-height: 1.5;
    padding: 0;
  }
  .cs-act-header-text strong {
    display: block;
    font-size: 10px;
    margin-bottom: 6px;
  }
}

/* Very narrow phones — further compact header */
@media (max-width: 480px) {
  .cs-header { padding: 10px 12px; gap: 8px; }
  .cs-logo { font-size: 15px; }
  .cs-header-title {
    /* Title already shown in title block; hide from header to free space for CTA */
    display: none;
  }
  .cs-cta { font-size: 11px; font-weight: 600; }
  .cs-title { font-size: 18px; }
  .cs-act-header { padding: 20px 12px 14px; }
  .cs-act-header-text { font-size: 11px; letter-spacing: 0.8px; }
}

/* ====================================================
   Book mode (?mode=book) — flip-page reader
   ==================================================== */
body.cs-mode-book .cs-toc { display: none; }
body.cs-mode-book .cs-layout { display: block; }
body.cs-mode-book .cs-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
}
body.cs-mode-book .cs-reader { max-width: none; }

.cs-book-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: calc(100vh - 180px);
}
.cs-book-nav {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.06);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}
.cs-book-nav:hover:not(:disabled) {
  background: rgba(230,57,70,0.25);
  border-color: var(--cs-red, #e63946);
  color: var(--cs-red, #e63946);
}
.cs-book-nav:disabled { opacity: 0.25; cursor: not-allowed; }

.cs-book-viewport {
  position: relative;
  flex: 1;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.cs-book-act-label {
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--cs-red, #e63946);
  font-weight: 700;
}
.cs-book-image {
  max-width: 100%;
  max-height: calc(100vh - 260px);
  object-fit: contain;
  display: block;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  cursor: zoom-in;
  background: #111;
  opacity: 1;
  transition: opacity 0.18s ease;
}
.cs-book-image.cs-book-image-swapping {
  opacity: 0.2;
}
.cs-book-counter {
  font-size: 13px;
  color: rgba(255,255,255,0.55);
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
}

body.cs-mode-book .cs-book-title-block {
  text-align: center;
  padding: 24px 16px 32px;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin-top: 24px;
}
.cs-book-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 6px;
  color: #fff;
}
.cs-book-author {
  font-size: 13px;
  color: rgba(255,255,255,0.55);
}
.cs-book-author strong { color: rgba(255,255,255,0.85); }

@media (max-width: 768px) {
  body.cs-mode-book .cs-main { padding: 8px; }
  .cs-book-stage { gap: 6px; min-height: calc(100vh - 140px); }
  .cs-book-nav { width: 40px; height: 40px; }
  .cs-book-nav svg { width: 20px; height: 20px; }
  .cs-book-image { max-height: calc(100vh - 200px); }
  .cs-book-title { font-size: 18px; }
}
