@font-face {
  font-family: 'Wordmark';
  src: url('fonts/jetbrains-mono-800-wordmark.woff2') format('woff2');
  font-weight: 800;
  font-display: swap;
}

/* Each token lists its light value, then its dark one. The film reel and
   strips stay dark in both themes, like real film. */
:root {
  color-scheme: light dark;
  --bg: light-dark(#ffffff, #0a0a0a);
  --panel: light-dark(#fafafa, #141414);
  --line: light-dark(#e5e5e5, #262626);
  --text: light-dark(#0a0a0a, #f5f5f5);
  --soft: light-dark(#404040, #d4d4d4);
  --muted: light-dark(#6b6b6b, #a3a3a3);
  /* Monochrome: the accent is just the text color, so the videos carry the color. */
  --accent: var(--text);
  --code-bg: light-dark(#f4f4f4, #111111);
  --film-accent: #ffffff;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --sprocket: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='14'%3E%3Crect x='8' y='2' width='12' height='10' rx='2.5' fill='%230a0a0a'/%3E%3C/svg%3E");
}

:root[data-theme='light'] {
  color-scheme: light;
}

:root[data-theme='dark'] {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    16px/1.6 system-ui,
    -apple-system,
    'Segoe UI',
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-underline-offset: 3px;
}

code,
pre {
  font-family: var(--mono);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 10;
  background: var(--accent);
  color: var(--bg);
  font: 700 14px var(--mono);
  padding: 10px 14px;
  border-radius: 8px;
}

.skip-link:focus {
  top: 16px;
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Masthead with the scrolling film reel. */

.masthead {
  position: relative;
  /* clip, not hidden, so focus or scrollIntoView can never scroll the reel sideways. */
  overflow: clip;
  padding-bottom: 8px;
}

.masthead-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 36px;
  position: relative;
  z-index: 1;
}

.wordmark {
  font:
    800 clamp(44px, 8.5vw, 104px) / 1 'Wordmark',
    var(--mono);
  letter-spacing: -0.02em;
  margin: 0;
}

.wordmark span {
  color: var(--muted);
}

nav ul {
  display: flex;
  gap: 20px;
  list-style: none;
  margin: 0;
  padding: 0;
  font: 600 14px var(--mono);
}

nav a {
  color: var(--soft);
  text-decoration: none;
}

nav a:hover {
  color: var(--accent);
}

.masthead-actions {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.theme-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  background: var(--panel);
}

.theme-toggle button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.theme-toggle button:hover {
  color: var(--text);
}

.theme-toggle button[aria-pressed='true'] {
  background: var(--text);
  color: var(--bg);
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.reel {
  --frame: clamp(120px, 16vw, 196px);
  --gap: 16px;
  position: relative;
  margin: 28px 0 24px;
  padding: 30px 0;
  background: #141414;
  box-shadow: 0 24px 48px rgb(0 0 0 / 40%);
}

.reel::before,
.reel::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 14px;
  background: var(--sprocket) repeat-x;
}

.reel::before {
  top: 5px;
}

.reel::after {
  bottom: 5px;
}

.reel-track {
  display: flex;
  width: max-content;
  animation: reel-scroll 80s linear infinite;
}

.reel:hover .reel-track {
  animation-play-state: paused;
}

.reel-frame {
  position: relative;
  flex: none;
  width: var(--frame);
  aspect-ratio: 1;
  margin-right: var(--gap);
  background: #000;
}

.reel-frame video {
  display: block;
  width: 100%;
  height: 100%;
}

.reel-frame::after {
  content: attr(data-number);
  position: absolute;
  bottom: -11px;
  left: 2px;
  font: 600 9px/1 var(--mono);
  letter-spacing: 0.1em;
  color: #737373;
}

@keyframes reel-scroll {
  to {
    transform: translateX(-50%);
  }
}

.motion-off .reel-track {
  animation-play-state: paused;
}

.intro {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.lede {
  font-size: 20px;
  color: var(--soft);
  max-width: 36em;
  margin: 0;
}

.buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.button {
  font: 600 14px var(--mono);
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
  background: var(--panel);
  cursor: pointer;
}

.button.primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

/* Sections. */

section.wrap {
  padding-top: 40px;
  padding-bottom: 40px;
}

main:focus {
  outline: none;
}

h2 {
  font: 600 14px var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin: 0 0 20px;
}

.section-note {
  color: var(--muted);
  font-size: 14px;
  margin: -8px 0 24px;
}

pre {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.7;
  margin: 0;
}

pre .c {
  color: var(--muted);
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.toolbar h2 {
  margin: 0;
}

.toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  background: var(--panel);
}

.toggle button {
  font: 600 12px var(--mono);
  border: 0;
  background: none;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.toggle button[aria-pressed='true'] {
  background: var(--text);
  color: var(--bg);
}

/* Gallery cards. */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 28px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  scroll-margin-top: 24px;
}

.stage {
  position: relative;
  aspect-ratio: 1;
  background: #000;
}

.stage video {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.scrub-preview {
  position: absolute;
  inset: 0;
  background-image: var(--scrub, var(--sprite));
  background-size: calc(var(--sprite-columns) * 100%)
    calc(var(--sprite-rows) * 100%);
  pointer-events: none;
}

.spinner {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgb(255 255 255 / 25%);
  border-top-color: var(--film-accent);
  opacity: 0;
  transition: opacity 0.2s;
  animation: spin 0.8s linear infinite;
  pointer-events: none;
}

.stage.is-loading .spinner {
  opacity: 1;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.card-body {
  padding: 16px 18px 18px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.card h3 {
  font: 700 18px var(--mono);
  margin: 0;
}

.meta {
  font: 12px var(--mono);
  color: var(--muted);
  white-space: nowrap;
}

.blurb {
  margin: 10px 0 6px;
  color: var(--soft);
  font-size: 15px;
}

.credit {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

.film {
  position: relative;
  margin: 14px -18px 0;
  padding: 16px 0;
  background:
    var(--sprocket) 0 1px / 14px 7px repeat-x,
    var(--sprocket) 0 calc(100% - 1px) / 14px 7px repeat-x,
    #050505;
  cursor: ew-resize;
  touch-action: none;
  user-select: none;
}

.film:focus-visible {
  outline-color: var(--film-accent);
  outline-offset: -2px;
  border-radius: 0;
}

.cells {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 3px;
  padding: 0 3px;
}

.cell {
  aspect-ratio: 1;
  background-color: #1a1a1a;
  background-size: calc(var(--sprite-columns) * 100%)
    calc(var(--sprite-rows) * 100%);
}

.card.sprite-ready .cell {
  background-image: var(--sprite);
}

.card:not(.sprite-ready) .cell {
  background-image: linear-gradient(
    100deg,
    #1a1a1a 30%,
    #2a2a2a 50%,
    #1a1a1a 70%
  );
  background-size: 300% 100%;
  animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: 0 0;
  }
}

.playhead {
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--film-accent);
  box-shadow: 0 0 8px var(--film-accent);
  pointer-events: none;
}

.film-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font: 11px var(--mono);
  color: var(--muted);
  margin: 8px 0 0;
}

.actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 14px;
  flex-wrap: wrap;
}

.copy {
  font: 12px var(--mono);
  color: var(--muted);
  background: var(--code-bg);
  border: 1px solid var(--line);
  padding: 4px 8px;
  border-radius: 6px;
  cursor: copy;
}

.copy:hover {
  color: var(--text);
}

/* How it works: a four-step pipeline that stacks on narrow screens. */

.pipeline {
  --arrow: 40px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--arrow);
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: step;
}

.pipeline > li {
  position: relative;
  counter-increment: step;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 18px 20px;
}

.pipeline > li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute;
  top: 16px;
  right: 18px;
  font: 600 11px var(--mono);
  letter-spacing: 0.1em;
  color: var(--muted);
}

/* Arrow drawn in the gap after each step; it turns downward when stacked. */
.pipeline > li:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 100%;
  width: var(--arrow);
  height: 14px;
  margin-top: -7px;
  background: var(--accent);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 14'%3E%3Cpath d='M5 7h26' stroke='%23000' stroke-width='2' stroke-dasharray='4 3' stroke-linecap='round'/%3E%3Cpath d='M28 2l7 5-7 5' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    center / 100% 100% no-repeat;
}

.pipeline .icon {
  width: 40px;
  height: 40px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pipeline h3 {
  font: 700 16px var(--mono);
  margin: 12px 0 10px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.chips li {
  font: 12px/1.4 var(--mono);
  color: var(--soft);
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
}

.chips code {
  color: var(--accent);
}

@media (max-width: 900px) {
  .pipeline {
    grid-template-columns: 1fr;
    max-width: 520px;
    --arrow: 32px;
  }
  .pipeline > li:not(:last-child)::after {
    top: 100%;
    left: 50%;
    width: var(--arrow);
    height: 14px;
    margin: calc(var(--arrow) / 2 - 7px) 0 0 calc(var(--arrow) / -2);
    transform: rotate(90deg);
  }
}

/* FAQ: an intro column beside a divided accordion. */

.faq-section {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) 2.4fr;
  gap: 24px 56px;
  align-items: start;
}

.faq-intro p {
  color: var(--muted);
  font-size: 15px;
  margin: 0;
}

.faq {
  border-top: 1px solid var(--line);
}

.faq details {
  border-bottom: 1px solid var(--line);
}

.faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 4px;
  cursor: pointer;
  list-style: none;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary h3 {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
  margin: 0;
  transition: color 0.15s;
}

.faq summary:hover h3,
.faq details[open] summary h3 {
  color: var(--accent);
}

.faq-icon {
  position: relative;
  flex: none;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 50%;
  transition:
    transform 0.2s,
    border-color 0.15s;
}

.faq-icon::before,
.faq-icon::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 2px;
  margin: -1px 0 0 -5px;
  background: var(--text);
  border-radius: 1px;
}

.faq-icon::after {
  transform: rotate(90deg);
}

.faq summary:hover .faq-icon {
  border-color: var(--accent);
}

.faq details[open] .faq-icon {
  transform: rotate(45deg);
  border-color: var(--accent);
}

.faq details p {
  margin: 0;
  padding: 0 52px 22px 4px;
  color: var(--soft);
  max-width: 62ch;
}

/* Smoothly open answers where the browser supports animating to auto height. */
@supports (interpolate-size: allow-keywords) {
  .faq {
    interpolate-size: allow-keywords;
  }
  .faq details::details-content {
    height: 0;
    overflow: clip;
    transition:
      height 0.25s ease,
      content-visibility 0.25s allow-discrete;
  }
  .faq details[open]::details-content {
    height: auto;
  }
}

@media (max-width: 760px) {
  .faq-section {
    grid-template-columns: 1fr;
  }
}

footer {
  padding: 40px 24px 60px;
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 640px) {
  .lede {
    font-size: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  html:not(.motion-on) .reel-track {
    animation-play-state: paused;
  }
  .spinner,
  .card:not(.sprite-ready) .cell {
    animation: none;
  }
}
