/* The landing page (templates/intro.html): a scroll through the night to daybreak (ui-redesign C304-C311). The
   bar, buttons, glass cards, letter tiles, type styles and every colour are style.css's; this file lays the journey
   out and sizes its headings. A night chapter is `.in-dark` and the day's chapter `.in-light`: the theme's dark and
   light colours, whatever the theme.
   Three levels, each complete without the next:
   1. static: every chapter paints its own sky (reduced motion, or a browser without scroll-driven animations);
   2. posters: a fixed night poster gives way to dawn as the last chapter scrolls in, and what the eye's and the
      ear's chapters show plays with the scroll, in CSS alone;
   3. scene: landing.js adds the film and the 3D scene on the canvas, and sets html.has-scene once it has drawn. */

main.sky.journey {
  --l-poster-night: url("/static/landing/night.jpg");
  --l-poster-dawn: url("/static/landing/dawn.jpg");
  min-height: 0; padding: 0;   /* the chapters hold their own heights and spacing */
}
/* The backdrop is fixed and would cover what is not positioned: the skip link when it shows, and the footer. */
:root:has(.journey) .skip:focus { position: relative; z-index: 11; }
main.journey ~ .version { position: relative; z-index: 1; max-width: none; }   /* a full band */
/* The bar takes the colours of the chapter under it (C326): the night's (.in-dark, as the template starts it) or the
   dawn's (.in-light), which bar.js sets as the page scrolls either way; past the chapters, the theme's. Its surface is
   nearly solid, which keeps its text at 4.5:1 over anything (C163), except where the sky is drawn behind it (the
   stage below: motion allowed and scroll timelines, or the scene): there it is a 40% tinted glass, unblurred (any blur
   wipes out the stars, a pixel or two wide). Its light/dark button still reads the page's own theme (style.css). */
.bar.landing-bar { --bar-tint: 92%; background: color-mix(in srgb, var(--color-bg-surface) var(--bar-tint), transparent); }
.bar.landing-bar:is(.in-dark, .in-light) { backdrop-filter: none; }
.has-scene .bar.landing-bar:is(.in-dark, .in-light) { --bar-tint: 40%; }
@media (prefers-reduced-motion: no-preference) {
  @supports ((animation-timeline: scroll()) and (animation-range: 0% 100%)) {
    .bar.landing-bar:is(.in-dark, .in-light) { --bar-tint: 40%; }
  }
}
.landing-bar .bar-end { margin-left: auto; }   /* no links in the middle: the logo left, the controls right (C326) */

/* Chapters. Level 1: each paints its own sky. */
.l-ch { position: relative; z-index: 1; display: flex; align-items: flex-start; padding: 0 clamp(1.25rem, 7vw, 7rem); }
.l-ch.in-dark { background: var(--color-bg-page); }
/* A scrim on the copy's side keeps the text readable over the poster or the film. */
.l-ch.in-dark::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(90deg, color-mix(in srgb, var(--color-bg-page) 80%, transparent) 0,
    color-mix(in srgb, var(--color-bg-page) 55%, transparent) 38%, transparent 68%); }
.l-ch--hero { min-height: calc(100svh - 4rem); align-items: center;   /* the bar's height, as main's */
  background: var(--color-bg-page) var(--l-poster-night) center / cover no-repeat; }
.l-ch--shape, .l-ch--check, .l-ch--eye, .l-ch--ear { padding-block: 16vh; }
.l-ch--line { padding-block: 18vh 14vh; }
/* the night's last chapter: its shade ends softly, where the day's begins */
.l-ch--ear::before { mask-image: linear-gradient(var(--color-bg-page) calc(100% - 75svh), transparent calc(100% - 10svh)); }
.l-ch--dawn { min-height: 100svh; align-items: center; justify-content: center;
  background: var(--color-sky-bottom) var(--l-poster-dawn) center / cover no-repeat; }

