/* ── Reset & base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #0f0e0d;
  --bg2:        #1a1917;
  --bg3:        #242220;
  --text:       #e8e0d4;
  --muted:      #8a7f72;
  --accent:     #c9a84c;
  --accent2:    #7a9e7e;
  --yt-red:     #ff4444;
  --kofi-red:   #ff5f5f;
  --radius:     8px;
  --font-body:  "Sarabun", sans-serif;
  --font-serif: "Noto Serif Thai", serif;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }
.container--narrow { max-width: 900px; }

/* ── Header ───────────────────────────────────────────────────────────── */
.site-header {
  background: var(--bg2);
  border-bottom: 1px solid #2e2b28;
  padding: 1rem 0;
  position: sticky; top: 0; z-index: 100;
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }

.site-brand { display: flex; align-items: center; gap: .5rem; color: var(--text); }
.brand-icon  { font-size: 1.4rem; }
.brand-name  { font-weight: 700; font-size: 1.05rem; }
.brand-sub   { color: var(--muted); font-size: .85rem; }

.site-nav { display: flex; gap: 1.5rem; }
.site-nav a { color: var(--muted); font-size: .95rem; }
.site-nav a:hover { color: var(--text); text-decoration: none; }

/* ── Footer ───────────────────────────────────────────────────────────── */
.site-footer {
  background: var(--bg2);
  border-top: 1px solid #2e2b28;
  padding: 1.5rem 0;
  margin-top: auto;
  color: var(--muted);
  font-size: .85rem;
  text-align: center;
}
.footer-links { margin-top: .3rem; }
.footer-links a { color: var(--muted); }

