/* ============================================
   OMETA NOVEL - COMPLETE STYLESHEET
   Standalone CSS for reader + archive
   ============================================ */

/* ============================================
   FONTS
   ============================================ */

@font-face {
  font-family: 'Necto Mono';
  src: url('fonts/necto-mono.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ============================================
   CSS VARIABLES
   ============================================ */

:root {
  /* === Core Colors === */
  --fg: #1a1a1a;
  --bg: #fafafa;
  --muted: #666;
  --border: rgba(0, 0, 0, 0.1);
  --accent: #2563eb;

  /* === Typography === */
  --font-body: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: Georgia, 'Times New Roman', Times, serif;
  --font-mono: 'Necto Mono', 'SF Mono', 'Consolas', monospace;
  --font-size: 19px;
  --line-height: 1.7;
  --max-measure: 68ch;

  /* === Layout === */
  --page-padding-v: 8vh;
  --page-padding-h: 10vw;
  --header-height: 56px;
  --max-content-width: 680px;

  /* === Transitions === */
  --transition-duration: 280ms;
  --transition-timing: cubic-bezier(0.4, 0, 0.2, 1);

  /* === Page Turn Animation (tweak these!) === */
  --page-exit-rotate: -6deg;
  --page-exit-opacity: 0;
  --page-exit-z-drop: -80px;
  --page-enter-opacity-start: 0.7;
  --page-enter-opacity-end: 1;
  --page-shadow-blur: 16px;
  --page-shadow-opacity: 0.12;

  /* === Title Page === */
  --title-split: 50%;
  --title-font-size: clamp(2.2rem, 5vw, 3.5rem);
  --subtitle-font-size: clamp(1rem, 2vw, 1.4rem);

  /* === Table of Contents === */
  --toc-width: min(380px, 88vw);
  --toc-item-delay: 0.04s;
  --toc-verbose-color: #777;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --fg: #e8e8e8;
    --bg: #141414;
    --muted: #999;
    --border: rgba(255, 255, 255, 0.1);
  }
}

/* ============================================
   RESET & BASE
   ============================================ */

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--font-size);
  line-height: var(--line-height);
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   READER MODE - CHAPTER VIEW
   ============================================ */

.ometa-novel-chapter {
  overflow: hidden;
  height: 100%;
}

.ometa-novel-chapter html {
  overflow: hidden;
  height: 100%;
}

/* When reader is released */
body.reader-released {
  overflow: auto;
  overflow-x: hidden;
  height: auto;
}

/* Source content - hidden once paginated */
#source {
  display: none;
}

/* ============================================
   READER CONTAINER
   ============================================ */

#reader {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--bg);
  touch-action: pan-y pinch-zoom;
  z-index: 1;
}

body.reader-released #reader {
  position: relative;
  height: auto;
  min-height: 100vh;
}

/* ============================================
   SCROLL MODE
   ============================================ */

body.scroll-mode {
  overflow: auto;
  overflow-x: hidden;
  height: auto;
}

body.scroll-mode #reader {
  position: relative;
  height: auto;
  min-height: auto;
  overflow: visible;
}

body.scroll-mode .page {
  display: none;
}

body.scroll-mode #source {
  display: block;
  max-width: var(--max-content-width);
  margin: 0 auto;
  padding: calc(var(--header-height) + 40px) var(--page-padding-h) 60px;
}

body.scroll-mode #source .entry-content {
  font-family: var(--font-serif);
  font-size: var(--font-size);
  line-height: var(--line-height);
  color: var(--fg);
}

body.scroll-mode #source .entry-content p {
  margin: 0 0 1.15em 0;
}

body.scroll-mode .reader-header {
  position: fixed;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

body.scroll-mode .reader-cta {
  display: block;
}

body.scroll-mode .reader-footer {
  display: block;
}

/* Scroll mode title/hero */
.scroll-mode-header {
  display: none;
  max-width: var(--max-content-width);
  margin: 0 auto;
  padding: calc(var(--header-height) + 40px) var(--page-padding-h) 0;
  text-align: center;
}

body.scroll-mode .scroll-mode-header {
  display: block;
}

body.scroll-mode #source {
  padding-top: 40px;
}

