/* Cat in the Hat Mac Port: everything that moves.
 *
 * All of it is opt-in. <html> gets the class "motion" only when scripts run
 * and the visitor has not asked for reduced motion (see the inline script in
 * index.html), so without it the page is the plain, still layout in style.css.
 * No libraries: CSS transitions, a spring easing, and motion.js for the parts
 * that follow the pointer or the scroll position.
 *
 * Sections, in order:
 *   1. Easing and the scroll progress bar
 *   2. Entrances (hero sequence, sections and their children)
 *   3. Hovers (buttons, links, tiles, windows, thumbnails, FAQ)
 *   4. Small loops (the drag-to-Applications arrow, the diagram)
 *   5. Showpiece: the hero window settling as you scroll
 *   6. Showpiece: the 2003-to-now scroll scene on the before/after slider
 */

/* ---------- 1. Easing ---------- */
:root {
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --out: cubic-bezier(.16, 1, .3, 1);
}
@supports (transition-timing-function: linear(0, 1)) {
  :root {
    /* A soft spring: overshoots about 8%, settles in two swings */
    --spring: linear(0, .009, .035 2.1%, .141, .281 6.7%, .723 12.9%, .938 16.7%, 1.017, 1.077, 1.121, 1.149 24.3%, 1.159, 1.163, 1.161, 1.154 29.9%, 1.129 32.8%, 1.051 39.6%, 1.017 43.1%, .991, .977 51%, .974 53.8%, .975 57.1%, .997 69.8%, 1.003 76.9%, 1.004 83.8%, 1);
  }
}

/* Reading progress under the sticky header (browsers with scroll timelines) */
@supports (animation-timeline: scroll()) {
  html.motion .progress {
    display: block; position: absolute; left: 0; right: 0; bottom: -3px; height: 3px;
    background: linear-gradient(90deg, var(--teal), var(--yellow)); transform-origin: 0 50%; transform: scaleX(0);
    opacity: 0; transition: opacity .3s;
    animation: progress linear both; animation-timeline: scroll(root);
  }
  html.motion .top.is-stuck .progress { opacity: 1; }
  @keyframes progress { to { transform: scaleX(1); } }
}

/* ---------- 2. Entrances ---------- */
@keyframes rise { from { opacity: 0; translate: 0 24px; } }
@keyframes word { from { transform: translateY(115%) rotate(7deg); } }
@keyframes pop { from { scale: 0; } }

html.motion .hero .badge { animation: rise .7s var(--out) both .05s; }
html.motion .hero .sub { animation: rise .8s var(--out) both .34s; }
html.motion .hero .cta-row { animation: rise .8s var(--out) both .44s; }
html.motion .hero .req { animation: rise .8s var(--out) both .52s; }
html.motion .hero .early { animation: rise .8s var(--out) both .58s; }
html.motion .hero .hero-media { animation: rise 1s var(--out) both .3s; }

/* The headline lands a word at a time (motion.js wraps the words) */
.hero h1 .w { display: inline-block; overflow: hidden; vertical-align: bottom; padding: .12em .04em .16em; margin: -.12em -.04em -.16em; }
.hero h1 .w > span { display: inline-block; transform-origin: 0 100%; animation: word .9s var(--spring) both; animation-delay: calc(var(--i) * 45ms + 60ms); }

/* Sections fade up; lists inside them follow one item at a time */
html.motion .fade { opacity: 0; translate: 0 32px; transition: opacity .8s var(--out), translate .9s var(--out); }
html.motion .fade.in { opacity: 1; translate: none; }

