/* ==========================================================================
   motion.css — how things move (v3). Works with assets/js/motion.js.
   Content is only hidden when html.motion is set (motion allowed and the
   browser supports it). With "reduce motion" every page is complete and still.
   Contents
     1. Reveal on scroll
     2. Headline words and the landing dot
     3. Section HUD index
     4. Cursor ring
     5. Page transition veil
     6. (retired: drift field)
     7. Kinetic tagline band
     8. Menu glide and tab thumb
     9. Continuous life: icon tiles, beams, scan lines
   ========================================================================== */
:root { --ease-out: cubic-bezier(0.16, 1, 0.3, 1); }

/* ---- 1. Reveal on scroll ------------------------------------------------ */
/* --rd is the stagger delay; motion.js resets it to 0 once the element has
   arrived, so hover effects afterwards respond at once. */
.motion [data-reveal] {
  transition:
    opacity 0.9s var(--ease-out) var(--rd, 0ms),
    translate 1s var(--ease-out) var(--rd, 0ms),
    scale 1s var(--ease-out) var(--rd, 0ms),
    filter 0.9s var(--ease-out) var(--rd, 0ms),
    clip-path 1.1s var(--ease-out) var(--rd, 0ms),
    transform 0.35s var(--ease-out), box-shadow 0.4s var(--ease-out), border-color 0.4s,
    background-color 0.3s;
}
.motion [data-reveal]:not(.is-in) { opacity: 0; translate: 0 34px; filter: blur(8px); }
.motion [data-reveal="scale"]:not(.is-in) { translate: 0 26px; scale: 0.94; }
.motion [data-reveal="decode"]:not(.is-in) { translate: 0 10px; filter: none; }
/* Logos are never faded or distorted (brand rule): they are wiped in. */
/* (Logos read left to right, so they wipe in from the left in Arabic too.) */
.motion [data-reveal="wipe"]:not(.is-in) { opacity: 1; translate: none; filter: none; clip-path: inset(0 100% 0 0); }
.motion [data-reveal="wipe"].is-in { clip-path: inset(0 0 0 0); }
/* Headline wrappers stay in place; their words move (section 2). */
.motion [data-reveal="words"]:not(.is-in), .motion [data-reveal="hud"]:not(.is-in) { opacity: 1; translate: none; filter: none; }

/* Safety net: if motion.js never runs, headings in the first screen still appear. */
.motion :is(.hero, .page-hero) h1:not([data-reveal]) { animation: failsafe 0.01s 2.5s both; }
@keyframes failsafe { from { opacity: 0; } to { opacity: 1; } }

/* ---- 2. Headline words and the landing dot ------------------------------ */
.w { display: inline-block; overflow: hidden; vertical-align: top; padding-block: 0.1em 0.16em; margin-block: -0.1em -0.16em; }
.w > span { display: inline-block; }
.motion [data-reveal="words"] .w > span {
  transition: translate 1s var(--ease-out), opacity 0.8s var(--ease-out);
  transition-delay: calc(var(--rd, 0ms) + var(--i, 0) * 70ms);
}
.motion [data-reveal="words"]:not(.is-in) .w > span { translate: 0 108%; opacity: 0; }
/* The orange full stop lands last, like a probe touching down on Mars. */
.motion [data-reveal="words"] .w .o { display: inline-block; }
.motion [data-reveal="words"].is-in .w .o { animation: dot-land 1.1s var(--ease-out) both; animation-delay: calc(var(--rd, 0ms) + 420ms + var(--i, 0) * 70ms); }
@keyframes dot-land {
  0% { translate: 0 -1.3em; }
  55% { translate: 0 0.06em; }
  72% { translate: 0 -0.12em; }
  100% { translate: 0 0; }
}