.l-copy { width: 100%; max-width: 34rem; min-width: 0; }   /* never wider than the screen, whatever it holds */
.l-copy--center { max-width: 46rem; text-align: center; margin-bottom: 22vh; }
.l-copy--center .hero-actions { justify-content: center; }
.l-ch h1, .l-ch > .l-copy > h2 { margin: 0 0 var(--space-6); font: var(--text-display); letter-spacing: var(--text-display-tracking); text-wrap: balance; }
.l-ch h1 { font-size: clamp(2.4rem, 5.4vw, 4.4rem); line-height: 1.06; }
.l-ch > .l-copy > h2 { font-size: clamp(1.9rem, 3.8vw, 3.1rem); line-height: 1.06; }
.l-ch--dawn > .l-copy > h2 { font-size: clamp(2.1rem, 4.6vw, 3.6rem); }
/* Amber is the app's colour for what is at or above the cut-off, and here for what a chapter asks the reader to
   look at; the accent is the light's and what two names share. A note is quieter than the sentence it follows. */
.l-copy > p:not([class]), .l-ch .lead, .l-ch .l-hint, .l-ch--hero .hero-note { color: var(--color-text-muted); }
.l-ch .lead { font-size: clamp(1.05rem, 1.4vw, 1.25rem); max-width: 32rem; }
.l-ch .hero-note a { color: inherit; }
.l-ch .l-angle { font: var(--text-mono-strong); color: var(--color-text-accent); min-height: 1.3em; }
.l-scene-only { display: none; }
.l-hear[hidden] { display: none; }   /* shown by landing.js */
.l-hear { min-height: 44px; border-radius: var(--radius-lg); font: var(--text-button); }

/* A shared letter is a filled tile; here it also has a bar under it, so colour is not its only mark (C163). */
.l-pair { display: grid; gap: var(--space-3); }
.journey .letter.shared { box-shadow: inset 0 -.2rem 0 var(--color-text-on-accent); }
.l-pair .is-speaking .letter { border-color: var(--color-border-above); }
.l-ch .example { margin-top: var(--space-7); }
.l-ch .example .letter { width: clamp(2rem, 4vw, 3.25rem); height: auto; aspect-ratio: 13 / 15; }

/* A card of the page: the chapter's surface, nearly solid, so its text keeps 4.5:1 whatever passes behind it
   (C163). */
.journey .l-card { padding: clamp(1.25rem, 3vw, 2.25rem); background: color-mix(in srgb, var(--color-bg-surface) 94%, transparent); }
.l-line { max-width: 44rem; }
.l-names { display: grid; grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); gap: var(--space-1) var(--space-7);
  margin: var(--space-7) 0; padding: 0; list-style: none; font: var(--text-mono-strong); font-weight: 500; }
.l-names li { display: flex; justify-content: space-between; gap: var(--space-4); border-bottom: 1px dashed var(--color-border-default); }
.l-names b { font-weight: 600; color: var(--color-text-above); }
/* The line the chapter speaks of, under the names, with its tag on its left end: amber, as the app draws the
   cut-off in a result. The scene draws the same line and tag under its own list. */
.l-names { padding-bottom: var(--space-6); border-bottom: 2px dashed var(--color-border-above); }
.l-names::after { content: "CUT-OFF" / ""; grid-column: 1 / -1; justify-self: start; margin-bottom: calc(-1 * var(--space-6) - .8em);
  padding: var(--space-1) var(--space-4); border: 1px solid var(--color-border-above); border-radius: var(--radius-full);
  background: var(--color-bg-above); color: var(--color-text-above); font: var(--text-tag-strong); font-family: var(--font-mono); }
.l-line .landing-cards { grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: var(--space-5); margin: 0; }
.l-line .landing-cards li { padding: var(--space-6); }

/* The eye's and the ear's chapters, laid out as the night's others: the copy, and beside it (under it on a phone)
   what the chapter shows, written on the sky, with its readout under a hairline as wide as it. A readout is an
   example card's score writ larger, for the open sky: the same large figure, then a label and a line under it in
   the body's type. As the page stands (level 1) the eye's sentence is shown as it was misread, its swapped pairs
   alight, and the ear's codes compared; with the scroll (level 2) each plays to its end. */
.l-ch--eye, .l-ch--ear { flex-wrap: wrap; align-content: flex-start; gap: var(--space-7) clamp(1rem, 4vw, 4rem); }
.l-show { flex: 1 1 18rem; display: grid; place-content: center; justify-items: center; min-width: 0; }
.l-shown { display: grid; gap: var(--space-7); text-shadow: 0 0 1.2em color-mix(in srgb, var(--color-bg-page) 70%, transparent); }
.l-ch--ear .l-shown { justify-items: center; }
.l-readout { display: flex; align-items: center; gap: var(--space-5); justify-self: stretch; margin: 0; padding-top: var(--space-6);
  border-top: 1px solid color-mix(in srgb, var(--color-text-primary) 45%, transparent); font: var(--text-body); line-height: 1.4; }
