/* Installation journey (homepage, Acts I–V) ---------------------------------
   Default: five static, illustrated sections (reduced motion, short screens,
   no JavaScript). html.jx-live (set by journey.js): one pinned stage, 100svh.

   In the live layout every visual is placed with left/top/margins only (never
   CSS transforms), so journey.js can measure slots with offsetLeft/offsetTop
   while GSAP owns the transforms. */

.journey {
  --jx-spot: 0.32;
  position: relative;
  z-index: 2;
  padding: 120px var(--gutter) 140px;
}
:root[data-theme="dark"] .journey { --jx-spot: 0.46; }

.jx-stage { position: relative; display: grid; gap: clamp(96px, 12vw, 160px); max-width: 1240px; margin: 0 auto; }
.jx-atmos, .jx-hero, .jx-route, .jx-orbit, .jx-field { display: none; }

/* Copy ---------------------------------------------------------------- */
.jx-copy { display: grid; gap: 20px; justify-items: start; align-content: center; }
.jx-title {
  font-size: clamp(2.3rem, 4.3vw, 4.5rem);
  font-weight: 700;
  line-height: 0.96;
  letter-spacing: -0.052em;
  text-wrap: balance;
}
.jx-lede { max-width: 36ch; color: var(--text-secondary); font-size: clamp(16px, 1.25vw, 18.5px); line-height: 1.55; text-wrap: pretty; }
.jx-fine { max-width: 44ch; color: var(--text-tertiary); font-size: 13.5px; line-height: 1.55; }
.jx-final { font-size: clamp(1.25rem, 1.9vw, 1.75rem); font-weight: 650; letter-spacing: -0.03em; }
.jx-actions { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; }

/* Static layout: copy beside its illustration */
.jx-act { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); align-items: center; gap: clamp(32px, 6vw, 96px); }
.jx-act[data-act="5"] { grid-template-columns: 1fr; justify-items: center; text-align: center; }
.jx-act[data-act="5"] .jx-copy { justify-items: center; }
.jx-vis { position: relative; justify-self: center; }

/* Act I: a small constellation (static only) */
.jx-cluster { display: grid; grid-template-columns: repeat(3, auto); gap: 18px; place-items: center; }
.jx-cluster__i .tile { --tile: 64px; opacity: 0.55; }
.jx-cluster__hero { grid-column: 2; grid-row: 2; }
.jx-cluster__hero .tile { --tile: 96px; box-shadow: var(--tile-shadow), 0 0 60px hsl(var(--app-hue) 90% 60% / var(--jx-spot)); }
.jx-cluster__i:nth-child(n+5) { grid-row: auto; }

