:root {
  --paper: #f3f3f1;
  --plate: #e4e4e1;
  --plate-2: #dcdcd8;
  --ink: #161616;
  --muted: #858580;
  --rule: #cfcfcb;
  /* translucent, so a button's outline darkens with whatever is under it (the phone's shadow) */
  --outline: rgba(22, 22, 22, 0.13);
  --skin: #f6f4f0;
  --skin-shade: #dedbd5;
  --sleeve: #161616;
  --phone: #0c0c0d;
  --serif: "New York", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans: "Helvetica Neue", -apple-system, BlinkMacSystemFont, "Segoe UI",
          "Apple SD Gothic Neo", "Hiragino Sans", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #111111;
    --plate: #1b1b1b;
    --plate-2: #222221;
    --ink: #ecebe7;
    --muted: #7d7d79;
    --rule: #333331;
    --outline: rgba(255, 255, 255, 0.13);
    --skin: #d9d6d0;
    --skin-shade: #b9b5ae;
    --sleeve: #050505;
  }
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  height: 100%;
  overflow: hidden;
}

/* The pages scroll inside this fixed box, not the window. On iPhone Safari a
 * scrolling window collapses the address bar, the screen's height changes
 * mid-scroll and the snap points drift; a fixed scroller keeps the bar still
 * and every page exactly one screen tall. */
.scroller {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  scroll-snap-type: y mandatory;
}

body {
  height: 100%;
  overflow: hidden;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 13px/1.6 var(--sans);
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* Fixed top line over every page */

.top {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  padding: 1.6rem 2rem;
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  pointer-events: none;
  color: #fff;
  mix-blend-mode: difference;
}

.top a { pointer-events: auto; }
.mark { font-weight: 600; }
.top a:not(.mark) { opacity: 0.6; }
.top a:hover { opacity: 1; }

/* One page = one screen */

.page {
  position: relative;
  height: 100%;
  min-height: 560px;
  overflow: hidden;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  background: var(--plate);
}

.work:nth-of-type(odd) { background: var(--plate-2); }

/* Vertical running text in the margins */

.run {
  position: absolute;
  z-index: 2;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--muted);
  writing-mode: vertical-rl;
  white-space: nowrap;
}

.run-left { left: 1.1rem; bottom: 2.2rem; transform: rotate(180deg); }
.run-right { right: 1.1rem; top: 5rem; }

/* Page 01: title */

.cover {
  display: grid;
  place-items: center;
  background: #0a0a0a;
  color: #f2f1ed;
}

.cover .motto { color: #a3a29b; }
.cover .run, .cover .next { color: #77766f; }

.cover-title { text-align: center; padding: 0 1rem; }

.cover h1 {
  margin: 0;
  font-family: var(--sans);
  font-weight: 500;
  font-size: clamp(2.4rem, 7vw, 5.6rem);
  letter-spacing: -0.035em;
  line-height: 1;
}

.motto {
  margin: 1.2rem 0 0;
  font-family: var(--sans);
  font-weight: 400;
  font-size: clamp(13px, 1.4vw, 16px);
  letter-spacing: 0.01em;
  color: var(--muted);
}

.next {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  z-index: 3;
  color: var(--muted);
  animation: nudge 2.4s ease-in-out infinite;
}

@keyframes nudge {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, 6px); }
}

@media (prefers-reduced-motion: reduce) {
  .next { animation: none; }
  html { scroll-behavior: auto; }
}

/* Pages 02 and 03: a hand holding the app, the arm leaving the bottom edge */

.work {
  display: grid;
  grid-template-columns: 1fr minmax(0, auto) 1fr;
  align-items: center;
}

.held, .caption, .cover-title { will-change: transform; }

.held {
  grid-column: 2;
  grid-row: 1;
  display: block;
  align-self: center;
  height: 143vh;
  width: 108.1vh; /* stated, not derived: Safari sizes an inline svg's auto width differently */
  /* the drawing has room for the shadow; the layout only counts the phone */
  margin: -37.5vh -37.8vh;
  max-width: none;
  pointer-events: none; /* the shadow's room overlaps the words; let clicks through to the links */
}

.skin { fill: var(--skin); }
.skin-shade { fill: var(--skin-shade); }
.sleeve { fill: var(--sleeve); }
.phone { fill: var(--phone); }
.finger, .thumb { stroke: var(--skin-shade); stroke-width: 1.2; }

.caption {
  position: relative;
  z-index: 2;
  grid-column: 1;
  grid-row: 1;
  align-self: center;
  justify-self: end;
  max-width: 19rem;
  margin-right: 3rem;
  padding-left: 3rem;
}

#tackpic .caption { grid-column: 3; justify-self: start; margin: 0 0 0 3rem; padding: 0 3rem 0 0; }

.caption h2 {
  margin: 0 0 1rem;
  font-family: var(--sans);
  font-weight: 500;
  font-size: clamp(2rem, 3.4vw, 3rem);
  letter-spacing: -0.035em;
  line-height: 1;
}