.l-readout b { font-weight: 600; }
.l-ch--eye .big-score { color: var(--color-text-above); }
.l-ch--ear .big-score { color: var(--color-text-accent); }
/* The eye: a sentence in the names' own type. The page holds its right spelling; the two letters of a marked pair
   are drawn in each other's place, alight, as the letters the glass names share are. */
.l-test { margin: 0; font: 600 clamp(1.3rem, 3.1vw + .5rem, 2.7rem)/1.3 var(--font-mono); white-space: nowrap; }
.l-row { display: block; width: fit-content; }   /* as wide as its text, which the scene measures */
.l-sw { color: var(--color-text-above); text-shadow: 0 0 .5em color-mix(in srgb, var(--color-border-above) 85%, transparent); }
.l-sw i { display: inline-block; font-style: normal; }
.l-sw i:first-child { translate: 1ch 0; }
.l-sw i:last-child { translate: -1ch 0; }
/* The ear: two names over their sound codes, the codes next to each other. A letter that is not sounded is faint; a
   cell is filled in the accent where the two names sound the same, and in amber where they do not. Each grid has
   a column of one cell's width for every letter or sound the page gives it. */
.l-pair-heard { --cell: clamp(1.6rem, 4.3vw + .4rem, 3.7rem); display: grid; gap: var(--space-4); }
.l-name { display: grid; gap: var(--space-4); justify-items: center; margin: 0; }
.l-name--under .l-letters { order: 1; }      /* its code above it, beside the other name's */
.l-letters, .l-codes { display: grid; grid-auto-flow: column; grid-auto-columns: var(--cell); }
.l-letters { justify-items: center; font: 600 calc(var(--cell) * .9)/1.1 var(--font-mono); }
.l-letters i { font-style: normal; }
.l-letters .quiet { opacity: .3; }
.l-codes b { display: grid; place-items: center; height: calc(var(--cell) * .82); margin: 0 var(--space-1); border: 1.5px solid var(--color-text-accent);
  border-radius: var(--radius-lg); background: color-mix(in srgb, var(--color-text-accent) 42%, transparent); color: var(--color-text-primary);
  box-shadow: 0 0 1.1rem color-mix(in srgb, var(--color-text-accent) 45%, transparent); font: 600 calc(var(--cell) * .5)/1 var(--font-mono); }
.l-codes .odd { border-color: var(--color-border-above); background: color-mix(in srgb, var(--color-border-above) 24%, transparent);
  color: var(--color-text-above); box-shadow: 0 0 1.4rem color-mix(in srgb, var(--color-border-above) 60%, transparent); }
/* where a cell comes from, when it drops into place: its letter stands this many cells to its side, a row away */
.l-codes .from-1 { --from: -1; }
.l-codes .from0 { --from: 0; }
.l-codes .from1 { --from: 1; }
.l-codes .from2 { --from: 2; }
.l-name--over { --drop: calc(var(--cell) * -1.1); }
.l-name--under { --drop: calc(var(--cell) * 1.1); }

/* The last screen's buttons are larger, the first carries the piercing star's mark, and both lift under the
   pointer. The star itself, which the scene flies to that button, shows only with the scene. */
.l-ch--dawn .hero-actions .button { padding: var(--space-6) var(--space-7); font-size: 1.0625rem; transition: transform .18s; }
.l-ch--dawn .hero-actions .button:hover { transform: translateY(-2px); }
.l-ch--dawn .button:not(.secondary) { position: relative; overflow: hidden; }
.l-ch--dawn .button:not(.secondary)::before { transition: transform .4s; }   /* the mark itself: star.css */
.l-ch--dawn .button:not(.secondary):hover::before { transform: rotate(180deg); }

.l-stage { display: none; position: fixed; inset: 0; z-index: 0; background: var(--color-bg-page); }
.l-sky, .l-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.l-sky--night { background: var(--l-poster-night) center / cover no-repeat; }
.l-sky--dawn { background: var(--l-poster-dawn) center / cover no-repeat; opacity: 0; }
.l-canvas { display: none; }

