/* InkLast — /app, the download page. Builds on landing.css (tokens, header, menu, badges, footer).
   Its own scene, distinct from the hero: a phone's home screen drawn in line, the InkLast icon
   downloads, then the app opens. */

.dlp { background: var(--bone); }
.dl { position: relative; overflow: hidden; display: grid; align-items: center; min-height: max(100svh, 720px); padding: 120px 0 64px; }
.dl-in { position: relative; z-index: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .9fr); gap: clamp(32px, 5vw, 96px); align-items: center; }

.dl-kick { display: flex; align-items: center; gap: 12px; font: 500 12px/1 var(--mono); letter-spacing: .2em; text-transform: uppercase; color: var(--graphite); animation: rise .9s var(--ease) .05s both; }
.dl-kick::before { content: ''; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--vermilion); box-shadow: 0 0 0 4px rgba(204, 68, 41, .16); }
.dl h1 { margin-top: 22px; max-width: 12ch; font: 400 clamp(44px, 4.8vw, 78px)/1 var(--serif); letter-spacing: -0.024em; animation: rise 1s var(--ease) .12s both; }
.dl h1 em { font-style: italic; letter-spacing: -0.012em; }
.dl-lead { max-width: 30em; margin-top: 24px; font-size: clamp(17px, 1.3vw, 19px); line-height: 1.5; color: var(--ink2); animation: rise 1s var(--ease) .2s both; }

.dl-get { display: grid; justify-items: start; gap: 22px; margin-top: 36px; animation: rise 1s var(--ease) .3s both; }
.dl-qr { display: flex; align-items: center; gap: 18px; padding: 14px 20px 14px 14px; border-radius: 22px; background: var(--paper); border: 1px solid var(--hairline); box-shadow: 0 24px 40px -32px rgba(21, 20, 19, .5); transition: translate .4s var(--ease), box-shadow .4s var(--ease); }
.dl-qr:hover { translate: 0 -2px; box-shadow: 0 30px 46px -32px rgba(21, 20, 19, .55); }
.dl-qr-box { position: relative; flex: none; display: block; width: 112px; height: 112px; padding: 10px; overflow: hidden; border-radius: 14px; background: #fff; box-shadow: inset 0 0 0 1px var(--hairline); }
.dl-qr-code { display: block; width: 100%; height: 100%; }
.dl-qr p { display: grid; gap: 5px; max-width: 17em; }
.dl-qr b { font: 400 21px/1.1 var(--serif); letter-spacing: -0.01em; color: var(--ink); }
.dl-qr span { font-size: 14.5px; line-height: 1.45; color: var(--graphite); }
/* the code gets « scanned » by a vermilion line */
.dl-scan { position: absolute; left: 6px; right: 6px; top: 0; height: 2px; border-radius: 2px; background: var(--vermilion); box-shadow: 0 0 10px 2px rgba(204, 68, 41, .45); opacity: 0; animation: scan 1.5s cubic-bezier(.45, 0, .2, 1) 1.1s 2 both; }
@keyframes scan { 0% { opacity: 0; translate: 0 6px; } 12% { opacity: 1; } 88% { opacity: 1; } 100% { opacity: 0; translate: 0 104px; } }
.dl-get .badge, .dl-get .badge-apple img { height: 50px; }
.dl-get .badge-google img { height: calc(50px * 250 / 191); margin-top: calc(50px * -30 / 191); }
.dl-get .badge { animation: rise .9s var(--ease) both; }
.dl-get .badge-apple { animation-delay: .5s; }
.dl-get .badge-google { animation-delay: .6s; }
.dl-note { font: 500 12px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--graphite); }

