/* site/assets/chapter.css */

:root {
  --topbar-h: 48px;
  --footer-h: 36px;
  --reading-font-scale: 1;
  --reading-max-width: 680px;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--color-bg);
}

.reader-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 var(--space-md);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  z-index: 10;
}
.top-back {
  color: var(--color-text-subtle);
  font-size: 14px;
  flex-shrink: 0;
  text-decoration: none;
}
.top-title {
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 400;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 var(--space-md);
  flex: 1;
  text-align: center;
}
.top-actions { display: flex; gap: 10px; flex-shrink: 0; }
.top-btn {
  background: transparent;
  border: none;
  font-size: 16px;
  color: var(--color-text-muted);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.top-btn:hover { background: var(--color-border); }

.reader-main {
  position: fixed;
  top: var(--topbar-h);
  bottom: var(--footer-h);
  left: 0; right: 0;
  background: var(--color-bg);
  color: var(--color-text);
}

.chapter {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 48px 24px 80px;
  box-sizing: border-box;
  font-family: var(--font-serif);
  font-size: calc(var(--reading-font-scale) * 18px);
  line-height: 1.7;
  color: var(--color-text);
}

.chapter > * {
  max-width: var(--reading-max-width);
  margin-left: auto;
  margin-right: auto;
}

.chapter-title {
  font-family: var(--font-serif);
  font-size: calc(var(--reading-font-scale) * 28px);
  font-weight: 600;
  margin: 0 auto 28px;
}

.chapter p {
  margin: 0 auto 14px;
  text-align: justify;
  hyphens: auto;
  line-height: 1.7;
}
.chapter em { font-style: italic; }
.chapter strong { font-weight: 600; }
.chapter blockquote {
  margin: 20px auto;
  padding: 0 20px;
  color: var(--color-text-muted);
  border-left: 3px solid var(--color-border);
  font-style: italic;
}

.reader-footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--footer-h);
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
  z-index: 10;
}

.footer-inner {
  max-width: calc(var(--reading-max-width) + 2 * var(--space-md));
  height: 100%;
  margin: 0 auto;
  padding: 0;
  box-sizing: border-box;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--color-text-subtle);
  font-size: 11px;
}
.nav-link {
  color: var(--color-text-muted);
  text-decoration: none;
  padding: 4px var(--space-md);
  font-size: 14px;
}
.nav-link[href=""] { visibility: hidden; pointer-events: none; }

/* Panel (settings) */
.panel {
  position: fixed;
  top: calc(var(--topbar-h) + 8px);
  right: var(--space-md);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  width: 300px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  z-index: 30;
}
.panel-section + .panel-section { margin-top: var(--space-md); }
.panel-label {
  color: var(--color-text-subtle);
  font-size: 10px;
  letter-spacing: 1.5px;
  margin: 0 0 8px;
}
.theme-picker { display: flex; gap: var(--space-sm); }
.theme-tile {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 11px;
}
.theme-tile.active { border-color: var(--color-accent); border-width: 2px; padding: 9px; }
.theme-light { background: #fafaf7; color: #1a1a1a; }
.theme-sepia { background: #f5efe4; color: #3a2e1f; }
.theme-dark  { background: #1a1a1a; color: #e8e2d2; }

.font-picker {
  display: flex;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.font-btn {
  flex: 1;
  padding: 8px;
  background: transparent;
  border: none;
  color: var(--color-text);
  font-family: var(--font-serif);
}
.font-current {
  flex: 2;
  text-align: center;
  padding: 8px;
  background: var(--color-border);
  font-family: var(--font-serif);
  font-size: 15px;
}

/* TOC drawer */
.drawer {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: 320px;
  background: var(--color-bg);
  border-right: 1px solid var(--color-border);
  padding: var(--space-md);
  z-index: 30;
  overflow-y: auto;
  box-shadow: 0 0 32px rgba(0,0,0,0.15);
}
.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}
.drawer-header h2 {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 400;
  margin: 0;
}
.drawer-close {
  background: transparent;
  border: none;
  font-size: 22px;
  color: var(--color-text-muted);
  line-height: 1;
  padding: 0 8px;
}
.toc-list a {
  display: block;
  padding: 8px 0;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
  text-decoration: none;
}
.toc-list a:hover { color: var(--color-accent); }
.toc-list a.current { font-weight: 600; color: var(--color-accent); }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 20;
}

/* Story pages */
/* Перебивает .reader-main bottom: var(--footer-h) — у страниц рассказов нет фиксированного футера */
.story-main { bottom: 0; }

.story-pagemeta {
  color: var(--color-text-subtle);
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: -16px auto 28px;
}

.story-end {
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--color-border);
}

.next-story {
  display: block;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 16px;
}
.next-story:hover { border-color: var(--color-accent); }

.next-story-label {
  display: block;
  color: var(--color-text-subtle);
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.next-story-title {
  display: block;
  font-size: calc(var(--reading-font-scale) * 20px);
  margin-bottom: 4px;
}
.next-story-teaser {
  display: block;
  color: var(--color-text-muted);
  font-size: calc(var(--reading-font-scale) * 14px);
  line-height: 1.5;
}

.all-stories {
  display: inline-block;
  color: var(--color-text-muted);
  font-size: 14px;
}

/* Mobile */
@media (max-width: 768px) {
  .chapter {
    padding: 24px 16px 64px;
    font-size: calc(var(--reading-font-scale) * 17px);
  }
  .chapter-title { font-size: calc(var(--reading-font-scale) * 22px); margin-bottom: 16px; }

  .panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: auto;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
  }
  .drawer { width: 100%; max-width: 100%; }
  .top-title { font-size: 12px; }
}
