/* ==================================================
   Codexal — Motion Layer
   Proprietary Software. NOT OPEN SOURCE.
   Copyright (c) Codexal. All Rights Reserved.

   Loaded after site.css on every page of every edition, so one change
   here lands on all 26 language editions at once.

   What this file owns:
     - the motion token set (easing, duration, direction)
     - shared reading polish: anchor offsets under the sticky header,
       and the measure/rhythm of long-form pages
     - a fail-safe replacement for the [data-animate] reveal
     - interaction polish on the shared header, footer, cards, buttons
     - a single, honest prefers-reduced-motion contract

   Rules this file keeps to:
     - only transform / opacity / filter are animated (no layout reflow)
     - no bare `ease`; every transition names a token
     - exits are shorter than entrances
     - every horizontal transform is multiplied by --dir, so the whole
       system mirrors itself in the RTL editions (ar, ur, sd, ks)
   ================================================== */

/* ---------- 1. TOKENS ------------------------------------- */
:root {
  --ease-out-quint: cubic-bezier(.22, 1, .36, 1);
  --ease-out-expo:  cubic-bezier(.16, 1, .3, 1);
  --ease-in-out:    cubic-bezier(.65, 0, .35, 1);

  /* spring fallbacks; upgraded to real linear() springs below */
  --spring:      cubic-bezier(.22, 1, .36, 1);
  --spring-snap: cubic-bezier(.34, 1.42, .64, 1);

  --dur-micro: .14s;   /* exit, release — always faster than entry */
  --dur-ui:    .24s;   /* hover, press, toggle */
  --dur-enter: .62s;   /* element entrance */
  --dur-slow:  .9s;    /* large panels */

  /* reading direction multiplier */
  --dir: 1;
}

/* linear() springs land in browsers that also have scroll timelines,
   so one @supports gate covers both upgrades. */
@supports (animation-timeline: scroll()) {
  :root {
    --spring: linear(0, .0033 .8%, .0263 2.39%, .0896 4.77%, .4676 12.75%, .6219 15.49%, .7536 18.24%, .8627 21%, .9377 23.72%, .9881 26.46%, 1.0217 29.21%, 1.0405 32.26%, 1.0441 35.68%, 1.0379 39.68%, 1.0053 52.42%, .9995 58.49%, 1.0002 74.48%, 1);
    --spring-snap: linear(0, .0696 2.3%, .2655 5%, .8318 11.4%, 1.0355 13.6%, 1.1442 16.1%, 1.1639 17.5%, 1.1697 18.8%, 1.1613 20.1%, 1.1399 21.6%, 1.0862 24.5%, 1.0168 28.2%, .9901 30.9%, .9773 34.6%, .9873 40.4%, 1.0012 48.8%, 1.0032 55.6%, .9998 76.8%, 1);
  }
}

[dir="rtl"] { --dir: -1; }


/* ---------- 2. FAIL-SAFE REVEAL --------------------------- */
/* site.css parks [data-animate] at opacity:0 and waits for JS. If a
   script fails, 203 elements across the site stay blank. Here the
   resting state is visible, and motion.js hides only what is below the
   fold — so the first painted frame is always a complete page. */
[data-animate] {
  opacity: 1;
  transform: none;
  transition: none;
}

html.has-motion [data-animate].mo-pending {
  opacity: 0;
}

html.has-motion [data-animate].mo-in {
  animation: mo-rise var(--dur-enter) var(--ease-out-expo) var(--mo-delay, 0ms) both;
}

@keyframes mo-rise {
  from { opacity: 0; transform: translate3d(0, 18px, 0) scale(.988); }
  to   { opacity: 1; transform: none; }
}

/* directional variants, mirrored by --dir */
html.has-motion [data-animate="fade-down"].mo-in { animation-name: mo-drop; }
@keyframes mo-drop {
  from { opacity: 0; transform: translate3d(0, -14px, 0); }
  to   { opacity: 1; transform: none; }
}

