/* Sorello: one black screen around the iPhone keyboard's dictation pill.
   The colours and the type are the app's: the pill's near-black with its grey
   hairline, white ink, aurora for the one dot that shows a state; Urbanist
   Medium for display text, tracked in by 0.015 em, and the system font for
   everything else. */

@font-face {
  font-family: "Urbanist";
  src: url("/fonts/Urbanist-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --black: #000;
  --pill: #09090a;
  --edge: #6e6e70;
  --edge-lit: #a2a2a6;
  --ink: #fff;
  --ink-2: rgba(255, 255, 255, 0.66);
  --ink-3: rgba(255, 255, 255, 0.5);
  --aurora: #6dffa8;
  --display: "Urbanist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --text: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --gutter: clamp(1.25rem, 4vw, 2rem);
  /* How the island's parts arrive: quick, then settling. */
  --settle: cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--black);
  color: var(--ink);
  font-family: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: rgba(109, 255, 168, 0.28);
}

/* ---------- The wordmark ---------- */

.top {
  padding: var(--gutter);
}

.wordmark {
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.25rem;
  letter-spacing: -0.015em;
}

/* ---------- The stage: the pill, what Sorello does, and where to get it ---------- */

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem var(--gutter) 2.5rem;
  text-align: center;
}

/* The pill is a button the size of its canvas; the island inside it is drawn,
   and so is its focus ring, which follows the island's own outline. */
.pill {
  appearance: none;
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  visibility: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.pill.is-ready {
  visibility: visible;
}

.pill:focus {
  outline: none;
}

.pill__canvas {
  display: block;
  /* The island's 200 by 38 points and 3 around it, at up to twice the keyboard's size. */
  width: min(100vw - 2 * var(--gutter), 412px);
  aspect-ratio: 206 / 44;
}

/* The headline: what the pill does, in the app's display face. On a phone it is as large as its two lines fit,
   so that it stays the largest thing on the page beside the subtitle under it, with room at 320 wide for a wider
   face than Urbanist while Urbanist loads.

   Its box is as wide as the page gives it, not as wide as its words. A box fitted to its words is exactly as wide
   as its longer line, and as the headline is typed that line's width changes by a fraction of a pixel, where the
   cursor parts two letters set close as a pair: the line would no longer fit, and jump to a third line and back. */
.headline {
  margin: clamp(2rem, 6vh, 3.25rem) 0 0;
  width: 100%;
  max-width: 11.5em;
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(2.25rem, 1.15rem + 5.5vw, 3.75rem);
  line-height: 1.08;
  letter-spacing: -0.015em;
}

/* Its two lines, as the page marks them: it breaks at the comma at every width. A line wraps again only where it
   cannot fit, as with the text made much larger on a phone. (The lines are not balanced: Safari's engine balances
   across a line break and would split the first line in two.) */
.headline__line {
  display: block;
}

/* The first line is there as the page loads. The second is typed in by js/main.js as the pill's dictation stops:
   what has been typed, the cursor after it, and the rest, which keeps its room unseen so the page never moves.
   Without scripts, and with Reduce Motion, the whole headline is simply there and has no cursor. */
.headline__rest {
  visibility: hidden;
}

/* The page is painted before its script has run, so the second line would show for an instant and then go, to be
   typed in later. Where scripts run and things may move, it is unseen from the first paint, until the script
   takes the headline over (it marks it with data-typing). Should the script never come, the line shows after
   three seconds, so the headline is not left without it. */
@media (scripting: enabled) and (prefers-reduced-motion: no-preference) {
  .headline:not([data-typing]) .headline__line:last-child {
    animation: unseen-at-first 0s linear 3s both;
  }
}

@keyframes unseen-at-first {
  from {
    visibility: hidden;
  }

  to {
    visibility: visible;
  }
}

/* The cursor the words are put in at. It is taken out of the line and left where it would have stood, after the
   last typed letter, so it adds no width in any engine and the words never move as it passes or as it goes. */
.headline[data-typing] .headline__typed::after {
  content: "";
  position: absolute;
  width: 0.055em;
  height: 0.84em;
  margin: 0.13em 0 0 0.09em;
  border-radius: 0.03em;
  background: var(--aurora);
}

/* It blinks while it waits for the words, holds still while they are typed, and blinks three times and goes.
   Where the words were put there all at once, with Reduce Motion, nothing was typed and there is no cursor. */
.headline[data-typing="shown"] .headline__typed::after {
  content: none;
}

.headline[data-typing="waiting"] .headline__typed::after {
  animation: blink 1.1s steps(1, end) infinite;
}

.headline[data-typing="typed"] .headline__typed::after {
  animation: blink-out 3.3s steps(1, end) forwards;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@keyframes blink-out {
  0%,
  33.3%,
  66.6% {
    opacity: 1;
  }

  16.6%,
  50%,
  83.3%,
  100% {
    opacity: 0;
  }
}

/* The subtitle is the quieter of the two at every width: on a phone it is smaller, and stands a little further
   off, so that its lines do not outweigh the headline's. */
.subtitle {
  margin: clamp(1.25rem, 3vh, 1.75rem) 0 0;
  max-width: 31em;
  color: var(--ink-2);
  font-size: clamp(0.9375rem, 0.86rem + 0.36vw, 1.0625rem);
  font-weight: 400;
  line-height: 1.5;
  text-wrap: balance;
}

/* ---------- Where to get it ---------- */

.get {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem 1rem;
  margin-top: clamp(2rem, 5vh, 2.75rem);
}

.get__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  /* Wide enough for its note on one line, and never wider than the page: with the text made much larger on a
     phone the note wraps instead. */
  min-width: min(14.5rem, 100%);
}

.get__note {
  margin: 0;
  color: var(--ink-3);
  font-size: 0.8125rem;
  line-height: 1.3;
}

/* A button is the island's surface, with the mark's dot. */
.button {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  height: 2.875rem;
  padding: 0 1.5rem 0 1.2rem;
  border-radius: 999px;
  background: var(--pill);
  box-shadow: inset 0 0 0 1px var(--edge);
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: box-shadow 150ms ease-out, transform 120ms ease-out, opacity 120ms ease-out;
}

.button::before {
  content: "";
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--aurora);
}

