/*
 * How a rich text body looks once rendered, on every page that shows one
 * (layouts/action_text/contents/_content.html.erb wraps each in
 * .rich-text-content). It serves bodies written by Trix, which saves a <div>
 * per paragraph, and by Lexxy, which saves real <p>s.
 */
.rich-text-content {
  line-height: 1.5;
  overflow-wrap: break-word;
  word-break: break-word;
}
.rich-text-content * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
/* The reset above would run Lexxy's paragraphs together: they get the 0.6em
   gap .blog-prose p uses (decision 8). Trix's bodies keep the blank line they
   put between paragraphs, a whole line, since a <br> needs no margin
   (test/system/rich_text_contents_test.rb). */
.rich-text-content p + p {
  margin-top: 0.6em;
}
.rich-text-content h1 {
  font-size: 1.7em;
  font-weight: 900;
  line-height: 1.8;
}
.rich-text-content h2,
.rich-text-content h2 > strong {
  font-size: 1.5em;
  font-weight: 700;
  line-height: 1.6;
}
.rich-text-content blockquote {
  border: 0 solid #93c771;
  border-left-width: 0.3em;
  margin-left: 0.3em;
  padding-left: 0.6em;
  margin-top: 2rem;
  margin-bottom: 2rem;
  font-family: cursive;
  font-size: large;
}
.rich-text-content [dir="rtl"] blockquote,
.rich-text-content blockquote[dir="rtl"] {
  border-width: 0;
  border-right-width: 0.3em;
  margin-right: 0.3em;
  padding-right: 0.6em;
}
.rich-text-content ol,
.rich-text-content ul {
  margin-top: 0.5em;
  margin-bottom: 1.5em;
}
.rich-text-content ol {
  list-style-type: decimal;
}
.rich-text-content ul {
  list-style-type: disc;
}
.rich-text-content li {
  margin-left: 2rem;
}
.rich-text-content [dir="rtl"] li {
  margin-right: 2rem;
}

.rich-text-content a {
  color: #0366d6;
  text-decoration: underline;
}

.rich-text-content pre {
  display: inline-block;
  width: 100%;
  vertical-align: top;
  font-family: monospace;
  font-size: 0.9em;
  padding: 0.5em;
  white-space: pre;
  background-color: #eee;
  overflow-x: auto;
}
.rich-text-content img {
  max-width: 100%;
  height: auto;
}
.rich-text-content .attachment {
  display: inline-block;
  position: relative;
  max-width: 100%;
  margin-top: 6pt;
}
.rich-text-content .attachment a {
  color: inherit;
  text-decoration: none;
}
.rich-text-content .attachment a:hover,
.rich-text-content .attachment a:visited:hover {
  color: inherit;
}
.rich-text-content .attachment__caption {
  margin-top: 4pt;
  margin-bottom: 10pt;
  text-align: left;
}
.rich-text-content .attachment__caption::before {
  content: "❝ ";
  color: #aaa;
}
.rich-text-content
  .attachment__caption
  .attachment__name
  + .attachment__size::before {
  content: " \2022 ";
}
.rich-text-content .attachment--preview {
  width: 100%;
  text-align: center;
}
.rich-text-content .attachment--preview .attachment__caption {
  color: #666;
  font-size: 0.9em;
  line-height: 1.2;
}
.rich-text-content .attachment--file {
  color: #333;
  line-height: 1;
  margin: 0 2px 2px 2px;
  padding: 0.4em 1em;
  border: 1px solid #bbb;
  border-radius: 5px;
}
.rich-text-content .attachment-gallery {
  display: flex;
  flex-wrap: wrap;
  position: relative;
}
.rich-text-content .attachment-gallery .attachment {
  flex: 1 0 33%;
  padding: 0 0.5em;
  max-width: 33%;
}
.rich-text-content .attachment-gallery.attachment-gallery--2 .attachment,
.rich-text-content .attachment-gallery.attachment-gallery--4 .attachment {
  flex-basis: 50%;
  max-width: 50%;
}

/*
 * An <action-text-attachment> element wraps each attachment, so the gallery
 * rules above must reach it too. Otherwise, images in galleries will be
 * squished by the max-width: 33%; rule.
*/
.rich-text-content .attachment-gallery > action-text-attachment,
.rich-text-content .attachment-gallery > .attachment {
  flex: 1 0 33%;
  padding: 0 0.5em;
  max-width: 33%;
}

.rich-text-content
  .attachment-gallery.attachment-gallery--2
  > action-text-attachment,
.rich-text-content .attachment-gallery.attachment-gallery--2 > .attachment,
.rich-text-content
  .attachment-gallery.attachment-gallery--4
  > action-text-attachment,
.rich-text-content .attachment-gallery.attachment-gallery--4 > .attachment {
  flex-basis: 50%;
  max-width: 50%;
}

.rich-text-content action-text-attachment .attachment {
  padding: 0 !important;
  max-width: 100% !important;
}

/* Light-dark theme: the app's variables, so a body follows the preference. */
.rich-text-content a {
  color: var(--admin-inline-link);
}
.rich-text-content blockquote {
  border-left-color: var(--border);
}
.rich-text-content pre {
  background-color: var(--surface);
  border: 1px solid var(--border);
  color: var(--page-text);
}
.rich-text-content .attachment--file {
  color: var(--page-text);
  border-color: var(--border);
}
.rich-text-content .attachment--preview .attachment__caption {
  color: var(--text-muted);
}