html.motion .fade :is(.step-list, .tiles, .checks, .diagram, .acc) > * {
  opacity: 0; translate: 0 28px;
  transition: opacity .7s var(--out) calc(var(--i, 0) * 85ms + 120ms), translate .9s var(--spring) calc(var(--i, 0) * 85ms + 120ms),
              transform .5s var(--spring), box-shadow .35s, border-color .3s;
}
html.motion .fade.in :is(.step-list, .tiles, .checks, .diagram, .acc) > * { opacity: 1; translate: none; }
html.motion .fade :is(.step-list, .tiles, .checks, .diagram, .acc) > :nth-child(2) { --i: 1; }
html.motion .fade :is(.step-list, .tiles, .checks, .diagram, .acc) > :nth-child(3) { --i: 2; }
html.motion .fade :is(.step-list, .tiles, .checks, .diagram, .acc) > :nth-child(4) { --i: 3; }
html.motion .fade :is(.step-list, .tiles, .checks, .diagram, .acc) > :nth-child(5) { --i: 4; }
html.motion .fade :is(.step-list, .tiles, .checks, .diagram, .acc) > :nth-child(6) { --i: 5; }
html.motion .fade :is(.step-list, .tiles, .checks, .diagram, .acc) > :nth-child(7) { --i: 6; }

/* The dashed path draws itself, then each number pops onto it */
html.motion .step-list::before { transform: scaleX(0); transform-origin: 0 50%; transition: transform 1.3s var(--out) .25s; }
html.motion .fade.in .step-list::before { transform: none; }
html.motion .fade .num { scale: 0; transition: scale .7s var(--spring) calc(var(--i, 0) * 180ms + 300ms); }
html.motion .fade.in .num { scale: 1; }
html.motion .fade .checks li::before { scale: 0; transition: scale .6s var(--spring) calc(var(--i, 0) * 85ms + 260ms); }
html.motion .fade.in .checks li::before { scale: 1; }
html.motion .settings-card, html.motion .after-steps, html.motion .not { opacity: 0; translate: 0 28px; transition: opacity .8s var(--out) .5s, translate .9s var(--out) .5s; }
html.motion .fade.in :is(.settings-card, .after-steps, .not) { opacity: 1; translate: none; }

/* ---------- 3. Hovers ---------- */
/* Buttons: a springy lift, a deeper shadow and one pass of light. --bx/--by
 * come from motion.js (the big buttons lean toward the pointer). */
html.motion .btn:not(.btn-compact) {
  position: relative; overflow: hidden;
  transform: translate(var(--bx, 0px), var(--by, 0px)) scale(var(--bs, 1));
  transition: transform .5s var(--spring), box-shadow .3s, background-color .15s;
}
html.motion .btn-red::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .34) 50%, transparent 65%);
  translate: -110% 0;
}
html.motion .btn-compact { transition: opacity .2s, transform .35s var(--spring), visibility .2s, background-color .15s; }
html.motion .q button { transition: color .2s; }
html.motion .q i { transition: transform .45s var(--spring); }
html.motion .nav a:not(.btn), html.motion .foot-links a { position: relative; }
html.motion .nav a:not(.btn):not(.gh)::after, html.motion .foot-links a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -7px; height: 2.5px; border-radius: 2px;
  background: currentColor; transform: scaleX(0); transform-origin: 100% 50%; transition: transform .35s var(--out);
}
html.motion .gh svg, html.motion .btn-light svg { transition: transform .5s var(--spring); }
html.motion .tiles li { position: relative; overflow: hidden; }
html.motion .tiles li::before { /* a warm light that follows the pointer */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .35s;
  background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 50%), rgba(245, 197, 66, .22), transparent 70%);
}
html.motion .tiles li > * { position: relative; }
html.motion .ic { transition: transform .6s var(--spring), stroke .3s; transform-origin: 50% 60%; }
html.motion .thumb { transition: transform .45s var(--spring), outline-color .25s, box-shadow .3s; }
html.motion .s-handle { transition: scale .4s var(--spring), box-shadow .3s; }
html.motion .slider.is-dragging .s-handle { scale: .92; }
html.motion .trailer-pill { transition: scale .45s var(--spring), background-color .2s; }
html.motion .dmg-in img { transition: translate .7s var(--spring); }
html.motion .how-link { text-decoration-thickness: 2px; transition: text-underline-offset .25s, color .15s; }

