/* The app's screens on the download page, beside style.css: a phone around
   one screen, the hero's two phones, and the tour of six (site/README.md).
   Only index.html loads it; the support and privacy pages show no screens. */

/* ---- A phone, around one app screen --------------------------------------- */

/* Every length is a share of the phone's OWN width, --w (a padding percentage
   would be of the parent's). The screen inside is 390 × 844, the size
   site_shots.dart draws at, so a 780 × 1688 shot fills it exactly; the status
   bar and the home indicator are drawn over the strips the shot leaves for them. */
.phone {
  --w: 280px;
  position: relative;
  width: var(--w);
  padding: calc(var(--w) * 0.032);
  border-radius: calc(var(--w) * 0.155);
  background: linear-gradient(150deg, #3a3c41 0%, #18191c 38%, #0e0f11 100%);
  box-shadow:
    0 60px 120px -28px rgba(0, 0, 0, 0.9),
    inset 0 0 0 1.5px rgba(255, 255, 255, 0.16),
    inset 0 0 0 calc(var(--w) * 0.012) #060607,
    0 0 0 1px #000;
}

.phone-screen {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  aspect-ratio: 390 / 844;
  border-radius: calc(var(--w) * 0.123);
  background: #ffffff;
}

.phone-screen img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.phone-screen::before,
.phone-screen::after {
  content: "";
  position: absolute;
  z-index: 2;
  pointer-events: none;
}

.phone-screen::before {
  top: 0;
  left: 0;
  width: 100%;
  aspect-ratio: 390 / 47;
  background: url("img/status-bar.svg") left top / 100% auto no-repeat;
}

.phone-screen::after {
  left: 32.8%;
  width: 34.4%;
  bottom: 0.95%;
  height: 0.6%;
  border-radius: 99px;
  background: #111214;
}

/* ---- The app, in two phones ---------------------------------------------- */

/* The section is as tall as the front phone's top four fifths, whatever its
   width, and cuts it there: the fade below covers the cut. A fixed height let
   a narrow screen's phone run on over the next heading. */
.showcase {
  --phone: clamp(230px, 24vw, 300px);
  position: relative;
  z-index: 1;
  margin-top: clamp(48px, 7vw, 88px);
  height: calc(var(--phone) * 1.78);
  overflow: hidden;
}

@supports (overflow: clip) {
  .showcase {
    overflow-x: visible;
    overflow-y: clip;
  }
}

.phone-front {
  position: absolute;
  z-index: 1;
  top: 0;
  left: 50%;
  --w: var(--phone);
  transform: translateX(-50%);
}

.phone-back {
  position: absolute;
  top: 56px;
  left: calc(50% + clamp(40px, 8vw, 120px));
  --w: clamp(200px, 21vw, 260px);
  transform: rotate(7deg);
  opacity: 0.85;
}

/* The phones sink into the night rather than ending on a hard edge. */
.showcase::after {
  content: "";
  position: absolute;
  z-index: 2;
  left: -50%;
  right: -50%;
  bottom: 0;
  height: 55%;
  background: linear-gradient(180deg, rgba(10, 10, 11, 0) 0%, rgba(10, 10, 11, 0.85) 60%, var(--ground) 100%);
  pointer-events: none;
}

/* ---- The tour: six screens of the app -------------------------------------- */

/* Three layouts from one list. A phone or a tablet swipes a row of cards, the
   next one peeking in. A desktop without tour.js sees the six cards in a grid.
   A desktop with it (`.is-staged`) reads the words down the left while one phone
   on the right stays put and changes to the screen they are about. */
.tour {
  position: relative;
  z-index: 3;
  margin-top: clamp(16px, 3vw, 40px);
  scroll-margin-top: 16px;
}

.eyebrow {
  font-size: 14px;
  font-weight: 500;
  color: var(--silver);
}

.tour h2 {
  margin-top: 10px;
  max-width: 18ch;
  font-size: clamp(32px, 4.6vw, 56px);
  line-height: 1.08;
  font-weight: 600;
  letter-spacing: -0.035em;
  text-wrap: balance;
  /* Room for the marks under ạ and ộ at this leading. */
  padding-bottom: 0.06em;
}

.tour-lead {
  margin-top: 14px;
  max-width: 42ch;
  font-size: clamp(16px, 1.6vw, 19px);
  line-height: 1.55;
  color: var(--body);
  text-wrap: pretty;
}

.tour-body {
  position: relative;
  margin-top: clamp(28px, 4vw, 52px);
}

.tour-list {
  --card: min(84vw, 340px);
  --edge-left: max(var(--gutter), env(safe-area-inset-left));
  --edge-right: max(var(--gutter), env(safe-area-inset-right));
  position: relative;
  list-style: none;
  display: flex;
  gap: 14px;
  /* Out to the screen's edges, so a card slides off it rather than off the
     column; the first card still starts on the column. */
  margin: 0 calc(var(--edge-right) * -1) 0 calc(var(--edge-left) * -1);
  padding: 2px var(--edge-right) 6px var(--edge-left);
  scroll-padding-inline: var(--edge-left) var(--edge-right);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.tour-list::-webkit-scrollbar {
  display: none;
}

.tour-item {
  flex: 0 0 var(--card);
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 28px;
  background: var(--glass);
  border: 1px solid var(--hairline);
}

/* The top three quarters of the phone, lit from behind and sinking into the
   card: the part of each screen that says what it is for. */
.tour-figure {
  display: flex;
  justify-content: center;
  height: calc(var(--card) * 1.3);
  padding-top: 28px;
  overflow: hidden;
  background: radial-gradient(closest-side at 50% 55%, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0));
}

.tour-figure .phone {
  --w: calc(var(--card) * 0.76);
  flex: none;
  box-shadow:
    0 30px 60px -20px rgba(0, 0, 0, 0.8),
    inset 0 0 0 1.5px rgba(255, 255, 255, 0.16),
    inset 0 0 0 calc(var(--w) * 0.012) #060607,
    0 0 0 1px #000;
  /* Of the phone's box, which the figure stretches to its own height: gone
     just before the figure's bottom edge, where the card's words begin. */
  -webkit-mask-image: linear-gradient(180deg, #000 62%, transparent 96%);
  mask-image: linear-gradient(180deg, #000 62%, transparent 96%);
}

.tour-copy {
  position: relative;
  padding: 4px 24px 28px;
}

.tour-number {
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: var(--silver);
}

.tour-tag {
  display: inline-block;
  margin-left: 10px;
  padding: 2px 10px;
  border-radius: 99px;
  border: 1px solid var(--edge);
  font-size: 12px;
  font-weight: 500;
  color: var(--silver);
  vertical-align: 1px;
}

.tour-copy h3 {
  margin: 10px 0 0;
  font-size: 20px;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.tour-copy p {
  margin-top: 8px;
  font-size: 15px;
  line-height: 1.55;
  color: var(--body);
  text-wrap: pretty;
}

/* tour.js: where the row is, and a way to any card. 48 tall to tap (DESIGN.md
   §5); the mark inside is small. */
.tour-dots {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

.tour-dot {
  display: grid;
  place-items: center;
  width: 32px;
  height: 48px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tour-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 99px;
  /* 3:1 against the ground, as a control's mark needs (WCAG 1.4.11). */
  background: rgba(255, 255, 255, 0.45);
  transition: width 240ms var(--ease-out), background-color 240ms;
}

.tour-dot[aria-current="true"]::before {
  width: 22px;
  background: var(--ink);
}

.tour-dot:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: -6px;
  border-radius: 12px;
}

/* Only tour.js fills and shows it. */
.tour-stage {
  display: none;
}

@media (min-width: 960px) {
  .tour-list {
    --card: 300px;
  }

  /* No script, or no way to stick: the six cards in a grid, and no dots,
     since a grid has nowhere to scroll them to. */
  .tour:not(.is-staged) .tour-dots {
    display: none;
  }

  .tour:not(.is-staged) .tour-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin: 0;
    padding: 0;
    overflow: visible;
  }

  /* The script: words on the left, one phone on the right. */
  .tour.is-staged .tour-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: clamp(40px, 6vw, 96px);
    align-items: start;
  }

  .tour.is-staged .tour-list {
    display: block;
    margin: 0;
    padding: 0;
    overflow: visible;
    border-left: 1px solid var(--hairline);
  }

  .tour.is-staged .tour-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    min-height: 70vh;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: none;
  }

  .tour.is-staged .tour-figure,
  .tour.is-staged .tour-dots {
    display: none;
  }

  .tour.is-staged .tour-copy {
    max-width: 30rem;
    padding: 0 0 0 clamp(28px, 3vw, 44px);
    /* Dimmed, not faded out: the paragraph keeps 4.5:1 on the ground. */
    opacity: 0.74;
    transition: opacity 420ms var(--ease-out);
  }

  /* The rail's bright stretch is the part being read. */
  .tour.is-staged .tour-copy::before {
    content: "";
    position: absolute;
    left: -1px;
    top: 0;
    bottom: 0;
    width: 2px;
    border-radius: 2px;
    background: var(--ink);
    transform: scaleY(0);
    transition: transform 420ms var(--ease-out);
  }

  .tour.is-staged .tour-item.is-active .tour-copy {
    opacity: 1;
  }

  .tour.is-staged .tour-item.is-active .tour-copy::before {
    transform: scaleY(1);
  }

  .tour.is-staged .tour-copy h3 {
    font-size: clamp(26px, 2.6vw, 34px);
    line-height: 1.2;
    letter-spacing: -0.025em;
  }

  .tour.is-staged .tour-copy p {
    margin-top: 12px;
    font-size: 18px;
  }

  .tour.is-staged .tour-stage {
    --w: min(300px, calc((100vh - 120px) * 0.478));
    display: block;
    justify-self: center;
    position: sticky;
    /* Centred in the window: the phone is 2.09 times as tall as it is wide. */
    top: calc(50vh - var(--w) * 1.045);
    margin-top: calc(35vh - var(--w) * 1.045);
  }

  .tour-stage::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 760px;
    height: 760px;
    transform: translate(-50%, -50%);
    background: radial-gradient(closest-side, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.025) 50%, rgba(255, 255, 255, 0));
    pointer-events: none;
  }

  .tour-stage .phone {
    --w: inherit;
  }

  .tour-stage .phone-screen img {
    opacity: 0;
    transform: scale(1.015);
    transition: opacity 520ms var(--ease-out), transform 700ms var(--ease-out);
  }

  .tour-stage .phone-screen img.is-shown {
    opacity: 1;
    transform: none;
  }
}

/* The second half of the page's one entrance (style.css): after the icon, the
   app rises. */
@media (prefers-reduced-motion: no-preference) {
  .phone-front {
    animation: rise-centred 900ms var(--ease-out) 160ms both;
  }

  .phone-back {
    animation: rise-tilted 900ms var(--ease-out) 260ms both;
  }

  @keyframes rise-centred {
    from {
      opacity: 0;
      transform: translate(-50%, 24px);
    }
  }

  @keyframes rise-tilted {
    from {
      opacity: 0;
      transform: translateY(24px) rotate(7deg);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .tour-dot::before,
  .tour.is-staged .tour-copy,
  .tour.is-staged .tour-copy::before,
  .tour-stage .phone-screen img {
    transition: none;
  }
}

/* Windows high contrast paints every background with the page's own colour,
   which would take the dots' marks and the rail's bright stretch with it. */
@media (forced-colors: active) {
  .tour-dot::before {
    background: ButtonText;
  }

  .tour-dot[aria-current="true"]::before,
  .tour.is-staged .tour-copy::before {
    background: Highlight;
  }
}
