/* The Lazy Reader. A book, not a manual. The colors follow docs.aihc.app. */

:root {
  --lazy-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --lazy-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --lazy-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --md-primary-fg-color: #5e5086;
  --md-primary-fg-color--light: #7d6fa6;
  --md-primary-fg-color--dark: #46396b;
  --md-primary-bg-color: #ffffff;
  --md-primary-bg-color--light: #ffffffb3;
  --md-accent-fg-color: #46396b;
  --md-accent-fg-color--transparent: #46396b1a;
  --md-accent-bg-color: #ffffff;
  --md-accent-bg-color--light: #ffffffb3;

  --md-text-font: var(--lazy-serif);
  --md-code-font: var(--lazy-mono);
}

[data-md-color-scheme="default"] {
  --md-default-bg-color: #faf8f3;
  --md-default-fg-color: #1d1a17;
  --md-default-fg-color--light: #1d1a17b3;
  --md-default-fg-color--lighter: #1d1a1766;
  --md-default-fg-color--lightest: #1d1a1712;
  --md-code-bg-color: #f3f0ea;
  --md-code-fg-color: #2b2622;
  --md-typeset-color: #1d1a17;
  --md-typeset-a-color: #5e5086;
  --md-footer-bg-color: #1d1a17;
  --md-footer-bg-color--dark: #151318;
  --lazy-ink: #1d1a17;
  --lazy-muted: #6b655d;
  --lazy-rule: #e6e0d6;
  --lazy-surface: #ffffff;
  --lazy-surface-2: #f3f0ea;
  --lazy-accent: #5e5086;
  --lazy-accent-soft: #eee9f7;
  --lazy-good: #2f9e6b;
  --lazy-bad: #d94f3d;
  --lazy-sun: #f2c14e;
}

[data-md-color-scheme="slate"] {
  --md-hue: 265;
  --md-default-bg-color: #151318;
  --md-default-fg-color: #ebe6de;
  --md-default-fg-color--light: #ebe6deb3;
  --md-default-fg-color--lighter: #ebe6de66;
  --md-default-fg-color--lightest: #ebe6de1f;
  --md-code-bg-color: #1d1a22;
  --md-code-fg-color: #ebe6de;
  --md-typeset-color: #ebe6de;
  --md-typeset-a-color: #b7a9e0;
  --md-footer-bg-color: #0f0e12;
  --md-footer-bg-color--dark: #0a090c;
  --lazy-ink: #ebe6de;
  --lazy-muted: #a59f95;
  --lazy-rule: #2d2936;
  --lazy-surface: #1d1a22;
  --lazy-surface-2: #26222e;
  --lazy-accent: #b7a9e0;
  --lazy-accent-soft: #2a2440;
  --lazy-good: #5fcf96;
  --lazy-bad: #f2735f;
  --lazy-sun: #f2c14e;
}

/* Layout: one column, like a page of a book. */

.md-sidebar,
.md-tabs {
  display: none;
}

.md-content {
  max-width: 46rem;
  margin: 0 auto;
}

.md-typeset {
  font-size: 1.05rem;
  line-height: 1.65;
}

.md-typeset h1 {
  font-family: var(--lazy-serif);
  font-weight: 700;
  font-size: 2.6rem;
  letter-spacing: -0.01em;
  color: var(--lazy-ink);
  margin-bottom: 0.4rem;
}

.md-typeset h2 {
  font-family: var(--lazy-serif);
  font-weight: 700;
  font-size: 1.7rem;
  color: var(--lazy-ink);
  margin-top: 2.4rem;
}

.md-typeset h3 {
  font-family: var(--lazy-sans);
  font-weight: 650;
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--lazy-accent);
}

.md-typeset code {
  font-size: 0.9em;
}

.md-typeset pre > code {
  font-size: 0.85rem;
  line-height: 1.55;
}

/* The chapter number above a title. */
.lazy-chapter {
  font-family: var(--lazy-sans);
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.8rem;
  color: var(--lazy-accent);
  margin: 1.5rem 0 0;
}

.lazy-chapter + h1 {
  margin-top: 0;
}

.lazy-lede {
  font-size: 1.3rem;
  line-height: 1.5;
  color: var(--lazy-muted);
  margin: 0 0 2rem;
}

/* The cover. */

.lazy-cover {
  text-align: center;
  padding: 2rem 0 1rem;
}

.lazy-cover img {
  width: 11rem;
  height: 11rem;
}

.lazy-cover h1 {
  font-size: 3.4rem;
  margin: 0.5rem 0 0;
}

.lazy-tagline {
  font-size: 1.4rem;
  font-style: italic;
  color: var(--lazy-muted);
  margin: 0.3rem 0 1.6rem;
}

