/* Wake Back to Red
   Three colours from the app: paper, ink and the dot. At night the page keeps the app's rule:
   black, and red light only. The page takes the colour of the part of the night you are reading. */

:root {
  --paper: #F3F0E8;
  --ink: #151311;
  --red: #FF1F0F;          /* the day dot */
  --light: #FF0000;        /* night light, pure red */

  --serif: ui-serif, "New York", "Iowan Old Style", Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --gutter: 24px;
  --max: 1480px;
  --ease: cubic-bezier(.22, .8, .24, 1);
  --spring: cubic-bezier(.3, 1.4, .55, 1);
  --fade: 1.1s;

  /* Tone. Day by default; the script moves the page between day, night and red. */
  --bg: var(--paper);
  --fg: var(--ink);
  --fg-2: rgba(21, 19, 17, .62);
  --line: rgba(21, 19, 17, .14);
  --dot: var(--red);
  --phone-shadow: 0 2cqw 4cqw rgba(21, 19, 17, .07), 0 16cqw 30cqw -12cqw rgba(21, 19, 17, .42);
  color-scheme: light;
}

html[data-tone="night"],
html:not(.js) .tone[data-tone="night"] {
  --bg: #000;
  --fg: var(--light);
  --fg-2: var(--light);
  --line: rgba(255, 0, 0, .3);
  --dot: var(--light);
  --phone-shadow: 0 0 #0000;
  color-scheme: dark;
}

html[data-tone="red"],
html:not(.js) .tone[data-tone="red"] {
  --bg: var(--light);
  --fg: #000;
  --fg-2: #000;
  --line: rgba(0, 0, 0, .28);
  --dot: #000;
  --phone-shadow: 0 0 #0000;
}

html:not(.js) .tone { background: var(--bg); color: var(--fg); }

@media (min-width: 720px) { :root { --gutter: 40px; } }
@media (min-width: 1100px) { :root { --gutter: 64px; } }

/* Base */

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  transition: background-color var(--fade) var(--ease);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 1.0625rem/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color var(--fade) var(--ease), color var(--fade) var(--ease);
  overflow-x: clip;
}

img { display: block; max-width: 100%; }
a { color: inherit; }
p { margin: 0; }
figure { margin: 0; }

::selection { background: var(--dot); color: var(--bg); }

:focus-visible {
  outline: 2px solid var(--dot);
  outline-offset: 5px;
  border-radius: 6px;
}