.scroll-mode-header__image {
  width: 100%;
  max-width: 400px;
  margin: 0 auto 2em;
  border-radius: 4px;
  overflow: hidden;
}

.scroll-mode-header__image img {
  width: 100%;
  height: auto;
  display: block;
}

.scroll-mode-header__title {
  font-family: var(--font-body);
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  font-weight: 700;
  margin: 0 0 0.3em 0;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.scroll-mode-header__subtitle {
  font-family: var(--font-serif);
  font-size: 1.1em;
  font-style: italic;
  color: var(--muted);
  margin: 0 0 2em 0;
}

/* Mode toggle switch */
.header__mode-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 14px;
  cursor: pointer;
  user-select: none;
}

.header__mode-toggle:focus {
  outline: none;
}

.header__mode-toggle:focus-visible .mode-toggle__track {
  box-shadow: 0 0 0 2px var(--accent);
}

.mode-toggle__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.4;
  transition: opacity 0.2s ease;
}

.mode-toggle__icon svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
}

/* Highlight active mode icon */
.mode-toggle__icon--book {
  opacity: 0.8;
}

.header__mode-toggle.is-scroll .mode-toggle__icon--book {
  opacity: 0.4;
}

.header__mode-toggle.is-scroll .mode-toggle__icon--scroll {
  opacity: 0.8;
}

/* Toggle track */
.mode-toggle__track {
  position: relative;
  width: 28px;
  height: 14px;
  background: var(--border);
  border-radius: 7px;
  transition: background 0.2s ease;
}

/* Toggle thumb */
.mode-toggle__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  background: var(--fg);
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.header__mode-toggle.is-scroll .mode-toggle__thumb {
  transform: translateX(14px);
}

.header__mode-toggle:hover .mode-toggle__track {
  background: rgba(0, 0, 0, 0.15);
}

/* ============================================
   PAGE STYLES
   ============================================ */

.page {
  position: absolute;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  padding: var(--page-padding-v) var(--page-padding-h);
  padding-top: calc(var(--page-padding-v) + var(--header-height));
  font-family: var(--font-serif);
  font-size: var(--font-size);
  line-height: var(--line-height);
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  color: var(--fg);
  background: var(--bg);
  opacity: 1;
  transform: none;
  will-change: transform, opacity;
}

.page__inner {
  width: 100%;
  max-width: var(--max-measure);
  overflow: hidden;
  max-height: 100%;
}

/* ============================================
   PAGE TRANSITIONS
   ============================================ */

.page.active {
  transform: none;
  opacity: var(--page-enter-opacity-end);
  z-index: 2;
  transition: opacity var(--transition-duration) var(--transition-timing);
}

.page.is-entering-next,
.page.is-entering-prev {
  opacity: var(--page-enter-opacity-start);
}

.page.is-entering-next {
  transform: perspective(1400px) rotateY(6deg);
  transform-origin: right center;
}

.page.is-entering-prev {
  transform: perspective(1400px) rotateY(-6deg);
  transform-origin: left center;
}

/* Exiting page - "melt away" effect */
.page.is-exiting {
  transform-origin: left center;
  transform:
    perspective(1400px)
    rotateY(var(--page-exit-rotate))
    translateZ(var(--page-exit-z-drop));
  opacity: var(--page-exit-opacity);
  filter: drop-shadow(0 8px var(--page-shadow-blur) rgba(0, 0, 0, var(--page-shadow-opacity)));
  z-index: 1;
  pointer-events: none;
  transition:
    transform var(--transition-duration) var(--transition-timing),
    opacity var(--transition-duration) var(--transition-timing),
    filter var(--transition-duration) var(--transition-timing);
}

/* Background stays visible during transition */
.page.is-exiting::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--bg);
  z-index: -1;
}

/* ============================================
   TITLE PAGE (50/50 Split)
   ============================================ */