html.has-motion [data-animate="slide-in"].mo-in { animation-name: mo-slide; }
@keyframes mo-slide {
  from { opacity: 0; transform: translate3d(calc(var(--dir) * 26px), 0, 0); }
  to   { opacity: 1; transform: none; }
}

html.has-motion [data-animate="zoom"].mo-in { animation-name: mo-zoom; }
@keyframes mo-zoom {
  from { opacity: 0; transform: scale(.94); }
  to   { opacity: 1; transform: none; }
}


/* ---------- 3. SCROLL PROGRESS ---------------------------- */
.mo-progress {
  position: fixed; inset-block-start: 0; inset-inline: 0;
  block-size: 2px; z-index: 2000; pointer-events: none;
  background: linear-gradient(to right, var(--blue), var(--green), var(--yellow), var(--red));
  transform: scaleX(var(--mo-p, 0));
  transform-origin: left center;
}
[dir="rtl"] .mo-progress { transform-origin: right center; }

@supports (animation-timeline: scroll()) {
  .mo-progress {
    animation: mo-grow linear;
    animation-timeline: scroll(root block);
  }
  @keyframes mo-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
}


/* ---------- 4. SHARED HEADER ------------------------------ */
/* motion.js sets .is-stuck on a rAF-throttled scroll handler, replacing
   the per-event inline box-shadow write in site.js. */
.site-header {
  transition:
    background-color var(--dur-ui) var(--ease-out-quint),
    border-color     var(--dur-ui) var(--ease-out-quint),
    box-shadow       var(--dur-ui) var(--ease-out-quint);
}
.site-header.is-stuck {
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  box-shadow: 0 1px 0 rgba(2, 8, 23, .06), 0 8px 28px rgba(2, 8, 23, .07);
}

.site-header .brand__img {
  transition: transform var(--dur-ui) var(--spring-snap);
}
.site-header .brand:hover .brand__img { transform: scale(1.03); }

/* nav links: the underline wipes in from the reading-start edge */
.site-header .menu > a {
  position: relative;
  transition: color var(--dur-micro) var(--ease-out-quint);
}
.site-header .menu > a::after {
  content: "";
  position: absolute; inset-block-end: 2px; inset-inline-start: 11px; inset-inline-end: 11px;
  block-size: 1.5px; border-radius: 2px; background: currentColor;
  transform: scaleX(0); transform-origin: var(--mo-uo, left);
  transition: transform var(--dur-ui) var(--ease-out-quint);
}
[dir="rtl"] .site-header .menu > a::after { --mo-uo: right; }
.site-header .menu > a:hover::after,
.site-header .menu > a.active::after { transform: scaleX(1); }
/* the CTA is a filled button, not a text link — no underline on it */
.site-header .menu > a.cta::after { display: none; }
.site-header .menu > a.cta {
  transition: transform var(--dur-micro) var(--ease-out-quint), opacity var(--dur-ui) var(--ease-out-quint);
}
.site-header .menu > a.cta:hover  { opacity: .9; }
.site-header .menu > a.cta:active { transform: scale(.96); transition-duration: 60ms; }

/* burger → X */
.burger span { transition: transform var(--dur-ui) var(--spring-snap), opacity var(--dur-micro) linear; }
.burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; transform: scaleX(.3); }
.burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }


/* ---------- 5. LAUNCHER / LANGUAGE PANELS ----------------- */
/* Both panels grow out of the button they belong to rather than
   appearing from nowhere. */
.toolpick__panel,
.langpick__panel {
  transform-origin: var(--mo-origin, top left);
  animation: mo-panel var(--dur-ui) var(--spring-snap) both;
}
[dir="rtl"] .toolpick__panel,
[dir="rtl"] .langpick__panel { --mo-origin: top right; }

