/*
 * Provides a drop-in pointer for the default Trix stylesheet that will format the toolbar and
 * the trix-editor content (whether displayed or under editing). Feel free to incorporate this
 * inclusion directly in any other asset bundle and remove this file.
 *
 *= require trix
*/

/*
 * We need to override trix.css’s image gallery styles to accommodate the
 * <action-text-attachment> element we wrap around attachments. Otherwise,
 * images in galleries will be squished by the max-width: 33%; rule.
*/
.trix-content .attachment-gallery > action-text-attachment,
.trix-content .attachment-gallery > .attachment {
  flex: 1 0 33%;
  padding: 0 0.5em;
  max-width: 33%;
}

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

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

.trix-content {
  position: absolute;
  top: 4rem;
  left: 0;
  right: 0;
  bottom: 0;
  border: 0;
  padding: 2rem;
  outline: 0;
  overflow: auto;
}

.trix-button-group.trix-button-group--file-tools {
  display: none;
}

/* Custom styles for Tajo */

.trix--fullscreen .trix-content {
  position: absolute;
  top: 4rem;
  left: 0;
  right: 0;
  bottom: 0;
  border: 0;
  padding: 2rem;
  outline: 0;
  overflow: auto;
}

.trix--white .trix-button {
  background: white;
}

.trix--for-email .trix-button--icon-strike,
.trix--for-email .trix-button--icon-quote,
.trix--for-email .trix-button--icon-code,
.trix--for-email .trix-button--icon-heading-1,
.trix--for-email .trix-button--icon-decrease-nesting-level,
.trix--for-email .trix-button--icon-increase-nesting-level {
  display: none;
}

.trix--simple .trix-button--icon-strike,
.trix--simple .trix-button--icon-link,
.trix--simple .trix-button--icon-quote,
.trix--simple .trix-button--icon-code,
.trix--simple .trix-button--icon-decrease-nesting-level,
.trix--simple .trix-button--icon-increase-nesting-level {
  display: none;
}

.trix--minimal .trix-button--icon-strike,
.trix--minimal .trix-button--icon-link,
.trix--minimal .trix-button--icon-quote,
.trix--minimal .trix-button--icon-code,
.trix--minimal .trix-button--icon-decrease-nesting-level,
.trix--minimal .trix-button--icon-increase-nesting-level,
.trix--minimal .trix-button--icon-heading-1,
.trix--minimal .trix-button-group--history-tools {
  display: none;
}

/* Announcement editor (Lexxy, see RichTextEditorComponent) */
.rich-text-editor {
  --lexxy-font-base: Rubik, sans-serif;
  --lexxy-color-ink: #292524;
  --lexxy-color-ink-medium: #57534e;
  --lexxy-color-ink-light: #a8a29e;
  --lexxy-color-ink-lighter: #e7e5e4;
  --lexxy-color-ink-lightest: #f5f5f4;
  --lexxy-color-accent-dark: var(--color-ocean-600);
  --lexxy-color-accent-medium: var(--color-ocean-500);
  --lexxy-color-accent-light: var(--color-ocean-100);
  --lexxy-color-accent-lightest: var(--color-ocean-50);
  --lexxy-color-link: var(--color-ocean-600);
  --lexxy-focus-ring-color: var(--color-ocean-500);
  --lexxy-radius: .5rem;
  --lexxy-toolbar-button-size: 2.25rem;
  --lexxy-shadow: 0 12px 30px rgb(28 25 23 / 15%), 0 2px 6px rgb(28 25 23 / 8%);

  position: relative;
  border: 1px solid #e7e5e4;
  border-radius: 1rem;
  background: white;
}

.rich-text-editor:focus-within {
  border-color: var(--color-ocean-500);
  box-shadow: 0 0 0 3px var(--color-ocean-100);
}

.rich-text-editor lexxy-editor {
  --lexxy-editor-padding: 1.25rem 1.5rem;
  --lexxy-editor-rows: 22rem;
  display: block;
  border: 0;
  border-radius: 1rem;
}