.caption .meta {
  margin: 0 0 0.9rem;
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
}

.caption p { margin: 0 0 1.4rem; }

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0 0 0.6rem !important;
}

.links a {
  border: 1px solid var(--outline);
  padding: 0.24rem 0.6rem;
  border-radius: 6px;
  font-size: 8.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.links a:hover { border-color: var(--ink); }

.links.langs { gap: 0.1rem 0.6rem; }

.links.langs a {
  border: none;
  padding: 0;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--muted);
}

.links.langs a:hover { color: var(--ink); }

/* Index and footer after the three pages */

.index {
  max-width: 44rem;
  margin: 0 auto;
  padding: 7rem 1.5rem 3rem;
  scroll-snap-align: end;
}

.index h2 {
  margin: 0 0 2.2rem;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  text-align: center;
}

.index ol {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--rule);
}

.index li { border-bottom: 1px solid var(--rule); }

.index li > a, .index li.soon {
  display: grid;
  grid-template-columns: 4.5rem 1fr 5.5rem 3.5rem;
  padding: 0.95rem 0.25rem;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.index li > a:hover { color: var(--muted); }
.index li.soon { color: var(--muted); }
.index .year { text-align: right; }

.foot {
  display: flex;
  justify-content: space-between;
  margin: 6rem 0 0;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.foot a:hover { color: var(--ink); }

/* Phone: caption on top, hand underneath */

@media (max-width: 760px) {
  .top { padding: 1.2rem 1rem; }
  .run { display: none; }
  .motto { font-size: 11px; margin-top: 0.55rem; }
  .next { bottom: 0.9rem; }
  .work {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    justify-items: center;
  }
  .caption, #tackpic .caption {
    grid-column: 1;
    grid-row: 1;
    justify-self: stretch;
    align-self: start;
    max-width: none;
    margin: 0;
    padding: 4.6rem 1.25rem 0;
  }
  .caption h2 { font-size: 2rem; margin-bottom: 0.5rem; }
  .caption p { margin-bottom: 0.8rem; }
  .caption, #tackpic .caption { text-align: center; }
  .caption .links { justify-content: center; }
  .caption p:not(.meta):not(.links) { font-size: 14px; max-width: 40ch; margin-left: auto; margin-right: auto; text-wrap: balance; }
  .links.langs { display: none; }
  .held {
    grid-column: 1;
    grid-row: 2;
    align-self: center;
    height: auto;
    width: auto;
    /* phone height: as tall as the width allows, but never so tall that it
       runs into the arrow on a short screen (Safari's bars take height) */
    --ph: min(126vw, calc(100svh - 19.5rem));
    height: calc(var(--ph) * 2.1026);
    width: calc(var(--ph) * 1.5897);
    max-width: none;
    max-height: none;
    margin: calc(var(--ph) * -0.5513) calc(var(--ph) * -0.5641);
    translate: 0 -1.2rem; /* a little higher than centre; separate from the parallax transform */
  }
  .index { padding: 4.5rem 1rem 2.5rem; }
  .index li > a, .index li.soon {
    grid-template-columns: 3rem 1fr 4.2rem 2.8rem;
    font-size: 11px;
    letter-spacing: 0.1em;
  }
}

/* Parallax driven by the scroll itself, not by script: the browser moves these
 * layers on the same thread as the finger, so it cannot lag or shake. Same
 * amounts as the script fallback: the phone drifts 22vh, the words 8vh the
 * other way and fade, the title sinks and fades as the cover leaves. */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    /* each page publishes its own position; its phone and words follow the
       page, not themselves */
    .work { view-timeline: --page block; }
    .cover { view-timeline: --cover block; }
    .work .held {
      animation: phone-drift linear both;
      animation-timeline: --page;
      animation-range: cover 0% cover 100%;
    }
    .work .caption {
      animation: words-drift linear both;
      animation-timeline: --page;
      animation-range: cover 0% cover 100%;
    }
    .cover-title {
      animation: title-sink linear both;
      animation-timeline: --cover;
      animation-range: exit 0% exit 100%;
    }
  }
}

@keyframes phone-drift {
  from { transform: translate3d(0, 22vh, 0); }
  50%  { transform: none; }
  to   { transform: translate3d(0, -22vh, 0); }
}

@keyframes words-drift {
  0%   { transform: translate3d(0, -8vh, 0); opacity: 0; }
  25%  { transform: translate3d(0, -4vh, 0); opacity: 0.45; }
  50%  { transform: none; opacity: 1; }
  75%  { transform: translate3d(0, 4vh, 0); opacity: 0.45; }
  100% { transform: translate3d(0, 8vh, 0); opacity: 0; }
}

@keyframes title-sink {
  from { transform: none; opacity: 1; }
  80%  { opacity: 0; }
  to   { transform: translate3d(0, 45vh, 0); opacity: 0; }
}
