/* ECHIVO — section: download (final CTA + footer). OWNED BY: web agent 9. All selectors scoped to #download. */

#download {
  --dl-icon: clamp(128px, 15vw, 212px);
  --dl-pad-top: clamp(96px, 14vh, 180px);
  overflow: hidden;
  isolation: isolate;
  padding-bottom: 0;
  background:
    linear-gradient(180deg, var(--night) 0%, rgba(5,7,13,0) 22vh),
    radial-gradient(120% 70% at 50% 0%, #0d1428 0%, rgba(5,7,13,0) 60%),
    var(--night);
}

/* ---------- Sky / atmosphere ---------- */
#download .download-sky {
  position: absolute; inset: 0; z-index: -1; pointer-events: none;
  /* fade in from the section above: no hard seam at the top edge */
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 20vh);
          mask-image: linear-gradient(180deg, transparent 0, #000 20vh);
}
#download .download-stars {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1px 1px at 20px 30px, rgba(255,255,255,.55), transparent 60%),
    radial-gradient(1px 1px at 140px 90px, rgba(255,255,255,.35), transparent 60%),
    radial-gradient(1.5px 1.5px at 90px 160px, rgba(245,200,130,.6), transparent 60%),
    radial-gradient(1px 1px at 200px 210px, rgba(255,255,255,.3), transparent 60%);
  background-size: 240px 240px;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 45%, transparent 85%);
          mask-image: linear-gradient(180deg, #000 0%, #000 45%, transparent 85%);
  opacity: .7;
  animation: download-twinkle 6s ease-in-out infinite alternate;
}
@keyframes download-twinkle { from { opacity: .35; } to { opacity: .8; } }

#download .download-aurora {
  position: absolute; border-radius: 50%;
  will-change: transform;
}
#download .download-aurora--a {
  width: 80vmax; height: 46vmax; left: -22vmax; top: -6vmax;
  background: radial-gradient(closest-side, rgba(245,200,130,.20), rgba(245,200,130,0));
  animation: download-drift-a 22s ease-in-out infinite alternate;
}
#download .download-aurora--b {
  width: 70vmax; height: 40vmax; right: -24vmax; top: 4vmax;
  background: radial-gradient(closest-side, rgba(157,123,255,.16), rgba(157,123,255,0));
  animation: download-drift-b 26s ease-in-out infinite alternate;
}
#download .download-aurora--c {
  width: 60vmax; height: 30vmax; left: 20%; top: 30%;
  background: radial-gradient(closest-side, rgba(255,138,91,.10), rgba(255,138,91,0));
  animation: download-drift-a 30s ease-in-out infinite alternate-reverse;
}
@keyframes download-drift-a { from { transform: translate3d(0,0,0) scale(1); } to { transform: translate3d(12vw, 6vh, 0) scale(1.15); } }
@keyframes download-drift-b { from { transform: translate3d(0,0,0) scale(1.1); } to { transform: translate3d(-14vw, 8vh, 0) scale(.95); } }

/* Rays: centred on the app icon */
#download .download-rays-wrap {
  position: absolute; left: 50%;
  top: calc(var(--dl-pad-top) + var(--dl-icon) / 2);
  width: 0; height: 0;
}
#download .download-rays {
  position: absolute; left: 0; top: 0;
  width: 160vmax; height: 160vmax;
  margin: -80vmax 0 0 -80vmax;
  border-radius: 50%;
  -webkit-mask-image: radial-gradient(closest-side, #000 0%, rgba(0,0,0,.55) 26%, rgba(0,0,0,.12) 50%, transparent 72%);
          mask-image: radial-gradient(closest-side, #000 0%, rgba(0,0,0,.55) 26%, rgba(0,0,0,.12) 50%, transparent 72%);
  will-change: transform;
}
#download .download-rays--1 {
  background: repeating-conic-gradient(from 0deg,
    rgba(245,200,130,0) 0deg, rgba(245,200,130,.20) 3deg, rgba(245,200,130,0) 7deg, rgba(245,200,130,0) 15deg);
  animation: download-spin 90s linear infinite;
}
#download .download-rays--2 {
  background: repeating-conic-gradient(from 7deg,
    rgba(255,226,170,0) 0deg, rgba(255,226,170,.10) 5deg, rgba(255,226,170,0) 11deg, rgba(255,226,170,0) 26deg);
  animation: download-spin 140s linear infinite reverse;
}
@keyframes download-spin { to { transform: rotate(360deg); } }

