/* ============================================
   نظام الفيديو - خلفية الهيرو + معرض فيديوهات المشاريع
   ============================================ */

/* ===== فيديو خلفية الهيرو ===== */
.hero-video-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.hero-video-bg video {
  position: absolute;
  top: 50%;
  left: 50%;
  min-width: 100%;
  min-height: 100%;
  width: auto;
  height: auto;
  transform: translate(-50%, -50%);
  object-fit: cover;
}

.hero-video-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--color-bg-primary);
  opacity: 0.55;
}

[data-theme="dark"] .hero-video-bg::after {
  opacity: 0.65;
}

/* على الجوّالات: نعرض صورة ثابتة بدل الفيديو لتوفير البيانات والبطارية، وتفادي مشاكل القص العمودي */
@media (max-width: 767px) {
  .hero-video-bg {
    display: none;
  }
}

/* ===== شبكة فيديوهات المشاريع (معرض الصور) ===== */
.video-gallery-section {
  margin-top: var(--space-16);
}

.video-gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-6);
}

.video-card {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 16/9;
  cursor: pointer;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
}

.video-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s var(--ease-out);
}

.video-card:hover img {
  transform: scale(1.06);
}

.video-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(11,13,15,0.75) 0%, rgba(11,13,15,0.1) 55%, transparent 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: var(--space-5);
}

.video-card-title {
  color: #fff;
  font-weight: 700;
  font-size: var(--text-base);
}

.video-play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast) var(--ease-out);
  box-shadow: var(--shadow-lg);
}

.video-card:hover .video-play-btn {
  background: var(--color-accent-primary);
  transform: translate(-50%, -50%) scale(1.1);
}

.video-play-btn svg {
  width: 22px;
  height: 22px;
  color: #14171A;
  margin-right: -3px; /* لضبط مثلث التشغيل بصرياً في المنتصف تماماً */
}

.video-card:hover .video-play-btn svg {
  color: #14171A;
}

/* ===== نافذة تشغيل الفيديو المنبثقة (Modal) ===== */
.video-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: rgba(11, 13, 15, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration-base) var(--ease-out), visibility var(--duration-base);
}

.video-modal-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

.video-modal-inner {
  width: 100%;
  max-width: 960px;
  position: relative;
}

.video-modal-close {
  position: absolute;
  top: -48px;
  left: 0;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--duration-fast) var(--ease-out);
}

.video-modal-close:hover {
  background: var(--color-accent-primary);
}

.video-modal-close svg {
  width: 18px;
  height: 18px;
  color: #fff;
}

/* ===== حاوية أي فيديو مضمَّن (نسبة 16:9 متجاوبة) ===== */
.ak-video-embed {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
}

.ak-video-embed iframe,
.ak-video-embed video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

@media (max-width: 1024px) {
  .video-gallery-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .video-gallery-grid {
    grid-template-columns: 1fr;
  }
  .video-modal-close {
    top: -44px;
  }
}
