/* Rendered CKEditor 5 HTML on the public site */
.richtext {
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.richtext > *:first-child {
  margin-top: 0;
}

.richtext > *:last-child {
  margin-bottom: 0;
}

/* Collapse spacer paragraphs CKEditor leaves in the editor */
.richtext > p:empty,
.richtext > p:has(> br:only-child) {
  display: none;
  margin: 0;
  padding: 0;
}

.richtext p,
.richtext ul,
.richtext ol,
.richtext blockquote,
.richtext pre,
.richtext table,
.richtext figure {
  margin: 0 0 0.75rem;
}

.richtext h1,
.richtext h2,
.richtext h3,
.richtext h4 {
  margin: 0.85rem 0 0.5rem;
  line-height: 1.3;
  font-weight: 700;
}

/* First heading should sit tight under the course title (even after empty <p> tags) */
.richtext h1:first-of-type,
.richtext h2:first-of-type,
.richtext h3:first-of-type,
.richtext h4:first-of-type {
  margin-top: 0;
}

.richtext ul,
.richtext ol {
  padding-left: 1.5rem;
}

.richtext li {
  margin-bottom: 0.35rem;
}

.richtext img {
  max-width: 100%;
  height: auto;
}

.richtext figure.image {
  display: table;
  clear: both;
  margin: 1rem auto;
  max-width: 100%;
}

.richtext figure.image img {
  display: block;
  margin: 0 auto;
}

.richtext figure.image.image-style-side {
  float: right;
  margin: 0 0 1rem 1.5rem;
  max-width: 50%;
}

.richtext figure.image.image-style-align-left {
  float: left;
  margin: 0 1.5rem 1rem 0;
  max-width: 50%;
}

.richtext figure.image.image-style-align-right {
  float: right;
  margin: 0 0 1rem 1.5rem;
  max-width: 50%;
}

.richtext figure.image.image-style-align-center {
  margin-left: auto;
  margin-right: auto;
}

.richtext figure.image figcaption {
  display: table-caption;
  caption-side: bottom;
  font-size: 0.9rem;
  color: #555;
  padding-top: 0.35rem;
}

.richtext table {
  width: 100%;
  border-collapse: collapse;
}

.richtext table td,
.richtext table th {
  border: 1px solid #ccc;
  padding: 0.5rem 0.75rem;
}

.richtext blockquote {
  border-left: 4px solid var(--green, #029602);
  padding-left: 1rem;
  color: #444;
}

.richtext a {
  color: var(--green, #029602);
  text-decoration: underline;
}

.richtext::after {
  content: "";
  display: table;
  clear: both;
}

/* Compact rich text (course cards use course-outline.css for layout) */
.richtext--compact {
  margin: 0;
  padding: 0;
}

.richtext--compact > *:first-child {
  margin-top: 0 !important;
  padding-top: 0 !important;
}