/* Act II: app-detail card ---------------------------------------------- */
.jx-card {
  --card-w: 380px;
  width: var(--card-w);
  border: 1px solid var(--card-border);
  border-radius: 32px;
  background: var(--card-bg);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  text-align: left;
}
.jx-card__art { position: relative; height: 112px; overflow: hidden; }
.jx-card__art span,
.jx-card__art::before {
  content: "";
  position: absolute;
  inset: -40%;
  background:
    radial-gradient(40% 60% at 30% 60%, hsl(var(--app-hue) 85% 60% / 0.85), transparent 70%),
    radial-gradient(45% 70% at 75% 30%, hsl(calc(var(--app-hue) + 50) 85% 62% / 0.7), transparent 70%),
    radial-gradient(60% 80% at 60% 90%, hsl(calc(var(--app-hue) - 40) 80% 55% / 0.6), transparent 70%);
}
.jx-card__art::before { opacity: 0.6; transform: scaleX(-1); }
.jx-card__head { position: relative; display: flex; align-items: flex-end; gap: 16px; margin: -40px 24px 0; }
.jx-card__id { padding-bottom: 2px; }
.jx-card__icon { position: relative; flex: none; width: 96px; height: 96px; }
.jx-card__icon .tile, .jx-pkg__icon .tile { --tile: 96px; }
.jx-card__id { display: grid; gap: 4px; padding-bottom: 6px; min-width: 0; }
.jx-card__name { font-size: 23px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; overflow-wrap: anywhere; }
.jx-card__source { color: var(--text-secondary); font-size: 13px; }
.jx-card__meta { display: grid; margin: 18px 24px 0; font-size: 13.5px; }
.jx-card__meta > div { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--border-subtle); }
.jx-card__meta dt { color: var(--text-tertiary); }
.jx-card__meta dd { color: var(--text-primary); font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.jx-card__bundle dd { font-family: var(--font-mono); font-size: 11.5px; font-weight: 500; }
.jx-card__action { position: relative; display: grid; margin: 20px 24px 24px; }
.jx-card__btn {
  display: grid;
  place-items: center;
  height: 48px;
  border-radius: var(--radius-pill);
  background: var(--btn-ink-bg);
  color: var(--btn-ink-text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.jx-card__tap { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; background: hsl(var(--app-hue) 90% 70% / 0.45); box-shadow: 0 0 0 1px rgb(255 255 255 / 0.5); opacity: 0; }

/* Act III: package + certificate ------------------------------------- */
@property --sweep { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
.jx-sign { --sign-w: 460px; --sign-h: 300px; width: var(--sign-w); height: var(--sign-h); }
.jx-pkg {
  position: absolute;
  left: 34px;
  top: 50%;
  width: 180px;
  height: 180px;
  margin-top: -100px;
  border-radius: 40px;
  background: var(--surface-glass-strong);
  box-shadow: inset 0 0 0 1px var(--border-subtle), var(--elevation-2);
}
.jx-pkg__edge {
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1.5px;
  background: conic-gradient(from var(--sweep), transparent 0 62%, var(--spectrum-1) 72%, var(--spectrum-2) 82%, var(--spectrum-3) 90%, transparent 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}
.jx-pkg__icon { position: absolute; left: 42px; top: 30px; width: 96px; height: 96px; }
.jx-pkg__sig { position: absolute; left: 30px; bottom: 16px; width: 120px; height: 30px; overflow: visible; }
.jx-pkg__sig path { fill: none; stroke: var(--line-2); stroke-width: 2; stroke-linecap: round; stroke-dasharray: 1 1; stroke-dashoffset: 0; }
.jx-pkg__state { position: absolute; left: 0; right: 0; top: calc(100% + 16px); display: grid; justify-items: center; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.22em; text-transform: uppercase; }
.jx-pkg__state > span { grid-area: 1 / 1; display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px; border-radius: var(--radius-pill); }
.jx-pkg__unsigned { color: var(--text-tertiary); box-shadow: inset 0 0 0 1px var(--border-subtle); opacity: 0; }
.jx-pkg__signed { color: var(--text-primary); background: var(--chip-bg); box-shadow: inset 0 0 0 1px var(--border-strong); }
.jx-pkg__signed svg, .jx-safari__ok svg, .jx-phone__done svg { width: 14px; height: 14px; fill: none; stroke: var(--status-live); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.jx-cert {
  position: absolute;
  right: 0;
  top: 22px;
  display: grid;
  gap: 9px;
  width: 210px;
  padding: 18px;
  border-radius: 22px;
  background: var(--surface-glass);
  box-shadow: inset 0 0 0 1px var(--border-strong), var(--elevation-2);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
}
.jx-cert__seal { width: 30px; height: 30px; border-radius: 50%; background: conic-gradient(var(--spectrum-1), var(--spectrum-2), var(--spectrum-3), var(--spectrum-1)); box-shadow: inset 0 0 0 5px var(--surface-glass-strong); }
.jx-cert__label { font-size: 14px; font-weight: 650; letter-spacing: -0.01em; }
.jx-cert__line { height: 6px; border-radius: 3px; background: var(--border-strong); }
.jx-cert__line--short { width: 58%; }
.jx-cert__file { color: var(--text-tertiary); font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; }
.jx-sign__ribbon { position: absolute; left: 110px; top: 40px; width: 300px; height: 120px; overflow: visible; opacity: 0; }
.jx-sign__ribbon path { fill: none; stroke: var(--line-2); stroke-width: 1.5; stroke-dasharray: 0.012 0.018; stroke-linecap: round; }
.jx-sign__ribbon path + path { stroke: var(--line-3); }

/* Act IV: phone -------------------------------------------------------- */
.jx-phone { --ph-h: 560px; --ph-w: calc(var(--ph-h) * 9 / 19.4); display: grid; justify-items: center; gap: 16px; margin: 0; }
.jx-phone__body {
  width: var(--ph-w);
  height: var(--ph-h);
  padding: calc(var(--ph-w) * 0.035);
  border-radius: calc(var(--ph-w) * 0.17);
  background: var(--device-frame);
  box-shadow: inset 0 0 0 1px var(--device-edge), inset 0 0 0 4px var(--device-frame), var(--device-shadow);
}
.jx-phone__screen {
  position: relative;
  height: 100%;
  border-radius: calc(var(--ph-w) * 0.14);
  overflow: hidden;
  container-type: size;
  background:
    radial-gradient(90% 55% at 15% 5%, hsl(var(--app-hue) 75% 62% / 0.6), transparent 72%),
    radial-gradient(90% 60% at 95% 70%, hsl(calc(var(--app-hue) + 45) 75% 60% / 0.38), transparent 72%),
    radial-gradient(80% 50% at 20% 100%, hsl(calc(var(--app-hue) - 35) 70% 58% / 0.3), transparent 72%),
    var(--app-bg);
  color: var(--app-text);
}
.jx-phone__status { position: absolute; left: 0; right: 0; top: 0; z-index: 3; display: flex; justify-content: space-between; align-items: center; height: 12cqw; padding: 0 9cqw; font-size: 4cqw; font-weight: 650; }
.jx-phone__island { position: absolute; left: 50%; top: 3.2cqw; width: 30cqw; height: 8.4cqw; margin-left: -15cqw; border-radius: 99px; background: #000; }
.jx-phone__bars { display: flex; gap: 0.8cqw; align-items: flex-end; }
.jx-phone__bars i { width: 1.1cqw; height: 2.6cqw; border-radius: 1px; background: currentColor; }
.jx-phone__bars i + i { height: 3.4cqw; }
.jx-phone__bars i + i + i { height: 4.2cqw; }
.jx-scr { position: absolute; inset: 0; }
.jx-scr--safari { display: none; background: var(--app-bg); }
.jx-safari__page { position: absolute; left: 0; right: 0; top: 22%; display: grid; justify-items: center; gap: 3.4cqw; padding: 0 9cqw; text-align: center; }
.jx-safari__icon { position: relative; width: 26cqw; height: 26cqw; }
.jx-safari__icon .tile { --tile: 26cqw; }
.jx-safari__page strong { font-size: 6.4cqw; letter-spacing: -0.02em; }
.jx-safari__ok { display: inline-flex; align-items: center; gap: 1.6cqw; color: var(--app-muted); font-size: 3.6cqw; }
.jx-safari__ok svg { width: 3.8cqw; height: 3.8cqw; }
.jx-safari__btn { position: relative; display: grid; place-items: center; width: 100%; height: 11.5cqw; margin-top: 3cqw; overflow: hidden; border-radius: 99px; background: var(--app-accent); color: #fff; font-size: 4cqw; font-weight: 700; }
.jx-safari__label { position: relative; z-index: 1; }
.jx-safari__fill { position: absolute; inset: 0; background: rgb(255 255 255 / 0.28); transform-origin: 0 50%; transform: scaleX(0); }
.jx-safari__bar { position: absolute; left: 5cqw; right: 5cqw; bottom: 6cqw; display: grid; place-items: center; height: 11cqw; border-radius: 99px; background: var(--app-surface); box-shadow: 0 0 0 1px var(--app-separator); font-size: 3.8cqw; }
.jx-safari__url::before { content: ""; display: inline-block; width: 2.4cqw; height: 3cqw; margin-right: 1.6cqw; border-radius: 0.6cqw; background: var(--app-muted); vertical-align: -0.2cqw; }
.jx-home__grid { position: absolute; left: 6cqw; right: 6cqw; top: 17cqw; display: grid; grid-template-columns: repeat(4, 1fr); row-gap: 5.2cqw; justify-items: center; }
.jx-home__app { display: grid; justify-items: center; gap: 1.4cqw; width: 100%; min-width: 0; }
.jx-home__app .tile { --tile: 15.6cqw; box-shadow: none; }
.jx-home__app small { max-width: 100%; overflow: hidden; color: #fff; font-size: 2.7cqw; text-overflow: ellipsis; white-space: nowrap; text-shadow: 0 1px 2px rgb(0 0 0 / 0.35); }
:root[data-theme="light"] .jx-home__app small, :root:not([data-theme]) .jx-home__app small { color: var(--app-text); text-shadow: none; }
.jx-home__slot { position: relative; width: 15.6cqw; height: 15.6cqw; }
.jx-home__ring { position: absolute; inset: 22%; width: 56%; height: 56%; transform: rotate(-90deg); fill: none; stroke: #fff; stroke-width: 4; stroke-dasharray: 1 1; stroke-dashoffset: 0; opacity: 0; }
.jx-home__dock { position: absolute; left: 4cqw; right: 4cqw; bottom: 4cqw; display: flex; justify-content: space-around; padding: 4cqw; border-radius: 9cqw; background: rgb(255 255 255 / 0.22); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.jx-home__dock .tile { --tile: 15.6cqw; box-shadow: none; }
.jx-phone__caption { color: var(--text-tertiary); font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.28em; text-transform: uppercase; }
.jx-phone__done { display: none; }

/* Act V: orbit (live only) */
.jx-orbit__i { position: absolute; left: 0; top: 0; }
.jx-orbit__i .tile { --tile: 64px; }

@media (max-width: 799px) {
  .journey { padding: 96px var(--gutter) 110px; }
  .jx-act { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .jx-copy { justify-items: center; }
  .jx-card { --card-w: min(86vw, 340px); }
  .jx-sign { --sign-w: min(92vw, 380px); --sign-h: 280px; }
  .jx-pkg { left: 0; }
  .jx-cert { width: 180px; }
  .jx-phone { --ph-h: 480px; }
  .jx-actions { width: 100%; flex-direction: column; }
  .jx-actions .btn { width: 100%; }
}

/* ====================================================================== */
/* Live: one pinned stage ------------------------------------------------ */
/* Overlaps the pinned intro, so the journey's first frame replaces its last one. */
html.jx-live .journey { padding: 0; margin-top: calc(-100svh - var(--jx-hold, 0px)); pointer-events: none; /* clicks reach the morph beneath; --jx-hold: see motion.js HANDOFF */
  height: calc(100svh + var(--jx-dist, 600svh)); } /* journey.js sets the scroll distance */
html.jx-live .jx-stage {
  --vcx: 66%;
  --vcy: 52%;
  --copy-x: var(--gutter);
  display: block;
  max-width: none;
  height: 100svh;
  position: sticky; /* never switches positioning mode while scrolling (see journey.js) */
  top: 0;
  overflow: hidden;
  pointer-events: auto; /* journey.js sets none until the stage pins */
}
html.jx-live .jx-act { display: block; }
html.jx-live .jx-atmos { display: block; position: absolute; inset: 0; pointer-events: none; }
html.jx-live .jx-atmos > span { position: absolute; border-radius: 50%; opacity: 0; }
/* Desktop: the glows fade in while the morph's stage is still showing beneath (hand-off hold, motion.js
   HANDOFF); on their own layers Safari only recomposites them instead of repainting each frame. */
@media (min-width: 800px) { html.jx-live .jx-atmos > span { will-change: opacity; } }
html.jx-live .jx-atmos__a { left: -20%; top: -30%; width: 80vmax; height: 80vmax; background: radial-gradient(closest-side, var(--atmo-a), transparent); }
html.jx-live .jx-atmos__b { right: -25%; bottom: -35%; width: 90vmax; height: 90vmax; background: radial-gradient(closest-side, var(--atmo-b), transparent); }
html.jx-live .jx-atmos__spot {
  left: var(--vcx);
  top: var(--vcy);
  width: 80vmin;
  height: 80vmin;
  margin: -40vmin 0 0 -40vmin;
  background: radial-gradient(closest-side, hsl(var(--app-hue) 90% 62% / var(--jx-spot)), hsl(calc(var(--app-hue) + 60) 90% 62% / calc(var(--jx-spot) * 0.35)) 55%, transparent);
}

html.jx-live .jx-copy {
  position: absolute;
  left: var(--copy-x);
  top: 0;
  bottom: 0;
  z-index: 6;
  width: min(36vw, 500px);
  pointer-events: none;
}
html.jx-live .jx-copy.is-on { pointer-events: auto; }
html.jx-live .jx-vis { position: absolute; left: var(--vcx); top: var(--vcy); margin: 0; }
html.jx-live .jx-cluster { display: none; }
html.jx-live .jx-act[data-act="5"] { text-align: left; }
html.jx-live .jx-act[data-act="5"] .jx-copy { justify-items: start; }

html.jx-live .jx-card { --card-h: 444px; height: var(--card-h); margin: calc(var(--card-h) / -2) 0 0 calc(var(--card-w) / -2); visibility: hidden; z-index: 3; }
html.jx-live .jx-sign { margin: calc(var(--sign-h) / -2) 0 0 calc(var(--sign-w) / -2); visibility: hidden; z-index: 3; }
html.jx-live .jx-phone { --ph-h: min(74svh, 660px); margin: calc(var(--ph-h) / -2) 0 0 calc(var(--ph-w) / -2); visibility: hidden; z-index: 2; }
html.jx-live .jx-phone__caption { position: absolute; top: calc(100% + 14px); white-space: nowrap; }
html.jx-live .jx-phone__done {
  position: absolute;
  top: calc(100% + 4px);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 15px;
  border-radius: var(--radius-pill);
  background: var(--chip-bg);
  box-shadow: inset 0 0 0 1px var(--border-strong);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
}
html.jx-live .jx-scr--safari { display: block; }
html.jx-live .jx-pkg__unsigned { opacity: 1; }
html.jx-live .jx-pkg__signed { opacity: 0; }
html.jx-live .jx-pkg__sig path { stroke-dashoffset: 1; }
html.jx-live .jx-card__icon > .tile,
html.jx-live .jx-pkg__icon > .tile { visibility: hidden; } /* the travelling icon stands in */
html.jx-live .jx-orbit { display: block; left: 0; top: 0; width: 0; height: 0; z-index: 1; } /* icons placed in stage coordinates */
html.jx-live .jx-orbit__i { opacity: 0; }
/* Act I depth field: standalone icons (cheap for Safari, unlike tiles inside the 2,700 px rows) */
html.jx-live .jx-field { display: block; position: absolute; left: 0; top: 0; z-index: 2; }
html.jx-live .jx-field__i { position: absolute; left: 0; top: 0; width: 84px; height: 84px; opacity: 0; will-change: transform, opacity; }
html.jx-live .jx-field__i .tile { --tile: 84px; }

html.jx-live .jx-route { display: block; position: absolute; left: 0; top: 0; z-index: 4; overflow: visible; pointer-events: none; }
html.jx-live .jx-route path { fill: none; stroke-linecap: round; stroke-dasharray: 1 1; stroke-dashoffset: 1; }
html.jx-live .jx-route__line { stroke: var(--line-2); stroke-width: 2; }
html.jx-live .jx-route__glow { stroke: hsl(var(--app-hue) 90% 65% / 0.5); stroke-width: 10; opacity: var(--line-glow, 0.6); }

html.jx-live .jx-hero { display: block; position: absolute; left: 0; top: 0; z-index: 5; width: 120px; height: 120px; opacity: 0; pointer-events: none; will-change: transform; }
html.jx-live .jx-hero .tile { --tile: 120px; }
html.jx-live .jx-hero::before {
  content: "";
  position: absolute;
  inset: -45%;
  border-radius: 50%;
  background: radial-gradient(closest-side, hsl(var(--app-hue) 95% 65% / var(--jx-spot)), transparent);
  opacity: var(--halo, 0);
}

/* The relay: a copy of the Unzag frame the journey opens on */
html.jx-live .jx-relay { position: absolute; inset: 0; z-index: 1; isolation: isolate; pointer-events: none; }
html.jx-live .jx-relay .icon-river { overflow: visible; }

@media (max-width: 799px) {
  html.jx-live .jx-stage {
    --copy-top: calc(env(safe-area-inset-top) + 82px);
    --vis-top: calc(var(--copy-top) + 200px);
    --vis-h: calc(100svh - var(--vis-top) - env(safe-area-inset-bottom) - 18px);
    --vcx: 50%;
    --vcy: calc(var(--vis-top) + var(--vis-h) / 2);
  }
  html.jx-live .jx-copy { left: var(--gutter); right: var(--gutter); top: var(--copy-top); bottom: auto; width: auto; align-content: start; gap: 12px; }
  html.jx-live .jx-copy--final { top: auto; bottom: calc(env(safe-area-inset-bottom) + 24px); }
  html.jx-live .jx-act[data-act="5"] { text-align: center; }
  html.jx-live .jx-act[data-act="5"] .jx-copy { justify-items: center; }
  html.jx-live .jx-title { font-size: clamp(1.9rem, 8.4vw, 2.5rem); }
  html.jx-live .jx-lede { font-size: 15px; }
  html.jx-live .jx-fine { display: none; }
  html.jx-live .jx-card { --card-h: min(420px, var(--vis-h)); }
  html.jx-live .jx-phone { --ph-h: min(var(--vis-h) - 48px, 560px); }
  html.jx-live .jx-actions { gap: 10px; }
  html.jx-live .jx-actions .btn--lg { --h: 54px; }
}
@media (max-width: 799px) and (max-height: 780px) {
  html.jx-live .jx-card__bundle { display: none; }
  html.jx-live .jx-card__art { height: 84px; }
}