.wrap {
  width: 100%;
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

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

/* Type. What the app says is New York; labels are the system sans. */

.display {
  margin: 0;
  font: 400 clamp(2.75rem, min(7.4vw, 11.6svh), 8.25rem)/1.01 var(--serif);
  letter-spacing: -.022em;
  text-wrap: balance;
}

.h2 {
  display: block;
  margin: 0;
  font: 400 clamp(2.125rem, 1.35rem + 2.9vw, 4.5rem)/1.05 var(--serif);
  letter-spacing: -.018em;
  text-wrap: balance;
}

.lede {
  max-width: 32ch;
  font-size: clamp(1.0625rem, 1rem + .28vw, 1.25rem);
  line-height: 1.45;
  color: var(--fg-2);
  text-wrap: pretty;
  transition: color var(--fade) var(--ease);
}

.h2 + .lede { margin-top: clamp(16px, 2.6vh, 28px); }

.muted { color: var(--fg-2); transition: color var(--fade) var(--ease); }

.eyebrow {
  display: flex;
  align-items: center;
  gap: .625rem;
  margin: 0 0 clamp(20px, 3vh, 32px);
  font: 500 .9375rem/1 var(--sans);
  font-variant-numeric: tabular-nums;
  color: var(--fg-2);
  transition: color var(--fade) var(--ease);
}

.dot {
  flex: none;
  width: .5rem;
  height: .5rem;
  border-radius: 50%;
  background: var(--dot);
  transition: background-color var(--fade) var(--ease);
}

.link {
  display: inline-flex;
  align-items: center;
  gap: .4em;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .28em;
  text-decoration-color: var(--line);
  transition: text-decoration-color .3s var(--ease), color var(--fade) var(--ease);
}
.link:hover { text-decoration-color: currentColor; }

/* Header */

.top {
  position: absolute;
  inset: 0 0 auto;
  z-index: 5;
}
.top .wrap {
  display: flex;
  align-items: center;
  height: clamp(72px, 11svh, 96px);
}
.mark {
  display: inline-flex;
  align-items: center;
  gap: .625rem;
  font: 600 .9375rem/1 var(--sans);
  letter-spacing: -.01em;
  text-decoration: none;
  color: var(--fg);
}
.mark .dot { width: .75rem; height: .75rem; }

/* Phone. One frame for every shot, drawn to iPhone Pro Max proportions.
   Shots from the smaller iPhone sit on the bottom edge, the app's own layout, with the
   screen's own colour above them. */

.phone {
  --pw: 340px;
  position: relative;
  width: min(var(--pw), 100%);
  container-type: inline-size;
}

.phone__body {
  position: relative;
  padding: 1.9cqw;
  border-radius: 13.6cqw;
  background: #050505;
  box-shadow:
    0 0 0 .45cqw #2a2a2c,
    0 0 0 .75cqw #0d0d0e,
    var(--phone-shadow);
  transition: box-shadow var(--fade) var(--ease);
}

/* Side buttons */
.phone::before,
.phone::after,
.phone__body::before {
  content: "";
  position: absolute;
  width: .9cqw;
  border-radius: .5cqw;
  background: #1d1d1f;
}
.phone::before { left: -1.35cqw; top: 17%; height: 4.6%; }                        /* action */
.phone__body::before { left: -1.35cqw; top: 25%; height: 7.6%;                   /* volume */
  box-shadow: 0 calc(7.6% + 2.6cqw) 0 #1d1d1f; }
.phone::after { right: -1.35cqw; top: 26%; height: 11%; }                         /* side */

.phone__screen {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1320 / 2868;
  border-radius: 11.7cqw;
  background: var(--screen, #000);
  isolation: isolate;
}

.phone__screen img {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: auto;
}

.phone__island {
  position: absolute;
  z-index: 3;
  top: 2.4cqw;
  left: 50%;
  width: 27.4cqw;
  height: 8.1cqw;
  border-radius: 99px;
  background: #000;
  transform: translateX(-50%);
}

/* Screens that change inside one phone */
.phone__screen [data-screen] {
  opacity: 0;
  transition: opacity .55s var(--ease);
}
.phone__screen [data-screen].is-on { opacity: 1; }
html:not(.js) .phone__screen [data-screen]:first-of-type { opacity: 1; }

/* Reveal */

.js [data-reveal] {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity 1.1s var(--ease) var(--d, 0s),
    transform 1.3s var(--ease) var(--d, 0s);
}
.js [data-reveal].is-in { opacity: 1; transform: none; }

/* 1. Hero: the app's first screen, at the size of a room. Dot high, words low. */

.hero { position: relative; }
.hero .wrap {
  position: relative;
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 100svh;
  padding-block: clamp(96px, 14svh, 140px) clamp(40px, 8svh, 80px);
}

.hero__text {
  grid-row: 2;
  display: grid;
  gap: clamp(20px, 3.4svh, 36px);
  position: relative;
  z-index: 2;
}

.hero__title .line { display: block; }

.check {
  position: absolute;
  top: clamp(112px, 17svh, 176px);
  right: calc(var(--gutter) + 3vw);
  width: clamp(136px, min(27vw, 39svh), 420px);
}

.check__dot {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--dot);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform .8s var(--spring),
    opacity .7s var(--ease),
    background-color var(--fade) var(--ease);
}
.check__dot:active { transform: scale(.97); }
.check.is-away .check__dot { opacity: 0; transform: scale(.9); transition-timing-function: var(--ease); }
.check__dot:focus-visible { outline-offset: 10px; border-radius: 50%; }

.check__say {
  margin-top: clamp(14px, 2.4svh, 24px);
  min-height: 1.5em;
  font: 500 .9375rem/1.4 var(--sans);
  color: var(--fg-2);
  transition: opacity .35s var(--ease), color var(--fade) var(--ease);
}
.check__say.is-swap { opacity: 0; }

.js .check[data-reveal] { transform: scale(.6); transition: opacity .9s var(--ease) var(--d, 0s), transform 1.4s var(--spring) var(--d, 0s); }
.js .check[data-reveal].is-in { transform: none; }

/* 2. Day: the check, in the app */

.day { padding-block: clamp(64px, 12vh, 160px) clamp(96px, 16vh, 200px); }

.day__grid { display: block; }

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
  max-width: 34rem;
}
.step {
  position: relative;
  border-bottom: 1px solid var(--line);
}
.step__btn {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 64px;
  margin: 0;
  padding: 14px 0;
  border: 0;
  background: none;
  text-align: left;
  font: 400 clamp(1.375rem, 1.05rem + 1vw, 2rem)/1.15 var(--serif);
  letter-spacing: -.012em;
  color: var(--fg-2);
  cursor: pointer;
  transition: color .5s var(--ease);
}
.step__btn:hover,
.step__btn[aria-pressed="true"] { color: var(--fg); }
.step__btn::before {
  content: "";
  position: absolute;
  left: -20px;
  top: 50%;
  width: 9px;
  height: 9px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: var(--dot);
  transform: scale(0);
  transition: transform .6s var(--spring);
}
.step__btn[aria-pressed="true"]::before { transform: scale(1); }

.step__bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--dot);
  transform: scaleX(0);
  transform-origin: left;
  pointer-events: none;
}
.step.is-on .step__bar { transform: scaleX(1); }
.steps.is-playing .step.is-on .step__bar { animation: fill var(--step-ms, 3400ms) linear both; }
@keyframes fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.day__device {
  display: flex;
  justify-content: center;
  margin-block: clamp(48px, 7vh, 64px) clamp(36px, 5vh, 48px);
}
.day__device .phone { --pw: min(66vw, 300px); }

