/* Attachments */
action-text-attachment {
  display: contents;

  img {
    display: initial;

    &.external-inline {
      max-width: 100%;

      &:not([height]) {
        height: auto;
      }
    }
  }
}

.attachment {
  display: inline-block;
  padding: 0;

  a,
  a:hover,
  a:visited:hover {
    color: inherit;
    text-decoration: none;
  }
}

.attachment--preview:not(.attachment--remote) {
  width: 100%;
  text-align: center;
  margin: 0.625em 0;

  img {
    border: 1px solid var(--color-border);
    vertical-align: middle;
    width: auto;
    max-width: calc(100% - 2px);
    max-height: 64rem;
  }
}

.attachment--lightboxable img {
  cursor: zoom-in;
}

.attachment.attachment--remote {
  display: inline;

  .attachment__caption {
    display: none;
  }
}

.attachment--file {
  &.attachment--linked,
  &.attachment--downloadable,
  action-text-attachment & {
    background-color: var(--color-bg--surface-glint);
    border-radius: 10px;
    position: relative;
    width: calc(100% / 4 - 10px);
    border: 0;
    padding: 0 !important;
    margin: 0 6px 6px 0 !important;
    min-width: 150px; /* Uses pixels to avoid font scaling factor breakage */
    max-width: 200px;

    .attachment__name {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      display: block;
    }

    &::before {
      content: "";
      display: block;
      padding-top: 45%;
    }

    &::after {
      background: url("/assets/icons/attachments/text-files-3de18e47.svg") center 1.5em / 25% no-repeat;
      content: "";
      position: absolute;
      top: 0;
      left: 0;
      bottom: 0;
      right: 0;
      z-index: 0;
    }

    [data-color-scheme="dark"] & {
      &::after {
        background-image: url("/assets/icons/attachments/text-files-reverse-98788575.svg");
      }
    }

    &.attachment--jpg,
    &.attachment--jpeg,
    &.attachment--png,
    &.attachment--gif,
    &.attachment--psd {
      &::after { background-image: url("/assets/icons/attachments/images-1346058e.svg"); }

      [data-color-scheme="dark"] & {
        &::after { background-image: url("/assets/icons/attachments/images-reverse-6850a029.svg"); }
      }
    }

    &.attachment--pdf {
      &::after { background-image: url("/assets/icons/attachments/pdfs-770c85af.svg"); }

      [data-color-scheme="dark"] & {
        &::after { background-image: url("/assets/icons/attachments/pdfs-reverse-2044372c.svg"); }
      }
    }

    &.attachment--doc,
    &.attachment--docx,
    &.attachment--pages,
    &.attachment--txt,
    &.attachment--odt {
      &::after { background-image: url("/assets/icons/attachments/documents-8d1a51da.svg"); }

      [data-color-scheme="dark"] & {
        &::after { background-image: url("/assets/icons/attachments/documents-reverse-9d480bc8.svg"); }
      }
    }

    &.attachment--csv,
    &.attachment--xls,
    &.attachment--xlsx,
    &.attachment--numbers,
    &.attachment--ods {
      &::after { background-image: url("/assets/icons/attachments/spreadsheets-d281f477.svg"); }

      [data-color-scheme="dark"] & {
        &::after { background-image: url("/assets/icons/attachments/spreadsheets-reverse-b7f87f5a.svg"); }
      }
    }

    &.attachment--ppt,
    &.attachment--pptx,
    &.attachment--keynote,
    &.attachment--odp {
      &::after { background-image: url("/assets/icons/attachments/presentations-2b1f45a9.svg"); }

      [data-color-scheme="dark"] & {
        &::after { background-image: url("/assets/icons/attachments/presentations-reverse-7001fa33.svg"); }
      }
    }

    &.attachment--mp4,
    &.attachment--mov,
    &.attachment--avi,
    &.attachment--mp3,
    &.attachment--m4v {
      &::after { background-image: url("/assets/icons/attachments/media-515be8c6.svg"); }

      [data-color-scheme="dark"] & {
        &::after { background-image: url("/assets/icons/attachments/media-reverse-c78b46f9.svg"); }
      }
    }

    &.attachment--zip,
    &.attachment--rar {
      &::after { background-image: url("/assets/icons/attachments/zip-files-600aa33c.svg"); }

      [data-color-scheme="dark"] & {
        &::after { background-image: url("/assets/icons/attachments/zip-files-reverse-df04b400.svg"); }
      }
    }

    &.attachment--ics {
      &::after { background-image: url("/assets/icons/attachments/calendar-invites-ee74786b.svg"); }

      [data-color-scheme="dark"] & {
        &::after { background-image: url("/assets/icons/attachments/calendar-invites-reverse-9150369e.svg"); }
      }
    }
  }
}

