/* ============ 1. COLORS (change these to restyle the whole site) ============ */
:root {
  --bg: #ffffff;
  --text: #111111;
  --muted: #626262;
  --card: #f3f4f7;
  --cover-empty: #e2e5ea;

  /* hero banner colors */
  --sky-top: #e8eefb;
  --sky-bottom: #d6d2f0;
  --moon: #ffffff;
  --hill-far: #bcbae3;
  --hill-mid: #9b97cf;
  --hill-near: #6f6aa8;
  --hero-text: #2d264b;
}

/* Dark theme: script.js adds data-theme="dark" to the page */
:root[data-theme="dark"] {
  --bg: #151418;
  --text: #f1eee9;
  --muted: #a9a4ab;
  --card: #23212a;
  --cover-empty: #34313c;

  --sky-top: #1c1a2e;
  --sky-bottom: #3d3052;
  --moon: #fff3d6;
  --hill-far: #4a3d63;
  --hill-mid: #382e4d;
  --hill-near: #262036;
  --hero-text: #f1eee9;
}

/* ============ 2. BASICS ============ */
* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Source Serif 4", Georgia, serif;
  transition: background 0.3s, color 0.3s;
}

a { color: inherit; text-decoration: none; }

/* ============ 3. TOP BAR ============ */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  max-width: 1000px;
  margin: 0 auto;
}

.logo {
  font-family: "Vidaloka", Georgia, serif;
  font-size: 24px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  padding: 6px;
  cursor: pointer;
  border-radius: 50%;
}
.icon-btn:hover { background: var(--card); }

/* Moon in light mode, sun in dark mode */
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon,
:root[data-theme="gray"] .icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun,
:root[data-theme="gray"] .icon-sun { display: inline; }

/* ============ 4. HERO BANNER ============ */
main { max-width: 1000px; margin: 0 auto; }

.hero {
  position: relative;
  height: 260px;
  margin: 0 12px;
  border-radius: 20px;
  overflow: hidden;
  background: linear-gradient(to bottom, var(--sky-top), var(--sky-bottom));
  /* To use your own photo instead, replace the line above with:
     background: url("images/banner.jpg") center / cover;
     and delete the <svg> block inside <section class="hero"> in index.html. */
}

.hero-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.moon      { fill: var(--moon); }
.moon-glow { fill: var(--moon); opacity: 0.25; }
.star      { fill: var(--moon); opacity: 0.8; }
.hill.far  { fill: var(--hill-far); }
.hill.mid  { fill: var(--hill-mid); }
.hill.near { fill: var(--hill-near); }

.hero-text {
  position: absolute;
  left: 22px;
  top: 28px;
  right: 22px;
  color: var(--hero-text);
}
.hero-text h1 {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 600;
  line-height: 1.2;
}
.hero-text p { margin: 0; font-size: 15px; opacity: 0.85; }

/* ============ 5. CARDS ============ */
.section-title {
  margin: 22px 16px 12px;
  font-size: 20px;
  font-weight: 600;
}

.cards {
  display: grid;
  gap: 20px;
  padding-bottom: 20px;
}

.card {
  display: flex;
  gap: 18px;
  padding: 8px 14px 8px 13px;
  background: var(--card);
  border-radius: 0 8px 8px 0;           /* flat on the left edge, like your design */
  box-shadow: 2px 5px 10px 2px rgba(0, 0, 0, 0.18);
  margin-right: 14px;
  transition: transform 0.2s;
}
.card:hover { transform: translateY(-2px); }

.cover {
  flex: none;
  width: 107px;
  height: 160px;
  background: var(--cover-empty);        /* the empty cover */
  border-radius: 13px;
  box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}
