/* =========================================================
   Site-wide motion (every page except start-settling.html).
   Load after the page's own stylesheets. Home adds home-motion.css
   on top for its notifications, platform diagram and impact charts.

   site-motion.js adds "motion" to <html> only when the visitor has
   not asked for reduced motion, so without it (or without JavaScript)
   pages look exactly as styled. Every animation ends on that design.

   Redesigned pages (<main class="page">): rules are scoped to .page,
   .band--hero, .site-header and .site-footer, because the older
   Tailwind/daisyUI pages use the same names (.btn, .card, .grid,
   .hero) for different things. Sections get "is-in" as they scroll
   into view; --n (set by site-motion.js) staggers items in a list.

   Older pages: site-motion.js marks content blocks below the first
   screen with "mo-reveal" and fades them up as they scroll in.

   Entrances use the individual `translate` / `scale` properties so
   they never fight the `transform` used by hover states.
   ========================================================= */

.motion {
  --ease-out: cubic-bezier(0.16, 0.84, 0.24, 1);
  --ease-back: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---------- Page to page: the logo stays put ----------
   Cross-document view transitions (both pages must load this file, so
   start-settling.html is never involved): when moving between pages the
   header logo is carried over as one fixed element instead of being
   blanked and repainted, while the rest of the page swaps underneath
   with a short crossfade. Browsers without support simply navigate as
   before. Not tied to .motion, because <html> has no classes yet when
   the transition starts; reduced motion turns it off. */
@view-transition {
  navigation: auto;
}

.site-header__brand img {
  view-transition-name: site-logo;
}

/* No movement or fade: the outgoing and incoming logos sit on top of
   each other, so the logo is never blank even for a frame */
::view-transition-group(site-logo),
::view-transition-old(site-logo),
::view-transition-new(site-logo) {
  animation: none;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.2s;
}

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }
}

/* ---------- Keyframes ---------- */
@keyframes mo-rise {
  from { opacity: 0; translate: 0 28px; }
  to { opacity: 1; translate: 0 0; }
}

@keyframes mo-rise-blur {
  from { opacity: 0; translate: 0 0.35em; filter: blur(10px); }
  to { opacity: 1; translate: 0 0; filter: blur(0); }
}

@keyframes mo-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes mo-pop {
  0% { opacity: 0; scale: 0.4; rotate: -12deg; }
  70% { opacity: 1; scale: 1.08; rotate: 3deg; }
  100% { opacity: 1; scale: 1; rotate: 0deg; }
}

@keyframes mo-from-left {
  from { opacity: 0; translate: -36px 0; }
  to { opacity: 1; translate: 0 0; }
}

@keyframes mo-from-right {
  from { opacity: 0; translate: 36px 0; }
  to { opacity: 1; translate: 0 0; }
}

@keyframes mo-show { to { opacity: 1; } }

@keyframes mo-glow-blue {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 114, 250, 0); }
  50% { box-shadow: 0 0 14px 2px rgba(16, 114, 250, 0.45); }
}

/* Radiating ring: a box-shadow that grows and fades */
@keyframes mo-radiate {
  0% { box-shadow: 0 0 0 0 var(--ring); opacity: 1; }
  70%, 100% { box-shadow: 0 0 0 16px transparent; opacity: 0; }
}

@keyframes mo-radiate-self {
  0% { box-shadow: 0 0 0 0 var(--ring); }
  70%, 100% { box-shadow: 0 0 0 12px transparent; }
}

@keyframes mo-shine {
  0% { background-position: 150% 0; }
  35%, 100% { background-position: -60% 0; }
}

@keyframes mo-arrow {
  0%, 60%, 100% { translate: 0 0; }
  75% { translate: 5px 0; }
  90% { translate: 1px 0; }
}

/* =========================================================
   Redesigned pages
   ========================================================= */

/* ---------- Hero (plays on load, and again each time it scrolls back
   into view: site-motion.js toggles "is-in" on .band--hero) ---------- */
/* The hero content drifts down a little as the page scrolls. It does not
   fade: fading made the white buttons see-through over the dot pattern
   (user, 2026-11-02: "Book a demo" must stay clear white). */
.motion .band--hero .hero__inner {
  translate: 0 calc(var(--hero-scroll, 0) * 70px);
  will-change: translate;
}

/* Hidden while off screen, ready to replay. The 3s fallback shows it
   anyway if the script never runs. */
