/* Giao diện chung cho các trang sáng: trang chủ, chi tiết truyện, thể loại, tìm kiếm.
   Tách khỏi HTML để cache riêng (1 file, đổi ít) + tái dùng giữa các Razor Pages. */
:root {
  --bg: #f6f4ef;
  --surface: #fff;
  --ink: #211d17;
  --muted: #7b7263;
  --line: #e6ded0;
  --accent: #d8642a;
  --accent-ink: #fff;
  --info: #1565c0;
}

* { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
}

a { color: inherit; }

/* ---------- Header ---------- */
header.site {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.bar {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.logo {
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -.01em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.logo b { color: var(--accent); }

form.search {
  flex: 1 1 240px;
  max-width: 460px;
  min-width: 180px;
  display: flex;
}

form.search input {
  flex: 1;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-right: none;
  border-radius: 8px 0 0 8px;
  font-size: .95rem;
  background: var(--bg);
  color: var(--ink);
}

form.search button {
  padding: 0 18px;
  border: none;
  border-radius: 0 8px 8px 0;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  cursor: pointer;
}

/* ---------- Main ---------- */
main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

main.narrow { max-width: 960px; }

h1.section {
  font-size: 1.05rem;
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

h1.section::before {
  content: "";
  width: 4px;
  height: 20px;
  background: var(--accent);
  border-radius: 2px;
}

/* ---------- Breadcrumb ---------- */
.crumb {
  font-size: .82rem;
  color: var(--muted);
  margin: 0 0 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--accent); }
.crumb span.sep { opacity: .5; }

/* ---------- Slider "Truyện Đề Cử" ---------- */
.feature { margin-bottom: 30px; }
.slider { position: relative; }

.track {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 6px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.track::-webkit-scrollbar { display: none; }

.slide {
  flex: 0 0 auto;
  width: 150px;
  scroll-snap-align: start;
  text-decoration: none;
  color: inherit;
}

.slide .s-thumb {
  position: relative;
  aspect-ratio: 190 / 247;
  border-radius: 10px;
  overflow: hidden;
  background: var(--line);
  border: 1px solid var(--line);
}

.slide .s-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .25s ease;
}

.slide:hover .s-thumb img { transform: scale(1.04); }

.slide .s-thumb .hot {
  position: absolute;
  right: 6px;
  top: 6px;
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .03em;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--accent);
  color: #fff;
}

.slide .s-title {
  font-size: .86rem;
  font-weight: 600;
  margin-top: 7px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.4em;
}

.slide .s-ch { font-size: .74rem; color: var(--muted); }

.slider .nav {
  position: absolute;
  top: 34%;
  transform: translateY(-50%);
  z-index: 2;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .14);
}

.slider .nav.prev { left: -6px; }
.slider .nav.next { right: -6px; }

@media (max-width: 560px) {
  .slider .nav { display: none; }
  .slide { width: 132px; }
}

/* ---------- Lưới truyện ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 18px 14px;
}

.card { display: block; text-decoration: none; color: inherit; }

.thumb {
  position: relative;
  aspect-ratio: 190 / 247;
  border-radius: 10px;
  overflow: hidden;
  background: var(--line);
  border: 1px solid var(--line);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .25s ease;
}

.card:hover .thumb img { transform: scale(1.04); }

.badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  font-size: .72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(20, 16, 12, .82);
  color: #fff;
}

.card h2, .card h3.t {
  font-size: .92rem;
  font-weight: 600;
  margin: 9px 2px 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
}

.card .st { font-size: .75rem; color: var(--muted); margin-left: 2px; }
.card .st.completed { color: var(--info); }

.thumb .hot {
  position: absolute;
  right: 8px;
  top: 8px;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .03em;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
}

.card .meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .72rem;
  color: var(--muted);
  margin: 3px 2px 0;
}

.card .meta .dot { opacity: .45; }

/* ---------- Phân trang (link thật) ---------- */
.pager {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 32px;
  flex-wrap: wrap;
}

.pager a, .pager span {
  min-width: 38px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  font-size: .9rem;
  text-align: center;
  text-decoration: none;
}

.pager a.active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 700;
}

.pager span.gap { border: none; background: none; }

#status { color: var(--muted); padding: 40px 0; text-align: center; }
#status.err { color: #c0392b; }

/* ---------- Chi tiết truyện ---------- */
.hero { display: flex; gap: 22px; flex-wrap: wrap; }

.cover {
  width: 190px;
  aspect-ratio: 190 / 247;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: var(--line);
  flex: none;
}

.hero .meta { flex: 1; min-width: 240px; }

.hero .meta h1 { font-size: 1.5rem; margin: 0 0 10px; line-height: 1.25; }