.page--title {
  padding: 0;
  padding-top: var(--header-height);
}

.page__inner--title {
  max-width: none;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: var(--title-split) calc(100% - var(--title-split));
}

.title-page__illustration {
  background: linear-gradient(135deg, #f0f0f0 0%, #e0e0e0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  height: 100%;
}

.title-page__illustration img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.title-page__content {
  padding: var(--page-padding-v) var(--page-padding-h);
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

.title-page__title {
  font-family: var(--font-body);
  font-size: var(--title-font-size);
  font-weight: 700;
  line-height: 1.15;
  margin: 0 0 0.4em 0;
  color: var(--fg);
  letter-spacing: -0.02em;
}

.title-page__subtitle {
  font-family: var(--font-serif);
  font-size: var(--subtitle-font-size);
  font-weight: 400;
  font-style: italic;
  line-height: 1.4;
  margin: 0 0 1.5em 0;
  color: var(--muted);
}

/* Mobile title page */
@media (max-width: 768px) {
  .page--title {
    padding-top: var(--header-height);
  }

  .page__inner--title {
    grid-template-columns: 1fr;
    grid-template-rows: 50vw 1fr;
    height: calc(100dvh - var(--header-height));
  }

  .title-page__illustration {
    max-height: 50vw;
  }

  .title-page__content {
    padding: 20px var(--page-padding-h);
    justify-content: flex-start;
  }

  .title-page__title {
    font-size: 1.8em;
  }

  .title-page__subtitle {
    font-size: 1em;
    margin-bottom: 0;
  }
}

/* ============================================
   HEADER
   ============================================ */

.reader-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  padding: 0 var(--page-padding-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  background: transparent;
  color: var(--fg);
  font-size: 13px;
  z-index: 100;
  pointer-events: none;
}

.reader-header > * {
  pointer-events: auto;
}

.header__left {
  display: flex;
  align-items: center;
}

.header__prev {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: inherit;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.header__prev:hover {
  opacity: 1;
}

.header__prev-arrow {
  font-size: 1.1em;
}

.header__prev-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

@media (max-width: 600px) {
  .header__prev-label {
    display: none;
  }
}

.header__book-title {
  text-align: center;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.85em;
  opacity: 0.7;
  margin: 0;
}

.header__right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}

.header__page-count {
  font-variant-numeric: tabular-nums;
  opacity: 0.6;
}

.header__menu-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 34px;
  height: 34px;
  padding: 8px;
  background: transparent;
  border: 1.5px solid currentColor;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.header__menu-btn:hover {
  opacity: 1;
}

.header__menu-btn span {
  display: block;
  width: 14px;
  height: 1.5px;
  background: currentColor;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.header__menu-btn.is-open span:nth-child(1) {
  transform: translateY(5.5px) rotate(45deg);
}

.header__menu-btn.is-open span:nth-child(2) {
  opacity: 0;
}

.header__menu-btn.is-open span:nth-child(3) {
  transform: translateY(-5.5px) rotate(-45deg);
}

body.reader-released .reader-header {
  position: absolute;
}

/* ============================================
   TABLE OF CONTENTS OVERLAY
   ============================================ */

.toc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  z-index: 200;
}

.toc-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.toc-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--toc-width);
  background: var(--bg);
  transform: translateX(100%);
  transition: transform 0.25s var(--transition-timing);
  overflow-y: auto;
  overscroll-behavior: contain;
  z-index: 201;
  padding: 20px;
  padding-top: calc(var(--header-height) + 20px);
}

.toc-overlay.is-open .toc-panel {
  transform: translateX(0);
}