.motion .band--hero:not(.is-in) :is(
  .hero__inner > :nth-child(1), .hero__inner > :nth-child(3), .hero__inner > :nth-child(4), .mo-word
) {
  opacity: 0;
  animation: mo-show 0s 3s forwards;
}

.motion .band--hero.is-in .hero__inner > :nth-child(1) { animation: mo-rise 0.9s var(--ease-out) 0.1s both; }
.motion .band--hero.is-in .hero__inner > :nth-child(3) { animation: mo-rise 0.9s var(--ease-out) 0.8s both; }
.motion .band--hero.is-in .hero__inner > :nth-child(4) { animation: mo-rise 0.9s var(--ease-out) 0.95s both; }

/* Headline: site-motion.js wraps each word, then they rise one by one */
.motion .band--hero :is(.h-display, .h-page):not(.is-split) {
  opacity: 0;
  animation: mo-show 0s 3s forwards;
}

.motion .band--hero .mo-word {
  display: inline-block;
}

.motion .band--hero.is-in .mo-word {
  animation: mo-rise-blur 1s var(--ease-out) both;
  animation-delay: calc(0.3s + var(--i) * 0.12s);
}

/* The dot pattern slowly breathes */
@keyframes mo-breathe {
  from { scale: 1; opacity: 1; }
  to { scale: 1.06; opacity: 0.7; }
}

.motion .band--hero .pattern::before {
  transform-origin: 100% 0;
  animation: mo-breathe 9s ease-in-out infinite alternate;
}

/* Home's badge arrow nudges every few seconds */
@keyframes mo-nudge {
  0%, 80%, 100% { translate: 0 0; }
  86% { translate: 5px 0; }
  92% { translate: 0 0; }
  96% { translate: 3px 0; }
}

.motion .hero-badge svg {
  animation: mo-nudge 3.6s ease-in-out 2s infinite;
}

/* ---------- Section entrances ----------
   Heads: eyebrow, title and intro text (some heads wrap eyebrow +
   title in a <div>; its children animate, not the wrapper).
   Items: the children of every list or grid, staggered by --n.
   Blocks: single panels that rise as one piece. */
.motion .page > :not(.is-in) :is(
  .section-head > :not(div), .section-head > div > *,
  .split > .stack > *, .container > .stack > *,
  .cta__inner > *, .faq-layout__intro > *
),
.motion .page > :not(.is-in) :is(.grid, .ruled-grid, .stat-grid, .jobs, .faq-list, .form-grid, .icon-rows, .news-list) > *,
.motion .page > :not(.is-in) :is(.form-card, .mock-window, .quote, .notice) {
  opacity: 0;
}

.motion .page > .is-in :is(
  .section-head > :not(div), .section-head > div > *,
  .split > .stack > *, .container > .stack > *,
  .cta__inner > *, .faq-layout__intro > *
) {
  animation: mo-rise 0.9s var(--ease-out) calc(var(--n, 0) * 0.12s) both;
}

.motion .page > .is-in :is(.grid, .ruled-grid, .stat-grid, .jobs, .faq-list, .form-grid, .icon-rows, .news-list) > * {
  animation: mo-rise 0.8s var(--ease-out) calc(0.15s + var(--n, 0) * 0.1s) both;
}

.motion .page > .is-in :is(.form-card, .mock-window, .quote, .notice) {
  animation: mo-rise 1s var(--ease-out) 0.2s both;
}

/* Form fields cascade in after their card */
.motion .page > .is-in .form-card .form-grid > * {
  animation-delay: calc(0.45s + var(--n, 0) * 0.08s);
}

/* Icon tiles inside list items pop in just after their item */
.motion .page > :not(.is-in) :is(.grid, .ruled-grid) > * .icon-tile { opacity: 0; }

.motion .page > .is-in :is(.grid, .ruled-grid) > * .icon-tile {
  animation: mo-pop 0.7s var(--ease-out) calc(0.3s + var(--n, 0) * 0.1s) both;
}

/* ---------- Numbered steps: progress runs from 01 to 05 ----------
   site-motion.js moves "is-active" along the steps of a .ruled-grid one
   stage at a time while the section is on screen; finished stages get
   "is-done". A bar fills along the bottom of each step as it becomes
   active, with a glowing head at its leading edge; the active step's
   icon turns blue and blinks. The bar is per step, so it still runs in
   order when the steps wrap or stack on smaller screens. */