/* ── the scene: a home screen, the icon downloads, the app opens ─────────────────────────── */
.dl-art { display: grid; place-items: center; }
.ins { --pw: clamp(250px, min(23vw, calc((100svh - 220px) / 2.17)), 340px); --rx: 0deg; --ry: 0deg; perspective: 1600px; padding: 20px 0; }
.ins-phone { position: relative; width: var(--pw); aspect-ratio: 400 / 868; font-size: calc(var(--pw) * .045); transform: rotateX(var(--rx)) rotateY(var(--ry)) rotate(-3deg); }
.ins-phone::before { content: ''; position: absolute; inset: 6% 4% -2%; z-index: -1; border-radius: 20%; background: rgba(21, 20, 19, .5); filter: blur(46px); opacity: 0; translate: -6% 8%; transition: opacity 1.4s ease .6s; }
.ins-body { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; }
.ins-body > * { stroke-dasharray: 1 1; stroke-dashoffset: 1; transition: stroke-dashoffset 1.5s cubic-bezier(.55, 0, .2, 1), fill .8s ease .9s; }
.ins-body .out { fill: transparent; }
.ins-body .in { stroke-width: 1.2; stroke: rgba(21, 20, 19, .35); transition-delay: .25s, 0s; }
.ins-body .key { stroke-width: 3; transition-delay: .5s; }
.ins-screen { position: absolute; inset: calc(var(--pw) * .0325); overflow: hidden; border-radius: calc(var(--pw) * .1325); background: linear-gradient(170deg, #F7F4EE, #EFEAE1); opacity: 0; transition: opacity .8s ease; }
.ins-sbar { position: absolute; inset: 0 0 auto 0; z-index: 4; height: 6.2%; display: flex; align-items: center; justify-content: space-between; padding: 0 9% 0 11%; color: var(--ink); transition: color .4s ease; }
.ins-sbar b { font: 600 calc(var(--pw) * .044) / 1 var(--sans); }
.ins-sbar svg { width: calc(var(--pw) * .17); height: calc(var(--pw) * .031); fill: currentColor; }
.ins-sbar i { position: absolute; left: 50%; top: 22%; width: 31%; height: 58%; translate: -50% 0; border-radius: 999px; background: #000; }

/* the icons: rounded squares drawn in line, with a short grey label */
.ins-home { position: absolute; inset: 13% 7% auto; display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.3em .9em; }
.ins-home i, .ins-dock i { display: grid; justify-items: center; gap: .45em; opacity: 0; scale: .6; transition: opacity .4s ease calc(var(--i) * 28ms), scale .6s cubic-bezier(.3, 1.5, .5, 1) calc(var(--i) * 28ms); }
.ins-home b, .ins-dock b { position: relative; display: block; width: 100%; aspect-ratio: 1; border-radius: 24%; border: 1.2px solid rgba(21, 20, 19, .18); background: rgba(255, 255, 255, .45); }
.ins-home u { display: block; width: 62%; height: .32em; border-radius: 1em; background: rgba(21, 20, 19, .1); text-decoration: none; }
.ins-dock { position: absolute; left: 5%; right: 5%; bottom: 3.5%; display: grid; grid-template-columns: repeat(4, 1fr); gap: .9em; padding: .9em; border-radius: 1.6em; background: rgba(255, 255, 255, .4); border: 1px solid rgba(21, 20, 19, .08); }

/* InkLast's icon: greyed while it downloads, the vermilion ring fills, then it comes to life */
.ins-app b { overflow: hidden; border: 0; background: #E2DCD2; box-shadow: inset 0 0 0 1px rgba(21, 20, 19, .14), 0 .5em 1em -.5em rgba(21, 20, 19, .45); }
.ins-app img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: grayscale(1) brightness(1.25) contrast(.6); opacity: .45; transition: filter .6s ease, opacity .6s ease; }
.ins-ring { position: absolute; inset: 14%; width: 72%; height: 72%; rotate: -90deg; fill: none; stroke: var(--vermilion); stroke-width: 3.2; stroke-linecap: round; opacity: 0; transition: opacity .3s ease; }
.ins-ring circle { stroke-dasharray: 107 107; stroke-dashoffset: 107; transition: stroke-dashoffset 1.9s cubic-bezier(.45, .05, .35, 1); }
.ins-app u { width: auto; height: auto; background: none; display: grid; justify-items: center; }
.ins-app u span { grid-area: 1 / 1; font: 500 .62em/1 var(--sans); color: var(--ink2); white-space: nowrap; transition: opacity .3s ease; }
.ins-name { opacity: 0; }

/* the tap, then the app opens from its icon */
.ins-tap { position: absolute; z-index: 3; width: 3.2em; height: 3.2em; margin: -1.6em 0 0 -1.6em; left: var(--ax, 50%); top: var(--ay, 40%); border-radius: 50%; background: rgba(21, 20, 19, .18); opacity: 0; scale: .3; pointer-events: none; }
.ins-open { position: absolute; inset: 0; z-index: 2; background: var(--bone); color: var(--ink); clip-path: circle(0 at var(--ax, 50%) var(--ay, 40%)); transition: clip-path .9s var(--push); }
.ins-mark { position: relative; width: 4.6em; aspect-ratio: 159 / 240; }
.ins-mark::before, .ins-mark::after { content: ''; position: absolute; inset: 0; }
.ins-mark::before { background: var(--ink); -webkit-mask: url(/mark-serpent.png) center / contain no-repeat; mask: url(/mark-serpent.png) center / contain no-repeat; clip-path: inset(100% 0 0 0); transition: clip-path 1.3s var(--push) .35s; }
.ins-mark::after { background: var(--vermilion); -webkit-mask: url(/mark-dot.png) center / contain no-repeat; mask: url(/mark-dot.png) center / contain no-repeat; transform-origin: 80% 14%; scale: 0; transition: scale .6s cubic-bezier(.3, 1.6, .5, 1) 1.4s; }
.ins-word { font: 400 2.5em/1 var(--serif); letter-spacing: -0.01em; opacity: 0; translate: 0 .3em; transition: opacity .7s ease 1.2s, translate .9s var(--ease) 1.2s; }
.ins-tag { font: 500 .62em/1 var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--moon2); opacity: 0; transition: opacity .7s ease 1.6s; }

/* timeline, set by app.js on .ins */
.ins.i1 .ins-body > * { stroke-dashoffset: 0; }
.ins.i1 .ins-body .out { fill: var(--paper); }
.ins.i1 .ins-phone::before { opacity: .5; }
.ins.i2 .ins-screen { opacity: 1; }
.ins.i2 .ins-home i, .ins.i2 .ins-dock i { opacity: 1; scale: 1; }
.ins.i3 .ins-ring { opacity: 1; }
.ins.i3 .ins-ring circle { stroke-dashoffset: 0; }
.ins.i4 .ins-ring { opacity: 0; }
.ins.i4 .ins-app img { filter: none; opacity: 1; }
.ins.i4 .ins-wait { opacity: 0; }
.ins.i4 .ins-name { opacity: 1; }
.ins.i4 .ins-app b { animation: pop .5s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop { 40% { scale: 1.12; } }
@keyframes tap { 0% { opacity: 0; scale: .3; } 40% { opacity: 1; scale: 1; } 100% { opacity: 0; scale: 1.5; } }
.ins.i6 .ins-open { clip-path: circle(150% at var(--ax, 50%) var(--ay, 40%)); }
.ins.i6 .ins-mark::before { clip-path: inset(0 0 0 0); }
.ins.i6 .ins-mark::after { scale: 1; }
.ins.i6 .ins-word { opacity: 1; translate: 0 0; }
.ins.i6 .ins-tag { opacity: 1; }

/* on a phone: no code to scan, the store of that phone first and larger */
html.is-phone .dl-qr { display: none; }
html.is-phone .dl-get .stores { flex-wrap: nowrap; gap: 12px; }
html.is-android .dl-get .badge-google { order: -1; }
/* both badges side by side on one line, even on the narrowest phones */
@media (max-width: 380px) {
  .dl-get .stores { gap: 10px; }
  .dl-get .badge, .dl-get .badge-apple img { height: 44px; }
  .dl-get .badge-google img { height: calc(44px * 250 / 191); margin-top: calc(44px * -30 / 191); }
}

@media (max-width: 900px) {
  .dl { min-height: 0; padding: 112px 0 48px; }
  .dl-in { grid-template-columns: minmax(0, 1fr); gap: 40px; }
  .ins { --pw: clamp(220px, 60vw, 290px); }
}
/* phone and tablet in portrait: the top of the phone comes right under the title and fades out,
   so the scene, the text and the badges all fit on the first screen */
@media (max-width: 900px) {
  .dl { padding-top: 88px; }
  .dl-in { gap: 0; }
  .dl h1 { margin-top: 16px; }
  .dl-copy { display: contents; }
  .dl-kick { order: 0; }
  .dl h1 { order: 1; }
  .dl-art { order: 2; height: clamp(220px, calc(100svh - 526px), 340px); margin: 10px -16px 0; overflow: hidden; place-items: start center; -webkit-mask: linear-gradient(#000 66%, transparent); mask: linear-gradient(#000 66%, transparent); }
  .ins { --pw: clamp(220px, 64vw, 280px); padding-top: 12px; }
  .dl-lead { order: 3; margin-top: 2px; }
  .dl-get { order: 4; }
}
@media (max-width: 560px) {
  .dl h1 { font-size: clamp(38px, 10.6vw, 50px); }
  .dl-lead { font-size: 16.5px; }
  .dl-qr { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .dl-scan { display: none; }
}

/* the app opens on paper, like the app itself */
.ins-splash { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: .9em; transition: opacity .5s ease; }
.ins-tag { color: var(--graphite); }
.ins.a1 .ins-splash { opacity: 0; }

/* a short walk through the app: home, the design, the dates, the day before */
.ins .scr { z-index: 1; translate: 101% 0; transition: translate .75s var(--push), filter .75s var(--push), opacity .5s ease; box-shadow: -1.4em 0 3em -1.6em rgba(0, 0, 0, .35); }
.ins .scr.sa { translate: 0 0; opacity: 0; box-shadow: none; }
.ins .scr.on { translate: 0 0; opacity: 1; filter: none; }
.ins .scr.past { translate: -30% 0; filter: brightness(.8); }
.ins .scr.sa.past { opacity: 1; }
/* a tap lands on what gets pressed; the pressed button says it is done */
.ins-tap { z-index: 6; left: var(--tx, 50%); top: var(--ty, 40%); }
.ins.tapping .ins-tap { animation: tap .55s ease-out forwards; }
.ins .ui-btn { transition: background-color .35s ease, color .35s ease, scale .2s ease; }
.ins .ui-btn.done { background: var(--sage); color: #fff; }
.ins .ui-btn.pressed { scale: .96; }

/* to draw the eye: a warm halo breathing behind the phone, and now and then a light sweeping the glass */
.ins { position: relative; isolation: isolate; }
.ins-halo { position: absolute; z-index: -1; left: 50%; top: 50%; width: calc(var(--pw) * 1.9); aspect-ratio: 1; translate: -50% -50%; border-radius: 50%; background: radial-gradient(circle, rgba(204, 68, 41, .34) 0%, rgba(228, 160, 112, .24) 30%, rgba(236, 228, 216, 0) 66%); filter: blur(30px); opacity: 0; transition: opacity 1.6s ease; }
.ins.i1 .ins-halo { opacity: 1; animation: breathe 6.5s ease-in-out 1.6s infinite; }
@keyframes breathe { 0%, 100% { scale: .9; opacity: .75; } 50% { scale: 1.06; opacity: 1; } }
/* a vermilion glint runs along the phone's outline, then rests */
.ins .ins-body .glint { stroke: var(--vermilion); stroke-width: 3.2; stroke-dasharray: .07 .93; stroke-dashoffset: 0; opacity: 0; filter: drop-shadow(0 0 5px rgba(204, 68, 41, .75)); transition: none; }
.ins.i2 .ins-body .glint { animation: glint 7s cubic-bezier(.45, .05, .4, 1) .6s infinite; }
@keyframes glint { 0% { stroke-dashoffset: 0; opacity: 0; } 6% { opacity: 1; } 58% { opacity: 1; } 64%, 100% { stroke-dashoffset: -1; opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .ins .ins-halo { opacity: 1; animation: none; }
  .ins .ins-body .glint { display: none; }
}
