/* scene:kingdom · round 10 · THE KINGDOM (#kingdom), right after the hero (owner point 6). As the hero's officers fly
   outward the reader flies into the clouds: the app's own cloud passage (home/media/kingdom/passage-*, the photographic
   AttunelyCloudPassage) rises over the hero's foot, then parts left and right and reveals the kingdom floating in the
   sky, which grows .86 → 1 and settles, with sparkles and three glass chips of real buildings. One plain statement of
   what the kingdom is (the app's own onboarding line), no slogans.
   - The kingdom render is a PLACEHOLDER (realm-{720,1080,1600}.webp, 1600 × 1275): the swap is a file replacement.
   - Motion: CSS scroll-driven on the scene's own --sx timeline, inside @supports + :root[data-sda], transform/opacity
     only (the individual translate/scale), baked keyframes; the idle (the island's bob, the chips' wobble, the
     sparkles) is one home.loops unit (kingdom.js). The masks sit on a still child, never on the moving layer.
   - Static (motion off, no scroll timelines) = the designed end state: clouds resting low at the edges, the kingdom
     whole. Phone ≤ 640 px. Desktop in desktop.css. */
.s-kingdom {
  --kd-chip-ink: var(--on-sky);
  padding: 34px 0 30px; text-align: center;
}

/* ── the cloud passage: one wide bank (170vw on a phone, its image 1.5 : 1 with alpha, billows along the bottom), cut
   into two halves that share the picture (the left shows its left 58 %, the right its right 58 %), each feathered on
   its inner side and its foot, so closed they read as one bank and parted they carry no seam ── */
.kd__pass {
  position: absolute; z-index: 1; top: 0; left: 50%; width: 170vw; margin-left: -85vw; aspect-ratio: 1536 / 1024;
  pointer-events: none;
}
/* owner: the phone gets the desk's feeling. Sized by the screen's HEIGHT like the desk's bank (about 1.2 screens tall),
   so held it fills the whole lower screen with cloud, then parts to rest at the far edges, framing the kingdom */
@media (max-width: 1023.98px) {
  .kd__pass { width: 180vh; width: 180svh; margin-left: -90vh; margin-left: -90svh; }
  .kd__half { --kd-rest-y: 8%; --kd-rest-s: .82; }
  .kd__half--l { --kd-rest-x: -30%; }
  .kd__half--r { --kd-rest-x: 30%; }
}
.kd__half { position: absolute; top: 0; width: 58%; height: 100%; translate: var(--kd-rest-x) var(--kd-rest-y); scale: var(--kd-rest-s); }
.kd__half--l { left: 0; --kd-rest-x: -2%; transform-origin: 0 100%; }
.kd__half--r { right: 0; --kd-rest-x: 2%; transform-origin: 100% 100%; }
/* at rest (motion off, and the passage's end): low at the section's foot, each half's feathered bank a quarter of the
   screen in from its edge, behind the island and its chips (z 1 under the stage), so the kingdom floats on cloud */
