/* The home page "scroll story". Wide screens (761px and up) follow Pilot-Snap.html, narrow ones A8-Story.html.
   Both layouts use the same class names with different rules, so each keeps its own block below. */
:root { --bg:#FFFFFF; --ink:#0B1220; --muted:#4B5874; --blue:#2563EB; --pale:#BFD4FF; --card:#F3F6FC; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: Inter, system-ui, -apple-system, sans-serif; -webkit-text-size-adjust: 100%; }
.eyebrow { font: 600 13px ui-monospace, Menlo, monospace; letter-spacing: .04em; word-spacing: -.2em; text-transform: uppercase; color: var(--blue); }
h1, h2 { font-weight: 800; letter-spacing: -.03em; }
p { color: var(--muted); line-height: 1.55; }
.btn { display: inline-flex; align-items: center; gap: 8px; border-radius: 12px; background: var(--blue); color: #fff; text-decoration: none; font-weight: 600; }
.btn svg { flex: none; margin-right: -4px; }
.card { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-radius: 16px; background: var(--card); color: var(--ink); text-decoration: none; }
.card b { font-size: 16px; } .card span { font-size: 14px; line-height: 1.4; color: var(--muted); }
.card i { font: 600 11px ui-monospace, Menlo, monospace; letter-spacing: .08em; text-transform: uppercase; color: var(--blue); }
/* App cards: the app's icon, its name and its label on one line, the description below. */
.card.app { gap: 10px; }
.card.app header { display: flex; align-items: center; gap: 11px; }
.card.app header div { display: flex; flex-direction: column; gap: 3px; }
.card.app i { margin: 0; padding: 0; }
.ico { width: 40px; height: 40px; border-radius: 10px; overflow: hidden; flex: none; display: grid; place-items: center; }
.ico img { width: 100%; height: 100%; }
.ico.zoom img { transform: scale(1.2); }
.links { display: flex; }
.links a { color: var(--blue); font-weight: 600; text-decoration: none; }
.links.site a { color: var(--muted); }

/* Wide: one screen per chapter, and one scroll gesture moves exactly one screen. */
@media (min-width: 761px) {
  .stage, .bar, #thread { display: none; }
  h1, h2 { margin: 12px 0 16px; line-height: 1.02; }
  h1 { font-size: clamp(44px, 6vw, 84px); }
  h1 span { display: block; }
  h2 { font-size: clamp(36px, 4.6vw, 64px); }
  p { font-size: 19px; margin: 0 0 24px; text-wrap: pretty; }
  .btn { padding: 14px 22px; }
  .ch { height: 100vh; display: grid; grid-template-columns: 1fr 1fr; align-items: center; padding: 0 6vw; position: relative; }
  .copy { max-width: 560px; }
  .more { margin: 22px 0 0; }
  .cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { transition: background .2s; }
  .card:hover { background: #E6EDFB; }
  .card i { margin-top: 2px; }

  /* The avatar stage stays fixed on the right while the screens move. */
  .rig { position: fixed; top: 0; right: 0; width: 50vw; height: 100vh; pointer-events: none; transition: opacity .5s; }
  .rig.away { opacity: 0; }
  .glow { position: absolute; left: 50%; top: 50%; width: 70vh; height: 70vh; transform: translate(-50%, -50%); border-radius: 50%;
          background: radial-gradient(circle, rgba(37,99,235,.18), rgba(37,99,235,0) 66%); }
  .ring { position: absolute; left: 50%; top: 44%; width: 54vh; height: 54vh; transform: translate(-50%, -50%); border-radius: 50%; border: 3px solid var(--blue); }
  .dot { position: absolute; right: 12%; top: 14%; width: 90px; height: 90px; border-radius: 50%; background: var(--blue); }
  .tile { position: absolute; left: 10%; bottom: 18%; width: 46px; height: 46px; border-radius: 12px; background: var(--pale); transform: rotate(12deg); }
  .shadow { position: absolute; left: 50%; bottom: 4.5vh; width: 26vh; height: 3.2vh; margin-left: -13vh; border-radius: 50%;
            background: radial-gradient(closest-side, rgba(11,18,32,.22), rgba(11,18,32,0)); }
  .mover { position: absolute; left: 50%; bottom: 3vh; height: 84vh; transform: translateX(-50%); }
  .avatar { height: 100%; transform-origin: 50% 100%; }
  .avatar canvas { height: 100%; display: block; }
  .waiting .mover, .waiting .shadow { visibility: hidden; }

  /* Builder: app icons rain down around him. */
  .icon { position: absolute; width: 54px; height: 54px; border-radius: 14px; opacity: 0; box-shadow: 0 6px 16px rgba(11,18,32,.12); }
  #rain { transition: opacity .4s; } #rain.gone { opacity: 0; }
  .rain .icon { animation: drop .9s cubic-bezier(.5,0,.75,0) both, settle .5s cubic-bezier(.2,1.6,.4,1) both; }

  #hello { grid-template-columns: 1fr; place-items: center; overflow: hidden; }
  #hello .copy { max-width: 520px; text-align: center; padding: 0 20px; }
  .links { margin-top: 18px; gap: 18px; justify-content: center; }
  .links.site { margin-top: 56px; }
  /* He peeks in from the left edge; the right edge has the dots and keys. */
  #peek-wide { position: absolute; left: 0; bottom: 0; height: 70vh; transform: translateX(-100%); transition: transform .7s cubic-bezier(.2,.9,.25,1.15); }
  #peek-wide img { height: 100%; display: block; }
  #peek-wide.in { transform: translateX(0); }

  .dots { position: fixed; right: 22px; top: 50%; transform: translateY(-50%); display: grid; gap: 10px; z-index: 5; }
  .dots button { width: 10px; height: 10px; padding: 0; border-radius: 50%; border: 0; background: #C9D5EC; cursor: pointer; }
  .dots button.on { background: var(--blue); }

  /* Top-left: a small round photo of Kofi, from chapter 2 on. It wipes in. Click to go back to the top. */
  .me { position: fixed; top: 22px; left: 6vw; width: 56px; height: 56px; z-index: 6; border: 0; padding: 0; background: none; cursor: pointer;
        opacity: 0; transform: translateX(-24px); transition: opacity .35s, transform .5s cubic-bezier(.2,1.3,.4,1); pointer-events: none; }
  .me.in { opacity: 1; transform: none; pointer-events: auto; }
  .me img { width: 56px; height: 56px; border-radius: 50%; display: block; box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--blue);
            clip-path: circle(0% at 50% 50%); transition: clip-path .6s cubic-bezier(.3,1,.4,1) .1s; }
  .me.in img { clip-path: circle(60% at 50% 50%); }

  /* Arrow-key hint under the chapter dots. A key lights up when it is pressed. */
  .keys { position: fixed; right: 28px; bottom: 28px; display: grid; grid-template-columns: repeat(3, 30px); grid-template-rows: 30px 30px; gap: 5px; z-index: 5; }
  .keys button { padding: 0; border: 0; background: #fff; cursor: pointer; width: 30px; height: 30px; border-radius: 7px; box-shadow: inset 0 0 0 1.5px #C9D5EC, 0 2px 0 #C9D5EC; color: #7C8BA8; font: 700 18px/30px system-ui, -apple-system, sans-serif; text-align: center; transition: background .15s, color .15s; }
  .keys [data-k=ArrowUp] { grid-area: 1 / 2; } .keys [data-k=ArrowLeft] { grid-area: 2 / 1; } .keys [data-k=ArrowDown] { grid-area: 2 / 2; } .keys [data-k=ArrowRight] { grid-area: 2 / 3; }
  .keys button:hover { color: var(--blue); box-shadow: inset 0 0 0 1.5px var(--blue), 0 2px 0 var(--blue); }
  .keys button.hit { background: var(--blue); color: #fff; box-shadow: none; }

  /* Scroll cue: a mouse with a rolling wheel. */
  .hint { position: absolute; left: 6vw; bottom: 28px; color: var(--muted); font-size: 13px; transition: opacity .3s; display: flex; align-items: center; gap: 10px; }
  .mouse { width: 20px; height: 30px; border-radius: 11px; box-shadow: inset 0 0 0 2px var(--muted); position: relative; }
  .mouse::after { content: ''; position: absolute; left: 50%; top: 6px; width: 4px; height: 6px; margin-left: -2px; border-radius: 2px; background: var(--blue); animation: wheel 1.6s ease-in-out infinite; }

  /* Pops: short lines that burst out and vanish, like the marks round a surprised cartoon face. */
  #pops { position: fixed; left: 0; top: 0; width: 100%; height: 100%; z-index: 4; pointer-events: none; }
  #pops line { stroke: var(--blue); stroke-width: 3; stroke-linecap: round; }
}
@media (min-width: 761px) and (prefers-reduced-motion: no-preference) { .avatar { animation: breathe 3.6s ease-in-out infinite; } }
@keyframes breathe { 50% { transform: scaleY(1.008); } }
@keyframes drop { from { opacity: 1; transform: translateY(-110vh) rotate(var(--r0)); } to { opacity: 1; transform: translateY(0) rotate(var(--r)); } }
@keyframes settle { from { opacity: 1; transform: translateY(0) rotate(var(--r)); } 40% { transform: translateY(-14px) rotate(var(--r)); } to { opacity: 1; transform: translateY(0) rotate(var(--r)); } }
@keyframes wheel { 0% { transform: translateY(0); opacity: 0; } 20% { opacity: 1; } 70% { transform: translateY(10px); opacity: 0; } 100% { opacity: 0; } }

/* Narrow: normal scrolling, one stage per chapter, and a blue thread that draws with the scroll. */
@media (max-width: 760px) {
  .rig, #pops, .dots, .keys, .me, .hint, #peek-wide { display: none; }
  .eyebrow { font-size: 12px; }
  h1, h2 { margin: 10px 0 12px; line-height: 1.04; }
  /* The name stays on one line: it is 9.7 times its font size wide, so the size follows the screen width. */
  h1 { font-size: min(38px, calc((100vw - 44px) / 9.7)); white-space: nowrap; } h2 { font-size: 32px; }
  p { font-size: 17px; margin: 0 0 20px; }
  .btn { min-height: 48px; padding: 0 22px; font-size: 16px; }
  .copy { padding: 0 20px; }
  #hi .copy { text-align: center; }
  .more { margin: 20px 0 0; }

  /* Cards scroll sideways so a chapter stays one screen tall. */
  .cards { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -20px; padding: 0 20px 4px; scrollbar-width: none; }
  .cards::-webkit-scrollbar { display: none; }
  .card { flex: 0 0 78%; scroll-snap-align: start; min-height: 112px; }
  .card i { margin-top: auto; padding-top: 6px; }
  .links { margin-top: 18px; gap: 22px; }
  .links.site { margin-top: 40px; }
  .links a { min-height: 44px; display: inline-flex; align-items: center; }

  /* Every chapter is at least one screen tall, with a wide gap below it. */
  body { position: relative; }
  .ch { position: relative; z-index: 1; min-height: 100vh; min-height: 100lvh; padding: 0 0 18svh; }
  .ch .copy { transition: opacity .5s ease, transform .5s cubic-bezier(.2,.9,.3,1); }
  .js .ch .copy { opacity: 0; transform: translateY(12px); }
  .js .ch .copy.in { opacity: 1; transform: none; }

  /* The avatar stage: soft glow, floor shadow, and the canvas. An avatar shows only while the thread has closed its ring. */
  .stage { position: relative; overflow: hidden; height: min(52svh, 440px); margin-bottom: 8px; }
  .stage .glow { position: absolute; left: 50%; top: 52%; width: 120%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; background: radial-gradient(circle, rgba(37,99,235,.16), rgba(37,99,235,0) 62%); }
  .stage .shadow { position: absolute; left: 50%; bottom: 3%; width: 46%; height: 5%; transform: translateX(-50%); border-radius: 50%; background: radial-gradient(closest-side, rgba(11,18,32,.2), rgba(11,18,32,0)); }
  .stage canvas { position: absolute; left: 50%; bottom: 4%; height: 92%; transform: translateX(-50%); }
  .stage canvas.wide { height: 84%; }
  .stage canvas, .stage .shadow { opacity: 0; transition: opacity .25s ease; }
  .stage.on canvas, .stage.on .shadow { opacity: 1; }
  #hello { padding-bottom: 40px; min-height: calc(100svh - 64px); } /* the last stage and its links fit on one screen under the header */
  #hello .stage { height: min(38svh, 360px); }
  /* The picture's cut edge sits on the screen's right edge (13% of it is empty space past the edge). The cut at its foot fades out. */
  #peek-narrow { position: absolute; right: 0; bottom: 0; height: 100%; transform: translateX(100%) scaleX(-1); transition: transform .7s cubic-bezier(.2,.9,.25,1.15);
                 -webkit-mask-image: linear-gradient(#000 78%, transparent); mask-image: linear-gradient(#000 78%, transparent); }
  #peek-narrow.in { transform: translateX(13%) scaleX(-1); }
  #peek-narrow img { height: 100%; display: block; }

  /* Header: from the second chapter on, it names the chapter you are in and fills a line as you read. */
  .bar { position: fixed; top: 0; left: 0; right: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: calc(env(safe-area-inset-top) + 10px) 20px 10px; background: var(--bg);
         transform: translateY(-100%); transition: transform .35s cubic-bezier(.2,.9,.3,1); }
  .bar.in { transform: none; }
  .bar button { width: 44px; height: 44px; padding: 0; border: 0; background: none; display: grid; place-items: center; cursor: pointer; }
  .bar img { width: 32px; height: 32px; border-radius: 50%; box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--blue); }
  .bar .eyebrow { transition: opacity .2s; }
  .bar .line { position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; background: var(--blue); transform-origin: 0 50%; transform: scaleX(0); }

  /* The thread lies under the chapters, so text, cards and avatars pass over it. */
  #thread { position: absolute; left: 0; top: 0; z-index: 0; pointer-events: none; }
  #thread path, #thread line { fill: none; stroke: var(--blue); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
  #thread #track { stroke: #DDE7FB; stroke-width: 2; }
  #thread line { stroke-width: 2.5; }
  #thread #glint { stroke: #DCE8FF; opacity: 0; }
  #tip { fill: var(--blue); transition: opacity .2s; }
  #tip .halo { transform-box: fill-box; transform-origin: center; animation: halo 1.8s ease-out infinite; }
  #tip.end .halo { animation: none; opacity: 0; }
}
@media (max-width: 760px) and (prefers-reduced-motion: reduce) {
  .js .ch .copy { opacity: 1; transform: none; }
  #tip .halo { animation: none; opacity: 0; }
}
@keyframes halo { from { transform: scale(1); opacity: .35; } to { transform: scale(2.8); opacity: 0; } }
