/* ==========================================================================
   stories.css — the two story pieces (v3):
     1. UAE → Mars journey        (partials/journey.html + js/journey.js)
     2. Qaly in 30 seconds        (partials/explainer.html + js/explainer.js)
   Mars is our flat orange dot: no tints, no glow. The UAE flag keeps its
   official colours. Everything else uses the brand blues.
   ========================================================================== */

/* =====================================================================
   1. UAE → Mars journey
   ===================================================================== */
.journey__grid { display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); gap: var(--s7); align-items: center; }
@media (max-width: 960px) { .journey__grid { grid-template-columns: 1fr; gap: var(--s5); } }
.journey__copy { display: grid; gap: var(--s5); align-content: center; }
.journey__lead { font-size: 1.1rem; }
.journey__steps { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.journey__step {
  display: grid; grid-template-columns: 78px minmax(0, 1fr); gap: var(--s4); align-items: start;
  padding: var(--s4); border-radius: 20px;
  background: var(--glass); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-line); box-shadow: var(--glass-shadow);
}
.journey__step h3 { font-size: 1.25rem; }
.journey__year {
  display: grid; place-items: center; height: 36px; border-radius: 999px;
  background: #FFFFFF; border: 1.5px solid var(--sky); color: var(--ink);
  font-weight: 700; font-variant-numeric: tabular-nums; box-shadow: 0 0 0 5px rgba(113, 181, 226, 0.14);
}
.journey__dots { display: none; }
.journey__note { max-width: 62ch; }
.journey__scene { position: relative; margin: 0; padding: var(--s2); overflow: hidden; }
.journey__svg { display: block; width: 100%; height: auto; }