/* Level 2: the stage is the sky. The eye's and the ear's chapters are tall and hold what they show in the window
   while it plays: in the eye's the swapped letters catch fire, then go back to their places; in the ear's the
   letters that are not sounded go faint, the others drop into their cells, and the cells then show which agree.
   Each readout comes last. The ear's chapter, the night's last, fades as it leaves (to `exit 40%`), and the day
   starts where that ends: the last chapter's `entry 40%` is the same moment of the scroll, since the one chapter
   follows the other. landing.js asks for this same @supports condition before it starts the scene. */
@media (prefers-reduced-motion: no-preference) {
  @supports ((animation-timeline: scroll()) and (animation-range: 0% 100%)) {
    :root:has(.journey) { timeline-scope: --l-last; }
    .journey .l-stage { display: block; }
    .journey .l-ch { background: none; }
    .journey .l-ch--dawn { view-timeline: --l-last block; }
    .journey .l-sky--dawn { animation: l-dawn linear both; animation-timeline: --l-last; animation-range: entry 40% entry 95%; }

    .journey .l-ch--eye, .journey .l-ch--ear { min-height: 170svh; padding-block: 0; }
    .journey .l-ch--eye { view-timeline: --l-eye block; }
    .journey .l-ch--ear { view-timeline: --l-ear block; }
    .journey :is(.l-ch--eye, .l-ch--ear) .l-copy { margin-block: 14svh 0; }
    .journey .l-show { position: sticky; top: 0; align-self: flex-start; height: 100svh; }
    /* :where, so that the rules below, which name each animation and its range, always win */
    .journey :where(.l-ch--eye :is(.l-sw, .l-sw i, .l-readout)) { animation: linear both; animation-timeline: --l-eye; }
    .journey :where(.l-ch--ear :is(.l-letters .quiet, .l-codes b, .l-readout, .l-copy, .l-show)) { animation: linear both; animation-timeline: --l-ear; }
    .journey .l-sw { animation-name: l-unlit; animation-range: contain 24% contain 32%; }
    .journey .l-sw i:first-child { animation-name: l-back-over; }
    .journey .l-sw i:last-child { animation-name: l-back-under; }
    .journey .l-sw i { animation-range: contain 44% contain 58%; }
    .journey .l-ch--eye .l-readout { animation-name: l-in; animation-range: contain 62% contain 74%; }
    .journey .l-letters .quiet { animation-name: l-sounded; animation-range: contain 2% contain 30%; }
    .journey .l-codes b { animation-name: l-drop, l-plain; }
    .journey .l-codes b:nth-child(1) { animation-range: contain 2% contain 14%, contain 46% contain 58%; }
    .journey .l-codes b:nth-child(2) { animation-range: contain 8% contain 20%, contain 46% contain 58%; }
    .journey .l-codes b:nth-child(3) { animation-range: contain 14% contain 26%, contain 46% contain 58%; }
    .journey .l-codes b:nth-child(4) { animation-range: contain 20% contain 32%, contain 46% contain 58%; }
    .journey .l-codes b:nth-child(5) { animation-range: contain 26% contain 38%, contain 46% contain 58%; }
    .journey .l-ch--ear .l-readout { animation-name: l-in; animation-range: contain 62% contain 74%; }
    .journey .l-ch--ear :is(.l-copy, .l-show) { animation-name: l-gone; animation-range: exit 8% exit 40%; }
  }
  @media (min-width: 48rem) {
    @supports ((animation-timeline: scroll()) and (animation-range: 0% 100%)) {
      .journey :is(.l-ch--eye, .l-ch--ear) .l-copy { position: sticky; top: 20svh; margin-block: 20svh; }
    }
  }
}
@keyframes l-dawn { to { opacity: 1; } }
@keyframes l-in { from { opacity: 0; translate: 0 .4em; } }
@keyframes l-gone { to { opacity: 0; } }
@keyframes l-unlit { from { color: inherit; text-shadow: inherit; } }
@keyframes l-back-over { 50% { translate: .5ch -.5em; } to { translate: 0 0; } }
@keyframes l-back-under { 50% { translate: -.5ch .5em; } to { translate: 0 0; } }
@keyframes l-sounded { from { opacity: 1; } }
/* a code cell comes from its letter, and is plain until the two codes are compared */
@keyframes l-drop { from { opacity: 0; translate: calc(var(--from) * var(--cell)) var(--drop); } }
@keyframes l-plain { from { border-color: color-mix(in srgb, var(--color-text-primary) 55%, transparent); background: transparent;
  color: var(--color-text-primary); box-shadow: none; } }