.toc__title {
  font-size: 1.1em;
  font-weight: 600;
  margin: 0 0 20px 0;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.toc__list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc__item {
  margin-bottom: 6px;
  opacity: 0;
  transform: translateY(-12px);
  animation: tocDropIn 0.3s var(--transition-timing) forwards;
  animation-play-state: paused;
}

/* Only animate when panel is open */
.toc-overlay.is-open .toc__item {
  animation-play-state: running;
}

.toc__item:nth-child(1) { animation-delay: calc(var(--toc-item-delay) * 1); }
.toc__item:nth-child(2) { animation-delay: calc(var(--toc-item-delay) * 2); }
.toc__item:nth-child(3) { animation-delay: calc(var(--toc-item-delay) * 3); }
.toc__item:nth-child(4) { animation-delay: calc(var(--toc-item-delay) * 4); }
.toc__item:nth-child(5) { animation-delay: calc(var(--toc-item-delay) * 5); }
.toc__item:nth-child(6) { animation-delay: calc(var(--toc-item-delay) * 6); }
.toc__item:nth-child(7) { animation-delay: calc(var(--toc-item-delay) * 7); }
.toc__item:nth-child(8) { animation-delay: calc(var(--toc-item-delay) * 8); }
.toc__item:nth-child(9) { animation-delay: calc(var(--toc-item-delay) * 9); }
.toc__item:nth-child(10) { animation-delay: calc(var(--toc-item-delay) * 10); }
.toc__item:nth-child(11) { animation-delay: calc(var(--toc-item-delay) * 11); }
.toc__item:nth-child(12) { animation-delay: calc(var(--toc-item-delay) * 12); }

@keyframes tocDropIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.toc__link {
  display: flex;
  align-items: baseline;
  gap: 6px;
  text-decoration: none;
  color: inherit;
  padding: 6px 0;
  transition: opacity 0.15s ease;
}

.toc__link:hover {
  opacity: 0.65;
}

.toc__item.is-current .toc__link {
  font-weight: 700;
}

.toc__chapter-title {
  flex-shrink: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.92em;
}

.toc__dots {
  flex: 1;
  border-bottom: 1px dotted var(--border);
  min-width: 16px;
  margin-bottom: 3px;
}

.toc__page-num {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  opacity: 0.6;
}

/* Verbose mode: trailer text */
.toc__trailer {
  max-height: 0;
  overflow: hidden;
  color: var(--toc-verbose-color);
  font-size: 0.8em;
  line-height: 1.5;
  padding-left: 14px;
  transition: max-height 0.25s var(--transition-timing),
              padding 0.25s var(--transition-timing),
              opacity 0.25s ease;
  opacity: 0;
}

.toc-overlay.is-verbose .toc__trailer {
  max-height: 180px;
  padding-top: 6px;
  padding-bottom: 6px;
  opacity: 1;
}

.toc__verbose-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.88em;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}

.toc__verbose-toggle:hover {
  opacity: 1;
}

.toc__verbose-checkbox {
  width: 14px;
  height: 14px;
}

/* ============================================
   NEXT CHAPTER LINK (simple, at page bottom)
   ============================================ */

.next-chapter-link {
  position: absolute;
  bottom: var(--page-padding-v);
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: 0.9em;
  font-family: var(--font-body);
  transition: color 0.2s ease;
}

.next-chapter-link:hover {
  color: var(--fg);
}

/* ============================================
   DROP CAPS (3-line initial caps)
   ============================================ */

.drop-cap::first-letter {
  float: left;
  font-size: 3.2em;
  line-height: 0.85;
  padding-right: 0.08em;
  margin-top: 0.05em;
  font-family: var(--font-serif);
  font-weight: 400;
  color: var(--fg);
}

/* First content page gets extra top margin */
.page--first .page__inner {
  padding-top: calc(var(--page-padding-v) * 0.5);
}

/* ============================================
   NEXT CHAPTER PREVIEW (in CTA section)
   ============================================ */

.next-chapter-preview {
  max-width: 600px;
  margin: 0 auto 4em auto;
  padding-bottom: 3em;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.next-chapter-preview__title {
  font-family: var(--font-body);
  font-size: 1.4em;
  font-weight: 600;
  margin: 0 0 1.2em 0;
  text-align: center;
  letter-spacing: -0.01em;
}

.next-chapter-preview__content {
  position: relative;
  max-height: 14em;
  overflow: hidden;
  margin-bottom: 0;
}

.next-chapter-preview__text {
  font-family: var(--font-serif);
  font-size: var(--font-size);
  line-height: var(--line-height);
  color: var(--fg);
}

.next-chapter-preview__text p {
  margin: 0 0 1em 0;
}

/* Gradient fade at bottom - uses mask for clean transparency */
.next-chapter-preview__content::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 8em;
  background: var(--bg);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 70%);
  mask-image: linear-gradient(to bottom, transparent 0%, black 70%);
  pointer-events: none;
}

