/* The Ark: the novel, and nothing else */
:root {
  --bg: #07090e; --bg-2: #0d1118; --text: #e9e3d6; --soft: #b9b2a3; --muted: #8a8475; --rule: rgba(233,227,214,.14);
  --accent: #e4a955; --shade: 7,9,14;
  --serif: "EB Garamond", Georgia, "Times New Roman", serif;
  --display: "Cormorant Garamond", "EB Garamond", Georgia, serif;
  --measure: 35rem;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4efe5; --bg-2: #ebe4d6; --text: #1f1c18; --soft: #4a453d; --muted: #7a7366; --rule: rgba(31,28,24,.15);
  --accent: #9c5a14; --shade: 244,239,229;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--serif); font-size: clamp(19px, .55vw + 15px, 22px); line-height: 1.62;
  font-kerning: normal; font-variant-ligatures: common-ligatures; text-rendering: optimizeLegibility; transition: background .4s ease, color .4s ease; }
img { display: block; max-width: 100%; }
a { color: inherit; }
::selection { background: color-mix(in srgb, var(--accent) 40%, transparent); }
.skip { position: absolute; left: -999px; top: 8px; z-index: 50; padding: 8px 14px; background: var(--text); color: var(--bg); border-radius: 4px; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- reading bar ---------- */
.bar { position: fixed; inset: 0 0 auto; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 52px; padding: 0 max(18px, env(safe-area-inset-left)) 0 max(18px, env(safe-area-inset-right));
  background: linear-gradient(rgba(var(--shade), .92), rgba(var(--shade), .7)); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule); transition: transform .35s ease; }
.bar.hide { transform: translateY(-100%); }
.bar-title { font-family: var(--display); font-size: 17px; letter-spacing: .32em; text-transform: uppercase; text-decoration: none; }
.bar-nav { display: flex; align-items: center; gap: 18px; font-size: 15px; letter-spacing: .06em; }
.bar-nav a { text-decoration: none; color: var(--soft); }
.bar-nav a:hover { color: var(--text); }
.theme { font: italic 500 16px/1 var(--serif); color: var(--soft); background: none; border: 1px solid var(--rule); border-radius: 999px; padding: 6px 11px; cursor: pointer; }
.theme:hover { color: var(--text); border-color: var(--soft); }
.progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); }

/* ---------- title page ---------- */
.cover { position: relative; min-height: 100svh; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; background: #000; color: #f1ebdf; }
.cover-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 57% 30%;
  animation: drift 26s ease-out both; filter: brightness(.8) saturate(1.05); }
