/* Genesis motion (2026-10-23, docs/ART-DIRECTION.md). One easing, one
   duration scale, and every move says where something came from. Loaded
   after css/genesis.css and css/learn.css, so these rules win.

   The budget per screen: one entrance, one transition, one emphasis.
     main page   entrance: the 3D builds out from the record (js/genesis-scene.js)
                 transition: the step card grows from its corner; a drawer slides
                 in from the card's right edge; the schedule drops from the bar
                 emphasis: the record settles once when it is read back
     learn page  entrance: the page arrives from the side of the chapter it
                 came from; the disc, the title and the bar stay in place
                 transition: tabs and the sub-nav pill move in place
                 emphasis: the page's parts rise and light in the 3D
   Nothing moves while idle (law 55). Reduced motion, from the system or from
   the page's own Motion switch (html[data-motion="reduced"],
   js/genesis-motion.js), keeps every state change and drops the travel. */

:root {
  /* the home redesign's glide: the words and the things they name land alike */
  --g-ease: cubic-bezier(.22, .7, .18, 1);
  --g-ease-in: cubic-bezier(.5, 0, .75, .4);
  --g-dur-1: 140ms;  /* a control answering: hover, a pill, a menu */
  --g-dur-2: 280ms;  /* a panel arriving: the card, a drawer, the disc stepping aside */
  --g-dur-3: 520ms;  /* a page arriving */
}

/* Controls answer at the first step of the scale. */
[data-dx-product="genesis"] :is(.g-tile, .g-split__head, .g-safe-row, .g-seq button, .g-seq button::after,
  .dx-choice, .l-subnav a, .l-vtab, .g-navmenu__sum, .l-pages a, .l-onward a) {
  transition: color var(--g-dur-1) var(--g-ease), background-color var(--g-dur-1) var(--g-ease),
    border-color var(--g-dur-1) var(--g-ease), box-shadow var(--g-dur-1) var(--g-ease);
}

/* A menu opens down from its word: structural, short. */
@media (prefers-reduced-motion: no-preference) {
  html:not([data-motion="reduced"]) :is(.g-navmenu, .g-learnmenu)[open] > :is(.g-navmenu__list, .g-learnmenu__list) {
    animation: g-drop var(--g-dur-1) var(--g-ease) 1; transform-origin: 0 0;
  }
}
@keyframes g-drop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* The step card grows up from its corner (it lives bottom right). */
@media (min-width: 981px) and (prefers-reduced-motion: no-preference) {
  html:not([data-motion="reduced"]) .g-act[data-size="open"] { animation: g-card-open var(--g-dur-2) var(--g-ease) 1; transform-origin: 100% 100%; }
  /* The disc steps aside when the card opens; the 3D follows it frame by frame. */
  html:not([data-motion="reduced"]) .g-disc { transition: left var(--g-dur-2) var(--g-ease), width var(--g-dur-2) var(--g-ease); }
}
@keyframes g-card-open { from { opacity: .35; transform: translateY(14px) scale(.975); } to { opacity: 1; transform: none; } }
/* On a phone the open card is a bottom sheet: it rises from the bottom edge. (The drawers are pages since 2026-11-25: no motion of their own.) */
@media (max-width: 980px) and (prefers-reduced-motion: no-preference) {
  html:not([data-motion="reduced"]) .g-act[data-size="open"] { animation: g-from-bottom var(--g-dur-2) var(--g-ease) 1; }
}
@keyframes g-from-bottom { from { opacity: .4; transform: translateY(28px); } to { opacity: 1; transform: none; } }

/* The one emphasis on the main page: the record settles once when read back.
   A brightness swell on the disc's words, not a fade of the whole button. */
@media (prefers-reduced-motion: no-preference) {
  html:not([data-motion="reduced"]) .g-disc[data-phase="sealed"] { animation: none; }
  html:not([data-motion="reduced"]) .g-disc[data-phase="sealed"] .g-disc__state { animation: g-seal 900ms var(--g-ease) 1; }
}
@keyframes g-seal { from { opacity: .3; letter-spacing: .12em; } to { opacity: 1; letter-spacing: 0; } }

