/* The homepage's moving parts, loaded only on the homepage (landing.html's head block).
   Andrew, 2026-11-16: the first hero animation was "too visually heavy + complicated, and
   transition too quickly to process". This one is light and slow:
   - The hero card (_hero_demo.html): four scenes on a 28 s loop, about 7 s each, soft fades,
     one small motion per scene, the site's own palette, thin rules instead of dark blocks.
   - "Research, Draft, Edit, Schedule, Repeat." (landing.html): four tiles; a gold line walks
     from tile to tile on a 16 s loop and each tile's small sketch moves once while it's lit.
   Only opacity and transform animate. With prefers-reduced-motion everything is still: the hero
   shows the Edit scene and every tile its finished sketch. */

/* ------------------------------------------------------------------ the hero card */

.hd {
  container-type: inline-size;
  display: grid;
  grid-template-rows: auto 1fr;
  aspect-ratio: 6 / 5;
  overflow: hidden;
  border-radius: 10px;
  background: var(--card);
  color: var(--espresso);
}
.hd-top, .hd-stage { font: 400 clamp(10px, 3.5cqw, 16px)/1.45 var(--sans); }
.hd-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1em;
  padding: 5cqw 6cqw 3.4cqw;
  border-bottom: 1px solid var(--line);
}
.hd-mark { font: 400 1.6em/1 var(--serif); }
.hd-steps {
  display: flex;
  gap: 1.1em;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.7em;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.hd-steps li { position: relative; padding-bottom: 0.45em; opacity: 0.45; }
.hd-steps li::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 2px;
  background: var(--gold);
  transform: scaleX(0);
  transform-origin: left;
}
.hd-stage { position: relative; }
.hd-scene { position: absolute; inset: 7cqw 6cqw 6cqw; opacity: 0; }
.hd-title { margin: 0 0 1.1em; font: 400 1.6em/1.15 var(--serif); letter-spacing: -0.01em; }

