/*
 * 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 iframe[src*="youtube"] {
	margin: 12px 0;
	width: 100% !important;
	height: 100% !important;
  aspect-ratio: 560 / 310;
}

@media (min-width: 560px) {
	.trix-content iframe[src*="youtube"] {
		width: 560px !important;
		height: 315px !important;
	}
}

trix-editor .attachment iframe[src*="youtube"] {
	margin: 12px auto;
	width: 100% !important;
	height: 100% !important;
  aspect-ratio: 560 / 310;
}

@media (min-width: 560px) {
	trix-editor .attachment iframe[src*="youtube"] {
		width: 560px !important;
		height: 315px !important;
	}
}

trix-editor .attachment blockquote.twitter-tweet {
  display: block;
  font-family: "Helvetica Neue", Roboto, "Segoe UI", Calibri, sans-serif;
  font-size: 12px;
  font-weight: bold;
  line-height: 16px;
  border-color: #eee #ddd #bbb;
  border-radius: 5px;
  border-style: solid;
  border-width: 1px;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.15);
  margin: 10px 5px;
  padding: 16px 16px 16px 16px;
  max-width: 468px;
}
trix-editor .attachment blockquote.twitter-tweet p {
  font-size: 16px;
  font-weight: normal;
  line-height: 20px;
}
trix-editor .attachment blockquote.twitter-tweet a {
  color: inherit;
  font-weight: normal;
  text-decoration: none;
  outline: 0 none;
}
trix-editor .attachment blockquote.twitter-tweet a:hover,
trix-editor .attachment blockquote.twitter-tweet a:focus {
  text-decoration: underline;
}

trix-editor .attachment--preview {
  margin: 12px 0;
  border: 1px dotted #aeaeae;
  padding: 4px;
}

/* Trixの画像横のカーソルターゲットでのIMEコンポジション崩れを防ぐ */
trix-editor span[data-trix-cursor-target] {
  white-space: nowrap !important;
  display: inline-block;
  width: 1px; /* ゼロ幅だとIMEがバグりやすいため1pxの幅を持たせる */
}

/* oEmbed が link を返した URL は、記事内でブログカードとして表示する。 */
.trix-content .embed-link-card,
trix-editor .embed-link-card {
  display: flex;
  overflow: hidden;
  margin: 1.5rem 0;
  border: 1px solid rgb(203 213 225);
  color: rgb(30 41 59);
  background: white;
  text-decoration: none;
}

trix-editor .embed-link-card {
  cursor: text;
}

.trix-content .embed-link-card:hover,
.trix-content .embed-link-card:focus-visible,
trix-editor .embed-link-card:hover,
trix-editor .embed-link-card:focus-visible {
  border-color: rgb(100 116 139);
  color: rgb(15 23 42);
}

.embed-link-card__image {
  flex: 0 0 34%;
  max-width: 180px;
  min-height: 96px;
  background: rgb(241 245 249);
}

.embed-link-card__image img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 96px;
  object-fit: cover;
}

.embed-link-card__body {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.9rem 1rem;
}

.embed-link-card__title {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.45;
}

.embed-link-card__meta {
  overflow: hidden;
  color: rgb(100 116 139);
  font-size: 0.75rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 420px) {
  .embed-link-card__image {
    flex-basis: 40%;
    min-height: 82px;
  }

  .embed-link-card__image img {
    min-height: 82px;
  }
}
