/*
Theme Name: Immortal Valley
Author: You
Description: Custom theme for translated novels
Version: 1.3
*/

/* ---------- Variables ---------- */
:root {
  --sage: #9CB080;
  --green: #618764;
  --forest: #2B5748;
  --slate: #273338;
  --bg: #F3F6EE;
  --text: #273338;
  --card: #FFFFFF;
  --muted: #618764;
  --link: #2B5748;
  color-scheme: light;
}
:root[data-mode="dark"] {
  --bg: #1B2326;
  --text: #E6EDDB;
  --card: #273338;
  --muted: #9CB080;
  --link: #9CB080;
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body, button, input, select, textarea,
h1, h2, h3, h4, h5, h6,
.site-title, .tagline, .main-nav a, .pill, .btn {
  font-family: Georgia, "Times New Roman", "Songti SC", "Noto Serif CJK SC", serif;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  overflow-x: clip; /* full-width banner uses 100vw */
  transition: background .2s, color .2s;
}
a { color: var(--link); }
img { max-width: 100%; height: auto; }
:focus-visible { outline: 2px solid var(--sage); outline-offset: 2px; }

.container { max-width: 1000px; margin: 0 auto; padding: 0 1rem; }
.container.wide { max-width: 1100px; }
main.container { padding-top: 2rem; padding-bottom: 3rem; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- Pill buttons ---------- */
.btn, .icon-btn, .pill {
  display: inline-block;
  font-size: .95rem;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  border-radius: 999px;
  transition: background .2s, color .2s, border-color .2s, transform .15s;
}
.btn {
  background: var(--forest);
  color: #fff !important;
  border: 2px solid var(--forest);
  padding: .8rem 1.6rem;
}
.btn:hover { background: var(--green); border-color: var(--green); transform: translateY(-1px); }
:root[data-mode="dark"] .btn { background: var(--green); border-color: var(--green); }
:root[data-mode="dark"] .btn:hover { background: var(--sage); border-color: var(--sage); color: var(--slate) !important; }

.btn-outline {
  background: transparent;
  color: var(--forest) !important;
  border: 2px solid var(--forest);
}
.btn-outline:hover { background: var(--forest); color: #fff !important; }
:root[data-mode="dark"] .btn-outline { background: transparent; color: var(--sage) !important; border-color: var(--sage); }
:root[data-mode="dark"] .btn-outline:hover { background: var(--sage); color: var(--slate) !important; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(135deg, var(--forest), var(--slate));
  border-bottom: 3px solid var(--sage);
  padding: 1.1rem 0;
}
.admin-bar .site-header { top: 32px; }

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand { display: flex; align-items: center; gap: .7rem; }
.brand .site-title {
  color: #fff !important;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-decoration: none;
}
.tagline { margin: 0; color: var(--sage); font-size: .75rem; font-style: italic; }
.site-icon { width: 32px; height: 32px; border-radius: 8px; display: block; }

.header-right { display: flex; align-items: center; gap: 1.2rem; margin-left: auto; }

.main-nav ul { list-style: none; display: flex; gap: .4rem; margin: 0; padding: 0; }
.main-nav a {
  display: block;
  color: #fff;
  text-decoration: none;
  font-size: .92rem;
  padding: .45rem 1rem;
  border-radius: 999px;
  transition: background .2s;
}
.main-nav a:hover { background: rgba(156,176,128,.25); }
.main-nav .current-menu-item a,
.main-nav .current_page_item a { background: var(--green); }

.icon-btn {
  background: transparent;
  color: #fff;
  border: 2px solid var(--sage);
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  font-size: 1.1rem;
  display: grid;
  place-items: center;
}
.icon-btn:hover { background: var(--green); }

/* ---------- Novel hero (centered stack) ---------- */
.novel-hero { text-align: center; }

.novel-hero .cover { display: flex; justify-content: center; margin: 0 0 1.4rem; }
.cover img,
.cover-placeholder {
  width: 220px;
  max-width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  object-position: top center;
}
.cover img {
  display: block;
  border-radius: 14px;
  border: 2px solid var(--sage);
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
.cover-placeholder {
  display: grid;
  place-items: center;
  background: var(--card);
  border: 2px dashed var(--sage);
  border-radius: 14px;
}

.novel-info { max-width: 680px; margin: 0 auto; }
.novel-info h1 { margin: 0 0 .5rem; font-size: 2.3rem; line-height: 1.2; }
.novel-info h2, .section-title {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--muted);
  margin: 1.5rem 0 .5rem;
}
.alt-titles {
  margin: 0 0 1rem;
  font-size: .95rem;
  font-style: italic;
  color: var(--muted);
  line-height: 1.5;
}
.meta { list-style: none; display: flex; justify-content: center; gap: .6rem; padding: 0; margin: 0; flex-wrap: wrap; }
.pill {
  background: var(--card);
  border: 1.5px solid var(--sage);
  color: var(--text);
  padding: .4rem .95rem;
  font-size: .85rem;
  cursor: default;
}
.pill b { color: var(--muted); font-weight: 600; margin-right: .3rem; text-transform: uppercase; font-size: .72rem; letter-spacing: .08em; }
.pill.status-ongoing   { background: var(--green);  border-color: var(--green);  color: #fff; }
.pill.status-completed { background: var(--forest); border-color: var(--forest); color: #fff; }
.pill.status-hiatus    { background: #8a6d3b;       border-color: #8a6d3b;       color: #fff; }
.pill[class*="status-"] b { color: rgba(255,255,255,.75); }

.synopsis p { margin: 0 0 1rem; }
.synopsis { text-align: left; }
.actions { display: flex; justify-content: center; gap: .75rem; flex-wrap: wrap; margin-top: 1.5rem; }

/* ---------- Chapter list ---------- */
.chapter-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.chapter-list a {
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: var(--card);
  border: 1.5px solid var(--sage);
  border-radius: 999px;
  padding: .7rem 1.4rem;
  text-decoration: none;
  color: var(--text);
  transition: background .2s, transform .15s;
}
.chapter-list a:hover { background: var(--green); color: #fff; transform: translateX(3px); }
.chapter-list .date { opacity: .65; font-size: .85rem; white-space: nowrap; }
.novel-chapters { margin-top: 3rem; }

.ch-meta { display: flex; gap: 1rem; font-size: .85rem; opacity: .75; white-space: nowrap; }
.ch-progress { position: absolute; left: 0; bottom: 0; width: 100%; height: 3px; }
.ch-progress i { display: block; height: 100%; width: 0; background: var(--sage); }
.chapter-list a:hover .ch-progress i { background: #fff; }

/* ---------- Reader (chapter page) ---------- */
body.single-chapter main.container { max-width: 760px; }
.reader-back { display: inline-block; margin-bottom: 1rem; font-size: .9rem; }
.reader h1 { font-size: 2rem; line-height: 1.25; margin: 0 0 1.5rem; }
.reader-meta { display: flex; gap: .5rem; margin: 0 0 1.5rem; }
.chapter-content { font-size: 1.15rem; line-height: 1.9; }
.chapter-content p { margin: 0 0 1.3em; }
.chapter-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 2.5rem 0;
}

#read-progress { position: fixed; top: 0; left: 0; width: 100%; height: 4px; z-index: 9999; }
body.admin-bar #read-progress { top: 32px; }
#read-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--sage);
  border-radius: 0 999px 999px 0;
  transition: width .1s linear;
}

/* ---------- Footer ---------- */
.site-footer { text-align: center; padding: 2rem 1rem; color: var(--muted); font-size: .9rem; }

/* ---------- Home: hero + novel list ---------- */
body.home main.container { max-width: none; padding: 0 0 3rem; }
body.home .site-header { padding: .7rem 0; }
body.home .tagline { display: none; }

.home-hero {
  position: relative;
  min-height: 420px;
  display: flex;
  align-items: center;
  background: linear-gradient(135deg, var(--forest), var(--slate)) center / cover no-repeat;
}
.home-hero::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,.1) 0%, transparent 35%, var(--bg) 100%);
}
.home-hero::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0; height: 55%;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000);
  mask-image: linear-gradient(to bottom, transparent, #000);
}
.home-hero-inner {
  position: relative; z-index: 2;
  width: 100%; max-width: 900px;
  margin: 0 auto;
  padding: 4rem 1rem 6rem;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0,0,0,.55);
}
.home-hero-inner h1 { margin: 0; font-size: 3.4rem; line-height: 1.1; letter-spacing: .02em; }
.home-hero-inner p { margin: .6rem 0 0; font-size: 1.1rem; }

.home-card {
  position: relative; z-index: 3;
  max-width: 900px;
  margin: -3.5rem auto 0;
  background: var(--card);
  border-radius: 18px;
  padding: 2rem;
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
.home-title { margin: 0 0 1.2rem; font-size: 1.8rem; }

.home-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; margin-bottom: 1.5rem; }
.home-stats div {
  background: var(--bg);
  border: 1.5px solid var(--sage);
  border-radius: 14px;
  text-align: center;
  padding: .6rem .4rem;
}
.home-stats b { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.home-stats span { font-size: 1.05rem; }

.novel-search {
  width: 100%;
  font: inherit; font-size: .95rem;
  padding: .7rem 1.2rem;
  margin-bottom: 1.2rem;
  border-radius: 999px;
  border: 1.5px solid var(--sage);
  background: var(--bg);
  color: var(--text);
}
.novel-search:focus { outline: 2px solid var(--green); }

.novel-cards { display: grid; gap: 1rem; }
.novel-card {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 1.2rem;
  background: var(--bg);
  border: 1.5px solid var(--sage);
  border-radius: 16px;
  padding: 1rem;
}
.nc-cover img, .nc-none {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  object-position: top center;
  border-radius: 10px;
  display: block;
}
.nc-none { display: grid; place-items: center; border: 2px dashed var(--sage); font-size: .8rem; }
.nc-body h3 { margin: 0; font-size: 1.25rem; line-height: 1.3; }
.nc-body h3 a { text-decoration: none; }
.nc-body h3 a:hover { text-decoration: underline; }
.nc-alt { margin: .2rem 0 0; font-size: .85rem; font-style: italic; color: var(--muted); }
.nc-desc { margin: .6rem 0; font-size: .95rem; line-height: 1.6; }
.nc-meta { display: flex; gap: .5rem; flex-wrap: wrap; }

/* =====================================================
   MOBILE
   ===================================================== */

/* Admin bar offsets */
@media (max-width: 782px) {
  .admin-bar .site-header { top: 46px; }
  body.admin-bar #read-progress { top: 46px; }
}

/* Header + home + chapter rows */
@media (max-width: 720px) {
  .site-header { padding: .4rem 0; }
  .header-inner {
    flex-wrap: nowrap;
    justify-content: space-between;
    gap: .5rem;
    padding-left: .75rem;
    padding-right: .75rem;
  }
  .brand { flex: 0 0 auto; gap: .45rem; }
  .brand .site-title,
  .brand .tagline { display: none; }
  .site-icon { width: 26px; height: 26px; border-radius: 6px; }

  .header-right { flex: 0 0 auto; margin-left: auto; gap: .5rem; }
  .main-nav ul { gap: .6rem; flex-wrap: nowrap; }
  .main-nav a { font-size: .8rem; white-space: nowrap; }
  .icon-btn { width: 30px; height: 30px; font-size: .9rem; }

  .ch-meta .date { display: none; }

  .home-hero { min-height: 320px; }
  .home-hero-inner h1 { font-size: 2.4rem; }
  .home-card { margin: -2.5rem .75rem 0; padding: 1.2rem; }
  .home-stats { grid-template-columns: repeat(2, 1fr); }
  .novel-card { grid-template-columns: 90px 1fr; gap: .8rem; }
}

@media (max-width: 400px) {
  .main-nav a { font-size: .75rem; }
  .main-nav ul { gap: .45rem; }
}

/* Novel page (mobile): same centered stack, smaller sizes */
@media (max-width: 640px) {
  .cover img,
  .cover-placeholder { width: 170px; }

  .novel-info h1 { font-size: 1.7rem; }
  .alt-titles { font-size: .9rem; }
  .meta { gap: .4rem; }
  .meta .pill { padding: .3rem .7rem; font-size: .78rem; }

  .actions .btn { width: 100%; max-width: 320px; text-align: center; }
}
