:root {
  --ink: #261812;
  --muted: #765842;
  --paper: #fff7df;
  --paper-strong: #fff0bf;
  --sand: #f3c778;
  --date: #9a4c2b;
  --blue: #263f67;
  --line: rgba(91, 52, 28, .18);
  --shadow: 0 28px 70px rgba(68, 38, 18, .18);
  --radius-lg: 34px;
  --radius-md: 22px;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  color: var(--ink);
  background: var(--paper);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 238, 173, .95), transparent 30rem),
    radial-gradient(circle at 78% 4%, rgba(255, 177, 94, .26), transparent 28rem),
    linear-gradient(180deg, #fff9e9 0%, #f4d596 48%, #e5a967 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .13;
  background-image:
    linear-gradient(90deg, #5e351d 1px, transparent 1px),
    linear-gradient(#5e351d 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: linear-gradient(180deg, #000, transparent 78%);
}

a {
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

.shell {
  width: min(1180px, calc(100% - 36px));
  margin-inline: auto;
}

.brand-nav,
.reader-nav,
.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand-nav {
  padding: 26px 0 18px;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .02em;
}

.brand-logo {
  width: 78px;
  height: 54px;
  object-fit: contain;
  filter: drop-shadow(0 8px 14px rgba(68, 38, 18, .16));
}

.nav-pill,
.story-kicker span,
.reader-tags span,
.cover-badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 248, 221, .78);
  color: #5f402d;
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.nav-pill {
  padding: 9px 13px;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 32px;
  align-items: stretch;
  padding: 38px 0 54px;
}

.hero-copy,
.hero-card,
.section-heading,
.reader-title-block,
.reader-aside,
.story-text {
  position: relative;
  border: 1px solid var(--line);
  background: rgba(255, 248, 224, .76);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.hero-copy {
  overflow: hidden;
  border-radius: var(--radius-lg);
  padding: clamp(34px, 6vw, 72px);
}

.hero-copy::after {
  content: "";
  position: absolute;
  width: 340px;
  height: 340px;
  right: -80px;
  bottom: -118px;
  border-radius: 50%;
  background: rgba(184, 93, 43, .13);
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--date);
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .18em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 36px;
  max-width: 760px;
  font-size: clamp(54px, 10vw, 128px);
  line-height: .86;
  letter-spacing: -.06em;
}

.hero-lede {
  max-width: 690px;
  margin-bottom: 0;
  color: #563722;
  font-size: clamp(20px, 3vw, 30px);
  line-height: 1.24;
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.hero-stats span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, .35);
  color: #5b3c27;
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  font-size: 13px;
}

.hero-stats strong {
  color: var(--ink);
}

.hero-card {
  display: grid;
  align-content: end;
  min-height: 440px;
  overflow: hidden;
  border-radius: var(--radius-lg);
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(38, 63, 103, .08), transparent),
    rgba(255, 246, 217, .78);
}

.hero-mascot {
  position: absolute;
  width: 390px;
  max-width: none;
  top: -82px;
  right: -118px;
}

.hero-card p {
  position: relative;
  max-width: 210px;
  margin: 0;
  color: #4b301f;
  font-size: 22px;
  line-height: 1.16;
}

.catalog-main {
  padding: 18px 0 42px;
}

.section-heading {
  margin-bottom: 24px;
  border-radius: var(--radius-md);
  padding: 28px;
}

.section-heading h2 {
  margin-bottom: 10px;
  font-size: clamp(34px, 5vw, 62px);
  letter-spacing: -.04em;
}

.section-heading p:last-child {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.45;
}

.catalog-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 0 0 22px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px;
  background: rgba(255, 248, 224, .72);
  box-shadow: 0 14px 34px rgba(68, 38, 18, .1);
}

.library-toolbar {
  margin-top: 0;
}

.toolbar-label {
  padding: 0 14px 0 16px;
  color: var(--date);
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.filter-button {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 11px 16px;
  color: #593721;
  background: transparent;
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: pointer;
}

.filter-button:hover,
.filter-button.is-active {
  border-color: rgba(91, 52, 28, .22);
  color: #fff8df;
  background: #9a4c2b;
}

.toolbar-count {
  margin-left: auto;
  padding: 0 10px;
  color: #6c4c37;
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  font-size: 13px;
  font-weight: 800;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.catalog-loading,
.empty-state {
  grid-column: 1 / -1;
  margin: 0;
  border: 1px dashed rgba(91, 52, 28, .26);
  border-radius: var(--radius-md);
  padding: 28px;
  color: #6c4c37;
  background: rgba(255, 248, 224, .66);
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  font-weight: 700;
}

.empty-state {
  margin-top: 16px;
}

.story-card {
  --accent: var(--date);
  overflow: hidden;
  border: 1px solid rgba(91, 52, 28, .2);
  border-radius: 28px;
  background: rgba(255, 246, 218, .78);
  box-shadow: 0 16px 36px rgba(68, 38, 18, .14);
  transition: transform .22s ease, box-shadow .22s ease;
}

.story-card:hover {
  transform: translateY(-5px) rotate(-.4deg);
  box-shadow: 0 24px 58px rgba(68, 38, 18, .2);
}

.cover-link {
  position: relative;
  display: block;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background: var(--paper-strong);
}

.story-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.015);
  transition: transform .45s ease;
}

