/* The story at "/" (templates/story.html, static/story.js): one text box
   in an empty page, like the text of an old handheld game. Each press
   writes the next paragraph over the last; the box keeps the height of
   the longest, so nothing below it moves. Without the script every
   paragraph shows, one under the other. */

.story-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ---- the corner ------------------------------------------------------ */

.story-top {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  padding: max(0.75rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 0 max(1rem, env(safe-area-inset-left));
  font-family: var(--font-interface, inherit);
  font-size: 0.875rem;
}

.story-nav {
  display: flex;
  align-items: center;
  gap: 0.125rem;
  margin-right: -0.5rem;
}
.story-nav-link {
  display: inline-flex;
  align-items: center;
  height: 2.75rem;
  padding-inline: 0.75rem;
  border-radius: 0.5rem;
  color: var(--marketing-foreground);
  font-weight: 500;
  transition: background-color 150ms ease, color 150ms ease;
}
.story-theme {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.5rem;
  color: var(--muted-foreground);
  transition: background-color 150ms ease, color 150ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .story-nav-link:hover,
  .story-theme:hover {
    background: var(--marketing-surface-hover-muted);
    color: var(--marketing-foreground);
  }
}

/* ---- the box --------------------------------------------------------- */

.story {
  position: relative;
  z-index: 10;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  max-width: 38rem;
  margin-inline: auto;
  padding: 3rem 1rem 4rem;
}

.story-logo {
  display: flex;
  justify-content: center;
  margin: 0 0 1.75rem;
}
.story-logo img {
  height: 2.5rem;
  width: auto;
}

/* The slogan under the logo, quiet beside it. */
.story-slogan {
  margin: -0.875rem 0 1.75rem;
  text-align: center;
  font-family: var(--font-interface, inherit);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--muted-foreground);
}

/* A double frame, the way the old games drew theirs: a solid line, and
   a hairline inside it. */
.story-box {
  position: relative;
  padding: 1.375rem 1.5rem 1.75rem;
  border: 2px solid var(--marketing-foreground);
  border-radius: 0.875rem;
  background: var(--app-content-solid, var(--marketing-surface));
  color: var(--marketing-foreground);
  box-shadow:
    inset 0 0 0 3px var(--app-content-solid, var(--marketing-surface)),
    inset 0 0 0 4px color-mix(in oklab, var(--marketing-foreground) 18%, transparent),
    0 1px 2px rgb(0 0 0 / 0.06),
    0 24px 48px -28px rgb(0 0 0 / 0.35);
}
/* Quick taps go on through the story; iOS would zoom on a double tap. */
.story-box,
.story-bar button {
  touch-action: manipulation;
}
.story-js .story-box {
  cursor: pointer;
  animation: story-in 500ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.story-beats {
  margin: 0;
  padding: 0;
  list-style: none;
}
.story-beat p {
  margin: 0;
  font-size: 1rem;
  line-height: 1.7;
  text-wrap: pretty;
}
html:not(.story-js) .story-beat + .story-beat {
  margin-top: 1rem;
}
/* With the script every paragraph shares one cell: the box takes the
   height of the longest, and only the current one is seen. */
.story-js .story-beats {
  display: grid;
}
.story-js .story-beat {
  grid-area: 1 / 1;
  visibility: hidden;
}
.story-js .story-beat.is-current {
  visibility: visible;
}
/* What the reader said to get here, in quotes like the button. */
.story-beat p.story-asked {
  margin-bottom: 0.5rem;
  color: var(--muted-foreground);
  font-size: 0.875rem;
}
.story-beat .rest {
  color: transparent;
}

/* The arrow that says there is more, once the paragraph is written. */
.story-more {
  position: absolute;
  right: 1.125rem;
  bottom: 0.75rem;
  width: 0;
  height: 0;
  border-inline: 5px solid transparent;
  border-top: 7px solid var(--marketing-foreground);
  opacity: 0;
}
.story-box.is-typed .story-more {
  opacity: 1;
  animation: story-blink 1s steps(1) infinite;
}
.story-box.is-last .story-more {
  display: none;
}
html:not(.story-js) .story-more {
  display: none;
}

/* ---- under the box --------------------------------------------------- */

.story-under {
  display: grid;
  margin-top: 1rem;
}
.story-js .story-under > * {
  grid-area: 1 / 1;
}

.story-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  align-self: start;
  font-family: var(--font-interface, inherit);
}
html:not(.story-js) .story-bar {
  display: none;
}
.story-bar[hidden] {
  display: flex;
  visibility: hidden;
}
.story-back {
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  margin-right: auto;
  border: 1px solid var(--marketing-border);
  border-radius: 9999px;
  background: var(--app-content-solid, var(--marketing-surface));
  color: var(--muted-foreground);
  transition: color 150ms ease, border-color 150ms ease, scale 150ms ease;
}
.story-back:active {
  scale: 0.97;
}
.story-back[hidden] {
  display: none;
}
.story-button {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  height: 2.75rem;
  padding-inline: 1.125rem 0.5rem;
  border: 1px solid var(--marketing-border);
  border-radius: 9999px;
  background: var(--app-content-solid, var(--marketing-surface));
  color: var(--marketing-foreground);
  font-size: 0.9375rem;
  font-weight: 500;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
  transition: scale 120ms ease-out, border-color 150ms ease, background-color 150ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .story-button:hover {
    border-color: color-mix(in oklab, var(--marketing-foreground) 40%, var(--marketing-border));
  }
  .story-back:hover {
    color: var(--marketing-foreground);
    border-color: color-mix(in oklab, var(--marketing-foreground) 40%, var(--marketing-border));
  }
}
.story-button:active {
  scale: 0.97;
}
.story-button:focus-visible,
.story-back:focus-visible,
.story-own:focus-visible {
  outline: 2px solid color-mix(in oklch, var(--ring) 70%, transparent);
  outline-offset: 2px;
}
.story-key {
  display: inline-grid;
  place-items: center;
  height: 1.625rem;
  padding-inline: 0.4375rem;
  border: 1px solid var(--marketing-border);
  border-bottom-width: 2px;
  border-radius: 0.375rem;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
}
@media (pointer: coarse) {
  .story-key {
    display: none;
  }
  .story-button {
    padding-inline: 1.25rem;
  }
}

