/*
 * DHV Experience 13.78.16 — Story Card Media Geometry.
 * Presentation only. The canonical FeedItem attachment ID, intrinsic source
 * dimensions and WordPress image pipeline remain authoritative. This layer
 * simply lets landscape, square, portrait and tall media breathe differently
 * instead of treating every image as the same generic thumbnail/module.
 */

/* Shared story-media stage. Remove legacy card-like framing; the image itself
 * is part of the story. Shape is already derived from attachment dimensions. */
.dhvx-app .dhvx-post {
  --dhvx-story-media-bleed: 20px;
  --dhvx-story-media-gap: 16px;
  --dhvx-story-portrait-width: 82%;
  --dhvx-story-tall-width: 68%;
}

.dhvx-app[data-dhv-experience="feed"] .dhvx-post {
  --dhvx-story-media-bleed: 24px;
}

.dhvx-listing-feed .dhvx-post {
  --dhvx-story-media-bleed: 22px;
}

.dhvx-app .dhvx-post__media,
.dhvx-app[data-dhv-experience="feed"] .dhvx-post__media,
.dhvx-listing-feed .dhvx-post__media {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: var(--dhvx-story-media-gap);
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: hidden;
}

.dhvx-app .dhvx-post__media img,
.dhvx-app[data-dhv-experience="feed"] .dhvx-post__media img,
.dhvx-listing-feed .dhvx-post__media img {
  display: block;
  height: auto;
  max-width: 100%;
  object-fit: contain;
}

/* Landscape is the default immersive editorial scene: true edge-to-edge
 * inside the story plane, with no artificial crop or max-height letterbox. */
.dhvx-app .dhvx-post__media.is-landscape,
.dhvx-app .dhvx-post__media.is-unknown {
  margin-inline: calc(-1 * var(--dhvx-story-media-bleed));
}

.dhvx-app .dhvx-post__media.is-landscape img,
.dhvx-app .dhvx-post__media.is-unknown img {
  width: 100%;
}

/* Square media remains visually strong but does not need a faux frame. */
.dhvx-app .dhvx-post__media.is-square {
  margin-inline: calc(-1 * var(--dhvx-story-media-bleed));
}

.dhvx-app .dhvx-post__media.is-square img {
  width: 100%;
}

/* Portrait imagery becomes a deliberate visual pause on wider screens instead
 * of a full-column wall. The source aspect ratio is untouched. */
.dhvx-app .dhvx-post__media.is-portrait {
  margin-inline: 0;
  padding: 0;
  overflow: visible;
}

.dhvx-app .dhvx-post__media.is-portrait img {
  width: var(--dhvx-story-portrait-width);
  max-height: min(76vh, 720px);
}

/* Very tall art is framed by whitespace, not cropped. A faint warm mat only
 * separates transparent/very light artwork from the paper surface. */
.dhvx-app .dhvx-post__media.is-tall {
  margin-inline: 0;
  padding: 14px 0;
  overflow: visible;
  background: color-mix(in srgb, var(--dhvx-surface-soft) 42%, transparent);
}

.dhvx-app .dhvx-post__media.is-tall img {
  width: var(--dhvx-story-tall-width);
  max-width: var(--dhvx-story-tall-width);
  max-height: min(72vh, 680px);
}

/* A featured story earns only a little more visual presence; it does not get a
 * different crop, preserving the same source truth as every other story. */
.dhvx-app .dhvx-post.is-featured {
  --dhvx-story-portrait-width: 86%;
  --dhvx-story-tall-width: 72%;
}

/* Tablet is a first-class composition. Keep horizontal scenes immersive while
 * vertical imagery stays contained enough that the next story remains visible. */
@media (min-width: 768px) and (max-width: 1119px) {
  .dhvx-app .dhvx-post {
    --dhvx-story-media-gap: 14px;
    --dhvx-story-portrait-width: 84%;
    --dhvx-story-tall-width: 70%;
  }

  .dhvx-app[data-dhv-experience="feed"] .dhvx-post,
  .dhvx-listing-feed .dhvx-post {
    --dhvx-story-media-bleed: 18px;
  }

  .dhvx-app .dhvx-post.is-featured {
    --dhvx-story-portrait-width: 88%;
    --dhvx-story-tall-width: 74%;
  }

  .dhvx-app .dhvx-post__media.is-portrait img { max-height: min(70vh, 650px); }
  .dhvx-app .dhvx-post__media.is-tall img { max-height: min(68vh, 620px); }
}

/* Mobile is not a miniature desktop. Landscape, square and ordinary portrait
 * photos use the viewport width as story scenery. Only unusually tall art is
 * inset so one image does not monopolize the entire scroll rhythm. */
@media (max-width: 767px) {
  .dhvx-app .dhvx-post,
  .dhvx-app[data-dhv-experience="feed"] .dhvx-post,
  .dhvx-listing-feed .dhvx-post {
    --dhvx-story-media-bleed: 14px;
    --dhvx-story-media-gap: 10px;
    --dhvx-story-portrait-width: 100%;
    --dhvx-story-tall-width: 88%;
  }

  .dhvx-listing-feed .dhvx-post {
    --dhvx-story-media-bleed: 16px;
  }

  .dhvx-app .dhvx-post__media.is-portrait {
    margin-inline: calc(-1 * var(--dhvx-story-media-bleed));
    overflow: hidden;
  }

  .dhvx-app .dhvx-post__media.is-portrait img {
    width: 100%;
    max-height: none;
  }

  .dhvx-app .dhvx-post__media.is-tall {
    margin-inline: 0;
    padding: 10px 0;
  }

  .dhvx-app .dhvx-post__media.is-tall img {
    width: var(--dhvx-story-tall-width);
    max-width: var(--dhvx-story-tall-width);
    max-height: 72vh;
  }
}

@media (max-width: 359px) {
  .dhvx-app .dhvx-post,
  .dhvx-app[data-dhv-experience="feed"] .dhvx-post {
    --dhvx-story-media-bleed: 12px;
    --dhvx-story-tall-width: 90%;
  }
  .dhvx-listing-feed .dhvx-post { --dhvx-story-media-bleed: 14px; }
}

/* Touch landscape gets a bounded image height so the platform never becomes a
 * single-image viewport while preserving the complete source. */
@media (max-width: 920px) and (max-height: 500px) and (orientation: landscape) and (pointer: coarse) {
  .dhvx-app .dhvx-post__media img { max-height: 76vh; width: auto; }
  .dhvx-app .dhvx-post__media.is-landscape img,
  .dhvx-app .dhvx-post__media.is-square img,
  .dhvx-app .dhvx-post__media.is-unknown img { width: 100%; object-fit: contain; }
}

html[data-theme="dark"] .dhvx-app .dhvx-post__media.is-tall {
  background: color-mix(in srgb, var(--dhvx-surface-soft) 58%, transparent);
}

@media (forced-colors: active) {
  .dhvx-app .dhvx-post__media.is-tall { background: Canvas; }
}