@keyframes l-settle { from { opacity: 0; transform: perspective(70rem) rotateX(12deg) translateY(2.5rem) scale(.97); } }

/* Level 3, set by landing.js once the scene has drawn its first frame: the canvas covers the posters, and the
   chapters grow tall enough to travel through. */
.has-scene .journey .l-stage { display: block; }
.has-scene .journey .l-canvas { display: block; }
.has-scene .journey .l-ch { background: none; }
.has-scene .journey .l-ch--shape, .has-scene .journey .l-ch--check { min-height: 170svh; }
.has-scene .journey .l-ch--line { min-height: 150svh; padding-top: 62svh; }
/* The eye's sentence is first written by the names' dust, which the scene draws; the page's own letters take the
   dust's place as the scene says (--l-formed, 0 to 1). */
.has-scene .l-test { opacity: var(--l-formed, 1); }
/* The last chapter is tall and its card stays in place, on every screen, while the day breaks behind it. The card
   comes with the day: it settles into place over the same scroll as the scene's daybreak (`entry 50%` is the
   chapter's top at the middle of the window, journey 6), after a moment of clear sky, and lets more of the day
   through. */
.has-scene .journey .l-ch--dawn { min-height: 160svh; align-items: flex-start; }
.has-scene .journey .l-ch--dawn .l-copy { position: sticky; top: 18svh; margin-bottom: 0; }
.has-scene .journey .l-ch--dawn .l-card { background: color-mix(in srgb, var(--color-bg-surface) 82%, transparent); transform-origin: 50% 100%;
  animation: l-settle linear both; animation-timeline: --l-last; animation-range: entry 50% entry 95%; }
/* The star's flight to the first button (the star's look, its placing and the button's mark and ring: star.css,
   star.js). The scene flies it with the scroll, and tells the page how far its mark has come into the button
   (--l-landed, 0 to 1) and its ring opened (--l-ring, 0 to 1). */
.has-scene .day-star { display: block; }
.has-scene .l-ch--dawn .button:not(.secondary) { --star-landed: var(--l-landed, 1); --star-ring: var(--l-ring, 1);
  scale: calc(1 + .03 * sin(var(--l-ring, 1) * 3.1416)); }
.has-scene .l-ch--dawn .button:not(.secondary)::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  translate: calc(-130% + var(--l-ring, 1) * 260%) 0; background: linear-gradient(105deg, transparent 35%, color-mix(in srgb, var(--color-text-on-accent) 55%, transparent) 50%, transparent 65%); }
/* On wide screens the copy stays put while the scene plays beside it; on phones it scrolls away and leaves the
   scene the whole screen. */
@media (min-width: 48rem) {
  .has-scene .journey .l-ch--shape .l-copy, .has-scene .journey .l-ch--check .l-copy { position: sticky; top: 20svh; }
}
.has-scene .l-scene-only { display: block; }
.has-scene .l-static-only { display: none; }
/* The scene shows the names itself; the list stays for screen readers. */
.has-scene .l-names { position: absolute; width: 1px; height: 1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 47.99rem) {
  /* the line's card is as wide as the scene's list here, so it comes later, once the list stands above its line;
     and the chapter has no shade over that list: its own text is all on the card */
  .has-scene .journey .l-ch--line { padding-top: 100svh; }
  .has-scene .journey .l-ch--line::before { content: none; }
  .l-ch--hero { align-items: flex-start; padding-top: var(--space-8); }
  .l-ch.in-dark::before { background: linear-gradient(color-mix(in srgb, var(--color-bg-page) 85%, transparent) 0,
    color-mix(in srgb, var(--color-bg-page) 60%, transparent) 45%, transparent 80%); }
  /* after the first chapter a shade comes in softly, with no edge across what the scene shows above it */
  .l-ch.in-dark:not(.l-ch--hero)::before { mask-image: linear-gradient(transparent, var(--color-bg-page) 16vh); }
  .l-ch.in-dark.l-ch--ear::before { mask-image: linear-gradient(transparent, var(--color-bg-page) 16vh calc(100% - 75svh), transparent calc(100% - 10svh)); }   /* and still ends softly */
}
