/* ============================================================
   THIẾT KẾ: "Thư Quán" — giấy dó cũ, mực, con dấu triện đỏ
   ============================================================
   Màu:
     --paper       nền giấy dó ngả vàng ấm
     --paper-line  đường kẻ trên giấy (đậm hơn nền 1 chút)
     --ink         mực đen ấm (không dùng đen thuần)
     --ink-soft    mực nhạt cho text phụ
     --seal        đỏ triện (con dấu) — đậm, ngả gạch, KHÔNG phải cam đất sét
     --seal-dark   đỏ triện đậm hơn, dùng cho hover
     --brass       đồng cũ, dùng cho viền/chi tiết nhỏ
   Font:
     Noto Serif       — tiêu đề, tên truyện (hỗ trợ tốt dấu tiếng Việt)
     Be Vietnam Pro   — giao diện, nhãn, mô tả
============================================================ */

:root {
  --paper: #EAE0C9;
  --paper-deep: #DED0AE;
  --paper-line: #C9B98D;
  --ink: #262019;
  --ink-soft: #6B5D47;
  --seal: #96281B;
  --seal-dark: #6E1D13;
  --brass: #A9843F;
  --card-shadow: rgba(38, 32, 25, 0.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Be Vietnam Pro', sans-serif;
  background-image:
    radial-gradient(circle at 20% 10%, rgba(169, 132, 63, 0.06), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(150, 40, 27, 0.05), transparent 45%);
}

h1, h2, h3, .wordmark, .story-title {
  font-family: 'Noto Serif', serif;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ---------- Header ---------- */
.site-header {
  padding: 2.5rem 1.5rem 1.5rem;
  text-align: center;
  border-bottom: 1px solid var(--paper-line);
}

.wordmark {
  font-size: 2rem;
  color: var(--ink);
  text-decoration: none;
  display: inline-block;
}

.wordmark::after {
  content: "印";
  color: var(--seal);
  font-size: 1rem;
  vertical-align: super;
  margin-left: 0.35rem;
}

.tagline {
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin: 0.4rem 0 0;
}

/* ---------- Layout chung ---------- */
.app-root {
  max-width: 880px;
  margin: 0 auto;
  padding: 2rem 1.25rem 6rem;
}

.loading-msg, .error-msg {
  text-align: center;
  color: var(--ink-soft);
  padding: 3rem 0;
}

.error-msg { color: var(--seal-dark); }

/* ---------- Danh sách truyện (trang chủ) ---------- */
.story-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1.25rem;
}

.story-card {
  background: var(--paper-deep);
  border: 1px solid var(--paper-line);
  border-radius: 2px;
  padding: 1.25rem;
  text-decoration: none;
  color: var(--ink);
  display: block;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.story-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 24px var(--card-shadow);
}

.story-card__title {
  font-family: 'Noto Serif', serif;
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  line-height: 1.3;
}

.story-card__desc {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 0 0 0.75rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.story-card__meta {
  font-size: 0.78rem;
  color: var(--brass);
  border-top: 1px solid var(--paper-line);
  padding-top: 0.6rem;
}

/* ---------- Trang chi tiết truyện ---------- */
.back-link {
  display: inline-block;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}
.back-link:hover { color: var(--seal); }

.story-header {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--paper-line);
  margin-bottom: 1.5rem;
}

.story-header__cover {
  width: 110px;
  height: 150px;
  flex-shrink: 0;
  background: var(--paper-deep);
  border: 1px solid var(--paper-line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brass);
  font-family: 'Noto Serif', serif;
  font-size: 1.8rem;
}

.story-title {
  font-size: 1.6rem;
  margin: 0 0 0.4rem;
}

.story-creator {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 0 0 0.75rem;
}

.story-description {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--ink);
  margin: 0 0 1rem;
}

.continue-btn {
  background: var(--seal);
  color: var(--paper);
  border: none;
  padding: 0.6rem 1.1rem;
  font-family: 'Be Vietnam Pro', sans-serif;
  font-weight: 500;
  font-size: 0.88rem;
  cursor: pointer;
  border-radius: 2px;
}
.continue-btn:hover { background: var(--seal-dark); }

/* ---------- Danh sách chapter (mục lục) ---------- */
.chapter-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.chapter-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 0.5rem;
  border-bottom: 1px solid var(--paper-line);
  cursor: pointer;
  background: transparent;
  transition: background 0.12s ease;
}

.chapter-row:hover { background: rgba(150, 40, 27, 0.05); }

.chapter-row--active {
  background: rgba(150, 40, 27, 0.09);
}

.chapter-row__num {
  font-family: 'Noto Serif', serif;
  font-size: 0.95rem;
  color: var(--seal);
  width: 2.2rem;
  text-align: right;
  flex-shrink: 0;
}

.chapter-row__title {
  flex: 1;
  font-size: 0.94rem;
}

.chapter-row__playing {
  font-size: 0.78rem;
  color: var(--seal);
  flex-shrink: 0;
}

/* ---------- Thanh player cố định dưới cùng ---------- */
.player-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  z-index: 100;
  box-shadow: 0 -6px 18px rgba(0,0,0,0.25);
}

.player-bar--hidden { display: none; }

.player-bar__info {
  display: flex;
  flex-direction: column;
  min-width: 140px;
  max-width: 220px;
}

.player-bar__story {
  font-size: 0.72rem;
  color: var(--brass);
}

.player-bar__chapter {
  font-family: 'Noto Serif', serif;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-bar__controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.player-btn {
  background: none;
  border: 1px solid rgba(234, 224, 201, 0.35);
  color: var(--paper);
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-btn--main {
  background: var(--seal);
  border-color: var(--seal);
  width: 2.5rem;
  height: 2.5rem;
}

.player-bar__progress {
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.75rem;
  color: var(--brass);
}

#player-seek {
  flex: 1;
  accent-color: var(--seal);
}

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  .story-header { flex-direction: column; }
  .player-bar { padding: 0.6rem 0.8rem; }
  .player-bar__info { max-width: 45%; }
}