/* 3. Night */

.night { padding-block: clamp(96px, 16vh, 200px); }

.split { display: grid; gap: clamp(56px, 8vh, 80px); }
.split__device .phone { --pw: min(80vw, 360px); }

/* 4. Red wake: the page becomes the red room */

.redwake { padding-block: clamp(80px, 12vh, 160px); }
.redwake__grid { display: grid; gap: clamp(48px, 7vh, 72px); }
.redwake__title { margin: 0; font-weight: 400; }
.clock {
  display: block;
  margin: 0 0 clamp(20px, 4vh, 40px) -.05em;
  font: 400 clamp(7.25rem, 3rem + 21vw, 23rem)/.78 var(--serif);
  letter-spacing: -.05em;
  font-variant-numeric: lining-nums tabular-nums;
}
/* The colon is two dots, drawn, so it is round in every font. */
.clock__colon {
  display: inline-block;
  position: relative;
  width: .26em;
  height: .9ex;
  margin-inline: .02em;
}
.clock__colon::before,
.clock__colon::after {
  content: "";
  position: absolute;
  left: 50%;
  width: .088em;
  height: .088em;
  margin-left: -.044em;
  border-radius: 50%;
  background: currentColor;
  animation: blink 2s ease-in-out infinite;
}
.clock__colon::before { top: 0; }
.clock__colon::after { bottom: 0; }
@keyframes blink { 50% { opacity: .25; } }
.redwake__text .lede { margin-top: clamp(16px, 2.6vh, 28px); }
.redwake__device { display: flex; justify-content: flex-end; }
.redwake__device .phone { --pw: min(80vw, 360px); }

/* 5. Asleep: the tone, very quietly */

.asleep {
  display: grid;
  place-items: center;
  min-height: 100svh;
  padding-block: 120px;
  text-align: center;
}
.asleep .h2 { max-width: 17ch; margin-inline: auto; }
.pulse {
  display: block;
  position: relative;
  width: 12px;
  height: 12px;
  margin: 0 auto clamp(56px, 9vh, 96px);
}
.pulse__dot,
.pulse__ring {
  position: absolute;
  border-radius: 50%;
}
.pulse__dot { inset: 0; background: var(--dot); }
.pulse__ring {
  left: 50%;
  top: 50%;
  width: 180px;
  height: 180px;
  margin: -90px 0 0 -90px;
  border: 1px solid var(--dot);
  opacity: 0;
  transform: scale(.067);
  animation: ring 6s var(--ease) infinite;
}
.pulse__ring + .pulse__ring { animation-delay: 3s; }
@keyframes ring {
  0% { opacity: 0; transform: scale(.067); }
  8% { opacity: .55; }
  100% { opacity: 0; transform: scale(1); }
}

