/* =====================================================================
 * Digital Trend — Media Player Modal Styles
 * Loaded globally via layout.ejs.
 * Covers both the direct-video modal and the YouTube modal.
 * ===================================================================== */

/* ── Shared modal shell ───────────────────────────────────────────────── */
.media-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 20px;
}

/* Completely hidden when the hidden attribute is present */
.media-modal[hidden] {
  display: none !important;
}

/* Semi-transparent backdrop sits behind the dialog */
.media-modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: rgba(0, 0, 0, 0.88);
  cursor: pointer;
}

/* Dialog card sits above the backdrop */
.media-modal-dialog {
  position: relative;
  z-index: 2;
  width: min(100%, 960px);
  max-height: 92vh;
  background: #050b18;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}

/* ── Close button ─────────────────────────────────────────────────────── */
.media-modal-close {
  position: absolute;
  /* In RTL the visual right side of the dialog is the physical left */
  top: 10px;
  left: 10px;
  z-index: 10;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.media-modal-close:hover { background: rgba(255, 255, 255, 0.18); }

/* ── Loader / Error overlay ───────────────────────────────────────────── */
.media-modal-loader,
.media-modal-error {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 30px;
  text-align: center;
  background: #050b18;
  color: #f1f5f9;
  font-size: 1rem;
  direction: rtl;
}

.media-modal-loader[hidden],
.media-modal-error[hidden] {
  display: none !important;
}

.media-modal-error-message {
  margin-bottom: 1rem;
  color: #fca5a5;
  font-size: 1rem;
  direction: rtl;
}

/* ── Error action buttons ─────────────────────────────────────────────── */
.media-modal-error-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  align-items: center;
  margin-top: 0.25rem;
}

.media-retry-button {
  display: inline-block;
  padding: 0.5rem 1.4rem;
  background: #1d4ed8;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.18s;
  direction: rtl;
}
.media-retry-button:hover { background: #2563eb; }

.media-direct-link {
  display: inline-block;
  padding: 0.5rem 1.2rem;
  background: transparent;
  color: #60a5fa;
  border: 1px solid rgba(96, 165, 250, 0.4);
  border-radius: 6px;
  font-size: 0.9rem;
  text-decoration: none;
  transition: border-color 0.18s, color 0.18s;
  direction: rtl;
}
.media-direct-link:hover { color: #93c5fd; border-color: rgba(147, 197, 253, 0.5); }
.media-direct-link[hidden] { display: none !important; }

/* ── Loader spinner ───────────────────────────────────────────────────── */
.media-loader-spinner {
  display: block;
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: #60a5fa;
  border-radius: 50%;
  animation: media-spin 0.75s linear infinite;
  margin-bottom: 0.75rem;
}
@keyframes media-spin {
  to { transform: rotate(360deg); }
}

/* ── YouTube player ───────────────────────────────────────────────────── */
.youtube-player-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  /* Must NOT have height:0 — aspect-ratio handles the height */
}

/* The iframe must fill the wrapper absolutely */
.youtube-player-wrapper iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  opacity: 1;
  visibility: visible;
}

/* ── Direct video player ──────────────────────────────────────────────── */
.direct-modal-video {
  display: block;
  width: 100%;
  max-height: 82vh;
  background: #000;
  object-fit: contain;
}

/* ── YouTube fallback link ────────────────────────────────────────────── */
.youtube-fallback-link {
  display: inline-block;
  margin-top: 0.5rem;
  color: #60a5fa;
  text-decoration: underline;
  font-size: 0.95rem;
}
.youtube-fallback-link[hidden] { display: none !important; }

/* ── Body scroll-lock ─────────────────────────────────────────────────── */
body.modal-open { overflow: hidden; }

/* ── Shared video card (all categories) ──────────────────────────────── */
.portfolio-video-card {
  display: block;
  background: var(--bg-card, #0E1628);
  border: 1px solid var(--border, rgba(59, 130, 246, 0.12));
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: transform 0.22s ease, border-color 0.22s ease;
  text-align: right;
  width: 100%;
  padding: 0;
  /* Reset <button> defaults */
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  color: inherit;
}
.portfolio-video-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover, rgba(59, 130, 246, 0.28));
}

.portfolio-video-card .card-thumb-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #000;
}

.portfolio-video-card .card-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.portfolio-video-card .card-thumb-fallback {
  width: 100%;
  height: 100%;
  background: var(--bg-card2, #121D35);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim, #64748B);
}

.portfolio-video-card .card-play-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.portfolio-video-card .card-info {
  padding: 0.65rem 0.75rem;
}
.portfolio-video-card .card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text, #F1F5F9);
  margin: 0;
}
.portfolio-video-card .card-brand {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--orange-light, #FB923C);
  background: rgba(249, 115, 22, 0.1);
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  margin-top: 0.25rem;
}

/* ── Mobile adjustments ───────────────────────────────────────────────── */
@media (max-width: 480px) {
  .media-modal          { padding: 10px; }
  .media-modal-dialog   { border-radius: 10px; }
  .media-modal-close    { top: 6px; left: 6px; width: 36px; height: 36px; font-size: 22px; }
}
