
/* The listening root occupies the space below the shared exam header. Give its
   content and save status separate rows so long questions can always scroll. */
html:root body.ft-official-exam-active #ft-listening-root .ftl-shell[data-ft-official-surface="listening"] {
  box-sizing: border-box;
  height: 100%;
  min-height: 0 !important;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

html:root body.ft-official-exam-active #ft-listening-root [data-ft-official-surface="listening"] .ftl-practice-body {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-width: 0;
  min-height: 0;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: auto;
}

html:root body.ft-official-exam-active #ft-listening-root [data-ft-official-surface="listening"] .ftl-task-layout {
  box-sizing: border-box;
  flex: 1 0 auto;
  width: 100%;
  max-width: none;
  min-height: 0 !important;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) !important;
  align-items: stretch;
}

html:root body.ft-official-exam-active #ft-listening-root [data-ft-official-surface="listening"] :is(.ftl-visual-panel, .ftl-task-panel) {
  box-sizing: border-box;
  min-height: 0;
  align-self: stretch;
  margin: 0;
  border: 0;
  padding: clamp(20px, 5vh, 52px) clamp(20px, 3.5vw, 72px) !important;
}

html:root body.ft-official-exam-active #ft-listening-root [data-ft-official-surface="listening"] .ftl-visual-panel {
  display: grid;
  place-items: start center;
  border-right: 1px solid #d5dce0 !important;
}

html:root body.ft-official-exam-active #ft-listening-root [data-ft-official-surface="listening"] .ftl-task-panel {
  display: flex;
  justify-content: flex-start;
  align-items: center !important;
}

html:root body.ft-official-exam-active #ft-listening-root [data-ft-official-surface="listening"] :is(.ftl-question-copy, .ftl-audio-copy, .ftl-held) {
  width: 100%;
  max-width: 76ch;
  min-width: 0;
  overflow-wrap: anywhere;
}

#ft-listening-root .ftl-visual-panel .ftl-scene {
  width: min(100%, 640px);
  padding: 0;
}

#ft-listening-root .ftl-visual-panel .ftl-scene > img,
#ft-listening-root .ftl-visual-panel > .ftl-person-photo {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: min(40vh, 400px);
  margin: 0 auto;
  aspect-ratio: auto;
  object-fit: contain;
}

html:root body.ft-official-exam-active #ft-listening-root [data-ft-official-surface="listening"] .ftl-exam-footer {
  box-sizing: border-box;
  position: static;
  min-height: 36px !important;
  padding: 8px clamp(16px, 2.5vw, 48px);
}

/* Next is operated through the shared header. Keep the original button in
   the DOM for its handler, without reserving a second button-sized footer. */
#ft-listening-root [data-ft-official-surface="listening"] .ftl-exam-footer [data-ftl-next] {
  display: none !important;
}

#ft-listening-root .ftl-complete {
  box-sizing: border-box;
  width: min(100%, 76rem);
  margin: 0 auto;
  padding: clamp(20px, 4vh, 48px) clamp(16px, 4vw, 64px);
  overflow-wrap: anywhere;
}

#ft-listening-root :is(.ftl-complete-actions, .ftl-header-actions) {
  flex-wrap: wrap;
}

@media (max-width: 700px) {
  html:root body.ft-official-exam-active #ft-listening-root [data-ft-official-surface="listening"] .ftl-task-layout {
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: auto 1fr;
  }

  html:root body.ft-official-exam-active #ft-listening-root [data-ft-official-surface="listening"] .ftl-visual-panel {
    min-height: 0 !important;
    border-right: 0 !important;
    padding: 12px 16px !important;
  }

  #ft-listening-root .ftl-visual-panel .ftl-listening-emblem {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 12px;
    max-width: 100%;
    padding: 0;
  }

  #ft-listening-root .ftl-visual-panel .ftl-wave {
    display: none;
  }

  #ft-listening-root .ftl-visual-panel .ftl-scene > img,
  #ft-listening-root .ftl-visual-panel > .ftl-person-photo {
    max-height: 18vh;
  }
}

