/*
Theme Name: Web Stories
Template: fictioneer
Description: Theme con của Fictioneer, giao diện giống dohangha.com.
Version: 1.0.0
Text Domain: web-stories
*/

/* Màu lấy theo Tailwind mà dohangha.com dùng (amber, rose, gray…). */
:root {
  --ws-bg: #f7f7f7;
  --ws-surface: #ffffff;
  --ws-text: #000000;
  --ws-muted: #6b7280;
  --ws-faint: #9ca3af;
  --ws-border: rgba(0, 0, 0, 0.05);
  --ws-amber-400: #fbbf24;
  --ws-amber-500: #f59e0b;
  --ws-amber-600: #d97706;
  --ws-amber-700: #b45309;
  --ws-accent-text: #d97706;
  --ws-shadow-lg: 0 12px 32px -12px rgba(0, 0, 0, 0.22);
  --ws-shadow-card: 0 4px 16px -4px rgba(0, 0, 0, 0.2);
  --ws-shadow-card-hover: 0 10px 28px -6px rgba(0, 0, 0, 0.3);
  --ws-font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

:root[data-mode=dark] {
  --ws-bg: #1f2028;
  --ws-surface: #2e3039;
  --ws-text: #ffffff;
  --ws-muted: #64748b;
  --ws-faint: #9ca3af;
  --ws-border: rgba(255, 255, 255, 0.05);
  --ws-accent-text: #fbbf24;
  --ws-shadow-lg: 0 12px 32px -12px rgba(0, 0, 0, 0.6);
  --ws-shadow-card: 0 4px 16px -4px rgba(0, 0, 0, 0.5);
  --ws-shadow-card-hover: 0 10px 28px -6px rgba(0, 0, 0, 0.65);
}

/* Fictioneer chỉ dùng màu này cho trang truyện/chương/bài viết. */
:root[data-mode=light] { --primary-400: #f59e0b; --primary-500: #d97706; --primary-600: #b45309; }
:root[data-mode=dark] { --primary-400: #fcd34d; --primary-500: #fbbf24; --primary-600: #f59e0b; }

body { background: var(--ws-bg); }

.ws-container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 5vw;
  box-sizing: border-box;
}

@media (min-width: 768px) {
  .ws-container { padding: 0 min(5vw, 64px); }
}

.ws-header *, .ws-home *, .ws-footer * { box-sizing: border-box; }

.ws-header, .ws-home, .ws-footer { font-family: var(--ws-font); color: var(--ws-text); }

.ws-header a, .ws-home a, .ws-footer a { text-decoration: none; color: inherit; }

.ws-home ul { list-style: none; margin: 0; padding: 0; }

/* Ẩn khi đang ở chế độ ngược lại (icon mặt trời/mặt trăng). */
:root[data-mode=dark] .ws-only-light, :root:not([data-mode=dark]) .ws-only-dark { display: none; }

/* ============================================================
   HEADER
   ============================================================ */

.ws-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--ws-border);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

:root[data-mode=dark] .ws-header { background: rgba(0, 0, 0, 0.6); }

.ws-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-top: 16px;
  padding-bottom: 16px;
}

.ws-logo {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 10px;
  transition: opacity .2s;
}

.ws-logo:hover { opacity: .8; }

.ws-logo__icon {
  display: flex;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: linear-gradient(to bottom right, #f59e0b, #e11d48);
  font-size: 18px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}

.ws-logo__text {
  white-space: nowrap;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.ws-logo__text span { color: var(--ws-amber-600); }
:root[data-mode=dark] .ws-logo__text span { color: var(--ws-amber-400); }

.ws-nav {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 4px;
  margin: 0 0 0 24px;
  padding: 0;
  list-style: none;
}

.ws-nav__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  border-radius: 9999px;
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ws-muted) !important;
  transition: all .3s;
}

.ws-nav__link:hover { background: rgba(0, 0, 0, .05); color: var(--ws-text) !important; }
:root[data-mode=dark] .ws-nav__link:hover { background: rgba(255, 255, 255, .1); }