.story-card:hover .story-cover {
  transform: scale(1.055);
}

.cover-badge {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  padding: 8px 10px;
  text-align: center;
  color: #fff8df;
  background: color-mix(in srgb, var(--accent) 78%, #2a160e);
  border-color: rgba(255, 248, 223, .4);
}

.story-card-body {
  padding: 16px 16px 18px;
}

.story-kicker,
.reader-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 12px;
}

.story-kicker span,
.reader-tags span {
  padding: 6px 8px;
}

.story-card h3 {
  margin-bottom: 10px;
  font-size: 24px;
  line-height: 1.02;
  letter-spacing: -.03em;
}

.story-card h3 a {
  text-decoration: none;
}

.story-meta,
.story-characters {
  margin-bottom: 8px;
  color: var(--muted);
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  font-size: 14px;
  line-height: 1.35;
}

.reader-hero {
  background:
    radial-gradient(circle at 78% 10%, rgba(255,255,255,.35), transparent 22rem),
    linear-gradient(135deg, rgba(255, 248, 224, .92), color-mix(in srgb, var(--accent) 28%, #f4d596));
  border-bottom: 1px solid var(--line);
}

.reader-nav {
  padding: 20px 0;
  color: #523520;
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.back-link {
  text-decoration: none;
}

.reader-hero-inner {
  display: grid;
  grid-template-columns: minmax(320px, 360px) minmax(0, 1fr);
  gap: 30px;
  align-items: stretch;
  padding: 28px 0 48px;
}

.reader-cover {
  width: 100%;
  height: 100%;
  min-height: clamp(500px, 46vw, 620px);
  border: 10px solid rgba(255, 248, 224, .72);
  border-radius: 30px;
  object-fit: cover;
  box-shadow: var(--shadow);
}

@media (max-width: 860px) {
  .reader-hero-inner {
    grid-template-columns: 1fr;
  }

  .reader-cover {
    height: auto;
    min-height: 0;
    aspect-ratio: 2 / 3;
  }
}

.reader-title-block {
  border-radius: var(--radius-lg);
  padding: clamp(28px, 5vw, 58px);
}

.reader-title-block h1 {
  margin-bottom: 42px;
  font-size: clamp(44px, 8vw, 102px);
}

.reader-lede {
  max-width: 760px;
  margin-bottom: 26px;
  color: #573823;
  font-size: 22px;
  line-height: 1.4;
}

.reader-warning {
  margin: 14px 0 0;
  border-left: 5px solid var(--accent);
  padding: 10px 0 10px 14px;
  color: #55321e;
  background: rgba(255, 244, 205, .7);
}

.reader-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 760px);
  gap: 30px;
  align-items: start;
  padding: 46px 0;
}

.reader-mode-bar {
  position: sticky;
  top: 0;
  z-index: 4;
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px;
  background: rgba(255, 248, 224, .9);
  box-shadow: 0 14px 34px rgba(68, 38, 18, .12);
  backdrop-filter: blur(12px);
}

.reader-layout [hidden] {
  display: none !important;
}

.reader-mode-switch,
.reader-book-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.reader-mode-button,
.reader-page-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: #593721;
  background: transparent;
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
  cursor: pointer;
}

.reader-mode-button {
  gap: 8px;
  padding: 0 16px;
}

.reader-mode-button svg,
.reader-page-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.reader-mode-button:hover,
.reader-mode-button.is-active,
.reader-page-button:hover:not(:disabled) {
  border-color: rgba(91, 52, 28, .22);
  color: #fff8df;
  background: #9a4c2b;
}

.reader-page-button:disabled {
  cursor: default;
  opacity: .35;
}

.reader-page-count {
  min-width: 72px;
  color: #5b3c27;
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  font-size: 14px;
  font-weight: 900;
  text-align: center;
}

.reader-aside {
  position: sticky;
  top: 22px;
  border-radius: var(--radius-md);
  padding: 22px;
  color: #543724;
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

.reader-aside section + section {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.reader-aside h2 {
  margin-bottom: 10px;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 22px;
}

.reader-aside ul {
  margin: 0;
  padding-left: 20px;
}

.sibling-links {
  display: grid;
  gap: 8px;
}

.reader-reading-surface {
  min-width: 0;
}

.story-text {
  border-radius: var(--radius-lg);
  padding: clamp(26px, 5vw, 62px);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, .28), transparent 18%),
    rgba(255, 251, 235, .88);
}

.story-text h2,
.story-text h3 {
  margin: 1.3em 0 .55em;
  letter-spacing: -.03em;
}

.story-text h2 {
  font-size: 38px;
}

.story-text p,
.story-text li {
  color: #2f2018;
  font-size: clamp(20px, 2.2vw, 25px);
  line-height: 1.72;
}

