/* -------------------------------------------------------------------------- */
/* Animation catalogue.                                                        */
/*                                                                            */
/* A small, named set of CSS-only transitions -- orthogonal to the CI, exactly  */
/* like the master pages: animation is runtime BEHAVIOUR, not identity, so the  */
/* same slide animates the same way under any CI. The runtime only toggles      */
/* classes and sets --anim-dur; every effect below is pure CSS.                 */
/*                                                                            */
/* The one thing an identity may legitimately set is the TEMPO: a sober CI and  */
/* a lively one disagree about how long 'brisk' is. But PAGE and ELEMENT tempos */
/* are independent: how long a slide takes to arrive and how long a bullet      */
/* takes to appear are separate decisions -- our own house deck (Rony's) proves */
/* it, using no page transition at all yet a full second on every fragment. So  */
/* an identity has TWO hooks: --skin-anim-duration-page (default 0s: a cut, no */
/* page transition) and --skin-anim-duration-elem (default 1s). These do not   */
/* let a CI change WHICH effects exist -- the catalogue stays closed.           */
/*                                                                            */
/* Each family seeds its own --anim-dur from its skin hook; the per-element    */
/* anim-duration="N" override still works because the runtime writes --anim-dur */
/* inline on the very element, which wins over the family default below.        */
/*                                                                            */
/* PAGE transitions: put anim="NAME" on a slide heading. Applied as the slide   */
/*   becomes .current. Names: fade (default), slide, fade-color, cut.           */
/* ELEMENT transitions: put anim="NAME" on a .fragment. Applied as it becomes   */
/*   .revealed. Names: fade (default), fade-up, fade-down, fade-left,           */
/*   fade-right, scale-in, blur-in, cut.                                        */
/*                                                                            */
/* anim-duration="N" (on slide or fragment) overrides the duration for that     */
/* one element. N is in SECONDS, like every other time in a deck; an explicit   */
/* "ms" suffix is still honoured. The runtime writes it into --anim-dur.        */
/* -------------------------------------------------------------------------- */

/* Each family seeds --anim-dur from its own skin hook. A page reads the page  */
/* tempo, a fragment reads the element tempo; the runtime's inline --anim-dur   */
/* (from anim-duration="N") overrides either one on the element it is set on.   */
.slide    { --anim-dur: var(--skin-anim-duration-page, 0s); }
.fragment { --anim-dur: var(--skin-anim-duration-elem, 1s); }

/* ---- PAGE transitions -------------------------------------------------- */
/* The runtime adds .anim-in to a slide the moment it becomes current, and     */
/* .anim-back as well when we arrived by going BACKWARDS. Only the slide       */
/* family reads that flag: fade, fade-color and cut are symmetric effects and  */
/* look identical whichever way the deck is travelling, so they ignore it.     */

.slide[data-anim="slide"].current.anim-in     { animation: pg-slide  var(--anim-dur) ease-out; }
.slide[data-anim="fade-color"].current.anim-in{ animation: pg-fadecol var(--anim-dur) ease-out; }
.slide[data-anim="fade"].current.anim-in      { animation: pg-fade   var(--anim-dur) ease-out; }
/* cut = no animation at all; declaring it simply suppresses the default fade. */
.slide[data-anim="cut"].current               { animation: none; }

/* Going back, the push comes from the other side. This is the phone-gallery   */
/* gesture: the direction of travel is what tells the audience whether we are  */
/* advancing or returning, and a 'back' that enters from the same side as a    */
/* 'forward' reads as a glitch. Jumps (the overlay, a hash landing, Ctrl+Home  */
/* /End) carry no direction and so use the forward form: they are arrivals,    */
/* not steps, and inventing a direction for them would be a lie.               */
.slide[data-anim="slide"].current.anim-in.anim-back { animation-name: pg-slide-back; }

@keyframes pg-fade  { from { opacity: 0; } to { opacity: 1; } }
@keyframes pg-slide { from { opacity: 0; transform: translateX(48px); }
                      to   { opacity: 1; transform: translateX(0); } }
@keyframes pg-slide-back { from { opacity: 0; transform: translateX(-48px); }
                           to   { opacity: 1; transform: translateX(0); } }