.hd-rows { margin: 0; padding: 0; list-style: none; }
.hd-rows li {
  display: flex;
  justify-content: space-between;
  gap: 1em;
  padding: 0.75em 0;
  border-top: 1px solid var(--line);
}
.hd-rows li:last-child { border-bottom: 1px solid var(--line); }
.hd-rows b { font-weight: 600; color: var(--gold-ink); }
/* A drawn tick (the sans has no check glyph): the b fades and scales, its ::before is the mark. */
.hd-where b { position: relative; width: 1em; height: 1em; }
.hd-where b::before {
  content: "";
  position: absolute;
  left: 0.2em;
  top: 0.1em;
  width: 0.35em;
  height: 0.65em;
  border: solid var(--ok);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.hd-hook { position: relative; z-index: 0; width: fit-content; margin: 0 0 1em; font-weight: 600; }
.hd-hook span { position: relative; }
.hd-hook span::before {
  content: "";
  position: absolute;
  inset: auto -0.2em 0.05em;
  z-index: -1;
  height: 0.6em;
  background: var(--butter);
  transform: scaleX(0);
  transform-origin: left;
}
.hd-line { margin: 0 0 0.65em; color: var(--body); }

.hd-ask {
  width: fit-content;
  max-width: 80%;
  margin: 0 0 1.1em auto;
  padding: 0.55em 0.95em;
  border-radius: 1.1em 1.1em 0.3em;
  background: var(--espresso);
  color: var(--white);
  font-size: 0.92em;
}
.hd-slide {
  position: relative;
  height: 9.2em;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}
.hd-old, .hd-new {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  margin: 0;
  padding: 1em 1.2em;
}
.hd-old { color: var(--body); }
.hd-new { font: 400 1.65em/1.15 var(--serif); opacity: 0; }
.hd-new em { color: var(--gold-ink); }
.hd-note { margin: 1.1em 0 0; color: var(--body); font-size: 0.92em; }

/* The loop: 28 s, a 7 s window per scene. Each scene, its step label and the label's line share
   one timeline, offset by a negative delay so scene 1 starts at once and each next one follows
   7 s later (25% of the loop). Everything inside a scene changes only while it's on screen. */
.hd-scene, .hd-steps li, .hd-steps li::after, .hd-hook span::before, .hd-ask, .hd-old, .hd-new,
.hd-where b {
  animation-duration: 28s;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  animation-fill-mode: both;
}
.hd-scene { animation-name: hd-scene; }
.hd-steps li { animation-name: hd-step; }
.hd-steps li::after { animation-name: hd-bar; }
.hd-hook span::before { animation-name: hd-wipe; }
.hd-ask { animation-name: hd-ask; }
.hd-old { animation-name: hd-old; }
.hd-new { animation-name: hd-new; }
.hd-where b { animation-name: hd-check; }

.hd-s2, .hd-steps .hd-s2::after, .hd-s2 .hd-hook span::before { animation-delay: -21s; }
.hd-s3, .hd-steps .hd-s3::after, .hd-s3 .hd-ask, .hd-s3 .hd-old, .hd-s3 .hd-new {
  animation-delay: -14s;
}
.hd-s4, .hd-steps .hd-s4::after, .hd-s4 .hd-where li:nth-child(1) b { animation-delay: -7s; }
.hd-s4 .hd-where li:nth-child(2) b { animation-delay: -6.4s; }
.hd-s4 .hd-where li:nth-child(3) b { animation-delay: -5.8s; }

@keyframes hd-scene {
  0% { opacity: 0; transform: translateY(0.5em); }
  3.5%, 22% { opacity: 1; transform: none; }
  25%, 100% { opacity: 0; transform: translateY(-0.3em); }
}
@keyframes hd-step {
  0%, 25.5%, 100% { opacity: 0.45; }
  3%, 23% { opacity: 1; }
}
@keyframes hd-bar {
  0% { opacity: 1; transform: scaleX(0); }
  22%, 24% { opacity: 1; transform: scaleX(1); }
  25.5% { opacity: 0; transform: scaleX(1); }
  26%, 100% { opacity: 0; transform: scaleX(0); }
}
/* Inside a scene: each change happens in the scene's window and resets at 26%, after the scene
   has faded out (25%), so every set ends as it starts and no loop shows a jump. */
@keyframes hd-wipe {
  0%, 5%, 26%, 100% { transform: scaleX(0); }
  10%, 25% { transform: scaleX(1); }
}
@keyframes hd-ask {
  0%, 4%, 26%, 100% { opacity: 0; transform: translateY(0.4em); }
  6.5%, 25% { opacity: 1; transform: none; }
}
@keyframes hd-old {
  0%, 11%, 26%, 100% { opacity: 1; }
  12.5%, 25% { opacity: 0; }
}
@keyframes hd-new {
  0%, 12.5%, 26%, 100% { opacity: 0; transform: translateY(0.3em); }
  15%, 25% { opacity: 1; transform: none; }
}
@keyframes hd-check {
  0%, 5%, 28%, 100% { opacity: 0; transform: scale(0.6); }
  7.5%, 26% { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------------ the four tiles */

.loop-grid { display: grid; gap: 1.25rem; margin: 1.5rem 0 0; padding: 0; list-style: none; }
@media (min-width: 40rem) { .loop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 64rem) { .loop-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.loop-tile h3 {
  margin: 0 0 0.4rem;
  font: 400 1.5rem/1.15 var(--serif);
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--espresso);
}
.loop-tile p { margin: 0; }
.loop-art {
  position: relative;
  aspect-ratio: 4 / 3;
  margin: 0 0 1rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}
.loop-art::after {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: var(--gold);
  transform: scaleX(0);
  transform-origin: left;
}
.loop-sketch { position: absolute; inset: 18% 14%; }
/* Phones: shorter sketches, so the four tiles don't read as four tall boxes. */
@media (max-width: 39.99rem) { .loop-art { aspect-ratio: 2 / 1; } }

/* Research: three bars, the tallest gold. */
.la-research { display: flex; align-items: flex-end; gap: 9%; }
.la-research i { flex: 1; border-radius: 4px 4px 0 0; background: var(--sand); transform-origin: bottom; }
.la-research i:nth-child(1) { height: 45%; }
.la-research i:nth-child(2) { height: 68%; }
.la-research i:nth-child(3) { height: 100%; background: var(--gold); }
/* Draft: lines of a script, the first one highlighted. */
.la-draft { display: flex; flex-direction: column; justify-content: center; gap: 13%; }
.la-draft i { display: block; height: 8%; border-radius: 3px; background: var(--sand); }
.la-draft i:nth-child(1) { width: 88%; background: var(--butter); transform-origin: left; }
.la-draft i:nth-child(2) { width: 100%; }
.la-draft i:nth-child(3) { width: 72%; }
.la-draft i:nth-child(4) { width: 84%; }
/* Edit: a chat bubble and a slide whose words get shorter. */
.la-edit i { position: absolute; display: block; border-radius: 4px; }
.la-edit .la-bubble { top: 0; right: 0; width: 46%; height: 18%; border-radius: 9px 9px 3px; background: var(--espresso); }
.la-edit .la-slide { left: 0; bottom: 0; width: 64%; height: 66%; border: 1px solid var(--line); background: var(--white); }
.la-edit .la-long, .la-edit .la-short { left: 8%; height: 9%; background: var(--sand); }
.la-edit .la-long { bottom: 38%; width: 52%; }
.la-edit .la-long + .la-long { bottom: 22%; width: 44%; }
.la-edit .la-short { bottom: 28%; width: 30%; height: 16%; background: var(--gold); opacity: 0; }
/* Schedule: a week, one day picked. */
.la-schedule { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7%; align-content: center; }
.la-schedule i { aspect-ratio: 1; border-radius: 3px; background: var(--sand); }
.la-schedule i.la-day { background: var(--gold); transform: scale(0.4); opacity: 0; }

/* 16 s: a 4 s turn per tile, in reading order. */
.loop-art::after, .la-research i, .la-draft i:nth-child(1), .la-edit .la-long, .la-edit .la-short,
.la-schedule i.la-day {
  animation-duration: 16s;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  animation-fill-mode: both;
}
.loop-art::after { animation-name: loop-bar; }
.la-research i { animation-name: loop-grow; }
.la-draft i:nth-child(1) { animation-name: loop-wipe; }
.la-edit .la-long { animation-name: loop-out; }
.la-edit .la-short { animation-name: loop-in; }
.la-schedule i.la-day { animation-name: loop-pick; }
.loop-tile:nth-child(2) .loop-art::after, .loop-tile:nth-child(2) .la-draft i:nth-child(1) {
  animation-delay: -12s;
}
.loop-tile:nth-child(3) .loop-art::after, .loop-tile:nth-child(3) .la-edit i { animation-delay: -8s; }
.loop-tile:nth-child(4) .loop-art::after, .loop-tile:nth-child(4) .la-schedule i { animation-delay: -4s; }

@keyframes loop-bar {
  0% { opacity: 1; transform: scaleX(0); }
  22%, 24% { opacity: 1; transform: scaleX(1); }
  25.5% { opacity: 0; transform: scaleX(1); }
  26%, 100% { opacity: 0; transform: scaleX(0); }
}
@keyframes loop-grow {
  0%, 2% { transform: scaleY(0.55); }
  14%, 92% { transform: none; }
  100% { transform: scaleY(0.55); }
}
@keyframes loop-wipe {
  0%, 3% { transform: scaleX(0.15); }
  14%, 92% { transform: none; }
  100% { transform: scaleX(0.15); }
}
@keyframes loop-out {
  0%, 8% { opacity: 1; }
  12%, 92% { opacity: 0; }
  100% { opacity: 1; }
}
@keyframes loop-in {
  0%, 10% { opacity: 0; }
  14%, 92% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes loop-pick {
  0%, 6% { opacity: 0; transform: scale(0.4); }
  12%, 92% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: scale(0.4); }
}

/* ------------------------------------------------------------------ reduced motion */

@media (prefers-reduced-motion: reduce) {
  .hd *, .hd *::before, .hd *::after,
  .loop-art, .loop-art *, .loop-art::after { animation: none !important; }
  .hd-scene { opacity: 0; transform: none; }
  .hd-scene.hd-s3, .hd-steps .hd-s3 { opacity: 1; }
  .hd-steps .hd-s3::after { transform: scaleX(1); }
  .hd-ask, .hd-new { opacity: 1; transform: none; }
  .hd-old { opacity: 0; }
  .la-edit .la-long { opacity: 0; }
  .la-edit .la-short, .la-schedule i.la-day { opacity: 1; transform: none; }
}