/* Pages: cross-document view transitions (Chrome and Edge 126+, Safari 18.2+).
   Elsewhere the link is an ordinary navigation. The bar, the disc, the eyebrow
   and the title keep their names, so they stay or morph in place; the rest of
   the page arrives from the side of the chapter it came from (01 Mint, then
   02 Overview to 08 Threats; js/genesis-motion.js sets the direction). */
@view-transition { navigation: auto; }
[data-dx-product="genesis"] .dx-bar { view-transition-name: g-bar; }
.g-disc { view-transition-name: g-record; }
.g-eyebrow { view-transition-name: g-eyebrow; }
:is(.g-title, .l-title) { view-transition-name: g-title; }
.l-subnav { view-transition-name: g-subnav; }
::view-transition-group(*) { animation-duration: var(--g-dur-3); animation-timing-function: var(--g-ease); }
::view-transition-group(g-bar) { animation-duration: 0s; }
::view-transition-old(root) { animation: var(--g-dur-2) var(--g-ease-in) both g-out-left; }
::view-transition-new(root) { animation: var(--g-dur-3) var(--g-ease) both g-in-right; }
html:active-view-transition-type(back)::view-transition-old(root) { animation-name: g-out-right; }
html:active-view-transition-type(back)::view-transition-new(root) { animation-name: g-in-left; }
::view-transition-old(g-title) { animation: var(--g-dur-2) var(--g-ease-in) both g-fade-out; }
::view-transition-new(g-title) { animation: var(--g-dur-3) var(--g-ease) both g-title-in; }
@keyframes g-out-left { to { opacity: 0; transform: translateX(-32px); } }
@keyframes g-out-right { to { opacity: 0; transform: translateX(32px); } }
@keyframes g-in-right { from { opacity: 0; transform: translateX(40px); } }
@keyframes g-in-left { from { opacity: 0; transform: translateX(-40px); } }
@keyframes g-fade-out { to { opacity: 0; } }
@keyframes g-title-in { from { opacity: 0; transform: translateY(10px); clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }

/* Reduced motion: the state still changes; nothing travels. A page change is
   a short crossfade, or none when the reader switched motion off here. */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation-duration: 120ms !important; animation-name: g-fade-out; }
  ::view-transition-new(*) { animation-name: none !important; }
}
html[data-motion="reduced"] *, html[data-motion="reduced"] *::before, html[data-motion="reduced"] *::after {
  animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important;
}
/* With nothing travelling, a view that leaves has nothing to show on its way out: it goes at once,
   so its words never stand over the next view's (filmed 2026-10-23: a part's title stood over the
   learn page's for 250 ms). The 3D lands at once too (js/genesis-scene.js returns a 0 ms flight). */
html[data-motion="reduced"] .g-app > .view.out { visibility: hidden; }
@media (prefers-reduced-motion: reduce) { .g-app > .view.out { visibility: hidden; } }

/* The Motion switch in the footer (js/genesis-motion.js). */
.g-motion {
  display: inline-flex; align-items: center; gap: var(--sp-3); min-height: var(--dxt-key-h); padding: 0 var(--sp-4); margin-left: var(--sp-4); cursor: pointer;
  border: 0; border-radius: var(--dxt-r); background: hsl(var(--raised)); box-shadow: var(--dxt-key);
  font: 600 var(--fs-tertiary)/1 var(--font-sans); letter-spacing: var(--dxt-key-space); text-transform: uppercase; color: hsl(var(--text-muted));
}
.g-motion:hover { color: hsl(var(--text-strong)); background: color-mix(in oklab, hsl(var(--text-strong)) 12%, hsl(var(--raised))); }
.g-motion:focus-visible { outline: 2px solid hsl(var(--reference)); outline-offset: 2px; }
.g-motion__dot { width: 7px; height: 7px; border-radius: 50%; background: hsl(var(--signal)); }
.g-motion[aria-pressed="false"] .g-motion__dot { background: transparent; box-shadow: inset 0 0 0 1.5px hsl(var(--text-faint)); }
