/*
Theme Name: ToonHive
Theme URI: https://example.com/toonhive
Author: ToonHive
Description: A lightweight, SEO-friendly manhwa/manga reading theme with dark & light mode, card grids, and a vertical webtoon reader. Pairs with the ToonHive Scraper plugin.
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: toonhive
Tags: dark, entertainment, custom-menu, custom-logo, featured-images, translation-ready
*/

:root {
  --bg: #0d0f16;
  --bg2: #12151f;
  --surface: #191d2b;
  --surface2: #222739;
  --line: #2b3149;
  --text: #e8eaf2;
  --muted: #9aa1b9;
  --accent: #8b5cf6;
  --accent2: #22d3ee;
  --grad: linear-gradient(135deg, var(--accent), var(--accent2));
  --hot: #f43f5e;
  --ok: #34d399;
  --radius: 12px;
  --shadow: 0 8px 28px rgba(0, 0, 0, .45);
}

[data-theme="light"] {
  --bg: #f4f5fa;
  --bg2: #eceef6;
  --surface: #ffffff;
  --surface2: #f0f1f8;
  --line: #dfe2ee;
  --text: #1a1d29;
  --muted: #6b7290;
  --shadow: 0 8px 24px rgba(30, 35, 60, .12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; }
ul { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, h4, h5 { margin: 0; line-height: 1.3; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.header-in { display: flex; align-items: center; gap: 14px; height: 64px; }
.site-brand { display: flex; align-items: center; flex-shrink: 0; }
.site-brand > a {
  display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 18px; line-height: 1.2;
}
.site-brand img { max-height: 40px; width: auto; }
.site-brand .hive-dot {
  width: 34px; height: 34px; border-radius: 10px; background: var(--grad);
  display: grid; place-items: center; color: #fff; font-size: 16px; font-weight: 900; flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; justify-content: center; }
.brand-sub {
  font-size: 9px; font-weight: 600; letter-spacing: 1.8px; color: var(--muted);
  line-height: 1.5; margin-top: 1px; white-space: nowrap;
}

.main-nav { flex: 1; }
.main-nav ul { display: flex; gap: 2px; }
.main-nav a {
  display: block; padding: 8px 13px; border-radius: 8px; font-weight: 600; font-size: 14px; color: var(--muted);
}
.main-nav a:hover, .main-nav .current-menu-item > a { color: var(--text); background: var(--surface); }

.header-search { flex-shrink: 0; }
.header-search form { display: flex; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.header-search input {
  background: transparent; border: 0; outline: 0; color: var(--text);
  padding: 8px 14px; width: 170px; font-size: 14px;
}
.header-search button { background: transparent; border: 0; color: var(--muted); cursor: pointer; padding: 8px 12px; font-size: 15px; }

.icon-btn {
  flex-shrink: 0; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); cursor: pointer; font-size: 16px;
  display: grid; place-items: center;
}
.icon-btn:hover { border-color: var(--accent); }

.nav-toggle { display: none; }
.mobile-nav { display: none; }

@media (max-width: 900px) {
  .main-nav { display: none; }
  .nav-toggle { display: grid; }
  .mobile-nav { display: none; flex-direction: column; padding: 8px 16px 14px; border-top: 1px solid var(--line); }
  .mobile-nav.open { display: flex; }
  .mobile-nav a { padding: 10px 4px; font-weight: 600; border-bottom: 1px solid var(--line); }
  .header-search input { width: 110px; }
}

/* ---------- Breadcrumb ---------- */
.breadcrumbs { font-size: 13px; color: var(--muted); padding: 14px 0 0; }
.breadcrumbs a:hover { color: var(--accent2); }
.breadcrumbs .sep { margin: 0 6px; opacity: .5; }

/* ---------- Section ---------- */
.section { margin: 26px 0; }
.section-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px;
}
.section-title { font-size: 19px; font-weight: 800; display: flex; align-items: center; gap: 10px; }
.section-title::before {
  content: ""; width: 4px; height: 20px; border-radius: 4px; background: var(--grad); display: inline-block;
}
.section-link { font-size: 13px; font-weight: 600; color: var(--accent2); }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 1fr 300px; gap: 26px; align-items: start; }
@media (max-width: 980px) { .layout { grid-template-columns: 1fr; } }

/* ---------- Manga grid & cards ---------- */
.manga-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 16px;
}
.manga-card { position: relative; }
.card-cover {
  position: relative; display: block; aspect-ratio: 2 / 3; border-radius: var(--radius);
  overflow: hidden; background: var(--surface2); box-shadow: 0 2px 10px rgba(0,0,0,.25);
  transition: transform .18s ease, box-shadow .18s ease;
}
.manga-card:hover .card-cover { transform: translateY(-4px); box-shadow: var(--shadow); }
.card-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s ease; }
.manga-card:hover .card-cover img { transform: scale(1.05); }
.card-cover .noimg {
  width: 100%; height: 100%; display: grid; place-items: center;
  font-size: 40px; font-weight: 900; color: #fff; background: var(--grad); opacity: .85;
}
.card-badge {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  font-size: 10px; font-weight: 800; letter-spacing: .4px; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; color: #fff; background: rgba(15, 17, 26, .8);
}
.card-badge.ongoing { background: rgba(52, 211, 153, .85); color: #06281c; }
.card-badge.completed { background: rgba(34, 211, 238, .85); color: #06222b; }
.card-views {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  font-size: 11px; font-weight: 700; color: #fff; padding: 3px 8px; border-radius: 999px;
  background: rgba(15, 17, 26, .75);
}
.card-overlay {
  position: absolute; inset: auto 0 0 0; padding: 26px 10px 10px; z-index: 1;
  background: linear-gradient(transparent, rgba(8, 10, 18, .92));
}
.card-overlay .ch-count { color: #d8dcf0; font-size: 12px; font-weight: 700; }
.card-title {
  margin-top: 9px; font-size: 14px; font-weight: 700; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { margin-top: 4px; font-size: 12px; color: var(--muted); }

/* ---------- Sidebar widgets ---------- */
.widget { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 18px; }
.widget-title { font-size: 15px; font-weight: 800; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.widget-title::before { content: ""; width: 4px; height: 16px; border-radius: 4px; background: var(--grad); }
.pop-item { display: flex; gap: 11px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.pop-item:last-child { border-bottom: 0; }
.pop-rank { width: 22px; font-weight: 900; font-size: 15px; color: var(--accent2); flex-shrink: 0; }
.pop-cover { width: 48px; height: 66px; border-radius: 8px; overflow: hidden; flex-shrink: 0; background: var(--surface2); }
.pop-cover img { width: 100%; height: 100%; object-fit: cover; }
.pop-info { min-width: 0; }
.pop-name { font-size: 13.5px; font-weight: 700; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pop-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.genre-cloud { display: flex; flex-wrap: wrap; gap: 7px; }
.genre-cloud a {
  font-size: 12.5px; font-weight: 600; padding: 5px 11px; border-radius: 999px;
  background: var(--surface2); border: 1px solid var(--line); color: var(--muted);
}
.genre-cloud a:hover { color: #fff; background: var(--accent); border-color: var(--accent); }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin: 28px 0; }
.pagination .page-numbers {
  min-width: 38px; height: 38px; padding: 0 10px; display: grid; place-items: center;
  border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font-weight: 700; font-size: 13.5px; color: var(--muted);
}
.pagination .current, .pagination .page-numbers:hover { background: var(--grad); color: #fff; border-color: transparent; }

/* ---------- Manga detail ---------- */
.manga-hero { position: relative; padding: 30px 0 24px; overflow: hidden; }
.manga-hero::before {
  content: ""; position: absolute; inset: -60px -20px; z-index: -1;
  background: var(--hero-img, none) center 30% / cover no-repeat;
  filter: blur(60px) saturate(1.4) brightness(.5); opacity: .55;
}
[data-theme="light"] .manga-hero::before { filter: blur(60px) saturate(1.2) brightness(1.1); opacity: .35; }
.hero-grid { display: grid; grid-template-columns: 220px 1fr; gap: 26px; align-items: start; }
@media (max-width: 700px) { .hero-grid { grid-template-columns: 150px 1fr; gap: 16px; } }
.hero-cover {
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  aspect-ratio: 2 / 3; background: var(--surface2);
}
.hero-cover img { width: 100%; height: 100%; object-fit: cover; }
.manga-title { font-size: clamp(22px, 4vw, 32px); font-weight: 900; }
.manga-alt { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.hero-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 13px 0; }
.chip {
  font-size: 12px; font-weight: 700; padding: 4px 11px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
}
.chip.status-ongoing { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.chip.status-completed { color: var(--accent2); border-color: color-mix(in srgb, var(--accent2) 45%, transparent); }
.chip.rating { color: #fbbf24; border-color: color-mix(in srgb, #fbbf24 45%, transparent); }
.genre-row { display: flex; flex-wrap: wrap; gap: 7px; margin: 10px 0 16px; }
.genre-row a {
  font-size: 12.5px; font-weight: 700; padding: 5px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
}
.genre-row a:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 10px 18px; border-radius: 10px;
  font-weight: 800; font-size: 13.5px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer;
}
.btn.primary { background: var(--grad); color: #fff; border: 0; }
.btn.primary:hover { filter: brightness(1.1); }
.btn:hover { border-color: var(--accent); }

.info-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 18px;
}
.info-cell { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.info-cell .k { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.info-cell .v { font-size: 14px; font-weight: 600; margin-top: 2px; }

.manga-desc { color: var(--text); opacity: .92; max-width: 900px; }

/* ---------- Chapter list ---------- */
.chapter-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.ch-count-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.sort-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 6px 13px; border-radius: 8px; font-size: 12.5px; font-weight: 700; cursor: pointer;
}
.chapter-list { display: grid; gap: 7px; }
.chapter-list.two-col { grid-template-columns: 1fr 1fr; }
@media (max-width: 700px) { .chapter-list.two-col { grid-template-columns: 1fr; } }
.ch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 15px;
  transition: border-color .15s ease, transform .15s ease;
}
.ch-row:hover { border-color: var(--accent); transform: translateX(3px); }
.ch-num { font-weight: 700; font-size: 14px; }
.ch-date { font-size: 12px; color: var(--muted); flex-shrink: 0; }

/* ---------- Reader ---------- */
/* While reading, nothing should stick: header and chapter bar scroll away. */
body.single-chapter .site-header { position: static; }
.reader-topbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--line); padding: 9px 0;
}
.reader-bar-in { display: flex; align-items: center; gap: 10px; }
.reader-bar-in .m-name { font-weight: 800; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.reader-bar-in .c-name { color: var(--accent2); font-weight: 700; font-size: 13px; flex-shrink: 0; }
.chapter-select {
  background: var(--surface); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; font-size: 13px; max-width: 170px;
}
.reader-pages { max-width: 860px; margin: 0 auto; padding: 18px 12px; display: grid; gap: 0; }
.reader-pages img { width: 100%; display: block; border-radius: 0; }
.reader-nav { max-width: 860px; margin: 0 auto 30px; padding: 0 12px; display: flex; gap: 10px; justify-content: center; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); margin-top: 44px; padding: 26px 0 34px; background: var(--bg2); }
.footer-in { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; color: var(--muted); font-size: 13.5px; }
.footer-in a:hover { color: var(--accent2); }
.footer-menu ul { display: flex; gap: 16px; flex-wrap: wrap; }

/* ---------- Misc ---------- */
.screen-reader-text {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.empty-note { color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 22px; text-align: center; }
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.back-top {
  position: fixed; right: 18px; bottom: 18px; z-index: 90; width: 42px; height: 42px;
  border-radius: 12px; background: var(--grad); color: #fff; border: 0; cursor: pointer; font-size: 17px;
  display: none; place-items: center; box-shadow: var(--shadow);
}
.back-top.show { display: grid; }