.rich-text-editor--fill,
.rich-text-editor--fill lexxy-editor {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.rich-text-editor--fill lexxy-editor { flex: 1; }
.rich-text-editor--fill .lexxy-editor__content { flex: 1; }

.rich-text-editor lexxy-toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: .5rem .75rem;
  border-bottom: 1px solid #f5f5f4;
  border-radius: 1rem 1rem 0 0;
  background: white;
}

/* Floating toolbar: the surrounding card is the frame, formatting buttons float above selected text and
   blocks (lists, tables, uploads, emojis) are inserted through the slash menu. */
.rich-text-editor--floating-toolbar,
.rich-text-editor--floating-toolbar:focus-within {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}

.rich-text-editor.rich-text-editor--floating-toolbar lexxy-editor {
  --lexxy-editor-padding: 0;
}

.rich-text-editor.rich-text-editor--floating-toolbar lexxy-toolbar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 50;
  width: max-content;
  max-width: calc(100vw - 16px);
  padding: .25rem;
  border: 1px solid #e7e5e4;
  border-radius: .75rem;
  box-shadow: var(--lexxy-shadow);
}

.rich-text-editor--floating-toolbar lexxy-toolbar:not([data-floating-visible]) {
  visibility: hidden;
  pointer-events: none;
}

/* Dropdowns in the same frame as the floating toolbar */
.rich-text-editor lexxy-toolbar [data-dropdown-panel] {
  border: 1px solid #e7e5e4;
  border-radius: .75rem;
}

.rich-text-editor lexxy-toolbar [data-dropdown-panel] button:focus {
  outline: none;
}

.rich-text-editor lexxy-toolbar [data-dropdown-panel] button:focus-visible {
  background-color: #f5f5f4;
}

/* Format menu: one line per entry, icons in a column so the labels line up */
.rich-text-editor lexxy-toolbar .lexxy-editor__toolbar-dropdown-list {
  min-width: 13rem;
  padding: .25rem;
}

.rich-text-editor lexxy-toolbar .lexxy-editor__toolbar-dropdown-list button {
  justify-content: flex-start;
  gap: .75rem;
  width: 100%;
  padding: .5rem .75rem;
  border-radius: .5rem;
  text-align: start;
  white-space: nowrap;
}

.rich-text-editor lexxy-toolbar .lexxy-editor__toolbar-dropdown-list button > :first-child {
  flex: none;
  width: 1.5rem;
  text-align: center;
}

.rich-text-editor lexxy-toolbar .lexxy-editor__toolbar-dropdown-list button > :last-child {
  flex: 1;
  text-align: start;
}

.rich-text-editor lexxy-toolbar .lexxy-editor__toolbar-dropdown-list button svg {
  margin-inline: auto;
}

.rich-text-editor lexxy-toolbar .lexxy-editor__toolbar-dropdown-list .lexxy-editor__toolbar-separator {
  margin-block: .25rem;
}

/* Link dialog: wide enough for an address, positioned by the rich-text-editor controller */
.rich-text-editor lexxy-toolbar .lexxy-editor__toolbar-dropdown--link [data-dropdown-panel] {
  inset-inline-end: auto;
  width: min(26rem, calc(100vw - 16px));
  margin-top: .375rem;
  padding: .375rem;
  gap: .375rem;
}

.rich-text-editor lexxy-toolbar .lexxy-editor__toolbar-dropdown--link input {
  flex: 1;
  min-width: 0;
  padding-inline: .75rem;
  border-color: #d6d3d1;
}

.rich-text-editor lexxy-toolbar .lexxy-editor__toolbar-dropdown--link input:focus {
  outline: none;
  border-color: var(--color-ocean-500);
  box-shadow: 0 0 0 3px var(--color-ocean-100);
}

.rich-text-editor lexxy-toolbar .lexxy-editor__toolbar-dropdown--link .lexxy-editor__toolbar-dropdown-actions {
  flex: none;
}

