/*
Theme Name: Tranh Truyện
Description: Theme đọc truyện tranh tiếng Việt, dùng cùng plugin VietManga API. Bố cục trang chủ có mục đề cử, truyện mới cập nhật và bảng xếp hạng. Phong cách khung truyện in: viền mực đậm, bóng đổ cứng, nền chấm bi (screentone). Có chế độ sáng/tối.
Version: 1.4.0
Requires PHP: 7.4
Text Domain: tranhtruyen
*/

:root {
  --vmx-bg: #eef0f3;
  --vmx-surface: #ffffff;
  --vmx-ink: #15171c;
  --vmx-muted: #596071;
  --vmx-line: #15171c;
  --vmx-shadow: #15171c;
  --vmx-accent: #2447d6;
  --vmx-accent-ink: #ffffff;
  --vmx-mark: #ffd84d;
  --tt-dot: rgba(36, 71, 214, .22);
  --tt-font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --vmx-bg: #111319; --vmx-surface: #1a1d26; --vmx-ink: #eceef3; --vmx-muted: #9aa1b2;
    --vmx-line: #3d4357; --vmx-shadow: #000; --vmx-accent: #8aa0ff; --vmx-accent-ink: #0d0e12; --tt-dot: rgba(138, 160, 255, .2);
  }
}
:root[data-theme="dark"] {
  --vmx-bg: #111319; --vmx-surface: #1a1d26; --vmx-ink: #eceef3; --vmx-muted: #9aa1b2;
  --vmx-line: #3d4357; --vmx-shadow: #000; --vmx-accent: #8aa0ff; --vmx-accent-ink: #0d0e12; --tt-dot: rgba(138, 160, 255, .2);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--vmx-bg); color: var(--vmx-ink); font: 400 1rem/1.65 var(--tt-font); }
img { max-width: 100%; }
a { color: var(--vmx-accent); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 100; padding: 10px 14px; background: var(--vmx-mark); color: #15171c; font-weight: 700; }
.skip:focus { top: 8px; }
:focus-visible { outline: 3px solid var(--vmx-accent); outline-offset: 2px; }

/* Header */
.site-head { position: sticky; top: 0; z-index: 40; background: var(--vmx-surface); border-bottom: 2px solid var(--vmx-line); }
.admin-bar .site-head { top: 32px; }
@media (max-width: 782px) { .admin-bar .site-head { top: 0; } }
.site-head__in { max-width: 1120px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 14px 24px; flex-wrap: wrap; }
.brand { font-size: 1.35rem; font-weight: 800; letter-spacing: -.01em; text-decoration: none; color: var(--vmx-ink); padding: 2px 8px; margin-left: -8px; background: linear-gradient(transparent 62%, var(--vmx-mark) 62%); }
.site-nav ul { display: flex; gap: 6px 18px; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.site-nav a { color: var(--vmx-ink); text-decoration: none; font-weight: 600; padding: 6px 0; border-bottom: 2px solid transparent; }
.site-nav a:hover, .site-nav .current-menu-item > a { border-bottom-color: var(--vmx-accent); }
.head-search { margin-left: auto; }
.head-search input { font: inherit; min-height: 40px; width: 220px; max-width: 100%; padding: 6px 12px; color: var(--vmx-ink); background: var(--vmx-bg); border: 2px solid var(--vmx-line); border-radius: 6px; }
.theme-toggle { font: inherit; font-weight: 600; min-height: 40px; padding: 4px 12px; color: var(--vmx-ink); background: var(--vmx-surface); border: 2px solid var(--vmx-line); border-radius: 6px; cursor: pointer; }
.theme-toggle:hover { background: var(--vmx-mark); color: #15171c; }

/* Hero: nền chấm bi như tờ screentone, mờ dần xuống dưới */
.hero { position: relative; border-bottom: 2px solid var(--vmx-line); background: var(--vmx-surface); overflow: hidden; }
.hero::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle, var(--tt-dot) 2px, transparent 2.6px) 0 0 / 14px 14px; -webkit-mask-image: linear-gradient(100deg, #000 0%, transparent 70%); mask-image: linear-gradient(100deg, #000 0%, transparent 70%); pointer-events: none; }
.hero__in { position: relative; max-width: 1120px; margin: 0 auto; padding: clamp(28px, 5vw, 56px) 20px; }
.hero h1 { margin: 0 0 12px; max-width: 16ch; text-wrap: balance; font-size: clamp(2.2rem, 6.5vw, 4.2rem); line-height: 1.04; font-weight: 800; letter-spacing: -.025em; }
.hero p { margin: 0 0 24px; max-width: 46ch; color: var(--vmx-muted); font-size: 1.1rem; }
.hero form { display: flex; flex-wrap: wrap; gap: 10px; max-width: 560px; }
.hero input[type="search"] { flex: 1 1 240px; font: inherit; min-height: 48px; padding: 8px 14px; color: var(--vmx-ink); background: var(--vmx-bg); border: 2px solid var(--vmx-line); border-radius: 6px; box-shadow: 3px 3px 0 var(--vmx-shadow); }

/* Các mục trên trang chủ */
.shelf { max-width: 1120px; margin: 0 auto; padding: 44px 20px 8px; }
.shelf__head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.shelf__head h2 { margin: 0; font-size: 1.6rem; line-height: 1.2; }
.shelf__head a { font-weight: 700; }
.notice-box { max-width: 1120px; margin: 32px auto; padding: 16px 20px; border: 2px solid var(--vmx-line); background: var(--vmx-surface); }

/* Trang thường */
.content { max-width: 760px; margin: 0 auto; padding: 36px 20px 56px; }
.content h1 { line-height: 1.2; }

/* Footer */
.site-foot { margin-top: 56px; border-top: 2px solid var(--vmx-line); background: var(--vmx-surface); color: var(--vmx-muted); font-size: .9rem; }
.site-foot__in { max-width: 1120px; margin: 0 auto; padding: 24px 20px; display: grid; gap: 6px; }
.site-foot p { margin: 0; max-width: 72ch; }


/* Thể loại và tiếp tục đọc trên trang chủ */
.shelf .vmx-chips { padding-top: 0; }
.shelf:has(> .vmx-continue[hidden]) { display: none; }
.shelf--tight { padding-top: 28px; padding-bottom: 0; }

/* ===== v1.3: bố cục trang chủ kiểu cổng truyện ===== */
.site-head__in { padding-top: 10px; padding-bottom: 10px; }
.site-nav ul { align-items: center; }
.site-nav li { position: relative; }
.site-nav summary { list-style: none; cursor: pointer; font-weight: 600; padding: 6px 0; border-bottom: 2px solid transparent; }
.site-nav summary::-webkit-details-marker { display: none; }
.site-nav summary::after { content: " \25BE"; font-size: .8em; }
.site-nav details[open] summary, .site-nav summary:hover { border-bottom-color: var(--vmx-accent); }
.mega__panel { position: absolute; left: 0; top: calc(100% + 8px); z-index: 60; width: min(640px, 92vw); padding: 16px; background: var(--vmx-surface); border: 2px solid var(--vmx-line); box-shadow: 5px 5px 0 var(--vmx-shadow); }
.mega__panel ul { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 2px 14px; margin: 0 0 10px; padding: 0; list-style: none; }
.mega__panel li a { display: block; padding: 5px 0; font-weight: 500; border: 0; }
.mega__panel li a:hover { color: var(--vmx-accent); text-decoration: underline; }
.mega__all { display: inline-block; padding-top: 10px; border-top: 1px solid var(--vmx-line); font-size: .9rem; font-weight: 600; }

.block__head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 2px solid var(--vmx-line); }
.block__head h2 { margin: 0; font-size: 1.3rem; line-height: 1.2; }
.block__head a { font-size: .92rem; font-weight: 600; }

/* Đề cử */
.feat { border-bottom: 2px solid var(--vmx-line); background: var(--vmx-surface); }
.feat__in { max-width: 1120px; margin: 0 auto; padding: 22px 20px 26px; }
.feat__btns { display: inline-flex; gap: 8px; }
.feat__btn { width: 36px; height: 36px; font: inherit; font-size: 1.4rem; line-height: 1; color: var(--vmx-ink); background: var(--vmx-bg); border: 2px solid var(--vmx-line); border-radius: 6px; cursor: pointer; }
.feat__btn:hover { background: var(--vmx-mark); color: #15171c; }
.feat__track { display: flex; gap: 14px; margin: 0; padding: 2px 2px 8px; list-style: none; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: thin; }
.feat__track li { flex: 0 0 150px; scroll-snap-align: start; }
.feat__track a { display: block; text-decoration: none; }
.feat__cover { position: relative; display: block; aspect-ratio: 2 / 3; overflow: hidden; background: var(--vmx-bg); border: 2px solid var(--vmx-line); }
.feat__cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.feat__name { position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 8px 8px; font-size: .88rem; font-weight: 700; line-height: 1.3; color: #fff; background: linear-gradient(transparent, rgba(8, 10, 14, .92)); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.feat__track a:hover .feat__cover, .feat__track a:focus-visible .feat__cover { border-color: var(--vmx-accent); }

/* Hai cột */
.tt-home { max-width: 1120px; margin: 0 auto; padding: 32px 20px 0; display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 36px; align-items: start; }
.home__main .vmx-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 22px 16px; }
.home__main .block + .block { margin-top: 8px; }
.home__main .vmx-continue { margin-bottom: 28px; }
.home__side { display: grid; gap: 24px; }
.side-box { background: var(--vmx-surface); border: 2px solid var(--vmx-line); padding: 16px; }
.side-box h2 { margin: 0 0 12px; padding-bottom: 8px; font-size: 1.1rem; border-bottom: 2px solid var(--vmx-line); }
.rank { list-style: none; margin: 0; padding: 0; }
.rank__i { display: grid; grid-template-columns: 26px 44px minmax(0, 1fr); gap: 10px; align-items: center; padding: 8px 0; }
.rank__i + .rank__i { border-top: 1px solid color-mix(in srgb, var(--vmx-line) 22%, transparent); }
.rank__n { font-size: 1.15rem; font-weight: 800; text-align: center; color: var(--vmx-muted); }
.rank__i--1 .rank__n, .rank__i--2 .rank__n, .rank__i--3 .rank__n { color: var(--vmx-accent); }
.rank__thumb { display: block; aspect-ratio: 2 / 3; overflow: hidden; background: var(--vmx-bg); border: 1px solid var(--vmx-line); }
.rank__thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.rank__t a { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--vmx-ink); font-weight: 700; line-height: 1.35; text-decoration: none; }
.rank__t a:hover { color: var(--vmx-accent); text-decoration: underline; }
.rank__t small { display: block; margin-top: 2px; color: var(--vmx-muted); }
.side-box .vmx-chips--wrap { gap: 6px; }
.side-box .vmx-chip { min-height: 30px; padding: 2px 11px; font-size: .85rem; }

@media (max-width: 900px) {
  .tt-home { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .mega__panel { position: static; width: auto; margin-top: 8px; box-shadow: none; }
  .feat__track li { flex-basis: 120px; }
}

/* ===== v1.4: khung trang, header và footer tùy biến ===== */
.site { display: flex; flex-direction: column; min-height: 100vh; }
.site > header, .site > main, .site > footer { width: 100%; }
.site > main { flex: 1 0 auto; }
.site-foot { margin-top: 56px; }

.brand-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-wrap .custom-logo-link { display: inline-flex; align-items: center; }
.custom-logo { display: block; width: auto; height: var(--tt-logo-h, 40px); max-width: 220px; object-fit: contain; }
.brand-tag { font-size: .8rem; color: var(--vmx-muted); max-width: 22ch; line-height: 1.3; }
body.tt-head-static .site-head { position: static; }
.head-tools { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.head-tools .head-search { margin-left: 0; }
.nav-toggle { display: none; min-height: 40px; padding: 4px 14px; font: inherit; font-weight: 600; color: var(--vmx-ink); background: var(--vmx-surface); border: 2px solid var(--vmx-line); border-radius: 6px; cursor: pointer; }

.site-foot__in { display: block; padding: 32px 20px 20px; }
.foot-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) repeat(2, minmax(0, 1fr)); gap: 28px 40px; padding-bottom: 24px; }
.foot-about .brand { display: inline-block; margin-bottom: 8px; }
.foot-text { max-width: 46ch; color: var(--vmx-muted); }
.foot-text p { margin: 8px 0 0; }
.foot-col h2 { margin: 0 0 10px; font-size: 1rem; color: var(--vmx-ink); }
.foot-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.foot-col a { color: var(--vmx-muted); text-decoration: none; }
.foot-col a:hover { color: var(--vmx-accent); text-decoration: underline; }
.foot-bottom { display: grid; gap: 4px; padding-top: 16px; border-top: 1px solid color-mix(in srgb, var(--vmx-line) 30%, transparent); font-size: .88rem; }
.foot-bottom p { margin: 0; max-width: 80ch; }
.foot-bottom a { color: var(--vmx-accent); }

@media (max-width: 900px) {
  .nav-toggle { display: inline-flex; align-items: center; }
  .head-tools { margin-left: auto; }
  .site-nav { display: none; flex: 1 0 100%; order: 10; }
  .site-nav.is-open { display: block; }
  .site-nav > ul, .site-nav ul:first-child { flex-direction: column; align-items: flex-start; }
  .site-nav > ul > li, .site-nav li { width: 100%; }
  .foot-grid { grid-template-columns: 1fr 1fr; }
  .foot-about { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .head-tools { flex: 1 0 100%; order: 5; }
  .head-tools .head-search { flex: 1 1 auto; }
  .head-tools .head-search input { width: 100%; }
  .foot-grid { grid-template-columns: 1fr; }
}