/* Loops pause while the section is off-screen (class toggled in download.js) */
#download.is-offscreen .download-sky *,
#download.is-offscreen .download-icon-glow,
#download.is-offscreen .download-icon-ring,
#download.is-offscreen .download-icon-ring::before,
#download.is-offscreen .download-icon-ring::after { animation-play-state: paused; }

/* ---------- Stage ---------- */
#download .download-stage {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  min-height: calc(100vh - var(--dl-pad-top));
  min-height: calc(100svh - var(--dl-pad-top));
  padding-bottom: clamp(72px, 12vh, 140px);
}

/* App icon */
#download .download-icon-wrap {
  position: relative;
  width: var(--dl-icon); height: var(--dl-icon);
  perspective: 900px;
  margin-bottom: clamp(36px, 6vh, 64px);
}
#download .download-icon {
  position: relative; z-index: 2;
  width: 100%; height: 100%;
  border-radius: 22.5%;
  box-shadow:
    0 0 0 1px rgba(255,255,255,.10) inset,
    0 30px 80px -10px rgba(0,0,0,.7),
    0 0 90px rgba(245,200,130,.35);
  will-change: transform;
}
#download .download-icon-glow {
  position: absolute; inset: -60%; z-index: 0;
  background: radial-gradient(closest-side, rgba(245,200,130,.55), rgba(245,200,130,.14) 45%, rgba(245,200,130,0) 70%);
  animation: download-breathe 4.5s ease-in-out infinite;
}
@keyframes download-breathe { 0%,100% { opacity: .75; transform: scale(.94); } 50% { opacity: 1; transform: scale(1.06); } }

/* Sound-wave echo rings (the "ear" listening) */
#download .download-icon-ring,
#download .download-icon-ring::before,
#download .download-icon-ring::after {
  position: absolute; inset: 0; z-index: 1;
  border-radius: 26%;
  border: 1.5px solid rgba(245,200,130,.55);
  opacity: 0;
  animation: download-echo 4.2s cubic-bezier(.2,.6,.3,1) infinite;
}
#download .download-icon-ring::before,
#download .download-icon-ring::after { content: ""; inset: -1.5px; }
#download .download-icon-ring::before { animation-delay: 1.4s; }
#download .download-icon-ring::after { animation-delay: 2.8s; }
@keyframes download-echo {
  0% { transform: scale(1); opacity: .7; border-radius: 26%; }
  100% { transform: scale(2.4); opacity: 0; border-radius: 50%; }
}

/* Headline */
#download .download-title {
  margin: 0;
  max-width: 12ch;
  text-wrap: balance;
}
#download .download-title .gold {
  color: var(--gold);
}
#download .download-sub {
  margin: clamp(14px, 2vh, 22px) 0 0;
  font-size: clamp(1.05rem, 1.4vw, 1.3rem);
}

