/* Spec 021: book videos. Spec 108: they live with the book (its card on My library, The End, /app/video), with a badge on
   the cover while one is made, ready, or failed. Colours are tokens only (tokens.css). */

.video-page {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.video-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.video-make .button {
  min-height: var(--touch-kid);
}

/* The Family plan badge beside "Make a video" on Free. */
.video-badge {
  align-self: center;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.85rem;
  font-weight: 600;
}

/* Spec 108: the book's cover holds the video badge in its bottom-right corner. */
.book-cover {
  position: relative;
  display: block;
}

.book-cover img {
  display: block;
}

.video-dot {
  position: absolute;
  right: var(--space-2);
  bottom: var(--space-2);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--crayon-purple);
  box-shadow: var(--elevation-raised);
}

.video-dot[hidden] {
  display: none;
}

/* Being made: a ring that turns. */
.video-dot[data-state="making"] {
  border-color: var(--hairline);
  border-top-color: var(--crayon-purple);
  animation: video-ring 900ms linear infinite;
}

/* Ready: a filled teal badge with a tick. */
.video-dot[data-state="ready"] {
  background: var(--crayon-teal);
  border-color: var(--surface);
}

.video-dot[data-state="ready"]::after {
  content: "";
  position: absolute;
  left: 11px;
  top: 6px;
  width: 8px;
  height: 14px;
  border: solid var(--on-crayon);
  border-width: 0 3px 3px 0;
  rotate: 45deg;
}

/* Failed: a soft red mark; the button under the card tries again. */
.video-dot[data-state="failed"] {
  border-color: var(--danger);
}

.video-dot[data-state="failed"]::after {
  content: "!";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--danger);
  font-weight: 700;
}

@keyframes video-ring {
  to { rotate: 360deg; }
}

/* Spec 111: on a book card the video's mark is one of the small marks in the cover's top-left corner. */
.book-marks .video-dot {
  position: relative;
  right: auto;
  bottom: auto;
  width: 30px;
  height: 30px;
  box-shadow: none;
}

.book-marks .video-dot[data-state="ready"]::after {
  left: 9px;
  top: 4px;
  width: 7px;
  height: 12px;
}

/* The End's video button: a whole button, the kid size. Spec 141: a clapperboard beside its words. */
.end-video {
  min-height: var(--touch-kid);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.end-video[hidden] {
  display: none;
}

.end-video .icon {
  flex: none;
  width: 22px;
  height: 22px;
}

.end-video[data-state="failed"] {
  border-color: var(--danger);
}

.end-video[data-state="ready"] {
  border-color: var(--crayon-teal);
}

@media (prefers-reduced-motion: reduce) {
  .video-dot[data-state="making"] {
    animation: none;
    border-color: var(--crayon-purple);
    border-style: dashed;
  }
}

/* Spec 111 (the owner: "a slightly better animation of the video being created, but something the user can still
   leave"): the making screen. A little screen where a film strip of pages (the crayons) slides past and the dragon bobs;
   the progress bar follows the export's status. With reduced motion everything stands still and the words say the same. */
.video-making {
  align-items: stretch;
}

.video-reel {
  position: relative;
  overflow: hidden;
  height: 132px;
  border-radius: var(--radius-lg);
  background: var(--text);
}

/* Spec 139: the making screen is the TV-and-storybook screen the video will play on, lit like the video's opening: the
   wordmark over the night sky (its letters bobbing in turn), the film strip of pages along the bottom, the dragon. */
.video-tv-making {
  margin-top: var(--space-2);
}

.video-tv-making .video-reel {
  height: clamp(11rem, 46vw, 15rem);
  padding: 0;
  border-radius: var(--radius-lg);
  background: var(--gradient-tile-night);
}

.video-reel-word {
  position: absolute;
  top: 12%;
  left: 50%;
  translate: -50% 0;
  padding: 0;
  font-size: clamp(2rem, 9vw, 3.2rem);
  white-space: nowrap;
}

.video-reel-word span {
  display: inline-block;
  animation: video-letter 2.4s ease-in-out infinite;
}

.video-reel-word span:nth-child(2) { animation-delay: 0.12s; }
.video-reel-word span:nth-child(3) { animation-delay: 0.24s; }
.video-reel-word span:nth-child(4) { animation-delay: 0.36s; }
.video-reel-word span:nth-child(5) { animation-delay: 0.48s; }
.video-reel-word span:nth-child(6) { animation-delay: 0.6s; }

.video-tv-making .video-strip {
  top: auto;
  bottom: 14%;
}

.video-strip {
  position: absolute;
  top: 22px;
  left: 0;
  display: flex;
  gap: 14px;
  width: max-content;
  animation: video-film 6s linear infinite;
}

.video-frame {
  width: 72px;
  height: 56px;
  border-radius: 8px;
  border: 3px solid var(--surface);
}

.frame-1 { background: var(--crayon-yellow); }
.frame-2 { background: var(--crayon-pink); }
.frame-3 { background: var(--crayon-teal); }
.frame-4 { background: var(--crayon-blue); }
.frame-5 { background: var(--crayon-purple); }

.video-dragon {
  position: absolute;
  right: var(--space-3);
  bottom: -6px;
  width: 84px;
  height: auto;
  animation: video-bob 2.4s ease-in-out infinite;
}

.video-progress-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.video-progress {
  width: 100%;
  height: 14px;
  accent-color: var(--crayon-teal);
}

.video-step {
  margin: 0;
  font-weight: 700;
  font-size: var(--font-md);
}

.video-player {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 60vh;
  border-radius: var(--radius-sm);
  background: var(--text);
}

/* Spec 136 (the owner on build 31: "the video container should have a fun frame"): a rounded TV-and-storybook frame, a
   rainbow edge round the night sky's bezel, sparkles twinkling at its corners and the dragon peeking over its top. */
.video-tv {
  position: relative;
  margin-top: var(--space-6);
  padding: 7px;
  border-radius: var(--radius-xl);
  background: var(--gradient-rainbow);
  box-shadow: var(--elevation-raised);
}

.video-tv-bezel {
  position: relative;
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  background: var(--gradient-tile-night);
}

.video-tv-dragon {
  position: absolute;
  right: 1.6rem;
  top: -2.6rem;
  width: auto;
  height: 4rem;
  pointer-events: none;
  animation: friend-bob 3.4s ease-in-out infinite;
}

.video-tv-sparkle {
  position: absolute;
  color: var(--sky-star);
  pointer-events: none;
  animation: twinkle 2.6s ease-in-out infinite;
}

.video-tv-sparkle-a {
  left: -0.5rem;
  top: -0.8rem;
  width: 1.4rem;
  height: 1.4rem;
}

.video-tv-sparkle-b {
  left: 0.2rem;
  bottom: -0.6rem;
  width: 1rem;
  height: 1rem;
  animation-delay: 0.8s;
}

.video-tv-sparkle-c {
  right: -0.4rem;
  bottom: -0.7rem;
  width: 1.2rem;
  height: 1.2rem;
  animation-delay: 1.5s;
}

@media (prefers-reduced-motion: reduce) {
  .video-tv-dragon,
  .video-tv-sparkle {
    animation: none;
  }
}

/* Spec 149 (the owner on build 34: "you have to tap it to see the controls and play it"): the big ▶ in the middle of the
   video whenever it is not playing, in the app's colours (the accent disc in a surface ring), with "Watch again" beside it
   at the end (beside, so it stays clear of the browser's controls along the video's foot). It never moves by itself; it
   darkens under the pointer. */
.video-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-2);
  width: max-content;
  min-width: var(--touch-kid);
  min-height: var(--touch-kid);
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--on-accent);
  font: inherit;
  cursor: pointer;
}

