/*
 * Storymaps on the documentation pages: the colours of Postdoc's own steps, the space
 * for a storymap's pictures, and the terminals in the steps, which type their commands.
 * Story pages load it too, for the parts that a story has in both places.
 */

/* Under a step's heading: when and where the step is. */
.storymap-step .story-meta {
  margin: -0.375rem 0 0.75rem;
  color: var(--story-muted, var(--color-muted));
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  line-height: 1.5;
  text-transform: uppercase;
}

/* The link that opens a story on a page of its own. */
.pd-content a.story-launch {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem 0.625rem;
  padding: 0.625rem 1.25rem;
  border-radius: 999px;
  background-color: #264437;
  color: #ffffff;
  font-weight: 500;
  text-decoration: none;
}

.pd-content a.story-launch::after {
  content: '';
  width: 0.875rem;
  height: 0.875rem;
  background-color: currentColor;
  mask: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"%3E%3Cpath d="M7 17 17 7M8 7h9v9"/%3E%3C/svg%3E') center / contain no-repeat;
}

.pd-content a.story-launch:hover {
  background-color: #1e392e;
  color: #ffffff;
}

.pd-content a.story-launch .story-launch-note {
  font-size: 0.875rem;
  font-weight: 400;
}

[data-theme="dark"] .pd-content a.story-launch {
  background-color: #8fd1a3;
  color: #0d1411;
}

[data-theme="dark"] .pd-content a.story-launch:hover {
  background-color: #b4e2c1;
  color: #0d1411;
}

.pd-content .storymap {
  --storymap-accent: rgb(var(--colour-dark-text-main));
  --storymap-border: var(--panel-border);
  --storymap-radius: var(--code-radius);
}

/* The pictures are small illustrations, so they have room around them. */
.pd-content .storymap.has-pictures > .storymap-body > .storymap-map {
  padding: clamp(1.5rem, 14%, 6rem);
  border: 1px solid var(--panel-border);
  background-color: var(--panel-bg);
}

/* Without JavaScript, a picture shows in its step, at the size of an illustration
   rather than as wide as the page. */
.pd-content .storymap-step > .storymap-image {
  width: 9rem;
}

/* The steps hold a terminal, so they get more of the width than the pictures do. */
@container (min-width: 640px) {
  .pd-content .storymap.has-pictures:not(.is-floating) > .storymap-body {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

/* A long command of a step's terminal wraps, so the reader sees all of it being typed. */
.pd-content .storymap-step :is(.language-sh, .language-bash, .language-shell, .language-zsh) pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/*
 * Typing, which postdoc/js/base.js starts when a terminal comes into view. The commands
 * are in the page from the start, a character to a span, and invisible until they're
 * typed, so the terminal doesn't change its size.
 */
.is-typing .line:not(.is-started)::before,
.is-typing .typed-character:not(.is-typed) {
  opacity: 0;
}

/* The caret takes up no room, so it doesn't move the text it's in. */
.typed-caret {
  position: relative;
}

.typed-caret::after {
  content: '';
  position: absolute;
  top: 0.1em;
  left: 0;
  width: 0.55em;
  height: 1.15em;
  background-color: var(--code-accent);
  animation: typed-caret 1.1s steps(1) infinite;
}

@keyframes typed-caret {
  50% {
    opacity: 0;
  }
}
