/* The film. The picture is one canvas behind everything; the page above it is nine tall
   sections, each with a title, and scrolling through them drives the picture. Three of them,
   about building a backend, also hold a panel to read.
   The palette, the type, a sample of code and the bar at the top are in base.css. */

html { background: var(--dark); color: var(--light); scroll-snap-type: y proximity; }
body { margin: 0; font-family: var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; }

.screen { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
html:not(.playing) .screen, html:not(.playing) .progress, html:not(.playing) .cue { display: none; }

/* The way to the shots about building, from the first screen. */
.corner a.lit { color: var(--light); }
.corner a.lit::before { content: ""; display: inline-block; width: 0.38rem; height: 0.38rem; margin-right: 0.55rem; border-radius: 50%; background: var(--ember); box-shadow: 0 0 0.6rem var(--ember); vertical-align: 0.08em; }
.corner a.lit:hover { color: var(--ember); }

/* ---------- The shots and their titles ---------- */

.shot { height: 135vh; scroll-snap-align: start; }
.shot:last-child { height: 100vh; height: 100svh; }
.title { position: sticky; top: 0; height: 100vh; height: 100svh; display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start; padding: 0 var(--edge) clamp(4.5rem, 13vh, 9rem); pointer-events: none; }
.title > * { pointer-events: auto; }
.title h1, .title h2 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: clamp(2.5rem, 6.4vw, 6.6rem); line-height: 1; letter-spacing: -0.025em; max-width: 13ch; text-wrap: balance; text-shadow: 0 0 2.5rem rgba(7, 6, 5, 0.9); }
.title p { margin: 1.3rem 0 0; max-width: 31ch; font-size: clamp(1rem, 1.25vw, 1.2rem); line-height: 1.5; color: var(--dim); text-shadow: 0 0 1.2rem var(--dark); }

/* The corner a title sits in is a little darker than the picture, so the words always read. */
.playing .shot:not(.end) .title::before { content: ""; position: absolute; left: 0; bottom: 0; width: min(100%, 62rem); height: 75%; background: radial-gradient(ellipse at 0% 100%, rgba(7, 6, 5, 0.86), rgba(7, 6, 5, 0.5) 45%, transparent 72%); opacity: 0; transition: opacity 1.2s; pointer-events: none; z-index: -1; }
.playing .shot.on .title::before { opacity: 1; }
.title { isolation: isolate; }

/* A title comes into focus as its shot arrives, and leaves upwards. */
.playing .title > * { opacity: 0; filter: blur(14px); transform: translateY(1.4rem); transition: opacity 0.9s ease, filter 1.1s ease, transform 1.3s cubic-bezier(0.2, 0.7, 0.2, 1); }
.playing .shot.on .title > * { opacity: 1; filter: none; transform: none; }
.playing .shot.on .title > :nth-child(2) { transition-delay: 0.25s; }
.playing .shot.on .title > :nth-child(3) { transition-delay: 0.5s; }
/* What is out of sight is out of reach, for the pointer and for the Tab key. */
.playing .shot:not(.on) .title > * { pointer-events: none; visibility: hidden; transition: opacity 0.9s ease, filter 1.1s ease, transform 1.3s cubic-bezier(0.2, 0.7, 0.2, 1), visibility 0s 1s; }
.playing .shot.past .title > * { transform: translateY(-1.4rem); }

.figure h2 { font-size: clamp(5.5rem, 19vw, 17rem); letter-spacing: -0.045em; max-width: none; line-height: 0.86; }
.figure h2 small { font-size: 0.3em; letter-spacing: 0; color: var(--dim); }
.figure p { max-width: 36ch; }

.end .title { align-items: center; justify-content: flex-start; text-align: center; padding-top: clamp(6rem, 17vh, 11rem); padding-bottom: 0; }
.end h2 { max-width: 16ch; font-size: clamp(2.3rem, 5vw, 5rem); }
.more { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem 2.2rem; max-width: none !important; margin-top: 2.6rem !important; }
.more a { color: var(--light); text-decoration: none; padding-bottom: 0.3rem; border-bottom: 1px solid rgba(241, 232, 218, 0.35); transition: border-color 0.3s, color 0.3s; }
.more a:hover { color: var(--ember); border-color: var(--ember); }

/* The one thing to touch. */
.switch { margin-top: 1.9rem; padding: 0.85rem 1.4rem; font: 500 0.95rem/1 var(--mono); color: var(--light); background: rgba(241, 232, 218, 0.06); border: 1px solid rgba(241, 232, 218, 0.45); border-radius: 999px; cursor: pointer; transition: background 0.3s, border-color 0.3s, color 0.3s; }
.switch:hover { background: rgba(241, 232, 218, 0.14); border-color: var(--light); }
.switch[aria-pressed="true"] { color: var(--ember); border-color: var(--ember); background: rgba(255, 134, 72, 0.08); }
html:not(.playing) .switch { display: none; }

/* ---------- Building a backend: three shots that also hold something to read ---------- */

/* A panel is real text over the picture: the commands, the repository, and what it serves.
   It comes into focus with its shot's title and leaves with it. */