.attachment__caption {
  color: var(--color--txt);
  margin: 0.625em 1.25em;
  text-align: center;
  font-weight: 500;
  font-size: 0.875em;
  line-height: 1.2;

  @media (min-width: 40em) {
    font-size: 0.75em;
    line-height: 1.3;
  }

  .attachment__name,
  .attachment__source {
    display: block;
  }

  .attachment__name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .attachment__source {
    font-weight: normal;
    max-height: 2.6em;
    padding-bottom: 0.2em;
    overflow-y: hidden;
  }

  .attachment__size {
    color: var(--color-txt--subtle-on-message-content);
    font-weight: normal;
  }

  .attachment--preview & {
    .attachment__name { display: inline; white-space: normal; }
    .attachment__name + .attachment__size::before { content: ' · '; }
  }

  .attachment--file & {
    .attachment__name + .attachment__size::before { content: ''; }
  }
}

.attachment__file-link {
  inset: 0;
  position: absolute;
  text-indent: -9999em;
  z-index: 1;
}

.attachment-gallery {
  display: flex;
  flex-wrap: wrap;
  position: relative;
  gap: 4px;

  .attachment {
    flex: 1 0 33%;
    margin: 0 0 1em;
    max-width: calc(33% - 10px);
  }

  &.attachment-gallery--2,
  &.attachment-gallery--4 {
    .attachment {
      flex-basis: 50%;
      max-width: calc(50% - 10px);
    }
  }
}

/* Base */
.trix-content > .__body {
  overflow: visible !important;
  height: initial !important;
  min-height: 1rem;
}

* {
  /* CSS transitions can affect the email height. This can break our geometry
   * calculations with Javascript. See +MessageContentContext.performMeasurement+.
   * Not removing transitions completely because emails can rely on their final state
   * to look ok, so we just set a 0 duration for them. */
  transition-duration: 0s !important;
}

h1 {
  font-size: 1.3em;
  line-height: 1.2;
  margin: 0 0 0.5em;
}

ul,
ol {
  margin: 0;
}

ul li,
ol li,
li li {
  padding: 0;
  margin: 0;
}

pre {
  display: inline-block;
  width: 100%;
  vertical-align: top;
  font-family: monospace;
  font-size: 0.9em;
  margin: 0;
  padding: 0.5em 2%;
  white-space: pre-wrap;
  background-color: var(--color-bg--surface);
  overflow-x: auto;
  border-radius: 4px;
  box-sizing: border-box;
}

a {
  color: var(--color-txt--action-on-message-content);

  /* Use foreground colors, if applied via color-picker */
  [style*="color"] {
    text-decoration: underline !important;
    text-decoration-color: unset !important;
  }
}

table {
  border-color: transparent;
}

hr {
  border: 0;
  border-bottom: 1px solid var(--color-border);
}

.email_img {
  width: auto;
  max-width: 99%;
  border: 1px solid var(--color-border);
}

img:not([width]):not([height]) {
  min-width: 1px;
  min-height: 1px;
}

/* Fix instances where RTL characters are cut off */
div[dir="rtl"] {
  line-height: normal;
}

/* Quotes */

blockquote {
  margin: 0;
  padding-block: 0;
  padding-inline-end: 0;
  padding-inline-start: 0.66em;
  border-inline-start: 1px solid var(--color-border);
}

.hey-quote {
  summary {
    list-style: none;
    outline: none;
    cursor: pointer;

    @media print {
      display: none;
    }

    &::-webkit-details-marker {
      display: none;
    }

    &:focus-visible::before {
      outline: none;
      box-shadow: 0 0 0 2px var(--color-focus-ring);
    }

    &::before {
      content: "Show quote";
      display: inline-flex;
      border-radius: 1.5rem;
      margin: 0.75em 0 2px 2px;
      width: 1.75rem;
      height: 1.75rem;
      background: url("/assets/icons/quote-0794c2a3.svg") center / 100% no-repeat;
      overflow: hidden;
      text-indent: -9999rem;
    }

    @media (min-width: 40em) {
      &::before {
        width: 1.5rem;
        height: 1.5rem;
      }
    }
  }

  &[open] > summary::before {
    margin-bottom: 1rem;
    background-image: url("/assets/icons/quote-open-6cf672b1.svg");
  }
}

