@import url("https://fonts.googleapis.com/css2?family=Literata:wght@400;500;600;700&family=Work+Sans:wght@400;500;600&display=swap");

:root {
  color-scheme: only light;
  --ink: #1f2428;
  --muted: #6f7881;
  --paper: #f4f6f8;
  --sand: #e6e9ee;
  --clay: #c7d2de;
  --wood: #3d556f;
  --accent: #6a88a6;
  --reader-font: "Literata", serif;
  --reader-weight: 400;
  --reader-size: 1.35rem;
}

:root[data-theme="dark"],
body[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e5ebf2;
  --muted: #a5b1bd;
  --paper: #1f242a;
  --sand: #272d34;
  --clay: #3a4653;
  --wood: #c2d2e1;
  --accent: #8ea7c2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Work Sans", sans-serif;
  color: var(--ink);
  background-color: #f2f5f8;
  background-image: url("https://www.transparenttextures.com/patterns/clean-gray-paper.png");
  min-height: 100vh;
}

:root[data-theme="dark"] body,
body[data-theme="dark"] {
  background-color: #171d23;
  background-image: url("https://www.transparenttextures.com/patterns/dark-matter.png");
}

.glow {
  display: none;
}

.site-header {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 2.5rem clamp(1.5rem, 4vw, 4rem) 1rem;
}

.chapter-view .site-header {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 1.6rem clamp(1.5rem, 4vw, 4rem) 0.8rem;
  gap: 1.5rem;
}

.text-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  position: relative;
}

.nav-toggle {
  display: none;
}

.nav-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.size-button {
  display: none;
}

.chapter-view .size-button {
  display: inline-flex;
}

.chapter-view .text-controls {
  gap: 0.4rem;
}

.control-button {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(61, 85, 111, 0.18);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.chapter-view .control-button {
  padding: 0.25rem 0.7rem;
  font-size: 0.78rem;
}

:root[data-theme="dark"] .control-button,
body[data-theme="dark"] .control-button {
  background: rgba(28, 34, 40, 0.9);
  border-color: rgba(255, 255, 255, 0.08);
}

.breadcrumbs {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-family: "Literata", serif;
  font-size: clamp(1.4rem, 2.2vw, 2rem);
  letter-spacing: 0.02em;
}

.chapter-view .breadcrumbs {
  font-size: clamp(1.1rem, 1.8vw, 1.5rem);
}

.crumb {
  text-decoration: none;
  color: var(--wood);
}

.crumb-short {
  display: none;
}

.crumb-full {
  display: inline;
}

.crumb-sep {
  color: var(--muted);
  font-size: 0.85rem;
}


.page {
  padding: 0 clamp(1.5rem, 4vw, 4rem) 4rem;
}

@media (min-width: 960px) {
  .page,
  .site-header {
    max-width: 75%;
    margin-left: auto;
    margin-right: auto;
  }
}

.hero,
.story-hero,
.chapter-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 2rem;
  padding: 1.5rem 0 2rem;
  border-bottom: 1px solid rgba(61, 85, 111, 0.15);
}

.chapter-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1rem 0 1.4rem;
  border-bottom: 1px solid rgba(61, 85, 111, 0.15);
}

.nav-title {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.nav-title h1 {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(1.4rem, 2.4vw, 1.9rem);
}

.nav-label {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.7rem;
  color: var(--accent);
}

.nav-sep {
  color: var(--muted);
  font-size: 0.9rem;
}

.nav-story {
  color: var(--muted);
  font-size: 0.95rem;
}

.hero h1,
.story-hero h1,
.chapter-hero h1 {
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(1.9rem, 3.2vw, 2.7rem);
  margin: 0 0 0.5rem;
}

.hero-sub {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.hero-label {
  text-transform: uppercase;
  letter-spacing: 0.25em;
  font-size: 0.75rem;
  color: var(--accent);
  margin: 0 0 0.8rem;
}

.story-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.8rem;
  margin-top: 2rem;
}

.story-card {
  position: relative;
  display: flex;
  gap: 1rem;
  min-height: 320px;
  padding: 1.5rem 1.5rem 1.5rem 1rem;
  background: linear-gradient(160deg, #f6f8fb 0%, #e7edf3 70%);
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(61, 85, 111, 0.16);
  text-decoration: none;
  color: var(--ink);
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.new-badge {
  position: absolute;
  top: 1rem;
  right: 1rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: rgba(106, 136, 166, 0.18);
  color: var(--wood);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0;
  pointer-events: none;
}

.draft-badge {
  position: absolute;
  top: 1rem;
  left: 1rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: rgba(205, 108, 57, 0.18);
  color: #a14d1f;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.draft-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: rgba(205, 108, 57, 0.18);
  color: #a14d1f;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-left: 0.55rem;
}

.story-card.is-new .new-badge {
  opacity: 1;
}

:root[data-theme="dark"] .story-card,
body[data-theme="dark"] .story-card {
  background: linear-gradient(160deg, #242b33 0%, #1c232b 70%);
  box-shadow: 0 18px 35px rgba(0, 0, 0, 0.45);
}

.story-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 28px 45px rgba(61, 85, 111, 0.22);
}

.spine {
  width: 18px;
  border-radius: 12px;
  background: linear-gradient(180deg, #6d89a5 0%, #3d556f 60%);
  box-shadow: inset 2px 0 4px rgba(0, 0, 0, 0.18);
  flex-shrink: 0;
}

.story-card-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 1rem;
  width: 100%;
}

.story-card h2 {
  font-family: "Literata", serif;
  font-size: 1.6rem;
  margin: 0;
}

.chapter-title {
  hyphens: auto;
}

.story-card p {
  margin: 0;
  color: var(--muted);
}

.back-link {
  text-decoration: none;
  color: var(--wood);
  font-weight: 600;
}

.nav-menu .back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(61, 85, 111, 0.18);
  background: rgba(255, 255, 255, 0.7);
  font-size: 0.85rem;
}

:root[data-theme="dark"] .nav-menu .back-link,
body[data-theme="dark"] .nav-menu .back-link {
  background: rgba(28, 34, 40, 0.9);
  border-color: rgba(255, 255, 255, 0.08);
}

.reader-shell {
  margin-top: 2.5rem;
}

.nav-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  max-width: min(320px, 80vw);
  padding: 14px 18px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(12, 18, 24, 0.94), rgba(28, 36, 44, 0.94));
  color: #f5f2ea;
  box-shadow: 0 14px 30px rgba(10, 14, 18, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  line-height: 1.4;
  transform: translateY(12px);
  opacity: 0;
  transition: transform 260ms ease, opacity 260ms ease;
}

.nav-toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

.nav-toast.is-hidden {
  transform: translateY(8px);
  opacity: 0;
  pointer-events: none;
}

.nav-toast-text {
  display: block;
}

.next-chapter-link {
  margin-top: 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.4rem;
  background: rgba(249, 251, 253, 0.9);
  border-radius: 18px;
  text-decoration: none;
  color: var(--ink);
  border: 1px solid rgba(61, 85, 111, 0.12);
}

:root[data-theme="dark"] .next-chapter-link,
body[data-theme="dark"] .next-chapter-link {
  background: rgba(30, 36, 43, 0.9);
  border-color: rgba(255, 255, 255, 0.08);
}

.next-label {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.7rem;
  color: var(--accent);
}

.next-title {
  font-family: var(--reader-font);
  font-size: 1.1rem;
  flex: 1;
}

.next-arrow {
  font-size: 1.2rem;
  color: var(--accent);
}

.reader-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.4rem;
  flex-wrap: nowrap;
}

