@font-face { font-family: "VW Cinzel"; src: url(/fonts/Cinzel-Regular.ttf) format("truetype"); font-display: swap }
@font-face { font-family: "VW Alegreya"; src: url(/fonts/Alegreya-Regular.ttf) format("truetype"); font-display: swap }
@font-face { font-family: "VW Mathilde"; src: url(/fonts/Mathilde-Regular.otf) format("opentype"); font-display: swap }

:root {
  color-scheme: dark;
  /* the dye families, by name, as the Bible holds them */
  --night: #0a0b1b;
  --woad-900: #121920;
  --indigo-800: #21243e;
  --ink: #1a1a2e;
  --linen: #f4e9d8;
  --linen-deep: #e9c79a;
  --linen-700: #605340;
  --bone: #f8f3e9;
  --gold: #d4a574;
  --moon: #ffdb47;
  --violet: #8a6aa3;
  --logwood-200: #e2d4f3;
  --mist: #b4a9c9;
  /* the lamp, in page units, just outside the top left corner */
  --lamp-x: -110;
  --lamp-y: -110;
}

* { box-sizing: border-box }

html {
  background: var(--night);   /* so an overscroll bounce shows night, not white */
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--night);
  color: var(--logwood-200);
  font-family: "VW Alegreya", Georgia, "Times New Roman", serif;
  font-size: 17px;
  line-height: 1.62;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

/* ---------------------------------------------------------------- the sky */

.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
/* three layers, each pinned to the edge it belongs to */
.sky { background: var(--night) }
.sky .layer { position: absolute; left: 0; right: 0; width: 100%; display: block }
.sky .mid { top: 0; height: 100% }
.sky .top { top: 0; height: clamp(128px, max(16vh, 9vw), 300px) }
.sky .bottom { bottom: 0; height: clamp(150px, max(20vh, 11vw), 320px) }

/* a phone sees the app's own 440-wide board; a wider screen gets the horizon carried
   off both sides, which would crowd the phone */
.wide { display: none }
@media (min-width: 760px) { .wide { display: inline } }

/* the same tooth over the whole night: the sky is cut paper too, not a gradient,
   so the clouds, the moon and the flame are grained like the sheets are */
.sky::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background-image: url(/img/paper.png);
  background-size: 150px 150px;
  mix-blend-mode: hard-light;
  opacity: .62;
  pointer-events: none;
}

.cloudband { will-change: transform }
.star { transform-box: fill-box; transform-origin: center }
#flame { will-change: transform }

/* the embers, rising behind everything. One canvas, under the words and over the
   sky, so the warm drift carries the whole page and not just the hero. */
#embers {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ----------------------------------------------------- the top of the page */

#rail {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  z-index: 6;
  background: linear-gradient(to right, var(--violet), var(--moon));
  transform: scaleX(0);
  transform-origin: left;
  pointer-events: none;
}

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: calc(12px + env(safe-area-inset-top, 0px))
           max(16px, env(safe-area-inset-right, 0px)) 12px
           max(16px, env(safe-area-inset-left, 0px));
  background: rgba(10, 11, 27, .72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(138, 106, 163, .22);
  opacity: 0;
  transform: translateY(-100%);
  transition: opacity .35s ease, transform .35s ease;
  pointer-events: none;
}
.topbar.stuck { opacity: 1; transform: none; pointer-events: auto }
.topbar a {
  font-family: "VW Cinzel", Georgia, serif;
  font-size: 11px;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--mist);
  text-decoration: none;
  white-space: nowrap;
}
.topbar a:hover, .topbar a:focus-visible { color: var(--bone) }
.topbar .mark { color: var(--bone); letter-spacing: .2em }
.topbar nav { display: flex; gap: clamp(13px, 4vw, 30px) }
/* the long link is a luxury the narrowest screens do not have */
@media (max-width: 460px) { .topbar .only-wide { display: none } }
@media (max-width: 400px) {
  .topbar a { font-size: 10px; letter-spacing: .16em }
  .topbar .mark { letter-spacing: .1em }
}

/* ------------------------------------------------------------- the pages */

.scroll { position: relative; z-index: 1 }

