/* Embed preview parts. Every value comes from tokens.css, like lab.css. */

.ep-url-row {
  display: grid;
  gap: var(--wp--preset--spacing--3);
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 30em) {

  .ep-url-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}

.ep-cards {
  display: grid;
  gap: var(--wp--preset--spacing--5);
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  align-items: start;
}

.ep-card {
  display: grid;
  gap: var(--wp--preset--spacing--2);
  min-width: 0;
}

.ep-card p {
  margin: 0;
}

.ep-url {
  color: var(--wp--preset--color--signal);
  overflow-wrap: anywhere;
}

.ep-clamp-2,
.ep-clamp-3 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ep-clamp-2 {
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.ep-clamp-3 {
  -webkit-line-clamp: 3;
  line-clamp: 3;
}

/* The page's og:image, cropped to the 1.91:1 frame the apps use for large cards. */
.ep-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1.91;
  object-fit: cover;
  background: var(--wp--preset--color--soft-paper);
  border-radius: var(--wp--preset--border-radius--md);
}

/* Shown in place of an image that is missing or failed to load. */
.ep-img--none {
  display: grid;
  place-items: center;
  padding: var(--wp--preset--spacing--2);
  color: var(--wp--preset--color--dust);
  background: var(--wp--preset--color--surface);
  border: 1px dashed var(--wp--preset--color--rule);
  font-family: var(--wp--preset--font-family--mono);
  font-size: var(--wp--preset--font-size--x-small);
  text-align: center;
}

/* Telegram: a message bubble with the preview inside, under a neutral bar. */
.ep-tg {
  display: grid;
  gap: var(--wp--preset--spacing--2);
  padding: var(--wp--preset--spacing--3);
  background: var(--wp--preset--color--soft-paper);
  border-radius: var(--wp--preset--border-radius--lg);
  font-size: var(--wp--preset--font-size--x-small);
  line-height: var(--wp--custom--line-height--normal);
}

.ep-tg__preview {
  display: grid;
  gap: var(--wp--preset--spacing--1);
  padding-left: var(--wp--preset--spacing--3);
  border-left: var(--wp--preset--spacing--1) solid var(--wp--preset--color--rule);
}

.ep-tg__site,
.ep-tg__title {
  font-weight: var(--wp--custom--font-weight--semibold);
}

.ep-tg .ep-img {
  margin-top: var(--wp--preset--spacing--1);
}

/* Slack: a message row, then the unfurl under a grey bar. */
.ep-sl {
  display: grid;
  grid-template-columns: var(--wp--preset--spacing--6) minmax(0, 1fr);
  gap: var(--wp--preset--spacing--1) var(--wp--preset--spacing--3);
  font-size: var(--wp--preset--font-size--x-small);
  line-height: var(--wp--custom--line-height--normal);
}

.ep-sl__avatar {
  grid-row: span 2;
  width: var(--wp--preset--spacing--6);
  height: var(--wp--preset--spacing--6);
  background: var(--wp--preset--color--soft-paper);
  border-radius: var(--wp--preset--border-radius--md);
}

.ep-sl__name {
  font-weight: var(--wp--custom--font-weight--bold);
}

.ep-sl__unfurl {
  display: grid;
  gap: var(--wp--preset--spacing--1);
  grid-column: 2;
  padding-left: var(--wp--preset--spacing--3);
  border-left: var(--wp--preset--spacing--1) solid var(--wp--preset--color--line);
}

.ep-sl__site {
  display: flex;
  gap: var(--wp--preset--spacing--2);
  align-items: center;
  font-weight: var(--wp--custom--font-weight--semibold);
}

.ep-sl__favicon {
  width: var(--wp--preset--spacing--4);
  height: var(--wp--preset--spacing--4);
  background: var(--wp--preset--color--soft-paper);
  border: 1px solid var(--wp--preset--color--line);
  border-radius: var(--wp--preset--border-radius--sm);
}

.ep-sl__title {
  color: var(--wp--preset--color--signal);
  font-weight: var(--wp--custom--font-weight--bold);
}

.ep-sl .ep-img {
  margin-top: var(--wp--preset--spacing--1);
}

/* X: a large image with the title over its corner, the domain under it. */
.ep-x {
  display: grid;
  gap: var(--wp--preset--spacing--2);
  font-size: var(--wp--preset--font-size--x-small);
  line-height: var(--wp--custom--line-height--normal);
}

