/* Task 1303 — self-service ordered lesson media authoring. */
.operator-topic-update-form .lesson-block-add-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: flex-end;
}

.operator-topic-update-form .lesson-author-block-toolbar > span {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.operator-topic-update-form :is([data-image-fields], [data-media-fields], [data-embed-fields], [data-caption-fields]) {
  margin-top: .75rem;
}

.operator-topic-update-form :is(.lesson-block-video-preview, .lesson-image-insert-preview) {
  display: block;
  height: auto;
  margin: 0 auto .75rem;
  max-height: 320px;
  max-width: 100%;
  object-fit: contain;
}

.operator-topic-update-form .lesson-block-audio-preview {
  display: block;
  margin-bottom: .75rem;
  max-width: 100%;
  width: 100%;
}

.operator-topic-update-form :is(.lesson-block-video-preview, .lesson-block-audio-preview, .lesson-image-insert-preview)[hidden] {
  display: none;
}

.lesson-image-insert-dialog {
  background: #fffdf8;
  border: 1px solid rgba(98, 83, 65, .24);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(39, 32, 26, .22);
  box-sizing: border-box;
  color: #332d28;
  max-height: min(720px, calc(100dvh - 32px));
  max-width: min(620px, calc(100vw - 32px));
  overflow: auto;
  padding: 24px;
  width: 100%;
}

.lesson-image-insert-dialog::backdrop {
  background: rgba(34, 30, 25, .48);
}

.lesson-image-insert-dialog h3 {
  margin-top: 0;
}

.lesson-image-insert-context {
  background: rgba(239, 232, 219, .72);
  border-radius: 10px;
  overflow-wrap: anywhere;
  padding: 12px;
  white-space: pre-wrap;
}

.lesson-image-insert-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

.lesson-page :is(.lesson-authored-media, .lesson-authored-embed) {
  margin: 1rem auto;
  max-width: 720px;
  text-align: center;
}

.lesson-page .lesson-authored-media video,
.lesson-page .lesson-authored-embed iframe {
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: 12px;
  display: block;
  max-width: 100%;
  width: 100%;
}

.lesson-page .lesson-authored-audio audio {
  max-width: 100%;
  width: 100%;
}

.lesson-page .lesson-authored-resource {
  margin: 1rem 0;
  text-align: center;
}

@media (max-width: 720px) {
  .operator-topic-update-form .lesson-block-editor-heading {
    align-items: stretch;
  }

  .operator-topic-update-form .lesson-block-add-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
  }

  .operator-topic-update-form .lesson-block-add-actions .btn {
    min-height: 44px;
    white-space: normal;
  }

  .lesson-image-insert-dialog {
    padding: 18px;
  }

  .lesson-image-insert-actions > * {
    min-height: 44px;
  }
}