.next-chapter-preview__link {
  display: block;
  text-align: center;
  margin-top: 1.5em;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: 1em;
  font-family: var(--font-body);
  transition: color 0.2s ease;
}

.next-chapter-preview__link:hover {
  color: var(--fg);
}

/* ============================================
   READER CTA SECTION
   ============================================ */

.reader-cta {
  display: none;
  background: var(--bg);
  padding: 40px var(--page-padding-h) 60px;
  min-height: 70vh;
}

body.reader-released .reader-cta {
  display: flex;
  align-items: center;
  justify-content: center;
}

.reader-cta__inner {
  max-width: 650px;
  width: 100%;
  margin: 0 auto;
}

/* Legacy styles for default CTA content */
.reader-cta__title {
  font-size: 1.6em;
  margin: 0 0 12px 0;
  text-align: center;
}

.reader-cta__text {
  font-size: 1.05em;
  color: var(--muted);
  margin: 0 0 28px 0;
  line-height: 1.5;
  text-align: center;
}

.reader-cta__form {
  display: flex;
  gap: 10px;
  max-width: 380px;
  margin: 0 auto 12px;
}

.reader-cta__input {
  flex: 1;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 0.95em;
  background: var(--bg);
  color: var(--fg);
}

.reader-cta__input:focus {
  outline: none;
  border-color: var(--fg);
}

.reader-cta__submit {
  padding: 11px 22px;
  background: var(--fg);
  color: var(--bg);
  border: none;
  border-radius: 5px;
  font-size: 0.95em;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.reader-cta__submit:hover {
  opacity: 0.85;
}

.reader-cta__privacy {
  font-size: 0.82em;
  color: var(--muted);
  margin: 0;
}

@media (max-width: 480px) {
  .reader-cta__form {
    flex-direction: column;
  }
}

/* Also reading section */
.reader-cta__also-reading {
  margin-top: 50px;
  padding-top: 40px;
  border-top: 1px solid var(--border);
}

.reader-cta__also-reading h3 {
  font-size: 1.1em;
  margin: 0 0 20px 0;
}

.also-reading__chapters {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.also-reading__chapter {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease;
  max-width: 280px;
}

.also-reading__chapter:hover {
  border-color: var(--muted);
}

.also-reading__image {
  width: 50px;
  height: 50px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--border);
  flex-shrink: 0;
}

.also-reading__content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
}

.also-reading__title {
  font-weight: 600;
  font-size: 0.9em;
}

.also-reading__cta {
  font-size: 0.82em;
  color: var(--muted);
}

/* ============================================
   READER FOOTER
   ============================================ */