.cover img {                             /* used when you add a cover picture */
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.info { padding-top: 12px; }
.info h3 { margin: 0 0 4px; font-size: 23px; font-weight: 400; }
.author { margin: 0; font-size: 13px; color: var(--muted); }
.meta { margin: 14px 0 0; font-size: 13px; color: var(--muted); }
/* ============ 6. FOOTER ============ */
.footer {
  text-align: center;
  padding: 28px 16px 36px;
  color: var(--muted);
  font-size: 14px;
}

/* ============ 7. BIGGER SCREENS (tablet / computer) ============ */
@media (min-width: 700px) {
  .hero { height: 340px; margin: 0 16px; }
  .hero-text { left: 40px; top: 50px; }
  .hero-text h1 { font-size: 40px; }
  .hero-text p { font-size: 18px; }

  .cards { grid-template-columns: 1fr 1fr; padding: 0 16px 20px; }
  .card { margin-right: 0; border-radius: 8px; }
  .section-title { margin-left: 16px; }
}

/* ============ 8. NOVEL PAGE ============ */
:root {
  --accent: #2d264b;
  --line: #e5e7eb;
}
:root[data-theme="dark"] {
  --accent: #cfc8f5;
  --line: #34313c;
}

.back {
  display: inline-flex;
  padding: 6px;
  border-radius: 50%;
  color: var(--text);
}
.back:hover { background: var(--card); }

.novel {
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 20px 24px;
}

/* cover + details side by side */
.novel-top {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.cover-big {
  width: 146px;
  height: 219px;
}
.novel-info h1 {
  margin: 4px 0 4px;
  font-size: 26px;
  font-weight: 400;
  line-height: 1.2;
}

/* bubbles (genres) */
.bubbles {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
  margin: 16px 0;
}
.bubbles li {
  font-size: 12px;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
}

/* status + total chapters */
.facts { margin: 0; font-size: 13px; color: var(--muted); }
.status {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--bg);
}
.dot { margin: 0 4px; }

/* description + chapters */
.block { margin-top: 30px; }
.block h2 { margin: 0 0 10px; font-size: 18px; font-weight: 600; }

.description {
  margin: 0;
  font-size: 15px;
  line-height: 1.65;
  color: var(--muted);
}
.description.clamped {            /* show only 4 lines until "Read more" */
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.link-btn {
  background: none;
  border: none;
  padding: 6px 0;
  font: inherit;
  font-size: 14px;
  color: var(--accent);
  cursor: pointer;
}

/* chapters card */
.chapters-card {
  background: var(--card);
  border-radius: 16px;
  padding: 14px 16px 6px;
}
.chapters-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

/* the small bubbles at the top of the card */
.bubble-input,
.bubble-btn {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  outline: none;
}
.bubble-input { width: 130px; }
.bubble-input::placeholder { color: var(--muted); }
.bubble-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

/* sort menu */
.sort { position: relative; }
.sort-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 5;
  min-width: 140px;
  background: var(--bg);
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}
.sort-menu[hidden] { display: none; }
.sort-menu button {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: none;
  border: none;
  padding: 11px 16px;
  cursor: pointer;
}
.sort-menu button:hover { background: var(--card); }
.sort-menu button.active { font-weight: 600; }

.jump-msg { margin: 8px 4px; font-size: 13px; color: var(--muted); }

/* the chapter rows */
.chapter-list { list-style: none; margin: 0; padding: 0; }
.chapter-list li + li { border-top: 1px solid var(--line); }
.chapter-list a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 6px;
  border-radius: 12px;
}
.chapter-list a:hover { background: rgba(127, 127, 127, 0.1); }
.chapter-list li.found a { background: var(--bg); }   /* the chapter you searched for */

.ch-num {
  flex: none;
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--bg);
  font-size: 13px;
  color: var(--muted);
}
.ch-title { flex: 1; font-size: 16px; }
.ch-date { font-size: 13px; color: var(--muted); }

/* ============ 9. EXTRA THEMES (used by the chapter page) ============ */
:root[data-theme="sepia"] {
  --bg: #f4ecd8;
  --text: #433422;
  --muted: #7a6a55;
  --card: #eadfc5;
  --cover-empty: #dccfb0;
  --line: #dccfb0;
  --accent: #5a4630;
}
:root[data-theme="gray"] {
  --bg: #2b2d31;
  --text: #e4e4e4;
  --muted: #a0a3a8;
  --card: #36383d;
  --cover-empty: #44474d;
  --line: #44474d;
  --accent: #cfc8f5;
  --sky-top: #1c1a2e;
  --sky-bottom: #3d3052;
  --moon: #fff3d6;
  --hill-far: #4a3d63;
  --hill-mid: #382e4d;
  --hill-near: #262036;
  --hero-text: #e4e4e4;
}

/* color of the bars and bubbles on the chapter page (adapts to every theme) */
:root { --bar: color-mix(in srgb, var(--text) 8%, var(--bg)); }

[hidden] { display: none !important; }

