/* Keep native video controls usable, including the built-in full-screen button. */
.source-video-wrap {
  width: min(100%, var(--source-video-max-width, 960px));
  max-width: 100%;
  margin: 12px auto;
}
.source-video,
.scenario-field .source-video,
.table-card .source-video {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  aspect-ratio: var(--source-video-ratio, 16 / 9);
  object-fit: contain;
}
.source-video-caption { display: flex; align-items: center; flex-wrap: wrap; }
.source-video-name { min-width: 0; overflow-wrap: anywhere; }
.source-video:focus-visible { outline: 3px solid #879af1; outline-offset: 3px; }

/* Give small videos room for browser controls; table overflow stays within the table. */
.scenario-field .doc-grid:has(.source-video) {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr));
}
.doc-table .source-video { min-width: 270px; }

/* Pair a single portrait demo with its original explanation instead of
   giving a narrow video an otherwise empty full-width dark strip. */
@media (min-width: 900px) {
  .scenario-record--single-video {
    grid-template-columns: minmax(0, 1fr) minmax(290px, 38%);
  }
  .scenario-record--single-video .scenario-field:not(:nth-child(3)) {
    grid-column: 1;
    border-right: 0;
    border-bottom: 1px solid #edf0f6;
  }
  .scenario-record--single-video .scenario-field:nth-child(1) { grid-row: 1; }
  .scenario-record--single-video .scenario-field:nth-child(2) { grid-row: 2; }
  .scenario-record--single-video .scenario-field:nth-child(4) { grid-row: 3; }
  .scenario-record--single-video .scenario-field:nth-child(5) { grid-row: 4; border-bottom: 0; }
  .scenario-record--single-video .scenario-field:nth-child(3) {
    grid-column: 2;
    grid-row: 1 / span 4;
    border-left: 1px solid #edf0f6;
    border-bottom: 0;
  }
}