@keyframes pg-fadecol {
  0%   { opacity: 0; }
  40%  { opacity: 0; background: var(--skin-accent, #0096d3); }
  100% { opacity: 1; }
}

/* ---- ELEMENT (fragment) transitions ------------------------------------ */
/* Fragments occupy their space while hidden, so nothing reflows on reveal.   */

/* Reveal travel is proportional to the DECK, not a fixed pixel count, so the  */
/* gesture reads the same on a projector and a phone -- and matches our house  */
/* deck, whose fade-ups move a tenth of the slide height (ODP "y+.1"). The     */
/* vertical shift is that tenth of --deck-h; the horizontal shift keeps the    */
/* catalogue's old 2:1 ratio to it. A skin may retune --anim-shift-y/-x.      */
.fragment {
  --anim-shift-y: calc(var(--deck-h, 720) * 0.10 * 1px);
  --anim-shift-x: calc(var(--deck-h, 720) * 0.20 * 1px);
  opacity: 0;
  transition: opacity var(--anim-dur) ease-out,
              transform var(--anim-dur) ease-out,
              filter var(--anim-dur) ease-out;
}
.fragment.revealed { opacity: 1; }

/* Pre-reveal offsets per effect. On reveal, the offset returns to zero.      */
.fragment[data-anim="fade-up"]              { transform: translateY(var(--anim-shift-y)); }
.fragment[data-anim="fade-up"].revealed     { transform: translateY(0); }

.fragment[data-anim="fade-down"]            { transform: translateY(calc(-1 * var(--anim-shift-y))); }
.fragment[data-anim="fade-down"].revealed   { transform: translateY(0); }

.fragment[data-anim="fade-left"]            { transform: translateX(calc(-1 * var(--anim-shift-x))); }
.fragment[data-anim="fade-left"].revealed   { transform: translateX(0); }

.fragment[data-anim="fade-right"]           { transform: translateX(var(--anim-shift-x)); }
.fragment[data-anim="fade-right"].revealed  { transform: translateX(0); }

.fragment[data-anim="scale-in"]             { transform: scale(0.9); }
.fragment[data-anim="scale-in"].revealed    { transform: scale(1); }

.fragment[data-anim="blur-in"]              { filter: blur(6px); }
.fragment[data-anim="blur-in"].revealed     { filter: blur(0); }

/* cut on an element mirrors cut on a page: it appears, it does not arrive.   */
/* Without it there was no way to ask for an instant reveal -- the floor was  */
/* always a fade -- which made the two halves of the catalogue asymmetric.    */
.fragment[data-anim="cut"]                  { transition: none; }

@media (prefers-reduced-motion: reduce) {
  .fragment { transition: opacity 1ms; transform: none !important; filter: none !important; }
  .slide.current.anim-in { animation: none !important; }
}

/* ---- LEAFING: Alt+PageDown / Alt+PageUp -------------------------------- */
/* The runtime puts .leafing on the root for the instant it changes slide    */
/* that way, and takes it off once the slide is in its final state: no page  */
/* transition, no fragment animation, the finished slide at once.            */
.leafing .slide.current { animation: none !important; }
.leafing .fragment      { transition: none !important; }

/* ---- PRINT: every fragment is revealed --------------------------------- */
/* On screen a fragment starts at opacity:0 and the runtime adds .revealed as */
/* you click through. Print has no clicks: a slide you never walked to keeps  */
/* all its fragments hidden, so the sheet comes out with only the parts that  */
/* are NOT fragments -- title and footer -- and a blank body. That is Rony's  */
/* 20-Sep report: most slides printed as title+footer only, and forcing each  */
/* page to render by hand (walking the whole deck first) was the workaround,  */
/* because walking is exactly what adds .revealed. Printing means "the finished*/
/* slide, all fragments shown", so here we put every fragment in its revealed  */
/* end-state regardless of .revealed: full opacity, no pre-reveal offset, no   */
/* blur, no transition. runtime.css's @media print dismantles the SCREEN       */
/* scaffolding (stage, scaling, one-slide clipping); this dismantles the       */
/* ANIMATION scaffolding, the other half of the same "screen state leaking     */
/* into paper" bug. .static content was never a fragment, so it already        */
/* printed -- which is why the first line of a slide often survived alone.     */
/* Revealed, not undone (v274, Rony 11-Oct): a fragment prints with the     */
/* transform it has when revealed on screen -- translateY(0), scale(1) --   */
/* and not none. A transform, even a null one, makes the fragment the box   */
/* its positioned blocks are placed in: a callout inside a fade-up block is */
/* placed against that block, on screen and on paper alike. With none, it  */
/* was placed against the slide on paper, at the block's numbers: in the    */
/* top left corner. A fragment with no effect of that kind has none, as on */
/* screen. A turn is rotate (its own property), never transform.           */
@media print {
  .fragment {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
    transition: none !important;
  }
  .fragment[data-anim="fade-up"], .fragment[data-anim="fade-down"] {
    transform: translateY(0) !important;
  }
  .fragment[data-anim="fade-left"], .fragment[data-anim="fade-right"] {
    transform: translateX(0) !important;
  }
  .fragment[data-anim="scale-in"] { transform: scale(1) !important; }
}