@keyframes drift { from { transform: scale(1.08); } to { transform: scale(1); } }
.cover::before { content: ""; position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(180deg, rgba(7,9,14,.82) 0%, rgba(7,9,14,.45) 32%, rgba(7,9,14,0) 52%, rgba(7,9,14,0) 78%, rgba(7,9,14,.85) 100%); }
.cover::after { content: ""; position: absolute; inset: 0; z-index: 1; box-shadow: inset 0 0 180px rgba(0,0,0,.6); pointer-events: none; }
.cover-copy { position: relative; z-index: 2; width: min(100%, 980px); margin: 0 auto; padding: clamp(40px, 7vh, 90px) 24px 0; text-align: center;
  animation: rise 1.8s ease .3s both; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.series { margin: 0; font-size: 14px; letter-spacing: .34em; text-transform: uppercase; color: rgba(241,235,223,.75); }
.cover h1 { margin: .06em 0 .1em; font: 500 clamp(60px, min(13vw, 21vh), 190px)/.92 var(--display); letter-spacing: .14em; text-indent: .14em; text-transform: uppercase;
  text-shadow: 0 8px 60px rgba(0,0,0,.7); }
.blurb { margin: 14px auto 0; max-width: 30ch; font-style: italic; font-size: clamp(19px, 1.6vw, 24px); color: rgba(241,235,223,.88); }
.byline { margin: 4px 0 0; font-size: 15px; letter-spacing: .26em; text-transform: uppercase; color: rgba(241,235,223,.6); }
.cover-cta { position: relative; z-index: 2; display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin: 0; padding: 24px 24px calc(clamp(28px, 6vh, 64px) + env(safe-area-inset-bottom)); animation: rise 1.8s ease .9s both; }
.btn { display: inline-block; padding: 12px 26px; border: 1px solid #e4a955; border-radius: 999px; background: #e4a955; color: #0b0d12;
  font-size: 16px; letter-spacing: .14em; text-transform: uppercase; text-decoration: none; transition: background .25s, color .25s; }
.btn:hover { background: #f2c07a; }
.btn.ghost { background: rgba(7,9,14,.35); color: #f1ebdf; border-color: rgba(241,235,223,.45); }
.btn.ghost:hover { border-color: #f1ebdf; }

.contents { width: min(100% - 40px, 860px); margin: 0 auto; padding: clamp(64px, 10vw, 120px) 0 clamp(40px, 6vw, 80px); }
.contents h2 { margin: 0 0 36px; text-align: center; font: 400 15px/1 var(--serif); letter-spacing: .4em; text-indent: .4em; text-transform: uppercase; color: var(--muted); }
.toc { list-style: none; margin: 0; padding: 0; }
.toc-part { margin: 40px 0 6px; text-align: center; font-family: var(--display); font-style: italic; font-size: 22px; color: var(--soft); }
.toc-row { display: grid; grid-template-columns: minmax(150px, 280px) 1fr; gap: 26px; align-items: center; padding: 18px 0; border-top: 1px solid var(--rule); text-decoration: none; }
.toc li:last-of-type .toc-row, .toc-row:hover { border-color: var(--rule); }
.toc-row img { width: 100%; aspect-ratio: 2.39; object-fit: cover; border-radius: 2px; filter: brightness(.85); transition: filter .4s ease, transform .6s ease; }
.toc-row:hover img { filter: brightness(1.05); }
.toc-row small { display: block; font-size: 13px; letter-spacing: .28em; text-transform: uppercase; color: var(--accent); }
.toc-row b { display: block; margin: 2px 0 4px; font: 500 clamp(26px, 2.6vw, 34px)/1.1 var(--display); }
.toc-row i { display: block; font-size: 17px; line-height: 1.45; color: var(--muted); }
.toc-coming { padding: 26px 0 0; border-top: 1px solid var(--rule); text-align: center; font-style: italic; color: var(--muted); font-size: 17px; }

/* ---------- chapter ---------- */
.still { position: relative; margin: 0; background: var(--bg); aspect-ratio: 2.39; max-height: 82vh; width: 100%; overflow: hidden; }
.still img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 55%; animation: drift 22s ease-out both; }
.still::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(7,9,14,.45) 0%, transparent 22%, transparent 66%, rgba(var(--shade), 1) 97%); }
.ch-head { width: min(100% - 40px, var(--measure)); margin: clamp(-80px, -6vw, -28px) auto 0; position: relative; z-index: 2; text-align: center; }
.part { margin: 0 0 22px; font-family: var(--display); font-style: italic; font-size: 20px; color: var(--soft); }
.ch-label { margin: 0; font-size: 14px; letter-spacing: .36em; text-indent: .36em; text-transform: uppercase; color: var(--accent); }
.ch-head h1 { margin: 10px 0 0; font: 500 clamp(38px, 5vw, 64px)/1.05 var(--display); letter-spacing: .01em; }
.ch-head::after { content: ""; display: block; width: 46px; height: 1px; margin: 34px auto 0; background: var(--accent); opacity: .7; }

.text { width: min(100% - 40px, var(--measure)); margin: 44px auto 0; hyphens: auto; -webkit-hyphens: auto; }
.text p { margin: 0; text-indent: 1.5em; text-align: justify; text-justify: inter-word; orphans: 2; widows: 2; }
.text p.open { text-indent: 0; }
.text > p.open:first-child { display: flow-root; text-wrap: pretty; }
.text > p.open:first-child::first-letter { float: left; margin: .1em .12em 0 0; font: 500 3.35em/.8 var(--display); color: var(--accent); }
.text > p.open:first-child::first-line { font-variant: small-caps; letter-spacing: .05em; }
.text strong { font-weight: 500; letter-spacing: .06em; font-size: .86em; }
.brk { border: 0; height: auto; margin: 1.6em 0; text-align: center; overflow: visible; }
.brk::after { content: "\2042"; font-size: 1.15em; color: var(--muted); }

/* ---------- next chapter ---------- */
.next { position: relative; display: block; margin: clamp(70px, 10vw, 130px) 0 0; aspect-ratio: 2.39; max-height: 70vh; width: 100%; overflow: hidden; background: var(--bg); color: #f1ebdf; text-decoration: none; }
.next img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: brightness(.55) saturate(.9); transition: filter .6s ease, transform 1.2s ease; }
.next:hover img { filter: brightness(.75); transform: scale(1.03); }
.next::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(var(--shade),1) 3%, transparent 30%, transparent 70%, rgba(7,9,14,.6) 100%); }
.next-copy { position: absolute; z-index: 2; inset: auto 0 clamp(24px, 6%, 64px); display: grid; justify-items: center; gap: 4px; padding: 0 24px; text-align: center; }
.next-copy small { font-size: 13px; letter-spacing: .36em; text-transform: uppercase; color: #e4a955; }
.next-copy b { font-weight: 400; font-size: 15px; letter-spacing: .3em; text-transform: uppercase; color: rgba(241,235,223,.75); }
.next-copy i { font: italic 500 clamp(28px, 4vw, 52px)/1.1 var(--display); text-shadow: 0 4px 30px rgba(0,0,0,.8); }
.coming .next-copy i { max-width: 32ch; font-size: clamp(20px, 2.2vw, 28px); }
.coming .next-copy a { margin-top: 10px; font-size: 15px; letter-spacing: .14em; text-transform: uppercase; color: rgba(241,235,223,.8); }

.pager { display: flex; justify-content: space-between; gap: 20px; width: min(100% - 40px, var(--measure)); margin: 34px auto 0; font-size: 16px; letter-spacing: .08em; }
.pager a { color: var(--muted); text-decoration: none; }
.pager a:hover { color: var(--text); }

.foot { padding: 60px 20px calc(40px + env(safe-area-inset-bottom)); text-align: center; font-size: 14px; letter-spacing: .08em; color: var(--muted); }
.foot p { margin: 0; }

@media (max-width: 700px) {
  .still { aspect-ratio: 4 / 3; }
  .next { aspect-ratio: 4 / 3; }
  .text p { text-align: left; }
  .toc-row { grid-template-columns: 1fr; gap: 12px; }
  .bar-title { letter-spacing: .24em; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .cover-img, .still img, .cover-copy, .cover-cta { animation: none; }
  .bar { transition: none; }
}
@media print {
  .bar, .next, .pager, .still, .foot { display: none; }
  body { background: #fff; color: #000; }
}