.rows { font-size: .92rem; }
.rows div { display: flex; gap: 8px; margin: 4px 0; }
.rows span.k { color: var(--muted); min-width: 84px; }

.st { font-weight: 600; }
.st.completed { color: var(--info); }
.st.ongoing { color: #2e7d32; }

.hot-tag {
  display: inline-block;
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .03em;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  vertical-align: middle;
  margin-left: 8px;
}

.genre-list { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

.genre-list a {
  font-size: .78rem;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  text-decoration: none;
}

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

.read-btn {
  display: inline-block;
  padding: 10px 22px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 8px;
  text-decoration: none;
  font-weight: 700;
}

.follow-btn {
  padding: 10px 20px;
  border: 1px solid var(--accent);
  background: var(--surface);
  color: var(--accent);
  border-radius: 8px;
  font-weight: 700;
  font-size: .95rem;
  cursor: pointer;
}

.follow-btn.on { background: var(--accent); color: #fff; }

.desc {
  margin: 26px 0 0;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: #3a352c;
  white-space: pre-line;
  font-size: .95rem;
}

h3 {
  margin: 30px 0 12px;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

h3::before {
  content: "";
  width: 4px;
  height: 18px;
  background: var(--accent);
  border-radius: 2px;
}

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

.chapters a {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  font-size: .9rem;
}

.chapters a:hover { border-color: var(--accent); color: var(--accent); }

#error { margin-top: 20px; color: #c0392b; }

/* ---------- Truyện liên quan ---------- */
.related { margin-top: 34px; }

/* ---------- Bình luận ---------- */
.cmt-form, .cmt-replybox { display: flex; gap: 8px; margin: 10px 0; }

.cmt-form textarea, .cmt-replybox textarea {
  flex: 1; min-height: 46px; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 8px; font: inherit; font-size: .92rem; resize: vertical; background: var(--surface); color: var(--ink);
}

.cmt-form button, .cmt-replybox button {
  align-self: flex-end; padding: 9px 18px; border: none; border-radius: 8px;
  background: var(--accent); color: #fff; font-weight: 700; cursor: pointer;
}

.cmt-guest { color: var(--muted); font-size: .92rem; margin: 8px 0 4px; }
.cmt-guest a { color: var(--accent); font-weight: 700; }
.cmt { display: flex; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.cmt.reply { border-top: none; padding: 10px 0 4px; }
.cmt-avwrap { flex: none; }
.cmt-av { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--line); }
.cmt-av-ph { display: flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; background: var(--accent); }
.cmt.reply .cmt-av { width: 32px; height: 32px; }
.cmt-body { flex: 1; min-width: 0; }
.cmt-head { font-size: .9rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cmt-src { font-size: .68rem; font-weight: 700; color: var(--muted); border: 1px solid var(--line); padding: 1px 6px; border-radius: 999px; }
.cmt-time { color: var(--muted); font-size: .78rem; }
.cmt-content { font-size: .92rem; margin: 3px 0 6px; white-space: pre-line; word-break: break-word; }
.cmt-actions { display: flex; gap: 14px; font-size: .8rem; }
.cmt-actions button { border: none; background: none; color: var(--muted); cursor: pointer; padding: 0; font-size: .8rem; }
.cmt-actions button:hover { color: var(--accent); }
.cmt-like.on { color: var(--accent); font-weight: 700; }
.cmt-replies { margin-top: 6px; padding-left: 6px; border-left: 2px solid var(--line); }

.cmt-more {
  display: block; margin: 16px auto 0; padding: 9px 22px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); border-radius: 8px; cursor: pointer; font-size: .9rem;
}

/* ---------- Footer ---------- */
footer.site { background: var(--ink); color: #c9c1b4; margin-top: 40px; }

footer.site .in {
  max-width: 1120px;
  margin: 0 auto;
  padding: 34px 20px 20px;
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr;
  gap: 28px;
}

footer.site h3 { font-size: .95rem; color: #fff; margin: 0 0 12px; }
footer.site h3::before { content: none; }
footer.site p { font-size: .82rem; margin: 0 0 8px; }

footer.site a {
  color: #c9c1b4;
  text-decoration: none;
  font-size: .82rem;
  display: block;
  padding: 3px 0;
}

footer.site a:hover { color: var(--accent); }

footer.site .flogo {
  font-weight: 800;
  font-size: 1.15rem;
  color: #fff;
  margin-bottom: 10px;
  display: block;
}

footer.site .flogo b { color: var(--accent); }

footer.site .bottom {
  border-top: 1px solid rgba(255, 255, 255, .1);
  padding: 16px 20px;
  text-align: center;
  font-size: .76rem;
  color: #8f867a;
  max-width: 1120px;
  margin: 14px auto 0;
}

@media (max-width: 720px) {
  footer.site .in { grid-template-columns: 1fr; gap: 20px; }
}