/* ============ 10. CHAPTER PAGE ============ */
.reader-page { min-height: 100vh; }

/* top bar: slides down when you tap the screen */
.reader-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 17px;
  transform: translateY(-120%);
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
  pointer-events: none;                  /* empty space in the bar does not block taps */
}
.reader-bar.show { transform: none; opacity: 1; }
.reader-bar.show .round-btn,
.reader-bar.show .pill { pointer-events: auto; }

.round-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: var(--bar);
  color: var(--text);
  cursor: pointer;
}
.round-btn.small { width: 34px; height: 34px; }

.pill {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 42px;
  padding: 0 8px;
  border-radius: 26px;
  background: var(--bar);
}
.pill button {
  width: 38px;
  height: 34px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 999px;
  background: none;
  color: var(--text);
  cursor: pointer;
}
.pill button.active { background: var(--bg); }

/* the pop-up under the 4 buttons */
.settings-panel {
  position: fixed;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 19;
  width: min(330px, calc(100vw - 32px));
  padding: 16px 18px;
  border-radius: 20px;
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22);
}
.panel-label { margin: 0 0 12px; font-size: 14px; color: var(--muted); }
.panel-label span { color: var(--text); margin-left: 6px; }

.slider-row { display: flex; align-items: center; gap: 12px; }
.slider-row input { flex: 1; accent-color: var(--accent); }
.a-small { font-size: 14px; color: var(--muted); }
.a-big   { font-size: 22px; color: var(--muted); }

.option-list { display: grid; gap: 4px; }
.option-list button {
  text-align: left;
  font-size: 17px;
  color: var(--text);
  background: none;
  border: none;
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
}
.option-list button:hover { background: var(--card); }
.option-list button.active { background: var(--card); font-weight: 600; }

.theme-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.theme-options button {
  display: grid;
  justify-items: center;
  gap: 6px;
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  background: none;
  border: none;
  padding: 4px 0;
  cursor: pointer;
}
.theme-options .swatch {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid var(--line);
  font-size: 18px;
}
.theme-options button.active .swatch { border-color: var(--accent); }
.theme-options button.active { color: var(--text); font-weight: 600; }

/* title + chapter name */
.reader-head { text-align: center; padding: 78px 20px 0; }
.novel-title {
  font-family: "EB Garamond", Georgia, serif;
  font-weight: 500;
  font-size: 21px;
  color: var(--muted);
}
.chapter-name {
  margin: 4px 0 0;
  font-family: "Crimson Pro", Georgia, serif;
  font-size: 14px;
  color: var(--muted);
}

/* the chapter text (font, size and spacing are set by reader.js) */
.reader-text {
  max-width: 660px;
  margin: 0 auto;
  padding: 32px 26px 140px;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 19px;
  line-height: 1.9;
}
.reader-text p { margin: 0 0 1em; }
.reader-text h1, .reader-text h2, .reader-text h3 { margin: 1.4em 0 0.6em; line-height: 1.3; }
.reader-text hr { border: none; margin: 1.6em 0; text-align: center; }
.reader-text hr::after { content: "* * *"; letter-spacing: 0.4em; color: var(--muted); }
.reader-text .loading { color: var(--muted); font-size: 15px; }

/* bottom bubble: previous / current chapter / next */
.reader-bottom {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  width: 261px;
  max-width: calc(100vw - 32px);
  height: 42px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 26px;
  background: var(--bar);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
.circle-btn {
  display: grid;
  place-items: center;
  color: var(--text);
  cursor: pointer;
}
.circle-btn:not([href]) { opacity: 0.3; cursor: default; }   /* no previous/next chapter */
.bottom-label {
  flex: 1;
  min-width: 0;
  margin: 0 8px;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 15px;
  color: var(--text);
  background: none;
  border: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

/* chapter index: slides in from the right */
.index-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.index-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  width: min(320px, 85vw);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.2);
  transform: translateX(100%);
  transition: transform 0.28s;
}
body.index-open .index-overlay { opacity: 1; pointer-events: auto; }
body.index-open .index-panel { transform: none; }

.index-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 16px 12px 20px;
}
.index-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.index-list { flex: 1; overflow-y: auto; padding: 0 10px 20px; }
.index-list .ch-num { background: var(--card); }
.index-list a.current { background: var(--card); }
.index-list a.current .ch-title { font-weight: 600; }
