:root {
  --ink: #f6f0e8;
  --ink-soft: rgba(246, 240, 232, 0.62);
  --ink-faint: rgba(246, 240, 232, 0.3);
  --halo: rgba(10, 12, 34, 0.5);
  --fs: clamp(16.5px, calc(0.8rem + 0.52vw), 23px);
  --text-top: 64px;
  --text-h: 60vh;
  --hY: 70vh;
  --F: 120px;
}
html.day {
  --ink: #1c2338;
  --ink-soft: rgba(28, 35, 56, 0.66);
  --ink-faint: rgba(28, 35, 56, 0.32);
  --halo: rgba(252, 247, 238, 0.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: #151b38;
  color: var(--ink);
  font-family: 'Newsreader', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: color 1.6s ease;
}
button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible { outline: 1px solid var(--ink-soft); outline-offset: 6px; }
.sr {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ------------------------------------------------ the journey */
html.js, html.js body { height: 100%; overflow: hidden; overscroll-behavior: none; }
html.js body { touch-action: none; -webkit-user-select: none; user-select: none; }

#sky { position: fixed; left: 0; top: 0; display: block; }
#grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.06;
  mix-blend-mode: overlay;
  background-size: 160px 160px;
}

html.js #essay {
  position: fixed;
  left: 0; right: 0;
  top: var(--text-top);
  height: var(--text-h);
  pointer-events: none;
}
html.js .b {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 0 clamp(20px, 5vw, 48px);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  filter: blur(6px);
  transition: opacity 0.9s ease, transform 1.4s cubic-bezier(0.2, 0.7, 0.2, 1), filter 1.1s ease, visibility 0s linear 1.4s;
}
html.js .b.on {
  opacity: 1;
  visibility: visible;
  transform: none;
  filter: none;
  pointer-events: auto;
  transition: opacity 1.5s ease 0.35s, transform 1.8s cubic-bezier(0.2, 0.7, 0.2, 1) 0.35s, filter 1.4s ease 0.35s, visibility 0s;
}

.b p {
  width: 100%;
  max-width: 32em;
  margin: 0 0 0.8em;
  font-size: calc(var(--fs) * var(--fit, 1));
  line-height: 1.6;
  font-weight: 340;
  text-align: center;
  text-wrap: pretty;
  text-shadow: 0 0 18px var(--halo), 0 0 2px var(--halo);
}
.b p:last-child { margin-bottom: 0; }
.b-big p {
  max-width: 21em;
  font-size: calc(var(--fs) * 1.42 * var(--fit, 1));
  line-height: 1.38;
  font-weight: 320;
  text-align: center;
  text-wrap: balance;
}
.b-prompt p {
  max-width: 24em;
  font-size: calc(var(--fs) * 1.28 * var(--fit, 1));
  line-height: 1.45;
  font-weight: 300;
  font-style: italic;
  text-align: center;
  text-wrap: balance;
}
.b-title .num {
  font-size: 0.78rem;
  letter-spacing: 0.42em;
  padding-left: 0.42em;
  color: var(--ink-soft);
}
.b-title h2 {
  margin: 0.45em 0 0;
  font-size: clamp(2.1rem, calc(2.6vw + 1.3rem), 3.8rem);
  line-height: 1.1;
  font-weight: 260;
  font-style: italic;
  text-align: center;
  text-shadow: 0 0 26px var(--halo);
}

/* a word before the journey; nothing is drawn above the horizon yet, so it may come lower */
html.js .b-prelude { bottom: calc(var(--F) * -1.1); }
.b-prelude p {
  max-width: 26em;
  margin-bottom: 0.55em;
  font-size: calc(var(--fs) * 0.98 * var(--fit, 1));
  color: var(--ink-soft);
  text-wrap: balance;
}
.b-prelude p.lead {
  margin-bottom: 0.9em;
  font-size: calc(var(--fs) * 1.5 * var(--fit, 1));
  font-weight: 300;
  font-style: italic;
  line-height: 1.3;
  color: var(--ink);
}
.b-prelude p.go { margin: 1.4em 0 0; font-size: 1.05rem; color: var(--ink); }
.b-prelude .go button {
  padding: 0.15em 0;
  border-bottom: 1px solid var(--ink-faint);
  transition: border-color 0.4s ease;
}
.b-prelude .go button:hover { border-color: currentColor; }

.b-end { text-align: center; }
.b-end h2 {
  margin: 0;
  font-size: clamp(2rem, calc(2.4vw + 1.2rem), 3.4rem);
  line-height: 1.1;
  font-weight: 260;
  text-shadow: 0 0 26px var(--halo);
}
.b-end .by {
  margin: 0.7em 0 2.4em;
  font-size: 0.78rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.b-end .end-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.8em 2.4em;
  max-width: 30em;
  font-size: 1.05rem;
}

.end-actions button,
.intro-actions button,
.sheet-link,
.sheet-close {
  padding: 0.15em 0;
  border-bottom: 1px solid var(--ink-faint);
  transition: border-color 0.4s ease, color 0.4s ease;
}
.end-actions button:hover,
.intro-actions button:hover,
.sheet-link:hover,
.sheet-close:hover { border-color: currentColor; }