.playing .panel { position: fixed; z-index: 2; right: calc(var(--edge) + 1.9rem); top: calc(50% + 1.2rem); translate: 0 -50%; width: min(41rem, 50vw); opacity: 0; filter: blur(14px); transform: translateY(1.4rem); visibility: hidden; transition: opacity 0.9s ease, filter 1.1s ease, transform 1.3s cubic-bezier(0.2, 0.7, 0.2, 1), visibility 0s 1s; }
.playing .shot.on .panel { opacity: 1; filter: none; transform: none; visibility: visible; transition-delay: 0.35s, 0.35s, 0.35s, 0s; }
.playing .shot.past .panel { transform: translateY(-1.4rem); }
/* The picture behind a panel is a little darker, as it is behind a title. */
.playing .panel::before { content: ""; position: absolute; inset: -4rem -5rem; z-index: -1; background: radial-gradient(closest-side, color-mix(in srgb, var(--dark) 82%, transparent), color-mix(in srgb, var(--dark) 55%, transparent) 60%, transparent); pointer-events: none; }
.build .title h2 { max-width: 10ch; }
.build .title p { max-width: 30ch; }
.panel h3 { margin: 0; font: 500 0.7rem/1.3 var(--sans); letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim); }
.panel p { margin: 0; font-size: 0.9rem; line-height: 1.55; color: var(--dim); }
.panel pre { margin: 0; }
.panel a { color: var(--light); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.22em; text-decoration-color: var(--ember); transition: color 0.3s; }
.panel a:hover { color: var(--ember); }

/* Shot 4: three commands, numbered as the reading page numbers its chapters. */
.commands { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.9rem; counter-reset: command; }
.commands li { position: relative; padding-left: 4.6rem; counter-increment: command; }
.commands li::before { content: counter(command, decimal-leading-zero); position: absolute; left: 0; top: -0.15rem; font: 400 2.7rem/1 var(--serif); letter-spacing: -0.04em; color: transparent; -webkit-text-stroke: 1px color-mix(in srgb, var(--light) 45%, transparent); }
.commands h3 { margin-bottom: 0.7rem; }
.commands pre { padding: 0; font-size: 0.84rem; }
.commands pre::before { content: "$"; top: 0.82rem; left: 1.1rem; width: auto; height: auto; background: none; font: inherit; color: var(--quiet); }
.commands pre::after { content: none; }
.commands pre > code { padding: 0.82rem 5rem 0.82rem 2.4rem; }
/* A long command passes under the copy button, so the button has the window's own dark behind it. */
.commands .copy { top: 0.5rem; background: color-mix(in srgb, var(--floor) 45%, var(--dark)); box-shadow: -0.6rem 0 0.6rem color-mix(in srgb, var(--floor) 45%, var(--dark)), 0.5rem 0 0 color-mix(in srgb, var(--floor) 45%, var(--dark)); }
.commands p { margin-top: 0.8rem; max-width: 34rem; }

