/*
Theme Name: Plotnox Stories
Theme URI: https://plotnox.test/
Author: Plotnox
Description: A fast, responsive WordPress theme for English serialized fiction with native series and chapter management.
Version: 1.0.0
Requires at least: 6.4
Requires PHP: 8.0
Text Domain: plotnox-stories
*/

:root {
  --ink: #1c2430;
  --muted: #667085;
  --paper: #fffdf9;
  --surface: #ffffff;
  --soft: #f6f1e9;
  --line: #e8e0d5;
  --accent: #b83a46;
  --accent-dark: #8e2231;
  --gold: #d69235;
  --navy: #14223a;
  --shadow: 0 12px 34px rgba(27, 24, 20, .08);
  --radius: 18px;
  --container: 1180px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid rgba(184, 58, 70, .3); outline-offset: 3px; }
.container { width: min(calc(100% - 40px), var(--container)); margin-inline: auto; }
.screen-reader-text { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.site-header { position: sticky; z-index: 50; top: 0; background: rgba(255, 253, 249, .96); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.header-row { min-height: 74px; display: flex; align-items: center; gap: 34px; }
.brand { display: inline-flex; align-items: center; gap: 11px; flex: 0 0 auto; font-family: Georgia, serif; font-size: 25px; font-weight: 800; letter-spacing: -.7px; }
.brand-mark { display: grid; place-items: center; width: 37px; height: 37px; color: #fff; background: var(--accent); border-radius: 11px 11px 11px 3px; font: 800 20px/1 Georgia, serif; transform: rotate(-2deg); }
.brand span:last-child { color: var(--accent); }
.primary-nav { margin-left: auto; }
.primary-nav ul { display: flex; align-items: center; gap: 26px; padding: 0; margin: 0; list-style: none; }
.primary-nav a { font-size: 14px; font-weight: 750; }
.header-search { position: relative; width: 220px; }
.header-search input { width: 100%; height: 42px; padding: 0 42px 0 15px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink); }
.header-search button { position: absolute; top: 4px; right: 5px; width: 34px; height: 34px; border: 0; border-radius: 50%; color: var(--muted); background: transparent; cursor: pointer; }
.menu-toggle { display: none; margin-left: auto; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; }

.hero { position: relative; overflow: hidden; padding: 72px 0 62px; color: #fff; background: var(--navy); }
.hero::before { content: ""; position: absolute; inset: -40% -5% auto 48%; height: 520px; background: radial-gradient(circle, rgba(214,146,53,.3), transparent 68%); }
.hero::after { content: ""; position: absolute; inset: auto 0 0; height: 1px; background: rgba(255,255,255,.16); }
.hero-grid { position: relative; display: grid; grid-template-columns: 1.07fr .93fr; align-items: center; gap: 64px; }
.eyebrow { display: flex; align-items: center; gap: 9px; margin: 0 0 14px; color: var(--gold); font-size: 12px; font-weight: 850; letter-spacing: .16em; text-transform: uppercase; }
.eyebrow::before { content: ""; width: 25px; height: 2px; background: currentColor; }
.hero h1 { max-width: 670px; margin: 0; font: 700 clamp(42px, 5.7vw, 72px)/1.02 Georgia, serif; letter-spacing: -2.5px; }
.hero-copy { max-width: 610px; margin: 23px 0 30px; color: #cbd2dd; font-size: 18px; }
.button-row { display: flex; flex-wrap: wrap; gap: 12px; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 20px; border: 1px solid transparent; border-radius: 999px; font-size: 14px; font-weight: 800; transition: transform .2s, background .2s; }
.button:hover { color: inherit; transform: translateY(-2px); }
.button-primary { color: #fff; background: var(--accent); }
.button-primary:hover { color: #fff; background: var(--accent-dark); }
.button-light { color: #fff; border-color: rgba(255,255,255,.35); background: rgba(255,255,255,.08); }
.button-light:hover { color: #fff; background: rgba(255,255,255,.16); }
.hero-stack { position: relative; min-height: 330px; }
.hero-cover { position: absolute; width: 205px; aspect-ratio: 2 / 3; overflow: hidden; border: 7px solid rgba(255,255,255,.92); border-radius: 8px; box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.hero-cover img { width: 100%; height: 100%; object-fit: cover; }
.hero-cover:nth-child(1) { top: 5px; left: 5%; transform: rotate(-8deg); }
.hero-cover:nth-child(2) { top: -16px; left: 35%; z-index: 2; transform: rotate(2deg); }
.hero-cover:nth-child(3) { top: 19px; right: 0; transform: rotate(9deg); }

.section { padding: 68px 0; }
.section-soft { background: var(--soft); }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 28px; }
.section-head h2, .archive-header h1 { margin: 0; font: 700 clamp(30px, 4vw, 44px)/1.05 Georgia, serif; letter-spacing: -1.2px; }
.section-head p { max-width: 560px; margin: 8px 0 0; color: var(--muted); }
.text-link { color: var(--accent); font-size: 14px; font-weight: 850; white-space: nowrap; }

.story-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 26px 20px; }
.story-card { min-width: 0; }
.story-cover { position: relative; display: block; overflow: hidden; aspect-ratio: 2 / 3; border-radius: 12px; background: #d7dbe2; box-shadow: 0 9px 24px rgba(25, 24, 22, .12); }
.story-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.story-card:hover .story-cover img { transform: scale(1.035); }
.story-badge { position: absolute; top: 12px; left: 12px; padding: 5px 9px; color: #fff; background: var(--accent); border-radius: 999px; font-size: 10px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.story-card h3 { margin: 14px 0 6px; font: 700 20px/1.22 Georgia, serif; }
.story-card h3 a { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.story-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 7px 12px; color: var(--muted); font-size: 12px; }
.story-meta span { display: inline-flex; align-items: center; gap: 5px; }

.discovery-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, .75fr); gap: 32px; }
.latest-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chapter-row { display: grid; grid-template-columns: 58px minmax(0,1fr); gap: 14px; align-items: center; min-height: 88px; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.chapter-thumb { width: 58px; aspect-ratio: 1; overflow: hidden; border-radius: 10px; background: var(--soft); }
.chapter-thumb img { width: 100%; height: 100%; object-fit: cover; }
.chapter-row h3 { margin: 0 0 3px; font: 700 16px/1.25 Georgia, serif; }
.chapter-series { color: var(--accent); font-size: 12px; font-weight: 750; }
.chapter-time { color: var(--muted); font-size: 11px; }
.rank-panel { padding: 22px; border-radius: var(--radius); background: var(--navy); color: #fff; }
.rank-panel h2 { margin: 0 0 17px; font: 700 27px/1.1 Georgia, serif; }
.rank-tabs { display: flex; gap: 7px; margin-bottom: 14px; }
.rank-tab { flex: 1; padding: 8px 4px; color: #bec8d8; border: 1px solid rgba(255,255,255,.16); border-radius: 999px; background: transparent; font-size: 12px; font-weight: 800; cursor: pointer; }
.rank-tab[aria-selected="true"] { color: var(--navy); border-color: #fff; background: #fff; }
.rank-list { display: none; margin: 0; padding: 0; list-style: none; }
.rank-list.is-active { display: block; }
.rank-item { display: grid; grid-template-columns: 31px minmax(0,1fr); gap: 11px; padding: 12px 0; border-top: 1px solid rgba(255,255,255,.11); }
.rank-number { display: grid; place-items: center; width: 29px; height: 29px; border-radius: 50%; background: rgba(255,255,255,.09); font-size: 12px; font-weight: 900; }
.rank-item:first-child .rank-number { color: #fff; background: var(--accent); }
.rank-item a { font: 700 14px/1.25 Georgia, serif; }
.rank-item small { display: block; margin-top: 3px; color: #9eabba; font-size: 10px; }

.genres { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.genre-card { min-height: 106px; padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: #fff; transition: transform .2s, box-shadow .2s, border-color .2s; }
.genre-card:hover { color: var(--ink); border-color: #dbc2c4; box-shadow: var(--shadow); transform: translateY(-3px); }
.genre-icon { color: var(--accent); font: 700 22px/1 Georgia, serif; }
.genre-card h3 { margin: 15px 0 0; font-size: 14px; line-height: 1.25; }
.genre-card span { color: var(--muted); font-size: 11px; }

.page-shell { padding: 48px 0 76px; }
.archive-header { margin-bottom: 34px; padding-bottom: 23px; border-bottom: 1px solid var(--line); }
.archive-header p { max-width: 650px; color: var(--muted); }
.pagination { margin-top: 42px; }
.pagination .nav-links { display: flex; justify-content: center; gap: 7px; }
.pagination .page-numbers { min-width: 40px; height: 40px; display: grid; place-items: center; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-weight: 750; }
.pagination .current { color: #fff; border-color: var(--accent); background: var(--accent); }
.empty-state { padding: 50px 24px; text-align: center; background: var(--soft); border-radius: var(--radius); }

.series-layout { display: grid; grid-template-columns: minmax(0, 1fr) 335px; gap: 30px; align-items: start; }
.series-main, .series-sidebar-card { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.series-hero { display: grid; grid-template-columns: 235px minmax(0, 1fr); gap: 34px; padding: 28px; }
.series-poster { align-self: start; overflow: hidden; aspect-ratio: 2 / 3; border-radius: 12px; background: var(--soft); box-shadow: 0 10px 28px rgba(20,34,58,.18); }
.series-poster img { width: 100%; height: 100%; object-fit: cover; }
.series-info h1 { margin: 3px 0 15px; font: 700 clamp(32px, 4.2vw, 50px)/1.03 Georgia, serif; letter-spacing: -1.5px; }
.series-kicker { color: var(--accent); font-size: 12px; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.series-description { color: #4d5768; }
.series-facts { display: flex; flex-wrap: wrap; gap: 12px 20px; margin: 20px 0 23px; padding: 15px 0; border-block: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.series-facts strong { color: var(--ink); }
.series-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.series-actions .button-light { color: var(--ink); border-color: var(--line); background: #fff; }
.chapter-section { margin-top: 22px; padding: 28px; }
.chapter-section h2 { margin: 0 0 20px; font: 700 28px/1.1 Georgia, serif; }
.chapter-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; margin: 0; padding: 0; list-style: none; counter-reset: chapter; }
.chapter-list li { counter-increment: chapter; border-bottom: 1px solid var(--line); }
.chapter-list a { display: grid; grid-template-columns: 37px minmax(0,1fr) auto; align-items: center; gap: 10px; min-height: 62px; padding: 10px 0; }
.chapter-list a::before { content: counter(chapter, decimal-leading-zero); color: var(--accent); font-size: 11px; font-weight: 900; }
.chapter-list time { color: var(--muted); font-size: 10px; }
.series-sidebar { position: sticky; top: 98px; }
.series-sidebar-card { padding: 22px; }
.series-sidebar-card h2 { margin: 0 0 13px; font: 700 24px/1.1 Georgia, serif; }
.ad-slot { width: 100%; max-width: 970px; margin: 24px auto; overflow: hidden; text-align: center; border-radius: 14px; }
.ad-slot__label { display: block; margin-bottom: 5px; color: var(--muted); font: 700 9px/1.2 Inter, sans-serif; letter-spacing: .13em; text-transform: uppercase; }
.ad-slot__content { min-height: 100px; display: flex; align-items: center; justify-content: center; overflow: hidden; background: #f8f6f1; }
.ad-slot--inline .ad-slot__content { min-height: 250px; }
.ad-slot__content iframe, .ad-slot__content ins { max-width: 100%; }
.ad-slot__preview { min-height: 112px; display: grid; place-content: center; gap: 6px; padding: 20px; color: #727b89; border: 2px dashed #cbd1da; background: repeating-linear-gradient(135deg, #f7f8fa, #f7f8fa 12px, #eef1f4 12px, #eef1f4 24px); }
.ad-slot__preview strong { color: var(--navy); font: 700 14px/1.3 Inter, sans-serif; }
.ad-slot__preview span { font: 600 10px/1.3 ui-monospace, monospace; }
.chapter-list .chapter-list-ad { grid-column: 1 / -1; counter-increment: none; border: 0; }
.chapter-list-ad .ad-slot { margin-block: 12px; }
.reader-content > .ad-slot { font-family: Inter, sans-serif; margin-block: 36px; }
.mini-story { display: grid; grid-template-columns: 50px minmax(0,1fr); gap: 12px; align-items: center; padding: 11px 0; border-top: 1px solid var(--line); }
.mini-story:first-of-type { border-top: 0; }
.mini-cover { overflow: hidden; width: 50px; aspect-ratio: 2 / 3; border-radius: 6px; }
.mini-cover img { width: 100%; height: 100%; object-fit: cover; }
.mini-story h3 { margin: 0; font: 700 14px/1.25 Georgia, serif; }
.mini-story small { color: var(--muted); font-size: 10px; }

.reading-progress { position: fixed; z-index: 100; top: 0; left: 0; width: 0; height: 3px; background: var(--accent); }
.reader-shell { --reader-size: 19px; --reader-width: 760px; padding: 44px 0 70px; }
.reader-shell.is-dark { color: #dce0e7; background: #141922; }
.reader-toolbar { position: sticky; z-index: 20; top: 88px; width: min(calc(100% - 32px), 900px); display: flex; align-items: center; gap: 8px; margin: 0 auto 32px; padding: 9px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.96); box-shadow: var(--shadow); }
.reader-toolbar a { margin-right: auto; padding: 4px 8px; color: var(--muted); font-size: 13px; font-weight: 750; }
.reader-toolbar button { min-width: 38px; height: 36px; border: 1px solid var(--line); border-radius: 9px; background: #fff; cursor: pointer; font-weight: 800; }
.reader-article { width: min(calc(100% - 40px), var(--reader-width)); margin: auto; }
.reader-series { display: block; margin-bottom: 10px; color: var(--accent); font-size: 12px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.reader-article h1 { margin: 0 0 14px; font: 700 clamp(34px, 6vw, 55px)/1.05 Georgia, serif; letter-spacing: -1.5px; }
.reader-meta { margin-bottom: 35px; color: var(--muted); font-size: 12px; }
.reader-cover { overflow: hidden; margin-bottom: 36px; border-radius: 14px; }
.reader-cover img { width: 100%; max-height: 480px; object-fit: cover; }
.reader-content { font: 400 var(--reader-size)/1.9 Georgia, "Times New Roman", serif; }
.reader-content p { margin: 0 0 1.45em; }
.reader-content h2, .reader-content h3 { margin-top: 1.7em; font-family: Georgia, serif; line-height: 1.25; }
.reader-toolbar { display: none !important; }
.reader-nav { width: min(calc(100% - 40px), 900px); display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; gap: 16px; margin: 50px auto 0; padding: 18px; border: 1px solid var(--line); border-radius: 20px; background: var(--soft); box-shadow: var(--shadow); }
.reader-nav > div { min-width: 0; }
.reader-nav > div > a { min-height: 72px; display: flex; align-items: center; padding: 15px 20px; border: 1px solid var(--line); border-radius: 15px; background: #fff; font: 800 14px/1.25 Inter, sans-serif; transition: transform .2s, border-color .2s, box-shadow .2s, background .2s; }
.reader-nav > div:first-child > a { justify-content: flex-start; color: var(--navy); font-size: 0; }
.reader-nav > div:first-child > a::before { content: '←'; margin-right: 9px; font-size: 18px; }
.reader-nav > div:first-child > a::after { content: 'Back Chapter'; font-size: 14px; }
.reader-nav > div:last-child > a { justify-content: flex-end; color: #fff; border-color: var(--accent); background: var(--accent); text-align: right; }
.reader-nav > div > a:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(20,34,58,.12); }
.reader-nav > div:first-child > a:hover { color: var(--accent); border-color: #d8b8bc; }
.reader-nav > div:last-child > a:hover { color: #fff; border-color: var(--accent-dark); background: var(--accent-dark); }
.reader-nav .all-chapters { display: inline-flex; align-items: center; justify-content: center; min-width: 126px; padding: 14px; color: var(--muted); border-radius: 14px; background: rgba(255,255,255,.65); font-size: 12px; font-weight: 850; text-align: center; }
.reader-nav .all-chapters:hover { color: var(--accent); background: #fff; }
.reader-shell.is-dark .reader-toolbar { color: #e9edf3; border-color: #343b48; background: rgba(28,34,44,.96); }
.reader-shell.is-dark .reader-toolbar button { color: #e9edf3; border-color: #454e5d; background: #242b36; }
.reader-shell.is-dark .reader-meta { color: #9da8b8; }
.reader-shell.is-dark .ad-slot__content { background: #1d2430; }
.reader-shell.is-dark .ad-slot__preview { color: #aab3c0; border-color: #465062; background: #1d2430; }
.reader-shell.is-dark .ad-slot__preview strong { color: #eef2f7; }

.site-footer { padding: 48px 0 24px; color: #c5ccda; background: var(--navy); }
.footer-grid { display: grid; grid-template-columns: 1.2fr .8fr .8fr; gap: 50px; }
.footer-brand p { max-width: 380px; color: #96a2b5; font-size: 14px; }
.footer-col h2 { margin: 0 0 14px; color: #fff; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; }
.footer-col ul { margin: 0; padding: 0; list-style: none; }
.footer-col li { margin: 7px 0; }
.footer-col a { font-size: 14px; }
.copyright { margin-top: 38px; padding-top: 20px; color: #7f8ba0; border-top: 1px solid rgba(255,255,255,.1); font-size: 12px; }

@media (max-width: 980px) {
  .primary-nav, .header-search { display: none; }
  .menu-toggle { display: block; }
  .site-header.is-open .primary-nav { position: absolute; top: 73px; left: 0; display: block; width: 100%; padding: 18px 20px; border-bottom: 1px solid var(--line); background: var(--paper); }
  .site-header.is-open .primary-nav ul { display: grid; gap: 0; }
  .site-header.is-open .primary-nav a { display: block; padding: 11px 0; }
  .hero-grid { grid-template-columns: 1fr; }
  .hero-stack { display: none; }
  .story-grid { grid-template-columns: repeat(3, 1fr); }
  .genres { grid-template-columns: repeat(3, 1fr); }
  .series-layout { grid-template-columns: 1fr; }
  .series-sidebar { position: static; }
}

@media (max-width: 720px) {
  .container { width: min(calc(100% - 28px), var(--container)); }
  .header-row { min-height: 64px; }
  .brand { font-size: 22px; }
  .site-header.is-open .primary-nav { top: 63px; }
  .hero { padding: 54px 0 50px; }
  .hero h1 { font-size: clamp(40px, 13vw, 58px); }
  .hero-copy { font-size: 16px; }
  .section { padding: 50px 0; }
  .section-head { align-items: start; flex-direction: column; gap: 8px; }
  .story-grid { grid-template-columns: repeat(2, 1fr); gap: 24px 14px; }
  .story-card h3 { font-size: 17px; }
  .discovery-grid { grid-template-columns: 1fr; }
  .latest-list { grid-template-columns: 1fr; }
  .genres { grid-template-columns: repeat(2, 1fr); }
  .genre-card { min-height: 96px; }
  .series-hero { grid-template-columns: 110px minmax(0,1fr); gap: 18px; padding: 18px; }
  .series-info h1 { font-size: 29px; letter-spacing: -.8px; }
  .series-description { grid-column: 1 / -1; }
  .series-facts, .series-actions { grid-column: 1 / -1; }
  .series-actions { flex-wrap: nowrap; width: 100%; }
  .series-actions .button { flex: 1 1 0; min-width: 0; padding-inline: 10px; white-space: nowrap; }
  .chapter-section { padding: 20px; }
  .chapter-list { grid-template-columns: 1fr; }
  .reader-toolbar { top: 74px; }
  .reader-toolbar a span { display: none; }
  .reader-content { line-height: 1.8; }
  .reader-nav { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 36px; padding: 12px; }
  .reader-nav > div { flex: 1 1 150px; }
  .reader-nav > div:empty { display: none; }
  .reader-nav > div:last-child { order: 2; }
  .reader-nav > div > a { min-height: 60px; padding: 13px 15px; }
  .reader-nav .all-chapters { flex: 1 0 100%; order: 3; min-height: 46px; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
}

@media (max-width: 420px) {
  .story-grid { gap-inline: 11px; }
  .story-meta span:last-child { display: none; }
  .genres { grid-template-columns: 1fr 1fr; gap: 8px; }
  .genre-card { padding: 14px; }
  .series-hero { grid-template-columns: 92px minmax(0,1fr); }
  .series-actions .button { flex: 1; padding-inline: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
