/*
Theme Name: Simple Webnovel — Fiction UI
Theme URI: https://example.com/
Author: OpenAI
Description: Lightweight single-style web novel theme inspired by modern web-fiction catalog interfaces. Uses the existing Simple Web Novel System functionality without additional front-end dependencies.
Version: 4.0.1
License: GPL2+
Text Domain: simple-webnovel-fiction-ui
*/

:root {
  --bg: #f2eff4;
  --surface: #ffffff;
  --surface-2: #f8f6f9;
  --surface-3: #ede8ef;
  --text: #29242d;
  --muted: #77707c;
  --line: #ddd7e1;
  --header: #302a35;
  --header-2: #3a3340;
  --primary: #8d5bc4;
  --primary-dark: #7442aa;
  --content-width: 1180px;
  --reading-width: 780px;
  --radius: 10px;
  --shadow: 0 8px 24px rgba(34, 27, 39, .07);
  --logo-height-desktop: 52px;
  --logo-height-mobile: 42px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.65;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--primary-dark); }
button, input, textarea, select { font: inherit; }

.wrap {
  width: min(calc(100% - 32px), var(--content-width));
  margin: 0 auto;
}

/* Header — compact, high-contrast web-fiction navigation */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--header);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.site-header__inner {
  min-height: calc(var(--logo-height-desktop) + 18px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.site-branding { display: flex; align-items: center; min-width: 0; }
.site-branding__link { display: inline-flex; align-items: center; min-height: var(--logo-height-desktop); }
.site-logo .custom-logo-link { display: inline-flex; align-items: center; line-height: 0; }
.custom-logo { max-height: var(--logo-height-desktop); width: auto; height: auto; display: block; }
.site-title {
  margin: 0;
  color: #fff;
  font-size: 22px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -.02em;
}
.main-navigation { margin-left: auto; }
.main-navigation ul {
  display: flex;
  align-items: center;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.main-navigation li { margin: 0; }
.main-navigation a {
  display: block;
  padding: 9px 12px;
  color: #e8e3eb;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 700;
}
.main-navigation a:hover,
.main-navigation .current-menu-item > a {
  color: #fff;
  background: rgba(255,255,255,.09);
}
.menu-toggle {
  display: none;
  border: 1px solid rgba(255,255,255,.12);
  background: var(--header-2);
  color: #fff;
  padding: 8px 11px;
  border-radius: 7px;
  font-weight: 700;
  cursor: pointer;
}

.page-shell { padding: 28px 0 52px; }
.home-grid-wrap { padding-top: 2px; }

/* Story cards — compact catalog cards, 3 columns preserved */
.novel-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.novel-card {
  min-width: 0;
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 2px 10px rgba(34,27,39,.035);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.novel-card:hover {
  border-color: #cfc5d5;
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.novel-card__cover-wrap {
  position: relative;
  display: block;
  width: 108px;
  align-self: start;
  border-radius: 7px;
  overflow: hidden;
  background: #e7e2e9;
  box-shadow: 0 4px 12px rgba(29,23,34,.10);
}
.novel-card__cover-wrap::before { content: ""; display: block; padding-top: 148%; }
.novel-card__cover {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.novel-card__placeholder,
.book-cover__placeholder {
  display: grid;
  place-items: center;
  color: #817987;
  background: linear-gradient(145deg, #eeeaf0, #ddd6e1);
  font-size: 12px;
  font-weight: 800;
}
.novel-card__meta {
  min-width: 0;
  padding: 2px 0 0;
  display: flex;
  flex-direction: column;
}
.novel-card__title {
  margin: 0;
  font-size: 18px;
  line-height: 1.22;
  letter-spacing: -.018em;
  font-weight: 800;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.novel-card__excerpt {
  margin: 10px 0 0;
  color: #5f5864;
  font-size: 13px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Archive heading */
.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 18px;
  padding: 0 0 13px;
  border-bottom: 1px solid var(--line);
}
.section-title { margin: 0; font-size: 28px; line-height: 1.12; letter-spacing: -.025em; }
.section-meta { margin: 5px 0 0; color: var(--muted); font-size: 13px; }

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin-top: 28px;
  flex-wrap: wrap;
}
.pagination .page-numbers {
  min-width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: #514958;
  font-size: 14px;
  font-weight: 800;
}
.pagination .page-numbers.current,
.pagination .page-numbers:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Single story */
.story-page { max-width: 1040px; }
.story-panel {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(34,27,39,.05);
}
.book-hero {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
  padding: 26px;
  background: linear-gradient(180deg, #fff 0%, #fbfafc 100%);
}
.book-cover {
  overflow: hidden;
  border-radius: 8px;
  background: #eae5ec;
  box-shadow: 0 8px 22px rgba(31,24,36,.14);
}
.book-cover__image,
.book-cover__placeholder {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
}
.book-summary { min-width: 0; }
.book-kicker {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid #ded5e4;
  border-radius: 999px;
  color: #6d5e78;
  background: #f6f2f8;
  font-size: 11px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.book-title {
  margin: 11px 0 7px;
  font-size: clamp(32px, 5vw, 46px);
  line-height: 1.04;
  letter-spacing: -.04em;
}
.book-description {
  margin-top: 15px;
  max-width: 68ch;
  color: #4a434e;
  font-size: 15px;
  line-height: 1.75;
}
.book-description p { margin-top: 0; }
.book-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 22px;
}
.btn,
.wp-block-button__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 7px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -.01em;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-secondary { background: var(--surface); border-color: var(--line); color: #4d4652; }
.btn-secondary:hover { background: var(--surface-2); border-color: #cec5d3; }

/* Chapter catalog — full-width section */
.book-catalog {
  margin: 0;
  padding: 22px 26px 28px;
  border-top: 1px solid var(--line);
  background: #faf9fb;
}
.catalog-title {
  margin: 0 0 14px;
  color: #37303c;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: -.015em;
}
.chapter-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 12px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.chapter-list li { min-width: 0; }
.chapter-list a {
  display: block;
  padding: 10px 12px;
  overflow: hidden;
  border: 1px solid #e4dfe7;
  border-radius: 7px;
  color: #4d4652;
  background: #fff;
  font-size: 14px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.chapter-list a:hover {
  color: var(--primary-dark);
  border-color: #cfc3d8;
  background: #fdfcfe;
}

/* Reader */
.reader-shell {
  width: min(calc(100% - 28px), var(--reading-width));
  margin: 0 auto;
  padding: 4px 0 72px;
}
.reader-top {
  padding: 18px 4px 15px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--line);
}
.reader-title {
  margin: 0;
  font-size: clamp(28px, 5vw, 40px);
  line-height: 1.1;
  letter-spacing: -.035em;
}
.reader-book-link { display: none; }
.reader-body {
  padding: 26px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 8px 24px rgba(35,28,41,.045);
}
.entry-content,
.reader-content {
  color: #322c35;
  font-size: 19px;
  line-height: 2.0;
  word-break: break-word;
}
.entry-content p,
.reader-content p { margin: 0 0 1.32em; }
.reader-content img,
.entry-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.3em auto;
}
.reader-content figure,
.entry-content figure {
  margin: 1.3em auto;
  text-align: center;
}
.reader-content .aligncenter,
.entry-content .aligncenter { margin-left: auto; margin-right: auto; }
.reader-nav,
.reader-nav.reader-nav--focus {
  position: static;
  display: grid;
  grid-template-columns: minmax(96px, .72fr) minmax(150px, 1.15fr);
  gap: 10px;
  align-items: stretch;
  margin-top: 26px;
  padding: 18px 0 0;
  border-top: 1px solid var(--line);
  background: transparent;
  box-shadow: none;
}
.reader-nav .btn,
.reader-nav--focus .btn {
  width: 100%;
  min-height: 48px;
  border-radius: 7px;
  font-size: 15px;
  font-weight: 800;
}
.reader-nav .btn.is-disabled {
  background: #f0edf2;
  color: #aaa2ae;
  border-color: #e4dfe7;
  pointer-events: none;
  box-shadow: none;
}
.reader-nav--focus .btn-catalog {
  background: #fff;
  border: 1px solid var(--line);
  color: #49414e;
}
.reader-nav--focus .btn-next { box-shadow: none; }

/* Footer */
.site-footer { padding: 0 0 34px; color: var(--muted); font-size: 13px; }
.footer-inner { padding-top: 19px; border-top: 1px solid var(--line); }

.screen-reader-text {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

@media (max-width: 980px) {
  .novel-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .page-shell { padding-top: 18px; }
  .site-header__inner {
    min-height: calc(var(--logo-height-mobile) + 8px);
    padding-top: 4px;
    padding-bottom: 4px;
  }
  .site-branding__link { min-height: var(--logo-height-mobile); }
  .custom-logo { max-height: var(--logo-height-mobile); }
  .site-title { font-size: 20px; }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .main-navigation {
    position: absolute;
    left: 12px;
    right: 12px;
    top: calc(100% + 7px);
    display: none;
    margin: 0;
    padding: 8px;
    background: var(--header);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 9px;
    box-shadow: 0 12px 28px rgba(15,11,18,.18);
  }
  .main-navigation.is-open { display: block; }
  .main-navigation ul { flex-direction: column; align-items: stretch; gap: 3px; }
  .main-navigation a { padding: 10px 11px; }

  .novel-grid { grid-template-columns: 1fr; gap: 12px; }
  .novel-card { grid-template-columns: 112px minmax(0, 1fr); max-width: 640px; width: 100%; margin: 0 auto; }
  .novel-card__cover-wrap { width: 112px; }

  .story-panel { border-radius: 10px; }
  .book-hero { grid-template-columns: 190px minmax(0, 1fr); gap: 20px; padding: 20px; }
  .book-title { font-size: 34px; }
  .book-catalog { padding: 20px; }
  .chapter-list { grid-template-columns: 1fr; }

  .reader-body { padding: 22px 18px; }
  .entry-content, .reader-content { font-size: 18px; line-height: 1.95; }
}

@media (max-width: 600px) {
  .wrap { width: min(calc(100% - 22px), var(--content-width)); }
  .book-hero { grid-template-columns: 1fr; gap: 18px; }
  .book-cover { width: min(210px, 62vw); margin: 0 auto; }
  .book-summary { text-align: left; }
  .book-title { font-size: 32px; }
  .book-actions { justify-content: center; }
  .book-actions .btn { flex: 1 1 calc(50% - 5px); min-width: 0; }
  .reader-shell { width: min(calc(100% - 18px), var(--reading-width)); }
  .reader-top { padding: 12px 2px; }
  .reader-title { font-size: 29px; }
  .reader-body { padding: 19px 15px; }
  .reader-nav, .reader-nav.reader-nav--focus { grid-template-columns: minmax(90px,.72fr) minmax(132px,1.12fr); gap: 9px; }
}

@media (max-width: 420px) {
  .novel-card { grid-template-columns: 96px minmax(0, 1fr); gap: 12px; padding: 10px; }
  .novel-card__cover-wrap { width: 96px; }
  .novel-card__title { font-size: 17px; }
  .novel-card__excerpt { -webkit-line-clamp: 3; font-size: 12.5px; }
  .book-catalog { padding: 18px 14px 22px; }
  .btn { min-height: 44px; padding: 0 14px; font-size: 14px; }
}