/* App screenshots lean toward the pointer (motion.js sets --rx/--ry) */
html.motion .tilt {
  position: relative;
  transform: perspective(1100px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) scale(var(--ts, 1));
  transition: transform .7s var(--spring), box-shadow .4s; will-change: transform;
}
html.motion .tilt.is-tilting { transition: transform .12s linear, box-shadow .4s; }
html.motion .tilt::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .4s;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 0%), rgba(255, 255, 255, .28), transparent 65%);
}

@media (hover: hover) and (pointer: fine) {
  html.motion .btn-light:hover { --bs: 1.045; box-shadow: 0 16px 34px rgba(0, 0, 0, .4); }
  html.motion .btn-light:hover svg { transform: rotate(-10deg) scale(1.15); }
  html.motion .btn-red:hover { --bs: 1.045; box-shadow: 0 16px 34px rgba(212, 43, 37, .38); }
  html.motion .btn-red:hover::after { translate: 110% 0; transition: translate .75s var(--out); }
  html.motion .top.show-get .btn-compact:hover { transform: scale(1.06); }
  html.motion .nav a:not(.btn):hover::after, html.motion .foot-links a:hover::after { transform: scaleX(1); transform-origin: 0 50%; }
  html.motion .gh:hover svg { transform: rotate(-10deg) scale(1.18); }
  html.motion .how-link:hover { text-underline-offset: 7px; }
  html.motion .tiles li:hover { transform: translateY(-8px); box-shadow: 0 26px 50px rgba(28, 36, 64, .14); border-color: rgba(29, 115, 119, .45); }
  html.motion .tiles li:hover::before { opacity: 1; }
  html.motion .tiles li:hover .ic { transform: rotate(-8deg) scale(1.18); }
  html.motion .tilt:hover { --ts: 1.03; box-shadow: 0 34px 70px rgba(28, 36, 64, .26); }
  html.motion .tilt:hover::after { opacity: 1; }
  html.motion .thumb:hover { transform: translateY(-5px) scale(1.06); box-shadow: 0 12px 24px rgba(28, 36, 64, .22); }
  html.motion .slider:hover .s-handle { scale: 1.12; box-shadow: 0 8px 26px rgba(28, 36, 64, .45), 0 0 0 8px rgba(245, 197, 66, .28); }
  html.motion .trailer-pill:hover { scale: 1.06; }
  html.motion .step-list li:hover .dmg-in img { translate: 16px 0; }
  html.motion .q button:hover { color: var(--teal); }
  html.motion .q button:hover i { transform: rotate(90deg); }
  html.motion .diagram li { transition-property: opacity, translate, transform, box-shadow, border-color; }
  html.motion .diagram li:hover { transform: translateY(-4px); border-color: #fff; }
}
html.motion .btn-red:active { --bs: .96; transition-duration: .1s; }
html.motion .thumb:active { transform: scale(.96); }

/* FAQ answers open and close smoothly (main.js adds .js to the list) */
.acc.js .a { display: grid !important; grid-template-rows: 0fr; visibility: hidden; opacity: 0; }
.acc.js .a > p { overflow: hidden; min-height: 0; padding-bottom: 0; }
.acc.js .a > p::after { content: ""; display: block; height: 30px; }
.acc.js .q.open .a { grid-template-rows: 1fr; visibility: visible; opacity: 1; }
html.motion .acc.js .a { transition: grid-template-rows .5s var(--out), opacity .4s, visibility .5s; }
@media (max-width: 700px) { .acc.js .a > p::after { height: 20px; } }

/* Switching scene: the new pictures settle in */
@keyframes scene-in { from { opacity: .15; scale: 1.05; filter: blur(8px); } }
html.motion .slider.swap img { animation: scene-in .6s var(--out); }

/* ---------- 4. Small loops ---------- */
@keyframes march { to { stroke-dashoffset: -14; } }
html.motion .dmg-arrow path:first-child { animation: march .9s linear infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 10px rgba(245, 197, 66, .16), 0 0 44px rgba(245, 197, 66, .5); } }
html.motion .fade.in .diagram li.hl { animation: glow 2.8s ease-in-out infinite 1.2s; }
@keyframes nudge { 50% { translate: 6px 0; } }
html.motion .diagram li + li::before { animation: nudge 1.6s ease-in-out infinite; }
@keyframes ring { to { box-shadow: 0 0 0 16px rgba(245, 197, 66, 0); } }
html.motion .trailer-pill .play { box-shadow: 0 0 0 0 rgba(245, 197, 66, .6); animation: ring 1.8s ease-out infinite; }

