/* ============================================================
   Ally Lama — Homepage v2 (living world hero)
   Loads after style.css; overrides hero + adds new sections.
   ============================================================ */

:root { --hero-ink: #ffffff; --teal: #74d0dc; --blue: #0078ff; --navy: #02092f; }

.skip-link { position: absolute; left: -999px; top: 8px; z-index: 200; background: #fff; color: #02092f; padding: 8px 16px; border-radius: 8px; }
.skip-link:focus { left: 12px; }

/* ── Nav over the world ─────────────────────────────────── */
.home .nav:not(.scrolled) .nav-links a { color: var(--hero-ink); opacity: .85; text-shadow: 0 1px 8px rgba(0,0,0,.18); }
.home .nav:not(.scrolled) .nav-links a:hover { opacity: 1; }
.home .nav:not(.scrolled) .nav-toggle span { background: var(--nav-icon, var(--hero-ink)); }
/* the ✕ (menu open) follows the scene too: blue by day, white at night, scrolled or not */
.home .nav .nav-toggle.open span { background: var(--nav-icon, #ffffff); }

/* ── World ──────────────────────────────────────────────── */
.world {
  position: relative;
  height: 100vh; height: 100svh;
  min-height: 560px;
  overflow: hidden;
  background: #a8cde6;
  isolation: isolate;
  cursor: default;
  touch-action: pan-y;
  container-type: size;            /* cq units + @container below measure the hero itself (as world.js does) */

  /* ── Scene + Ally placement: the ONE place to retarget ──
     World units = pixels of the painted master (3168×2112, assets/world/, tools/bg/build_world.py).
     Landscape shows the approved painting band: --scene-w × --scene-h starting at world y --scene-y0, cover-fitted
     into the hero and aligned at (--scene-ax, --scene-ay). world.js reads these same variables for its camera.
     --ally-x / --ally-seat = world point under his seat (the painted stone); --ally-size = his artboard height.
     Portrait (hero narrower than 9:10): the camera follows him, so he is placed in fractions of the hero:
     --ally-px / --ally-py = seat point, --ally-psize = artboard height.
     --ally-ax / --ally-ay = the seat point inside the 1000×1200 artboard (centre of his base, on the ground line). */
  --scene-w: 3168; --scene-h: 1344; --scene-y0: 450; --scene-ax: .5; --scene-ay: .6;
  --ally-x: 2150; --ally-seat: 1478; --ally-size: 680;   /* x: centre of the stone slab (1790..2505) */
  --ally-px: .5; --ally-py: .72; --ally-psize: .36;
  --ally-ax: .5; --ally-ay: .965;
}
/* narrower landscape screens: slide the camera right so Ally stays clear of the copy and inside the frame */
@container (max-aspect-ratio: 3/2) { .world { --scene-ax: .62; } }
@container (max-aspect-ratio: 4/3) { .world { --scene-ax: .7; } }

/* the painting as a plain image: first paint, Save-Data, and the base the living canvas fades in over.
   Its box is the asset's crop rectangle in world units, placed with the same camera maths as world.js. */
.world-poster { position: absolute; z-index: 0; pointer-events: none; background-size: 100% 100%; background-repeat: no-repeat; }
.world-poster::after { content: ""; position: absolute; inset: 0; background: var(--world-grade, transparent); mix-blend-mode: multiply; }
.world-poster.wide {
  --s: max(100cqw / var(--scene-w), 100cqh / var(--scene-h));
  width: calc(3168 * var(--s)); height: calc(1464 * var(--s));
  left: calc(0px - (var(--scene-w) * var(--s) - 100cqw) * var(--scene-ax));
  top: calc((390 - var(--scene-y0)) * var(--s) - (var(--scene-h) * var(--s) - 100cqh) * var(--scene-ay));
  background-image: url(../assets/world/wide-poster.jpg?v=20261008a);
  background-image: image-set(url(../assets/world/wide-poster.avif?v=20261008a) type("image/avif"), url(../assets/world/wide-poster.jpg?v=20261008a) type("image/jpeg"));
}
.world-poster.tall {
  display: none;
  background-image: url(../assets/world/tall-poster.jpg?v=20261008a);
  background-image: image-set(url(../assets/world/tall-poster.avif?v=20261008a) type("image/avif"), url(../assets/world/tall-poster.jpg?v=20261008a) type("image/jpeg"));
}
@container (max-aspect-ratio: 9/10) {
  .world-poster.wide { display: none; }
  .world-poster.tall {
    display: block;
    --s: calc(var(--ally-psize) * 100cqh / var(--ally-size));
    width: calc(1768 * var(--s)); height: calc(2112 * var(--s));
    left: calc((1400 - var(--ally-x)) * var(--s) + var(--ally-px) * 100cqw);
    top: calc(0px - var(--ally-seat) * var(--s) + var(--ally-py) * 100cqh);
  }
}
@supports not (width: 1cqw) {     /* pre-2023 browsers */
  .world-poster.wide { inset: 0; width: auto; height: auto; background-size: cover; background-position: 60% 50%; }
}
#world-back, #world-front { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#world-back { z-index: 1; }
#world-front { z-index: 3; pointer-events: none; }
.world-scrim { position: absolute; inset: 0; z-index: 4; pointer-events: none;
  background: linear-gradient(90deg, rgba(2,9,47,.34) 0%, rgba(2,9,47,.14) 34%, rgba(2,9,47,0) 55%);
  transition: opacity 1s ease; }
.world[data-phase="day"] .world-scrim { background: linear-gradient(90deg, rgba(255,255,255,.3) 0%, rgba(255,255,255,.12) 34%, rgba(255,255,255,0) 52%); }
#world-back, #world-front { opacity: 1; transition: opacity .6s ease; }
.world:not(.ready) #world-back, .world:not(.ready) #world-front { opacity: 0; }

/* Ally: a 5:6 box = the Rive artboard (AllySeated 1000×1200). The poster and the Rive canvas both fill it exactly,
   so the poster → rig swap cannot shift. He is drawn above the scene's grade and carries his own (the app's light). */
#ally {
  position: absolute; z-index: 2; outline: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
  --s: max(100cqw / var(--scene-w), 100cqh / var(--scene-h));
  --ah: calc(var(--ally-size) * var(--s));
  height: var(--ah); width: calc(var(--ah) * 5 / 6);
  left: calc(var(--ally-x) * var(--s) - (var(--scene-w) * var(--s) - 100cqw) * var(--scene-ax) - var(--ah) * 5 / 6 * var(--ally-ax));
  top: calc((var(--ally-seat) - var(--scene-y0)) * var(--s) - (var(--scene-h) * var(--s) - 100cqh) * var(--scene-ay) - var(--ah) * var(--ally-ay));
}
@supports not (width: 1cqw) {     /* pre-2023 browsers: a fixed spot */
  #ally { height: 46vh; width: 38.33vh; left: 52vw; top: 40vh; }
}
@container (max-aspect-ratio: 9/10) {
  #ally {
    --ah: calc(var(--ally-psize) * 100cqh);
    left: calc(var(--ally-px) * 100cqw - var(--ah) * 5 / 6 * var(--ally-ax));
    top: calc(var(--ally-py) * 100cqh - var(--ah) * var(--ally-ay));
  }
}
/* Brand six-circle seed turning slowly behind Ally's head. Centred on the head in the 5:6 artboard
   (head centre ≈ 48.6% / 17.5% of the box, head ≈ 26% of its width; seed 43.2% wide); not part of #ally-stage, so the
   time-of-day light grade never tints it, and the Rive canvas (in front) keeps the head on top. */
.ally-seed {
  position: absolute; pointer-events: none; user-select: none; -webkit-user-drag: none;
  width: 43.2%; height: auto; left: 27%; top: .7%;   /* centre (48.6%, 17.5%); height = 43.2% × 385/413 × 5/6 of the box */
  opacity: .75; animation: seed-turn 48s linear infinite; will-change: transform;
}
@keyframes seed-turn { to { transform: rotate(360deg); } }
/* hero: the pin box (= Ally's 5:6 box) is moved by ally-rive.js in step with the rig's hover float, so the seed stays
   on his face; the seed itself only turns */
.ally-seed-pin { position: absolute; inset: 0; pointer-events: none; will-change: transform; }
/* hero scene: a quieter halo (Tarun 18:17): 10% smaller than the Start-free one, half opacity; same centre */
#ally .ally-seed { width: 38.88%; left: 29.16%; top: 2.4%; opacity: .5; }
#ally:focus-visible { outline: 3px solid var(--teal); outline-offset: -10px; border-radius: 42% 42% 30% 30%; }
/* isolated: the poster's light map overlays the poster only, never the garden behind him */
#ally-stage { position: absolute; inset: 0; isolation: isolate; }
/* time of day (the app v2's light, world.js): the rig grades and lights itself (view model); the poster gets the same
   grade as a CSS filter chain (--ally-light, none by day) and, at night, the lantern light map overlaid on it */
#ally-stage .ally-poster { filter: var(--ally-light, none); }
#ally-stage .ally-poster, #ally-stage .ally-poster img, #ally-stage canvas, #ally-stage .ally-poster-light { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#ally-stage .ally-poster-light { mix-blend-mode: overlay; opacity: 0; pointer-events: none; -webkit-user-drag: none; user-select: none; }
#ally-stage .ally-poster img { -webkit-user-drag: none; user-select: none; }
#ally-stage canvas { opacity: 0; transition: opacity .45s ease; pointer-events: none; }
/* cross-fade: the canvas fades in over the identical poster, then the poster is hidden (no double compositing) */
#ally.live #ally-stage canvas { opacity: 1; }
#ally.live .ally-poster, #ally.live .ally-poster-light { visibility: hidden; transition: visibility 0s linear .5s; }

#ally-bubble {
  position: absolute; z-index: 5; max-width: 250px;
  background: #fffdf8; color: #1d1719; border-radius: 22px;
  padding: 12px 16px; font-size: .95rem; line-height: 1.45;
  filter: drop-shadow(0 8px 22px rgba(0,0,0,.16));            /* borderless; the shadow follows the tail too */
  opacity: 0; transform: translateY(8px) scale(.96); transition: opacity .3s ease, transform .3s ease; pointer-events: none;
}
#ally-bubble strong { display: block; font-weight: 600; }
/* tail: a rotated square in the bubble's colour; above Ally it points down at his head from the bubble's right side */
#ally-bubble::after { content: ""; position: absolute; left: var(--tail, 34px); bottom: -8px; width: 18px; height: 18px;
  background: #fffdf8; border-radius: 3px; transform: rotate(45deg); }
#ally-bubble.show { opacity: 1; transform: none; }
/* portrait: the bubble sits just above his head and may briefly cover the headline, so it rides above the hero copy */
#ally-bubble.compact { z-index: 7; }

/* Hero copy */
.hero-ui { position: absolute; inset: 0; z-index: 6; display: flex; align-items: center; pointer-events: none; }
.hero-ui .container { width: 100%; }
.hero-copy { max-width: 520px; pointer-events: auto; padding-top: 40px; }
.hero-copy .hero-eyebrow { color: var(--hero-ink); border-color: currentColor; background: rgba(255,255,255,.08); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.hero-copy .hero-title { color: var(--hero-ink); font-size: clamp(2.6rem, 5.4vw, 4.6rem); text-shadow: 0 2px 18px rgba(0,0,0,.18); }
.hero-copy .hero-title span { color: var(--blue); }
.world[data-phase="night"] .hero-copy .hero-title span, .world[data-phase="twilight"] .hero-copy .hero-title span { color: var(--teal); }
.hero-copy .hero-sub { color: var(--hero-ink); opacity: .92; text-shadow: 0 1px 10px rgba(0,0,0,.2); }
.world[data-phase="day"] .hero-copy .hero-title, .world[data-phase="day"] .hero-copy .hero-sub { text-shadow: 0 0 18px rgba(255,255,255,.85), 0 0 4px rgba(255,255,255,.7); }
.hero-copy .hero-download-card {
  background: linear-gradient(135deg, rgba(2,9,47,.72) 0%, rgba(0,50,125,.62) 100%);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-color: rgba(116,208,220,.5); box-shadow: 0 18px 50px rgba(2,9,47,.28);
}
.badge-stack { display: inline-flex; flex-direction: column; align-items: center; }

/* Controls */
.world-controls { position: absolute; z-index: 7; right: 24px; bottom: 24px; }
.time-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px 8px 10px; border-radius: 50px; cursor: pointer;
  font: inherit; font-size: .82rem; letter-spacing: .06em; color: #fff;
  background: rgba(2,9,47,.5); border: 1px solid rgba(255,255,255,.25); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: background .2s ease, transform .2s ease;
}
.time-chip:hover { background: rgba(2,9,47,.7); transform: translateY(-1px); }
.time-chip:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }
.time-icon { width: 18px; height: 18px; border-radius: 50%; background: #ffd66e; box-shadow: 0 0 10px rgba(255,214,110,.8); }
.time-chip[data-mode="night"] .time-icon { background: #f3efdc; box-shadow: inset -5px -2px 0 0 #9aa6c8, 0 0 8px rgba(243,239,220,.6); }
.time-chip[data-mode="dawn"] .time-icon, .time-chip[data-mode="dusk"] .time-icon { background: linear-gradient(#ffb36b, #f07a8a); }

.scroll-cue { position: absolute; z-index: 7; left: 50%; bottom: 22px; width: 26px; height: 42px; margin-left: -13px;
  border: 2px solid rgba(255,255,255,.75); border-radius: 14px; }
.scroll-cue span { position: absolute; left: 50%; top: 8px; width: 4px; height: 8px; margin-left: -2px; background: #fff; border-radius: 2px; animation: cue 1.8s ease-in-out infinite; }
@keyframes cue { 0% { transform: translateY(0); opacity: 1; } 70% { transform: translateY(12px); opacity: 0; } 100% { opacity: 0; } }

/* ── Meet Ally ──────────────────────────────────────────── */
.meet { padding-top: 110px; }
.meet-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 64px; align-items: center; }
.meet-copy h2 { color: #fff; margin-bottom: 14px; }
.meet-copy p { font-size: 1.08rem; color: rgba(255,255,255,.86); max-width: 560px; }
/* the "wise companion" illustration, in the same glow disc as the feature cards (the art is cut to its own circle) */
.meet-portrait { position: relative; width: 200px; aspect-ratio: 1; margin-bottom: 26px; }
.meet-portrait::before { content: ''; position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, rgba(255,240,214,.22), rgba(116,208,220,.16) 52%, rgba(0,120,255,.12) 74%);
  box-shadow: inset 0 0 0 1.5px rgba(116,208,220,.38), 0 18px 40px -18px rgba(0,120,255,.55); }
.meet-portrait picture, .meet-portrait img { position: relative; display: block; width: 100%; height: auto; }
.meet .hero-phone-wrap { display: flex; flex-direction: column; align-items: center; }

/* ── Feature cards ──────────────────────────────────────── */
.features { padding-top: 40px; }
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.feature-card {
  position: relative; padding: 30px 28px 32px; border-radius: 22px;
  background: linear-gradient(160deg, rgba(255,255,255,.07), rgba(255,255,255,.025));
  border: 1px solid rgba(255,255,255,.1); transition: transform .3s ease, border-color .3s ease, background .3s ease;
}
.feature-card:hover { transform: translateY(-4px); border-color: rgba(116,208,220,.45); background: linear-gradient(160deg, rgba(116,208,220,.1), rgba(0,120,255,.05)); }
/* Ally illustrations: each is cut to its own canvas circle, so the disc behind it is the same box and the robe's
   lower edge lands on the disc's rim */
.feature-art { position: relative; width: 192px; aspect-ratio: 1; margin: 0 auto 22px; }
.feature-art::before { content: ''; position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, rgba(255,240,214,.22), rgba(116,208,220,.16) 52%, rgba(0,120,255,.12) 74%);
  box-shadow: inset 0 0 0 1.5px rgba(116,208,220,.38), 0 18px 40px -18px rgba(0,120,255,.55);
  transition: box-shadow .3s ease, background .3s ease; }
.feature-card:hover .feature-art::before { box-shadow: inset 0 0 0 1.5px rgba(116,208,220,.7), 0 20px 44px -16px rgba(116,208,220,.5); }
.feature-art picture, .feature-art img { position: relative; display: block; width: 100%; height: auto; }
.feature-card h3 { color: #fff; font-size: 1.3rem; margin-bottom: 10px; font-weight: 400; }
.feature-card p { color: rgba(255,255,255,.78); font-size: .98rem; }
.feature-quote { display: flex; flex-direction: column; justify-content: center; background: linear-gradient(160deg, rgba(0,120,255,.22), rgba(116,208,220,.1)); border-color: rgba(116,208,220,.35); }
.feature-quote .quote-mark { font-size: 4rem; line-height: .6; color: var(--teal); font-family: Georgia, serif; }
.feature-quote .quote-text { font-size: 1.35rem; color: #fff; font-style: italic; margin: 12px 0 10px; font-family: 'Baskerville', Georgia, serif; }
.feature-quote .quote-src { font-size: .8rem; letter-spacing: .16em; text-transform: uppercase; color: var(--teal); }

/* ── Start free ─────────────────────────────────────────── */
.pricing-ally { width: 170px; margin: 0 auto 30px; filter: drop-shadow(0 16px 30px rgba(0,120,255,.25)); animation: float 6s ease-in-out infinite; }
.pricing-ally { position: relative; }
.pricing-ally picture { position: relative; display: block; }
.pricing-ally img { display: block; width: 100%; height: auto; }
.pricing-ally .ally-seed { position: absolute; display: block; width: 43.2%; height: auto; }
.pricing-actions { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-bottom: 24px; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 900px) {
  .meet-grid { grid-template-columns: 1fr; text-align: center; }
  .meet-portrait { margin-left: auto; margin-right: auto; }
  .meet-copy p { margin: 0 auto; }
  .feature-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-aspect-ratio: 9/10) {
  /* portrait: copy sits in the sky, download card over the foreground */
  .hero-ui { align-items: stretch; }
  .hero-ui .container { display: flex; }
  .hero-copy { max-width: none; width: 100%; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 92px 0 20px; }
  /* the column spans the whole hero here: let taps in its empty middle reach Ally and the pond */
  .hero-copy { pointer-events: none; }
  .hero-copy > * { pointer-events: auto; }
  .hero-copy .hero-title { display: block; font-size: clamp(2.2rem, 10vw, 3.2rem); margin-bottom: 6px; line-height: 1.12; }
  .hero-copy .hero-eyebrow { margin-top: 0; }
  .hero-copy .hero-sub { display: none; }
  .hero-copy .hero-eyebrow { font-size: .7rem; margin-bottom: 10px; }
  .hero-copy .hero-download-card { margin-top: auto; width: 100%; max-width: 420px; padding: 14px 14px 12px; gap: 10px; }
  .hero-copy .hero-actions { flex-wrap: nowrap; gap: 10px; }
  .hero-copy .store-badge { padding: 9px 14px; gap: 8px; }
  .hero-copy .store-badge .badge-name { font-size: .88rem; }
  .hero-copy .coming-soon-label { font-size: .6rem; margin-top: 4px; white-space: nowrap; }
  .hero-copy .hero-download-free { font-size: 1rem; }
  .hero-copy .hero-download-sub { display: none; }
  .hero-actions { justify-content: center; }
  .world-scrim, .world[data-phase="day"] .world-scrim { background: linear-gradient(180deg, rgba(2,9,47,.28) 0%, rgba(2,9,47,0) 30%, rgba(2,9,47,0) 62%, rgba(2,9,47,.35) 100%); }
  .world[data-phase="day"] .world-scrim { background: linear-gradient(180deg, rgba(255,255,255,.42) 0%, rgba(255,255,255,.2) 22%, rgba(255,255,255,0) 34%, rgba(2,9,47,0) 62%, rgba(2,9,47,.3) 100%); }
  /* the headline sits over cherry blossom here: a soft paper glow + a deeper blue keep it crisp */
  .world[data-phase="day"] .hero-copy .hero-title { text-shadow: 0 0 22px rgba(255,255,255,.95), 0 0 8px rgba(255,255,255,.85), 0 0 2px rgba(255,255,255,.9); }
  .world[data-phase="day"] .hero-copy .hero-title span { color: #0060d6; }
  /* ultra-light 200 is too fine over the painting at phone size */
  .hero-copy .hero-title { font-weight: 400; letter-spacing: -.01em; }
  .world-controls { right: 14px; bottom: auto; top: 84px; }
  .scroll-cue { display: none; }
}
@media (max-width: 660px) {
  .feature-grid { grid-template-columns: 1fr; }
  .feature-art { width: 200px; }
  .time-chip .time-label { display: none; }
  .time-chip { padding: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .pricing-ally, .scroll-cue span, .ally-seed { animation: none !important; }
}
@media (max-aspect-ratio: 9/10) {
  .hero-copy .store-badge { white-space: nowrap; flex: 1 1 0; justify-content: center; min-width: 0; }
  .hero-copy .store-badge .badge-sub { font-size: .6rem; }
  .hero-copy .badge-stack { flex: 1 1 0; min-width: 0; }
  .hero-copy .badge-stack .store-badge { width: 100%; }
}
@media (max-width: 900px) {
  .meet .hero-phone-wrap { order: 0; margin-right: 0; margin-top: 12px; }
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.home .iphone-carousel img { object-fit: cover; }
/* legibility in low light */
.world[data-phase="twilight"] .hero-copy .hero-title span { color: #b3f0f7; text-shadow: 0 2px 16px rgba(2,9,47,.45); }
.home:has(.world[data-phase="night"]) .nav:not(.scrolled) .nav-logo img,
.home:has(.world[data-phase="twilight"]) .nav:not(.scrolled) .nav-logo img { filter: brightness(1.7) saturate(.85) drop-shadow(0 1px 6px rgba(2,9,47,.5)); }

/* beside Ally: the bubble sits to the LEFT of his head, the tail pointing right at his cheek */
#ally-bubble.side, #ally-bubble.compact { font-size: .84rem; padding: 9px 13px; border-radius: 18px; }
#ally-bubble.side::after { left: auto; right: -7px; top: 20px; bottom: auto; width: 16px; height: 16px; }

/* speech: words appear as Ally says them (the box is laid out in full from the start, so it never grows) */
#ally-bubble .w { opacity: 0; transition: opacity .16s ease; }
#ally-bubble .w.on { opacity: 1; }
@media (prefers-reduced-motion: reduce) { #ally-bubble .w { opacity: 1; transition: none; } }