.story-text p {
  margin-bottom: 1.2em;
}

.story-text p:first-child::first-letter {
  float: left;
  padding: .08em .12em 0 0;
  color: var(--date);
  font-size: 4.2em;
  line-height: .78;
}

.story-book-reader {
  border: 1px solid rgba(91, 52, 28, .2);
  border-radius: 28px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, .38), transparent 18%),
    rgba(255, 251, 235, .94);
  box-shadow: var(--shadow);
}

.book-pages {
  display: flex;
  width: 100%;
  height: clamp(500px, calc(100vh - 210px), 760px);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
}

.book-pages:focus {
  outline: 3px solid rgba(154, 76, 43, .34);
  outline-offset: -6px;
}

.book-page {
  position: relative;
  flex: 0 0 100%;
  box-sizing: border-box;
  overflow: hidden;
  scroll-snap-align: start;
  padding: clamp(30px, 5vw, 78px);
}

.book-page::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 92px;
  height: 92px;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at top right, rgba(255, 255, 255, .92), rgba(255, 255, 255, .38) 58%, transparent 76%);
  filter: drop-shadow(-4px 7px 8px rgba(68, 38, 18, .18));
  transform: translate(62%, -62%) rotate(6deg) scale(.6);
}

.book-page-turn::after {
  animation: bookCornerTurn .36s ease-out forwards;
}

@keyframes bookCornerTurn {
  0% {
    opacity: 0;
    transform: translate(62%, -62%) rotate(0deg) scale(.5);
  }
  45% {
    opacity: .9;
    transform: translate(18%, -18%) rotate(14deg) scale(1.05);
  }
  100% {
    opacity: 0;
    transform: translate(62%, -62%) rotate(16deg) scale(1.12);
  }
}

.book-page h2,
.book-page h3 {
  margin: 1.2em 0 .55em;
  letter-spacing: 0;
}

.book-page h2 {
  font-size: clamp(34px, 4.5vw, 54px);
}

.book-page p,
.book-page li {
  color: #2f2018;
  font-size: clamp(22px, 2.2vw, 28px);
  line-height: 1.72;
}

.book-page p {
  margin: 0 0 1.15em;
}

.reader-pagination-stage {
  position: absolute;
  top: 0;
  left: -99999px;
  box-sizing: border-box;
  visibility: hidden;
  overflow: hidden;
  pointer-events: none;
  padding: clamp(30px, 5vw, 78px);
  color: #2f2018;
}

.reader-pagination-stage h2,
.reader-pagination-stage h3 {
  margin: 1.2em 0 .55em;
  letter-spacing: 0;
}

.reader-pagination-stage h2 {
  font-size: clamp(34px, 4.5vw, 54px);
}

.reader-pagination-stage p,
.reader-pagination-stage li {
  color: #2f2018;
  font-size: clamp(22px, 2.2vw, 28px);
  line-height: 1.72;
}

.reader-pagination-stage p {
  margin: 0 0 1.15em;
}

.book-progress-track {
  height: 9px;
  background: rgba(91, 52, 28, .12);
}

.book-progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: #9a4c2b;
  transition: width .2s ease;
}

.reader-layout.is-book-mode {
  grid-template-columns: minmax(0, 1fr);
}

.reader-layout.is-book-mode .reader-aside {
  display: none;
}

.site-footer {
  padding: 26px 0 42px;
  color: #6c4c37;
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  font-size: 13px;
}

@media (max-width: 1040px) {
  .catalog-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .hero-grid,
  .reader-hero-inner,
  .reader-layout {
    grid-template-columns: 1fr;
  }

  .hero-card {
    min-height: 300px;
  }

  .hero-mascot {
    width: 320px;
    top: -68px;
    right: -96px;
  }

  .reader-cover {
    width: min(260px, 74vw);
  }

  .reader-aside {
    position: static;
  }

  .reader-mode-bar {
    align-items: stretch;
    border-radius: 24px;
    flex-direction: column;
  }

  .reader-mode-switch,
  .reader-book-status {
    width: 100%;
  }

  .reader-mode-button {
    flex: 1 1 0;
  }

  .reader-book-status {
    justify-content: space-between;
  }

  .catalog-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 540px) {
  .shell {
    width: min(100% - 24px, 1180px);
  }

  .brand-nav,
  .reader-nav,
  .site-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .catalog-grid {
    grid-template-columns: 1fr;
  }

  .catalog-toolbar {
    align-items: stretch;
    border-radius: 24px;
    flex-direction: column;
  }

  .filter-button {
    width: 100%;
  }

  .toolbar-count {
    margin-left: 0;
    padding: 6px 10px 2px;
  }

  .hero-copy,
  .reader-title-block,
  .story-text {
    padding: 24px;
  }

  .story-card h3 {
    font-size: 28px;
  }

  .book-pages {
    height: min(72svh, 640px);
    min-height: 430px;
  }

  .book-page {
    padding: 28px 24px 34px;
  }
}