/* ---------- 5. Showpiece: the hero window ---------- */
/* It starts tipped back and a little small, and settles flat as it scrolls
 * up the screen. --hp runs 0 to 1 (motion.js). */
html.motion .hero-media {
  transform-origin: 50% 100%;
  transform: perspective(1600px) rotateX(calc((1 - var(--hp, 1)) * 16deg)) scale(calc(.86 + .14 * var(--hp, 1)));
  box-shadow: 0 0 0 1px rgba(28, 36, 64, .12), 0 2px 6px rgba(28, 36, 64, .10),
              0 calc(18px + 10px * var(--hp, 1)) calc(36px + 20px * var(--hp, 1)) -16px rgba(28, 36, 64, .32),
              0 calc(40px + 30px * var(--hp, 1)) calc(80px + 40px * var(--hp, 1)) -40px rgba(28, 36, 64, calc(.24 + .14 * var(--hp, 1)));
  will-change: transform;
}

/* ---------- 6. Showpiece: 2003 to now ---------- */
/* html.scene is set by motion.js on wide, tall-enough screens. The section
 * becomes a tall track; its contents stick to the screen while the scroll
 * position plays the scene: the 2003 picture as a small 4:3 frame, the frame
 * widening, the port sweeping across it, then the slider handed to the
 * visitor. motion.js sets --sc (size), --clip (side crop), --ui (controls)
 * and the slider's own --pos; data-phase picks the headline. */
html.scene .compare { height: 320vh; }
html.scene .compare-stage { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; justify-content: center; padding-top: 88px; padding-bottom: 24px; }
html.scene .compare-head { margin-bottom: 36px; align-items: center; }
html.scene .compare h2 { display: grid; }
html.scene .compare h2 .t { display: block; grid-area: 1 / 1; opacity: 0; translate: 0 18px; transition: opacity .45s, translate .6s var(--out); }
html.scene .compare[data-phase="then"] .t-then,
html.scene .compare[data-phase="now"] .t-now,
html.scene .compare[data-phase="drag"] .t-drag { opacity: 1; translate: none; }
html.scene .slider { height: min(660px, calc(100vh - 400px)); transform: scale(var(--sc, 1)); clip-path: var(--clip, none); will-change: transform; }
html.scene .compare:not(.scene-live) .slider { pointer-events: none; }
html.scene .compare:not(.scene-live) .slider { box-shadow: none; }
html.scene :is(.s-label, .s-handle, .thumbs, .small, .scene-label) { opacity: var(--ui, 1); }
html.scene .thumbs { translate: 0 calc((1 - var(--ui, 1)) * 20px); margin-top: 28px; }
html.scene .small { margin-top: 16px; }
html.scene .scene-pills { display: flex; gap: 12px; position: absolute; left: 50%; bottom: 28px; translate: -50% 0; pointer-events: none; }
html.scene .scene-pills span {
  background: var(--yellow); color: var(--ink); font: 600 20px/1 var(--display); padding: 12px 20px; border-radius: 999px;
  box-shadow: 0 8px 22px rgba(28, 36, 64, .35); white-space: nowrap;
  opacity: 0; scale: .5; transition: opacity .25s, scale .6s var(--spring);
}
html.scene .scene-pills span.on { opacity: 1; scale: 1; }
html.scene .s-line { box-shadow: 0 0 calc(18px + 30px * var(--sweep, 0)) rgba(245, 197, 66, .85); width: calc(4px + 2px * var(--sweep, 0)); }

