/* The page borrows the look of the videos: white paper, dark ink, one accent, a rail on the left. */
:root {
  --paper: #ffffff;
  --ink: #1b2430;
  --muted: #5b6673;
  --accent: #2f5da8;
  --accent-soft: #e9eef7;
  --rule: #e3e6ea;
  --code: #f5f7fa;
  --cycle: 7.5s;
  --display: 'Lato', 'Avenir Next', 'Segoe UI', system-ui, sans-serif;
  --body: 'Open Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding-left: 14px;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.6 var(--body);
}

.rail {
  position: fixed;
  inset: 0 auto 0 0;
  width: 14px;
  background: var(--accent);
  transform-origin: top;
  animation: grow 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

/* Shown while orders are refused. It stays at the top of the window. */
.notice {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0;
  padding: 12px 40px;
  background: #fff4d6;
  border-bottom: 1px solid #e6c766;
  color: #5c4400;
  font-weight: 600;
  text-align: center;
}

.after-table {
  margin-top: 20px;
}

.hero,
main,
footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 40px;
}

/* Hero */

.hero {
  position: relative;
  padding-top: 88px;
  padding-bottom: 56px;
  overflow: hidden;
}

.arcs {
  position: absolute;
  top: 0;
  right: 0;
  width: 400px;
  height: 400px;
  pointer-events: none;
}

.arcs circle {
  fill: none;
  stroke: var(--accent-soft);
  stroke-width: 3;
  /* Each circle is given a length of 100 in the markup, so one dash is the whole circle. */
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation:
    draw 1.6s ease-out forwards,
    breathe 6s ease-in-out 1.6s infinite;
}

.arcs circle:nth-child(2) {
  animation-delay: 0.15s, 2.1s;
}
.arcs circle:nth-child(3) {
  animation-delay: 0.3s, 2.6s;
}
.arcs circle:nth-child(4) {
  animation-delay: 0.45s, 3.1s;
}

.chip-line {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 20px;
  color: var(--muted);
  font-family: var(--display);
  font-size: 20px;
  animation: rise 0.6s ease-out both;
}

.chip {
  padding: 2px 12px;
  border: 2px solid var(--accent);
  border-radius: 8px;
  color: var(--accent);
  font-weight: 700;
  font-size: 16px;
}

h1 {
  margin: 0 0 20px;
  font: 800 clamp(34px, 5.2vw, 60px) / 1.12 var(--display);
  letter-spacing: -0.01em;
}

.word {
  display: inline-block;
  animation: rise 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.word:nth-of-type(1) {
  animation-delay: 0.15s;
}
.word:nth-of-type(2) {
  animation-delay: 0.23s;
}
.word:nth-of-type(3) {
  animation-delay: 0.31s;
}
.word:nth-of-type(4) {
  animation-delay: 0.39s;
}
.word:nth-of-type(5) {
  animation-delay: 0.6s;
}
.word:nth-of-type(6) {
  animation-delay: 0.68s;
}
.word:nth-of-type(7) {
  animation-delay: 0.76s;
}
.word:nth-of-type(8) {
  animation-delay: 0.84s;
}
.word:nth-of-type(9) {
  animation-delay: 0.92s;
}

.lead {
  max-width: 640px;
  margin: 0 0 48px;
  color: var(--muted);
  font-size: 20px;
  animation: rise 0.6s ease-out 1.1s both;
}

/* The pipeline: a dot travels from the script to the link, and each step lights up as it passes. */

.pipeline {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  margin: 0;
  padding: 0;
  list-style: none;
  animation: rise 0.6s ease-out 1.3s both;
}

.pipeline::before {
  content: '';
  position: absolute;
  top: 21px;
  left: 10%;
  right: 10%;
  height: 2px;
  background: var(--rule);
}

.pipeline::after {
  content: '';
  position: absolute;
  top: 16px;
  left: 10%;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  border-radius: 50%;
  background: var(--accent);
  animation: travel var(--cycle) linear infinite;
}

.pipeline li {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 2px;
  text-align: center;
}

.node {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 8px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--paper);
  color: var(--accent);
  font: 700 17px var(--display);
  animation: light var(--cycle) ease-out infinite;
}

.pipeline li:nth-child(2) .node {
  animation-delay: calc(var(--cycle) * 0.2);
}
.pipeline li:nth-child(3) .node {
  animation-delay: calc(var(--cycle) * 0.4);
}
.pipeline li:nth-child(4) .node {
  animation-delay: calc(var(--cycle) * 0.6);
}
.pipeline li:nth-child(5) .node {
  animation-delay: calc(var(--cycle) * 0.8);
}

.pipeline b {
  font-family: var(--display);
  font-size: 18px;
}

.pipeline small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}

/* The progress line of a video: one part per step. A part fills while the dot is on its way to the next step. */

.progress {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-top: 40px;
}

.progress i {
  height: 4px;
  border-radius: 2px;
  background: var(--rule);
  overflow: hidden;
}

