.media-frame {
  position: relative;
  display: block;
  min-width: 0;
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.34), transparent 38%),
    #e8e1d7;
  isolation: isolate;
}

.media-frame > picture {
  display: block;
  width: 100%;
}

.media-frame img,
.media-frame video {
  position: relative;
  z-index: 1;
}

.media-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  background: linear-gradient(100deg, transparent 22%, rgba(255, 255, 255, 0.52) 48%, transparent 74%);
  background-size: 220% 100%;
  opacity: 0.72;
  pointer-events: none;
  animation: media-shimmer 1.35s ease-in-out infinite;
  transition: opacity 180ms ease;
}

.media-frame.is-loaded::before,
.media-frame.is-error::before,
.media-frame.is-video-ready::before {
  opacity: 0;
  animation: none;
}

.media-frame.is-error img,
.media-frame.is-error video {
  opacity: 0;
}

.media-frame--transparent {
  background: transparent;
}

.media-frame--transparent::before {
  inset: 14% 20%;
  border-radius: 48%;
  background: rgba(105, 89, 73, 0.08);
  animation: media-pulse 1.4s ease-in-out infinite;
}

.media-fallback {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  min-width: 0;
  padding: 18px;
  border: 1px dashed rgba(79, 47, 32, 0.24);
  border-radius: inherit;
  background:
    radial-gradient(circle at 50% 32%, rgba(255, 255, 255, 0.72), transparent 42%),
    rgba(237, 229, 218, 0.96);
  color: #4f2f20;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 180ms ease, visibility 180ms ease;
}

.media-frame.is-error .media-fallback,
.media-frame.is-awaiting-play .media-fallback {
  opacity: 1;
  visibility: visible;
}

.media-frame.is-error .media-fallback.has-action,
.media-frame.is-awaiting-play .media-fallback.has-action {
  pointer-events: auto;
}

.media-fallback__icon {
  width: 34px;
  height: 25px;
  border: 1.5px solid currentColor;
  border-radius: 4px;
  position: relative;
  opacity: 0.68;
  transform: rotate(-2deg);
}

.media-fallback__icon::before,
.media-fallback__icon::after {
  content: "";
  position: absolute;
}

.media-fallback__icon::before {
  width: 6px;
  height: 6px;
  margin: 5px 0 0 20px;
  border-radius: 50%;
  background: currentColor;
}

.media-fallback__icon::after {
  width: 18px;
  height: 10px;
  margin: 10px 0 0 6px;
  border-left: 1.5px solid currentColor;
  border-top: 1.5px solid currentColor;
  transform: rotate(45deg) skew(-8deg, -8deg);
}

.media-fallback__action {
  min-height: 34px;
  padding: 7px 13px;
  border: 1px solid rgba(79, 47, 32, 0.38);
  border-radius: 999px;
  background: rgba(255, 253, 250, 0.9);
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}

.media-fallback__action:hover,
.media-fallback__action:focus-visible {
  background: #fffdfa;
  outline: 2px solid rgba(79, 47, 32, 0.2);
  outline-offset: 2px;
  transform: translateY(-1px);
}

.media-frame--link .media-fallback {
  pointer-events: none;
}

html.is-low-data .media-frame::before {
  animation: none;
}

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

@keyframes media-shimmer {
  from { background-position: 180% 0; }
  to { background-position: -60% 0; }
}

@keyframes media-pulse {
  0%, 100% { opacity: 0.34; transform: scale(0.98); }
  50% { opacity: 0.62; transform: scale(1.015); }
}

/* Case-study media wrappers preserve the existing layout while allowing shared states. */
.p1-media-frame,
.p-case-media-frame {
  width: 100%;
  border-radius: 16px;
}

.p1-media-frame {
  margin-top: 23px;
}

.p1-media-frame .p1-figma-image {
  width: 100%;
  margin-top: 0;
}

.p1-impact-media {
  width: 643px;
  max-width: 100%;
  margin: 0 auto 112px;
}

.p1-impact-media .p1-impact-image {
  width: 100%;
  height: auto;
  margin: 0;
}

.p-case-media-frame {
  margin-top: 28px;
  border-radius: var(--p1-radius-panel, 16px);
}

.p-case-media-frame .p-case-image {
  margin-top: 0;
}

.case-hero__card.media-frame,
.p1-figure-image.media-frame {
  overflow: hidden;
}