.button:hover,
.button:focus-visible {
  box-shadow: inset 0 0 0 1px var(--edge-lit);
}

/* Under the pointer the dot beats as Start's does: a ring grows from it and fades, then rests. */
.button:hover::before,
.button:focus-visible::before {
  animation: beat 1.8s ease-out infinite;
}

.button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

/* Pressed, a control is a little smaller and dimmer. */
.button:active {
  transform: scale(0.97);
  opacity: 0.8;
}

@keyframes beat {
  0% {
    box-shadow: 0 0 0 0 rgba(109, 255, 168, 0.6);
  }

  55%,
  100% {
    box-shadow: 0 0 0 0.45rem rgba(109, 255, 168, 0);
  }
}

/* ---------- The foot ---------- */

.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1.75rem;
  padding: var(--gutter);
  font-size: 0.8125rem;
}

.foot a {
  color: var(--ink-3);
  text-decoration: none;
  transition: color 150ms ease-out;
}

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

.foot a:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
  border-radius: 2px;
}

/* ---------- A page with nothing to say (404.html) ---------- */

.still {
  display: block;
  width: min(100vw - 2 * var(--gutter), 412px);
  height: auto;
}

/* ---------- Arriving ---------- */

.top,
.pill.is-ready,
.still,
.headline,
.subtitle,
.get,
.foot {
  animation: arrive 800ms var(--settle) both;
}

.headline {
  animation-delay: 90ms;
}

.subtitle {
  animation-delay: 170ms;
}

.get {
  animation-delay: 250ms;
}

.foot {
  animation-delay: 330ms;
}

@keyframes arrive {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
}

/* ---------- Reduce Motion: nothing travels; the parts cross-fade into their places ---------- */

@media (prefers-reduced-motion: reduce) {
  .top,
  .pill.is-ready,
  .still,
  .headline,
  .subtitle,
  .get,
  .foot {
    animation: none;
  }

  .headline[data-typing] .headline__typed::after {
    content: none;
  }

  .button,
  .button:active {
    transform: none;
  }

  .button:hover::before,
  .button:focus-visible::before {
    animation: none;
  }
}