.progress i::after {
  content: '';
  display: block;
  height: 100%;
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(0);
  animation: var(--cycle) linear infinite;
}

.progress i:nth-child(1)::after {
  animation-name: fill-1;
}
.progress i:nth-child(2)::after {
  animation-name: fill-2;
}
.progress i:nth-child(3)::after {
  animation-name: fill-3;
}
.progress i:nth-child(4)::after {
  animation-name: fill-4;
}
.progress i:nth-child(5)::after {
  animation-name: fill-5;
}

/* Sections */

section {
  padding: 56px 0;
  border-top: 1px solid var(--rule);
}

.js .reveal {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity 0.7s ease-out,
    transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.js .reveal.is-visible {
  opacity: 1;
  transform: none;
}

h2 {
  position: relative;
  margin: 0 0 20px;
  padding-bottom: 12px;
  font: 800 34px/1.2 var(--display);
}

h2::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 4px;
  border-radius: 2px;
  background: var(--accent);
  transition: width 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) 0.25s;
}

.is-visible h2::after,
html:not(.js) h2::after {
  width: 64px;
}

h3 {
  margin: 32px 0 8px;
  font: 700 21px/1.3 var(--display);
}

.section-lead {
  max-width: 720px;
  margin: 0 0 28px;
  color: var(--muted);
}

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

code {
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--code);
  font: 0.88em var(--mono);
}

/* Themes */

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

.theme {
  --theme-accent: var(--accent);
  border: 1px solid var(--rule);
  border-radius: 12px;
  overflow: hidden;
  background: var(--paper);
  transition:
    transform 0.25s ease-out,
    box-shadow 0.25s ease-out;
}

.theme:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 30px rgb(27 36 48 / 12%);
}

.theme-pictures {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--theme-accent);
}

.theme-pictures img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* The scene fades in over the opening card and out again, a little later on each card. */
.theme-pictures img + img {
  animation: swap 9s ease-in-out infinite;
}
.theme:nth-child(2) img + img {
  animation-delay: 0.6s;
}
.theme:nth-child(3) img + img {
  animation-delay: 1.2s;
}
.theme:nth-child(4) img + img {
  animation-delay: 1.8s;
}
.theme:nth-child(5) img + img {
  animation-delay: 2.4s;
}
.theme:nth-child(6) img + img {
  animation-delay: 3s;
}

.theme-text {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-top: 4px solid var(--theme-accent);
}

.theme-text b {
  flex: 1;
  font: 700 17px/1.3 var(--display);
}

/* How to use it */

.steps {
  display: grid;
  /* A column may be narrower than its longest line of code, which then scrolls inside its own box. */
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  position: relative;
  padding-left: 64px;
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 28px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--paper);
  font: 700 19px var(--display);
}

.steps p {
  max-width: 680px;
  margin: 0 0 12px;
  color: var(--muted);
}

.code {
  position: relative;
  margin: 0 0 8px;
  padding: 16px 18px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--code);
  overflow-x: auto;
  font: 14px/1.55 var(--mono);
}

.code code {
  padding: 0;
  background: none;
  font-size: inherit;
}

.copy {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--paper);
  color: var(--muted);
  font: 13px var(--body);
  cursor: pointer;
}

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

.fields {
  width: 100%;
  margin-top: 32px;
  border-collapse: collapse;
}

.fields caption {
  padding-bottom: 8px;
  text-align: left;
  font: 700 21px var(--display);
}

.fields th,
.fields td {
  padding: 10px 12px 10px 0;
  border-top: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

.fields th {
  width: 150px;
  font-weight: 400;
}

.fields td {
  color: var(--muted);
}

/* The script */

.script-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}

.paper {
  margin: 0;
  padding: 22px 24px;
  border: 1px solid var(--rule);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  box-shadow: 0 10px 24px rgb(27 36 48 / 7%);
  white-space: pre-wrap;
  font: 14px/1.7 var(--mono);
}

.paper .key {
  color: var(--accent);
  font-weight: 700;
}

.paper .dashes {
  color: var(--muted);
}

.paper .text {
  font: 16px/1.65 var(--body);
}

.notes {
  margin: 0;
}

.notes dt {
  margin-top: 14px;
  font-weight: 600;
}

.notes dt:first-child {
  margin-top: 0;
}

.notes dd {
  margin: 2px 0 0;
  color: var(--muted);
}