.lazy-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1rem;
  margin: 1.2rem 0 2rem;
}

.md-typeset .lazy-card {
  display: block;
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--lazy-rule);
  border-radius: 1rem;
  background: var(--lazy-surface);
  color: var(--lazy-ink);
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.md-typeset .lazy-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(30, 20, 60, 0.12);
  color: var(--lazy-ink);
}

.lazy-card-number {
  font-family: var(--lazy-sans);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--lazy-accent);
}

.lazy-card-title {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0.2rem 0 0.3rem;
}

.lazy-card-note {
  color: var(--lazy-muted);
  font-size: 0.95rem;
}

.md-typeset .lazy-card-soon {
  opacity: 0.6;
}

/* A figure with a caption. */

.md-typeset figure.lazy-figure {
  width: 100%;
  margin: 2rem 0;
  padding: 1.2rem;
  border-radius: 1rem;
  background: var(--lazy-surface);
  border: 1px solid var(--lazy-rule);
}

.lazy-figure svg {
  display: block;
  width: 100%;
  height: auto;
}

.lazy-caption {
  margin: 0.8rem 0 0;
  font-family: var(--lazy-sans);
  font-size: 0.9rem;
  color: var(--lazy-muted);
  text-align: center;
}

/* The playground. */

.lazy-play {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1.6rem 0 2rem;
}

@media (max-width: 44rem) {
  .lazy-play {
    grid-template-columns: 1fr;
  }
}

.lazy-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--lazy-rule);
  border-radius: 1rem;
  background: var(--lazy-surface);
  overflow: hidden;
}

.lazy-pane-title {
  font-family: var(--lazy-sans);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--lazy-muted);
  padding: 0.6rem 1rem 0.4rem;
  border-bottom: 1px solid var(--lazy-rule);
}

.lazy-pane-output .lazy-pane-title {
  color: var(--lazy-accent);
}

.lazy-editor {
  flex: 1;
  width: 100%;
  min-height: 7rem;
  padding: 0.8rem 1rem;
  border: 0;
  outline: 0;
  resize: vertical;
  background: transparent;
  color: var(--lazy-ink);
  font-family: var(--lazy-mono);
  font-size: 0.9rem;
  line-height: 1.55;
  tab-size: 2;
}

.lazy-editor:focus {
  background: var(--lazy-accent-soft);
}

.lazy-status {
  font-family: var(--lazy-sans);
  font-size: 0.85rem;
  color: var(--lazy-muted);
  padding: 0 1rem;
}

.lazy-status:not(:empty) {
  padding: 0.8rem 1rem;
}

.lazy-output {
  padding: 0.6rem 1rem 0.8rem;
  overflow-x: auto;
}

.lazy-output:empty {
  display: none;
}

.md-typeset .lazy-painted {
  margin: 0;
  padding: 0.2rem 0;
  background: transparent;
  font-family: var(--lazy-mono);
  font-size: 0.9rem;
  line-height: 1.55;
  white-space: pre;
}

/* The parse tree. */

.lazy-tree-item {
  position: relative;
  animation: lazy-pop 0.25s ease both;
}

.lazy-tree-node {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.1rem 0 0.1rem calc(var(--depth) * 1.1rem);
  position: relative;
}

.lazy-tree-node::before {
  content: "";
  position: absolute;
  left: calc(var(--depth) * 1.1rem - 0.7rem);
  top: 0;
  bottom: 0;
  width: 0.5rem;
  border-left: 1.5px solid var(--lazy-rule);
  border-bottom: 1.5px solid var(--lazy-rule);
  border-bottom-left-radius: 0.4rem;
  height: 0.95rem;
}

.lazy-tree-node[style="--depth: 0"]::before {
  display: none;
}

.lazy-tree-label {
  font-family: var(--lazy-sans);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--lazy-accent);
  background: var(--lazy-accent-soft);
  border-radius: 0.5rem;
  padding: 0.05rem 0.5rem;
  white-space: nowrap;
}

.md-typeset .lazy-tree-text {
  background: transparent;
  color: var(--lazy-ink);
  padding: 0;
  font-size: 0.9rem;
}