.reader-footer {
  display: none;
  padding: 30px var(--page-padding-h);
  text-align: center;
  font-size: 0.88em;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

body.reader-released .reader-footer {
  display: block;
}

.reader-footer a {
  color: inherit;
}

.reader-footer__copyright {
  margin: 10px 0 0;
}

/* ============================================
   OFFSCREEN MEASURER
   ============================================ */

.measure {
  position: absolute;
  left: -99999px;
  top: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  padding: var(--page-padding-v) var(--page-padding-h);
  padding-top: calc(var(--page-padding-v) + var(--header-height));
  font-family: var(--font-serif);
  font-size: var(--font-size);
  line-height: var(--line-height);
  overflow: hidden;
  visibility: hidden;
  pointer-events: none;
}

.measure .page__inner {
  width: 100%;
  max-width: var(--max-measure);
  max-height: 100%;
  overflow: hidden;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */

.x-the-content.entry-content,
.entry-content {
  font-family: var(--font-serif);
}

.x-the-content.entry-content p,
.entry-content p {
  margin: 0 0 1.15em 0;
}

.x-the-content.entry-content p:last-child,
.entry-content p:last-child {
  margin-bottom: 0;
}

.x-the-content.entry-content h1,
.x-the-content.entry-content h2,
.x-the-content.entry-content h3,
.entry-content h1,
.entry-content h2,
.entry-content h3 {
  font-family: var(--font-body);
  margin: 1.4em 0 0.5em 0;
  line-height: 1.25;
}

.x-the-content.entry-content h1:first-child,
.x-the-content.entry-content h2:first-child,
.x-the-content.entry-content h3:first-child,
.entry-content h1:first-child,
.entry-content h2:first-child,
.entry-content h3:first-child {
  margin-top: 0;
}

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

@supports (height: 100dvh) {
  #reader,
  .page,
  .measure {
    height: 100dvh;
  }
}

@media screen and (max-width: 768px) {
  html, body {
    touch-action: manipulation;
  }

  #reader {
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .page {
    min-height: 100vh;
    min-height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
  }

  :root {
    --page-padding-h: 6vw;
    --font-size: 17px;
  }
}

/* ============================================
   ARCHIVE PAGE STYLES
   ============================================ */

.ometa-novel-archive {
  min-height: 100vh;
}

.archive-container {
  width: 100%;
}

/* Hero */
.archive-hero {
  padding: 60px var(--page-padding-h) 80px;
  background: linear-gradient(180deg, #f8f8f8 0%, var(--bg) 100%);
}

.archive-hero__inner {
  max-width: 900px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 50px;
  align-items: center;
}

.archive-hero__cover img {
  width: 100%;
  max-width: 280px;
  border-radius: 4px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.archive-hero__title {
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 700;
  margin: 0 0 0.2em 0;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.archive-hero__tagline {
  font-size: 1.2em;
  font-style: italic;
  color: var(--muted);
  margin: 0 0 1.2em 0;
  line-height: 1.4;
}

.archive-hero__meta {
  font-size: 0.9em;
  color: var(--muted);
  margin-bottom: 1.5em;
}

.meta-separator {
  margin: 0 8px;
  opacity: 0.4;
}

.archive-hero__description {
  font-size: 1.05em;
  line-height: 1.6;
  margin: 0 0 2em 0;
}

.archive-hero__cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  background: var(--fg);
  color: var(--bg);
  text-decoration: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 1.05em;
  transition: opacity 0.15s ease;
}

.archive-hero__cta:hover {
  opacity: 0.85;
}

.cta-arrow {
  transition: transform 0.15s ease;
}

.archive-hero__cta:hover .cta-arrow {
  transform: translateX(3px);
}

.archive-hero__byline {
  margin-top: 1.5em;
  font-size: 0.95em;
  color: var(--muted);
}

.archive-hero__byline a {
  color: inherit;
  text-decoration: underline;
}

@media (max-width: 768px) {
  .archive-hero__inner {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .archive-hero__cover {
    order: -1;
    margin: 0 auto;
  }

  .archive-hero__cover img {
    max-width: 200px;
  }
}

/* Table of Contents */
.archive-toc {
  padding: 60px var(--page-padding-h);
}

.archive-toc__inner {
  max-width: 700px;
  margin: 0 auto;
}

.toc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.toc-header__title {
  font-size: 1.4em;
  font-weight: 600;
  margin: 0;
}

.toc-header__toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88em;
  color: var(--muted);
  cursor: pointer;
}

.toc-header__toggle input {
  width: 14px;
  height: 14px;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: chapter;
}

.toc-item {
  margin-bottom: 4px;
  opacity: 0;
  transform: translateY(10px);
  animation: archiveTocIn 0.3s ease forwards;
  animation-delay: var(--delay, 0s);
}

@keyframes archiveTocIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.toc-item__link {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 0;
  text-decoration: none;
  color: inherit;
  transition: opacity 0.15s ease;
}

.toc-item__link:hover {
  opacity: 0.6;
}

.toc-item__number {
  font-size: 0.85em;
  font-weight: 600;
  opacity: 0.4;
  min-width: 24px;
}

.toc-item__title {
  font-weight: 500;
}

.toc-item__dots {
  flex: 1;
  border-bottom: 1px dotted var(--border);
  min-width: 20px;
  margin-bottom: 3px;
}

.toc-item__page {
  font-variant-numeric: tabular-nums;
  font-size: 0.9em;
  opacity: 0.5;
}

.toc-item__trailer {
  max-height: 0;
  overflow: hidden;
  padding-left: 34px;
  font-size: 0.9em;
  color: var(--toc-verbose-color);
  line-height: 1.5;
  transition: max-height 0.25s ease, padding 0.25s ease, opacity 0.25s ease;
  opacity: 0;
}

.toc-list.is-verbose .toc-item__trailer {
  max-height: 150px;
  padding-top: 6px;
  padding-bottom: 12px;
  opacity: 1;
}

/* About Section */
.archive-about {
  padding: 60px var(--page-padding-h);
  background: #f5f5f5;
}

.archive-about__inner {
  max-width: 900px;
  margin: 0 auto;
}

.archive-about h2 {
  font-size: 1.4em;
  margin: 0 0 30px 0;
  text-align: center;
}

.about-content {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 40px;
}

.about-content h3 {
  font-size: 1em;
  margin: 0 0 12px 0;
  opacity: 0.7;
}

.themes-list,
.similar-list,
.genres-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.themes-list li {
  margin-bottom: 12px;
}

.themes-list strong {
  display: block;
}

.themes-list span {
  font-size: 0.88em;
  color: var(--muted);
}

.similar-intro {
  font-size: 0.9em;
  color: var(--muted);
  margin: 0 0 10px 0;
}

.similar-list li {
  margin-bottom: 6px;
}

.similar-list a {
  color: inherit;
}

.genres-list li {
  display: inline-block;
  padding: 4px 10px;
  margin: 0 6px 6px 0;
  background: var(--bg);
  border-radius: 4px;
  font-size: 0.88em;
}

@media (max-width: 768px) {
  .about-content {
    grid-template-columns: 1fr;
    gap: 30px;
  }
}

/* Newsletter */
.archive-newsletter {
  padding: 70px var(--page-padding-h);
  text-align: center;
}

.archive-newsletter__inner {
  max-width: 500px;
  margin: 0 auto;
}

.archive-newsletter h2 {
  font-size: 1.6em;
  margin: 0 0 10px 0;
}

.archive-newsletter > p {
  color: var(--muted);
  margin: 0 0 28px 0;
}

.newsletter-form {
  display: flex;
  gap: 10px;
  max-width: 400px;
  margin: 0 auto 12px;
}

.newsletter-form__input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 1em;
  background: var(--bg);
  color: var(--fg);
}

.newsletter-form__input:focus {
  outline: none;
  border-color: var(--fg);
}

.newsletter-form__submit {
  padding: 12px 24px;
  background: var(--fg);
  color: var(--bg);
  border: none;
  border-radius: 5px;
  font-size: 1em;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.newsletter-form__submit:hover {
  opacity: 0.85;
}

.newsletter-privacy {
  font-size: 0.82em;
  color: var(--muted);
  margin: 0;
}

@media (max-width: 480px) {
  .newsletter-form {
    flex-direction: column;
  }
}

/* Footer */
.archive-footer {
  padding: 40px var(--page-padding-h);
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.88em;
  color: var(--muted);
}

.archive-footer__copyright {
  margin: 0 0 8px 0;
}

.archive-footer__fiction {
  margin: 0 0 16px 0;
}

.archive-footer__nav {
  display: flex;
  justify-content: center;
  gap: 20px;
}

.archive-footer__nav a {
  color: inherit;
  text-decoration: none;
}

.archive-footer__nav a:hover {
  text-decoration: underline;
}

/* ============================================
   UTILITIES
   ============================================ */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
