/* Yapper V257 — Yap sharing. Kept in a final cascade so the new surface can
   extend the current UI without changing existing Yap, DM, or modal shapes. */

.share-yap-button {
  gap: 7px;
}

/* Reserve enough room for the longest action instead of truncating Dislike. */
#yapFeed .post-actions {
  grid-template-columns: minmax(max-content, 1.4fr) minmax(max-content, 1fr) minmax(max-content, 1fr);
}

#yapFeed .post-actions.question-snippet-actions {
  grid-template-columns: minmax(max-content, 1fr) minmax(max-content, 1fr);
}

#yapFeed .post-actions button {
  gap: 5px;
  padding-inline: 10px;
  white-space: nowrap;
}

#yapFeed .post-actions .like-button span {
  overflow: visible;
  text-overflow: clip;
}

.share-yap-button svg,
.yap-share-external-actions svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.yap-share-overlay {
  z-index: 1125;
}

.yap-share-modal {
  position: relative;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  width: min(520px, calc(100vw - 28px));
  max-height: min(760px, calc(100dvh - 32px));
  padding: 24px;
  overflow: hidden;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 36px;
}

.yap-share-heading {
  padding-right: 48px;
}

.yap-share-heading h2 {
  margin: 0;
  font-size: clamp(27px, 4.6vw, 34px);
  line-height: 1.05;
  letter-spacing: -.7px;
}

.yap-share-heading p {
  margin: 7px 0 0;
  color: var(--secondary-text);
  font-size: 14px;
  line-height: 1.4;
}

.yap-share-preview {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  min-height: 68px;
  margin-top: 17px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 34px;
  background: var(--bubble);
}

.yap-share-preview .profile-avatar,
.yap-share-preview-avatar {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: 50%;
}

.yap-share-preview-copy {
  min-width: 0;
}

.yap-share-preview-author {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 5px;
  font-size: 14px;
  line-height: 1.2;
}

.yap-share-preview-author strong,
.yap-share-target-copy strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.yap-share-preview-copy > p {
  display: -webkit-box;
  margin: 4px 0 0;
  overflow: hidden;
  color: var(--secondary-text);
  font-size: 12.5px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.yap-share-yapper-section {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  min-height: 0;
  margin-top: 17px;
}

.yap-share-section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 2px 9px;
}

.yap-share-section-heading h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
}

.yap-share-section-heading span {
  color: var(--secondary-text);
  font-size: 11px;
  font-weight: 750;
}

.yap-share-search-wrap {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
  height: 44px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 9999px;
  background: var(--button);
  margin: 0;
  line-height: 1;
}

.yap-share-search-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.yap-share-search-wrap svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--secondary-text);
  stroke-width: 2;
  stroke-linecap: round;
}

.yap-share-search-wrap input {
  box-sizing: border-box;
  width: 100%;
  height: 42px !important;
  min-height: 42px !important;
  margin: 0 !important;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  box-shadow: none;
  line-height: normal;
  text-align: left;
  align-self: center;
}

.yap-share-search-wrap input:disabled {
  opacity: .58;
}

#yapShareStatus {
  min-height: 18px;
  margin: 7px 3px 5px;
  font-size: 12px;
}

.yap-share-targets {
  display: grid;
  align-content: start;
  gap: 7px;
  min-height: 92px;
  max-height: 304px;
  padding: 8px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  border: 1px solid var(--border);
  border-radius: 36px;
  background: color-mix(in srgb, var(--bubble) 62%, transparent);
}

.yap-share-targets::-webkit-scrollbar {
  display: none;
}

.yap-share-target,
.yap-share-empty {
  border-radius: 9999px !important;
}

.yap-share-target {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 66px;
  padding: 8px 9px;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
}

.yap-share-target:hover,
.yap-share-target:focus-visible {
  border-color: color-mix(in srgb, var(--primary) 58%, var(--border));
  background: color-mix(in srgb, var(--primary) 8%, var(--card));
}

.yap-share-target.is-sent {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 13%, var(--card));
}

.yap-share-target-avatar,
.yap-share-target .profile-avatar {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  min-width: 48px;
  overflow: hidden;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-text);
  font-size: 13px;
  font-weight: 900;
}

