/* Lillirode design system -- motion. Load after components.css and tokens-motion.css.
   Every rule sits inside prefers-reduced-motion: no-preference and html:not([data-motion="off"]); outside them the page is the static page, nothing lost.
   Only transform and opacity move (the card corner's arcs also change stroke colour). The hover and focus transitions also change colour, border colour and shadow of one small control (paint, no layout).
   No width, height, margin, padding or top/left is ever animated. Values come only from tokens: tokens-motion.css for time, easing and distance, the system's colour and decor tokens for the corner's colours. */

@media (prefers-reduced-motion: no-preference) {

  /* ==== 1. float: the satellites sway along their own orbits (hero sphere, hero dot, divider spark) ====
     Each satellite is a <g class="ds-deco-sat"> whose transform-origin is its orbit's centre, so a rotation moves it along the orbit line and never off it. */
  @keyframes ds-mo-sway {
    from { transform: rotate(calc(var(--ds-mo-arc) * -1)); }
    to   { transform: rotate(var(--ds-mo-arc)); }
  }
  html:not([data-motion="off"]) .ds-deco-sat {
    --ds-mo-half: calc(var(--ds-mo-period) / 2);
    animation: ds-mo-sway var(--ds-mo-half) var(--ease-float) infinite alternate;
    animation-delay: calc(var(--ds-mo-half) * -.5); /* starts in the middle of the swing, i.e. where the satellite is drawn */
  }
  html:not([data-motion="off"]) .ds-deco-sat--sphere { --ds-mo-arc: var(--float-arc-sphere); --ds-mo-period: var(--dur-float-sphere); }
  html:not([data-motion="off"]) .ds-deco-sat--dot    { --ds-mo-arc: var(--float-arc-dot);    --ds-mo-period: var(--dur-float-dot); }
  /* a looping effect pauses when it is out of view (motion.js sets data-offscreen) */
  html:not([data-motion="off"]) [data-offscreen] .ds-deco-sat,
  html:not([data-motion="off"]) .ds-divider[data-offscreen] :is(.ds-deco-sat, .ds-deco-orbit) { animation-play-state: paused; }

  /* ==== 1b. the divider ring: the small open ring with the gold spark makes one slow full turn, rests, and turns again.
     The ring path and the spark group rotate together about the ring's centre (160 12 in its drawing, set in the svg), so the spark stays on the ring.
     This replaces the sway for the divider: its spark no longer sways. The turn is the last 24 percent of the cycle, the rest the first 76. ==== */
  @keyframes ds-mo-turn {
    0%, 76% { transform: rotate(0deg); animation-timing-function: var(--ease-float); }
    100%    { transform: rotate(360deg); }
  }
  html:not([data-motion="off"]) .ds-divider :is(.ds-deco-sat, .ds-deco-orbit) {
    --ds-mo-ring-centre: 160px 12px; /* the ring's centre in the divider's drawing, elements/svg/divider-*.svg */
    transform-origin: var(--ds-mo-ring-centre);
    animation: ds-mo-turn var(--dur-turn-cycle) linear infinite;
  }

  /* ==== 1c. the corner of a decorated card: its two arcs flash one after the other, like a signal (inner, then outer), once, when the card is hovered or focused
     (and once when it has just arrived only where the card carries data-wave: motion.js then adds class ds-mo-wave; a card without it never flashes by itself). Each arc goes from its drawn colour to the light colour, then to lilac, and back to its drawn colour,
     at full opacity at the top. The arcs are inline svg in the card (elements/README.md), so their stroke is animated by CSS from the tokens; a corner drawn as an image does not flash. ==== */
  @keyframes ds-mo-wave {
    22% { stroke: var(--decor-flash); opacity: var(--glow-peak); }
    55% { stroke: var(--color-second); opacity: var(--glow-peak); }
  }
  html:not([data-motion="off"]) :is(.ds-card--deco:is(:hover, :focus-within, .is-hover), .ds-card--deco.ds-mo-wave) .ds-card__corner path {
    animation: ds-mo-wave var(--dur-wave) var(--ease-calm) both;
  }
  html:not([data-motion="off"]) :is(.ds-card--deco:is(:hover, :focus-within, .is-hover), .ds-card--deco.ds-mo-wave) .ds-card__corner path:nth-child(2) {
    animation-delay: var(--dur-wave-step);
  }

  /* ==== 2a. arrival of the hero on load: text rises, the portrait only fades (nothing travels round her face) ==== */
  @keyframes ds-mo-rise { from { opacity: 0; transform: translate3d(0, var(--move-rise), 0); } to { opacity: 1; transform: none; } }
  @keyframes ds-mo-fade { from { opacity: 0; } to { opacity: 1; } }
  html:not([data-motion="off"]) .ds-hero__kicker,
  html:not([data-motion="off"]) .ds-hero__title { animation: ds-mo-rise var(--dur-enter) var(--ease-enter) both; }
  html:not([data-motion="off"]) .ds-hero__lead { animation: ds-mo-rise var(--dur-enter) var(--ease-enter) var(--dur-stagger) both; }
  html:not([data-motion="off"]) .ds-hero__actions { animation: ds-mo-rise var(--dur-enter) var(--ease-enter) calc(var(--dur-stagger) * 2) both; }
  html:not([data-motion="off"]) .ds-hero__media { animation: ds-mo-fade var(--dur-enter) var(--ease-enter) var(--dur-stagger) both; }

  /* ==== 2b. entrance of sections and cards on scroll: an element marked data-reveal rises once and stays.
     Hidden only while motion.js is running (class ds-mo on the root); without the script, or with it off, everything is simply there. ==== */
  html.ds-mo:not([data-motion="off"]) [data-reveal] {
    --ds-mo-delay: 0ms; opacity: 0; transform: translate3d(0, var(--move-rise), 0);
    transition: opacity var(--dur-enter) var(--ease-enter) var(--ds-mo-delay), transform var(--dur-enter) var(--ease-enter) var(--ds-mo-delay);
  }
  html.ds-mo:not([data-motion="off"]) [data-reveal].is-in { opacity: 1; transform: none; }
  html.ds-mo:not([data-motion="off"]) [data-reveal]:focus-within { opacity: 1; transform: none; transition: none; } /* focus never waits: a focused element is shown at once */
  @media print { html.ds-mo:not([data-motion="off"]) [data-reveal] { opacity: 1; transform: none; transition: none; } }

  /* ==== 2c. the feature icon drawn in once: an icon marked data-draw (class ds-feature-icon) is hidden as a dashed line while motion.js is running, and when it has scrolled into view
     motion.js adds is-drawn and the line draws from its start to its end, once; when it has played the attribute is removed and the icon is the ordinary still icon.
     --ds-mo-dash is longer than any stroke of the 24-unit icons, so the dash covers a whole path at the end. Without the script, or under reduced motion, the icon is simply drawn and still. ==== */
  @keyframes ds-mo-draw { from { stroke-dashoffset: var(--ds-mo-dash); } to { stroke-dashoffset: 0; } }
  html.ds-mo:not([data-motion="off"]) [data-draw] { --ds-mo-dash: 120; stroke-dasharray: var(--ds-mo-dash); stroke-dashoffset: var(--ds-mo-dash); }
  html.ds-mo:not([data-motion="off"]) [data-draw].is-drawn { animation: ds-mo-draw var(--dur-draw) var(--ease-calm) both; }
  @media print { html.ds-mo:not([data-motion="off"]) [data-draw] { stroke-dasharray: none; stroke-dashoffset: 0; } }

  /* ==== 3. hover, press and focus of buttons, links, cards: colour and shadow settle, a card that leads on rises. The focus ring itself is never delayed. ==== */
  html:not([data-motion="off"]) :is(.ds-button, .ds-link, .ds-site-header__link, .ds-site-header__menu, .ds-site-footer__link, .ds-lang__button, .ds-lang__item, .ds-theme-toggle, .ds-prose a) {
    transition: color var(--dur-quick) var(--ease-calm), background-color var(--dur-quick) var(--ease-calm), border-color var(--dur-quick) var(--ease-calm),
                box-shadow var(--dur-quick) var(--ease-calm), transform var(--dur-quick) var(--ease-calm);
  }
  html:not([data-motion="off"]) .ds-button:is(:active, .is-active) { transform: scale(var(--scale-press)); }
  html:not([data-motion="off"]) .ds-card--link {
    transition: box-shadow var(--dur-soft) var(--ease-calm), border-color var(--dur-soft) var(--ease-calm), transform var(--dur-soft) var(--ease-calm);
  }
  html:not([data-motion="off"]) .ds-card--link:is(:hover, .is-hover) { transform: translate3d(0, calc(var(--move-lift) * -1), 0); }

  /* ==== 4. disclosures: the language list and the phone menu open and close softly (opacity and a short slide).
     display is transitioned as a discrete property; a browser without it opens and closes at once, as today. ==== */
  html:not([data-motion="off"]) .ds-lang__list {
    transform-origin: top; opacity: 1; transform: none;
    transition: opacity var(--dur-soft) var(--ease-calm), transform var(--dur-soft) var(--ease-calm), display var(--dur-soft) allow-discrete;
  }
  html:not([data-motion="off"]) .ds-lang__list[hidden] { opacity: 0; transform: translate3d(0, calc(var(--move-drop) * -1), 0); }
  @starting-style {
    html:not([data-motion="off"]) .ds-lang__list { opacity: 0; transform: translate3d(0, calc(var(--move-drop) * -1), 0); }
  }
  @container scr (not (min-width: 1024px)) {
    html:not([data-motion="off"]) .ds-site-header__nav {
      opacity: 0; transform: translate3d(0, calc(var(--move-drop) * -1), 0);
      transition: opacity var(--dur-soft) var(--ease-calm), transform var(--dur-soft) var(--ease-calm), display var(--dur-soft) allow-discrete;
    }
    html:not([data-motion="off"]) .ds-site-header[data-open] .ds-site-header__nav { opacity: 1; transform: none; }
    @starting-style {
      html:not([data-motion="off"]) .ds-site-header[data-open] .ds-site-header__nav { opacity: 0; transform: translate3d(0, calc(var(--move-drop) * -1), 0); }
    }
  }
}