/* 6. Morning */

.morning { padding-block: clamp(96px, 16vh, 200px); }
.morning__grid { display: grid; gap: clamp(56px, 8vh, 80px); }
.morning__devices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(16px, 3vw, 40px);
  align-items: start;
}
.morning__devices .phone { --pw: 100%; }
.morning__devices figure:last-child { margin-top: clamp(56px, 14vw, 180px); }
.caption {
  margin-top: 20px;
  max-width: 24ch;
  font: 500 .9375rem/1.4 var(--sans);
  color: var(--fg-2);
  transition: color var(--fade) var(--ease);
}

/* 7. Privacy and credits */

.privacy { padding-block: clamp(32px, 6vh, 64px) clamp(96px, 14vh, 180px); }
.privacy__grid { display: grid; gap: clamp(48px, 8vh, 96px); }
.privacy__lead { display: grid; gap: clamp(20px, 3vh, 28px); align-content: start; }
.privacy__lead .h2 { max-width: 13ch; }

.credits { margin: 0; border-top: 1px solid var(--line); }
.credits > div {
  display: grid;
  gap: 6px;
  padding: 20px 0 22px;
  border-bottom: 1px solid var(--line);
}
.credits dt { font: 500 .8125rem/1.3 var(--sans); color: var(--fg-2); }
.credits dd { margin: 0; font-size: 1rem; line-height: 1.5; text-wrap: pretty; }
.credits a { white-space: nowrap; }

/* 8. End */

.end {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 100svh;
  padding-block: clamp(96px, 16vh, 160px) 36px;
}
.end__lead {
  display: grid;
  place-items: center;
  align-content: center;
  gap: clamp(28px, 4vh, 40px);
  text-align: center;
  padding-bottom: clamp(64px, 10vh, 120px);
}
.end__dot {
  width: clamp(168px, 34vw, 320px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--dot);
  animation: breathe 10s ease-in-out infinite;   /* six breaths a minute, as in the red room */
  transition: background-color var(--fade) var(--ease);
}
@keyframes breathe {
  0%, 100% { transform: scale(.94); }
  50% { transform: scale(1); }
}
.end__name { font: 400 clamp(2rem, 1.5rem + 1.8vw, 3rem)/1.1 var(--serif); letter-spacing: -.015em; }
.end__note { margin-top: 10px; font: 500 .9375rem/1.4 var(--sans); }

.foot {
  display: grid;
  gap: 28px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
  font: 500 .9375rem/1.45 var(--sans);
}
.contacts {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.contacts li { display: grid; gap: 2px; }
.contacts span { font-size: .8125rem; color: var(--fg-2); }
.contacts a, .foot__nav a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .25em;
  text-decoration-color: transparent;
  transition: text-decoration-color .3s var(--ease);
}
.contacts a:hover, .foot__nav a:hover { text-decoration-color: currentColor; }
.foot__nav { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.foot__legal { font-size: .8125rem; color: var(--fg-2); }

/* Larger screens */

@media (min-width: 900px) {
  .grid12 {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: 24px;
  }

  .day__grid { grid-template-rows: 1fr auto auto auto 1fr; }
  .day__eyebrow, .day__title, .steps { grid-column: 1 / 7; }
  .day__eyebrow { grid-row: 2; }
  .day__title { grid-row: 3; }
  .steps { grid-row: 4; margin-top: clamp(36px, 6vh, 64px); }
  .day__device { grid-column: 8 / 13; grid-row: 1 / 6; align-self: center; margin: 0; }
  .day__device .phone { --pw: min(30vw, 400px, 39svh); }

  .split { align-items: end; }
  .split__device { grid-column: 2 / 6; grid-row: 1; }
  .split__device .phone { --pw: min(28vw, 390px, 38svh); }
  .split__text { grid-column: 7 / 13; grid-row: 1; padding-bottom: 10vh; }

  .redwake__grid { align-items: end; }
  .redwake__text { grid-column: 1 / 8; grid-row: 1; padding-bottom: 6vh; }
  .redwake__device { grid-column: 8 / 13; grid-row: 1; justify-content: center; }
  .redwake__device .phone { --pw: min(28vw, 390px, 38svh); }

  .morning__text { grid-column: 1 / 6; align-self: start; position: sticky; top: 22vh; }
  .morning__devices { grid-column: 6 / 13; }
  .morning__devices .phone { --pw: min(100%, 320px, 34svh); }
  .morning__devices figure { display: grid; justify-items: center; }
  .morning__devices figure:last-child { margin-top: 18vh; }
  .morning__devices .caption { width: min(100%, 320px, 34svh); }

  .privacy__lead { grid-column: 1 / 7; }
  .credits { grid-column: 8 / 13; align-self: start; }

  .foot {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 28px 48px;
  }
  .contacts { display: flex; flex-wrap: wrap; gap: 14px 48px; }
  .foot__nav { margin-right: auto; }
  .foot__legal { text-align: right; }
}

@media (max-width: 899.98px) {
  .redwake__device { justify-content: center; }
  .split__device { display: flex; justify-content: center; }
  .split__text { order: -1; }
  .steps { max-width: none; }
}

.drift { width: 100%; display: flex; justify-content: center; }

/* Gentle drift on the phones, where scroll-linked animation exists */

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .drift {
      animation: drift linear both;
      animation-timeline: view();
      animation-range: cover 0% cover 100%;
    }
    @keyframes drift {
      from { transform: translateY(var(--drift, 7%)); }
      to { transform: translateY(calc(var(--drift, 7%) * -1)); }
    }
  }
}