.yap-share-target-avatar img,
.yap-share-target .profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.yap-share-target-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.yap-share-target-name {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 4px;
  font-size: 14px;
}

.yap-share-target-copy small {
  overflow: hidden;
  color: var(--secondary-text);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.yap-share-target-action {
  min-width: 57px;
  padding: 0 10px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 850;
  text-align: center;
}

.yap-share-target.is-sent .yap-share-target-action {
  color: var(--text);
}

.yap-share-empty {
  display: grid;
  place-items: center;
  min-height: 78px;
  margin: 0;
  padding: 16px;
  color: var(--secondary-text);
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
  background: var(--card);
}

.yap-share-external-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-top: 14px;
}

.yap-share-external-actions button {
  width: 100%;
  min-width: 0;
  min-height: 48px;
}

/* The encrypted Messages card for a shared Yap. */
.dm-shared-yap-card {
  display: grid;
  grid-template-columns: 43px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  box-sizing: border-box;
  width: min(330px, 72vw);
  max-width: 100%;
  padding: 11px 12px;
  overflow: hidden;
  color: var(--text);
  text-decoration: none;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.4;
  border: 1px solid color-mix(in srgb, var(--primary) 36%, var(--border));
  border-radius: 22px;
  background: color-mix(in srgb, var(--primary) 10%, var(--bubble));
}

.dm-shared-yap-card:hover,
.dm-shared-yap-card:focus-visible {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 16%, var(--bubble));
}

.dm-shared-yap-avatar {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  overflow: hidden;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-text);
  font-size: 13px;
  font-weight: 900;
}

.dm-shared-yap-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dm-shared-yap-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.dm-shared-yap-copy small {
  color: var(--primary);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.dm-shared-yap-copy strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dm-shared-yap-copy span {
  display: -webkit-box;
  overflow: hidden;
  color: var(--secondary-text);
  font-size: 11.5px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.dm-shared-yap-open {
  color: var(--primary);
  font-size: 19px;
  font-weight: 900;
}

@media (max-width: 700px) {
  #yapFeed .post-actions {
    gap: 7px;
  }

  #yapFeed .post-actions button {
    padding-inline: 7px;
    font-size: clamp(11.5px, 3.45vw, 14px) !important;
  }

  .yap-share-overlay {
    align-items: flex-end;
    box-sizing: border-box;
    padding: max(10px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)) !important;
  }

  .yap-share-modal.modal-surface {
    width: 100% !important;
    max-width: none !important;
    max-height: calc(100dvh - max(10px, env(safe-area-inset-top)) - max(12px, env(safe-area-inset-bottom))) !important;
    padding: 20px 14px 14px !important;
    border-radius: 36px !important;
    overflow-y: auto;
  }

  .yap-share-heading {
    padding: 2px 46px 0 3px;
  }

  .yap-share-heading h2 {
    font-size: 27px;
  }

  .yap-share-preview {
    margin-top: 14px;
  }

  .yap-share-yapper-section {
    margin-top: 14px;
  }

  .yap-share-targets {
    max-height: min(292px, 36dvh);
    min-height: 64px;
    border-radius: 34px;
  }

  .yap-share-target {
    min-height: 64px;
  }

  .yap-share-external-actions button {
    min-height: 50px;
  }
}

@media (max-width: 540px) {
  /* Match the phone radius used by multi-line DM and group messages. */
  #dmModal .dm-shared-yap-card {
    border-radius: 19px;
  }
}

@media (max-width: 370px) {
  .yap-share-modal.modal-surface {
    padding-inline: 10px !important;
  }

  .yap-share-target {
    grid-template-columns: 44px minmax(0, 1fr) auto;
    gap: 8px;
    padding-inline: 7px;
  }

  .yap-share-target-avatar,
  .yap-share-target .profile-avatar {
    width: 44px;
    height: 44px;
    min-width: 44px;
  }

  .yap-share-target-action {
    min-width: 50px;
    padding-inline: 6px;
  }
}

@media (hover: none) and (pointer: coarse) {
  .yap-share-search-wrap input {
    font-size: 16px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .yap-share-target,
  .dm-shared-yap-card {
    transition: none !important;
  }
}