/* Shot 5: the repository, at a size that shows all of it. It is written from the top, as the slab is. */
#repository .panel { width: min(49.5rem, 55vw); }
.file { font-size: clamp(0.62rem, (100svh - 11.6rem) / 63.5, 0.8rem); line-height: 1.5; }
.file::after { content: "src/models/comment.rs" !important; letter-spacing: 0.06em; text-transform: none; }
@property --written { syntax: "<percentage>"; inherits: false; initial-value: 0%; }
.playing .file > code { --written: 0%; -webkit-mask-image: linear-gradient(#000 calc(var(--written) - 7%), transparent var(--written)); mask-image: linear-gradient(#000 calc(var(--written) - 7%), transparent var(--written)); }
.playing .shot.on .file > code { --written: 108%; transition: --written 2.2s cubic-bezier(0.3, 0.5, 0.3, 1) 0.6s; }

/* Shot 6: what that one definition serves, as branches of one line. */
.served { position: relative; padding-left: 1.7rem; }
.served::before { content: ""; position: absolute; left: 0.4rem; top: 2.3rem; bottom: 3.9rem; width: 1px; background: linear-gradient(var(--ember), var(--rim) 30%); transform-origin: top; }
.source { margin: 0 0 0.4rem -1.7rem !important; }
.source code { display: inline-block; padding: 0.55rem 0.9rem; font-size: 0.8rem; color: var(--light); background: color-mix(in srgb, var(--floor) 80%, var(--dark)); border: 1px solid var(--line); border-top-color: color-mix(in srgb, var(--ember) 60%, transparent); border-radius: 0.5rem; box-shadow: 0 1.2rem 2.4rem -1.4rem color-mix(in srgb, var(--ember) 50%, transparent); }
.served h3 { position: relative; margin: 1.25rem 0 0.35rem; color: var(--light); }
.served h3 span { margin-left: 0.5rem; color: var(--quiet); }
.served ul { list-style: none; margin: 0; padding: 0; }
.served li { position: relative; display: grid; grid-template-columns: 17.5rem minmax(0, 1fr); column-gap: 1.2rem; align-items: baseline; padding: 0.3rem 0; }
.served h3::before, .served li::before { content: ""; position: absolute; left: -1.3rem; top: 0.95rem; width: 0.9rem; height: 1px; background: var(--rim); }
.served h3::before { top: 0.45rem; background: var(--ember); }
.served li > code { padding: 0; font-size: 0.8rem; line-height: 1.5; color: var(--ink); background: none; white-space: nowrap; }
.served li > code b { font-weight: 400; color: var(--ember); }
.served li > span { font-size: 0.8rem; line-height: 1.5; color: var(--dim); }
.served li > span code { padding: 0.05em 0.3em; font-size: 0.92em; color: var(--ink); background: color-mix(in srgb, var(--light) 7%, transparent); white-space: nowrap; }
.also { margin-top: 1.3rem !important; font-size: 0.84rem !important; }
/* The line is drawn first, then each branch arrives in turn (film.js numbers them). */
.playing .served::before { transform: scaleY(0); transition: transform 0.4s; }
.playing .shot.on .served::before { transform: none; transition: transform 1.5s cubic-bezier(0.3, 0.5, 0.3, 1) 0.6s; }
.playing .served :is(h3, li, .also) { opacity: 0; transform: translateX(-0.6rem); transition: opacity 0.4s, transform 0.4s; }
.playing .shot.on .served :is(h3, li, .also) { opacity: 1; transform: none; transition: opacity 0.7s ease, transform 0.9s cubic-bezier(0.2, 0.7, 0.2, 1); transition-delay: calc(0.7s + var(--i, 0) * 0.09s); }

@media (prefers-reduced-motion: reduce) {
  .playing .file > code { -webkit-mask-image: none; mask-image: none; }
  .playing .served::before, .playing .served :is(h3, li, .also) { transform: none; opacity: 1; transition: none; }
}

/* ---------- Progress, and the cue to scroll ---------- */

.progress { position: fixed; z-index: 3; right: calc(var(--edge) - 0.9rem); top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; }
.progress a { display: block; padding: 0.55rem 0.9rem; }
.progress a::before { content: ""; display: block; margin-left: auto; width: 0.7rem; height: 1px; background: var(--dim); opacity: 0.55; transition: width 0.5s, opacity 0.5s, background 0.5s; }
.progress a:hover::before { opacity: 1; }
.progress a[aria-current]::before { width: 1.8rem; background: var(--light); opacity: 1; }

.cue { position: fixed; z-index: 3; left: 50%; bottom: 1.5rem; margin: 0; transform: translateX(-50%); font-size: 0.68rem; letter-spacing: 0.3em; text-transform: uppercase; color: var(--dim); transition: opacity 0.8s; }
.cue::after { content: ""; display: block; width: 1px; height: 1.6rem; margin: 0.6rem auto 0; background: linear-gradient(var(--dim), transparent); animation: fall 2.2s ease-in-out infinite; transform-origin: top; }
.cue.gone { opacity: 0; }
@keyframes fall { 0% { transform: scaleY(0); } 60% { transform: scaleY(1); opacity: 1; } 100% { transform: scaleY(1); opacity: 0; } }

/* ---------- A tall window ---------- */

@media (max-aspect-ratio: 4/5) {
  .title { padding-bottom: clamp(4rem, 11vh, 7rem); }
  .title h1, .title h2 { font-size: clamp(2.4rem, 11.5vw, 4rem); }
  .figure h2 { font-size: clamp(5rem, 27vw, 9rem); }
  .end h2 { font-size: clamp(2.2rem, 9vw, 3.4rem); }
  .progress { right: 0.2rem; }
  /* A panel takes the top of the window, over its title, and scrolls when it is longer. */
  .playing .panel, .playing #repository .panel { left: var(--edge); right: var(--edge); top: 4.4rem; translate: none; width: auto; max-height: calc(100svh - 4.4rem - 17.5rem); padding-bottom: 1.6rem; overflow: auto; scrollbar-width: none; -webkit-mask-image: linear-gradient(#000 calc(100% - 1.6rem), transparent); mask-image: linear-gradient(#000 calc(100% - 1.6rem), transparent); }
  .playing .panel::before { content: none; }
  .build .title h2, .build .title p { max-width: none; }
  .commands { gap: 1.2rem; }
  .commands li { padding-left: 0; }
  .commands li::before { position: static; display: inline-block; margin-right: 0.7rem; font-size: 1.5rem; vertical-align: -0.2rem; }
  .commands h3 { display: inline-block; }
  .commands p { font-size: 0.82rem; }
  .file { font-size: 0.62rem; }
  .served li { grid-template-columns: minmax(0, 1fr); }
  .served li > span { font-size: 0.74rem; }
}

/* ---------- Without the film (it has not started, or cannot) ---------- */

html:not(.playing) .shot, html:not(.playing) .title { height: auto; }
html:not(.playing) .title { position: static; padding: 3rem var(--edge); }
html:not(.playing) .corner { position: static; }
html:not(.playing) .panel { max-width: 52rem; padding: 0 var(--edge) 3rem; }