.scene-types {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.scene-type {
  padding: 12px 14px;
  border: 1px solid var(--rule);
  border-radius: 10px;
}

.scene-type code {
  color: var(--accent);
  font-weight: 700;
}

.scene-type small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.scene-type p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

/* Voices */

.voice-rows {
  display: grid;
  gap: 12px;
}

.voice-row {
  display: grid;
  grid-template-columns: 56px minmax(120px, 1fr) minmax(0, 2fr);
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border: 1px solid var(--rule);
  border-radius: 12px;
}

/* A voice speaking: bars that rise and fall, each at its own pace. */
.bars {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 36px;
}

.bars i {
  width: 6px;
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transform: scaleY(0.3);
  animation: speak 1.1s ease-in-out infinite;
}

.bars i:nth-child(2) {
  animation-duration: 0.8s;
  animation-delay: 0.1s;
}
.bars i:nth-child(3) {
  animation-duration: 1.3s;
  animation-delay: 0.25s;
}
.bars i:nth-child(4) {
  animation-duration: 0.95s;
  animation-delay: 0.05s;
}

.voice-row b {
  font: 700 21px var(--display);
}

.voice-row small {
  display: block;
  color: var(--muted);
}

.voice-names {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.voice-name {
  padding: 4px 12px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-size: 15px;
}

.voice-name.is-default {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* Try it */

.try {
  display: grid;
  gap: 16px;
  max-width: 820px;
}

.try label {
  display: grid;
  gap: 6px;
  font-weight: 600;
}

.try label small {
  color: var(--muted);
  font-weight: 400;
}

.try-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font: 15px var(--body);
}

textarea {
  resize: vertical;
  font: 13px/1.5 var(--mono);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 3px solid var(--accent-soft);
}

button[type='submit'] {
  justify-self: start;
  padding: 12px 26px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--paper);
  font: 700 17px var(--display);
  cursor: pointer;
  transition: transform 0.15s ease-out;
}

button[type='submit']:hover {
  transform: translateY(-2px);
}

button[type='submit']:disabled {
  opacity: 0.55;
  cursor: progress;
  transform: none;
}

.try-status {
  min-height: 1.6em;
  margin: 0;
  color: var(--muted);
}

.try-status.is-working::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}

.try-status.is-error {
  color: #a32222;
}

video {
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--ink);
}

.try-link {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 15px;
}

footer {
  padding-top: 28px;
  padding-bottom: 48px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 15px;
}

/* Motion */

@keyframes grow {
  from {
    transform: scaleY(0);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
}

@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes breathe {
  50% {
    stroke: #d5dff0;
  }
}

/* The dot crosses in four fifths of the cycle, one step per fifth, and rests on the link before it starts again. */
@keyframes travel {
  0% {
    left: 10%;
    opacity: 1;
  }
  80% {
    left: 90%;
    opacity: 1;
  }
  96%,
  100% {
    left: 90%;
    opacity: 0;
  }
}

/* A step lights up when the dot reaches it, a fifth of the cycle apart, and cools down slowly. */
@keyframes light {
  0%,
  100% {
    background: var(--paper);
    color: var(--accent);
    transform: scale(1);
  }
  2% {
    background: var(--accent);
    color: var(--paper);
    transform: scale(1.18);
  }
  22% {
    background: var(--accent-soft);
    color: var(--accent);
    transform: scale(1);
  }
}

@keyframes fill-1 {
  0% {
    transform: scaleX(0);
  }
  20%,
  96% {
    transform: scaleX(1);
    opacity: 1;
  }
  100% {
    transform: scaleX(1);
    opacity: 0;
  }
}
@keyframes fill-2 {
  0%,
  20% {
    transform: scaleX(0);
  }
  40%,
  96% {
    transform: scaleX(1);
    opacity: 1;
  }
  100% {
    transform: scaleX(1);
    opacity: 0;
  }
}
@keyframes fill-3 {
  0%,
  40% {
    transform: scaleX(0);
  }
  60%,
  96% {
    transform: scaleX(1);
    opacity: 1;
  }
  100% {
    transform: scaleX(1);
    opacity: 0;
  }
}
@keyframes fill-4 {
  0%,
  60% {
    transform: scaleX(0);
  }
  80%,
  96% {
    transform: scaleX(1);
    opacity: 1;
  }
  100% {
    transform: scaleX(1);
    opacity: 0;
  }
}
@keyframes fill-5 {
  0%,
  80% {
    transform: scaleX(0);
  }
  96% {
    transform: scaleX(1);
    opacity: 1;
  }
  100% {
    transform: scaleX(1);
    opacity: 0;
  }
}

@keyframes swap {
  0%,
  38% {
    opacity: 0;
  }
  50%,
  88% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes speak {
  50% {
    transform: scaleY(1);
  }
}

@keyframes pulse {
  50% {
    opacity: 0.25;
    transform: scale(0.7);
  }
}

@media (max-width: 760px) {
  .hero,
  main,
  footer {
    padding: 0 20px;
  }
  .hero {
    padding-top: 56px;
    padding-bottom: 40px;
  }
  .arcs {
    width: 240px;
    height: 240px;
  }
  .pipeline small {
    display: none;
  }
  .steps li {
    padding-left: 52px;
  }
  .steps li::before {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }
  .script-layout,
  .try-options {
    grid-template-columns: 1fr;
  }
  .voice-row {
    grid-template-columns: 56px 1fr;
  }
  .voice-names {
    grid-column: 1 / -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
  .arcs circle {
    stroke-dashoffset: 0;
  }
  .js .reveal {
    opacity: 1;
    transform: none;
  }
  .theme-pictures img + img {
    opacity: 0;
  }
}