/* ---------- Waitlist form ---------- */
#download .download-cta {
  position: relative;
  width: min(560px, 100%);
  margin-top: clamp(32px, 5vh, 52px);
  min-height: 72px;
}
#download .download-form {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 6px 6px 18px;
  border-radius: 999px;
  transition: box-shadow .3s, border-color .3s;
}
#download .download-form:focus-within {
  border-color: rgba(245,200,130,.6);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 0 0 4px rgba(245,200,130,.16), 0 20px 60px rgba(0,0,0,.35);
}
#download .download-form.is-invalid { border-color: rgba(255,122,138,.7); }
#download .download-form__icon { color: var(--text-3); flex: none; }
#download .download-form__input {
  flex: 1; min-width: 0;
  background: transparent; border: 0; outline: none;
  color: var(--text); font: inherit; font-size: 1rem;
  padding: 14px 6px;
}
#download .download-form__input::placeholder { color: var(--text-3); }
#download .download-form__btn { flex: none; white-space: nowrap; padding: .95em 1.4em; }
#download .download-form__btn:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
#download .download-form__btn svg { transition: transform .4s var(--ease-spring); }
#download .download-form__btn:hover svg { transform: translateX(3px); }
#download .download-form__msg {
  min-height: 1.4em; margin: 10px 0 0;
  font-size: var(--t-small); color: var(--rose);
}
#download .download-sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* Success state */
#download .download-success {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
#download .download-success[hidden],
#download .download-form[hidden],
#download .download-form__msg[hidden] { display: none; }
#download .download-success__circle { stroke: rgba(245,200,130,.35); stroke-width: 2; }
#download .download-success__tick {
  stroke: var(--gold); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 40; stroke-dashoffset: 40;
}
#download .download-success.is-in .download-success__tick { animation: download-tick .7s .25s var(--ease-out) forwards; }
@keyframes download-tick { to { stroke-dashoffset: 0; } }
#download .download-success__check { filter: drop-shadow(0 0 18px rgba(245,200,130,.45)); }
#download .download-success__title {
  margin: 4px 0 0; outline: none;
  font-size: clamp(1.5rem, 2.6vw, 2.2rem);
  color: var(--gold);
}
#download .download-success__note { margin: 0; font-size: var(--t-small); }
#download .download-confetti {
  position: absolute; left: 50%; top: 28px; width: 0; height: 0;
  pointer-events: none; z-index: 5;
}
#download .download-confetti i {
  position: absolute; left: -4px; top: -4px;
  width: 8px; height: 8px; border-radius: 2px;
}

/* ---------- Coming-soon badge (not Apple's official artwork) ---------- */
#download .download-badge {
  margin-top: clamp(20px, 3.5vh, 36px);
  display: inline-flex; align-items: center; gap: 10px;
  padding: 9px 20px 9px 15px;
  background: #000; color: #fff;
  border: 1px solid rgba(255,255,255,.32);
  border-radius: 13px;
  box-shadow: 0 14px 40px rgba(0,0,0,.45);
  user-select: none;
}
#download .download-badge__apple { width: 26px; height: 26px; margin-top: -3px; }
#download .download-badge__text { display: flex; flex-direction: column; align-items: flex-start; text-align: left; line-height: 1.05; }
#download .download-badge__text small { font-size: 11px; font-weight: 500; letter-spacing: .01em; }
#download .download-badge__text strong { font-size: 22px; font-weight: 600; letter-spacing: -0.015em; }

/* ---------- Footer ---------- */
#download .download-footer {
  position: relative;
  border-top: 1px solid var(--hairline);
  padding-top: clamp(48px, 7vh, 72px);
}
#download .download-footer__top {
  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-areas: "brand links social" "tag links social";
  align-items: center;
  column-gap: clamp(24px, 4vw, 56px); row-gap: 10px;
}
#download .download-footer__brand { grid-area: brand; display: inline-flex; align-items: center; gap: 12px; width: max-content; }
#download .download-footer__brand img:first-child { width: 36px; height: 36px; }
#download .download-footer__wordmark { width: auto; height: 22px; }
#download .download-footer__tagline { grid-area: tag; margin: 0; font-size: var(--t-small); }
#download .download-footer__links { grid-area: links; display: flex; flex-wrap: wrap; gap: 4px; }
#download .download-footer__links a {
  padding: 8px 12px; border-radius: 999px;
  font-size: .9rem; font-weight: 600; color: var(--text-2);
  transition: color .2s, background .2s;
}
#download .download-footer__links a:hover { color: #fff; background: rgba(255,255,255,.07); }
#download .download-footer__social { grid-area: social; display: flex; gap: 8px; }
#download .download-footer__soc {
  display: grid; place-items: center;
  width: 42px; height: 42px; border-radius: 50%;
  color: var(--text-2);
  border: 1px solid var(--hairline);
  transition: color .2s, border-color .2s, transform .4s var(--ease-spring);
}
#download .download-footer__soc:hover { color: var(--gold); border-color: rgba(245,200,130,.5); transform: translateY(-2px); }
#download .download-footer a:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
#download .download-footer__bottom {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-top: clamp(32px, 5vh, 48px);
  padding-top: 20px;
  border-top: 1px solid var(--hairline);
  font-size: var(--t-small); color: var(--text-3);
}
#download .download-footer__made { display: inline-flex; align-items: center; gap: 6px; }
#download .download-footer__made svg { color: var(--gold); }

