/* ============================================================
   ECA v4 — Unified Video Display (Instagram-style preview)
   FIXED HEIGHT strategy:
     - Container `.post .plyr--video`: 528px fixed
     - Wrapper, poster, video: 528px fixed too (not 100% — that was being
       crushed to 0 by Plyr/SNGINE styles)
     - object-fit: cover preserves aspect ratio, no stretch
   Click anywhere → /reels/<post_id> for full view.
   Scope is `.post` — never touches `.reel-container` or `.pg_video`.
   ============================================================ */

/* Container */
.post .plyr--video {
  width: 100% !important;
  height: 528px !important;
  min-height: 528px !important;
  max-height: 528px !important;
  background: #000 !important;
  position: relative !important;
  cursor: pointer;
  padding-bottom: 0 !important;
  --plyr-aspect-ratio: auto;
  border-radius: 8px;
  overflow: hidden;
  display: block !important;
}

/* Wrapper Plyr injects between container and <video>.
   Use FIXED height (not 100%) — something on the page collapses 100% to 0. */
.post .plyr--video .plyr__video-wrapper {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 528px !important;
  min-height: 528px !important;
  max-height: 528px !important;
  padding-bottom: 0 !important;
  display: block !important;
  overflow: hidden;
}

/* The <video> element fills the wrapper with cover crop.
   Inline style on the tag says `height: auto` — our !important wins,
   but we use FIXED 528 to bypass any parent-percentage collapse. */
.post .plyr--video video,
.post .plyr--video .plyr__video-wrapper video {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 528px !important;
  min-height: 528px !important;
  max-height: 528px !important;
  max-width: 100% !important;
  object-fit: cover !important;
  object-position: center center !important;
  display: block !important;
  background: #000 !important;
  pointer-events: none;
}

/* Poster (thumbnail) — fixed height too */
.post .plyr--video .plyr__poster {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 528px !important;
  min-height: 528px !important;
  max-height: 528px !important;
  background-size: cover !important;
  background-position: center center !important;
  background-color: #000 !important;
}

/* Hide native Plyr controls in feed preview */
.post .plyr--video .plyr__controls,
.post .plyr--video .plyr__control--overlaid,
.post .plyr--video .plyr__poster + .plyr__controls {
  display: none !important;
}

/* Custom centered play affordance */
.post .plyr--video::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='28' height='28' fill='white'><path d='M8 5v14l11-7z'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 28px 28px;
  pointer-events: none;
  transition: background 0.15s ease, transform 0.15s ease;
  z-index: 2;
}

.post .plyr--video:hover::after {
  background-color: rgba(0, 0, 0, 0.75);
  transform: translate(-50%, -50%) scale(1.05);
}

/* Mobile: 480px fixed instead of 528 */
@media (max-width: 575.98px) {
  .post .plyr--video,
  .post .plyr--video .plyr__video-wrapper,
  .post .plyr--video video,
  .post .plyr--video .plyr__video-wrapper video,
  .post .plyr--video .plyr__poster {
    height: 480px !important;
    min-height: 480px !important;
    max-height: 480px !important;
  }
  .post .plyr--video::after {
    width: 56px;
    height: 56px;
    background-size: 24px 24px;
  }
}

body.night-mode .post .plyr--video {
  outline: 1px solid #1f2a25;
}
