@font-face {
  font-family: "Bricolage Grotesque";
  src: url("fonts/BricolageGrotesque-latin.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* --bg, --floor and --ink follow the octopus's colour and the hour, and are set again from script.
   These are the same values, so nothing changes colour when the octopus takes over. */
:root { --bg: #0c5df0; --floor: #0849c2; --ink: #fff; --pad: 22px; }
:root[data-daypart="evening"] { --bg: #0b3b9f; --floor: #092c7e; }
:root[data-daypart="night"] { --bg: #041230; --floor: #063388; }

html { background: var(--floor); -webkit-text-size-adjust: 100%; }

body {
  font-family: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- the scene: the app's main screen, held in place while the page scrolls ---------- */

/* One stop of the track for each stop of the story; the scene sticks for all of them. */
:root { --stop: 80vh; }
@supports (height: 1svh) { :root { --stop: 80svh; } }
#track { height: calc(5 * var(--stop) + 100vh); }
@supports (height: 1svh) { #track { height: calc(5 * var(--stop) + 100svh); } }

.scene {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  min-height: 540px;
  overflow: hidden;
  background: var(--bg);
  user-select: none;
  -webkit-user-select: none;
}

/* A finger on the octopus still scrolls the page; only taps reach it. */
#scene { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: pan-y; }

#bar {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 14px);
  left: 0;
  right: 0;
  margin: 0 auto;
  padding: 0 var(--pad);
  max-width: 474px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mark { font-size: 21px; font-weight: 800; letter-spacing: -0.01em; }

.pill {
  height: 36px;
  padding: 0 15px;
  border-radius: 18px;
  background: #fff;
  color: #000;
  box-shadow: 0 4px 0 var(--floor);
  font-size: 15px;
  font-weight: 700;
  transition: transform 110ms, box-shadow 110ms, opacity 240ms;
}

.pill:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--floor); }
.scene[data-phase="signup"] .pill, .scene[data-listed] .pill { opacity: 0; pointer-events: none; }

/* How big the octopus stands, by the same sum the script uses, so its still picture sits exactly under it. */
:root { --R: min(28.5vw, 16.5vh); }
@supports (height: 1svh) { :root { --R: min(28.5vw, 16.5svh); } }
#poster { position: absolute; left: calc(50% - 2.4 * var(--R)); top: calc(51% - 2.2 * var(--R)); width: calc(4.8 * var(--R)); height: auto; pointer-events: none; }

/* The phone the app runs in. On a phone that is the whole screen; on a wide window it gets an outline. */
#phone { position: absolute; inset: 0; pointer-events: none; }

#say {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 76px);
  left: 0;
  right: 0;
  margin: 0 auto;
  padding: 0 var(--pad);
  max-width: 474px;
  text-align: center;
  pointer-events: none;
}

#line {
  min-height: 1.2em;
  font-size: clamp(24px, 7vw, 30px);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

#line.long { font-size: clamp(20px, 5.9vw, 24px); }

.ghost { visibility: hidden; }

#bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 38px);
  margin: 0 auto;
  padding: 0 var(--pad);
  max-width: 474px;
  pointer-events: auto;
}

.group {
  position: absolute;
  left: var(--pad);
  right: var(--pad);
  bottom: 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 240ms, transform 240ms, visibility 0s 240ms;
}

.scene[data-phase="asking"] #answers,
.scene[data-phase="device"] #device,
.scene[data-phase="signup"] #signup,
.scene[data-phase="done"] #done {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition-delay: 0s;
}

#answers, #device { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Solid objects with a thickness you press down. */
.slab {
  height: 88px;
  border-radius: 28px;
  background: #fff;
  color: #000;
  box-shadow: 0 10px 0 var(--floor);
  font-size: 27px;
  font-weight: 800;
  transition: transform 110ms, box-shadow 110ms;
}

.slab.dark { background: #000; color: #fff; }
.slab:active { transform: translateY(8px); box-shadow: 0 2px 0 var(--floor); }
.slab:disabled { opacity: 0.6; }

/* Above the email box when it needs a click, and taking no room when it does not. */
#check { display: flex; justify-content: center; }
#check:not(:empty) { margin-bottom: 14px; }

#signup .row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }

#email {
  min-width: 0;
  height: 62px;
  padding: 0 18px;
  border: 0;
  border-radius: 22px;
  background: #fff;
  color: #000;
  box-shadow: 0 8px 0 var(--floor);
  font-size: 18px;
  font-weight: 600;
  user-select: text;
  -webkit-user-select: text;
}

#email::placeholder { color: #8a8a8a; }
#send { height: 62px; padding: 0 20px; border-radius: 22px; box-shadow: 0 8px 0 var(--floor); font-size: 20px; white-space: nowrap; }
#send:active { transform: translateY(6px); box-shadow: 0 2px 0 var(--floor); }

#signup.bad .row { animation: nope 320ms; }
@keyframes nope { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }

.fine { margin-top: 20px; text-align: center; text-wrap: balance; font-size: 14px; font-weight: 600; opacity: 0.85; }
.fine.big { font-size: 17px; font-weight: 700; opacity: 1; }

.quiet {
  display: block;
  margin: 2px auto -10px;
  padding: 10px 14px;
  font-size: 15px;
  font-weight: 600;
  opacity: 0.85;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
}

/* ---------- the words that go with each stop ---------- */

#captions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 34px);
  height: 0;
  margin: 0 auto;
  max-width: 474px;
  pointer-events: none;
}

.caption {
  position: absolute;
  left: var(--pad);
  right: var(--pad);
  bottom: 0;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 320ms, transform 320ms, visibility 0s 320ms;
}

.caption.on { opacity: 1; visibility: visible; transform: none; transition-delay: 120ms, 120ms, 0s; }
.when { font-size: 12px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.8; }
.caption h2 { margin-top: 6px; font-size: 21px; line-height: 1.15; text-wrap: balance; }
.caption h2 + p { margin-top: 7px; font-size: 15px; font-weight: 500; line-height: 1.35; text-wrap: balance; opacity: 0.92; }

/* Which stop you are at, and that there is more below. */
#dots { position: absolute; right: 7px; top: 50%; display: grid; gap: 9px; list-style: none; transform: translateY(-50%); pointer-events: none; }
#dots li { width: 6px; height: 6px; border-radius: 50%; background: var(--ink); opacity: 0.32; transition: opacity 240ms, transform 240ms; }
#dots li.on { opacity: 1; transform: scale(1.5); }
#hint { position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 3px); margin-left: -12px; opacity: 0.8; pointer-events: none; transition: opacity 240ms; animation: bob 1.8s ease-in-out infinite; }
.scene:not([data-station="0"]) #hint { opacity: 0; }
@keyframes bob { 50% { transform: translateY(5px); } }

/* On a phone the first and last stops need the bottom of the screen for the buttons and the
   email box; what their captions say is repeated in the words under the scene. */
.scene[data-station="0"] .caption, .scene[data-station="5"] .caption { opacity: 0; visibility: hidden; }

/* ---------- a wide window: the app in a phone, the page around it ---------- */

@media (min-width: 1000px) and (min-height: 620px) {
  :root { --ph: min(calc(100vh - 64px), 860px); --pw: calc(var(--ph) * 390 / 844); --R: min(calc(var(--pw) * 0.285), calc(var(--ph) * 0.165)); }

  #phone { inset: auto; left: 50%; top: 50%; width: var(--pw); height: var(--ph); transform: translate(-50%, -50%); }
  /* The outline and the notch are all there is to the phone: inside and outside are one scene. */
  #phone::before { content: ""; position: absolute; inset: -6px; border: 6px solid #0a0a12; border-radius: 58px; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.22); }
  #phone::after { content: ""; position: absolute; top: 12px; left: 50%; width: 92px; height: 26px; margin-left: -46px; border-radius: 13px; background: #0a0a12; }

  #bar { top: 24px; max-width: none; padding: 0 36px; }
  .mark { font-size: 25px; }
  #say { top: 64px; }
  #line { font-size: 27px; }
  #line.long { font-size: 22px; }
  #bottom { bottom: 34px; }
  .slab { height: 80px; }

  #captions { top: 50%; bottom: auto; left: auto; right: calc(50% + var(--pw) / 2 + 64px); width: min(400px, calc(50vw - var(--pw) / 2 - 104px)); max-width: none; margin: 0; }
  .caption { left: 0; right: 0; top: 0; bottom: auto; text-align: left; transform: translateY(calc(-50% + 14px)); }
  .scene[data-station] .caption.on { opacity: 1; visibility: visible; transform: translateY(-50%); }
  .when { font-size: 14px; }
  .caption h2 { margin-top: 12px; font-size: clamp(30px, 3vw, 44px); line-height: 1.05; letter-spacing: -0.02em; }
  .caption h2 + p { margin-top: 16px; font-size: 19px; line-height: 1.45; }

  #dots { right: auto; left: calc(50% + var(--pw) / 2 + 32px); gap: 12px; }
  #dots li { width: 8px; height: 8px; }
}

.nojs { position: absolute; left: var(--pad); right: var(--pad); top: 76%; text-align: center; font-size: 20px; font-weight: 700; }

/* ---------- below the scene: what it is, in words ---------- */

#about { background: var(--floor); }
.wrap { max-width: 640px; margin: 0 auto; padding: 64px var(--pad) calc(env(safe-area-inset-bottom) + 40px); }

h1 { font-size: clamp(30px, 8vw, 40px); font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; text-wrap: balance; }
h2 { margin-top: 36px; font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
h2.questions { margin-top: 56px; font-size: 28px; }
h3 { margin-top: 26px; font-size: 19px; font-weight: 800; }
#about h3 + p { margin-top: 6px; }
#about p, .doc p, .doc li { margin-top: 12px; font-size: 18px; font-weight: 500; line-height: 1.5; }
.lede { font-size: 20px !important; }
.status { margin-top: 44px !important; padding-top: 24px; border-top: 2px solid rgba(255, 255, 255, 0.25); }
.help { font-size: 15px !important; opacity: 0.8; }

footer { margin-top: 44px; display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: 15px; font-weight: 600; }
footer span { margin-left: auto; opacity: 0.7; }
a { color: inherit; text-underline-offset: 3px; }

/* ---------- plain pages ---------- */

.doc { background: var(--floor); }
.doc h1 { font-size: clamp(28px, 7vw, 36px); }
.doc ul { padding-left: 22px; }
.doc .numbers { padding-left: 0; list-style: none; }
.doc .numbers a { white-space: nowrap; }
.doc .warn { margin-top: 24px; padding: 14px 16px; border-radius: 14px; background: #fff; color: #000; }
.doc .back { display: inline-block; margin-bottom: 28px; font-weight: 700; }
.doc .draft { margin: 0 0 28px; padding: 12px 16px; border-radius: 14px; background: #fff; color: #000; font-size: 15px; font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  .group, .slab, .pill, .caption { transition-duration: 1ms; }
  #signup.bad .row, #hint { animation: none; }
}