/* ---- 3. Section HUD index ----------------------------------------------- */
.section { position: relative; }
.sec-hud {
  position: absolute; top: clamp(22px, 3vw, 38px); left: 0; right: 0; z-index: 1;
  width: 100%; max-width: var(--max); margin-inline: auto; padding-inline: var(--gutter);
  display: flex; align-items: center; gap: 0.9rem; pointer-events: none;
  font-size: var(--fs-label); font-weight: 700; letter-spacing: 0.18em; font-variant-numeric: tabular-nums; color: var(--sky);
}
.sec-hud__n { color: var(--ink); }
.sec-hud__line { position: relative; flex: 1; height: 1px; overflow: hidden; background: linear-gradient(90deg, var(--sky), rgba(113, 181, 226, 0.12)); }
[dir="rtl"] .sec-hud__line { background: linear-gradient(270deg, var(--sky), rgba(113, 181, 226, 0.12)); }
.motion .sec-hud__line { transform-origin: 0 50%; scale: 0 1; transition: scale 1.6s var(--ease-out) 0.1s; }
[dir="rtl"].motion .sec-hud__line { transform-origin: 100% 50%; }
.motion .sec-hud.is-in .sec-hud__line { scale: 1 1; }
.sec-hud__line::after {
  content: ""; position: absolute; top: -1px; bottom: -1px; left: 0; width: 100%; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent calc(50% - 45px), var(--sky) calc(50% - 15px), #FFFFFF 50%, transparent calc(50% + 45px));
}
.motion .sec-hud.is-in .sec-hud__line::after { animation: scan-x 5s linear 1.6s infinite; }
/* A sweep of light across its parent (the parent clips it). Transform only: no layout work. */
@keyframes scan-x { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
[dir="rtl"] .sec-hud__line::after { animation-direction: reverse; }
.sec-hud__t::before { content: "/ "; color: var(--blue-light); }

/* ---- 4. Cursor ring (mouse only) ---------------------------------------- */
.cursor {
  position: fixed; left: 0; top: 0; z-index: 300; pointer-events: none;
  width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%;
  border: 1.5px solid var(--sky);
  transition: width 0.3s var(--ease-out), height 0.3s var(--ease-out), margin 0.3s var(--ease-out), background-color 0.3s, opacity 0.3s, scale 0.2s;
}
/* The centre is our orange dot (v4.11): a flat Mars-orange disc, always full strength. */
.cursor::after { content: ""; position: absolute; left: 50%; top: 50%; width: 7px; height: 7px; margin: -3.5px; border-radius: 50%; background: var(--orange); }
.cursor.is-hover { width: 60px; height: 60px; margin: -30px 0 0 -30px; background-color: rgba(113, 181, 226, 0.12); }
.cursor.is-down { scale: 0.82; }
.cursor.is-hidden { opacity: 0; }

/* ---- 5. Page transition veil -------------------------------------------- */
.px-veil { position: fixed; inset: 0; z-index: 400; pointer-events: none; display: none; }
.px-veil canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.px-veil.is-on { display: block; pointer-events: all; }
html.px-in .px-veil { display: block; background: #FFFFFF; animation: veil-fallback 0.4s 1.8s both; }
html.px-in .px-veil.is-drawn { background: transparent; }
@keyframes veil-fallback { to { opacity: 0; visibility: hidden; } }

/* ---- 6. (Drift field retired: the living lattice is the background animation.) */

/* ---- 7. Kinetic tagline band -------------------------------------------- */
.kinetic { overflow: hidden; direction: ltr; padding-block: var(--s7) var(--s3); pointer-events: none; user-select: none; }
.kinetic__track { display: flex; width: max-content; will-change: transform; }
.kinetic__group { display: flex; align-items: center; flex: none; }
.kinetic__item {
  font-size: clamp(3rem, 1.6rem + 6.5vw, 8.5rem); font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; white-space: nowrap;
  color: var(--blue-light); --dj-ink: var(--blue-light); padding-inline: 0.35em;
}
.kinetic__item[lang="ar"] { letter-spacing: 0; }
.kinetic__sep { flex: none; width: 0.42em; height: 0.42em; font-size: clamp(3rem, 1.6rem + 6.5vw, 8.5rem); border: 2px solid var(--sky); rotate: 45deg; margin-inline: 0.3em; }

/* ---- 8. Menu glide and tab thumb ---------------------------------------- */
.nav__list.has-glide { position: relative; }
.nav__glide {
  position: absolute; left: 0; top: 50%; height: 40px; margin-top: -20px; width: 0; opacity: 0;
  border-radius: 999px; background: rgba(232, 244, 252, 0.95); box-shadow: inset 0 0 0 1px var(--line);
  transition: transform 0.5s var(--ease-out), width 0.5s var(--ease-out), opacity 0.3s; pointer-events: none;
}
.nav__list.has-glide > li:not(.nav__glide) { position: relative; z-index: 1; }
/* (".nav__list > li" would make the pill a normal list item: it must float behind the links,
   taking no room, in both reading directions.) */
.nav__list > li.nav__glide { position: absolute; left: 0; right: auto; }
@media (min-width: 1200px) {
  .nav__list.has-glide > li > a, .nav__list.has-glide > li > a:hover, .nav__list.has-glide > li > a[aria-current="page"] { background: transparent; }
}
@media (max-width: 1199px) { .nav__glide { display: none; } }
.tabs__list.has-thumb { position: relative; }
.tabs__thumb {
  position: absolute; left: 0; top: 0; border-radius: 999px; pointer-events: none;
  background: var(--white); box-shadow: 0 6px 18px rgba(75, 151, 200, 0.28), inset 0 0 0 1px var(--line);
  transition: transform 0.55s var(--ease-out), width 0.55s var(--ease-out), height 0.55s var(--ease-out);
}
@media (max-width: 640px) { .tabs__thumb { border-radius: var(--radius-s); } }
.tabs__list.has-thumb [role="tab"] { position: relative; z-index: 1; }
.tabs__list.has-thumb [role="tab"][aria-selected="true"] { background: transparent; box-shadow: none; }

/* ---- 9. Continuous life ------------------------------------------------- */
/* Icon lines draw themselves when their card arrives. */
.motion .icon-tile .icon { stroke-dasharray: 200; stroke-dashoffset: 0; transition: stroke-dashoffset 1.8s var(--ease-out) calc(var(--rd, 0ms) + 250ms); }
.motion [data-reveal]:not(.is-in) .icon-tile .icon, .motion .icon-tile[data-reveal]:not(.is-in) .icon { stroke-dashoffset: 200; }

@media (prefers-reduced-motion: reduce) {
  .cursor, .px-veil { display: none !important; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
