/* ==========================================================================
   Motion — motion.css (1 Dec 2026)
   Loaded on the public pages only, after base.css and public.css. It adds
   movement and nothing else: no colours, no sizes, no layout.

   Rules this file keeps:
   - Only transform and opacity move. The one exception is the height of an
     opened question, which a person starts with a click.
   - Everything sits inside "prefers-reduced-motion: no-preference". With
     reduced motion on, this file does nothing and base.css switches every
     transition and animation off.
   - Nothing is hidden by CSS alone, apart from short entrances that always
     end visible. Scroll reveals hide a block only after public/js/motion.js
     has put the class .rv on it, so a page without JavaScript shows it all.
   - The hero headline never fades or moves: it is readable on the first frame.
     The long intro text under it starts at 30% and is fully there in 0.6 s.
   - Entrances fill "backwards" only, so when they end the element is back on
     its own styles and hover movement still works.
   ========================================================================== */

:root {
  --m-out: cubic-bezier(0.22, 1, 0.36, 1);
  --m-inout: cubic-bezier(0.65, 0, 0.35, 1);
  --m-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (prefers-reduced-motion: no-preference) {
  /* -------------------------------------------------------------- first screen: entrance */
  /* The pill drops in, the intro and the buttons rise one after the other. The headline stands still
     while its thread draws (base.css, wott-draw). */
  .hero .beta-pill,
  .page-hero .beta-pill,
  .sales-hero .beta-pill {
    animation: m-drop 0.55s var(--m-out) backwards;
  }
  .beta-pill::before {
    animation: m-beat 2.6s ease-in-out 1.2s infinite;
  }
  .hero .lede,
  .page-hero .lede,
  .page-hero .hero-sub,
  .sales-hero .lede {
    animation: m-rise-soft 0.6s var(--m-out) backwards;
  }
  .hero .hero-ctas,
  .page-hero .hero-ctas,
  .page-hero .hero-choose,
  .sales-hero .sales-cta {
    animation: m-rise 0.6s var(--m-out) 0.14s backwards;
  }
  .hero .hero-ctas > .btn:nth-child(2),
  .page-hero .hero-ctas > .btn:nth-child(2) {
    animation: m-rise-sm 0.5s var(--m-out) 0.3s backwards;
  }

  /* The thread under the headline word (base.css, wott-draw): before it starts to draw, its round ends showed
     as two dots. A longer gap and a start a little further back keep it fully out of sight until it draws. */
  .hero .on > svg path,
  .page-hero .on > svg path {
    stroke-dasharray: 1 2;
    stroke-dashoffset: 1.06;
  }

  /* The big pale bubble behind the first screen drifts very slowly. */
  .hero-ghost {
    animation: m-ghost 18s ease-in-out infinite alternate;
  }

  /* -------------------------------------------------------------- first screen: the example card */
  /* The card itself never moves, so its small text stays sharp. Its ink shadow slides out and back, slowly,
     which reads as the card lifting off the page for as long as it is on screen. */
  .hero-card-stack::before {
    animation: m-lift 5.5s ease-in-out 1.4s infinite alternate;
  }
  .hero.is-off .hero-card-stack::before,
  .hero.is-off .hero-ghost,
  .hero.is-off .beta-pill::before {
    animation-play-state: paused;
  }
  /* With a mouse the shadow leans away from the pointer, as if the pointer were the light (motion.js sets
     --sx and --sy, at most 6 px each way). */
  .hero-card-stack.is-lit::before {
    animation: none;
    transform: translate(var(--sx, 0px), var(--sy, 0px));
    transition: transform 0.25s var(--m-out);
  }
  /* Two columns: the card is on the first screen, so it arrives with the page. */
  @media (min-width: 860px) {
    .hero .hero-card-figure,
    .page-hero-grid > :not(.page-hero-copy),
    .sales-hero-grid > :not(.sales-hero-copy) {
      animation: m-card-in 0.85s var(--m-out) 0.12s backwards;
    }
    .hero .hero-card-top .badge.ok {
      animation: m-pop 0.5s var(--m-spring) 0.95s backwards;
    }
    .hero .hero-card-top .badge.ok svg path {
      stroke-dasharray: 22;
      animation: m-tick 0.35s ease-out 1.2s backwards;
    }
  }
  /* One column: the card is further down, so it arrives when it scrolls into view. */
  .hero-card-figure.rv.is-in .badge.ok {
    animation: m-pop-b 0.5s var(--m-spring) 0.45s backwards;
  }
  .hero-card-figure.rv.is-in .badge.ok svg path {
    stroke-dasharray: 22;
    animation: m-tick-b 0.35s ease-out 0.7s backwards;
  }

  /* -------------------------------------------------------------- scroll reveals */
  /* motion.js puts .rv on blocks that start below the screen, and .is-in when they scroll into view.
     --rv-d staggers blocks that arrive together. When the move is over the script takes both classes off. */
  .rv {
    opacity: 0;
    transform: translateY(22px);
  }
  .rv.is-in {
    opacity: 1;
    transform: none;
    transition:
      opacity 0.55s ease-out var(--rv-d, 0ms),
      transform 0.75s var(--m-out) var(--rv-d, 0ms);
  }
  /* Steps: the numbered bubble pops, then the thread runs on to the next one. */
  .step.rv.is-in .step-n,
  .rv.is-in > .principle-n {
    animation: m-pop 0.55s var(--m-spring) calc(var(--rv-d, 0ms) + 0.12s) backwards;
  }
  .step.rv.is-in::after {
    transform-origin: 50% 0;
    animation: m-run-y 0.6s var(--m-out) calc(var(--rv-d, 0ms) + 0.35s) backwards;
  }
  @media (min-width: 860px) {
    .step.rv.is-in::after {
      transform-origin: 0 50%;
      animation-name: m-run-x;
    }
  }
  /* Ticks in a list pop one after the other when their card arrives. */
  .rv.is-in .list-check li > svg {
    animation: m-pop 0.45s var(--m-spring) calc(var(--rv-d, 0ms) + 0.25s) backwards;
  }
  .rv.is-in .list-check li:nth-child(2) > svg {
    animation-delay: calc(var(--rv-d, 0ms) + 0.32s);
  }
  .rv.is-in .list-check li:nth-child(3) > svg {
    animation-delay: calc(var(--rv-d, 0ms) + 0.39s);
  }
  .rv.is-in .list-check li:nth-child(4) > svg {
    animation-delay: calc(var(--rv-d, 0ms) + 0.46s);
  }
  .rv.is-in .list-check li:nth-child(n + 5) > svg {
    animation-delay: calc(var(--rv-d, 0ms) + 0.53s);
  }
  /* A headline word on the thread further down the page draws when its block arrives. */
  .rv.is-in .on > svg path {
    stroke-dasharray: 1 2;
    animation: m-draw 0.9s cubic-bezier(0.6, 0, 0.2, 1) calc(var(--rv-d, 0ms) + 0.25s) backwards;
  }

  /* -------------------------------------------------------------- buttons and card links */
  /* The colour swap stays instant (base.css). The button itself lifts 2 px and gives a little when pressed;
     its arrow leans forward. */
  .btn {
    transition: transform 0.2s var(--m-out);
  }
  .btn .icon,
  .card-arrow svg {
    transition: transform 0.25s var(--m-out);
  }
  .btn:active {
    transform: scale(0.97);
    transition-duration: 0.06s;
  }
  .card-stretch {
    transition: transform 0.3s var(--m-out);
  }
  @media (hover: hover) {
    .btn:hover {
      transform: translateY(-2px);
    }
    .btn:hover:active {
      transform: translateY(0) scale(0.97);
    }
    .btn:hover .icon:last-child,
    .card-stretch:hover .card-arrow svg {
      transform: translateX(4px);
    }
    .card-stretch:hover {
      transform: translateY(-4px);
    }
  }
  .card-stretch:active {
    transform: translateY(0) scale(0.99);
    transition-duration: 0.08s;
  }

  /* -------------------------------------------------------------- menus */
  /* The two top menus, the language card and the phone menu open from their button: a short drop and fade.
     Their rows follow, a few hundredths of a second apart. */
  .nav-menu[open] > .nav-menu-panel {
    transform-origin: 24px 0;
    animation: m-menu 0.22s var(--m-out) backwards;
  }
  .lang-menu[open] > .lang-menu-panel,
  .site-header .menu[open] > .menu-panel {
    transform-origin: calc(100% - 24px) 0;
    animation: m-menu 0.22s var(--m-out) backwards;
  }
  .nav-menu[open] > .nav-menu-panel li,
  .lang-menu[open] > .lang-menu-panel li {
    animation: m-rise-sm 0.32s var(--m-out) 0.04s backwards;
  }
  .nav-menu[open] > .nav-menu-panel li:nth-child(2),
  .lang-menu[open] > .lang-menu-panel li:nth-child(2) {
    animation-delay: 0.075s;
  }
  .nav-menu[open] > .nav-menu-panel li:nth-child(3),
  .lang-menu[open] > .lang-menu-panel li:nth-child(3) {
    animation-delay: 0.11s;
  }
  .nav-menu[open] > .nav-menu-panel li:nth-child(n + 4),
  .lang-menu[open] > .lang-menu-panel li:nth-child(n + 4) {
    animation-delay: 0.145s;
  }
  /* Closing: where the browser lets us style the inside of <details>, the panel fades out instead of
     vanishing. A closing panel takes no clicks. Other browsers close it at once, as before. */
  @supports selector(::details-content) {
    .nav-menu::details-content,
    .lang-menu::details-content,
    .site-header .menu::details-content {
      opacity: 0;
      pointer-events: none;
      transition:
        opacity 0.14s ease,
        content-visibility 0.14s allow-discrete;
    }
    .nav-menu[open]::details-content,
    .lang-menu[open]::details-content,
    .site-header .menu[open]::details-content {
      opacity: 1;
      pointer-events: auto;
    }
  }

  /* -------------------------------------------------------------- questions (FAQ) */
  /* The answer fades in under its question. */
  details.disclosure[open] > div {
    animation: m-answer 0.4s var(--m-out) backwards;
  }
  /* Where the browser can move between a fixed height and "auto", the row also opens and closes smoothly. */
  @supports (interpolate-size: allow-keywords) and selector(::details-content) {
    details.disclosure {
      interpolate-size: allow-keywords;
    }
    details.disclosure::details-content {
      height: 0;
      overflow: clip;
      transition:
        height 0.28s var(--m-inout),
        content-visibility 0.28s allow-discrete;
    }
    details.disclosure[open]::details-content {
      height: auto;
    }
  }
  /* The plus turns into the minus: the upright bar lies down onto the flat one. */
  .faq details.disclosure > summary {
    position: relative;
  }
  .faq details.disclosure > summary::after {
    background: linear-gradient(var(--accent-strong), var(--accent-strong)) center / 100% 2.4px no-repeat;
  }
  .faq details.disclosure > summary::before {
    content: '';
    position: absolute;
    right: 7.8px;
    top: 50%;
    width: 2.4px;
    height: 14px;
    margin-top: -7px;
    background: var(--accent-strong);
    transition: transform 0.3s var(--m-out);
  }
  .faq details.disclosure[open] > summary::before {
    transform: rotate(90deg);
  }

  /* -------------------------------------------------------------- guides: the thread shows how far you have read */
  /* A red line along the bottom of the header grows with the page. Only where the browser can tie an
     animation to scrolling; elsewhere there is no line. */
  @supports (animation-timeline: scroll()) {
    body:has(article.guide) .site-header::after {
      content: '';
      position: absolute;
      left: 0;
      right: 0;
      bottom: -5px;
      height: 3px;
      background: var(--red);
      transform-origin: 0 50%;
      transform: scaleX(0);
      animation: m-read linear both;
      animation-timeline: scroll(root block);
      pointer-events: none;
    }
  }
}

/* Print: nothing waits for a scroll. */
@media print {
  .rv {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* -------------------------------------------------------------- keyframes */
/* Each one names only its start: the end is the element's own style. */
@keyframes m-drop {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
}
@keyframes m-rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
}
@keyframes m-rise-sm {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
/* For the long intro text: never fully hidden, so it counts as painted from the first frame. */
@keyframes m-rise-soft {
  from {
    opacity: 0.3;
    transform: translateY(12px);
  }
}
@keyframes m-card-in {
  from {
    opacity: 0;
    transform: translate(26px, 20px) rotate(2.5deg);
  }
}
@keyframes m-pop {
  from {
    opacity: 0;
    transform: scale(0.6);
  }
}
@keyframes m-pop-b {
  from {
    opacity: 0;
    transform: scale(0.6);
  }
}
@keyframes m-tick {
  from {
    stroke-dashoffset: 22;
  }
}
@keyframes m-tick-b {
  from {
    stroke-dashoffset: 22;
  }
}
@keyframes m-draw {
  from {
    stroke-dashoffset: 1.06;
  }
}
@keyframes m-run-x {
  from {
    opacity: 0;
    transform: scaleX(0);
  }
}
@keyframes m-run-y {
  from {
    opacity: 0;
    transform: scaleY(0);
  }
}
@keyframes m-menu {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.97);
  }
}
@keyframes m-answer {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}
@keyframes m-lift {
  to {
    transform: translate(5px, 6px);
  }
}
@keyframes m-ghost {
  from {
    transform: translate(0, 0) rotate(-3deg);
  }
  to {
    transform: translate(-2.5%, 3%) rotate(4deg);
  }
}
@keyframes m-beat {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.45;
    transform: scale(0.7);
  }
}
@keyframes m-read {
  to {
    transform: scaleX(1);
  }
}