/* ---- the end ---------------------------------------------------------- */

.story-end {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.5rem;
  padding-top: 0.5rem;
  font-family: var(--font-interface, inherit);
  text-align: center;
}
.story-js .story-end:not(.is-shown) {
  visibility: hidden;
}
.story-js .story-end.is-shown {
  animation: story-in 400ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.story-own-offer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.625rem;
}
.story-cta {
  height: 2.75rem;
  padding-inline: 1.375rem;
}
.story-own {
  display: inline-flex;
  align-items: center;
  height: 2.75rem;
  padding-inline: 1.25rem;
  border: 1px solid var(--marketing-border);
  border-radius: 9999px;
  background: var(--app-content-solid, var(--marketing-surface));
  color: var(--marketing-foreground);
  font-size: 0.875rem;
  font-weight: 500;
  transition: border-color 150ms ease, scale 120ms ease-out;
}
.story-own:active {
  scale: 0.98;
}
@media (hover: hover) and (pointer: fine) {
  .story-own:hover {
    border-color: color-mix(in oklab, var(--marketing-foreground) 40%, var(--marketing-border));
  }
}
.story-price {
  margin: 0;
  color: var(--muted-foreground);
  font-size: 0.8125rem;
  line-height: 1.6;
}
@media (max-width: 30rem) {
  .story-own-offer {
    align-self: stretch;
  }
  .story-cta,
  .story-own {
    justify-content: center;
    width: 100%;
  }
}

.story-foot {
  position: relative;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 1.25rem;
  padding: 1rem 1rem max(1.25rem, env(safe-area-inset-bottom));
  font-family: var(--font-interface, inherit);
  font-size: 0.8125rem;
}
.story-foot a {
  color: var(--muted-foreground);
}
@media (hover: hover) and (pointer: fine) {
  .story-foot a:hover {
    color: var(--marketing-foreground);
  }
}

@keyframes story-in {
  from {
    opacity: 0;
    translate: 0 8px;
  }
}
@keyframes story-blink {
  50% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .story-js .story-box,
  .story-js .story-end.is-shown {
    animation: none;
  }
  .story-box.is-typed .story-more {
    animation: none;
  }
}
