/* Tellurin: "How it works": a manuscript page that sets itself as a book page while you scroll,
   and a few faint printer's marks in the margins of the site.
   Everything that moves changes only transform and opacity (typeset.js); without motion it is the finished page. */

/* ==================================================================
   The page, in its own pixels: 364 x 546 (6 x 9 in), scaled to fit with --fit
================================================================== */
.ts { --ts-ink: #26324f; --ts-run: 270vh; position: relative; margin-top: 72px; }
.ts-stage { position: relative; display: flex; flex-direction: column; align-items: center; gap: 26px; }
.ts-frame {
  position: relative;
  flex: none;
  width: min(100%, 400px);
  aspect-ratio: 364 / 546;
}
.ts-sheet {
  position: absolute;
  left: 0;
  top: 0;
  width: 364px;
  height: 546px;
  transform-origin: 0 0;
  transform: scale(var(--fit, 1));
}

/* the book page: warm paper, a soft shadow, the binding on the left (page 3 is a right-hand page) */
.ts-paper {
  position: absolute;
  left: 0;
  top: 0;
  width: 364px;
  height: 546px;
  transform-origin: 0 0;
  border-radius: 2px 3px 3px 2px;
  background:
    linear-gradient(90deg, rgba(120, 92, 48, 0.11), rgba(120, 92, 48, 0.03) 5%, rgba(120, 92, 48, 0) 11%),
    linear-gradient(180deg, #fefbf4, #fbf6ea);
  box-shadow:
    inset 0 0 0 1px rgba(168, 133, 76, 0.1),
    0 1px 2px rgba(29, 42, 69, 0.06),
    0 30px 60px -30px rgba(29, 42, 69, 0.42),
    0 12px 28px -18px rgba(29, 42, 69, 0.18);
}
.ts-page { position: absolute; left: 0; top: 0; width: 364px; height: 546px; }

/* text block: inner margin 40, outer 48, head 52, foot 74 */
.ts-tb { position: absolute; left: 40px; top: 52px; width: 276px; height: 420px; }

/* the chapter opening */
.ts-open { position: absolute; left: 0; right: 0; top: 10px; display: none; text-align: center; }
.is-open .ts-open { display: block; }
.ts-label {
  font-family: var(--sans);
  font-size: 7.5px;
  font-weight: 600;
  line-height: 8px;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  text-transform: uppercase;
  color: var(--gold-deep);
}
.ts-num { margin-top: 10px; font-family: var(--serif); font-size: 36px; font-style: italic; font-weight: 500; line-height: 1; color: var(--ink); }
.ts-orn { display: flex; align-items: center; justify-content: center; gap: 10px; height: 10px; margin-top: 13px; color: var(--gold-line); }
.ts-orn svg { flex: none; }
.ts-orn i { width: 34px; height: 1px; background: linear-gradient(to right, rgba(168, 133, 76, 0), currentColor); }
.ts-orn i:last-child { background: linear-gradient(to left, rgba(168, 133, 76, 0), currentColor); }

/* the manuscript's own heading (only in the copies typeset.js measures) */
.ts-mshead { position: absolute; left: 0; top: 0; font-family: var(--sans); font-size: 12px; font-weight: 600; line-height: 16px; color: var(--ink); }

/* the text, step by step: manuscript → justified → hyphenated → drop cap → small caps → chapter opening */
.ts-text {
  position: absolute;
  left: 0;
  right: 0;
  top: 30px;
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 500;
  line-height: 24px;
  color: var(--ts-ink);
  text-align: left;
  -webkit-hyphens: none;
  hyphens: none;
  font-kerning: normal;
  font-variant-numeric: lining-nums;
  overflow-wrap: normal;
}
.ts-text p + p { margin-top: 10px; }
/* a whisker of tracking on two paragraphs, as a compositor would, for evener lines (scripts: spacing.js) */
.ts-text p:first-child { letter-spacing: 0.05px; }
.ts-text p:nth-child(5) { letter-spacing: -0.1px; }
.is-just .ts-text { line-height: 21px; text-align: justify; }
.is-just .ts-text p + p { margin-top: 0; text-indent: 1.5em; }
.is-hyph .ts-text { -webkit-hyphens: manual; hyphens: manual; }
.is-dc .ts-dcx,
.ts-page .ts-first::first-letter {
  float: left;
  margin: 1px 5px 0 -1px;
  font-size: 47.6px;
  font-weight: 500;
  font-style: normal;
  line-height: 40px;
  letter-spacing: 0;
  color: var(--gold-deep);
}
.is-sc .ts-scw,
.ts-page .ts-sc { font-variant: small-caps; font-variant-caps: small-caps; letter-spacing: 0.06em; }
.is-open .ts-text { top: 112px; height: 294px; overflow: hidden; } /* fourteen whole lines; the rest is on page 4 */

.ts-folio {
  position: absolute;
  left: 40px;
  top: 497px;
  width: 276px;
  font-family: var(--serif);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.1em;
  text-align: center;
  color: var(--ink-mute);
}

/* hidden copies of the page, one per step, measured once (typeset.js) */
.ts-measure { position: absolute; left: 0; top: 0; width: 364px; height: 546px; visibility: hidden; pointer-events: none; contain: strict; }
.ts-clone { position: absolute; left: 0; top: 0; width: 364px; height: 546px; }

/* ---------- what typeset.js draws when motion is on ---------- */
.ts-win {
  position: absolute;
  left: 15px;
  top: 1px;
  width: 326px;
  height: 494px;
  transform-origin: 0 0;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.66), rgba(255, 255, 255, 0.34));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    inset 0 -1px 0 rgba(29, 42, 69, 0.05),
    0 24px 60px -24px rgba(29, 42, 69, 0.28);
}
.ts-doc { position: absolute; left: 8px; top: 8px; right: 8px; bottom: 8px; border-radius: 14px; background: rgba(255, 255, 255, 0.9); box-shadow: 0 0 0 1px rgba(29, 42, 69, 0.05); }
.ts-bar {
  position: absolute;
  left: 24px;
  top: 10px;
  width: 308px;
  height: 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 13px;
  border-bottom: 1px solid var(--hairline);
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--ink-mute);
}
.ts-bar .ts-dots { display: flex; gap: 5px; margin-right: 2px; }
.ts-bar .ts-dots i { width: 6px; height: 6px; border-radius: 50%; background: #d8d2c2; }

/* the actors: one per syllable, hyphen, initial, heading word; placed by transform in text-block pixels */
.ts-actors { position: absolute; left: 10px; top: 12px; width: 336px; height: 460px; overflow: hidden; pointer-events: none; user-select: none; -webkit-user-select: none; }
.ta {
  position: absolute;
  left: 30px;
  top: 40px;
  transform-origin: 0 0;
  white-space: pre;
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 500;
  line-height: 21px;
  color: var(--ts-ink);
  font-kerning: normal;
}
.ta-sc { font-variant: small-caps; font-variant-caps: small-caps; letter-spacing: 0.06em; }
.ta-gold { color: var(--gold-deep); }
.ta-h { font-family: var(--sans); font-size: 12px; font-weight: 600; line-height: 16px; color: var(--ink); }
.ta-hl { font-family: var(--sans); font-size: 7.5px; font-weight: 600; line-height: 8px; letter-spacing: 0.42em; text-transform: uppercase; color: var(--gold-deep); }
.ta-hn { font-size: 36px; font-style: italic; line-height: 1; color: var(--ink); }
.ts-actors .ts-orn { position: absolute; margin: 0; }
.ts-actors .ts-orn > * { transform-origin: 50% 50%; }
.ts-actors .ts-orn i:first-child { transform-origin: 100% 50%; }
.ts-actors .ts-orn i:last-child { transform-origin: 0 50%; }

.ts.is-armed .ts-page { opacity: 0; }
/* the layers typeset.js draws are shown only while the story runs */
.ts:not(.is-armed) .ts-win,
.ts:not(.is-armed) .ts-bar,
.ts:not(.is-armed) .ts-actors,
.ts:not(.is-armed) .ts-folio-a { display: none; }

/* ---------- the six steps beside the page (as a plain list: no motion, no JS, or a very short screen) ---------- */
.ts-side { position: relative; width: 100%; max-width: 400px; }
.ts-cap { position: relative; height: 16px; margin: 0; }
.ts-cap span { position: absolute; left: 0; right: 0; top: 0; white-space: nowrap; }
.ts-cap-a { display: none; }
.ts-steps { position: relative; margin: 0; padding: 0; list-style: none; }
.ts-steps li + li { margin-top: 10px; }
.ts-line { display: flex; align-items: baseline; gap: 12px; font-family: var(--serif); font-size: 20px; font-weight: 500; line-height: 1.3; color: var(--ink); }
.ts-n { flex: none; min-width: 1.9em; font-size: 14px; font-weight: 600; letter-spacing: 0.06em; color: var(--gold-deep); }
.ts-seg, .ts-thread { display: none; }

/* phones and narrow windows: the list under the page */
@media (max-width: 899px) {
  .ts-side { order: 2; text-align: center; }
  .ts-cap { margin-bottom: 14px; }
  .ts-cap span { text-align: center; }
  .ts-steps { display: inline-block; text-align: left; }
}
/* wide: the steps on the left, the page on the right */
@media (min-width: 900px) {
  .ts { margin-top: 56px; }
  .ts-stage { flex-direction: row; justify-content: center; align-items: center; gap: clamp(56px, 8vw, 128px); }
  .ts-side { width: 300px; max-width: none; padding-left: 30px; }
  .ts-frame { width: min(440px, max(320px, calc((100vh - 140px) * 0.6667))); }
  .ts-cap { margin-bottom: 24px; }
  .ts-steps li { padding: 9px 0; }
  .ts-steps li + li { margin-top: 0; }
  .ts-line { font-size: 21px; }
}

/* ==================================================================
   Motion on (and a screen tall enough to hold a page): a tall track,
   the stage held in view while the page sets itself
================================================================== */
@media (min-height: 481px) {
  .anim .ts-track { height: calc(100vh + var(--ts-run)); }
  .anim .ts-stage { position: sticky; top: 0; height: 100vh; justify-content: center; }
  .anim .ts-cap-a { display: block; }
  .anim .ts-cap-b { opacity: 0; }
  .anim .ts + .steps-block { margin-top: 40px; }
}
@media (min-height: 481px) and (min-width: 900px) {
  .anim .ts-frame { width: min(440px, calc((100vh - 140px) * 0.6667)); }
  .anim .ts-thread { display: block; position: absolute; left: 7px; top: 0; width: 1px; height: 0; background: var(--hairline); }
  .anim .ts-fill { position: absolute; left: 0; top: 0; width: 1px; height: 100%; background: var(--gold-line); transform-origin: 50% 0; transform: scaleY(0); }
  .anim .ts-bead { position: absolute; left: -3px; top: -3.5px; width: 7px; height: 7px; background: var(--gold-line); opacity: 0; transform: rotate(45deg); }
  .anim .ts-line { opacity: 0.34; }
}
@media (min-height: 481px) and (max-width: 899px) {
  .ts.ts { --ts-run: 240vh; }
  .anim .ts { margin-top: 24px; }
  .anim .ts-stage { gap: 14px; padding-top: 20px; }
  .anim .ts-frame { width: min(100%, 400px, calc((100vh - 120px) * 0.6667)); }
  @supports (height: 100svh) {
    .ts.ts { --ts-run: 240svh; }
    .anim .ts-track { height: calc(100svh + var(--ts-run)); }
    .anim .ts-stage { height: 100svh; }
    .anim .ts-frame { width: min(100%, 400px, calc((100svh - 120px) * 0.6667)); }
  }
  /* one caption at a time, over six short rules that fill as the steps are done */
  .anim .ts-cap { margin-bottom: 4px; }
  .anim .ts-steps { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; height: 42px; padding-top: 38px; }
  .anim .ts-steps li + li { margin-top: 0; }
  .anim .ts-line { position: absolute; left: 0; right: 0; top: 2px; justify-content: center; font-size: 19px; white-space: nowrap; }
  .anim .ts-steps li + li .ts-line { opacity: 0; }
  .anim .ts-seg { display: block; height: 2px; border-radius: 2px; background: var(--hairline); overflow: hidden; }
  .anim .ts-seg i { display: block; height: 100%; background: var(--gold-line); transform-origin: 0 50%; transform: scaleX(0); }
}

/* ==================================================================
   Printer's marks: a few faint gold signs in the wide margins, drifting at their own pace
================================================================== */
.tg {
  display: none;
  position: absolute;
  z-index: -1;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  font-family: var(--serif);
  font-weight: 400;
  line-height: 1;
  color: var(--gold-line);
  opacity: 0.085;
}
.tg svg { display: block; width: 100%; height: auto; }
@media (min-width: 1100px) {
  .tg { display: block; }
  .anim .tg { will-change: transform; }
  /* max(0px, …): from 1366 px up the marks sit where they always did; on narrower windows (1100–1365 px)
     they stop at the edge of the window instead of running past it (they ran 10 px out at 1280 px) */
  .tg-pilcrow { left: max(0px, calc(50% - 640px)); top: 8px; font-size: 220px; }
  .tg-letter { right: max(0px, calc(50% - 650px)); top: -10px; font-size: 300px; font-style: italic; }
  .tg-section { right: max(0px, calc(50% - 680px)); top: 34%; font-size: 240px; }
  .tg-fleuron { left: max(0px, calc(50% - 650px)); top: 40%; width: 250px; }
  .tg-quote { left: max(0px, calc(50% - 600px)); top: 14%; font-size: 330px; }
}