/* ---------- 7. Bands, gallery and the hero's colour ---------- */
/* Banded sections keep their colour on screen; only their contents animate */
html.motion :is(.compare, .get).fade { opacity: 1; translate: none; }
html.motion .get.fade > h2 { opacity: 0; translate: 0 28px; transition: opacity .8s var(--out), translate .9s var(--out); }
html.motion .get.fade.in > h2 { opacity: 1; translate: none; }
html.motion .fade :is(.step-list, .tiles, .checks, .diagram, .acc) > :nth-child(8) { --i: 7; }
html.motion .fade :is(.step-list, .tiles, .checks, .diagram, .acc) > :nth-child(9) { --i: 8; }
html.scene .compare { padding-top: 0; padding-bottom: 0; }

@keyframes drift-a { to { translate: 60px 40px; scale: 1.12; } }
@keyframes drift-b { to { translate: -70px -30px; scale: .92; } }

/* The gallery strip loops by itself and stops under the pointer. The track
 * holds the pictures twice; moving it by half its width (plus half a gap)
 * lands the copy exactly where the first set began. */
@keyframes strip { to { transform: translateX(calc(-50% - 14px)); } }
html.motion .strip { overflow: hidden; -webkit-mask: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent); mask: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent); }
html.motion .strip-track { padding: 0; animation: strip 80s linear infinite; }
html.motion .strip-track li[aria-hidden] { display: block; }
html.motion .strip-track li { transition: rotate .6s var(--spring), scale .6s var(--spring), box-shadow .4s; }
@media (hover: hover) and (pointer: fine) {
  html.motion .strip:hover .strip-track { animation-play-state: paused; }
  html.motion .strip-track li:hover { rotate: 0deg; scale: 1.06; box-shadow: 0 34px 70px rgba(28, 36, 64, .34); }
}
@media (max-width: 700px) {
  @keyframes strip { to { transform: translateX(calc(-50% - 8px)); } }
  html.motion .strip-track { animation-duration: 60s; }
}