.motion .page .ruled-grid > .step {
  position: relative;
}

.motion .page .ruled-grid > .step::before,
.motion .page .ruled-grid > .step::after {
  content: "";
  position: absolute;
  bottom: 0;
  pointer-events: none;
}

/* the bar */
.motion .page .ruled-grid > .step::before {
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #5A9BFF, var(--blue));
  transform: scaleX(0);
  transform-origin: left;
}

/* its glowing head */
.motion .page .ruled-grid > .step::after {
  left: 0;
  width: 10px;
  height: 10px;
  margin: 0 0 -3.5px -5px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 4px rgba(16, 114, 250, 0.18), 0 0 12px rgba(16, 114, 250, 0.8);
  opacity: 0;
}

.motion .page .ruled-grid > .step.is-active::before {
  transform: scaleX(1);
  transition: transform var(--stage, 1.3s) linear;
}

.motion .page .ruled-grid > .step.is-done::before {
  transform: scaleX(1);
}

.motion .page .ruled-grid > .step.is-active::after {
  left: 100%;
  opacity: 1;
  transition: left var(--stage, 1.3s) linear, opacity 0.2s ease;
}

.motion .page .ruled-grid > .step .step__num {
  transition: color 0.3s ease;
}

.motion .page .ruled-grid > .step:is(.is-active, .is-done) .step__num {
  color: var(--blue);
}

/* the active stage's icon lights up and blinks */
@keyframes mo-stage-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.motion .page .ruled-grid > .step .icon-tile {
  transition: transform 0.35s var(--ease-back), background-color 0.25s ease, color 0.25s ease, box-shadow 0.3s ease;
}

.motion .page .ruled-grid > .step.is-active .icon-tile {
  background-color: var(--blue);
  color: var(--white);
  box-shadow: 0 0 0 6px rgba(16, 114, 250, 0.15), 0 8px 20px rgba(16, 114, 250, 0.35);
}

.motion .page .ruled-grid > .step.is-active .icon-tile svg {
  animation: mo-stage-blink 0.43s ease-in-out 3;
}

/* ---------- Hover: icons tilt, link cards lift ---------- */
.motion .page :is(.step, .feature, .card, .partner, .value-card) .icon-tile {
  transition: transform 0.35s var(--ease-back), background-color 0.2s ease, color 0.2s ease;
}

.motion .page :is(.step, .feature, .card, .partner, .value-card):hover .icon-tile {
  transform: translateY(-4px) rotate(-6deg);
}

.motion .page :is(.step, .feature, .card, .partner):hover .icon-tile:not(.icon-tile--white) {
  background-color: var(--blue);
  color: var(--white);
}

.motion .page .card--link {
  transition: border-color 0.15s ease, box-shadow 0.3s ease, transform 0.4s var(--ease-out);
}

.motion .page .card--link:hover {
  transform: translateY(-6px);
}

.motion .page .card--link:hover .icon-tile {
  transform: rotate(-8deg) scale(1.08);
  background-color: var(--tint);
  color: var(--blue);
}

.motion .page :is(.job, .news-card) {
  transition: transform 0.4s var(--ease-out), background-color 0.15s ease;
}

.motion .page .job:hover { transform: translateX(6px); }
.motion .page .news-card:hover { transform: translateY(-6px); }

/* ---------- Text links: arrow pulse, glow and underline ---------- */
.motion .page .text-link svg {
  animation: mo-arrow 2.4s ease-in-out calc(var(--n, 0) * 0.3s) infinite;
  transition: transform 0.4s var(--ease-back);
}

.motion .page .text-link {
  width: fit-content;   /* in a card it would stretch to the card's width */
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1.5px no-repeat;
  transition: background-size 0.4s var(--ease-out), text-shadow 0.3s ease;
}

/* The underline stops at the end of the words, before the arrow
   (18px icon + 8px gap) */
.motion .page :is(.card--link, .job, .news-card):hover .text-link,
.motion .page a.text-link:hover {
  background-size: calc(100% - 26px) 1.5px;
  text-shadow: 0 0 14px rgba(16, 114, 250, 0.45);
}

.motion .page :is(.card--link, .job, .news-card):hover .text-link svg {
  transform: translateX(5px);
}

/* ---------- Buttons: radiating ring + shine sweep ----------
   Both live on pseudo-elements so they never replace a button's own
   entrance. Each button gets a --ring-delay so they don't pulse in
   unison. */