.ws-nav__link.is-active { background: #000; color: #fff !important; }
:root[data-mode=dark] .ws-nav__link.is-active { background: #fff; color: #000 !important; }

.ws-header__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.ws-icon-btn {
  display: flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0, 0, 0, .1);
  border-radius: 9999px;
  background: transparent;
  color: var(--ws-text);
  cursor: pointer;
  padding: 0;
}

:root[data-mode=dark] .ws-icon-btn { border-color: rgba(255, 255, 255, .15); }

.ws-mode-toggle { display: flex; }

.ws-burger { display: none; }

@media (max-width: 1023px) {
  .ws-burger { display: flex; }

  .ws-nav {
    order: 3;
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    margin: 8px 0 0;
  }

  .ws-menu-toggle:checked ~ .ws-nav { display: flex; }

  .ws-nav__link { width: 100%; padding: 10px 14px; font-size: 15px; }
}

/* ============================================================
   KHỐI CHUNG
   ============================================================ */

.ws-home { padding: 24px 0 80px; }

.ws-zone { display: flex; flex-direction: column; gap: 28px; margin-bottom: 48px; scroll-margin-top: 140px; }

.ws-zone-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.ws-zone-heading h2 { margin: 0; font-size: 24px; font-weight: 700; line-height: 1.3; font-family: var(--ws-font); }
.ws-zone-heading p { margin: 4px 0 0; font-size: 14px; color: var(--ws-muted); }

.ws-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  border-radius: 9999px;
  background: var(--ws-amber-500);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  color: #fff !important;
  transition: background-color .3s;
}

.ws-btn:hover { background: var(--ws-amber-600); }

.ws-btn--outline {
  border: 1px solid #d1d5db;
  background: transparent;
  color: var(--ws-text) !important;
}

.ws-btn--outline:hover { border-color: var(--ws-amber-500); background: transparent; color: var(--ws-accent-text) !important; }
:root[data-mode=dark] .ws-btn--outline { border-color: rgba(255, 255, 255, .2); }

.ws-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .25em;
  text-transform: uppercase;
  color: var(--ws-accent-text);
}

