/* Biến giao diện cho 3 chế độ đọc: Light (mặc định), Sepia và Dark */
:root,
html[data-theme="light"] {
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --accent: #b45309;
  --accent-hover: #92400e;
  --accent-soft: #fef3c7;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.07);
}

html[data-theme="sepia"] {
  --bg-page: #efe6d5;
  --bg-surface: #f7f0e2;
  --bg-subtle: #e7dcc8;
  --text-primary: #2c2115;
  --text-secondary: #5c4934;
  --text-muted: #7b664f;
  --border-color: #dccdb5;
  --accent: #9a3412;
  --accent-hover: #7c2d12;
  --accent-soft: #ead7b7;
  --shadow-sm: 0 1px 2px rgba(44, 33, 21, 0.06);
  --shadow-md: 0 4px 12px rgba(44, 33, 21, 0.08);
}

html[data-theme="dark"] {
  --bg-page: #0b1120;
  --bg-surface: #111827;
  --bg-subtle: #1e293b;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border-color: #1f2937;
  --accent: #f59e0b;
  --accent-hover: #fbbf24;
  --accent-soft: rgba(245, 158, 11, 0.14);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.45);
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.2s ease, color 0.2s ease;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

.container {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header & Navigation */
.site-header {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.15rem;
  font-weight: 700;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-links a {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-links a:hover,
.nav-links a.active {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
}

.menu-toggle {
  display: none;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

@media (max-width: 768px) {
  .menu-toggle {
    display: inline-flex;
    align-items: center;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 16px;
    flex-direction: column;
    align-items: stretch;
    box-shadow: var(--shadow-md);
  }

  .nav-links.is-open {
    display: flex;
  }
}

/* Main content */
.main-content {
  flex: 1;
  padding: 28px 0 48px;
}

/* Hero featured story */
.hero-card {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 24px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 32px;
}

.hero-media {
  position: relative;
  min-height: 260px;
  background-color: var(--bg-subtle);
}

.hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-body {
  padding: 28px 28px 28px 4px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

@media (max-width: 820px) {
  .hero-card {
    grid-template-columns: 1fr;
  }
  .hero-body {
    padding: 20px;
  }
}

.badge-cat {
  display: inline-block;
  width: fit-content;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 999px;
  background-color: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 10px;
}

.hero-title {
  margin: 0 0 12px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.5rem, 2.5vw, 2.05rem);
  line-height: 1.25;
}

.hero-title a:hover {
  color: var(--accent);
}

.story-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-excerpt {
  color: var(--text-secondary);
  margin: 14px 0 20px;
  font-size: 0.98rem;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background-color: var(--accent);
  color: #ffffff;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 11px 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  width: fit-content;
  transition: background-color 0.15s ease;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background-color: var(--bg-subtle);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.btn-secondary:hover {
  background-color: var(--border-color);
}

/* Section Headers & Category Filter Pills */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.section-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.pill-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill-link {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.pill-link:hover,
.pill-link.active {
  border-color: var(--accent);
  color: var(--accent);
  background-color: var(--accent-soft);
}

/* Story Grid */
.story-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

@media (max-width: 960px) {
  .story-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .story-grid {
    grid-template-columns: 1fr;
  }
}

.story-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.story-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.story-card-thumb {
  aspect-ratio: 16 / 9;
  background-color: var(--bg-subtle);
  overflow: hidden;
}

.story-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.story-card-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.story-card-title {
  margin: 0 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.12rem;
  line-height: 1.35;
}

.story-card-title a:hover {
  color: var(--accent);
}

.story-card-excerpt {
  margin: 0 0 14px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  flex: 1;
}

/* Reader Layout (Article + Sidebar) */
.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 28px;
  align-items: start;
}

@media (max-width: 960px) {
  .article-layout {
    grid-template-columns: 1fr;
  }
}

.article-panel {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

@media (max-width: 600px) {
  .article-panel {
    padding: 20px 16px;
  }
}

.breadcrumbs {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 14px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.breadcrumbs a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.article-title {
  margin: 0 0 12px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.6rem, 3vw, 2.25rem);
  line-height: 1.24;
}

.article-cover {
  margin: 18px 0 22px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.article-cover img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

/* Reader Toolbar: Theme + Font Size + Chapter Drawer */
.reader-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  margin: 18px 0 22px;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.toolbar-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-right: 4px;
}

.tool-btn {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.tool-btn.active {
  border-color: var(--accent);
  background-color: var(--accent-soft);
  color: var(--accent);
}

.font-size-readout {
  font-size: 0.82rem;
  font-weight: 600;
  min-width: 38px;
  text-align: center;
  color: var(--text-secondary);
}

/* Chapter Progress & Collapsible Drawer */
.chapter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.chapter-badge {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--accent);
}

.progress-track {
  width: 100%;
  height: 6px;
  background-color: var(--bg-subtle);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 18px;
}

.progress-fill {
  height: 100%;
  background-color: var(--accent);
  border-radius: 999px;
}

.chapter-drawer {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 22px;
}

.chapter-drawer[hidden] {
  display: none;
}

.chapter-drawer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(115px, 1fr));
  gap: 8px;
}

.chapter-chip {
  display: block;
  text-align: center;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 0.85rem;
  font-weight: 600;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.chapter-chip.current {
  background-color: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

/* Story Prose */
.story-prose {
  font-family: Georgia, "Times New Roman", serif;
  font-size: var(--reader-font-size, 19px);
  line-height: 1.82;
  color: var(--text-primary);
}

.story-prose p {
  margin: 0 0 1.25em;
}

.story-prose h2 {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 1.25em;
  margin: 1.6em 0 0.7em;
  line-height: 1.35;
}

.prose-stamp {
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Khoảng cách an toàn quanh khung Quảng cáo (tránh Invalid Click trên Mobile) */
.ad-slot-wrapper {
  margin: 30px 0;
  padding: 12px;
  border-top: 1px dashed var(--border-color);
  border-bottom: 1px dashed var(--border-color);
  text-align: center;
  min-height: 100px;
}

.ad-slot-label {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* Chapter Navigation (cách xa khung quảng cáo tối thiểu 28px) */
.chapter-nav {
  margin-top: 32px;
  padding-top: 22px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.chapter-nav .btn-next-full {
  margin-left: auto;
  padding: 13px 26px;
  font-size: 1rem;
}

/* Disclaimer box */
.fiction-disclaimer {
  margin-top: 28px;
  padding: 14px 16px;
  border-radius: 8px;
  background-color: var(--bg-subtle);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Sidebar Widgets */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.widget-box {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.widget-title {
  margin: 0 0 14px;
  font-size: 1rem;
  font-weight: 700;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.widget-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.widget-item a {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.38;
  margin-bottom: 3px;
}

.widget-item a:hover {
  color: var(--accent);
}

.widget-item span {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Legal & Static Pages */
.legal-card {
  max-width: 820px;
  margin: 0 auto;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 32px;
  box-shadow: var(--shadow-sm);
}

.legal-card h1 {
  margin-top: 0;
  font-family: Georgia, "Times New Roman", serif;
}

.legal-card h2 {
  margin-top: 1.6em;
  font-size: 1.18rem;
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 20px;
}

.form-field label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.form-field input,
.form-field textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
}

.form-status {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
}

/* Footer */
.site-footer {
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: 28px 0;
  margin-top: auto;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-links {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.footer-links a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.footer-copy {
  font-size: 0.84rem;
  color: var(--text-muted);
}
