:root {
  --paper: #e7e4da;
  --page: #fcfbf6;
  --ink: #171a1d;
  --quiet: #65696c;
  --hairline: #d3d0c6;
  --sidebar: #090c0f;
  --sidebar-panel: #11161b;
  --sidebar-ink: #eeece3;
  --sidebar-quiet: #899198;
  --electric: #bcecff;
  --electric-bright: #e5f8ff;
  --metal: #7e878d;
  --reading-progress: 0;
  color-scheme: light;
}

* { box-sizing: border-box; }

html {
  background: var(--paper);
  scroll-behavior: smooth;
  scroll-padding-top: 2rem;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  margin: 0;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
::selection { background: #cceeff; color: #070a0c; }

.skip-link {
  background: var(--electric-bright);
  color: #06090b;
  font: 700 .75rem/1 Arial, sans-serif;
  left: 1rem;
  padding: .8rem 1rem;
  position: fixed;
  text-transform: uppercase;
  top: -4rem;
  z-index: 100;
}

.skip-link:focus { top: 1rem; }

.reading-line {
  background: #252c32;
  height: 2px;
  left: 22rem;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 30;
}

.reading-line span {
  background: var(--electric);
  display: block;
  height: 100%;
  transform: scaleX(var(--reading-progress));
  transform-origin: left center;
  width: 100%;
}

.reader-sidebar {
  background: var(--sidebar);
  border-right: 1px solid #2a3035;
  color: var(--sidebar-ink);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr) auto;
  height: 100vh;
  left: 0;
  position: fixed;
  top: 0;
  width: 22rem;
  z-index: 40;
}

.sidebar-brand {
  align-items: flex-start;
  border-bottom: 1px solid #2a3035;
  display: flex;
  font-family: Arial, Helvetica, sans-serif;
  justify-content: space-between;
  padding: 1.25rem 1.45rem 1.2rem;
}

.sidebar-brand a { text-decoration: none; }
.sidebar-brand strong {
  display: block;
  font-family: "Big Caslon", Baskerville, Georgia, serif;
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: .055em;
  line-height: 1;
  text-transform: uppercase;
}

.sidebar-brand a span {
  color: var(--sidebar-quiet);
  display: block;
  font-size: .59rem;
  letter-spacing: .13em;
  margin-top: .55rem;
  text-transform: uppercase;
}

.reading-percent {
  color: var(--electric);
  font: 600 .67rem/1 Arial, sans-serif;
  letter-spacing: .09em;
  padding-top: .12rem;
}

.toc-panel, .minimap-panel { min-height: 0; padding: 1rem 1.1rem; }
.toc-panel { border-bottom: 1px solid #2a3035; display: flex; flex-direction: column; }
.panel-label {
  color: var(--sidebar-quiet);
  flex: none;
  font: 600 .59rem/1 Arial, sans-serif;
  letter-spacing: .2em;
  padding: .1rem .35rem .75rem;
  text-transform: uppercase;
}

.toc-scroll { min-height: 0; overflow-y: auto; scrollbar-color: #48515a transparent; scrollbar-width: thin; }
.toc-scroll ol { list-style: none; margin: 0; padding: 0 .15rem .35rem 0; }
.toc-scroll li + li { margin-top: .1rem; }
.toc-scroll a {
  align-items: center;
  border-left: 2px solid transparent;
  color: #bec3c5;
  display: grid;
  font-family: Arial, Helvetica, sans-serif;
  gap: .7rem;
  grid-template-columns: 1.65rem 1fr;
  padding: .49rem .62rem;
  text-decoration: none;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.toc-scroll a:hover { background: #171d22; color: #fff; }
.toc-scroll a[aria-current="location"] { background: #1a2228; border-left-color: var(--electric); color: #fff; }
.toc-number { color: #66717a; font-size: .59rem; letter-spacing: .09em; text-align: right; }
.toc-scroll a[aria-current="location"] .toc-number { color: var(--electric); }
.toc-copy, .toc-copy strong, .toc-copy small { display: block; }
.toc-copy strong { font-size: .68rem; font-weight: 600; letter-spacing: .055em; text-transform: uppercase; }
.toc-copy small { color: #78828a; font-size: .55rem; font-weight: 400; letter-spacing: .055em; margin-top: .2rem; }

.minimap-panel { display: flex; flex-direction: column; }
.minimap {
  background: #05080a;
  border: 1px solid #30383f;
  cursor: crosshair;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.minimap:focus-visible { outline: 2px solid var(--electric); outline-offset: 2px; }
.minimap-pages {
  bottom: 6px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  left: 8px;
  position: absolute;
  right: 8px;
  top: 6px;
}

.mini-chapter {
  align-content: space-around;
  background: #11171c;
  border-left: 2px solid transparent;
  display: grid;
  flex-grow: var(--chapter-weight);
  min-height: 6px;
  overflow: hidden;
  padding: 2px 6px 2px 25px;
  position: relative;
}

.mini-chapter b { color: #46515a; font: 600 5px/1 Arial, sans-serif; left: 6px; position: absolute; top: 4px; }
.mini-chapter i { background: #29333b; display: block; height: 1px; width: var(--line-width); }
.mini-chapter.is-active { background: #1b252c; border-left-color: var(--electric); }
.mini-chapter.is-active b { color: var(--electric); }
.mini-chapter.is-active i { background: #50606b; }
.minimap-viewport {
  background: rgba(188, 236, 255, .05);
  border: 1px solid rgba(188, 236, 255, .65);
  left: 2px;
  min-height: 10px;
  pointer-events: none;
  position: absolute;
  right: 2px;
  transition: top 70ms linear;
}

.sidebar-downloads {
  align-items: center;
  border-top: 1px solid #2a3035;
  color: #c7cbcd;
  display: flex;
  font: 600 .57rem/1 Arial, sans-serif;
  gap: .9rem;
  letter-spacing: .12em;
  padding: .95rem 1.4rem 1rem;
  text-transform: uppercase;
}

.sidebar-downloads a { text-decoration-color: #5c6871; text-underline-offset: .25em; }
.sidebar-downloads a:hover { color: var(--electric); }
.sidebar-downloads span { color: #68737c; margin-left: auto; }

.book-page { background: var(--page); margin-left: 22rem; min-height: 100vh; }
.title-page {
  align-content: center;
  align-items: center;
  background:
    radial-gradient(circle at 50% 54%, rgba(77, 91, 101, .22), transparent 37%),
    radial-gradient(circle at 50% 48%, #151b20 0, #0b0f12 64%, #06090b 100%);
  color: #f0ede4;
  display: grid;
  gap: clamp(2rem, 4vh, 3.5rem);
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto auto;
  min-height: 100vh;
  overflow: hidden;
  padding: clamp(3rem, 7vw, 7rem);
  position: relative;
}

.title-page::after {
  border: 1px solid rgba(202, 214, 220, .07);
  border-radius: 50%;
  content: "";
  height: min(88vw, 75rem);
  pointer-events: none;
  position: absolute;
  right: -23%;
  top: 14%;
  width: min(88vw, 75rem);
}

.title-copy { align-self: start; position: relative; z-index: 2; }
.title-kicker { color: #8d969c; font: 600 .63rem/1 Arial, sans-serif; letter-spacing: .34em; margin: 0 0 2rem; text-transform: uppercase; }
.title-page h1 {
  font-family: "Big Caslon", Baskerville, Georgia, serif;
  font-size: clamp(4.35rem, 7.7vw, 8.8rem);
  font-weight: 500;
  letter-spacing: -.025em;
  line-height: .84;
  margin: 0;
  text-transform: uppercase;
}

.title-page h1 span { display: block; white-space: nowrap; }
.crown-diagram { color: #d8d4c9; filter: drop-shadow(0 20px 50px rgba(0, 0, 0, .35)); grid-column: 1; grid-row: 2; justify-self: center; max-height: 32vh; overflow: visible; position: relative; width: min(100%, 68rem); z-index: 1; }
.crown-rings polygon { stroke: #758089; stroke-width: 3; }
.crown-rings polygon:nth-child(2n) { stroke: #9a968d; }
.crown-rings polygon:nth-child(3n) { stroke: #4d5961; }
.crown-rings polygon:nth-child(1) { opacity: .42; stroke-width: 7; }
.crown-rings polygon:nth-child(2) { opacity: .6; }
.crown-rings polygon:nth-child(3) { opacity: .42; }
.crown-rings polygon:nth-child(4) { opacity: .72; }
.crown-rings polygon:nth-child(5) { opacity: .55; }
.crown-rings polygon:nth-child(6) { opacity: .78; }
.crown-rings polygon:nth-child(7) { opacity: .9; }
.crown-nodes { opacity: .9; }
.electric-trace { stroke: var(--electric); stroke-linecap: square; stroke-linejoin: miter; stroke-width: 4; }
.trace-shadow { filter: blur(5px); opacity: .6; stroke-width: 10; }
.title-deck { align-self: start; grid-column: 1; grid-row: 3; max-width: 48rem; position: relative; z-index: 2; }
.title-deck > p { color: #b9bfc1; font-size: clamp(1.08rem, 1.55vw, 1.3rem); line-height: 1.64; margin: 0; }
.title-deck > p + p { margin-top: .9rem; }
.title-actions { align-items: center; display: flex; font: 600 .63rem/1 Arial, sans-serif; gap: 1.6rem; letter-spacing: .14em; margin-top: 2.25rem; text-transform: uppercase; }
.title-actions a { text-decoration-color: #6c7980; text-underline-offset: .33em; }
.title-actions a:hover { color: var(--electric); }
.title-actions .primary-action { border: 1px solid #7f8c93; padding: 1rem 1.2rem; text-decoration: none; }
.title-actions .primary-action:hover { background: var(--electric); border-color: var(--electric); color: #070a0c; }

.novella { margin: 0 auto; max-width: 82rem; padding: 0 clamp(3rem, 9vw, 11rem); }
.chapter { border-top: 1px solid var(--ink); padding: 8rem 0 9rem; scroll-margin-top: 1rem; }
.chapter:first-child { border-top: 0; }
.chapter-heading { font-family: Arial, Helvetica, sans-serif; margin: 0 auto 4.6rem; max-width: 62rem; text-align: center; }
.chapter-ordinal { color: var(--quiet); font-size: .63rem; letter-spacing: .24em; margin-bottom: 1.25rem; text-transform: uppercase; }
.chapter-heading h2 { font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; font-size: clamp(2.7rem, 5.7vw, 5.5rem); font-weight: 500; letter-spacing: -.05em; line-height: .94; margin: 0; text-transform: uppercase; }
.chapter-text { font-size: clamp(1.18rem, 1.47vw, 1.42rem); line-height: 1.76; margin: 0 auto; max-width: 46rem; }
.chapter-text p { margin: 0; text-indent: 1.5em; }
.chapter-text .first-paragraph { text-indent: 0; }
.chapter-text .first-paragraph::first-letter { float: left; font-size: 4.05em; font-weight: 500; line-height: .72; padding: .12em .1em 0 0; }
.chapter-text em { font-style: italic; }

.book-end {
  align-items: center;
  border-top: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  font: 600 .61rem/1.5 Arial, sans-serif;
  letter-spacing: .17em;
  margin: 0 auto;
  max-width: 60rem;
  padding: 8rem 2rem 10rem;
  text-align: center;
  text-transform: uppercase;
}

.end-signal { color: #637580; font-size: .54rem; letter-spacing: .23em; }
.book-end p { margin: 1.8rem 0 2.5rem; }
.book-end a { text-decoration-color: #969b9c; text-underline-offset: .32em; }
.book-end a:hover { color: #405d6c; }
.mobile-menu, .sidebar-scrim { display: none; }

@media (max-width: 1050px) {
  .reader-sidebar { width: 19rem; }
  .book-page { margin-left: 19rem; }
  .reading-line { left: 19rem; }
  .title-page { align-content: center; grid-template-columns: 1fr; padding: 5rem clamp(2.5rem, 8vw, 6rem); }
  .title-copy { align-self: auto; }
  .crown-diagram { grid-column: 1; grid-row: auto; height: 42vh; margin: -2rem auto; width: 100%; }
  .title-deck { align-self: auto; }
}

@media (max-width: 760px) {
  html { scroll-padding-top: 4.6rem; }
  body.menu-open { overflow: hidden; }
  .reading-line { left: 0; }
  .reader-sidebar { box-shadow: 14px 0 35px rgba(0, 0, 0, .32); transform: translateX(-105%); transition: transform 180ms ease; width: min(90vw, 22rem); }
  .reader-sidebar.is-open { transform: translateX(0); }
  .book-page { margin-left: 0; }
  .mobile-menu {
    align-items: center;
    background: #0b0f12;
    border: 1px solid #364047;
    color: #f2f0e8;
    display: flex;
    font: 600 .61rem/1 Arial, sans-serif;
    gap: .55rem;
    left: .8rem;
    letter-spacing: .12em;
    padding: .7rem .85rem;
    position: fixed;
    text-transform: uppercase;
    top: .8rem;
    z-index: 60;
  }
  .menu-symbol { color: var(--electric); font-size: .85rem; }
  .sidebar-scrim { background: rgba(0, 0, 0, .48); border: 0; bottom: 0; left: 0; position: fixed; right: 0; top: 0; z-index: 35; }
  .sidebar-scrim.is-open { display: block; }
  .title-page { display: flex; flex-direction: column; gap: 2rem; min-height: 100svh; padding: 6.2rem 1.35rem 4rem; }
  .title-copy { width: 100%; }
  .title-page h1 { font-size: clamp(3.55rem, 18.5vw, 6.5rem); }
  .title-page h1 span { white-space: normal; }
  .crown-diagram { flex: 1; height: auto; margin: -1.5rem -12%; min-height: 14rem; width: 124%; }
  .title-deck { max-width: none; }
  .title-deck > p { font-size: 1.02rem; }
  .title-actions { align-items: stretch; flex-wrap: wrap; }
  .novella { padding: 0 1.25rem; }
  .chapter { padding: 6rem 0 7rem; }
  .chapter-heading { margin-bottom: 3.5rem; }
  .chapter-heading h2 { font-size: clamp(2.35rem, 13vw, 4rem); }
  .chapter-text { font-size: 1.14rem; line-height: 1.72; }
  .book-end { margin: 0 1.25rem; padding: 6rem .5rem 8rem; }
  .end-signal { line-height: 2; }
}

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

@media print {
  .reader-sidebar, .mobile-menu, .reading-line, .sidebar-scrim, .title-actions { display: none !important; }
  .book-page { margin: 0; }
  .title-page { background: #fff; color: #000; min-height: auto; padding: 2in .5in; }
  .title-deck > p { color: #333; }
  .chapter { break-before: page; padding: .7in 0; }
}