/* Syntax highlighting */
.highlight table td { padding: 5px; }
.highlight table pre { margin: 0; }
.highlight .cm {
  color: #999988;
  font-style: italic;
}
.highlight .cp {
  color: #999999;
  font-weight: bold;
}
.highlight .c1 {
  color: #999988;
  font-style: italic;
}
.highlight .cs {
  color: #999999;
  font-weight: bold;
  font-style: italic;
}
.highlight .c, .highlight .ch, .highlight .cd, .highlight .cpf {
  color: #999988;
  font-style: italic;
}
.highlight .err {
  color: #a61717;
  background-color: #e3d2d2;
}
.highlight .gd {
  color: #000000;
  background-color: #ffdddd;
}
.highlight .ge {
  color: #000000;
  font-style: italic;
}
.highlight .gr {
  color: #aa0000;
}
.highlight .gh {
  color: #999999;
}
.highlight .gi {
  color: #000000;
  background-color: #ddffdd;
}
.highlight .go {
  color: #888888;
}
.highlight .gp {
  color: #555555;
}
.highlight .gs {
  font-weight: bold;
}
.highlight .gu {
  color: #aaaaaa;
}
.highlight .gt {
  color: #aa0000;
}
.highlight .kc {
  color: #000000;
  font-weight: bold;
}
.highlight .kd {
  color: #000000;
  font-weight: bold;
}
.highlight .kn {
  color: #000000;
  font-weight: bold;
}
.highlight .kp {
  color: #000000;
  font-weight: bold;
}
.highlight .kr {
  color: #000000;
  font-weight: bold;
}
.highlight .kt {
  color: #445588;
  font-weight: bold;
}
.highlight .k, .highlight .kv {
  color: #000000;
  font-weight: bold;
}
.highlight .mf {
  color: #009999;
}
.highlight .mh {
  color: #009999;
}
.highlight .il {
  color: #009999;
}
.highlight .mi {
  color: #009999;
}
.highlight .mo {
  color: #009999;
}
.highlight .m, .highlight .mb, .highlight .mx {
  color: #009999;
}
.highlight .sa {
  color: #000000;
  font-weight: bold;
}
.highlight .sb {
  color: #d14;
}
.highlight .sc {
  color: #d14;
}
.highlight .sd {
  color: #d14;
}
.highlight .s2 {
  color: #d14;
}
.highlight .se {
  color: #d14;
}
.highlight .sh {
  color: #d14;
}
.highlight .si {
  color: #d14;
}
.highlight .sx {
  color: #d14;
}
.highlight .sr {
  color: #009926;
}
.highlight .s1 {
  color: #d14;
}
.highlight .ss {
  color: #990073;
}
.highlight .s, .highlight .dl {
  color: #d14;
}
.highlight .na {
  color: #008080;
}
.highlight .bp {
  color: #999999;
}
.highlight .nb {
  color: #0086B3;
}
.highlight .nc {
  color: #445588;
  font-weight: bold;
}
.highlight .no {
  color: #008080;
}
.highlight .nd {
  color: #3c5d5d;
  font-weight: bold;
}
.highlight .ni {
  color: #800080;
}
.highlight .ne {
  color: #990000;
  font-weight: bold;
}
.highlight .nf, .highlight .fm {
  color: #990000;
  font-weight: bold;
}
.highlight .nl {
  color: #990000;
  font-weight: bold;
}
.highlight .nn {
  color: #555555;
}
.highlight .nt {
  color: #000080;
}
.highlight .vc {
  color: #008080;
}
.highlight .vg {
  color: #008080;
}
.highlight .vi {
  color: #008080;
}
.highlight .nv, .highlight .vm {
  color: #008080;
}
.highlight .ow {
  color: #000000;
  font-weight: bold;
}
.highlight .o {
  color: #000000;
  font-weight: bold;
}
.highlight .w {
  color: #bbbbbb;
}
.highlight {
  color: var(--color-always-black);
  background-color: #f8f8f8;
}

/* Third party patches */
/* CKeditor bug in Safari. See https://3.basecamp.com/2914079/buckets/27/card_tables/cards/7848395051 */
.ck-content .table table {
  height: auto !important;
}

/* brevo.com. See https://3.basecamp.com/2914079/buckets/27/card_tables/cards/8115510298 */
.nl2go-body-table table[width='900'] {
  width: 100% !important;
}