/* Giant faded wordmark across the bottom */
#download .download-giant {
  position: relative;
  margin-top: clamp(28px, 5vh, 56px);
  overflow: hidden;
  /* show ~82% of the word height: its feet are cropped by the page edge */
  aspect-ratio: 936 / 224;
}
#download .download-giant__word {
  width: 100%;
  aspect-ratio: 936 / 272;
  background: linear-gradient(180deg, rgba(245,200,130,.20) 0%, rgba(245,200,130,.07) 55%, rgba(245,200,130,0) 95%);
  -webkit-mask: url("../../img/brand/logo-wordmark.png") center top / 100% auto no-repeat;
          mask: url("../../img/brand/logo-wordmark.png") center top / 100% auto no-repeat;
  will-change: transform;
}

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  #download .download-form {
    flex-wrap: wrap; border-radius: 26px; padding: 8px;
  }
  #download .download-stage { min-height: 0; }
  #download .download-form__icon { margin-left: 10px; }
  #download .download-form__input { padding: 12px 6px; }
  #download .download-form__btn { width: 100%; }
  #download .download-confetti { top: 28px; }
  #download .download-footer__top {
    grid-template-columns: 1fr;
    grid-template-areas: "brand" "tag" "links" "social";
    justify-items: start; row-gap: 18px;
  }
  #download .download-footer__links { margin-left: -12px; }
}

/* ---------- lowPower (phones / touch / low memory; .is-lite set by download.js) ----------
   Same sky, a fraction of the GPU memory: pre-rendered ray textures (720px img layers instead of two
   160vmax conic gradients at 3x DPR), static aurora + stars, compositor-only icon motion, no backdrop blur. */
#download.is-lite .download-rays { background: none; -webkit-mask-image: none; mask-image: none; animation: none; will-change: auto; }
#download.is-lite .download-rays__img {
  display: block; width: 100%; height: 100%; max-width: none;
  will-change: transform;
  animation: download-spin 90s linear infinite;
}
#download.is-lite .download-rays--2 .download-rays__img { animation-duration: 140s; animation-direction: reverse; }
#download.is-lite .download-stars { animation: none; opacity: .6; }
#download.is-lite .download-aurora { animation: none; will-change: auto; }
#download.is-lite .download-icon-ring,
#download.is-lite .download-icon-ring::before,
#download.is-lite .download-icon-ring::after { border-radius: 34%; animation-name: download-echo-lite; }
@keyframes download-echo-lite { 0% { transform: scale(1); opacity: .7; } 100% { transform: scale(2.4); opacity: 0; } }
#download.is-cssfloat .download-icon { animation: download-float 3.2s ease-in-out infinite alternate; }
@keyframes download-float { from { transform: translateY(0); } to { transform: translateY(-14px); } }
#download.is-cssfloat.is-offscreen .download-icon,
#download.is-lite.is-offscreen .download-rays__img { animation-play-state: paused; }
#download.is-lite .download-form.glass {
  -webkit-backdrop-filter: none; backdrop-filter: none;
  background: linear-gradient(180deg, rgba(38,44,62,.92), rgba(22,27,42,.92));
}

/* ---------- Reduced motion: final state, nothing moves ---------- */
@media (prefers-reduced-motion: reduce) {
  #download .download-stars,
  #download .download-aurora,
  #download .download-rays,
  #download .download-icon-glow,
  #download .download-icon-ring,
  #download .download-icon-ring::before,
  #download .download-icon-ring::after,
  #download .download-rays__img,
  #download.is-cssfloat .download-icon { animation: none; }
  #download .download-success__tick { stroke-dashoffset: 0; }
}
