/* First draft to final: headings are ruled and pencilled before they are inked,
   and the painting waits under the last sheet of paper. */

/* The second sentence of each title keeps the spacing of the first. */
.page-home main :is(h1, h2) em { letter-spacing: inherit; }

/* ---- Seams ---- */
/* The opener fades into the same grained paper the page is made of, so no band
   shows where one ends and the other begins. */
.first-drafts::after {
  background: #f8f8f6 var(--paper-grain);
  -webkit-mask-image: linear-gradient(transparent, #000 92%);
  mask-image: linear-gradient(transparent, #000 92%);
}
/* The header's paper strip is cut from that sheet too, edge to edge. */
body.page-home { overflow-x: clip; }
.page-home .site-header:not(.workspace-site-header)::before {
  inset: 0 calc(50% - 50vw); box-shadow: none; clip-path: none;
  background: var(--paper) var(--paper-grain);
}

/* The page arrives over the opener as a sheet of paper with a slanted edge and
   its own shadow, the same way the last sheet leaves at the bottom. The old
   misty dissolve is switched off once this is running. */
.first-drafts.has-rise::after { display: none; }
.first-drafts.has-rise .reel-paint { -webkit-mask-image: none; mask-image: none; }
.sheet-rise {
  position: absolute; left: 50%; bottom: 100%; z-index: 3;
  width: 100vw; height: var(--rise, 0px); translate: -50% 0;
  pointer-events: none;
}
.sheet-rise::before {
  content: ''; position: absolute; inset: 0 0 -1px;
  background: #f8f8f6 var(--paper-grain);
  clip-path: polygon(0 100%, 100% 0, 100% 100%);
}
.sheet-rise::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 44px;
  background: linear-gradient(transparent, rgb(8 6 14 / .16) 62%, rgb(8 6 14 / .46));
  transform-origin: left bottom;
  transform: skewY(calc(-1 * var(--tilt, 0deg)));
  opacity: var(--shade, 0);
}

/* ---- The way past the opener, offered only to a reader who has stopped ---- */
.reel-continue { width: 64px; height: 64px; bottom: max(26px, env(safe-area-inset-bottom)); }
.reel-continue svg { width: 64px; height: 64px; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.reel-continue:hover svg { transform: none; }
.reel-continue-ring { stroke-dasharray: 1; stroke-dashoffset: 0; }
.first-drafts.has-rise .reel-continue:not(.is-offered, :focus-visible) { opacity: 0; visibility: hidden; transition: opacity 220ms ease, visibility 0s 220ms; }
.reel-continue.is-offered { opacity: 1; visibility: visible; transition: opacity 220ms ease, scale 320ms cubic-bezier(.3, 1.5, .5, 1); }
@media (prefers-reduced-motion: no-preference) {
  .reel-continue.is-offered .reel-continue-ring { animation: continue-ring 950ms cubic-bezier(.3, 0, .2, 1) both; }
  .reel-continue.is-offered .reel-continue-arrow { animation: continue-drop 520ms cubic-bezier(.2, .8, .2, 1) 620ms both, continue-nudge 2.8s ease-in-out 1.9s infinite; }
}
@keyframes continue-ring { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes continue-drop { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }
@keyframes continue-nudge { 0%, 62%, 100% { transform: none; } 74% { transform: translateY(6px); } 86% { transform: translateY(-1px); } }

/* The way past the opener is a pencilled ring, clear through to the sheet. Pointed at,
   it grows about its own centre, and now and then the arrow dives. */
/* Centred with its own translate, so that growing does not carry it sideways. */
.reel-continue { isolation: isolate; transform: none; translate: -50% 0; transform-origin: 50% 50%; }
@media (prefers-reduced-motion: no-preference) {
  .reel-continue:is(:hover, :focus-visible) { scale: 1.14; }
  .reel-continue:is(:hover, :focus-visible) .reel-continue-arrow { animation: continue-dive 5400ms cubic-bezier(.3, 0, .2, 1) infinite; }
}
@keyframes continue-dive {
  0%, 8% { transform: none; opacity: 1; }
  24% { transform: translateY(11px); opacity: 1; }
  30% { transform: translateY(14px); opacity: 0; }
  31% { transform: translateY(-8px); opacity: 0; }
  44%, 100% { transform: none; opacity: 1; }
}

/* The fan of prints is not trimmed by its section, and has room beneath it. */
.page-home .manifesto { overflow: visible; }
.page-home .manifesto .intro-section { padding-bottom: clamp(28px, 4vw, 60px); }

/* ---- Headings that are drafted, then inked ---- */
.draft-boil-defs { position: absolute; width: 0; height: 0; pointer-events: none; }
.is-drafted {
  --rule: 0; --pencil: 0; --ink: 0; --fade: 0;
  --graphite: #8b8a86;
  position: relative;
}
.is-drafted > .draft-ink { display: block; position: relative; }
.is-drafted > :is(.draft-outline, .draft-hatch) {
  display: block; position: absolute; inset: 0;
  pointer-events: none; user-select: none; -webkit-user-select: none;
  opacity: calc(var(--pencil) * (1 - var(--fade)));
  filter: url(#draft-boil);
}
/* The stroke is laid first and the paper fill covers its inner half, so
   overlapping contours in the variable font never show inside a letter. */
.is-drafted > .draft-outline {
  -webkit-text-stroke: 1.5px var(--graphite);
  -webkit-text-fill-color: var(--paper);
  paint-order: stroke fill;
}
.is-drafted > .draft-hatch {
  color: transparent; -webkit-text-fill-color: transparent;
  background: repeating-linear-gradient(118deg, var(--graphite) 0 .75px, transparent .75px 5.5px);
  -webkit-background-clip: text; background-clip: text;
  opacity: calc(var(--pencil) * (1 - var(--fade)) * .62);
}
.is-drafted > .draft-ink {
  -webkit-mask-image: linear-gradient(100deg, #000 calc(var(--ink) * 124% - 24%), transparent calc(var(--ink) * 124%));
  mask-image: linear-gradient(100deg, #000 calc(var(--ink) * 124% - 24%), transparent calc(var(--ink) * 124%));
  -webkit-mask-clip: no-clip; mask-clip: no-clip;
}
.draft-probe { display: inline-block; width: 0; height: 0; vertical-align: baseline; }
.is-drafted > .draft-rules {
  position: absolute; inset: 0; pointer-events: none;
  opacity: calc(1 - var(--fade));
  filter: url(#draft-boil);
}
.draft-rules > i {
  position: absolute; display: block; height: 1px;
  background: var(--graphite); opacity: var(--weight, .8);
  transform-origin: left center;
  rotate: var(--lean, 0deg);
  transform: scaleX(clamp(0, calc((var(--rule) - var(--wait, 0)) * 2.4), 1));
}
.draft-rules > i.draft-tick {
  width: 1px; height: auto;
  transform-origin: center top;
  transform: scaleY(clamp(0, calc((var(--rule) - var(--wait, 0)) * 2.4), 1));
}
.draft-measure { position: absolute; display: block; visibility: hidden; width: 0; }
.is-drafted.is-blank > :is(.draft-outline, .draft-hatch, .draft-rules) { visibility: hidden; }
/* A finished title is ordinary text again. */
.is-drafted.is-inked > :is(.draft-outline, .draft-hatch, .draft-rules) { display: none; }
.is-drafted.is-inked > .draft-ink { -webkit-mask-image: none; mask-image: none; }

/* ---- Pictures that are set out in pencil, then washed in ---- */
.draft-plan {
  --rule: 0; --fade: 0;
  position: absolute; z-index: 2; overflow: visible; pointer-events: none;
  fill: none; stroke: #8b8a86; stroke-width: 1; stroke-linecap: round;
  opacity: calc(1 - var(--fade));
  filter: url(#draft-boil);
}
.draft-plan.is-idle { display: none; }
.draft-plan path {
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 1;
  stroke-dashoffset: calc(1 - clamp(0, (var(--rule) - var(--wait, 0)) * 2.4, 1));
  opacity: .8;
}
.draft-plan path.draft-diagonal { opacity: .45; }
.draft-wash:not(.is-washed) {
  -webkit-mask-image: linear-gradient(100deg, #000 calc(var(--ink, 0) * 124% - 24%), transparent calc(var(--ink, 0) * 124%));
  mask-image: linear-gradient(100deg, #000 calc(var(--ink, 0) * 124% - 24%), transparent calc(var(--ink, 0) * 124%));
  -webkit-mask-clip: no-clip; mask-clip: no-clip;
  /* The print is carried in at a tilt, a little small, and settles into its box. */
  rotate: var(--lean, 0deg); scale: var(--grow, 1); translate: 0 var(--drop, 0px);
}

/* Figures and charts are set out in pencil first as well. Their boxes are
   hatched, the drafting sign for "to be filled", and carry no diagonals. */
.draft-plan path.draft-hatching { opacity: .5; }
.page-home .model-data [data-reveal-ready]:not(.is-visible) :is(.data-score-track > span, .model-data-tiles > span) { opacity: 1; transform: none; }
.draft-wash.draft-flat:not(.is-washed) { rotate: none; scale: none; translate: none; }

/* A print that is sketched before it is coloured: the print itself waits,
   unseen, while a sheet over it is drawn on; then the two change places. */
.draft-sketched { transition: opacity 280ms ease; }
.draft-sketched:not(.is-washed) { opacity: 0; pointer-events: none; }
.draft-sheet { position: absolute; z-index: 1; pointer-events: none; border-radius: 2px; transition: opacity 280ms ease; }
.draft-sheet.is-idle { opacity: 0; }
/* The diagram's output is built by the steps themselves, so it is not dimmed while it waits. */
.page-home .model-explainer[data-mode] .model-flow-output { opacity: 1; }

/* ---- When the machine cannot keep up (see pace.js) ---- */
/* First the pencil stops trembling: the filter behind the tremble is the dearest thing on the sheet. */
html.pace-still-titles .is-drafted > :is(.draft-outline, .draft-hatch, .draft-rules),
html.pace-still-pictures .draft-plan { filter: none; }
/* If that is not enough, titles and pictures stop following the scroll. Each one
   arrives once, by a transition the browser runs by itself, and stays. */
html.pace-plain-titles .is-drafted > :is(.draft-outline, .draft-hatch, .draft-rules) { display: none; }
html.pace-plain-titles .is-drafted > .draft-ink {
  -webkit-mask-image: none; mask-image: none;
  opacity: 0; translate: 0 .14em;
  transition: opacity 520ms ease, translate 640ms cubic-bezier(.2, .7, .2, 1);
}
html.pace-plain-titles .is-drafted.is-inked > .draft-ink { opacity: 1; translate: none; }
.page-home main .draft-arrive { transition: opacity 560ms ease, translate 700ms cubic-bezier(.2, .7, .2, 1); }
.page-home main .draft-arrive:not(.is-arrived) { opacity: 0; translate: 0 18px; pointer-events: none; }
.page-home main .draft-arrive.draft-flat:not(.is-arrived) { translate: none; }

/* ---- Answers open at reading speed ---- */
@supports selector(::details-content) {
  @media (prefers-reduced-motion: no-preference) {
    .page-home .home-faq { interpolate-size: allow-keywords; }
    .page-home .faq-item::details-content {
      height: 0; overflow: clip;
      transition: height 420ms cubic-bezier(.3, 0, .15, 1), content-visibility 420ms allow-discrete;
    }
    .page-home .faq-item[open]::details-content { height: auto; }
    .page-home .faq-item .faq-plus { transition: transform 420ms cubic-bezier(.3, 0, .15, 1); }
  }
}

/* ---- The last sheet lifts, and the cloth is still there ---- */
.page-home main {
  position: relative; z-index: 1; overflow-x: clip;
  background: var(--paper) var(--paper-grain);
  padding-bottom: var(--section-space);
}
.sheet-edge {
  position: absolute; left: 0; right: 0; top: 100%; height: var(--edge, 0px);
  pointer-events: none;
}
.sheet-edge::before {
  content: ''; position: absolute; inset: -1px 0 0;
  background: var(--paper) var(--paper-grain);
  clip-path: polygon(0 0, 100% 0, 100% 1px, 0 100%);
}
.sheet-edge::after {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 38px;
  background: linear-gradient(rgb(8 6 14 / .58) 0, rgb(8 6 14 / .2) 28%, transparent);
  opacity: var(--shade, 1);
  transform-origin: right top;
  transform: skewY(calc(-1 * var(--tilt, 0deg)));
}
.curtain-call {
  position: sticky; bottom: 0; z-index: 0;
  height: 100vh; height: 100svh;
  overflow: hidden; isolation: isolate;
  background: #182260 url('/assets/reel/silk.webp') center / cover no-repeat;
  color: #fff4d6;
}
.curtain-call.is-waiting { background-image: none; }
/* Out of the render tree until the last sheet is near: a hidden GPU canvas behind the page is not free. */
.curtain-silk { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; display: none; }
.curtain-call.has-paint:not(.is-waiting) .curtain-silk { display: block; }
.page-home .curtain-call .closing.closing-simple {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  margin: 0; padding: var(--navigation-height) 24px 72px;
  border: 0; background: none; color: inherit; text-align: center;
}
.page-home .curtain-call .closing h2 {
  margin: 0; max-width: 14ch;
  font: 460 clamp(44px, 7.4vw, 104px)/1.03 var(--display);
  font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1;
  letter-spacing: -.02em; color: inherit; text-wrap: balance;
  text-shadow: 0 2px 22px #000a;
}
/* Once the question is painted into the cloth, the heading stays for readers and search only. */
.page-home .curtain-call.has-phrase .closing h2 {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.page-home .curtain-call.has-phrase .closing .paper-link {
  position: absolute; left: 50%; top: calc(var(--phrase-bottom, 60%) + clamp(14px, 3.4svh, 38px));
  translate: -50% 0;
}
.page-home .curtain-call .paper-link {
  color: inherit; font-size: clamp(21px, 2.3vw, 29px); white-space: nowrap;
  text-shadow: 0 1px 12px #000c;
}
.page-home .curtain-call .paper-link:focus-visible { outline-color: currentColor; }
.page-home .curtain-call .footer {
  position: absolute; left: 0; right: 0; bottom: 0; margin-inline: auto; padding: 0 0 20px;
}
.page-home .curtain-call .footer .footer-bottom {
  margin-top: 0; border-top-color: #fff4d63d; color: #fff4d6d9;
  text-shadow: 0 1px 8px #000c;
}
.page-home .curtain-call .footer a { color: inherit; }
.page-home .curtain-call .footer a:hover { color: #fff; }
/* The header's lettering is one even colour: ink wherever paper is under it,
   cream wherever the bare cloth is. Its paper strip comes and goes with the
   edge of the sheet that passes under it. */
.page-home .site-header::before { opacity: var(--strip, 1); }
.page-home .site-header :is(.brand, nav > a) { transition: color 260ms ease, text-shadow 260ms ease; }
.page-home .site-header.on-cloth .brand { color: #fff4d6; text-shadow: 0 1px 10px rgb(0 0 0 / .7); }
.page-home .site-header .menu-toggle span,
.page-home .site-header.on-cloth .menu-toggle span { background: currentColor; -webkit-backdrop-filter: none; backdrop-filter: none; }
.page-home .site-header.on-cloth .menu-toggle { color: #fff4d6; border-color: #fff4d680; }
@media (min-width: 901px) {
  .page-home .site-header.on-cloth nav > a { color: #fff4d6; text-shadow: 0 1px 10px rgb(0 0 0 / .7); }
}
@media (max-width: 640px) {
  .page-home .curtain-call .footer .footer-bottom { flex-wrap: wrap; row-gap: 6px; }
}
/* On a narrow screen the cloth is as tall as the screen is with the browser's bars away. */
@media (max-width: 760px) {
  .curtain-call { height: 100vh; height: 100lvh; }
}
/* ---- Wide screens: a page with margins and columns, not one centred strip ---- */
@media (min-width: 1280px) {
  .page-home {
    --sheet-width: min(1560px, calc(100% - clamp(96px, 10vw, 220px)));
    --sheet-title: clamp(52px, 4.1vw, 74px);
  }
  .page-home main :is(.hero-copy h1, .manifesto h2, .proof-heading h2, .model-data-heading h2,
                      .model-flow-heading h2, .home-faq-heading h2) { margin-inline: 0; text-align: left; }
  /* Opening statement on the left margin, the artwork given the rest. */
  .page-home .hero.editorial-hero {
    display: grid; grid-template-columns: minmax(300px, 4fr) minmax(0, 8fr);
    column-gap: clamp(32px, 4vw, 84px); align-items: center;
  }
  .page-home .editorial-hero .hero-copy { text-align: left; }
  .page-home .hero-copy h1 { font-size: clamp(60px, 5.3vw, 98px); line-height: 1; }
  /* The second line steps in from the first, like a line of verse. */
  .page-home .hero-copy h1 em { display: block; text-align: left; margin-left: .62em; }
  .page-home .hero-copy .hero-description { margin-inline: 0; margin-top: 30px; }
  .page-home .hero-copy .hero-detail { margin-inline: 0; }
  .page-home .hero-stage { margin-top: 0; grid-template-columns: minmax(120px, .8fr) minmax(0, 4.6fr) minmax(120px, .8fr); }
  /* The header keeps to the same margins as the page beneath it. */
  .page-home .site-header:not(.workspace-site-header) { width: var(--sheet-width); }
  /* The prints on the left this time, the explanation on the right. */
  .page-home .manifesto .intro-section {
    display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 5fr);
    column-gap: clamp(40px, 6vw, 120px); align-items: center;
  }
  .page-home .manifesto .polaroid-gallery { order: -1; width: min(100%, 640px); justify-self: center; }
  .page-home .manifesto-copy { text-align: left; }
  .page-home .manifesto-copy > p { margin-inline: 0; }
  /* Title and test switch share a line; the boards take the full measure. */
  .page-home .proof-section {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; text-align: left;
  }
  .page-home .proof-section > .proof-tabs { justify-self: end; margin-bottom: 30px; }
  .page-home .proof-section > .proof-panel { grid-column: 1 / -1; }
  .page-home .proof-test-intro, .page-home .proof-panel[data-proof-panel] .proof-test-intro { justify-items: start; }
  .page-home .proof-test-intro > p { text-align: left; }
  .page-home .proof-model-picker, .page-home .proof-source-picker { justify-content: flex-start; }
  .page-home .model-data-heading {
    display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 5fr);
    column-gap: clamp(40px, 6vw, 120px); align-items: end; text-align: left;
  }
  .page-home .model-data-heading > p { margin: 0 0 .5em; }
  /* Questions run beside their title, which stays put while they scroll. */
  .page-home .home-faq.section-space {
    display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 8fr);
    column-gap: clamp(40px, 5vw, 96px); align-items: start;
  }
  .page-home .home-faq .home-faq-heading { position: sticky; top: calc(var(--navigation-height) + 40px); margin-bottom: 0; }
}

@media print {
  .is-drafted > :is(.draft-outline, .draft-hatch, .draft-rules) { display: none; }
  .is-drafted > .draft-ink, .draft-wash { -webkit-mask-image: none !important; mask-image: none !important; }
  .draft-plan { display: none; }
  .page-home main { padding-bottom: 0; }
  .curtain-call, .sheet-edge { display: none; }
}