.ep-x__media {
  position: relative;
}

.ep-x__media .ep-img {
  border: 1px solid var(--wp--preset--color--line);
  border-radius: var(--wp--preset--border-radius--lg);
}

.ep-x__badge {
  position: absolute;
  left: var(--wp--preset--spacing--2);
  bottom: var(--wp--preset--spacing--2);
  max-width: calc(100% - var(--wp--preset--spacing--4));
  padding: 0 var(--wp--preset--spacing--2);
  color: var(--wp--preset--color--ink);
  background: var(--wp--preset--color--surface);
  border-radius: var(--wp--preset--border-radius--sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ep-x__summary {
  display: grid;
  grid-template-columns: var(--wp--preset--spacing--9) minmax(0, 1fr);
  border: 1px solid var(--wp--preset--color--line);
  border-radius: var(--wp--preset--border-radius--lg);
  overflow: hidden;
}

.ep-x__summary .ep-img {
  aspect-ratio: 1;
  height: 100%;
  border: 0;
  border-right: 1px solid var(--wp--preset--color--line);
  border-radius: 0;
}

.ep-x__summary-text {
  display: grid;
  gap: var(--wp--preset--spacing--1);
  align-content: center;
  padding: var(--wp--preset--spacing--2) var(--wp--preset--spacing--3);
}

.ep-x__from {
  color: var(--wp--preset--color--dust);
}

/* Detail sections: closed by default, the summary is a full-height control. */
.ep-mores {
  display: grid;
}

.ep-cards[hidden],
.ep-mores[hidden] {
  display: none;
}

.ep-more {
  container-type: inline-size;
  border-top: 1px solid var(--wp--preset--color--line);
}

.ep-mores .ep-more:last-child {
  border-bottom: 1px solid var(--wp--preset--color--line);
}

.ep-more > summary {
  display: flex;
  gap: var(--wp--preset--spacing--3);
  align-items: center;
  min-height: 2.75rem;
  color: var(--wp--preset--color--graphite);
  font-family: var(--wp--preset--font-family--mono);
  font-size: var(--wp--preset--font-size--x-small);
  list-style: none;
  cursor: pointer;
  transition: color var(--wp--custom--transition--base);
}

.ep-more > summary::-webkit-details-marker {
  display: none;
}

.ep-more > summary::before {
  content: "+";
  width: 1ch;
}

.ep-more[open] > summary::before {
  content: "\2212";
}

.ep-more > summary:hover {
  color: var(--wp--preset--color--ink);
}

.ep-more__count {
  margin-left: auto;
  color: var(--wp--preset--color--dust);
}

.ep-more__body {
  margin-bottom: var(--wp--preset--spacing--4);
}

/* Names, tags and status words stay on one line; sources wrap between words. */
.ep-rows .ep-key {
  overflow-wrap: normal;
  white-space: nowrap;
}

.ep-rows .ep-text {
  overflow-wrap: break-word;
}

/* Four columns don't fit a phone, so each row of the fields table becomes a small block. */
@container (max-width: 34rem) {

  .ep-rows:not(.ep-rows--raw2),
  .ep-rows:not(.ep-rows--raw2) tbody {
    display: block;
  }

  .ep-rows:not(.ep-rows--raw2) thead {
    display: none;
  }

  .ep-rows:not(.ep-rows--raw2) tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--wp--preset--spacing--1) var(--wp--preset--spacing--3);
    padding: var(--wp--preset--spacing--3) 0;
    border-bottom: 1px solid var(--wp--preset--color--line);
  }

  .ep-rows:not(.ep-rows--raw2) td {
    padding: 0;
    border: 0;
  }

  .ep-rows:not(.ep-rows--raw2) td:nth-child(1) {
    grid-area: 1 / 1;
  }

  .ep-rows:not(.ep-rows--raw2) td:nth-child(2) {
    grid-area: 2 / 1 / 3 / 3;
    overflow-wrap: anywhere;
  }

  .ep-rows:not(.ep-rows--raw2) td:nth-child(3) {
    grid-area: 3 / 1 / 4 / 3;
    color: var(--wp--preset--color--dust);
  }

  .ep-rows:not(.ep-rows--raw2) td:nth-child(4) {
    grid-area: 1 / 2;
  }
}