.rich-text-editor lexxy-toolbar .lexxy-editor__toolbar-dropdown--link button {
  width: auto;
  padding-inline: .875rem;
  border-radius: 9999px;
  font-weight: 600;
  white-space: nowrap;
}

.rich-text-editor lexxy-toolbar .lexxy-editor__toolbar-dropdown--link button[value="link"] {
  background-color: var(--color-forest-500);
  color: white;
}

.rich-text-editor lexxy-toolbar .lexxy-editor__toolbar-dropdown--link button[value="link"]:hover {
  background-color: var(--color-forest-600);
}

.rich-text-editor lexxy-toolbar .lexxy-editor__toolbar-dropdown--link button[value="unlink"] {
  background-color: transparent;
  color: var(--color-stone-500);
}

.rich-text-editor lexxy-toolbar .lexxy-editor__toolbar-dropdown--link button[value="unlink"]:hover {
  background-color: #f5f5f4;
}

.rich-text-editor--floating-toolbar lexxy-toolbar :is(button[name="unordered-list"], button[name="ordered-list"], button[name="table"], button[name="image"], button[name="file"], button[name="emoji"], .lexxy-editor__toolbar-overflow) {
  display: none;
}

/* Undo and redo stay on Cmd/Ctrl+Z, quote and divider in the slash menu. */
.rich-text-editor lexxy-toolbar :is(button[name="undo"], button[name="redo"], button[name="quote"], button[name="divider"]) {
  display: none;
}

.rich-text-editor svg.rich-text-emoji-icon {
  fill: none;
}

.rich-text-editor svg.rich-text-emoji-icon circle {
  fill: currentColor;
}

.rich-text-editor .lexxy-editor__content {
  line-height: 1.7;
}

/* Table tools in Tajo's dropdown style instead of Lexxy's dark pills */
.rich-text-editor lexxy-table-tools {
  --lexxy-color-ink: white;
  --lexxy-color-ink-inverted: #44403c;
  --lexxy-color-ink-medium: #f5f5f4;
  --lexxy-color-floating-controls-separator: #e7e5e4;
}

.rich-text-editor lexxy-table-tools .lexxy-floating-controls__group {
  border: 1px solid #e7e5e4;
  box-shadow: 0 4px 12px rgb(28 25 23 / 10%);
}

.rich-text-slash-menu,
.rich-text-emoji-picker {
  position: fixed;
  z-index: 1100;
  background: #fff;
  border: 1px solid #e7e5e4;
  border-radius: .75rem;
  box-shadow: 0 12px 30px rgb(28 25 23 / 15%), 0 2px 6px rgb(28 25 23 / 8%);
}

.rich-text-slash-menu[hidden],
.rich-text-emoji-picker[hidden],
.rich-text-emoji-picker [hidden] {
  display: none;
}

.rich-text-slash-menu {
  width: min(16rem, calc(100vw - 16px));
  max-height: min(30rem, 70vh);
  overflow-y: auto;
  padding: .35rem;
}

.rich-text-slash-separator {
  margin: .35rem .5rem;
  border-top: 1px solid #e7e5e4;
}

.rich-text-slash-option {
  display: flex;
  align-items: center;
  gap: .75rem;
  width: 100%;
  padding: .45rem .6rem;
  border: 0;
  border-radius: .45rem;
  background: transparent;
  color: #292524;
  text-align: left;
  cursor: pointer;
}

.rich-text-slash-option:hover,
.rich-text-slash-option[aria-selected="true"] {
  background: #f5f5f4;
}

.rich-text-slash-icon {
  display: inline-flex;
  justify-content: center;
  width: 1.5rem;
  color: #78716c;
  font-size: .8rem;
  font-weight: 600;
}

.rich-text-slash-icon svg {
  width: 1.125rem;
  height: 1.125rem;
  fill: currentColor;
}



.rich-text-emoji-picker {
  display: flex;
  flex-direction: column;
  width: min(20rem, calc(100vw - 16px));
  height: min(22rem, 60vh);
  padding: .5rem;
}