.motion .page .btn,
.motion .site-header .btn--header,
.motion .hero-badge {
  --ring: rgba(16, 114, 250, 0.45);
  --shine: rgba(255, 255, 255, 0.4);
  position: relative;
  isolation: isolate;
}

.motion .page :is(.btn--white, .btn--ghost),
.motion .hero-badge { --ring: rgba(255, 255, 255, 0.6); }

.motion .page .btn--secondary { --shine: rgba(16, 114, 250, 0.16); }

.motion .page .btn::after,
.motion .site-header .btn--header::after,
.motion .hero-badge::after {
  content: "";
  position: absolute;
  inset: -1.5px;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
  animation: mo-radiate 3s ease-out var(--ring-delay, 0s) infinite;
}

/* Shine on the filled blue buttons. White buttons stay solid white
   (user, 2026-11-02), outlined ones have nothing to shine on. */
.motion .page .btn:not(.btn--outline):not(.btn--ghost):not(.btn--white)::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(110deg, transparent 38%, var(--shine) 50%, transparent 62%) 150% 0 / 250% 100% no-repeat;
  animation: mo-shine 4.5s ease-in-out calc(var(--ring-delay, 0s) + 1s) infinite;
}

/* Header "Book a demo": a star border (after reactbits.dev "Star Border",
   user 2026-11-03) instead of the shine. Two glowing stars travel along the
   button's edge, one across the top and one back along the bottom. The
   transparent border plus the mask shows them only in a thin rounded band
   around the edge. */