.kd__half { --kd-rest-y: -4%; --kd-rest-s: .7; }
.kd__half--l { --kd-rest-x: -44%; }
.kd__half--r { --kd-rest-x: 44%; }
.kd__mist {
  position: absolute; inset: 0; overflow: hidden;
  -webkit-mask: linear-gradient(#000 60%, transparent 100%), linear-gradient(to var(--kd-in), #000 58%, rgba(0, 0, 0, .55) 80%, transparent 100%);
  -webkit-mask-composite: source-in; -webkit-mask-repeat: no-repeat;
  mask: linear-gradient(#000 60%, transparent 100%) intersect, linear-gradient(to var(--kd-in), #000 58%, rgba(0, 0, 0, .55) 80%, transparent 100%);
  mask-repeat: no-repeat;   /* a repeating mask tile wraps its opaque top row onto a fractional box's foot: a 1 px hairline */
}
.kd__half--l .kd__mist { --kd-in: right; }
.kd__half--r .kd__mist { --kd-in: left; }
.kd__mist img { position: absolute; top: 0; width: calc(100% / .58); max-width: none; height: auto; -webkit-user-drag: none; user-select: none; }
.kd__half--l img { left: 0; }
.kd__half--r img { right: 0; }
/* by night the bank is moonlit, not noon: a graded copy (passage-night-*: lavender highlights, violet shadows), a little
   thin so the starry sky shows through. The swap is two lazy images, so only the theme on screen is fetched */
.kd__night, :root:not([data-theme="light"]) .kd__day { display: none; }
:root:not([data-theme="light"]) .kd__night { display: block; }
:root:not([data-theme="light"]) .kd__mist { opacity: .84; }

/* ── the words ── */
.kd__head { position: relative; z-index: 3; width: var(--col); margin: 0 auto; }
.kd__tag {
  display: inline-flex; align-items: center; gap: 7px; margin: 0; padding: 6px 14px 7px 11px; border-radius: 999px;
  font-size: 15px; line-height: 1.1; letter-spacing: .1em; color: #6E4A00;
  background: linear-gradient(150deg, rgba(255, 255, 255, .5), rgba(255, 255, 255, .22));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9), inset 0 0 0 1px rgba(255, 255, 255, .5), 0 10px 22px -14px rgba(60, 74, 122, .5);
}
.kd__tag::before {   /* the gold four-point star: the kingdom's sparkle, as the tag's mark */
  content: ""; width: 12px; height: 12px; flex: none; background: var(--spark);
  -webkit-mask: var(--spark-shape) center / contain no-repeat; mask: var(--spark-shape) center / contain no-repeat;
}
.kd__tag:lang(en) { letter-spacing: .04em; }
:root[data-sky-tone="dark"] .kd__tag {
  color: #FFE7A3; background: linear-gradient(150deg, rgba(186, 166, 255, .2), rgba(120, 98, 220, .1));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .26), inset 0 0 0 1px rgba(255, 255, 255, .12), 0 12px 24px -14px rgba(8, 5, 26, .8);
}
.kd__title {
  margin: 14px 0 0; font-size: clamp(30px, 9vw, 38px); line-height: 1.16; letter-spacing: .02em; color: var(--on-sky-title);
  text-wrap: balance;
}
.kd__title:lang(en) { font-size: clamp(30px, 9.4vw, 40px); line-height: 1.06; letter-spacing: -.014em; }
.kd__lede {
  margin: 12px auto 0; max-width: 20em; font: 600 17px/1.5 var(--font-body); letter-spacing: .02em; color: var(--on-sky-2);
  text-wrap: balance; text-shadow: var(--sky-halo);
}
.kd__lede:lang(en) { max-width: 18em; letter-spacing: 0; }

/* ── the stage: the kingdom floating in the sky, a pearl glow under it, three chips of real buildings ── */
.kd__stage { position: relative; z-index: 2; width: min(96vw, 440px); margin: 47px auto 39px; aspect-ratio: 1600 / 1275; }
.kd__glow {
  position: absolute; inset: 4% -8% 10%; border-radius: 50%; pointer-events: none;
  background: radial-gradient(closest-side, rgba(255, 255, 255, .72), rgba(255, 246, 252, .3) 52%, transparent 100%);
}
:root[data-sky-tone="dark"] .kd__glow { background: radial-gradient(closest-side, rgba(196, 176, 255, .2), rgba(150, 120, 255, .08) 55%, transparent 100%); }
.kd__realm { position: absolute; inset: 0; display: block; }
.kd__bob { display: block; animation: kd-bob 9s cubic-bezier(.45, 0, .55, 1) infinite paused; }
.kd__realm img { display: block; width: 100%; height: auto; object-fit: contain; -webkit-user-drag: none; user-select: none; }
[data-loop="on"] .kd__bob { animation-play-state: running; }
@keyframes kd-bob { 0%, 100% { transform: translate3d(0, 0, 0); } 50% { transform: translate3d(0, -7px, 0); } }

.kd__chips { position: absolute; inset: 0; z-index: 7; margin: 0; padding: 0; list-style: none; }
.kd__c { --wt: 7.6s; }
.kd__chip { gap: 9px; padding: 9px 16px 10px; border-radius: 16px; }   /* text only (owner: no icons) */
.kd__chip .glass__t > b { font-size: 11.5px; }
.kd__chip .glass__t > :last-child { font-size: 15px; }
/* phone: the island fills the width, so every chip sits on open sky, never on the render (its buildings would show
   through the clear glass): the lighthouse's name floats just above the lighthouse, the tea house's in the open corner
   right of the rock, the alliance under the rock's tip */
.kd__c--light { --x: 0%; --y: -14.2%; --r: -3deg; --wd: -1.8s; }
.kd__c--tea { left: auto; right: -1%; --y: 77%; --r: 3deg; --wd: -4.2s; }
.kd__c--ally { --x: 1%; --y: 97%; --r: -2deg; --wd: -3s; --wt: 8.4s; }
.kd__s--1 { --x: 6%; --y: 30%; --s: 18px; --sd: -.7s; }
.kd__s--2 { --x: 48%; --y: -4%; --s: 14px; --sd: -2.2s; }
.kd__s--3 { --x: 88%; --y: 58%; --s: 20px; --sd: -1.3s; }
.kd__s--4 { --x: 30%; --y: 86%; --s: 12px; --sd: -2.9s; }

/* short / narrow phones: the chips step down a size */
@media (max-width: 359.98px) { .kd__chip { scale: .9; } .kd__c--light { transform-origin: 0 50%; } }

/* ── the passage, scroll-driven (never under motion off; without scroll timelines the static end state stands) ──
   cover 0 %: the bank closed at the scene's top edge, below the fold at first paint · → 26 %: it rises over the hero's
   foot and swells as the officers fly out (the reader flies in) · 26–34 %: held, the screen is cloud · → 56 %: it parts
   left and right and sinks back to rest low at the edges. The kingdom grows in through the parting; the words and the
   chips follow it. */
@supports (animation-timeline: view()) {
  :root[data-sda]:not([data-motion="off"]) :is(.kd__half, .kd__realm, .kd__head, .kd__c) {
    animation-duration: auto; animation-timing-function: linear; animation-fill-mode: both; animation-timeline: --sx;
  }
  :root[data-sda]:not([data-motion="off"]) .kd__half--l { animation-name: kd-part-l; animation-range: cover 0% cover 56%; }
  :root[data-sda]:not([data-motion="off"]) .kd__half--r { animation-name: kd-part-r; animation-range: cover 0% cover 56%; }
  @media (max-height: 1599.98px) {   /* never in a page-tall crawler render (see home.css .sx-rise) */
    :root[data-sda]:not([data-motion="off"]) .kd__realm { animation-name: kd-realm; animation-range: cover 22% cover 50%; }
    :root[data-sda]:not([data-motion="off"]) .kd__head { animation-name: kd-rise; animation-range: cover 24% cover 42%; }
    :root[data-sda]:not([data-motion="off"]) .kd__c { animation-name: kd-chip; animation-range: cover 36% cover 54%; }
    :root[data-sda]:not([data-motion="off"]) .kd__c--tea { animation-range: cover 39% cover 57%; }
    :root[data-sda]:not([data-motion="off"]) .kd__c--ally { animation-range: cover 33% cover 51%; }
  }
}
@keyframes kd-part-l {
  0% { translate: 0 0; scale: 1.06; }
  26%, 34% { translate: 0 -64%; scale: 1.26; }
  100% { translate: var(--kd-rest-x) var(--kd-rest-y); scale: var(--kd-rest-s); }
}
@keyframes kd-part-r {
  0% { translate: 0 0; scale: 1.06; }
  26%, 34% { translate: 0 -64%; scale: 1.26; }
  100% { translate: var(--kd-rest-x) var(--kd-rest-y); scale: var(--kd-rest-s); }
}
@media (max-width: 1023.98px) {
  @supports (animation-timeline: view()) {
    :root[data-sda]:not([data-motion="off"]) :is(.kd__half--l, .kd__half--r) { animation-range: cover 0% cover 64%; }
    :root[data-sda]:not([data-motion="off"]) .kd__half--l { animation-name: kd-part-l-ph; }
    :root[data-sda]:not([data-motion="off"]) .kd__half--r { animation-name: kd-part-r-ph; }
  }
}
@keyframes kd-part-l-ph { 0% { translate: 0 0; scale: 1.06; } 22%, 44% { translate: 0 -46%; scale: 1.2; } 100% { translate: var(--kd-rest-x) var(--kd-rest-y); scale: var(--kd-rest-s); } }
@keyframes kd-part-r-ph { 0% { translate: 0 0; scale: 1.06; } 22%, 44% { translate: 0 -46%; scale: 1.2; } 100% { translate: var(--kd-rest-x) var(--kd-rest-y); scale: var(--kd-rest-s); } }
@keyframes kd-realm {
  0% { opacity: 0; translate: 0 44px; scale: .86; }
  30% { opacity: 1; }
  82% { translate: 0 -4px; scale: 1.012; }
  100% { opacity: 1; translate: 0 0; scale: 1; }
}
@keyframes kd-rise { from { opacity: 0; translate: 0 26px; } }
@keyframes kd-chip { from { opacity: 0; translate: 0 22px; scale: .9; } }

:root[data-motion="off"] .kd__bob { animation: none; }
