/* MazeFeel: paper and ink, as in the game. */

:root {
  --ground: #fafaf9;
  --ink: #141414;
  --soft: rgba(20, 20, 20, 0.56);
  --faint: rgba(20, 20, 20, 0.1);
  --wall: rgba(20, 20, 20, 0.22);
  --column: 1080px;
  color-scheme: light;
}

/* Dark when chosen with the switch in the bar (site.js); light otherwise. */
:root[data-theme="dark"] {
  --ground: #0f0f0f;
  --ink: #f2f2f0;
  --soft: rgba(242, 242, 240, 0.6);
  --faint: rgba(242, 242, 240, 0.12);
  --wall: rgba(242, 242, 240, 0.28);
  color-scheme: dark;
}

/* The theme switch: a moon in the light, a sun in the dark. */
.theme {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  margin: -6px -6px -6px 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--soft);
  cursor: pointer;
}
.theme:hover { color: var(--ink); background: var(--faint); }
.theme svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.theme .moon { fill: currentColor; stroke: none; }
.theme .sun { display: none; }
:root[data-theme="dark"] .theme .moon { display: none; }
:root[data-theme="dark"] .theme .sun { display: block; }
.bar nav { align-items: center; }

/* The language menu in the footer: plain text with a small arrow. */
.language select {
  appearance: none;
  -webkit-appearance: none;
  field-sizing: content;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  padding-right: 14px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(-45deg, transparent 50%, currentColor 50%);
  background-position: right 4px center, right 0 center;
  background-size: 4px 4px;
  background-repeat: no-repeat;
}
.language select:hover { color: var(--ink); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 17px/1.55 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* Top bar */

/* The bar stays at the top; a hairline shows under it once the page has moved. */
.bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px max(24px, calc((100vw - var(--column)) / 2 + 24px));
  background: color-mix(in srgb, var(--ground) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(18px);
  backdrop-filter: saturate(1.4) blur(18px);
  transition: box-shadow 0.3s ease;
}
.bar.moved { box-shadow: 0 1px 0 var(--faint); }


.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.brand img {
  width: 30px; height: 30px;
  border-radius: 7px;
  box-shadow: 0 0 0 1px var(--faint);
}

.bar nav { display: flex; gap: 22px; font-size: 15px; }
.bar nav a { text-decoration: none; color: var(--soft); }
.bar nav a:not(.store):hover { color: var(--ink); }

/* Type */

h1 {
  margin: 0;
  font-size: clamp(48px, 9vw, 112px);
  line-height: 1.02;
  font-weight: 300;
  letter-spacing: -0.035em;
}

h2 {
  margin: 0 0 14px;
  font-size: clamp(34px, 4.4vw, 54px);
  line-height: 1.05;
  font-weight: 300;
  letter-spacing: -0.03em;
}

.lede {
  margin: 22px auto 34px;
  max-width: 30ch;
  font-size: clamp(18px, 2.2vw, 22px);
  color: var(--soft);
}


/* The maze behind the page: a plane at an angle, shown only around the middle. */

.field {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  perspective: 900px;
  color: var(--wall);
  -webkit-mask-image: radial-gradient(ellipse 55% 50% at 50% 58%, #000 0%, rgba(0, 0, 0, 0.55) 45%, transparent 100%);
  mask-image: radial-gradient(ellipse 55% 50% at 50% 58%, #000 0%, rgba(0, 0, 0, 0.55) 45%, transparent 100%);
}

.plane {
  position: absolute;
  left: 50%; top: 58%;
  width: 170vmax; height: 170vmax;
  transform: translate(-50%, -50%) rotateX(var(--tilt, 62deg)) rotateZ(var(--spin, 20deg));
  will-change: transform;
}

/* The stage: a tall section whose view stays on screen while it scrolls. */

.stage {
  position: relative;
  z-index: 1;
  height: 620vh;
}

.view {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  perspective: 1800px;
}

.intro {
  position: absolute;
  left: 0; right: 0;
  top: 17vh;
  padding: 0 24px;
  text-align: center;
  opacity: var(--intro, 1);
  transform: translateY(var(--intro-y, 0));
  will-change: opacity, transform;
}

.captions {
  position: absolute;
  top: 50%;
  left: max(24px, calc(50% - 520px));
  width: min(400px, 38vw);
  transform: translateY(-50%);
}

.caption {
  position: absolute;
  top: 0; left: 0; right: 0;
  transform: translateY(calc(-50% + var(--shift, 24px)));
  opacity: var(--shown, 0);
  will-change: opacity, transform;
}

.caption p { margin: 0; color: var(--soft); font-size: 19px; }

/* The phone: a graphite body built in CSS 3D, its screen the real game. */

.device {
  --w: min(300px, 64vw);
  --depth: calc(var(--w) * 0.045);
  --radius: calc(var(--w) * 0.16);
  position: absolute;
  left: var(--x, 50%);
  top: 50%;
  width: var(--w);
  aspect-ratio: 1320 / 2868;
  transform: translate(-50%, -50%) translateY(var(--y, 0)) scale(var(--scale, 1));
  transform-style: preserve-3d;
  will-change: transform;
}

.body {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform: rotateX(var(--rx, 0)) rotateY(var(--ry, 0)) rotateZ(var(--rz, 0));
  will-change: transform;
}

.front, .back, .edge {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
}

.edge {
  background: #2c2c2e;
  transform: translateZ(var(--z));
}

.edge.lit { background: #3a3a3c; }

.front {
  padding: calc(var(--w) * 0.032);
  background: #161618;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  transform: translateZ(calc(var(--depth) / 2));
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.screen {
  position: relative;
  width: 100%; height: 100%;
  border-radius: calc(var(--radius) - var(--w) * 0.032);
  overflow: hidden;
  background: #fafaf9;
  transform: translateZ(0);
}

/* Which face is towards you is decided in scene.js from the turn: browsers don't all hide
   a turned-away face with layers inside it. */
.body.away .front, .body:not(.away) .back { visibility: hidden; }

.shot {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
}

.shot.on { opacity: 1; }

.island {
  position: absolute;
  top: 1.9%; left: 50%;
  width: 29%; height: 3.6%;
  transform: translateX(-50%);
  border-radius: 999px;
  background: #050505;
}

/* Light sliding over the glass as the phone turns. */
.glare {
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.55) 50%, transparent 65%);
  background-size: 300% 100%;
  background-position: var(--glare, 50%) 0;
  mix-blend-mode: soft-light;
  opacity: 0.9;
}

.back {
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #2a2a2c, #161618 60%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  transform: rotateY(180deg) translateZ(calc(var(--depth) / 2));
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.back img {
  width: 26%;
  border-radius: 22%;
  opacity: 0.9;
}

/* A soft shadow on the ground under the phone, narrowing as it turns side on. */
.shadow {
  position: absolute;
  left: 10%; right: 10%;
  bottom: -9%;
  height: 7%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.28), transparent);
  transform: translateZ(-80px) scaleX(var(--shadow, 1));
  filter: blur(6px);
}

/* Where the story is: four short marks. */
.steps {
  position: absolute;
  right: max(24px, calc(50% - 520px));
  top: 50%;
  display: grid;
  gap: 10px;
  transform: translateY(-50%);
  opacity: calc(1 - var(--intro, 1));
}

.steps i {
  display: block;
  width: 3px; height: 22px;
  border-radius: 2px;
  background: var(--faint);
  transition: background 0.3s;
}

.steps i.on { background: var(--ink); }

/* After the story */

main, footer { position: relative; z-index: 1; }

.price {
  text-align: center;
  padding: 120px 24px 130px;
}

.price p { margin: 0 auto 34px; max-width: 40ch; color: var(--soft); font-size: 19px; }

.facts {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 40px;
  padding: 0;
  list-style: none;
}

.facts li {
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--ground);
  box-shadow: 0 0 0 1px var(--faint);
  font-size: 15px;
}

/* Words over the maze: a soft halo of the ground behind them. */
.home h1, .home h2, .home .lede, .home .caption p, .home .price p {
  text-shadow: 0 0 20px var(--ground), 0 0 40px var(--ground), 0 0 6px var(--ground);
}

footer {
  max-width: var(--column);
  margin: 0 auto;
  padding: 36px 24px 48px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border-top: 1px solid var(--faint);
  font-size: 14px;
  color: var(--soft);
}

footer nav { display: flex; gap: 20px; }
footer a { text-decoration: none; }
footer a:hover { color: var(--ink); }

/* Text pages: privacy, support */

.page {
  max-width: 680px;
  margin: 0 auto;
  padding: 140px 24px 80px;
}

.page h1 { font-size: clamp(40px, 7vw, 64px); margin-bottom: 12px; }
.page .date { color: var(--soft); margin: 0 0 48px; }
.page h2 { font-size: 26px; letter-spacing: -0.015em; font-weight: 400; margin: 44px 0 10px; }
.page p { margin: 0 0 14px; }
.page p, .page li { color: var(--soft); }
.page strong { color: var(--ink); font-weight: 500; }

.questions { margin: 0; padding: 0; list-style: none; }
.questions li { padding: 26px 0; border-top: 1px solid var(--faint); }
.questions h2 { margin: 0 0 8px; color: var(--ink); }
.questions p { margin: 0; }

/* A narrow screen: the phone above, the words under it. */
@media (max-width: 820px) {
  .intro { top: 13vh; }
  .captions {
    top: auto;
    bottom: 5vh;
    left: 24px; right: 24px;
    width: auto;
    transform: none;
    text-align: center;
  }
  .caption { top: auto; bottom: 0; transform: translateY(var(--shift, 24px)); }
  .caption h2 { font-size: 30px; margin-bottom: 8px; }
  .caption p { font-size: 16px; }
  .device { --w: min(250px, 56vw); }
  .steps { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .store { transition: none; }
}

/* Apple's App Store badge: black on light pages, white on dark. */
.store { display: inline-block; line-height: 0; transition: transform 0.2s ease, opacity 0.2s ease; }
.store:hover { transform: translateY(-1px); }
.store img { height: 54px; width: auto; }
.store.small img { height: 40px; }
.store .dark { display: none; }
:root[data-theme="dark"] .store .light { display: none; }
:root[data-theme="dark"] .store .dark { display: inline; }

/* 404: the ball against a wall, the buzz spreading from it. */
.lost { min-height: 100vh; display: grid; place-content: center; justify-items: center; text-align: center; padding: 120px 24px 80px; }
.lost svg { width: 160px; height: 120px; margin-bottom: 36px; fill: none; stroke: var(--ink); }
.lost .wall { stroke-width: 7; stroke-linecap: round; }
.lost .ball { fill: var(--ink); stroke: none; }
.lost .ring { stroke-width: 1.5; opacity: 0.25; transform-box: fill-box; transform-origin: center; }
.lost h1 { margin: 0 0 12px; font-size: clamp(40px, 7vw, 64px); }
.lost p { margin: 0 0 28px; color: var(--soft); }
.lost .way-back { color: var(--ink); text-underline-offset: 4px; }
@media (prefers-reduced-motion: no-preference) {
  .lost .ring { opacity: 0; animation: ripple 2.4s cubic-bezier(.2, .6, .3, 1) infinite; }
  .lost .ring + .ring { animation-delay: 1.2s; }
  .lost .ball { animation: bump 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
}
@keyframes bump { 0%, 100% { transform: none; } 6% { transform: translateX(3px); } 12% { transform: none; } }