.ws-eyebrow--light { color: #fbbf24; }

.ws-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.ws-chip {
  border-radius: 9999px;
  background: #fef3c7;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 500;
  color: #92400e;
}

:root[data-mode=dark] .ws-chip { background: rgba(120, 53, 15, .4); color: #fde68a; }

.ws-badge {
  border-radius: 9999px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}

.ws-badge--ongoing { background: #10b981; }
.ws-badge--complete { background: #3b82f6; }
.ws-badge--post { background: var(--ws-amber-500); }

.ws-divider { display: flex; align-items: center; gap: 16px; margin-bottom: 48px; }

.ws-divider__line {
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, #fbbf24, #f59e0b);
}

.ws-divider__line--right { background: linear-gradient(to left, transparent, #fbbf24, #f59e0b); }

.ws-divider__label {
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .25em;
  text-transform: uppercase;
  color: var(--ws-accent-text);
}

.ws-empty { margin: 0; color: var(--ws-muted); font-size: 14px; }

@media (max-width: 767px) {
  .ws-hide-mobile { display: none; }
}

/* ============================================================
   BANNER
   ============================================================ */

.ws-hero {
  position: relative;
  display: flex;
  min-height: 220px;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
  border-radius: 16px;
  margin-bottom: 48px;
}

@media (min-width: 640px) { .ws-hero { min-height: 260px; margin-bottom: 64px; } }
@media (min-width: 1024px) { .ws-hero { min-height: 280px; } }

.ws-hero__image { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.ws-hero__shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, .95), rgba(0, 0, 0, .6), transparent);
}

.ws-hero__content {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px;
}

@media (min-width: 640px) { .ws-hero__content { gap: 12px; padding: 28px 40px; } }

.ws-hero__title {
  display: -webkit-box;
  max-width: 672px;
  margin: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-family: var(--ws-font);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.25;
  color: #f2e9d8;
}

@media (min-width: 640px) { .ws-hero__title { font-size: 36px; } }

.ws-hero__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding-top: 4px; }

.ws-hero__chip {
  border: 1px solid rgba(251, 191, 36, .4);
  border-radius: 9999px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  color: #fde68a;
}

.ws-hero__extra { font-size: 12px; font-weight: 600; color: #fde68a; }
.ws-hero__date { font-size: 12px; color: #a69c89; }

.ws-hero__cta {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  border: 1px solid #fbbf24;
  border-radius: 9999px;
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #fcd34d !important;
  transition: all .3s;
}

.ws-hero__cta:hover { background: #fbbf24; color: #000 !important; }
.ws-hero__cta span { transition: transform .3s; }
.ws-hero__cta:hover span { transform: translateX(4px); }

@media (min-width: 640px) { .ws-hero__cta { margin-top: 12px; padding: 10px 24px; } }

/* ============================================================
   KHU TRUYỆN DÀI
   ============================================================ */

.ws-long-top { display: flex; flex-direction: column; gap: 24px; }

@media (min-width: 1024px) { .ws-long-top { flex-direction: row; } }

.ws-featured { min-width: 0; }

@media (min-width: 1024px) { .ws-featured { flex: 2; } }

.ws-featured__item {
  display: flex;
  height: 100%;
  flex-direction: column;
  overflow: hidden;
  border-radius: 22px;
  background: var(--ws-surface);
  box-shadow: var(--ws-shadow-lg);
}

.ws-featured__item[hidden] { display: none; }

@media (min-width: 640px) { .ws-featured__item { flex-direction: row; } }

.ws-featured__cover { position: relative; display: block; flex-shrink: 0; aspect-ratio: 16 / 9; }

@media (min-width: 640px) { .ws-featured__cover { width: 46%; min-height: 300px; aspect-ratio: auto; } }

.ws-featured__cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.ws-featured__badge { position: absolute; left: 12px; top: 12px; font-size: 11px; padding: 2px 10px; }

.ws-featured__body {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  padding: 20px;
}

@media (min-width: 640px) { .ws-featured__body { padding: 24px; } }

.ws-featured__title {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.35;
  transition: color .3s;
}

.ws-featured__title:hover { color: var(--ws-accent-text); }

@media (min-width: 640px) { .ws-featured__title { font-size: 24px; } }

.ws-featured__meta { margin: 0; font-size: 14px; color: var(--ws-muted); }
.ws-featured__meta strong { color: var(--ws-text); }

.ws-featured__desc {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  font-size: 14px;
  line-height: 1.65;
  color: var(--ws-muted);
}

.ws-featured__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 4px; }

.ws-dots { display: flex; align-items: center; gap: 6px; }

.ws-dot {
  width: 8px;
  height: 8px;
  border: 0;
  border-radius: 9999px;
  background: #d1d5db;
  padding: 0;
  cursor: pointer;
  transition: all .3s;
}

.ws-dot.is-active { width: 24px; background: var(--ws-amber-500); }
:root[data-mode=dark] .ws-dot:not(.is-active) { background: rgba(255, 255, 255, .3); }

.ws-new-chapters {
  min-width: 0;
  border-radius: 22px;
  background: var(--ws-surface);
  padding: 20px 20px 8px;
  box-shadow: var(--ws-shadow-lg);
}

@media (min-width: 1024px) { .ws-new-chapters { flex: 1; } }

.ws-new-chapters h3 { margin: 0 0 8px; font-family: var(--ws-font); font-size: 20px; font-weight: 700; }

.ws-new-chapters li { border-top: 1px solid var(--ws-border); }

.ws-new-chapters a {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 -8px;
  border-radius: 12px;
  padding: 12px 8px;
  transition: background-color .2s;
}

.ws-new-chapters a:hover { background: #f9fafb; }
:root[data-mode=dark] .ws-new-chapters a:hover { background: rgba(255, 255, 255, .05); }

.ws-new-chapters__thumb {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 12px;
  background: #e5e7eb;
}

.ws-new-chapters__thumb img { width: 100%; height: 100%; object-fit: cover; }

.ws-new-chapters__text { display: flex; min-width: 0; flex: 1; flex-direction: column; gap: 2px; }

.ws-new-chapters__story {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: #6b7280;
}

:root[data-mode=dark] .ws-new-chapters__story { color: #b8ae9c; }

.ws-new-chapters__title {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
}

.ws-new-chapters__title b { color: var(--ws-amber-700); }
:root[data-mode=dark] .ws-new-chapters__title b { color: var(--ws-amber-400); }

.ws-pill-free {
  flex-shrink: 0;
  border-radius: 9999px;
  background: #d1fae5;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  color: #065f46;
}

:root[data-mode=dark] .ws-pill-free { background: #022c22; color: #6ee7b7; }

.ws-tabs {
  display: flex;
  align-self: flex-start;
  border-radius: 9999px;
  background: var(--ws-surface);
  padding: 4px;
  box-shadow: 0 4px 14px -6px rgba(0, 0, 0, .2);
  margin-bottom: -12px;
}

.ws-tabs button {
  height: 36px;
  white-space: nowrap;
  border: 0;
  border-radius: 9999px;
  background: transparent;
  padding: 0 14px;
  font-family: var(--ws-font);
  font-size: 13px;
  font-weight: 600;
  color: #4b5563;
  cursor: pointer;
  transition: color .2s, background-color .2s;
}

.ws-tabs button:hover { color: #000; }
:root[data-mode=dark] .ws-tabs button { color: #d8cfbf; }
:root[data-mode=dark] .ws-tabs button:hover { color: #fff; }
.ws-tabs button.is-active { background: var(--ws-amber-500); color: #fff; }

/* ============================================================
   THẺ TRUYỆN
   ============================================================ */

.ws-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

@media (min-width: 640px) { .ws-grid { gap: 20px; } }
@media (min-width: 768px) { .ws-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .ws-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

.ws-grid > li[hidden] { display: none; }

.ws-card { display: block; height: 100%; }

.ws-card article {
  display: flex;
  height: 100%;
  flex-direction: column;
  overflow: hidden;
  border-radius: 12px;
  background: var(--ws-surface);
  box-shadow: var(--ws-shadow-card);
  transition: all .3s;
}

.ws-card:hover article { transform: translateY(-4px); box-shadow: var(--ws-shadow-card-hover); }

.ws-card__cover {
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
  aspect-ratio: 3 / 4;
  background: #e5e7eb;
}

@media (min-width: 640px) { .ws-card__cover { aspect-ratio: 16 / 9; } }

.ws-card__cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .5s ease-out;
}

.ws-card:hover .ws-card__cover img { transform: scale(1.1); }

.ws-card__badge { position: absolute; left: 8px; top: 8px; }

.ws-card__count {
  position: absolute;
  right: 8px;
  top: 8px;
  border-radius: 9999px;
  background: rgba(0, 0, 0, .7);
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
}

.ws-card__body { display: flex; flex: 1; flex-direction: column; gap: 6px; padding: 12px; }

.ws-card__title {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-family: var(--ws-font);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  text-transform: uppercase;
  transition: color .3s;
}

@media (min-width: 640px) { .ws-card__title { font-size: 16px; } }

.ws-card:hover .ws-card__title { color: var(--ws-accent-text); }

.ws-card__meta { margin: 0; font-size: 11px; color: var(--ws-faint); }

.ws-card__desc {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 12px;
  line-height: 1.6;
  color: var(--ws-muted);
}

@media (min-width: 640px) { .ws-card__desc { -webkit-line-clamp: 3; font-size: 13px; } }

.ws-card__genres { margin: auto 0 0; padding-top: 4px; font-size: 11px; color: var(--ws-faint); }

/* Ô tìm kiếm ở trang danh sách truyện. */
.ws-filter-bar { display: flex; justify-content: flex-end; margin-bottom: -12px; }

.ws-search {
  width: 100%;
  max-width: 320px;
  height: 44px;
  border: 1px solid #d1d5db;
  border-radius: 9999px;
  background: var(--ws-surface);
  padding: 0 18px;
  font-family: var(--ws-font);
  font-size: 14px;
  color: var(--ws-text);
}

/* ============================================================
   CHÂN TRANG
   ============================================================ */

/* Ẩn chân trang mặc định của Fictioneer, chỉ giữ chân trang mới. */
.footer__wrapper > :not(.ws-footer) { display: none !important; }

.footer { background: transparent !important; }

.ws-footer {
  width: 100%;
  padding: 40px 0 24px;
  border-top: 1px solid var(--ws-border);
  text-align: center;
}

.ws-footer__nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 24px;
  font-size: 14px;
  color: var(--ws-muted);
}

.ws-footer__nav a { color: var(--ws-muted) !important; transition: color .3s; }
.ws-footer__nav a:hover { color: var(--ws-text) !important; }

.ws-footer__copy { margin: 16px 0 0; font-size: 12px; color: var(--ws-faint); }

/* Khung #site của Fictioneer căn giữa các phần tử con (flex), nên header,
   nội dung và chân trang bị co theo nội dung: ép giãn hết chiều ngang. */
.ws-header, .ws-home, .footer {
  width: 100%;
  max-width: none;
  align-self: stretch;
}

/* ============================================================
   LINK TRONG NỘI DUNG BÀI / CHƯƠNG
   ============================================================ */

/* Link trong bài phải nhìn ra ngay là link: chữ xanh, gạch chân. */
.post__main a,
.chapter__content a,
.story__summary a,
.page__main a {
  color: #2563eb !important;
  font-weight: 600;
  text-decoration: underline !important;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color .2s;
}

.post__main a:hover,
.chapter__content a:hover,
.story__summary a:hover,
.page__main a:hover { color: #1d4ed8 !important; }

:root[data-mode=dark] .post__main a,
:root[data-mode=dark] .chapter__content a,
:root[data-mode=dark] .story__summary a,
:root[data-mode=dark] .page__main a { color: #60a5fa !important; }

:root[data-mode=dark] .post__main a:hover,
:root[data-mode=dark] .chapter__content a:hover,
:root[data-mode=dark] .story__summary a:hover,
:root[data-mode=dark] .page__main a:hover { color: #93c5fd !important; }

/* Link mở trang khác (NovelUpdates…) có thêm mũi tên ↗. */
.post__main a[target="_blank"]::after { content: " ↗"; font-size: .8em; text-decoration: none; display: inline-block; }