/* the title */
#intro {
  position: fixed;
  left: 0; right: 0; top: 0;
  height: var(--hY);
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 24px calc(var(--F) * 0.9);
  text-align: center;
  transition: opacity 1.8s ease, filter 1.8s ease;
}
#intro.gone { opacity: 0; filter: blur(8px); pointer-events: none; }
html:not(.intro) #intro { pointer-events: none; }
#intro h1 {
  margin: 0;
  font-size: clamp(2.6rem, calc(5vw + 1rem), 5.6rem);
  line-height: 1.04;
  font-weight: 240;
  letter-spacing: -0.012em;
  text-wrap: balance;
  text-shadow: 0 0 34px var(--halo);
}
/* "v2", set small beside the title without moving it off centre */
#intro h1, .b-end h2 { position: relative; }
#intro h1 .v, .b-end h2 .v {
  position: absolute;
  left: 100%;
  top: 0.5em;
  margin-left: 0.45em;
  font-size: max(0.75rem, 0.2em);
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  text-shadow: none;
}
@media (max-width: 420px) {
  #intro h1 .v, .b-end h2 .v { left: auto; right: 0; top: -1.2em; margin-left: 0; }
}
#intro .by {
  margin: 1.1em 0 2.8em;
  font-size: 0.8rem;
  letter-spacing: 0.34em;
  padding-left: 0.34em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.intro-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.8em 2.4em;
  font-size: 1.1rem;
}
#intro .hint {
  margin: 2.6em 0 0;
  font-size: 0.88rem;
  font-style: italic;
  color: var(--ink-faint);
}
.hint-touch { display: none; }
@media (hover: none) and (pointer: coarse) {
  .hint-keys { display: none; }
  .hint-touch { display: inline; }
}

/* corners */
.ui {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  z-index: 5;
  padding: 8px 4px;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
  transition: color 0.4s ease, opacity 1.2s ease;
}
.ui:hover { color: var(--ink); }
#chapter {
  left: clamp(12px, 3vw, 28px);
  max-width: calc(100vw - 150px);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: left;
}
#chapter .n { margin-right: 1.3em; }
#sound { right: clamp(12px, 3vw, 28px); }
html.intro #chapter { opacity: 0; pointer-events: none; }

#hint {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  width: 40px;
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.8s ease;
}
#hint.show { opacity: 0.5; }
#hint svg { display: block; width: 100%; }
#hint path { fill: none; stroke: var(--ink); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }

#progress { position: fixed; left: 0; right: 0; bottom: 0; height: 2px; pointer-events: none; }
#progress span {
  display: block;
  height: 100%;
  background: var(--ink-faint);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 1.2s ease;
}

/* sheets: chapters and sources */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: rgba(9, 11, 28, 0.8);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  color: #f3ede4;
  opacity: 0;
  visibility: hidden;
  touch-action: pan-y;
  -webkit-user-select: text;
  user-select: text;
  transition: opacity 0.7s ease, visibility 0s linear 0.7s;
}
.sheet.open { opacity: 1; visibility: visible; transition: opacity 0.7s ease, visibility 0s; }
.sheet-inner { width: 100%; max-width: 38em; padding: 11vh 26px 9vh; text-align: center; }
.sheet-title, .sheet h2 {
  margin: 0 0 1.4em;
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: rgba(243, 237, 228, 0.6);
}
#index ol { list-style: none; margin: 0 0 2.6em; padding: 0; }
#index li button {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 0.9em;
  width: 100%;
  padding: 0.42em 0;
  font-size: clamp(1.15rem, calc(0.9rem + 0.8vw), 1.5rem);
  font-weight: 300;
  text-align: center;
  color: rgba(243, 237, 228, 0.86);
  transition: color 0.3s ease;
}
#index li button:hover { color: #fff; }
#index li button[aria-current] { font-style: italic; color: #fff; }
#index li .n { font-size: 0.72rem; letter-spacing: 0.3em; color: rgba(243, 237, 228, 0.5); }
.sheet-link { margin: 0 1.2em; }
.sheet-close { margin: 0 1.2em; }
.sheet-link, .sheet-close { font-size: 1rem; --ink-faint: rgba(243, 237, 228, 0.32); }
.sources-text p { margin: 0 0 1.1em; font-size: 1.02rem; line-height: 1.72; font-weight: 340; color: rgba(243, 237, 228, 0.86); }
.sources-text a { color: inherit; text-underline-offset: 3px; }
#sources .sheet-close { margin-top: 1.6em; }

@media (prefers-reduced-motion: reduce) {
  html.js .b, html.js .b.on { filter: none; transform: none; transition-duration: 0.6s; transition-delay: 0s; }
}

/* ------------------------------------------------ without JavaScript: a plain page to read */
html:not(.js) body { background: #10152f; }
html:not(.js) #sky, html:not(.js) #grain, html:not(.js) .ui, html:not(.js) .intro-actions,
html:not(.js) #intro .hint, html:not(.js) #hint, html:not(.js) #progress, html:not(.js) #index,
html:not(.js) .end-actions, html:not(.js) .sheet-close { display: none; }
html:not(.js) #intro { padding: 14vh 22px 6vh; text-align: center; }
html:not(.js) #intro h1 { margin: 0; font-size: 3.2rem; font-weight: 260; }
html:not(.js) .b { max-width: 36em; margin: 1.2em auto; padding: 0 22px; }
html:not(.js) .b p { font-size: 1.15rem; line-height: 1.7; text-shadow: none; text-align: center; }
html:not(.js) .b-title { margin-top: 4em; text-align: center; }
html:not(.js) .b-end { margin: 5em auto 3em; }
html:not(.js) .sheet { position: static; background: none; opacity: 1; visibility: visible; display: block; }