/* ── Main content ─────────────────────────────────────────────────────── */
main.container { padding-top: 2rem; padding-bottom: 3rem; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: .55rem 1.2rem;
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  transition: opacity .15s;
}
.btn:hover { opacity: .85; text-decoration: none; }
.btn-primary  { background: var(--accent); color: #000; font-weight: 600; }
.btn-outline  { background: transparent; border: 1px solid var(--muted); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm       { padding: .3rem .8rem; font-size: .8rem; }
.btn-yt       { background: var(--yt-red); color: #fff; }
.btn-kofi     { background: var(--kofi-red); color: #fff; }

/* ── Badges ───────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-pd     { background: #2a3a2a; color: var(--accent2); }
.badge-genre  { background: var(--bg3); color: var(--muted); }
.badge-done   { background: #1e3a1e; color: #6fcf6f; }
.badge-pending{ background: #2a2a1e; color: #c9a84c; }
.badge-yt     { background: #3a1e1e; color: var(--yt-red); }
.badge-sm     { padding: .1rem .4rem; font-size: .7rem; }

/* ── Brand logo ───────────────────────────────────────────────────────── */
.brand-logo { height: 1.6rem; width: auto; max-width: 140px; display: block; }

/* ── Hero ─────────────────────────────────────────────────────────────── */
.hero { text-align: center; padding: 2rem 0 2rem; }
.hero-banner { max-width: 100%; max-height: 200px; width: auto; height: auto; border-radius: var(--radius); margin-bottom: 1.5rem; }
.hero h1 { font-family: var(--font-serif); font-size: 2rem; color: var(--accent); margin-bottom: .5rem; }
.hero-sub { color: var(--muted); font-size: 1.05rem; }

/* ── Books grid ───────────────────────────────────────────────────────── */
.books-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}
@media (max-width: 780px) { .books-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .books-grid { grid-template-columns: 1fr; } }

.book-card {
  background: var(--bg2);
  border: 1px solid #2e2b28;
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.book-cover {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: calc(var(--radius) - 4px);
  background: var(--bg3);
  display: block;
}

.book-meta { display: flex; gap: .4rem; flex-wrap: wrap; }
.book-title { font-family: var(--font-serif); font-size: 1.15rem; }
.book-title a { color: var(--text); }
.book-title a:hover { color: var(--accent); }
.book-title-th { color: var(--muted); font-size: .9rem; }
.book-title-th--large { font-size: 1.1rem; margin-bottom: .25rem; }
.book-author { color: var(--muted); font-size: .85rem; }

/* ── Progress bars ────────────────────────────────────────────────────── */
.progress-section { display: flex; flex-direction: column; gap: .4rem; }
.progress-row { display: flex; align-items: center; gap: .6rem; font-size: .8rem; }
.progress-label { color: var(--muted); width: 3.5rem; flex-shrink: 0; }
.progress-bar { flex: 1; height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.progress-fill          { height: 100%; background: var(--accent2); border-radius: 3px; transition: width .3s; }
.progress-fill--audio   { background: var(--accent); }
.progress-fill--yt      { background: var(--yt-red); }
.progress-pct { color: var(--muted); width: 3rem; text-align: right; flex-shrink: 0; }

/* ── Poll teaser ──────────────────────────────────────────────────────── */
.poll-teaser {
  margin-top: 3rem;
  padding: 2rem;
  background: var(--bg2);
  border: 1px solid #2e2b28;
  border-radius: var(--radius);
  text-align: center;
}
.poll-teaser h2 { margin-bottom: .5rem; }
.poll-teaser p  { color: var(--muted); margin-bottom: 1rem; }

/* ── Poll page ────────────────────────────────────────────────────────── */
.poll-page { max-width: 600px; margin: 0 auto; }
.poll-page h1 { font-size: 1.6rem; margin-bottom: .5rem; }
.poll-question { color: var(--muted); margin-bottom: 1.5rem; }
.poll-closed, .poll-notice { color: var(--accent); margin-bottom: 1rem; }

.poll-form { display: flex; flex-direction: column; gap: .75rem; margin-bottom: 2rem; }
.poll-option {
  display: flex; align-items: center; gap: .75rem;
  padding: .9rem 1.2rem;
  background: var(--bg2);
  border: 1px solid #2e2b28;
  border-radius: var(--radius);
  cursor: pointer;
}
.poll-option:hover { border-color: var(--accent); }
.poll-option input[type=radio] { accent-color: var(--accent); width: 1rem; height: 1rem; }

.poll-results { margin-top: 2rem; }
.poll-results h2 { font-size: 1rem; color: var(--muted); margin-bottom: 1rem; }
.result-row { display: flex; align-items: center; gap: .75rem; margin-bottom: .6rem; }
.result-label { flex: 1; font-size: .9rem; }
.result-votes { width: 6rem; text-align: right; color: var(--muted); font-size: .85rem; }

/* ── Book header / detail ─────────────────────────────────────────────── */
.book-header { padding: 2rem 0 1.5rem; border-bottom: 1px solid #2e2b28; margin-bottom: 2rem; }
.book-header h1 { font-family: var(--font-serif); font-size: 1.8rem; margin: .5rem 0 .25rem; }
.book-header-meta { display: flex; gap: .4rem; margin-bottom: .5rem; }

.back-link { color: var(--muted); font-size: .9rem; display: inline-block; margin-bottom: .75rem; }
.back-link:hover { color: var(--text); }

.chapter-list { display: flex; flex-direction: column; gap: .6rem; }
.chapter-list h2 { font-size: 1.1rem; color: var(--muted); margin-bottom: 1rem; }

.chapter-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: .75rem;
  padding: .75rem 1rem;
  background: var(--bg2);
  border: 1px solid #2e2b28;
  border-radius: var(--radius);
}
.chapter-row--done { border-left: 3px solid var(--accent2); }
.chapter-info { flex: 1; display: flex; gap: .75rem; align-items: baseline; }
.chapter-num  { color: var(--muted); font-size: .8rem; width: 3.5rem; flex-shrink: 0; }
.chapter-slug { font-size: .95rem; }
.chapter-badges { display: flex; gap: .3rem; flex-wrap: wrap; }
.chapter-actions { display: flex; gap: .4rem; }

/* ── Support page ─────────────────────────────────────────────────────── */
.support-page { max-width: 700px; margin: 0 auto; }
.support-page h1 { font-size: 1.6rem; margin-bottom: .5rem; }
.support-intro { color: var(--muted); margin-bottom: 2rem; }

.support-options { display: grid; gap: 1.5rem; }
.support-card {
  background: var(--bg2);
  border: 1px solid #2e2b28;
  border-radius: var(--radius);
  padding: 1.5rem;
}
.support-card h2 { font-size: 1.1rem; margin-bottom: .5rem; }
.support-card p  { color: var(--muted); margin-bottom: 1rem; font-size: .9rem; }
.support-card--credits { border-color: var(--accent); }
.support-card--credits ul { padding-left: 1.2rem; display: flex; flex-direction: column; gap: .4rem; }
.support-card--credits li { font-size: .95rem; }

.qr-wrapper { text-align: center; margin: 1rem 0; }
.qr-image   { max-width: 200px; border-radius: var(--radius); background: #fff; padding: .5rem; }

/* ── Preview page ─────────────────────────────────────────────────────── */
.preview-page { max-width: 680px; margin: 0 auto; }
.preview-header { margin-bottom: 2rem; border-bottom: 1px solid #2e2b28; padding-bottom: 1rem; }
.preview-header h1 { font-family: var(--font-serif); font-size: 1.5rem; margin: .5rem 0 .25rem; }

.chapter-text { line-height: 1.9; }
.narration  { margin: .25rem 0; }
.dialogue   { margin: .15rem 0; color: #d4c9b8; }
.thought    { margin: .15rem 0; color: var(--muted); font-style: italic; }
.scene-break { border: none; border-top: 1px solid #2e2b28; margin: 1.5rem 0; }
.spacer     { height: .75rem; }

/* ── Misc ─────────────────────────────────────────────────────────────── */
.muted { color: var(--muted); font-size: .875rem; }
.empty-state { text-align: center; color: var(--muted); padding: 3rem 0; }

@media (max-width: 600px) {
  .books-grid { grid-template-columns: 1fr; }
  .chapter-row { flex-direction: column; align-items: flex-start; }
}
