.yun-card:is(.post-card-wrapper, .collection-card) {
  // Keep each card and its interactive children in the same stacking context.
  position: relative;
  isolation: isolate;
  border: 1px solid var(--yun-surface-line);
  border-inline-start-width: var(--yun-feed-card-leading-width, 1px);
  border-inline-start-color: var(--yun-feed-card-leading-color, var(--yun-surface-line));
  transition: transform 220ms var(--yun-ease-in-out, ease), border-color 220ms ease, box-shadow 220ms ease;

  @media (hover: hover) and (pointer: fine) {
    &:hover {
      z-index: 1;

      --yun-feed-card-hover-border: color-mix(in srgb, var(--va-c-link) 28%, var(--yun-surface-line));

      border-color: var(--yun-feed-card-hover-border);
      border-inline-start-color: var(--yun-feed-card-leading-hover-color, var(--yun-feed-card-hover-border));
      box-shadow: var(--yun-card-hover-shadow);

      @media (prefers-reduced-motion: no-preference) {
        transform: translateY(-2px);
      }
    }
  }

  @media (prefers-reduced-motion: reduce) {
    transition: none;
  }
}

.yun-card.is-draft {
  --yun-draft-border-color: color-mix(in srgb, #b45309 36%, var(--yun-surface-line));
  --yun-draft-border-hover-color: color-mix(in srgb, #b45309 54%, var(--yun-surface-line));
  --yun-feed-card-leading-color: var(--yun-draft-border-color);
  --yun-feed-card-leading-hover-color: var(--yun-draft-border-hover-color);

  border-width: 1px;
  border-style: dashed;
  border-color: var(--yun-draft-border-color);
}

html.dark .yun-card.is-draft:is(.post-card-wrapper, .collection-card, .yun-main .yun-card) {
  --yun-draft-border-color: color-mix(in srgb, #f5b971 48%, var(--yun-surface-line));
  --yun-draft-border-hover-color: color-mix(in srgb, #f5b971 68%, var(--yun-surface-line));

  border-style: dashed;
  border-color: var(--yun-draft-border-color);
}

.yun-card:is(.post-card-wrapper, .collection-card).is-draft {
  @media (hover: hover) and (pointer: fine) {
    &:hover {
      border-color: var(--yun-draft-border-hover-color);
    }
  }
}

.post-card-wrapper {
  .post-status-icons {
    left: auto;
    right: 1rem;
  }

  &.has-post-status .post-title-link {
    max-width: calc(100% - (1.15rem + var(--yun-post-status-count, 1) * 1.975rem) * 2);

    @media screen and (width <= 640px) {
      max-width: 100%;
      margin-top: 2.25rem;
    }
  }
}

.yun-main > .content > .yun-card.has-post-status .post-header {
  @media screen and (width <= 640px) {
    padding-top: 0.5rem;
  }
}

.post-card {
  position: relative;
  max-width: var(--yun-post-card-max-width);
}

.post-card-image {
  position: relative;
  max-width: var(--yun-post-card-max-width);

  .post-card-cover {
    width: 40%;
    height: 13.5rem; // h-54
    flex-shrink: 0;
  }

  .post-card-body-with-cover {
    height: 13.5rem; // h-54
  }

  // Use md breakpoint (768px) instead of mobile (640px)
  // because 640~768px screens are still too narrow for side-by-side layout
  @media screen and (width <= 768px) {
    .post-card-info {
      flex-direction: column;
    }

    .post-card-cover {
      width: 100%;
      height: auto;
      max-height: 12rem;

      &:has(.valaxy-cover-content) {
        max-height: none;
      }
    }

    .post-card-body-with-cover {
      height: auto;
    }
  }
}

.post-title-link {
  position: relative;
  padding: 0.7rem 1.2rem;
  color: var(--card-c-primary, var(--yun-post-title-color, var(--va-c-link)));
  font-weight: var(--yun-post-title-font-weight, 600);

  .icon {
    width: 1.6rem;
    height: 1.6rem;
    margin-right: 0.4rem;
  }

  &::before,
  &::after {
    content: "";
    position: absolute;
    width: 10px;
    height: 10px;
    opacity: 0;
    border: 2px solid;
    transition: opacity var(--va-transition-duration), transform var(--va-transition-duration);
    transition-timing-function: cubic-bezier(0.17, 0.67, 0.05, 1.29);
  }

  &::before {
    top: 0;
    left: 0;
    border-width: 2px 0 0 2px;
    transform: translate3d(10px, 10px, 0);
  }

  &::after {
    right: 0;
    bottom: 0;
    border-width: 0 2px 2px 0;
    transform: translate3d(-10px, -10px, 0);
  }

  &:hover {
    color: var(--yun-post-title-hover-color, var(--card-c-primary, var(--yun-post-title-color, var(--va-c-link))));
  }

  &:hover::before,
  &:hover::after {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

.post-link-btn,
.markdown-body .post-link-btn {
  background-color: var(--va-c-primary, #111);
  line-height: 1.2;
  padding: 0.5rem 1.2rem;
  color: white;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-decoration: none;
  margin-top: -0.2rem;
  transition: box-shadow var(--va-transition-duration), transform var(--va-transition-duration-fast);

  &:hover {
    transform: translateY(-1px);
  }

  &::before {
    content: none;
  }
}

.yun-card-actions {
  border-top: 1px solid var(--yun-surface-line);
}

.post-tag {
  white-space: nowrap;
}

.post-tag:not(.yun-post-badge) {
  color: var(--yun-tag-color);
  transition: color var(--va-transition-duration-fast);

  &:hover {
    color: var(--yun-tag-hover-color, var(--va-c-primary));
  }
}

.yun-post-badge {
  color: var(--va-c-text-2);
  border-color: var(--yun-surface-line);
  background-color: color-mix(in srgb, var(--va-c-text) 2.5%, transparent);
  transition: color 180ms ease, border-color 180ms ease, background-color 180ms ease;

  &:is(:hover, :focus-visible) {
    color: var(--va-c-link);
    border-color: color-mix(in srgb, var(--va-c-link) 42%, transparent);
    background-color: color-mix(in srgb, var(--va-c-link) 10%, transparent);
  }

  &:focus-visible {
    outline: 2px solid var(--yun-focus-color);
    outline-offset: 2px;
  }

  @media (prefers-reduced-motion: reduce) {
    transition: none;
  }
}

.post-card-title,
.post-header .post-title {
  font-family: var(--yun-post-title-font-family, var(--va-font-serif));
  font-weight: var(--yun-post-title-font-weight, 600);
  font-optical-sizing: auto;
  font-kerning: normal;
  letter-spacing: var(--yun-post-title-letter-spacing, normal);
  line-height: var(--yun-post-title-line-height, 1.35);
}

:is(h1, h2):where(.post-header .post-title) {
  font-size: var(--yun-post-title-font-size, clamp(1.625rem, 1.35rem + 1.2vw, 2.125rem));
}

.post-header .post-title > span {
  line-height: inherit;
}

.post-meta {
  color: var(--yun-post-meta-color, inherit);
}

@media (prefers-reduced-motion: reduce) {
  .post-title-link::before,
  .post-title-link::after {
    transition: none;
    transform: none;
  }
}
