[data-template="cms-md"] {
  --field-gap: 2rem;
  --font-family-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

[data-template="cms-md"] .main {
  line-height: 1.5;
}

/* 🏷️ The syntax layer: field names, separators, markers */

.field,
.syntax,
.task__box,
li.task::before,
.meta-fields hr::after,
hr.field-separator::after,
.article-content__text pre::before,
.article-content__text pre::after,
.marquee-toggle::before,
.marquee-toggle::after,
.marquee-still::before,
.marquee-still::after {
  font-family: var(--font-family-mono);
  font-size: var(--font-size-s);
  color: var(--color-grey);
}

.field {
  font-weight: normal;
  letter-spacing: normal;
  text-transform: none;
  white-space: nowrap;
  margin-block: 0;
}

/* 📑 Field layout */

.meta-fields {
  display: flex;
  flex-direction: column;
  gap: var(--field-gap, 2rem);
}

.meta-fields__meta {
  max-inline-size: fit-content;
}

.meta-fields__description {
  text-wrap: pretty;
}

.article-content {
  margin-block-start: var(--field-gap, 2rem);
}

.meta-fields > :is(h1, p),
.article-body,
.article-field {
  @media (min-width: 1200px) {
    display: grid;
    grid-template-columns: 0 1fr;
    align-items: baseline;
  }
}

.meta-fields .field,
.article-body > .field,
.article-field .field {
  @media (max-width: 1199.98px) {
    display: block;
    margin-block-end: 0.5rem;
  }

  @media (min-width: 1200px) {
    justify-self: end;
    margin-inline-end: 0.75rem;
  }
}

/* Clear the hanging ## when a field starts with a heading */
.article-body:has(.article-content__text > .anchor-heading:first-child)
  > .field {
  @media (min-width: 1200px) {
    margin-inline-end: 2.35rem;
  }
}

.meta-fields hr,
hr.field-separator {
  margin: 0;
  height: auto;
  border: none;
  background: none;
  opacity: 1;
  color: var(--color-grey);

  &::after {
    content: "----" / "";
    opacity: 0.5;
  }
}

hr.field-separator {
  margin-block: var(--field-gap, 2rem);
}

/* 💬 Field values */

.article-field {
  margin-block: 0;

  .value {
    margin-block: 0;
  }

  .value a {
    text-decoration: underline;
    text-decoration-thickness: 0.075em;
    text-underline-offset: 0.2em;
    text-decoration-color: var(--color-grey);
  }
}

.value--multiline {
  white-space: pre-line;
  max-width: 60ch;
}

.value--raw {
  white-space: pre-wrap;
  font-family: var(--font-family-primary);
  font-size: var(--font-size-m);
}

/* ✏️ Markdown syntax, dimmed like the field names */

.article-content__text {
  em {
    &::before,
    &::after {
      content: "*" / "";
      color: var(--color-grey);
      font-style: normal;
    }
  }

  strong {
    &::before,
    &::after {
      content: "**" / "";
      color: var(--color-grey);
      font-weight: normal;
    }
  }

  :not(pre) > code {
    &::before,
    &::after {
      content: "`" / "";
      color: var(--color-grey);
    }
  }

  ul:has(> li.task) {
    padding-inline-start: 0;
  }

  li.task {
    list-style: none;

    &::before {
      content: "- " / "";
    }

    .task__check {
      color: var(--color-highlight);
    }

    @media (min-width: 1000px) {
      display: grid;
      grid-template-columns: auto auto 1fr;
      column-gap: 0.5ch;
      align-items: baseline;
    }
  }

  pre {
    &::before,
    &::after {
      content: "```" / "";
      display: block;
      opacity: 0.5;
    }
  }

  h2 .anchor-heading__link {
    margin-inline-start: -1.6rem;

    &::before {
      content: "##" / "";
      width: 1.6rem;
    }

    @media (max-width: 1000px) {
      margin-inline-start: -1.1rem;

      &::before {
        width: 1.1rem;
      }
    }
  }

  h3 .anchor-heading__link {
    margin-inline-start: -2.2rem;

    &::before {
      content: "###" / "";
      width: 2.2rem;
    }

    @media (max-width: 1000px) {
      margin-inline-start: -1.5rem;

      &::before {
        width: 1.5rem;
      }
    }
  }
}

/* inline-block stops the link underline from painting the brackets */
.article-content__text a:not(.anchor-heading__link, [class*="footnote"]),
.article-field .value a {
  &::before,
  &::after {
    display: inline-block;
    color: var(--color-grey);
  }

  &::before {
    content: "[" / "";
  }

  &::after {
    content: "]" / "";
  }
}

/* 🚂 */

.marquee-toggle,
.marquee-still {
  display: inline-flex;
  align-items: baseline;
  width: 100%;
  max-width: 16rem;
  vertical-align: middle;

  &::before {
    content: "<marquee>" / "";
  }

  &::after {
    content: "</marquee>" / "";
  }
}

.marquee-toggle {
  border-radius: var(--border-radius);
}

.marquee-viewport {
  flex: 1;
  min-width: 0;
  overflow: clip;
}

.marquee-track {
  display: inline-block;
  white-space: nowrap;
  padding-inline-start: 100%;
  animation: marquee-scroll 6s linear infinite;
}

@keyframes marquee-scroll {
  from {
    translate: 0;
  }
  to {
    translate: -100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .marquee-track {
    animation: none;
  }
}

/* 🍓 */

.wavy span {
  display: inline-block;

  .wavy.is-waving & {
    animation: wave 1s ease-in-out infinite;
    animation-delay: calc(var(--i) * 0.1s);
  }

  @media (prefers-reduced-motion: reduce) {
    animation: none;
  }
}

.wavy-toggle {
  border-radius: var(--border-radius);
}

@keyframes wave {
  50% {
    translate: 0 -0.06em;
  }
}

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