/* Scene drawing */
.jr-stars path { fill: var(--blue-light); }
.jr-stars path.is-sky { fill: var(--sky); }
.jr-orbits circle { fill: none; stroke: var(--blue-light); stroke-width: 1.2; stroke-dasharray: 3 9; }
.jr-earth__air { fill: var(--ice); stroke: var(--blue-light); stroke-width: 1; }
.jr-earth__body { fill: var(--sky); }
.jr-earth__grid { opacity: 0.75; }
.jr-earth__rim { fill: none; stroke: var(--ink); stroke-width: 1.6; }
.jr-uae path { fill: #FFFFFF; stroke: var(--ink); stroke-width: 1.6; stroke-linejoin: round; }
.jr-uae circle { fill: var(--ink); }
.jr-tag rect { fill: #FFFFFF; stroke: var(--blue-light); }
.jr-tag text { font-family: var(--font); font-weight: 700; font-size: 13px; letter-spacing: 0.12em; fill: var(--ink); }
.jr-track { fill: none; stroke: var(--blue-light); stroke-width: 2; stroke-dasharray: 2 8; stroke-linecap: round; }
.jr-done { fill: none; stroke: var(--sky); stroke-width: 3.2; stroke-linecap: round; }
.jr-mark circle { fill: #FFFFFF; stroke: var(--blue-light); stroke-width: 2; transition: fill 0.4s, stroke 0.4s; }
.jr-mark text { font-family: var(--font); font-weight: 700; font-size: 17px; fill: var(--slate-mid); font-variant-numeric: tabular-nums; transition: fill 0.4s; }
.jr-mark.is-on circle { fill: var(--sky); stroke: var(--ink); }
.jr-mark.is-on text { fill: var(--ink); }
.jr-ring { fill: none; stroke: var(--sky); stroke-width: 1.2; stroke-dasharray: 4 8; opacity: 0.5; transform-box: fill-box; transform-origin: center; transition: opacity 0.6s; }
.is-landed .jr-ring { opacity: 1; }
.jr-hope-orbit { fill: none; stroke: var(--sky); stroke-width: 1; stroke-dasharray: 2 5; }
.jr-hope rect { fill: #FFFFFF; stroke: var(--ink); stroke-width: 1.4; }
.jr-hope path { fill: none; stroke: var(--ink); stroke-width: 1.4; stroke-linecap: round; }
.jr-dome { fill: #FFFFFF; stroke: var(--sky); stroke-width: 1.8; }
.jr-flag__pole { stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; }
/* The QALY rocket body is the symbol #i-qaly-rocket (partials/icons.svg). */
.jr-flame { fill: var(--sky); transform-box: fill-box; transform-origin: 50% 0; }
.jr-flame.f2 { fill: var(--blue-light); }

/* Arrival: the craft docks, the settlement appears, the flag is planted. */
.jr-craft { transition: opacity 0.5s; }
.is-landed .jr-craft { opacity: 0; }
.jr-base { opacity: 0; transition: opacity 0.7s var(--ease-out); }
.is-landed .jr-base { opacity: 1; }
.jr-flag__pole { transform-box: fill-box; transform-origin: 50% 100%; transform: scaleY(0); transition: transform 0.6s var(--ease-out) 0.15s; }
.is-landed .jr-flag__pole { transform: scaleY(1); }
.jr-flag__cloth { transform-box: fill-box; transform-origin: 0 50%; transform: scaleX(0); transition: transform 0.8s var(--ease-out) 0.6s; }
.is-landed .jr-flag__cloth { transform: scaleX(1); }

@media (prefers-reduced-motion: no-preference) {
  .jr-stars path { animation: twinkle 4s ease-in-out infinite; }
  .jr-earth__grid { animation: earth-turn 5s linear infinite; }
  .jr-ring.r1 { animation: spin 40s linear infinite; }
  .jr-ring.r2 { animation: spin 64s linear infinite reverse; }
  .jr-flame { animation: flame 0.28s ease-in-out infinite alternate; }
  .is-landed .jr-flag__cloth { animation: wave 2.6s ease-in-out 1.5s infinite; }
}
@keyframes twinkle { 50% { opacity: 0.25; } }
@keyframes earth-turn { to { transform: translateX(-18px); } }
@keyframes flame { to { transform: scaleY(1.4); } }
@keyframes wave { 0%, 100% { transform: scaleX(1) skewY(0deg); } 50% { transform: scaleX(0.95) skewY(-3deg); } }

/* Read-outs over the scene */
/* The readouts stay at the top left in both languages: Mars is always at the top right. */
.journey__hud {
  position: absolute; top: var(--s4); left: var(--s4); width: min(300px, 46%);
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); pointer-events: none;
}
.journey__read {
  display: grid; gap: 0.1rem; padding: 0.5rem 0.8rem; border-radius: 14px;
  background: rgba(255, 255, 255, 0.86); border: 1px solid var(--glass-line);
}
.journey__read .label { font-size: 0.62rem; }
.journey__read strong { font-size: clamp(1.1rem, 0.9rem + 1vw, 1.6rem); line-height: 1.1; color: var(--ink); font-variant-numeric: tabular-nums; }
.journey__read small { font-size: 0.72rem; font-weight: 500; color: var(--muted); }
.journey__bar { grid-column: 1 / -1; height: 4px; border-radius: 4px; background: rgba(232, 244, 252, 0.95); overflow: hidden; }
.journey__bar i { display: block; height: 100%; background: var(--sky); transform-origin: 0 50%; transform: scaleX(1); }
[dir="rtl"] .journey__bar i { transform-origin: 100% 50%; }
.journey__hint {
  position: absolute; bottom: var(--s4); inset-inline-end: var(--s4); display: none; align-items: center; gap: 0.6rem;
  padding: 0.45rem 0.9rem; border-radius: 999px; background: rgba(255, 255, 255, 0.86); border: 1px solid var(--glass-line); transition: opacity 0.5s;
}
.journey__hint::after { content: ""; width: 8px; height: 8px; border-inline-end: 2px solid var(--ink); border-bottom: 2px solid var(--ink); rotate: 45deg; margin-top: -4px; }
@media (prefers-reduced-motion: no-preference) { .journey__hint::after { animation: nudge 1.4s ease-in-out infinite; } }
@keyframes nudge { 50% { translate: 0 4px; } }

/* Live (scroll-driven) mode, added by journey.js */
.journey--live { height: 300vh; padding-block: 0; }
.journey--live .journey__stage {
  position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden;
  display: grid; align-items: center; padding-block: 96px var(--s5);
}
.journey--live .journey__steps { display: grid; }
.journey--live .journey__step {
  grid-area: 1 / 1; opacity: 0; translate: 0 22px; filter: blur(5px); pointer-events: none;
  transition: opacity 0.6s var(--ease-out), translate 0.7s var(--ease-out), filter 0.6s var(--ease-out);
}
.journey--live .journey__step.is-past { translate: 0 -22px; }
.journey--live .journey__step.is-active { opacity: 1; translate: 0 0; filter: none; pointer-events: auto; }
.journey--live .journey__dots { display: flex; flex-wrap: wrap; gap: var(--s2); }
.journey__dots button {
  min-height: 36px; padding: 0 0.9rem; border-radius: 999px; cursor: pointer; font: inherit; font-weight: 700; font-size: 0.85rem;
  color: var(--ink); background: var(--glass); border: 1px solid var(--glass-line); font-variant-numeric: tabular-nums;
  transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
}
.journey__dots button:hover { border-color: var(--sky); }
.journey__dots button.is-active { background: var(--sky); border-color: var(--sky); box-shadow: 0 0 0 4px rgba(113, 181, 226, 0.2); }
.journey--live .journey__bar i { transform: scaleX(0); }
.journey--live .journey__hint { display: inline-flex; }
.journey--live.is-started .journey__hint { opacity: 0; }
@media (max-width: 960px) {
  .journey--live .journey__stage { padding-block: 88px var(--s3); align-items: start; }
  .journey--live .journey__grid { gap: var(--s3); }
  .journey--live .journey__scene { order: -1; max-height: 44svh; }
  .journey--live .journey__svg { max-height: calc(44svh - 16px); margin-inline: auto; width: auto; max-width: 100%; }
  .journey--live .journey__lead, .journey--live .journey__note { display: none; }
  .journey--live .journey__copy { gap: var(--s3); }
  .journey--live .journey__copy h2 { font-size: clamp(1.6rem, 1.2rem + 2vw, 2.2rem); }
  .journey--live .journey__step { padding: var(--s3); }
  .journey--live .journey__step p { font-size: 0.95rem; }
  .journey__hud { width: min(240px, 60%); }
}
@media (max-width: 640px) {
  .jr-mark text { font-size: 26px; }
  .jr-tag text { font-size: 18px; }
  .jr-mark circle { r: 9px; }
}
@media (max-width: 960px) and (max-height: 700px) {
  .journey--live .journey__copy .label { display: none; }
}

/* =====================================================================
   2. Qaly in 30 seconds
   ===================================================================== */
.xp {
  display: grid; gap: var(--s4); padding: clamp(0.6rem, 1.6vw, 1.1rem); border-radius: 32px;
  background: var(--glass); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-line); box-shadow: var(--glass-shadow);
}
.xp__screen {
  position: relative; aspect-ratio: 16 / 9; border-radius: 24px; overflow: hidden; isolation: isolate;
  background: linear-gradient(160deg, #FFFFFF 20%, var(--ice));
  border: 1px solid var(--glass-line);
}
.xp__screen::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background-image: linear-gradient(rgba(113, 181, 226, 0.12) 1px, transparent 1px), linear-gradient(90deg, rgba(113, 181, 226, 0.12) 1px, transparent 1px);
  background-size: 40px 40px;
}
@media (max-width: 640px) { .xp__screen { aspect-ratio: 4 / 5; } }
.xp__hud { position: absolute; top: 12px; left: 12px; right: 12px; z-index: 3; display: flex; justify-content: space-between; gap: var(--s2); pointer-events: none; }
.xp__hud .hud-chip { background: rgba(255, 255, 255, 0.86); }
.xp__time { font-variant-numeric: tabular-nums; }
.xp__stage { position: absolute; inset: 58px 14px 18px; }
.xp__scene { position: absolute; inset: 0; opacity: 0; visibility: hidden; transition: opacity 0.5s var(--ease-out), visibility 0.5s; }
.xp__scene.is-on { opacity: 1; visibility: visible; }
.xp__caption {
  margin: 0 auto; max-width: 64ch; min-height: 3.1em; text-align: center;
  font-weight: 500; color: var(--ink); font-size: clamp(1rem, 0.9rem + 0.4vw, 1.2rem); line-height: 1.5;
}
@media (prefers-reduced-motion: no-preference) { .xp__caption.is-new { animation: morph 0.6s var(--ease-out); } }
.xp:not(.is-playing) .xp__stage * { animation-play-state: paused !important; }

/* Timing helpers: --p runs 0 → 1 between --a and --a + --d of the scene. */
.xp .k {
  --p: clamp(0, (var(--t, 0) - var(--a, 0)) / var(--d, 0.25), 1);
  --e: calc(1 - (1 - var(--p)) * (1 - var(--p)));
}

/* Scene 1: Who (logos are wiped in, never faded) */
.xp-who { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(26px, 5vw, 44px); }
.xp-who__top { width: min(280px, 40%); clip-path: inset(0 calc((1 - var(--e)) * 100%) 0 0); }
.xp-who__top img, .xp-who__slot img { display: block; width: 100%; height: auto; }
.xp-who__row { position: relative; display: flex; justify-content: center; width: min(600px, 84%); }
.xp-who__row--3 > * { flex: 0 0 33.333%; }
.xp-who__row--2 { width: min(400px, 56%); }
.xp-who__row--2 > * { flex: 0 0 50%; }
.xp-who__row::before { content: ""; position: absolute; top: calc(clamp(26px, 5vw, 44px) / -2); left: 16.666%; right: 16.666%; height: 2px; background: var(--sky); scale: var(--p) 1; }
.xp-who__row--2::before { left: 25%; right: 25%; }
.xp-who__row::after { content: ""; position: absolute; top: calc(clamp(26px, 5vw, 44px) * -1); left: 50%; width: 2px; margin-left: -1px; height: calc(clamp(26px, 5vw, 44px) / 2); background: var(--sky); transform-origin: 50% 0; scale: 1 var(--p); }
.xp-who__slot { position: relative; display: grid; place-items: center; padding-inline: clamp(4px, 1vw, 10px); }
.xp-who__slot img { max-width: 180px; clip-path: inset(0 calc((1 - clamp(0, (var(--p) - 0.3) / 0.7, 1)) * 100%) 0 0); }
.xp-who__slot::before { content: ""; position: absolute; bottom: 100%; left: 50%; width: 2px; margin-left: -1px; height: calc(clamp(26px, 5vw, 44px) / 2); background: var(--sky); transform-origin: 50% 0; scale: 1 clamp(0, var(--p) * 3.3, 1); }

/* Scene 2: What */
.xp-what { display: grid; place-items: center; }
.xp-what__row { position: relative; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(10px, 3vw, 40px); width: min(760px, 100%); }
@media (max-width: 640px) {
  .xp-what__row { gap: 8px; } .xp-what__item b { font-size: 0.78rem; line-height: 1.25; }
  .xp-what__rocket { z-index: 2; }   /* little room between the tiles on phones: the rocket flies in front */
}
.xp-what__item { position: relative; z-index: 1; display: grid; justify-items: center; gap: 0.7rem; text-align: center; opacity: var(--p); translate: 0 calc((1 - var(--e)) * 30px); }
.xp-what__item .icon-tile { width: clamp(56px, 9vw, 96px); height: clamp(56px, 9vw, 96px); border-radius: 24px; }
.xp .xp-what__item .icon-tile .icon { width: 50%; height: 50%; stroke-dasharray: 200; stroke-dashoffset: calc((1 - clamp(0, (var(--p) - 0.15) / 0.85, 1)) * 200); transition: none; }
.xp-what__item b { color: var(--ink); font-size: clamp(0.85rem, 0.8rem + 0.3vw, 1.05rem); }
.xp-what__line {
  position: absolute; z-index: 0; left: 12%; right: 12%; top: calc(clamp(56px, 9vw, 96px) / 2); height: 2px; margin-top: -1px;
  background: linear-gradient(90deg, var(--sky), var(--blue-light), var(--sky)); scale: var(--p) 1; transform-origin: 0 50%; overflow: hidden;
}
[dir="rtl"] .xp-what__line { transform-origin: 100% 50%; }
/* The QALY rocket flies along the line from Clinic to Pharmacy (right to left in Arabic),
   passing behind each tile. Its body is the symbol #i-qaly-rocket (partials/icons.svg). */
.xp-what__rocket {
  --len: clamp(46px, 7vw, 72px);
  position: absolute; z-index: 0; top: calc(clamp(56px, 9vw, 96px) / 2); left: calc(12% + var(--p) * 76%);
  width: calc(var(--len) * 46 / 96); height: var(--len); margin: calc(var(--len) * -0.4375) 0 0 calc(var(--len) * -23 / 96);
  rotate: 90deg; transform-origin: 50% 43.75%; opacity: clamp(0, var(--p) * 12, 1); pointer-events: none;
}
.xp-what__rocket svg { display: block; width: 100%; height: 100%; overflow: visible; }
[dir="rtl"] .xp-what__rocket { left: calc(88% - var(--p) * 76%); rotate: -90deg; }
/* Our name on the rocket always reads left to right: one copy for each direction of flight. */
.qaly-name { color: var(--ink); }
.xp-what__rocket .qaly-name--rtl, [dir="rtl"] .xp-what__rocket .qaly-name--ltr { display: none; }
[dir="rtl"] .xp-what__rocket .qaly-name--rtl { display: inline; }

/* Scene 3: Where */
.xp-where__map {
  position: absolute; inset: -20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='36' height='36' viewBox='0 0 36 36'%3E%3Cpath d='M18 4 L32 18 L18 32 L4 18 Z' fill='none' stroke='%23B9DAF1' stroke-width='1.2'/%3E%3C/svg%3E");
  background-size: 36px 36px;
  -webkit-mask-image: radial-gradient(circle at 50% 45%, #000 0%, transparent 62%); mask-image: radial-gradient(circle at 50% 45%, #000 0%, transparent 62%);
}
@media (prefers-reduced-motion: no-preference) { .xp-where__map { animation: map-pan 16s linear infinite; } }
@keyframes map-pan { to { background-position: 36px 36px; } }
.xp-where__ring { position: absolute; left: 50%; top: 44%; width: 90px; height: 90px; margin: -45px; border-radius: 50%; border: 1.5px solid var(--sky); opacity: 0; }
@media (prefers-reduced-motion: no-preference) {
  .xp-where__ring { animation: radar 3s var(--ease-out) infinite; }
  .xp-where__ring.r2 { animation-delay: 1s; }
  .xp-where__ring.r3 { animation-delay: 2s; }
}
@keyframes radar { 0% { scale: 0.3; opacity: 0.9; } 100% { scale: 3.4; opacity: 0; } }
.xp-where__pin {
  position: absolute; left: 50%; top: 44%; width: 66px; height: 66px; display: grid; place-items: center;
  border-radius: 50% 50% 50% 4px; rotate: -45deg; background: #FFFFFF; border: 2px solid var(--ink);
  box-shadow: 0 16px 34px rgba(75, 151, 200, 0.3);
  translate: -50% calc(-100% - 6px + (1 - var(--e)) * -110px); opacity: var(--p);
}
.xp-where__pin .icon { rotate: 45deg; width: 30px; height: 30px; }
.xp-where__card {
  position: absolute; left: 4%; right: 4%; margin-inline: auto; width: fit-content; top: 58%; display: grid; gap: 0.25rem; text-align: center;
  padding: 0.8rem 1.2rem; border-radius: 18px; background: rgba(255, 255, 255, 0.92); border: 1px solid var(--glass-line); box-shadow: var(--glass-shadow);
  translate: 0 calc((1 - var(--e)) * 24px); opacity: var(--p);
}
.xp-where__card strong { font-size: clamp(1rem, 0.9rem + 0.6vw, 1.35rem); }
[dir="rtl"] .xp-where__pin { left: auto; right: 50%; }
[dir="rtl"] .xp-where__pin { translate: 50% calc(-100% - 6px + (1 - var(--e)) * -110px); }

/* Scene 4: When */
.xp-when { display: grid; place-items: center; }
.xp-when__track { position: relative; width: min(640px, 80%); height: 150px; }
.xp-when__line { position: absolute; left: 0; right: 0; top: 50%; height: 3px; margin-top: -1.5px; border-radius: 3px; background: linear-gradient(90deg, var(--sky), var(--blue-light)); scale: var(--e) 1; transform-origin: 0 50%; }
[dir="rtl"] .xp-when__line { transform-origin: 100% 50%; background: linear-gradient(270deg, var(--sky), var(--blue-light)); }
.xp-when__node {
  position: absolute; top: 50%; inset-inline-start: var(--x); translate: -50% -50%;
  display: grid; justify-items: center; gap: 0.35rem; opacity: var(--p); scale: calc(0.6 + 0.4 * var(--e));
}
[dir="rtl"] .xp-when__node { translate: 50% -50%; }
.xp-when__node::before { content: ""; width: 22px; height: 22px; border-radius: 50%; background: #FFFFFF; border: 2.5px solid var(--ink); box-shadow: 0 0 0 6px rgba(113, 181, 226, 0.2); }
.xp-when__node--mars::before { width: 34px; height: 34px; border: 0; box-shadow: none; background: var(--orange); }
.xp-when__node b { order: -1; font-size: clamp(1.1rem, 0.9rem + 1vw, 1.7rem); color: var(--ink); font-variant-numeric: tabular-nums; }
.xp-when__node small { color: var(--muted); font-weight: 500; font-size: clamp(0.75rem, 0.7rem + 0.3vw, 0.9rem); white-space: nowrap; }
.xp-when__traveller { position: absolute; top: 50%; inset-inline-start: calc(var(--e) * 100%); width: 12px; height: 12px; margin: -6px; rotate: 45deg; background: var(--sky); box-shadow: 0 0 0 5px rgba(113, 181, 226, 0.25); opacity: var(--p); }

/* Scene 5: Why */
.xp-why { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(10px, 2vw, 18px); text-align: center; }
.xp-why__years { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 8px; width: min(560px, 92%); }
@media (max-width: 640px) { .xp-why__years { grid-template-columns: repeat(5, minmax(0, 1fr)); width: min(260px, 80%); } }
.xp-why__years span {
  aspect-ratio: 1; border-radius: 8px; border: 1.5px solid var(--blue-light);
  background: linear-gradient(to top, var(--sky) calc(var(--p) * 100%), #FFFFFF calc(var(--p) * 100%));
  scale: calc(0.8 + 0.2 * var(--e));
}
.xp-why__word { font-size: clamp(2.4rem, 1.8rem + 4vw, 5rem); font-weight: 700; color: var(--ink); line-height: 1; letter-spacing: 0.06em; opacity: var(--p); translate: 0 calc((1 - var(--e)) * 22px); }
.xp-why__sub { max-width: 34ch; opacity: var(--p); translate: 0 calc((1 - var(--e)) * 16px); }

/* Controls */
.xp__bar { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.xp__btn {
  width: 48px; height: 48px; flex: none; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  background: var(--glass-strong); border: 1px solid var(--glass-line); color: var(--ink); font: inherit; font-weight: 700; font-size: 0.85rem;
  transition: background 0.3s, border-color 0.3s, box-shadow 0.3s, transform 0.3s var(--ease-out);
}
.xp__btn:hover { border-color: var(--sky); box-shadow: 0 0 0 4px rgba(113, 181, 226, 0.18); }
.xp__btn .icon { width: 22px; height: 22px; }
.xp__play { width: 58px; height: 58px; background: var(--sky); border-color: var(--sky); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), 0 10px 26px rgba(113, 181, 226, 0.4); }
.xp__play:hover { background: var(--sky); }
.xp__btn[aria-pressed="true"] { background: var(--sky); border-color: var(--sky); }
.xp__speed { font-variant-numeric: tabular-nums; }
.xp__segs { flex: 1 1 260px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; min-width: 0; }
.xp__seg {
  position: relative; display: grid; gap: 0.4rem; padding: 0.3rem 0; background: none; border: 0; cursor: pointer; font: inherit;
  text-align: start; color: var(--muted); font-weight: 700; font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
:lang(ar) .xp__seg { letter-spacing: 0; font-size: 0.85rem; }
.xp__seg::before { content: ""; height: 6px; border-radius: 6px; background: rgba(232, 244, 252, 0.95); box-shadow: inset 0 0 0 1px var(--glass-line); }
.xp__seg-fill { position: absolute; top: 0.3rem; left: 0; height: 6px; border-radius: 6px; width: calc(var(--fill, 0) * 100%); background: var(--sky); }
[dir="rtl"] .xp__seg-fill { left: auto; right: 0; }
.xp__seg[aria-current="step"] { color: var(--ink); }
.xp__seg:hover { color: var(--ink); }
.xp__words summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 0.6rem; font-weight: 700; color: var(--ink); font-size: var(--fs-small); }
.xp__words summary::-webkit-details-marker { display: none; }
.xp__words summary::before { content: ""; width: 7px; height: 7px; background: var(--sky); rotate: 45deg; transition: rotate 0.3s; }
.xp__words[open] summary::before { rotate: 135deg; }
.xp__words ol { margin: var(--s3) 0 0; padding-inline-start: 1.3rem; display: grid; gap: 0.45rem; font-size: var(--fs-small); }

/* =====================================================================
   3. The gaps in care: stacked cards over a sphere of light
   ===================================================================== */
.deck { position: relative; overflow: clip; }
.deck__stage { position: relative; }
.deck__figure { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }
.deck__grid { position: relative; display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: var(--s7); align-items: center; }
.deck__head { align-self: start; }
.deck__head h2 { font-size: clamp(2.2rem, 1.4rem + 3vw, 3.8rem); max-width: 11ch; }
.deck__cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
.deck__card {
  position: relative; display: flex; flex-direction: column; gap: var(--s3); min-height: 250px; padding: clamp(1.25rem, 2.6vw, 2rem);
  border-radius: 30px; background: #FFFFFF; border: 1px solid var(--glass-line);
  box-shadow: inset 0 1px 0 #fff, 0 40px 90px rgba(75, 151, 200, 0.22);
}
.deck__card h3 { font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.6rem); }
.deck__card p { margin-top: auto; max-width: 34ch; }
.deck__num { position: absolute; bottom: 14px; inset-inline-end: 22px; font-size: clamp(3rem, 2.2rem + 2.4vw, 4.6rem); font-weight: 300; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.deck__answer { grid-column: 1 / -1; justify-self: end; margin: 0; font-size: clamp(2rem, 1.2rem + 3.4vw, 4.2rem); font-weight: 700; line-height: 1.05; color: var(--ink); text-align: end; max-width: 14ch; }

/* Live (scroll-driven) mode, added by deck.js */
.deck--live { height: 420vh; padding-block: 0; }
.deck--live .deck__stage { position: sticky; top: 0; height: 100vh; height: 100svh; display: grid; align-items: center; padding-block: 100px var(--s5); overflow: hidden; }
.deck--live .deck__grid { grid-template-rows: 1fr auto; height: 100%; }
.deck--live .deck__cards { display: grid; grid-template-columns: 1fr; place-items: center; grid-row: 1 / 3; grid-column: 2; }
.deck--live .deck__card { grid-area: 1 / 1; width: min(520px, 100%); min-height: 300px; will-change: transform, opacity; transform-origin: 50% 80%; opacity: 0; }
.deck--live .deck__card.is-top { box-shadow: inset 0 1px 0 #fff, 0 50px 110px rgba(75, 151, 200, 0.3); }
.deck--live .deck__answer { grid-column: 1; grid-row: 2; justify-self: start; text-align: start; opacity: 0; }
@media (max-width: 860px) {
  .deck__grid { grid-template-columns: 1fr; gap: var(--s5); }
  .deck__cards { grid-template-columns: 1fr; }
  .deck--live .deck__stage { padding-block: 96px var(--s4); align-items: start; }
  .deck--live .deck__grid { grid-template-rows: auto 1fr auto; }
  .deck--live .deck__cards { grid-row: 2; grid-column: 1; }
  .deck--live .deck__card { min-height: 240px; }
  .deck--live .deck__answer { grid-row: 3; font-size: clamp(1.6rem, 1rem + 4vw, 2.4rem); }
  .deck--live .deck__head p { display: none; }
}

/* =====================================================================
   4. How Qaly closes the gaps: sky-blue cards with orbs of light
   ===================================================================== */
.solve__grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s4); }
@media (max-width: 1100px) { .solve__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .solve__grid { grid-template-columns: 1fr; } }
.solve-card {
  position: relative; overflow: hidden; isolation: isolate; display: flex; flex-direction: column; gap: var(--s3);
  min-height: 380px; padding: var(--s5); border-radius: 28px;
  background: var(--sky); color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 24px 60px rgba(75, 151, 200, 0.3);
  transition: transform 0.45s var(--ease-out), box-shadow 0.45s var(--ease-out), translate 1s var(--ease-out) var(--rd, 0ms), opacity 0.9s var(--ease-out) var(--rd, 0ms), filter 0.9s var(--ease-out) var(--rd, 0ms);
}
.solve-card:hover { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 0 0 5px rgba(113, 181, 226, 0.22), 0 34px 80px rgba(75, 151, 200, 0.38); }
.solve-card__orb { position: absolute; z-index: -1; top: -6%; inset-inline-end: -14%; width: 88%; height: 70%; pointer-events: none; }
.solve-card__num { font-size: clamp(3rem, 2.4rem + 2vw, 4.4rem); font-weight: 300; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.solve-card h3 { margin-top: auto; color: var(--ink); font-size: 1.35rem; }
.solve-card p { color: var(--ink); font-size: 0.98rem; }
/* On sky blue, the orange dot keeps its colour; text stays dark blue (brand contrast rule). */
.solve-card .dj { --dj-ink: var(--ink); }

/* =====================================================================
   5. Qaly in 30 seconds — richer scenes (v3.1)
   ===================================================================== */
@property --yr { syntax: "<integer>"; inherits: false; initial-value: 2026; }
/* Always moving behind the scenes */
.xp__bg { position: absolute; inset: -12% -8%; width: 116%; height: 124%; z-index: 0; opacity: 0.32; pointer-events: none; }
.xp__scan { position: absolute; left: 0; right: 0; top: -90px; height: 90px; z-index: 1; pointer-events: none; background: linear-gradient(180deg, transparent, rgba(113, 181, 226, 0.14), transparent); }
@media (prefers-reduced-motion: no-preference) { .xp__scan { animation: scan-y 4.5s linear infinite; } }
@keyframes scan-y { to { transform: translateY(calc(100% + 900px)); } }
.xp__stage { z-index: 2; }
.xp:not(.is-playing) .xp__scan { animation-play-state: paused; }
/* Scene changes: the old scene zooms away, the new one zooms in; the camera drifts closer. */
.xp__scene { scale: 1.1; filter: blur(8px); transition: opacity 0.6s var(--ease-out), visibility 0.6s, scale 0.9s var(--ease-out), filter 0.6s var(--ease-out); }
.xp__scene.is-on { scale: calc(1 + var(--t, 0) * 0.05); filter: none; }
.xp-chip {
  position: absolute; left: 50%; bottom: 2%; translate: -50% calc((1 - var(--e)) * 16px); opacity: var(--p);
  padding: 0.4rem 1rem; border-radius: 999px; background: rgba(255, 255, 255, 0.92); border: 1px solid var(--glass-line);
  font-size: 0.8rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink); white-space: nowrap;
}
:lang(ar) .xp-chip { letter-spacing: 0; }

/* 1. Who: a pulse, the tree, then one shield around it all */
.xp-who { position: absolute; inset: 0; }
.xp-who__wave { position: absolute; left: 50%; top: 22%; width: 180px; height: 180px; margin: -90px; border-radius: 50%; border: 2px solid var(--sky); pointer-events: none;
  scale: calc(0.2 + var(--e) * 2.6); opacity: calc(1 - var(--p)); }
/* The shield is drawn from the brand lattice on this canvas (explainer.js, shieldPainter). */
.xp-who__shield { position: absolute; z-index: 0; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }
.xp-who__row, .xp-who__top { position: relative; z-index: 1; }

/* 2. What: four kinds of care burst out of the group mark */
.xp-what__core { position: absolute; left: 50%; top: 42%; width: clamp(64px, 11%, 110px); aspect-ratio: 1; translate: -50% -50%; z-index: 2;
  clip-path: circle(calc(min(var(--p) * 3, 1, (1 - var(--p)) * 2.6) * 72%) at 50% 50%); }
.xp-what__core img { width: 100%; height: 100%; border-radius: 22%; }
.xp-what__item { translate: calc((1 - var(--e)) * var(--fx, 0%)) calc((1 - var(--e)) * 14px); scale: calc(0.35 + var(--e) * 0.65); }
.xp-what__item .icon-tile::before { content: ""; position: absolute; inset: -10px; border-radius: 50%; border: 1.5px dashed var(--sky); opacity: var(--p); }
@media (prefers-reduced-motion: no-preference) { .xp-what__item .icon-tile::before { animation: spin 9s linear infinite; } }
.xp-what__item b { clip-path: inset(0 calc((1 - clamp(0, (var(--p) - 0.4) / 0.6, 1)) * 100%) 0 0); }

/* 3. Where: the Earth turns and we zoom into Dubai */
.xp-where__map { opacity: var(--p); }
.xp-where__globe {
  position: absolute; left: 50%; top: 44%; width: 200px; height: 200px; margin: -100px; border-radius: 50%; z-index: 1;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 22 22'%3E%3Cpath d='M11 3 L19 11 L11 19 L3 11 Z' fill='none' stroke='%23FFFFFF' stroke-width='1.3'/%3E%3C/svg%3E") 0 0 / 22px 22px,
    radial-gradient(circle at 35% 30%, #91E0F1, var(--sky) 60%, var(--blue-mid));
  box-shadow: inset 0 0 0 2px var(--ink), 0 0 0 10px rgba(232, 244, 252, 0.9);
  scale: calc(0.7 + var(--e) * 3.4); opacity: calc(1 - clamp(0, (var(--p) - 0.72) / 0.28, 1));
}
@media (prefers-reduced-motion: no-preference) { .xp-where__globe { animation: globe-turn 6s linear infinite; } }
@keyframes globe-turn { to { background-position: -44px 0, 0 0; } }
.xp-where__beam { position: absolute; left: 50%; top: 4%; width: 4px; margin-left: -2px; height: 40%; transform-origin: 50% 100%; scale: 1 var(--e);
  background: linear-gradient(180deg, rgba(113, 181, 226, 0), var(--sky)); border-radius: 4px; }
.xp-where__pin { z-index: 2; }
.xp-where__card { z-index: 2; }

/* 4. When: the years count up; a craft flies to Mars; a small UAE flag */
.xp-when__count {
  position: absolute; left: 50%; top: 4%; translate: -50% 0; --yr: calc(2026 + var(--p) * 91); counter-reset: yr var(--yr);
  font-size: clamp(2.6rem, 1.6rem + 5vw, 5.4rem); font-weight: 700; line-height: 1; color: var(--blue-light); letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
}
.xp-when__count::before { content: counter(yr); }
.xp-when__track { margin-top: 12%; }
.xp-when__traveller { display: none; }
.xp-when__rocket {
  position: absolute; top: 50%; inset-inline-start: calc(var(--e) * 100%); width: 40px; height: 40px; margin: -20px;
  display: grid; place-items: center; border-radius: 50%; background: #FFFFFF; border: 1.5px solid var(--sky);
  box-shadow: 0 10px 24px rgba(75, 151, 200, 0.3); z-index: 2;
  opacity: calc(var(--p) * (1 - clamp(0, (var(--p) - 0.9) / 0.1, 1)));   /* lands, then hands over to the flag */
}
.xp-when__rocket .icon { width: 24px; height: 24px; rotate: 90deg; }
[dir="rtl"] .xp-when__rocket .icon { rotate: -90deg; }
[dir="rtl"] .xp-when__rocket { margin: -20px; }
.xp-when__flag {
  position: absolute; top: 50%; inset-inline-start: 100%; width: 26px; height: 13px; margin-top: -40px; margin-inline-start: 34px; z-index: 3;
  background: linear-gradient(90deg, #EF3340 0 25%, transparent 25%), linear-gradient(180deg, #009739 0 33.33%, #FFFFFF 33.33% 66.66%, #000000 66.66%);
  outline: 1px solid var(--blue-light); transform-origin: 0 50%; scale: var(--e) 1;
}
.xp-when__flag::before { content: ""; position: absolute; left: -2px; top: 0; width: 2px; height: 34px; background: var(--ink); }
[dir="rtl"] .xp-when__flag { direction: ltr; }

/* 5. Why: a heartbeat runs and the letters of QALY come together */
.xp-why__ecg { width: min(560px, 90%); height: 60px; overflow: visible; }
.xp-why__ecg path { fill: none; stroke: var(--sky); stroke-width: 2.5; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: calc(1 - var(--p)); }
.xp-why__word { opacity: 1; translate: none; display: flex; gap: 0.08em; margin: 0; }
.xp-why__word .k { display: inline-block; opacity: var(--p); translate: calc((1 - var(--e)) * var(--fx)) calc((1 - var(--e)) * var(--fy)); rotate: calc((1 - var(--e)) * 35deg); }
@media (max-width: 640px) {
  .xp-when__flag { margin-inline-start: -13px; margin-top: -76px; }
  .xp-who__top { width: min(220px, 56%); }
  .xp-who__row { width: 92%; }
  .xp-who__row--2 { width: 64%; }
  .xp-when__track { margin-top: 30%; }
  .xp-chip { font-size: 0.7rem; }
}