.gutter {
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

.first {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  text-align: center;
  padding-block: 20vh 26vh;
}

.eyebrow {
  font-family: "VW Cinzel", Georgia, serif;
  font-size: 12px;
  letter-spacing: .34em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 18px;
}

/* the real mark, lifted out of the app's Login art board */
.wordmark {
  margin: 0;
  line-height: 0;
  display: block;
}
.wordmark svg {
  display: block;
  width: min(80vw, 430px);
  height: auto;
  overflow: visible;
  filter: drop-shadow(0 0 44px rgba(138, 106, 163, .45));
}
.offscreen {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.standfirst {
  max-width: min(26ch, 100%);
  margin: 20px 0 0;
  font-size: clamp(17px, 4.6vw, 21px);
  color: var(--mist);
}

.hint {
  margin-top: 46px;
  font-family: "VW Cinzel", Georgia, serif;
  font-size: 10px;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: #6f6690;
}
.hint span { display: block; margin: 10px auto 0; width: 1px; height: 38px;
  background: linear-gradient(to bottom, #6f6690, transparent) }

/* ------------------------------------------- a chapter head, on the night itself */

/* the bar is fixed, so a jump to a chapter has to clear it */
#believe, #hello { scroll-margin-top: 76px }

.chapter {
  max-width: 1040px;
  margin: 0 auto;
  text-align: center;
  padding-block: clamp(76px, 15vh, 160px) clamp(20px, 4vh, 44px);
}
.chapter .label { color: var(--gold); margin-bottom: 18px }
.chapter h2 {
  font-family: "VW Alegreya", Georgia, serif;
  font-weight: 500;
  font-size: clamp(29px, 7.6vw, 54px);
  line-height: 1.12;
  letter-spacing: -.01em;
  color: var(--bone);
  margin: 0 auto;
  max-width: min(17ch, 100%);
  text-wrap: balance;
}
.chapter .sub {
  max-width: min(48ch, 100%);
  margin: 20px auto 0;
  color: var(--mist);
  font-size: clamp(16px, 4.2vw, 19px);
}

/* the narration voice, spoken into the dark between chapters */
.whisper {
  text-align: center;
  padding-block: clamp(54px, 11vh, 120px);
}
.whisper p {
  font-family: "VW Mathilde", "Brush Script MT", cursive;
  font-size: clamp(62px, 18vw, 142px);
  line-height: .96;
  color: #cbb8e8;
  margin: 0 auto;
  max-width: min(17ch, 100%);
  text-shadow: 0 0 44px rgba(138, 106, 163, .55);
}

/* ------------------------------------------------------- parchment sheets */

.sheets {
  max-width: 1040px;
  margin: 0 auto;
  padding-block: 2vh 4vh;
  display: flex;
  flex-direction: column;
  gap: clamp(26px, 6vw, 52px);
}

.paper {
  position: relative;
  --sx: 6px;
  --sy: 6px;
  --rot: 0deg;
  width: 100%;
  max-width: 620px;
  background: var(--linen);
  color: var(--ink);
  padding: clamp(22px, 6vw, 40px) clamp(20px, 6vw, 42px);
  transform: rotate(var(--rot));
  /* one constant faint cream line on every edge, never changing */
  box-shadow: inset 0 0 0 1px rgba(248, 243, 233, .4);
  filter:
    drop-shadow(var(--sx) var(--sy) 0 rgba(26, 16, 2, .34))
    drop-shadow(calc(var(--sx) * .5) calc(var(--sy) * .5) 14px rgba(0, 0, 0, .34));
}
.paper > * { position: relative; z-index: 2 }

/* the tooth: the app's own relief, lifted until the eye can see it.
   The shipped texture carries its grain entirely in an alpha channel that never
   rises above 21 of 255 -- true to the app, invisible on a web page -- so
   make_paper.py lifts that alpha and this lays the result on as real paper. */
.paper::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background-image: url(/img/paper.png);
  background-size: 150px 150px;
  mix-blend-mode: hard-light;
  opacity: .85;
  clip-path: var(--clip, none);
  pointer-events: none;
}
/* the rim: a gradient aimed at the lamp, light where the lamp is */
.paper::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  background: linear-gradient(var(--rim, 135deg), rgba(255, 255, 255, .5), rgba(70, 50, 20, .34));
  mix-blend-mode: soft-light;
  clip-path: var(--clip, none);
  pointer-events: none;
}

.paper p { margin: 0 0 1em; font-size: clamp(16px, 4.3vw, 19px); overflow-wrap: break-word }
.paper p:last-child { margin-bottom: 0 }
.paper h3 {
  font-family: "VW Alegreya", Georgia, serif;
  font-weight: 600;
  font-size: clamp(21px, 5.6vw, 28px);
  line-height: 1.2;
  margin: 0 0 14px;
  color: #2b2142;
  text-wrap: balance;
}
.paper a { color: #5b3679; text-underline-offset: 3px }
.paper a:hover, .paper a:focus-visible { color: #2b2142 }

/* the etch, on paper: dark away from the lamp, light towards it */
.paper p, .paper h3, .paper .label, .paper .teller, .paper li {
  text-shadow: -0.5px -0.5px 0 rgba(0, 0, 0, .18), 0.55px 0.55px 0 rgba(255, 255, 255, .7);
}

.label {
  font-family: "VW Cinzel", Georgia, serif;
  font-size: 11px;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--linen-700);
  margin: 0 0 14px;
}

/* .paper p would out-specify a bare .teller and pin this to body size, which is
   exactly what kept the narration hand small however large the number here got.
   Mathilde also draws small for its point size -- its x-height is 0.221 em where
   Alegreya's is 0.452 -- so it needs roughly double to read at the same weight,
   and more than that to read as a hand. */
.paper .teller {
  font-family: "VW Mathilde", "Brush Script MT", cursive;
  font-size: clamp(66px, 19vw, 116px);
  line-height: .92;
  color: #4a3a6a;
  margin: 0;
  text-align: center;
}

.paper.quiet { background: var(--linen-deep) }
.paper.small { max-width: min(34ch, 100%) }
.paper.left { align-self: flex-start }
.paper.right { align-self: flex-end }
/* once the edges are torn the sheet is painted by a generated SVG behind it,
   and the drop-shadow above follows that shape instead of the square box */
.paper.torn { background-color: transparent; box-shadow: none }
.paper.torn { background-repeat: no-repeat; background-size: 100% 100% }

/* the things the app refuses to be, struck through as they come into view */
.struck {
  display: flex;
  flex-wrap: wrap;
  gap: 10px clamp(14px, 4vw, 26px);
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
}
.struck li {
  position: relative;
  font-family: "VW Cinzel", Georgia, serif;
  font-size: clamp(13px, 3.6vw, 16px);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #7a6a55;
}
.struck li::after {
  content: "";
  position: absolute;
  left: -3px; right: -3px; top: 54%;
  height: 1.5px;
  background: #9c4040;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .55s cubic-bezier(.22,.7,.2,1);
}
.paper.in .struck li::after { transform: scaleX(1) }
.paper.in .struck li:nth-child(2)::after { transition-delay: .12s }
.paper.in .struck li:nth-child(3)::after { transition-delay: .24s }
.paper.in .struck li:nth-child(4)::after { transition-delay: .36s }

/* ------------------------------------------------------------- the close */

.closing {
  text-align: center;
  padding-block: clamp(30px, 6vh, 60px) clamp(90px, 18vh, 170px);
}
.email {
  display: inline-block;
  font-family: "VW Cinzel", Georgia, serif;
  font-size: clamp(14px, 4.2vw, 19px);
  letter-spacing: .08em;
  color: var(--gold);
  text-decoration: none;
  border-bottom: 1px solid rgba(212, 165, 116, .45);
  padding-bottom: 7px;
  word-break: break-word;
}
.email:hover, .email:focus-visible { color: var(--moon); border-bottom-color: var(--moon) }

.foot {
  position: relative;
  z-index: 1;
  text-align: center;
  font-size: 12.5px;
  line-height: 1.75;
  color: #5d5578;
  padding-block: 0 calc(26px + env(safe-area-inset-bottom, 0px));
}
.foot a { color: #8d84ab; text-decoration: none; border-bottom: 1px solid rgba(141, 132, 171, .35) }
.foot a:hover, .foot a:focus-visible { color: var(--bone) }
.foot p { margin: 0 0 10px }

/* before they settle, the sheets are a little away and a little turned */
.js .paper { opacity: 0 }
.js .chapter, .js .whisper { opacity: 0; transform: translateY(26px);
  transition: opacity .9s cubic-bezier(.22,.7,.2,1), transform .9s cubic-bezier(.22,.7,.2,1) }
.js .chapter.in, .js .whisper.in { opacity: 1; transform: none }

:focus-visible { outline: 2px solid var(--moon); outline-offset: 3px }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto }
  .js .paper { opacity: 1 }
  .js .chapter, .js .whisper { opacity: 1; transform: none }
  .cloudband, #flame, .star { animation: none !important }
  * { transition-duration: .01ms !important }
}