.motion .site-header .btn--header::before {
  --star: radial-gradient(closest-side, #fff 0%, rgba(214, 233, 255, 0.95) 35%, rgba(120, 180, 255, 0.5) 65%, rgba(120, 180, 255, 0) 100%);
  content: "";
  position: absolute;
  inset: -1.5px;
  z-index: -1;
  border: 3px solid transparent;
  border-radius: inherit;
  pointer-events: none;
  background: var(--star), var(--star);
  background-origin: border-box;
  background-clip: border-box;
  background-repeat: no-repeat;
  background-size: 64px 18px, 64px 18px;
  -webkit-mask: linear-gradient(#000 0 0) padding-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) padding-box exclude, linear-gradient(#000 0 0);
  animation: mo-star-border 5s linear infinite;
}

.motion .site-header .btn--header:is(:hover, :focus-visible)::before {
  animation-duration: 2s;
}

@keyframes mo-star-border {
  0% {
    background-position: -64px -8px, calc(100% + 64px) calc(100% + 8px);
    opacity: 0;
  }
  12% { opacity: 1; }
  88% { opacity: 1; }
  100% {
    background-position: calc(100% + 64px) -8px, -64px calc(100% + 8px);
    opacity: 0;
  }
}

/* Faster ring while hovered or focused; none while disabled */
.motion .page .btn:hover::after,
.motion .page .btn:focus-visible::after,
.motion .site-header .btn--header:hover::after,
.motion .hero-badge:hover::after {
  animation-duration: 1.3s;
  animation-delay: 0s;
}

.motion .page .btn:disabled::before,
.motion .page .btn:disabled::after {
  animation: none;
}

.motion .site-header .btn--header { --ring-delay: 0.2s; }
.motion .band--hero .btn-row > :nth-child(1) { --ring-delay: 1.4s; }
.motion .band--hero .btn-row > :nth-child(2) { --ring-delay: 2.2s; }
.motion .hero-badge { --ring-delay: 2.8s; }
.motion .page .section-head .btn { --ring-delay: 0.4s; }
.motion .page .cta .btn-row > :nth-child(1) { --ring-delay: 0.6s; }
.motion .page .cta .btn-row > :nth-child(2) { --ring-delay: 1.8s; }

/* ---------- Buttons: hover like start-settling's "Request A Callback" ----------
   On hover a button grows a little with a springy overshoot, its letters
   spread slightly, a soft glow lights up inside it (site-motion.js moves
   the glow with the pointer via --gx / --gy) and its shadow deepens;
   pressing shrinks it a touch. */
@property --btn-glow {
  syntax: "<color>";
  inherits: false;
  initial-value: rgba(255, 255, 255, 0);
}

.motion .page .btn,
.motion .site-header .btn--header {
  --btn-glow-on: rgba(255, 255, 255, 0.3);
  --btn-shadow: 0 10px 20px rgba(16, 114, 250, 0.4), 0 6px 8px rgba(16, 114, 250, 0.3);
  background-image: radial-gradient(circle at var(--gx, 50%) var(--gy, 50%), var(--btn-glow) 0%, rgba(255, 255, 255, 0) 70%);
  transition:
    background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease,
    scale 0.3s cubic-bezier(0.2, 0.8, 0.2, 1.2),
    letter-spacing 0.3s cubic-bezier(0.2, 0.8, 0.2, 1.2),
    box-shadow 0.3s ease, --btn-glow 0.3s ease;
}

/* Light and outlined buttons get a blue glow; buttons on blue panels a
   darker shadow */
.motion .page :is(.btn--white, .btn--secondary, .btn--outline) { --btn-glow-on: rgba(16, 114, 250, 0.16); }
.motion .page :is(.btn--white, .btn--ghost) { --btn-shadow: 0 10px 20px rgba(4, 38, 92, 0.35), 0 6px 8px rgba(4, 38, 92, 0.25); }

.motion .page .btn:is(:hover, :focus-visible):not(:disabled),
.motion .site-header .btn--header:is(:hover, :focus-visible) {
  scale: 1.05;
  letter-spacing: 0.5px;
  box-shadow: var(--btn-shadow);
  --btn-glow: var(--btn-glow-on);
}

/* Spreading the letters widens the button, which would push the header's
   language switch sideways (user, 2026-11-04), so the header button only
   grows (scale doesn't move its neighbours) */
.motion .site-header .btn--header:is(:hover, :focus-visible) {
  letter-spacing: normal;
}

.motion .page .btn:active:not(:disabled),
.motion .site-header .btn--header:active {
  scale: 0.98;
}

/* ---------- Sections marked "no-motion": no animation at all ----------
   (user, 2026-11-02: Home's "Built for the whole recovery ecosystem"
   cards). Everything inside shows straight away and stays still: no
   entrance, no icon blink, no hover lift, tilt, underline or arrow
   movement. The design's own hover (blue border and shadow on the
   cards, in mosadad.css) is kept. */
.motion .page > .no-motion *,
.motion .page > .no-motion *::before,
.motion .page > .no-motion *::after {
  animation: none !important;
}

.motion .page > .no-motion * {
  opacity: 1 !important;
  translate: none !important;
  scale: none !important;
  rotate: none !important;
  filter: none !important;
}

.motion .page > .no-motion .card--link,
.motion .page > .no-motion .card--link:hover {
  transform: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.motion .page > .no-motion .card--link .icon-tile,
.motion .page > .no-motion .card--link:hover .icon-tile {
  transform: none;
  background-color: var(--tint);
  color: var(--blue);
  box-shadow: none;
}

.motion .page > .no-motion .text-link,
.motion .page > .no-motion .card--link:hover .text-link {
  background-size: 0 1.5px;
  text-shadow: none;
}

.motion .page > .no-motion .text-link svg,
.motion .page > .no-motion .card--link:hover .text-link svg {
  transform: none !important;   /* also beats the Arabic page's hover rule */
}

/* ---------- Footer social icons: ring on hover ---------- */
.motion .site-footer .social-links a:hover,
.motion .site-footer .social-links a:focus-visible {
  --ring: rgba(255, 255, 255, 0.55);
  animation: mo-radiate-self 1.3s ease-out infinite;
}

/* ---------- FAQs: the answer slides open ---------- */
@keyframes mo-panel {
  from { opacity: 0; translate: 0 -10px; }
  to { opacity: 1; translate: 0 0; }
}

.motion .page .faq__panel:not([hidden]) {
  animation: mo-panel 0.45s var(--ease-out) both;
}

.motion .page .faq__btn:hover .faq__num {
  color: var(--blue);
}

/* ---------- Regulators: the dashboard comes alive ---------- */
@keyframes mo-grow-y {
  0% { transform: scaleY(0); }
  60% { transform: scaleY(1.08); }
  80% { transform: scaleY(0.97); }
  100% { transform: scaleY(1); }
}

@keyframes mo-grow-x {
  0% { transform: scaleX(0); }
  70% { transform: scaleX(1.04); }
  100% { transform: scaleX(1); }
}

@keyframes mo-live-y {
  0%, 100% { scale: 1 1; }
  50% { scale: 1 0.9; }
}

@keyframes mo-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.motion .page .mock-bars span { transform-origin: bottom; }
.motion .page .mock-meter__track span { transform-origin: left; }

.motion .page > :not(.is-in) .mock-bars span { transform: scaleY(0); }
.motion .page > :not(.is-in) .mock-meter__track span { transform: scaleX(0); }
.motion .page > :not(.is-in) :is(.mock-alert, .mock-window__dot) { opacity: 0; }

.motion .page > .is-in .mock-window__dot {
  animation: mo-pop 0.5s var(--ease-out) calc(0.5s + var(--n, 0) * 0.1s) both;
}

.motion .page > .is-in .mock-bars span {
  animation:
    mo-grow-y 1s var(--ease-out) calc(0.6s + var(--n, 0) * 0.08s) both,
    mo-live-y 2.8s ease-in-out calc(2.2s + var(--n, 0) * 0.3s) infinite;
}

.motion .page > .is-in .mock-bars span.is-current {
  animation:
    mo-grow-y 1s var(--ease-out) calc(0.6s + var(--n, 0) * 0.08s) both,
    mo-glow-blue 2.4s ease-in-out 2s infinite;
}

.motion .page > .is-in .mock-meter__track span {
  animation: mo-grow-x 1.2s var(--ease-out) calc(1s + var(--n, 0) * 0.18s) both;
}

.motion .page > .is-in .mock-alert {
  animation: mo-from-right 0.8s var(--ease-out) 1.7s both;
}

.motion .page > .is-in .mock-alert svg {
  animation: mo-blink 1.6s ease-in-out 2.6s infinite;
}

/* =========================================================
   Older pages: content fades up as it scrolls in.
   `backwards` fill hands the element straight back to its own
   styles when the animation ends, so Tailwind hover effects that use
   `translate` keep working.
   ========================================================= */
.motion .mo-reveal:not(.is-in) {
  opacity: 0;
}

.motion .mo-reveal:not(.is-in):not(.mo-fade) {
  translate: 0 24px;
}

.motion .mo-reveal.is-in {
  animation: mo-rise 0.8s var(--ease-out) calc(var(--n, 0) * 0.08s) backwards;
}

.motion .mo-reveal.mo-fade.is-in {
  animation-name: mo-fade;
}

/* =========================================================
   Back-to-top button (every page). Self-contained colours, because
   the older pages don't have the redesign's tokens. Works without
   the "motion" class; only its halo is motion-only. site-motion.js
   shows it once the page is scrolled and fills the ring with scroll
   progress.
   ========================================================= */
/* It always sits above the page bar (and above the older pages' phone
   language toggle): site-motion.js measures both and sets --bar-space and
   --toggle-space. The fallbacks match the bar's usual heights. */
.back-to-top {
  position: fixed;
  right: 24px;
  bottom: calc(var(--bar-space, 84px) + var(--toggle-space, 0px));
  z-index: 101;
  box-sizing: border-box;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #1072FA;
  color: #FFFFFF;
  box-shadow: 0 12px 30px rgba(16, 114, 250, 0.4);
  text-decoration: none;
  transition: opacity 0.3s ease, visibility 0.3s ease, translate 0.4s var(--ease-out, ease), scale 0.4s var(--ease-out, ease), background-color 0.15s ease;
}

/* Wide screens have room beside the centred page bar, so the button sits
   level with it (centred on the bar: the bar is 16px from the bottom and
   --bar-space is its height + 28px), and the footer needs less space */
@media (min-width: 1024px) {
  .back-to-top {
    bottom: calc((var(--bar-space, 76px) - 28px) / 2 - 12px + var(--toggle-space, 0px));
  }
}

.back-to-top:hover {
  background: #0B55BD;
  color: #FFFFFF;
}

.back-to-top:focus-visible {
  outline: 3px solid #1C2025;
  outline-offset: 3px;
}

.mo-js .back-to-top:not(.is-shown) {
  opacity: 0;
  visibility: hidden;
  translate: 0 16px;
  scale: 0.8;
}

.back-to-top svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.back-to-top .back-to-top__arrow {
  width: 22px;
  height: 22px;
  stroke-width: 2.2;
  transition: translate 0.3s var(--ease-out, ease);
}

.back-to-top:hover .back-to-top__arrow {
  translate: 0 -3px;
}

/* Scroll-progress ring */
.back-to-top .back-to-top__ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  rotate: -90deg;
  stroke-width: 3;
}

.back-to-top__ring circle:first-child {
  stroke: rgba(255, 255, 255, 0.25);
}

.back-to-top__ring circle + circle {
  stroke: #FFFFFF;
  stroke-dasharray: 100;
  stroke-dashoffset: calc(100 - var(--page-progress, 0) * 100);
}

.motion .back-to-top.is-shown {
  --ring: rgba(16, 114, 250, 0.5);
  animation: mo-radiate-self 2.6s ease-out 0.4s infinite;
}

@media (max-width: 768px) {
  .back-to-top {
    right: 16px;
    width: 50px;
    height: 50px;
  }
}

/* Printing never scrolls sections into view, so show everything */
@media print {
  .motion .page > :not(.is-in) *,
  .motion .mo-reveal {
    opacity: 1 !important;
    animation: none !important;
    clip-path: none !important;
  }

  .motion .mo-reveal { translate: none !important; }
  .motion .page :is(.mock-bars, .mock-meter__track) span { transform: none !important; }

  .motion .band--hero .hero__inner { translate: none; opacity: 1; }
  .back-to-top { display: none; }
}

/* ---------- Menus: pill hover ----------
   After reactbits.dev "Pill Nav" (user, 2026-11-03): header menu and page
   bar. site-motion.js adds .pn-fill (the circle), .pn-face (the label)
   and .pn-face-alt (the label's copy in the fill's colour) to each link.
   On hover or keyboard focus the circle swells up from the bottom edge
   and the labels roll up. Header: blue fill, white label. Page bar:
   white fill, dark label. */
.motion .pn-item {
  --pn-fill: var(--blue, #1072FA);
  --pn-ink: #FFFFFF;
  --pn-roll: 2.4em;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.motion .page-bar .pn-item {
  --pn-fill: #FFFFFF;
  --pn-ink: #1C2025;
  display: inline-block;
}

.motion .pn-face,
.motion .pn-face-alt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: inherit;
  transition: translate 0.36s cubic-bezier(0.22, 1, 0.36, 1);
}

/* The copy sits exactly where the label is: same padding and alignment */
.motion .pn-face-alt {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  padding: inherit;
  justify-content: inherit;
  color: var(--pn-ink);
  translate: 0 var(--pn-roll);
}

.motion .pn-fill {
  position: absolute;
  top: 100%;
  left: 50%;
  z-index: -1;
  /* Wide enough to cover the whole pill from its bottom edge */
  width: max(160%, 6em);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--pn-fill);
  translate: -50% -50%;
  scale: 0;
  transition: scale 0.36s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

/* Header menu: the fill is plain blue, no pattern (review comments
   2026-11-09) */
.motion .site-header .pn-fill {
  background: var(--blue, #1072FA);
}

/* ...so the link itself keeps its resting look (site-chrome.css gives it
   the pattern straight away, for when there is no motion) */
.motion .site-header .nav-link.pn-item:hover:not([aria-current="page"]):not(.is-active):not([aria-expanded="true"]) {
  background: transparent;
  color: var(--ink);
}

.motion .pn-item:is(:hover, :focus-visible) .pn-fill {
  scale: 1;
  transition: scale 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.motion .pn-item:is(:hover, :focus-visible) .pn-face {
  translate: 0 calc(var(--pn-roll) * -1);
  transition-duration: 0.5s;
}

.motion .pn-item:is(:hover, :focus-visible) .pn-face-alt {
  translate: 0 0;
  transition-duration: 0.5s;
}

/* Page bar logo spins once on hover (Pill Nav) */
@keyframes mo-logo-spin {
  from { rotate: 0deg; }
  to { rotate: 360deg; }
}

.motion .page-bar__logo:is(:hover, :focus-visible) img {
  animation: mo-logo-spin 0.9s cubic-bezier(0.65, 0, 0.25, 1);
}

/* "All news" back link on news stories (user, 2026-11-12): no underline at
   rest; on hover the line runs under the whole text, right to its end.
   The arrow comes first here, so the line is anchored to the text end
   (right in English, left in Arabic) instead of stopping 26px short. */
.page a.text-link.article__back,
.page a.text-link.article__back:hover {
  text-decoration: none;
}

.motion .page a.text-link.article__back {
  background-position: 100% 100%;
}

html[dir="rtl"] .page a.text-link.article__back {
  background-position: 0 100%;
}