/* ---------- 8. Player and picture viewer ---------- */
@keyframes pic-in { from { opacity: 0; scale: .96; } }
html.motion .lb img.in { animation: pic-in .45s var(--out); }
html.motion .lightbox:not([hidden]) .lb { animation: pic-in .4s var(--out); }
html.motion .lb-nav { transition: scale .4s var(--spring), background-color .15s; }
@media (hover: hover) and (pointer: fine) {
  html.motion .lb-nav:hover { scale: 1.12; background: #fff; }
}

/* ---------- 9. Decals ---------- */
@keyframes bob { 50% { translate: 0 -16px; rotate: calc(var(--r, 0deg) + 9deg); } }
@keyframes spin { to { rotate: 360deg; } }
@keyframes decal-in { from { opacity: 0; scale: .4; } }
html.motion .decals svg { animation: decal-in .9s var(--spring) both .5s, bob var(--t, 9s) ease-in-out infinite 1.4s; }
html.motion .decals svg.spin { animation: decal-in .9s var(--spring) both .5s, spin var(--t, 40s) linear infinite; }

/* ---------- 10. The card after the steps ---------- */
html.motion .fade .after-steps::before { scale: 0; transition: scale .7s var(--spring) 1s; }
html.motion .fade.in .after-steps::before { scale: 1; }
html.motion .fade .after-steps::after { transform: scaleY(0); transform-origin: 50% 0; transition: transform .6s var(--out) .7s; }
html.motion .fade.in .after-steps::after { transform: none; }

/* ---------- 11. Picture tiles ---------- */
/* The 4:3 frame opens out to the full picture and back, forever */
@keyframes widen { 0%, 18% { left: 12.5%; right: 12.5%; box-shadow: 0 0 0 999px rgba(22, 28, 54, .62); } 62%, 100% { left: 0%; right: 0%; box-shadow: 0 0 0 999px rgba(22, 28, 54, 0); } }
@keyframes tag-out { 0%, 18% { opacity: 1; } 55%, 100% { opacity: 0; } }
html.motion .fade.in .t-frame { animation: widen 4.5s var(--out) infinite alternate 1s; }
html.motion .fade.in .t-frame span { animation: tag-out 4.5s linear infinite alternate 1s; }
/* Until a pointer takes over, the split and the lens wander by themselves */
@keyframes cut { from { --cut: 30%; } to { --cut: 70%; } }
@property --cut { syntax: "<length-percentage>"; inherits: true; initial-value: 50%; }
@property --lx { syntax: "<length-percentage>"; inherits: true; initial-value: 50%; }
@property --ly { syntax: "<length-percentage>"; inherits: true; initial-value: 50%; }
@keyframes lens { 0% { --lx: 28%; --ly: 40%; } 50% { --lx: 68%; --ly: 62%; } 100% { --lx: 50%; --ly: 30%; } }
html.motion .tiles li:not(.touched) .t-split { animation: cut 5s ease-in-out infinite alternate; }
html.motion .tiles li:not(.touched) .t-lens { animation: lens 9s ease-in-out infinite alternate; }
html.motion .t-zoom img, html.motion .t-wide img { transition: scale 1.2s var(--out); }
/* The controller floats; on hover it tips and its buttons press in turn */
@keyframes hover-pad { 50% { translate: 0 -7px; } }
@keyframes hover-floor { 50% { scale: .9 1; opacity: .7; } }
@keyframes press { 30% { scale: .78; } }
html.motion .pad-all { animation: hover-pad 4.5s ease-in-out infinite; transition: rotate .7s var(--spring); transform-origin: 160px 105px; transform-box: view-box; }
html.motion .pad-floor { animation: hover-floor 4.5s ease-in-out infinite; transform-origin: 160px 196px; transform-box: view-box; }
html.motion .pad-btn { transform-box: fill-box; transform-origin: 50% 50%; }
html.motion .pad-stick, html.motion .pad-cap { transition: translate .5s var(--spring); }
html.motion .tiles .ic { transition: transform .6s var(--spring), background-color .3s; transform-origin: 50% 50%; }
@media (hover: hover) and (pointer: fine) {
  html.motion .tiles li:hover .t-zoom img, html.motion .tiles li:hover .t-wide img { scale: 1.07; }
  html.motion .tiles li:hover .pad-all { rotate: -7deg; }
  html.motion .tiles li:hover .pad-btn { animation: press .9s ease-in-out infinite; }
  html.motion .tiles li:hover .pad-btn.b2 { animation-delay: .15s; }
  html.motion .tiles li:hover .pad-btn.b3 { animation-delay: .3s; }
  html.motion .tiles li:hover .pad-btn.b4 { animation-delay: .45s; }
  html.motion .tiles li:hover .pad-stick, html.motion .tiles li:hover .pad-cap { translate: 3px -2px; }
  html.motion .tiles li:hover .ic { transform: rotate(-10deg) scale(1.12); }
  html.motion .tiles li:hover { border-color: transparent; }
}

/* ---------- 12. The poster ---------- */
html.motion .poster-play { transition: scale .5s var(--spring), background-color .2s; }
html.motion .poster { transition: background-color .3s; }
html.motion .poster .label { transition: translate .5s var(--out); }
@media (hover: hover) and (pointer: fine) {
  html.motion .poster:hover .poster-play { scale: 1.1; background: #fff; }
  html.motion .poster:hover .label { translate: 4px 0; }
}
html.motion .poster:active .poster-play { scale: .94; }