/* Small pages: privacy, support, not found */

.page { min-height: 100svh; display: grid; grid-template-rows: auto 1fr auto; }
.page .top { position: static; }
.doc {
  max-width: 42rem;
  padding-block: clamp(48px, 10vh, 120px) clamp(80px, 14vh, 160px);
}
.doc .h2 { margin-bottom: clamp(16px, 3vh, 28px); }
.doc__date { font: 500 .9375rem/1.4 var(--sans); color: var(--fg-2); }
.doc__intro { margin-top: clamp(28px, 5vh, 48px); font: 400 clamp(1.375rem, 1.1rem + .8vw, 1.75rem)/1.3 var(--serif); letter-spacing: -.01em; text-wrap: pretty; }
.doc h2 {
  margin: clamp(44px, 7vh, 64px) 0 12px;
  font: 400 1.5rem/1.2 var(--serif);
  letter-spacing: -.01em;
}
.doc p, .doc li { line-height: 1.6; color: var(--fg); text-wrap: pretty; }
.doc p + p, .doc ul + p { margin-top: 12px; }
.doc ul + p { margin-top: 18px; }
.doc ul { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.doc li { padding: 14px 0; border-bottom: 1px solid var(--line); }
.doc li strong { display: block; font-weight: 600; }
.doc a { text-decoration-thickness: 1px; text-underline-offset: .22em; }
.doc dl { margin: 0; border-top: 1px solid var(--line); }
.doc dl > div { padding: 18px 0; border-bottom: 1px solid var(--line); }
.doc dt { font: 400 1.25rem/1.3 var(--serif); letter-spacing: -.01em; }
.doc dd { margin: 6px 0 0; line-height: 1.6; color: var(--fg-2); }

.page__foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  padding-block: 28px 36px;
  border-top: 1px solid var(--line);
  font: 500 .9375rem/1.45 var(--sans);
}
.page__foot a { text-decoration: none; }
.page__foot a:hover { text-decoration: underline; text-underline-offset: .25em; }
.page__foot .foot__legal { margin-left: auto; }

.lost { display: grid; align-content: center; gap: 28px; padding-block: 64px; }
.lost .dot { width: clamp(120px, 24vw, 220px); height: auto; aspect-ratio: 1; }

/* Motion off */

@media (prefers-reduced-motion: reduce) {
  :root { --fade: .3s; }
  .js [data-reveal], .js .check[data-reveal] { opacity: 1; transform: none; transition: none; }
  .end__dot, .pulse__ring, .clock__colon::before, .clock__colon::after { animation: none; }
  .pulse__ring { opacity: 0; }
  .check__dot { transition: opacity .3s linear, background-color .3s linear; }
  .check.is-away .check__dot { transform: none; }
  .phone__screen [data-screen] { transition-duration: .2s; }
}

@media print {
  html, body { background: #fff !important; color: #000 !important; }
  .check, .pulse, .end__dot, .phone::before, .phone::after { display: none; }
}
