/* The fifteen-second film on the home page (design §11): one inline SVG
   (public/_motion.html.erb). Generic motions carry a start time from a
   t-class (tenths of a second); scenes, clippings and captions follow
   15-second tracks. home.js starts it when it comes into view; paused, it
   holds; without JavaScript or with reduced motion it shows its last frame. */

.film { background: #14110e; color: #efe8da; }
.home .film h2 { color: #fbf6ec; }
.film .eyebrow { color: var(--accent-soft); }
.film .section-sub { color: #c8bfaf; }

.mg { margin: 0; }
.mg-frame { overflow: hidden; border: 1px solid rgba(255, 255, 255, .09); border-radius: 22px; box-shadow: 0 50px 90px -50px rgba(0, 0, 0, .8); background: #1b1814; }
.mg-stage { display: block; width: 100%; height: auto; }
.mg-stage text { font-family: var(--display); }
.mg-stage .mg-kicker { font: 700 13px var(--sans); letter-spacing: .16em; }
.mg-stage .mg-tag { font: 700 13px var(--sans); letter-spacing: .14em; }
.mg-stage .mg-mini { font: 700 11px var(--sans); letter-spacing: .16em; }
.mg-stage .mg-note { font: 500 21px var(--text); }
.mg-stage .mg-stampword { font: 800 16px var(--sans); letter-spacing: .08em; }
.mg-stage .mg-word { font: 600 44px var(--display); letter-spacing: -.01em; }
.mg-stage .mg-cap { font: 500 42px var(--display); fill: #f6f1e7; }

.mg-bar { height: 3px; margin-top: 16px; overflow: hidden; border-radius: 3px; background: rgba(255, 255, 255, .12); }
.mg-progress { display: block; height: 100%; background: var(--accent-soft); transform-origin: left center; animation: mgProgress 15s linear both; }
.mg-controls { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 16px; }
.mg-controls[hidden] { display: none; }
.mg-controls button { padding: .6rem 1.05rem; border: 1px solid rgba(255, 255, 255, .35); border-radius: 999px; background: transparent; color: #f6f1e7; font: 600 .85rem/1 var(--sans); cursor: pointer; }
.mg-controls button:hover { border-color: var(--accent-soft); color: var(--accent-soft); }
.mg-controls button:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 3px; }
.mg-controls button[hidden] { display: none; }
.mg.is-done [data-mg-replay] { border-color: #f6f1e7; background: #f6f1e7; color: #1b1814; }

/* Generic motions. */
.mg-draw, .mg-grow, .mg-pop, .mg-fade, .mg-rise, .mg-slide, .mg-stamp, .mg-dim {
  animation-duration: .6s; animation-timing-function: cubic-bezier(.2, .7, .2, 1); animation-fill-mode: both; transform-box: fill-box;
}
.mg-draw { animation-name: mgDraw; animation-duration: .9s; stroke-dasharray: 1; }
.mg-grow { animation-name: mgGrow; animation-duration: .55s; transform-origin: left center; }
.mg-pop { animation-name: mgPop; animation-duration: .5s; transform-origin: center; }
.mg-fade { animation-name: mgFade; animation-duration: .5s; }
.mg-rise { animation-name: mgRise; }
.mg-slide { animation-name: mgSlide; animation-duration: .8s; }
.mg-stamp { animation-name: mgStamp; animation-duration: .45s; animation-timing-function: cubic-bezier(.3, 1.4, .5, 1); transform-origin: center; }
.mg-dim { animation-name: mgDim; animation-duration: .4s; }

/* A line not yet drawn is a dash of no length, and its round cap would show
   as a dot at its far end, so it stays invisible until it starts. */
@keyframes mgDraw { from { stroke-dashoffset: 1; opacity: 0; } 4% { opacity: 1; } to { stroke-dashoffset: 0; opacity: 1; } }
@keyframes mgGrow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes mgPop { 0% { opacity: 0; transform: scale(.4); } 70% { opacity: 1; transform: scale(1.06); } 100% { opacity: 1; transform: scale(1); } }
@keyframes mgFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes mgRise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes mgSlide { from { opacity: 0; transform: translateX(90px); } to { opacity: 1; transform: none; } }
@keyframes mgStamp { from { opacity: 0; transform: scale(1.9); } to { opacity: 1; transform: scale(1); } }
@keyframes mgDim { from { opacity: 1; } to { opacity: .25; } }
@keyframes mgProgress { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes mgClock { from { opacity: 0; } to { opacity: 0; } }

/* Start times. */
.mg-stage .t2 { animation-delay: 0.2s; }
.mg-stage .t6 { animation-delay: 0.6s; }
.mg-stage .t10 { animation-delay: 1.0s; }
.mg-stage .t13 { animation-delay: 1.3s; }
.mg-stage .t14 { animation-delay: 1.4s; }
.mg-stage .t15 { animation-delay: 1.5s; }
.mg-stage .t16 { animation-delay: 1.6s; }
.mg-stage .t17 { animation-delay: 1.7s; }
.mg-stage .t18 { animation-delay: 1.8s; }
.mg-stage .t19 { animation-delay: 1.9s; }
.mg-stage .t20 { animation-delay: 2.0s; }
.mg-stage .t36 { animation-delay: 3.6s; }
.mg-stage .t37 { animation-delay: 3.7s; }
.mg-stage .t39 { animation-delay: 3.9s; }
.mg-stage .t40 { animation-delay: 4.0s; }
.mg-stage .t41 { animation-delay: 4.1s; }
.mg-stage .t42 { animation-delay: 4.2s; }
.mg-stage .t43 { animation-delay: 4.3s; }
.mg-stage .t44 { animation-delay: 4.4s; }
.mg-stage .t45 { animation-delay: 4.5s; }
.mg-stage .t46 { animation-delay: 4.6s; }
.mg-stage .t47 { animation-delay: 4.7s; }
.mg-stage .t50 { animation-delay: 5.0s; }
.mg-stage .t52 { animation-delay: 5.2s; }
.mg-stage .t54 { animation-delay: 5.4s; }
.mg-stage .t58 { animation-delay: 5.8s; }
.mg-stage .t59 { animation-delay: 5.9s; }
.mg-stage .t60 { animation-delay: 6.0s; }
.mg-stage .t64 { animation-delay: 6.4s; }
.mg-stage .t68 { animation-delay: 6.8s; }
.mg-stage .t70 { animation-delay: 7.0s; }
.mg-stage .t72 { animation-delay: 7.2s; }
.mg-stage .t74 { animation-delay: 7.4s; }
.mg-stage .t76 { animation-delay: 7.6s; }
.mg-stage .t78 { animation-delay: 7.8s; }
.mg-stage .t80 { animation-delay: 8.0s; }
.mg-stage .t82 { animation-delay: 8.2s; }
.mg-stage .t85 { animation-delay: 8.5s; }
.mg-stage .t88 { animation-delay: 8.8s; }
.mg-stage .t98 { animation-delay: 9.8s; }
.mg-stage .t99 { animation-delay: 9.9s; }
.mg-stage .t103 { animation-delay: 10.3s; }
.mg-stage .t108 { animation-delay: 10.8s; }
.mg-stage .t109 { animation-delay: 10.9s; }
.mg-stage .t115 { animation-delay: 11.5s; }
.mg-stage .t126 { animation-delay: 12.6s; }
.mg-stage .t131 { animation-delay: 13.1s; }
.mg-stage .t133 { animation-delay: 13.3s; }
.mg-stage .t135 { animation-delay: 13.5s; }
.mg-stage .t139 { animation-delay: 13.9s; }

/* The whole film's length: its end is the "done" signal. */
.mg-clock { animation: mgClock 15s linear both; }

/* Scenes leave on the 15-second track (1% = .15 s). */
.mg-scene1 { animation: mgScene1 15s linear both; }
.mg-scene2 { animation: mgScene2 15s linear both; }
.mg-scene3 { animation: mgScene3 15s linear both; }
@keyframes mgScene1 { 0%, 22.7% { opacity: 1; } 26%, 100% { opacity: 0; } }
@keyframes mgScene2 { 0%, 41.3% { opacity: 1; } 44.7%, 100% { opacity: 0; } }
@keyframes mgScene3 { 0%, 80.7% { opacity: 1; } 83.3%, 100% { opacity: 0; } }

/* The clippings: out of the newspaper (3.1 s), onto the invented life (5.0 s),
   beside the draft as its sources (7.0 s), gone with the page (12.4 s). */
.mg-clip { transform-box: fill-box; transform-origin: 0 0; }
.mg-clip1 { animation: mgClip1 15s cubic-bezier(.45, 0, .25, 1) both; }
.mg-clip2 { animation: mgClip2 15s cubic-bezier(.45, 0, .25, 1) .15s both; }
.mg-clip3 { animation: mgClip3 15s cubic-bezier(.45, 0, .25, 1) .3s both; }
@keyframes mgClip1 {
  0%, 14.7% { opacity: 0; transform: translate(460px, 120px) scale(.3); }
  20.7%, 28.7% { opacity: 1; transform: translate(0, 0) scale(1); }
  33.3%, 42% { opacity: 1; transform: translate(120px, -30px) scale(.8); }
  46.7%, 80% { opacity: 1; transform: translate(-60px, -20px) scale(.85); }
  82.7%, 100% { opacity: 0; transform: translate(-60px, -20px) scale(.85); }
}
@keyframes mgClip2 {
  0%, 14.7% { opacity: 0; transform: translate(460px, -150px) scale(.3); }
  20.7%, 28.7% { opacity: 1; transform: translate(0, 0) scale(1); }
  33.3%, 42% { opacity: 1; transform: translate(415px, -325px) scale(.8); }
  46.7%, 80% { opacity: 1; transform: translate(-60px, -145px) scale(.85); }
  82.7%, 100% { opacity: 0; transform: translate(-60px, -145px) scale(.85); }
}
@keyframes mgClip3 {
  0%, 14.7% { opacity: 0; transform: translate(-360px, -15px) scale(.3); }
  20.7%, 28.7% { opacity: 1; transform: translate(0, 0) scale(1); }
  33.3%, 42% { opacity: 1; transform: translate(-110px, -165px) scale(.8); }
  46.7%, 80% { opacity: 1; transform: translate(-880px, 135px) scale(.85); }
  82.7%, 100% { opacity: 0; transform: translate(-880px, 135px) scale(.85); }
}

/* Captions, one per beat; the last one stays. */
.mg-cap { transform-box: fill-box; }
.mg-cap1 { animation: mgCap1 15s linear both; }
.mg-cap2 { animation: mgCap2 15s linear both; }
.mg-cap3 { animation: mgCap3 15s linear both; }
.mg-cap4 { animation: mgCap4 15s linear both; }
.mg-cap5 { animation: mgCap5 15s linear both; }
.mg-cap6 { animation: mgCap6 15s linear both; }
@keyframes mgCap1 { 0%, 2% { opacity: 0; transform: translateY(10px); } 5.3%, 20.7% { opacity: 1; transform: none; } 22.7%, 100% { opacity: 0; transform: none; } }
@keyframes mgCap2 { 0%, 24% { opacity: 0; transform: translateY(10px); } 26.7%, 40.7% { opacity: 1; transform: none; } 42.7%, 100% { opacity: 0; transform: none; } }
@keyframes mgCap3 { 0%, 44% { opacity: 0; transform: translateY(10px); } 46.7%, 62.7% { opacity: 1; transform: none; } 64.7%, 100% { opacity: 0; transform: none; } }
@keyframes mgCap4 { 0%, 65.3% { opacity: 0; transform: translateY(10px); } 68%, 80.7% { opacity: 1; transform: none; } 82.7%, 100% { opacity: 0; transform: none; } }
@keyframes mgCap5 { 0%, 84% { opacity: 0; transform: translateY(10px); } 86.7%, 93.3% { opacity: 1; transform: none; } 95.3%, 100% { opacity: 0; transform: none; } }
@keyframes mgCap6 { 0%, 95.3% { opacity: 0; transform: translateY(10px); } 98%, 100% { opacity: 1; transform: none; } }

/* Playing, paused, and the still last frame. */
.mg .mg-stage *, .mg .mg-progress { animation-play-state: paused; }
.mg.is-playing:not(.is-paused) .mg-stage *, .mg.is-playing:not(.is-paused) .mg-progress { animation-play-state: running; }
.mg.is-static .mg-stage *, .mg.is-static .mg-progress,
html:not(.js) .mg .mg-stage *, html:not(.js) .mg .mg-progress {
  animation-duration: 0s !important; animation-delay: 0s !important; animation-play-state: running !important;
}