.reader-button {
  background: var(--wood);
  color: #fff;
  border: none;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.78rem;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

:root[data-theme="dark"] .reader-button,
body[data-theme="dark"] .reader-button {
  background: #d9e3ed;
  color: #141a21;
  box-shadow: 0 10px 18px rgba(6, 10, 14, 0.25);
}

.reader-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.page-indicator {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.reader-page {
  background: var(--paper);
  border-radius: 26px;
  padding: clamp(1.8rem, 3vw, 3rem);
  box-shadow: none;
  min-height: 320px;
  position: relative;
  border: none;
  font-size: var(--reader-size);
  line-height: 1.85;
  font-family: var(--reader-font);
  font-weight: var(--reader-weight);
}

.reader-page.measure {
  position: absolute;
  visibility: hidden;
  height: auto;
  left: -9999px;
  top: 0;
}

.reader-page.turn {
  animation: pageTurn 0.25s ease;
}

.reader-page h2,
.reader-page h3,
.reader-page h4 {
  font-family: "Literata", serif;
  margin-top: 0;
}

.reader-page blockquote {
  margin: 1.5rem 0;
  padding: 0.5rem 1.2rem;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}

.reader-page pre {
  background: rgba(61, 85, 111, 0.08);
  padding: 1rem;
  border-radius: 12px;
  overflow-x: auto;
}

.chapter-source {
  display: none;
}

.site-footer {
  display: flex;
  justify-content: center;
  margin: 3rem 0 2rem;
}

.footer-link {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}

.footer-link:hover {
  color: var(--ink);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 26, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  z-index: 20;
}

.modal-overlay.is-open {
  display: flex;
}

.modal-card {
  background: var(--paper);
  border-radius: 20px;
  width: min(860px, 100%);
  max-height: 80vh;
  overflow: auto;
  padding: 2rem 2.2rem;
  position: relative;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.25);
}

.modal-close {
  position: sticky;
  top: 0;
  margin-left: auto;
  display: block;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(61, 85, 111, 0.18);
  border-radius: 999px;
  padding: 0.3rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.modal-content h2,
.modal-content h3 {
  font-family: "Literata", serif;
}

.modal-content {
  font-family: var(--reader-font);
  line-height: 1.7;
}

.modal-open {
  overflow: hidden;
}

@keyframes pageTurn {
  from {
    transform: rotateY(-6deg) translateY(4px);
    box-shadow: none;
  }
  to {
    transform: rotateY(0deg) translateY(0);
    box-shadow: none;
  }
}

@media (max-width: 720px) {
  .crumb-full {
    display: none;
  }

  .crumb-short {
    display: inline;
  }

  .crumb-last .crumb-full,
  .crumb-last {
    display: inline;
  }
  .story-grid {
    grid-template-columns: 1fr;
  }
  .hero,
  .story-hero,
  .chapter-hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .chapter-nav {
    flex-direction: column;
    align-items: flex-start;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .nav-menu {
    display: none;
    position: absolute;
    top: calc(100% + 0.6rem);
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.9rem;
    min-width: 190px;
    border-radius: 18px;
    background: var(--paper);
    border: 1px solid rgba(61, 85, 111, 0.18);
    box-shadow: 0 18px 32px rgba(31, 36, 40, 0.18);
    z-index: 10;
  }

  .nav-menu.is-open {
    display: flex;
  }

  .nav-menu .control-button,
  .nav-menu .back-link {
    width: 100%;
    justify-content: center;
  }


  .reader-page {
    padding: 1.4rem 1.2rem;
    border-radius: 18px;
  }
}

@media (max-width: 640px) {
  .nav-toast {
    right: 16px;
    left: 16px;
    bottom: 18px;
    max-width: unset;
    text-align: center;
  }
}