@keyframes mo-panel {
  from { opacity: 0; transform: translateY(-6px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

.toolpick__chev { transition: transform var(--dur-ui) var(--spring-snap); }
.toolpick__btn[aria-expanded="true"] .toolpick__chev { transform: rotate(180deg); }

.toolpick__item {
  transition:
    background-color var(--dur-micro) var(--ease-out-quint),
    transform        var(--dur-micro) var(--ease-out-quint);
}
.toolpick__item:hover  { transform: translateY(-1px); }
.toolpick__item:active { transform: translateY(0) scale(.98); transition-duration: 60ms; }
.toolpick__item img { transition: transform var(--dur-ui) var(--spring-snap); }
.toolpick__item:hover img { transform: scale(1.08) rotate(-3deg); }

.toolpick__all svg,
.langpick__btn svg { transition: transform var(--dur-ui) var(--spring-snap); }
.toolpick__all:hover svg { transform: translateX(calc(var(--dir) * 3px)); }

/* panel children arrive in reading order */
.toolpick__panel .toolpick__item,
.langpick__panel .langpick__opt { animation: mo-pop .3s var(--ease-out-quint) both; }
@keyframes mo-pop {
  from { opacity: 0; transform: translate3d(calc(var(--dir) * -6px), 3px, 0); }
  to   { opacity: 1; transform: none; }
}
.toolpick__panel .toolpick__item:nth-child(1) { animation-delay: .02s; }
.toolpick__panel .toolpick__item:nth-child(2) { animation-delay: .05s; }
.toolpick__panel .toolpick__item:nth-child(3) { animation-delay: .08s; }
.toolpick__panel .toolpick__item:nth-child(4) { animation-delay: .11s; }
.toolpick__panel .toolpick__item:nth-child(5) { animation-delay: .14s; }
.toolpick__panel .toolpick__item:nth-child(6) { animation-delay: .17s; }


/* ---------- 6. CARDS, BUTTONS, LINKS ---------------------- */
.card, .svc-card, .case-card, .post-card {
  transition:
    transform    var(--dur-ui) var(--ease-out-quint),
    box-shadow   var(--dur-ui) var(--ease-out-quint),
    border-color var(--dur-ui) var(--ease-out-quint);
}
.card:hover, .svc-card:hover, .case-card:hover, .post-card:hover {
  transform: translateY(-3px);
}

.btn, .btn-primary, .btn-ghost, .btn-primary-glow, .btn-ghost-glow {
  transition:
    transform  var(--dur-micro) var(--ease-out-quint),
    box-shadow var(--dur-ui)    var(--ease-out-quint),
    opacity    var(--dur-ui)    var(--ease-out-quint);
}
.btn:active, .btn-primary:active, .btn-ghost:active,
.btn-primary-glow:active, .btn-ghost-glow:active {
  transform: scale(.97);
  transition-duration: 60ms;
}
/* arrows lean toward the direction of travel, mirrored in RTL */
.btn svg, .btn-primary-glow svg, .btn-ghost-glow svg {
  transition: transform var(--dur-ui) var(--spring-snap);
}
.btn:hover svg, .btn-primary-glow:hover svg { transform: translateX(calc(var(--dir) * 3px)); }

/* footer links */
.fc-quick a, .foot-col a {
  position: relative;
  transition: color var(--dur-micro) var(--ease-out-quint);
}
.fc-quick a::after, .foot-col a::after {
  content: "";
  position: absolute; inset-block-end: -2px; inset-inline-start: 0;
  inline-size: 100%; block-size: 1px; background: currentColor;
  transform: scaleX(0); transform-origin: var(--mo-uo, left);
  transition: transform var(--dur-ui) var(--ease-out-quint);
}
[dir="rtl"] .fc-quick a::after, [dir="rtl"] .foot-col a::after { --mo-uo: right; }
.fc-quick a:hover::after, .foot-col a:hover::after { transform: scaleX(1); }

.fc-social a, .socials a {
  transition:
    transform    var(--dur-ui) var(--spring-snap),
    color        var(--dur-ui) var(--ease-out-quint),
    border-color var(--dur-ui) var(--ease-out-quint);
}
.fc-social a:hover, .socials a:hover  { transform: translateY(-2px); }
.fc-social a:active, .socials a:active { transform: translateY(0) scale(.94); transition-duration: 60ms; }

.v-link {
  transition:
    transform    var(--dur-micro) var(--ease-out-quint),
    border-color var(--dur-ui)    var(--ease-out-quint),
    color        var(--dur-ui)    var(--ease-out-quint);
}
.v-link:hover { transform: translateY(-1px); }

/* magnetic primary CTAs — motion.js writes --mo-dx / --mo-dy */
[data-magnet] { transform: translate3d(var(--mo-dx, 0), var(--mo-dy, 0), 0); }
[data-magnet]:not(:hover) { transition: transform .45s var(--spring); }


/* ---------- 6b. HEADLINE SPLIT ---------------------------- */
/* motion.js splits any [data-split] heading into words so it resolves
   in reading order — which flips with --dir. An inline element inside
   the heading (a gradient run, a highlighted phrase) is kept whole, so
   its colour ramp stays continuous instead of restarting per word. */
[data-split] .hw {
  display: inline-block;
  animation: mo-word-in .7s var(--ease-out-expo) both;
  animation-delay: calc(.1s + var(--i, 0) * .045s);
}

@keyframes mo-word-in {
  from { opacity: 0; transform: translate3d(calc(var(--dir) * 14px), 0, 0); filter: blur(7px); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}


/* ---------- 6c. CARD SPOTLIGHT ---------------------------- */
/* Put data-spotlight on any card grid. motion.js writes --mx/--my from
   the pointer; the paint stays on the compositor and nothing here
   triggers layout. The light sits above the card fill and below its
   content. */
[data-spotlight] > * { position: relative; }

[data-spotlight] > *::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(360px circle at var(--mx, 50%) var(--my, 50%),
              color-mix(in oklab, var(--mo-accent, var(--blue)) 13%, transparent), transparent 62%);
  opacity: 0;
  transition: opacity var(--dur-ui) var(--ease-out-quint);
}

[data-spotlight] > *:hover::before { opacity: 1; }
[data-spotlight] > * > * { position: relative; z-index: 1; }

/* Cards carry a colour from the brand quad, cycling down the grid, so a
   row of otherwise identical cards is still distinguishable. */
[data-spotlight] > *:nth-child(4n + 1) { --mo-accent: var(--blue); }
[data-spotlight] > *:nth-child(4n + 2) { --mo-accent: var(--green); }
[data-spotlight] > *:nth-child(4n + 3) { --mo-accent: var(--red); }
[data-spotlight] > *:nth-child(4n + 4) { --mo-accent: var(--yellow); }

[data-spotlight] > *:hover {
  border-color: color-mix(in oklab, var(--mo-accent, var(--blue)) 34%, transparent);
}


/* ---------- 6d. INNER-PAGE HERO --------------------------- */
/* The inner heroes are a bare h1 + lead, which reads flat next to the
   homepage. This gives them the same brand tint without touching their
   markup: a pseudo-element inset to the hero, so it cannot push the
   document sideways the way a free-standing blob would. The gradient is
   anchored to the reading-start corner, so it mirrors in RTL.

   section.hero (not .section.hero) so it also catches the solution
   sub-pages, which open with a bare <section class="hero">. */
.hero-svc,
.hero-about,
section.hero {
  position: relative;
  isolation: isolate;
  overflow: clip;
}

.hero-svc::before,
.hero-about::before,
section.hero::before {
  content: "";
  position: absolute;
  inset: -20% -5% -40%;
  z-index: 0;                 /* above the hero's own background fill,
                                 below its content. -1 would sit behind
                                 an opaque background and never show. */
  pointer-events: none;
  opacity: .55;
  filter: blur(80px);
  background:
    radial-gradient(42% 60% at calc(50% - var(--dir) * 36%) 18%, color-mix(in oklab, var(--blue) 26%, transparent), transparent 70%),
    radial-gradient(38% 55% at calc(50% + var(--dir) * 32%) 34%, color-mix(in oklab, var(--green) 22%, transparent), transparent 72%),
    radial-gradient(30% 45% at calc(50% + var(--dir) * 8%) 76%, color-mix(in oklab, var(--yellow) 16%, transparent), transparent 74%);
}

.hero-svc > *,
.hero-about > *,
section.hero > * { position: relative; z-index: 1; }

/* the lead follows the heading in rather than arriving with it */
.hero-svc .lead,
.hero-about .lead,
section.hero .lead {
  animation: mo-rise var(--dur-enter) var(--ease-out-expo) .22s both;
}

/* The six service sub-pages ship their own hero wash built on
   rgba(124,58,237) — a purple that is not in the Codexal palette, on 18
   pages across the three source editions. Same gradient geometry, brand
   colours: element+class beats the page's own .svc-hero rule, so this
   needs no edit in any of those files. */
section.svc-hero {
  background:
    radial-gradient(circle at 80% 20%, color-mix(in oklab, var(--blue) 9%, transparent) 0%, transparent 50%),
    radial-gradient(circle at 20% 80%, color-mix(in oklab, var(--green) 9%, transparent) 0%, transparent 50%);
}
/* it already carries its own wash, so it does not take the shared one */
section.svc-hero::before { content: none; }

/* Its heading is painted with the same off-palette purple ramp
   (#1e1b4b → #7c3aed). Brought onto the brand ink-to-blue, again by
   element+class so none of the 18 files needs editing. The heading
   keeps background-clip:text, so motion.js leaves it unsplit. */
section.svc-hero h1 {
  /* background-image, not the `background` shorthand: the shorthand
     resets background-clip to border-box, which un-clips the text and
     paints the gradient as a solid block over the heading. */
  background-image: linear-gradient(135deg, var(--text, #0B1220), var(--blue));
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
}


/* ---------- 6e. TOOL UI ----------------------------------- */
/* The converters are the most interactive surface on the site and the
   one place where feedback is load-bearing: the visitor needs to know
   the drop registered, the file was accepted, and work is happening.
   These classes come from tools.css and are shared by 28 tool pages
   across every edition.

   Each selector doubles its class (.tool-drop.tool-drop). tools.css is
   linked by the tool pages themselves, which is after head.php loads
   this file, so an equal-specificity rule there would win. Doubling
   lifts these to (0,2,0) without relying on an ancestor — the four
   tool partials do not share a common wrapper. */

/* the drop zone answers the drag with a spring, not a colour swap */
.tool-drop.tool-drop {
  transition:
    background-color var(--dur-ui)    var(--ease-out-quint),
    border-color     var(--dur-ui)    var(--ease-out-quint),
    transform        var(--dur-micro) var(--ease-out-quint);
}
.tool-drop.tool-drop:hover { border-color: color-mix(in oklab, var(--blue) 55%, transparent); }
.tool-drop.tool-drop.is-over { transform: scale(1.012); transition-timing-function: var(--spring-snap); }
.tool-drop.tool-drop:active  { transform: scale(.995); transition-duration: 60ms; }

.tool-drop__icon.tool-drop__icon {
  transition: transform var(--dur-ui) var(--spring-snap);
  will-change: transform;
}
.tool-drop.tool-drop.is-over .tool-drop__icon.tool-drop__icon { transform: translateY(-4px) scale(1.06); }

/* a file row / status row appears when work starts; give it an entrance
   rather than letting it pop into the layout */
.tool-row.tool-row[data-tool-file]:not([hidden]),
.tool-row.tool-row[data-tool-status]:not([hidden]) {
  animation: mo-rise var(--dur-ui) var(--ease-out-quint) both;
}

.tool-btn.tool-btn {
  transition:
    transform  var(--dur-micro) var(--ease-out-quint),
    opacity    var(--dur-ui)    var(--ease-out-quint),
    box-shadow var(--dur-ui)    var(--ease-out-quint);
}
.tool-btn.tool-btn:active:not(:disabled) { transform: scale(.96); transition-duration: 60ms; }
.tool-btn.tool-btn:disabled { opacity: .55; }

.tool-link.tool-link { transition: color var(--dur-micro) var(--ease-out-quint); }

/* While a job runs the bar is a real percentage, so it keeps animating
   width — the tool scripts own that value. The curve is at least named
   here instead of a bare `ease`, and the sheen makes a slow conversion
   read as working rather than stalled. */
.tool-progress__bar.tool-progress__bar {
  transition: width var(--dur-ui) var(--ease-out-quint);
  position: relative;
  overflow: hidden;
}
.tool-progress__bar.tool-progress__bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent);
  transform: translateX(-100%);
  animation: mo-sheen 1.4s var(--ease-in-out) infinite;
}
@keyframes mo-sheen {
  0%   { transform: translateX(-100%); }
  60%, 100% { transform: translateX(100%); }
}


/* ---------- 6f. ANCHORS & LONG-FORM READING --------------- */
/* The header is sticky, so an in-page anchor lands underneath it and the
   heading the reader just jumped to is hidden. scroll-margin pushes the
   landing point clear. This is site-wide: every tools page, every policy
   table of contents, every blog heading link. */
:target,
[id] { scroll-margin-block-start: 88px; }

html { scroll-behavior: smooth; }

/* Legal pages and articles are read, not scanned. Cap the measure so
   lines stay near 70 characters, and give headings room to separate
   sections. The pages set their own colours; this only sets rhythm. */
.policy .container,
.terms .container,
.blog-article {
  max-inline-size: 76ch;
}

.policy h2, .terms h2, .blog-article h2 {
  margin-block-start: 2.2em;
  margin-block-end: .6em;
  line-height: 1.25;
  text-wrap: balance;
  scroll-margin-block-start: 88px;
}

.policy h3, .terms h3, .blog-article h3 {
  margin-block-start: 1.6em;
  margin-block-end: .45em;
  line-height: 1.3;
  text-wrap: balance;
  scroll-margin-block-start: 88px;
}

.policy p, .terms p, .blog-article p { line-height: 1.75; }
.policy li, .terms li { line-height: 1.7; margin-block-end: .4em; }

/* the table of contents is a jump menu, so make its targets read as
   controls rather than as body copy */
.toc a {
  transition:
    background-color var(--dur-micro) var(--ease-out-quint),
    transform        var(--dur-micro) var(--ease-out-quint),
    border-color     var(--dur-ui)    var(--ease-out-quint);
}
.toc a:hover { transform: translateX(calc(var(--dir) * 2px)); }


/* ---------- 7. REDUCED MOTION ----------------------------- */
/* One honest contract: nothing travels, nothing loops, everything is
   readable. Opacity is allowed to settle instantly. */
@media (prefers-reduced-motion: reduce) {
  html.has-motion [data-animate].mo-pending { opacity: 1 !important; }
  html.has-motion [data-animate].mo-in,
  .toolpick__panel, .langpick__panel,
  .toolpick__panel .toolpick__item,
  .langpick__panel .langpick__opt {
    animation: none !important;
  }

  .mo-progress { display: none; }
  [data-split] .hw {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
  }
  [data-spotlight] > *:hover::before { opacity: 0 !important; }
  .tool-progress__bar.tool-progress__bar::after { animation: none !important; content: none; }
  .tool-drop.is-over, .tool-drop.is-over .tool-drop__icon { transform: none !important; }
  .tool-row[data-tool-file]:not([hidden]),
  .tool-row[data-tool-status]:not([hidden]) { animation: none !important; }
  .hero-svc .lead, .hero-about .lead, section.hero .lead { animation: none !important; }
  [data-magnet] { transform: none !important; }
  .toc a:hover { transform: none !important; }

  .card:hover, .svc-card:hover, .case-card:hover, .post-card:hover,
  .fc-social a:hover, .socials a:hover, .v-link:hover,
  .toolpick__item:hover {
    transform: none !important;
  }

  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
  }
}
