/* Media placeholder: fixed-ratio image frame with a skeleton shimmer.
   Stands in until real imagery is dropped in, and doubles as a graceful
   loading state once a `src` is set (skeleton holds until the img loads).

   No box treatment (border/radius/fill): instead the edges are feathered
   to transparent with a soft mask so the image dissolves into the page
   surface behind it, rather than reading as a pasted rectangle. Tune the
   fade depth with --media-ph-feather. */
.media-ph {
  position: relative;
  display: block;
  margin: 0;
  width: 100%;
  aspect-ratio: var(--media-ph-ratio, 4 / 3);
  overflow: hidden;

  /* Thin fixed rim so only the very edges fade; the center stays crisp.
     Fixed px (not %) keeps the rim consistent regardless of image size. */
  --media-ph-feather: 28px;
  -webkit-mask-image:
    linear-gradient(to right,  transparent 0, #000 var(--media-ph-feather), #000 calc(100% - var(--media-ph-feather)), transparent 100%),
    linear-gradient(to bottom, transparent 0, #000 var(--media-ph-feather), #000 calc(100% - var(--media-ph-feather)), transparent 100%);
  mask-image:
    linear-gradient(to right,  transparent 0, #000 var(--media-ph-feather), #000 calc(100% - var(--media-ph-feather)), transparent 100%),
    linear-gradient(to bottom, transparent 0, #000 var(--media-ph-feather), #000 calc(100% - var(--media-ph-feather)), transparent 100%);
  -webkit-mask-composite: source-in;
  mask-composite: intersect;
}

.media-ph__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.media-ph.is-loaded .media-ph__img {
  opacity: 1;
}

/* Skeleton: a muted base with a sweeping highlight. Sits on top of the
   image until `.is-loaded`, or stands alone in the empty state. */
.media-ph__skeleton {
  position: absolute;
  inset: 0;
  background: var(--color-muted);
  overflow: hidden;
}

.media-ph__skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    transparent 20%,
    color-mix(in oklch, white 60%, transparent) 45%,
    transparent 70%
  );
  transform: translateX(-100%);
  animation: media-ph-shimmer 1.5s ease-in-out infinite;
}

.media-ph.is-loaded .media-ph__skeleton {
  opacity: 0;
  animation: none;
  transition: opacity 0.4s ease;
}

@keyframes media-ph-shimmer {
  to {
    transform: translateX(100%);
  }
}

/* Empty state: a centered hint floats over the skeleton. */
.media-ph--empty {
  display: grid;
  place-items: center;
}

.media-ph__hint {
  position: relative;
  z-index: 1;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-muted-foreground);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.media-ph__hint .icon {
  opacity: 0.7;
}

@media (prefers-reduced-motion: reduce) {
  .media-ph__skeleton::after {
    animation: none;
  }
}
