/* Reusable protected-video page. Inherits RP theme tokens (themes.css) so it tracks the site's
   light/dark palette automatically. */

.video-page__container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.video-page__header {
  text-align: center;
}

.video-page__title {
  margin: 0;
  color: var(--text-primary);
}

/* The stage owns the responsive width; size toggles just change its max-width. */
.video-stage {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  transition: max-width 0.2s ease;
}

.video-stage.is-theater {
  max-width: 1200px;
}

.video-stage__frame {
  position: relative;
  width: 100%;
  aspect-ratio: var(--video-aspect, 16 / 9);
  background: #000;
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.video-stage__el {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
  object-fit: contain;
}

.video-page__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.video-size-btn {
  appearance: none;
  border: 1px solid var(--border-color);
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  padding: 0.4rem 1rem;
  border-radius: var(--border-radius-full);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.video-size-btn:hover {
  border-color: var(--border-color-focus);
  color: var(--text-primary);
}

.video-size-btn.is-active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--text-inverse);
}

.video-page__desc {
  max-width: 720px;
  text-align: center;
  color: var(--text-muted);
  margin: 0;
}

.video-page__cta {
  display: flex;
  justify-content: center;
}

@media (max-width: 640px) {
  .video-stage,
  .video-stage.is-theater {
    max-width: 100%;
  }
}

/* --- Movie / Document tab toggle (segmented pill) + panels --------------------------------- */
.view-tabs {
  display: inline-flex;
  gap: 0.25rem;
  align-self: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-full);
  padding: 0.25rem;
}

.view-tab {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 0.4rem 1.4rem;
  border-radius: var(--border-radius-full);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.view-tab:hover { color: var(--text-primary); }

.view-tab.is-active {
  background: var(--color-primary);
  color: var(--text-inverse);
  font-weight: 600;
}

.view-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.view-panel[hidden] { display: none; }

/* --- Document lane (protected SharePoint embed) -------------------------------------------- */
.doc-stage {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
}

.doc-stage__frame {
  display: block;
  width: 100%;
  height: 75vh;
  min-height: 460px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  background: var(--bg-surface-elevated);
}

@media (max-width: 640px) {
  .doc-stage__frame { height: 68vh; min-height: 360px; }
}

/* --- DRM tier (self-hosted PlayReady): reusable protected-media component -------------------- */
.rp-drm {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}
.rp-drm--image { max-width: 720px; }

.rp-drm__frame {
  position: relative;
  width: 100%;
  aspect-ratio: var(--drm-aspect, 16 / 9);
  background: #000;
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.rp-drm__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
  object-fit: contain;
}

/* Image kind renders as a static picture — no pointer affordances, no right-click save/drag. */
.rp-drm--image .rp-drm__video {
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

.rp-drm__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  text-align: center;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
}
.rp-drm__overlay[hidden] { display: none; }

.rp-drm__spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  animation: rp-drm-spin 0.8s linear infinite;
}
.rp-drm__spinner[hidden] { display: none; }
@keyframes rp-drm-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .rp-drm__spinner { animation-duration: 2.4s; }
}

.rp-drm__panel {
  max-width: 30rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}
.rp-drm__panel[hidden] { display: none; }
.rp-drm__panel-title { margin: 0; font-size: 1.1rem; font-weight: 600; color: #fff; }
.rp-drm__panel-body { margin: 0; font-size: 0.95rem; color: rgba(255, 255, 255, 0.85); line-height: 1.5; }
.rp-drm__panel-cta { margin-top: 0.25rem; }

.rp-drm__caption {
  margin: 0.6rem 0 0;
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Per-browser capture notice — filled by rp-drm-player.js from the negotiated key system. Honest
   about whether screenshots black out on THIS browser. Rendered outside the protected surface. */
.rp-drm__notice {
  margin: 0.5rem 0 0;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  opacity: 0.85;
}

/* Diagnostics (?diag=1) — rendered OUTSIDE the protected surface so it screenshots even when the
   media is black; a failed stage tells you exactly which hop broke. */
.rp-drm__diag {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--border-radius);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: left;
}
.rp-drm__diag-line.is-ok { color: #2e7d32; }
.rp-drm__diag-line.is-bad { color: #c62828; }

/* Gallery grid of protected items (each cell an independent player instance). */
.rp-drm-gallery {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  align-items: start;
}
.rp-drm-gallery .rp-drm { max-width: 100%; }
.rp-drm-gallery__empty { grid-column: 1 / -1; text-align: center; color: var(--text-muted); }

@media (max-width: 640px) {
  .rp-drm,
  .rp-drm--image { max-width: 100%; }
}

/* --- Closed captions: reusable CC control (both tiers) + caption rendering ------------------ */
.rp-cc-slot {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.rp-cc-btn {
  appearance: none;
  border: 1px solid var(--border-color);
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  padding: 0.4rem 0.9rem;
  border-radius: var(--border-radius-full);
  font: 600 0.8rem/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.rp-cc-btn:hover { border-color: var(--border-color-focus); color: var(--text-primary); }
.rp-cc-btn.is-on {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--text-inverse);
}
.rp-cc-btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.rp-cc-lang {
  border: 1px solid var(--border-color);
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  padding: 0.35rem 0.5rem;
  border-radius: var(--border-radius);
  font-size: 0.85rem;
  cursor: pointer;
}
.rp-cc-lang:disabled { opacity: 0.5; cursor: default; }

/* DRM tier controls bar (below the frame — the CC slot mounts here). */
.rp-drm__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.75rem;
}

/* Caption text: white on a translucent backing, readable over any video (captions always sit over
   dark video, so this is theme-independent). Covers native <track> (::cue) and Shaka's displayer. */
::cue {
  color: #fff;
  background-color: rgba(0, 0, 0, 0.75);
  font-size: 1rem;
  line-height: 1.35;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}
.shaka-text-container { font-size: 1rem !important; }
.shaka-text-container span {
  background-color: rgba(0, 0, 0, 0.75) !important;
  color: #fff !important;
}