.video-play-disc {
  flex: none;
  display: grid;
  place-items: center;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 4px solid var(--surface);
  background: var(--accent);
  box-shadow: var(--elevation-raised);
}

.video-play-disc .icon {
  width: 56px;
  height: 56px;
  margin-left: 4px;
}

/* A phone-width player is short: the disc stays well above the browser's control bar. */
@media (max-width: 480px) {
  .video-play-disc {
    width: 72px;
    height: 72px;
  }

  .video-play-disc .icon {
    width: 48px;
    height: 48px;
  }
}

.video-play:hover .video-play-disc {
  background: var(--accent-strong);
}

.video-play-again {
  max-width: 10rem;
  padding: 4px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  font-weight: 700;
  font-size: var(--font-md);
  text-align: center;
}

.video-downloads {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.video-downloads .button {
  min-height: var(--touch-kid);
  white-space: normal;
}

/* "Make it again": small and quiet, under Delete. */
.video-again {
  align-self: center;
  min-height: var(--touch-standard);
}

@keyframes video-film {
  to { translate: -430px 0; }
}

@keyframes video-bob {
  50% { translate: 0 -6px; }
}

/* Spec 139: a letter of the wordmark hops, then the next. */
@keyframes video-letter {
  0%, 60%, 100% { translate: 0 0; }
  30% { translate: 0 -0.18em; }
}

@media (prefers-reduced-motion: reduce) {
  .video-strip,
  .video-dragon {
    animation: none;
  }

  .video-reel-word span {
    animation: none;
  }
}

/* Spec 141: the sample's badges ("Sample" and "Family plan") over its player, and its lines under it. */
.video-sample-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
}

.video-sample-badges[hidden],
.video-sample-lines[hidden] {
  display: none;
}

.video-sample-badge {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--crayon-pink);
  color: var(--on-crayon);
  font-size: 0.85rem;
  font-weight: 800;
}

.video-sample-lines p {
  margin: 0 0 var(--space-1);
}

/* Spec 141 (the owner on build 32: "emphasize this to engage them to purchase to create videos"): the Family pitch, a
   friendly card: a pink clapperboard chip and its headline, the line, four points with crayon icons, "Watch a sample", the
   price and Get Family (then the two checkout buttons). */
.video-pitch {
  gap: var(--space-3);
}

.video-pitch:focus {
  outline: none;
}

.video-pitch:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.video-pitch-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.video-pitch-head h2 {
  margin: 0;
  font-size: var(--font-lg);
  line-height: 1.2;
}

.video-pitch-chip {
  flex: none;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--crayon-pink);
  color: var(--on-crayon);
}

.video-pitch-chip .icon {
  width: 28px;
  height: 28px;
}

.video-pitch > p {
  margin: 0;
}

.video-pitch-points {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.video-pitch-points li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.video-pitch-points .icon {
  flex: none;
  width: 24px;
  height: 24px;
}

.video-pitch-sample {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.video-pitch-sample[hidden],
.video-pitch-checkout[hidden] {
  display: none;
}

.video-pitch-sample .icon {
  width: 24px;
  height: 24px;
}

.video-pitch-price {
  margin: 0;
  text-align: center;
  font-weight: 700;
  font-size: var(--font-md);
}

.video-pitch-checkout {
  flex-wrap: wrap;
  gap: var(--space-2);
}
