/**
 * Vazir Bricks Extras — Single Aparat Video (Persian RTL)
 *
 * Layouts: minimal / standard (cover) / card.
 *
 * Layering inside .vbe-aparat-video__media (no negative z-index):
 *   z:0  iframe frame (revealed on play)
 *   z:1  .vbe-aparat-video__cover button (poster img, overlay, play, label)
 *   z:2  .vbe-aparat-video__overlay-text (title/meta panel — sibling, pointer-events:none)
 *   z:3  .vbe-aparat-video__badge (duration chip — sibling, pointer-events:none)
 *
 * When the media switches to --playing, all cover layers are hidden and the
 * iframe is revealed on top.
 */

/*
 * Bricks root wrapper sizing (critical).
 *
 * Bricks containers/blocks are flex columns. When a parent centers its
 * children (align-items: center), flex items shrink to their content width.
 * Every layer inside this element is absolutely positioned, so a shrink-to-
 * fit root collapses to zero width — and aspect-ratio:16/9 then yields zero
 * height (the element renders as nothing). Forcing the Bricks root wrapper
 * to full width keeps the inner percentage-width chain alive. Bricks still
 * wins when the user sets an explicit width on the element (ID selectors).
 */
.brxe-vbe-aparat-video {
  width: 100%;
}

.vbe-aparat-video {
  --vbe-apv-max-w: 720px;
  position: relative;
  width: 100%;
  max-width: var(--vbe-apv-max-w);
  margin-inline: auto;
  direction: rtl;
  text-align: right;
  font-size: 1rem;
  line-height: 1.6;
  box-sizing: border-box;
}

.vbe-aparat-video *,
.vbe-aparat-video *::before,
.vbe-aparat-video *::after {
  box-sizing: border-box;
}

/* ── Media box (iframe / cover) ───────────────────────────────────────────── */

.vbe-aparat-video__media {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 12px;
  background-color: #0b1220;
}

.vbe-aparat-video__frame {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* Before play: keep the (not yet injected) frame beneath the cover layers. */
.vbe-aparat-video__media--lazy .vbe-aparat-video__frame {
  opacity: 0;
  pointer-events: none;
}

/* After play: hide every cover layer, reveal the iframe on top. */
.vbe-aparat-video__media--playing .vbe-aparat-video__frame {
  opacity: 1;
  pointer-events: auto;
  z-index: 4;
}

.vbe-aparat-video__media--playing .vbe-aparat-video__cover,
.vbe-aparat-video__media--playing .vbe-aparat-video__overlay-text,
.vbe-aparat-video__media--playing .vbe-aparat-video__badge {
  display: none;
}

/* ── Cover / play trigger (z:1) ───────────────────────────────────────────── */

.vbe-aparat-video__cover {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  margin: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  transition: opacity 0.3s ease;
}

.vbe-aparat-video__cover:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: -4px;
}

/* Poster image: first layer inside the cover stacking context. */
.vbe-aparat-video__cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.45s ease;
}

.vbe-aparat-video__cover:hover img {
  transform: scale(1.04);
}

/* Dark overlay above the poster (z:1 inside cover). */
.vbe-aparat-video__overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-color: rgba(2, 6, 23, 0.55);
  transition: background-color 0.3s ease;
}

.vbe-aparat-video__cover:hover .vbe-aparat-video__overlay {
  background-color: rgba(2, 6, 23, 0.42);
}

/* ── Play button + label (z:2 inside cover) ───────────────────────────────── */

.vbe-aparat-video__play {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 999px;
  background-color: #ffffff;
  color: #e11d48;
  box-shadow: 0 8px 24px rgba(2, 6, 23, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.vbe-aparat-video__play svg {
  width: 60%;
  height: 60%;
  color: inherit;
}

.vbe-aparat-video__play--mini {
  width: 48px;
  height: 48px;
}

.vbe-aparat-video__cover:hover .vbe-aparat-video__play {
  transform: scale(1.08);
}

.vbe-aparat-video__cover:active .vbe-aparat-video__play {
  transform: scale(0.96);
}

.vbe-aparat-video__play-label {
  position: relative;
  z-index: 2;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 8px rgba(2, 6, 23, 0.7);
}

/* ── Title/meta panel (z:2 sibling of the cover) ──────────────────────────── */

.vbe-aparat-video__overlay-text {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  left: 1rem;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  background: linear-gradient(to top, rgba(2, 6, 23, 0.82), rgba(2, 6, 23, 0));
  pointer-events: none;
  text-align: right;
}

.vbe-aparat-video__title {
  margin: 0;
  padding: 0;
  color: #f8fafc;
  font-size: clamp(1rem, 2.4vw, 1.25rem);
  font-weight: 700;
  line-height: 1.4;
}

.vbe-aparat-video__meta {
  margin: 0.1rem 0 0;
  padding: 0;
  color: #94a3b8;
  font-size: 0.82rem;
}

/* ── Duration badge (z:3 sibling of the cover) ────────────────────────────── */

.vbe-aparat-video__badge {
  position: absolute;
  bottom: 0.75rem;
  left: 0.75rem;
  z-index: 3;
  padding: 0.22rem 0.55rem;
  border-radius: 6px;
  pointer-events: none;
  background-color: rgba(2, 6, 23, 0.72);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ── Card layout ──────────────────────────────────────────────────────────── */

.vbe-aparat-video__card {
  display: block;
  overflow: hidden;
  border-radius: 16px;
  background-color: #0f172a;
  box-shadow: 0 12px 32px rgba(2, 6, 23, 0.18);
}

/* The card clips the media corners itself, so the media stays square inside. */
.vbe-aparat-video--card .vbe-aparat-video__card .vbe-aparat-video__media {
  border-radius: 0;
}

.vbe-aparat-video__card-body {
  padding: 1rem 1.15rem 1.15rem;
}

.vbe-aparat-video__card-body .vbe-aparat-video__title {
  font-size: 1.05rem;
}

.vbe-aparat-video__card-body .vbe-aparat-video__meta {
  margin-top: 0.25rem;
}

/* ── Watch link ───────────────────────────────────────────────────────────── */

.vbe-aparat-video__watch {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.65rem;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.2s ease;
}

.vbe-aparat-video__watch:hover {
  opacity: 1;
  text-decoration: underline;
}

.vbe-aparat-video__watch svg {
  color: inherit;
}

/* ── Minimal layout: iframe is the visible box itself ─────────────────────── */

.vbe-aparat-video--minimal .vbe-aparat-video__frame {
  position: relative;
  inset: auto;
  z-index: auto;
  opacity: 1;
  pointer-events: auto;
}

/* ── Empty / error state (builder only) ───────────────────────────────────── */

.vbe-aparat-video--empty {
  padding: 1.25rem 1.5rem;
  border: 1px dashed rgba(148, 163, 184, 0.4);
  border-radius: 12px;
  background-color: rgba(2, 6, 23, 0.04);
  color: #475569;
  font-size: 0.9rem;
  text-align: center;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 478px) {
  .vbe-aparat-video__play {
    width: 56px;
    height: 56px;
  }

  .vbe-aparat-video__play--mini {
    width: 40px;
    height: 40px;
  }

  .vbe-aparat-video__overlay-text {
    right: 0.6rem;
    bottom: 0.6rem;
    left: 0.6rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .vbe-aparat-video__cover img,
  .vbe-aparat-video__play,
  .vbe-aparat-video__cover:hover img,
  .vbe-aparat-video__cover:hover .vbe-aparat-video__play {
    transition: none;
    transform: none;
  }
}