.rich-text-emoji-search {
  width: 100%;
  margin-bottom: .5rem;
  padding: .45rem .65rem;
  border: 1px solid #e7e5e4;
  border-radius: .5rem;
  font-size: .875rem;
}

.rich-text-emoji-search:focus {
  border-color: var(--color-ocean-500);
  outline: none;
  box-shadow: 0 0 0 2px var(--color-ocean-100);
}

.rich-text-emoji-groups {
  flex: 1;
  overflow-y: auto;
}

.rich-text-emoji-heading {
  padding: .5rem .25rem .25rem;
  color: #78716c;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.rich-text-emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(2.25rem, 1fr));
}

.rich-text-emoji {
  height: 2.25rem;
  border-radius: .4rem;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.rich-text-emoji:hover,
.rich-text-emoji:focus-visible {
  background: #f5f5f4;
  outline: none;
}

.rich-text-emoji-empty {
  padding: 1rem .25rem;
  color: #78716c;
  font-size: .875rem;
  text-align: center;
}

/* Announcement content, shared by the editor and the announcement pages */
/* Body headings stay smaller than the announcement title above them. */
.rich-text-editor .lexxy-editor__content h1,
.rich-text-content .trix-format h1 { margin: 1.5rem 0 .75rem; font-size: 1.375rem; line-height: 1.3; font-weight: 600; }
.rich-text-editor .lexxy-editor__content h2,
.rich-text-content .trix-format h2 { margin: 1.25rem 0 .5rem; font-size: 1.1875rem; line-height: 1.35; font-weight: 600; }
.rich-text-editor .lexxy-editor__content h3,
.rich-text-content .trix-format h3 { margin: 1rem 0 .5rem; font-size: 1.0625rem; line-height: 1.4; font-weight: 600; }
.rich-text-editor .lexxy-editor__content hr,
.rich-text-content .trix-format hr { width: 100%; margin: 1.5rem 0; border: 0; border-top: 1px solid #e7e5e4; }
.rich-text-content .trix-format { color: #292524; line-height: 1.7; }
.rich-text-content .trix-format :is(ul, ol) { margin: 0 0 .75rem; padding-left: 1.5rem; }
.rich-text-content .trix-format ul { list-style: disc; }
.rich-text-content .trix-format ol { list-style: decimal; }
.rich-text-content .trix-format li { margin: .125rem 0; padding: 0; }
.rich-text-content .trix-format li::marker { color: inherit; }
.rich-text-content .trix-format :is(h1, h2, h3, strong, th) { color: inherit; }
.rich-text-editor .lexxy-editor__content > :first-child,
.rich-text-content .trix-format > :first-child { margin-top: 0; }
.rich-text-content .trix-format p { margin: 0 0 .75rem; }
.rich-text-content .trix-format mark { background: transparent; color: inherit; }
.rich-text-content .trix-format figure.lexxy-content__table-wrapper { margin: 1rem 0; overflow-x: auto; }
.rich-text-content .trix-format table { width: 100%; margin: 0; border-collapse: collapse; font-size: .9375rem; }
.rich-text-content .trix-format th,
.rich-text-content .trix-format td { padding: .5rem .75rem; border: 1px solid #e7e5e4; text-align: left; vertical-align: top; }
.rich-text-content .trix-format th { background: #f5f5f4; font-weight: 600; }
.rich-text-content .trix-format th > p,
.rich-text-content .trix-format td > p { margin: 0; }

/* Images: no file name below them, and a size (small, normal, full width) and alignment (left, centered, right) chosen
   in the editor's image toolbar (rich_text_editor/image_layout.js), saved as data-size and data-align. The editor marks
   images with data-image (PDF previews keep their name). On the page, only images with data-size are sized, so Trix
   content, gallery images and images saved before this keep their old layout. */
.rich-text-editor figure[data-image]:not(.node--selected) > .attachment__caption--editable[data-placeholder] { display: none; }
.rich-text-editor figure[data-image] > .attachment__caption--editable[data-placeholder] .attachment__caption-text { font-size: 0; }
.rich-text-editor figure[data-image] > .attachment__caption--editable[data-placeholder] .attachment__caption-text::before {
  content: "Bildunterschrift hinzufügen";
  color: #a8a29e;
  font-size: var(--lexxy-text-small);
}

.rich-text-editor .lexxy-editor__content > figure[data-image] { max-inline-size: 66.667%; }
.rich-text-editor .lexxy-editor__content > figure[data-image] img { max-block-size: none; }
.rich-text-editor .lexxy-editor__content > figure[data-image][data-size="small"] { max-inline-size: 33.333%; }
.rich-text-editor .lexxy-editor__content > figure[data-image][data-size="full"] { inline-size: 100%; max-inline-size: 100%; }
.rich-text-editor .lexxy-editor__content > figure[data-image][data-size="full"] img { inline-size: 100%; }
.rich-text-editor .lexxy-editor__content > figure[data-image][data-align="left"] { margin-inline: 0 auto; }
.rich-text-editor .lexxy-editor__content > figure[data-image][data-align="right"] { margin-inline: auto 0; }

.rich-text-content action-text-attachment[data-size]:not(.attachment-gallery > *) { display: block; }
.rich-text-content action-text-attachment[data-size]:not(.attachment-gallery > *) > figure.attachment--preview {
  width: fit-content;
  max-width: 66.667%;
  margin: 1.25rem auto;
}
.rich-text-content action-text-attachment[data-size]:not(.attachment-gallery > *) > figure.attachment--preview img { display: block; max-width: 100%; height: auto; margin: 0; border-radius: .5rem; }
.rich-text-content action-text-attachment[data-size="small"]:not(.attachment-gallery > *) > figure.attachment--preview { max-width: 33.333%; }
.rich-text-content action-text-attachment[data-size="full"]:not(.attachment-gallery > *) > figure.attachment--preview { width: 100%; max-width: 100%; }
.rich-text-content action-text-attachment[data-size="full"]:not(.attachment-gallery > *) > figure.attachment--preview img { width: 100%; }
.rich-text-content action-text-attachment[data-size][data-align="left"]:not(.attachment-gallery > *) > figure.attachment--preview { margin-left: 0; }
.rich-text-content action-text-attachment[data-size][data-align="right"]:not(.attachment-gallery > *) > figure.attachment--preview { margin-right: 0; }
.rich-text-content .attachment--preview .attachment__caption { margin-top: .5rem; color: #78716c; font-size: .875rem; text-align: center; }

/* The size and alignment buttons, before Lexxy's alternative text and remove buttons */
.rich-text-editor lexxy-attachment-toolbar { gap: .5rem; }
.rich-text-editor .rich-text-image-layout[hidden] { display: none; }
.rich-text-editor .rich-text-image-layout { align-items: center; }
.rich-text-editor .rich-text-image-layout button svg { width: 1.25rem; height: 1.25rem; fill: none; }
.rich-text-editor .rich-text-image-layout button svg .filled { fill: currentColor; stroke: none; }
.rich-text-editor .rich-text-image-layout button[aria-pressed="true"] { background: var(--lexxy-color-ink-medium); }
.rich-text-editor .rich-text-image-layout button[hidden] { display: none; }
.rich-text-editor .rich-text-image-layout__separator { width: 1px; height: 1.25em; margin-inline: .375rem; background: #78716c; }
.rich-text-editor .rich-text-image-layout__separator[hidden] { display: none; }

@media (max-width: 640px) {
  /* Above the image instead of over it, so it stays on screen next to a small image; alignment matters little here */
  .rich-text-editor lexxy-attachment-toolbar[data-image-layout] {
    --button-size: 2.5rem;
    left: max(0px, var(--lexxy-anchor-left));
    transform: translateY(calc(-100% - .375rem));
  }
  .rich-text-editor .rich-text-image-layout :is([data-align], .rich-text-image-layout__separator) { display: none; }
  .rich-text-editor .lexxy-editor__content > figure[data-image] { max-inline-size: 100%; }
  .rich-text-editor .lexxy-editor__content > figure[data-image][data-size="small"] { max-inline-size: 50%; }
  .rich-text-content action-text-attachment[data-size]:not(.attachment-gallery > *) > figure.attachment--preview { max-width: 100%; }
  .rich-text-content action-text-attachment[data-size="small"]:not(.attachment-gallery > *) > figure.attachment--preview { max-width: 50%; }
}

@media (max-width: 640px) {
  .rich-text-editor lexxy-editor {
    --lexxy-editor-padding: 1rem;
    --lexxy-editor-rows: 16rem;
  }

  .rich-text-editor lexxy-toolbar { padding: .375rem .5rem; }
}

/* Refactor this so that Trix can be used in various contexts */
trix-editor h1,
.trix-format h1 {
  font-size: 1.25rem;
  line-height: 1.5rem;
  margin-bottom: 1rem;
  font-weight: 700;
}

trix-editor p,
.trix-format p {
  margin-bottom: 1rem;
}

trix-editor ul,
.trix-format ul {
  list-style-position: inside;
  list-style-type: disc;
}

trix-editor ol,
.trix-format ol {
  list-style-position: inside;
  list-style-type: decimal;
}

trix-editor a,
.trix-format a {
  text-decoration: underline;
  color: blue;
}

trix-editor {
  overflow: auto;
}

/* Previews of content blocks in the editor (see content_blocks/_content_block) */
lexxy-editor action-text-attachment[content-type="application/vnd.actiontext.content-block"] {
  display: block;
  margin: 0.75rem 0;
  border: 1px solid var(--color-stone-200);
  border-left: 4px solid var(--color-ocean-500);
  border-radius: 0.75rem;
  background: var(--color-stone-50);
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  line-height: 1.5;
}

lexxy-editor action-text-attachment[content-type="application/vnd.actiontext.content-block"] p { margin: 0; }
lexxy-editor action-text-attachment[content-type="application/vnd.actiontext.content-block"] p + p { margin-top: 0.25rem; color: var(--color-stone-600); }
lexxy-editor action-text-attachment[content-type="application/vnd.actiontext.content-block"] a { color: var(--color-ocean-700); font-weight: 600; cursor: pointer; }

.rich-text-slash-group {
  padding: .35rem .6rem .15rem;
  color: #78716c;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .02em;
}

/* A block card opens its form on a click; the link is a small action at the top right */
lexxy-editor action-text-attachment[content-type="application/vnd.actiontext.content-block"] {
  position: relative;
  cursor: pointer;
  padding-right: 6.5rem;
}

lexxy-editor action-text-attachment[content-type="application/vnd.actiontext.content-block"]:hover { border-color: var(--color-ocean-300); }
lexxy-editor action-text-attachment[content-type="application/vnd.actiontext.content-block"] p:last-child { position: absolute; top: .7rem; right: 1rem; margin: 0; }
lexxy-editor action-text-attachment[content-type="application/vnd.actiontext.content-block"] p:last-child a { text-decoration: none; font-size: .875rem; }
lexxy-editor action-text-attachment[content-type="application/vnd.actiontext.content-block"] :is(ol, ul) { margin: .25rem 0 0; padding-left: 1.25rem; color: var(--color-stone-600); }
lexxy-editor action-text-attachment[content-type="application/vnd.actiontext.content-block"] ol { list-style: decimal; }
lexxy-editor action-text-attachment[content-type="application/vnd.actiontext.content-block"] ul { list-style: disc; }

/* The only entry of a block's list can't be removed */
.content-block-item:only-child .content-block-item-remove { visibility: hidden; }

/* Translating a page: the blocks in the text are the original's and get translated below the editor,
   so their previews can't be opened from the text */
.academy-translation-editor action-text-attachment a,
.academy-translation-editor action-text-attachment :is(p, ul, ol):not(:first-child) {
  display: none;
}

.academy-translation-editor action-text-attachment p:first-child::after {
  content: " · Text unten übersetzen";
  font-weight: 400;
  color: var(--color-stone-500);
}