@keyframes lazy-pop {
  from {
    opacity: 0;
    transform: translateX(-0.3rem);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Names and colors. */

.lazy-name {
  color: var(--name-color);
  font-weight: 650;
  border-bottom: 2px solid var(--name-color);
  border-radius: 0.15rem;
  transition: opacity 0.15s ease;
}

.lazy-name-binder {
  background: color-mix(in srgb, var(--name-color) 16%, transparent);
  border-bottom-width: 3px;
}

.lazy-name-unresolved {
  text-decoration: wavy underline var(--lazy-bad);
  border-bottom: 0;
}

.lazy-name-dim {
  opacity: 0.3;
}

.md-typeset .lazy-legend {
  list-style: none;
  margin: 0.8rem 0 0;
  padding: 0.6rem 0 0;
  border-top: 1px dashed var(--lazy-rule);
  font-family: var(--lazy-sans);
  font-size: 0.85rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.2rem 0.8rem;
}

.md-typeset .lazy-legend li {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.15rem 0.3rem;
  border-radius: 0.4rem;
}

.lazy-legend-active {
  background: var(--lazy-surface-2);
}

.lazy-legend-swatch {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--name-color);
  flex: none;
  position: relative;
  top: 0.05rem;
}

.lazy-legend-note {
  color: var(--lazy-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Inferred types. */

.lazy-typed .lazy-line {
  display: block;
  min-height: 1.55em;
}

.lazy-inferred {
  background: var(--lazy-accent-soft);
  color: var(--lazy-accent);
  font-weight: 650;
  animation: lazy-pop 0.3s ease both;
}

/* Problems. */

.md-typeset .lazy-problems {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  font-family: var(--lazy-sans);
  font-size: 0.88rem;
}

.md-typeset .lazy-problems li {
  margin: 0.2rem 0;
  padding: 0.4rem 0.7rem;
  border-left: 3px solid var(--lazy-bad);
  background: color-mix(in srgb, var(--lazy-bad) 8%, transparent);
  border-radius: 0 0.5rem 0.5rem 0;
}

.lazy-problem-stage {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--lazy-bad);
}

.lazy-problem-where {
  color: var(--lazy-muted);
}

/* The "try this" box. */

.md-typeset .lazy-try {
  border: 1px solid var(--lazy-rule);
  border-left: 4px solid var(--lazy-sun);
  border-radius: 0.8rem;
  padding: 0.8rem 1.1rem;
  margin: 1.4rem 0;
  background: var(--lazy-surface);
}

.md-typeset .lazy-try p:first-child {
  font-family: var(--lazy-sans);
  font-weight: 650;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--lazy-muted);
  margin: 0 0 0.3rem;
}

.md-typeset .lazy-try ul {
  margin: 0.2rem 0 0.2rem 1rem;
}

/* The chapter 1 animation: text becomes a tree becomes a program. */

.lazy-anim .lazy-anim-token {
  animation: lazy-token 9s ease-in-out infinite;
  transform-origin: center;
}

.lazy-anim .lazy-anim-node {
  animation: lazy-node 9s ease-in-out infinite;
  transform-origin: center;
}

.lazy-anim .lazy-anim-edge {
  stroke-dasharray: 60;
  stroke-dashoffset: 60;
  animation: lazy-edge 9s ease-in-out infinite;
}

.lazy-anim .lazy-anim-arrow {
  stroke-dasharray: 8 6;
  animation: lazy-flow 1.2s linear infinite;
}

.lazy-anim .lazy-anim-bit {
  animation: lazy-bit 9s steps(1) infinite;
}

@keyframes lazy-token {
  0%,
  8% {
    opacity: 0;
    transform: translateY(0.3rem);
  }
  14%,
  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes lazy-node {
  0%,
  28% {
    opacity: 0;
    transform: scale(0.6);
  }
  36%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes lazy-edge {
  0%,
  32% {
    stroke-dashoffset: 60;
  }
  44%,
  100% {
    stroke-dashoffset: 0;
  }
}

@keyframes lazy-bit {
  0%,
  58% {
    opacity: 0.15;
  }
  66%,
  100% {
    opacity: 1;
  }
}

@keyframes lazy-flow {
  to {
    stroke-dashoffset: -14;
  }
}

/* Each animated element has a delay step through the --i custom property. */
.lazy-anim [style*="--i"] {
  animation-delay: calc(var(--i) * 0.25s);
}

@media (prefers-reduced-motion: reduce) {
  .lazy-anim *,
  .lazy-tree-item,
  .lazy-inferred {
    animation: none !important;
    opacity: 1 !important;
    stroke-dashoffset: 0 !important;
    transform: none !important;
  }
}

/* The next-chapter link at the end of a chapter. */

.md-typeset .lazy-next {
  display: block;
  margin: 3rem 0 1rem;
  padding: 1.2rem 1.4rem;
  border-radius: 1rem;
  background: var(--lazy-accent);
  color: #ffffff;
  text-decoration: none;
  font-size: 1.1rem;
}

.md-typeset .lazy-next:hover {
  color: #ffffff;
  filter: brightness(1.08);
}

.md-typeset .lazy-next small {
  display: block;
  font-family: var(--lazy-sans);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.8;
}
