/* ==========================================================================
   quizvie-responsive-learning.css
   Mobile/tablet responsive overrides for the LM/FM learning & authoring
   screens (makers, tests, study, results, similar-question, embedded).

   - Loaded LAST on every page, after the page's own stylesheet, so
     equal-specificity rules here win by cascade. !important is used only
     where JS/inline sizing or later duplicated page rules must be beaten.
   - Every rule lives inside a max-width media query: desktop (>=1024px)
     is completely untouched.
   - This file is linked from every page of the app, so selectors are
     scoped to learning-screen structures (.FM-maker, .LM__maker,
     .result-view, .player-section, .OMR-cell, ...).

   Breakpoints:
     <=1023px  tablets and below (768px tablets included)
     <=767px   phones (360 / 375 / 390 / 430)
     <=480px   small phones fine-tuning
     landscape phones: (orientation: landscape) and (max-height: 520px)
   ========================================================================== */

/* ==========================================================
   TABLET AND BELOW  (<=1023px)
   ========================================================== */
@media (max-width: 1023px) {

  /* ---- horizontal overflow guards (learning screens) ---- */
  body#body,
  #bottom-body,
  .bottom {
    overflow-x: hidden;
  }

  .FM-maker img,
  .FM-question img,
  .FM-maker canvas {
    max-width: 100%;
    height: auto;
  }

  .LM-Video,
  .LM-Video iframe {
    max-width: 100%;
  }

  .LM-Video iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
  }

  /* ---- shared FM top menu: fixed 45rem (720px) button row ---- */
  .top-menu {
    flex-wrap: wrap;
    row-gap: 0.25rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    box-sizing: border-box;
  }

  .top-menu__btns {
    width: auto;
    max-width: 100%;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .top-menu__login-info {
    width: auto;
    max-width: 45%;
  }

  /* ---- LM / contents top bar ---- */
  .top-bar {
    flex-wrap: wrap;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    box-sizing: border-box;
  }

  /* main-FM-Contents-maker is the only learning page combining a fixed
     .top-bar with an .FM-maker card; clear the bar instead of the
     desktop negative margin */
  body:has(.top-bar) .FM-maker {
    margin-top: 5.5rem;
  }

  /* ---- touch targets >= 40px on primary actions ---- */
  .top-menu-btn,
  .bottom__btn,
  .bottom__btn--prev,
  .bottom__btn--next,
  .prev-btn,
  .next-btn,
  .FM-footer-btn,
  .FM-maker__footer-cancel,
  .FM-maker__footer-enroll,
  .FM-maker-menu-btn,
  .setting__save-btn,
  .submit-btn,
  .result__btn,
  .selection__bottom__btn,
  .omr__bottom__btn,
  .typing__bottom__btn,
  .preview-btn,
  .FM-question-Ordering__btn,
  .step-btn,
  .top-bar-btn,
  .top-bar__save,
  .top-bar__finish {
    min-height: 2.5rem;
    min-width: 2.5rem;
    box-sizing: border-box;
  }

  /* ---- oversized fixed-position modals (LM step4 + Result-Total) ---- */
  .modal1__view,
  .modal5__view {
    width: min(94vw, 45rem);
    height: auto;
    min-height: 16rem;
    max-height: 88vh;
    overflow-y: auto;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-sizing: border-box;
  }

  /* ---- absolute dropdown overlays ---- */
  .dropdown-content {
    max-width: calc(100vw - 1rem);
  }

  .bottom__btn__type-btn {
    max-width: calc(100vw - 2rem);
  }

  /* ---- elements pushed off-canvas with margin-left: 45rem ---- */
  .plus-btn {
    margin-left: 0;
    left: auto;
    right: 1rem;
  }

  /* ---- LM maker (maker-LM__step1 / step4): stack video + editor ---- */
  .LM__maker {
    width: 94%;
    margin-left: auto;
    margin-right: auto;
    height: auto;
    flex-direction: column;
  }

  .maker__section-video {
    width: 100%;
    height: auto;
    margin: 0 0 1rem 0;
  }

  .maker__section-video .section-video__video {
    width: 100%;
    height: 52vw;
    max-height: 24rem;
    position: relative;
  }

  .maker__section-main-inputs {
    width: 100%;
    height: auto;
  }

  .maker__section {
    width: 100%;
    height: auto;
  }

  .steps,
  .LM__desc,
  .test-control {
    width: 94%;
    margin-left: auto;
    margin-right: auto;
  }

  .test-control {
    height: auto;
    min-height: 7rem;
  }

  .slidecontainer {
    width: 90%;
  }

  /* ---- embedded loader: JS injects <iframe width="960" height="800"> ---- */
  #root {
    width: 100%;
    overflow-x: hidden;
  }

  #root iframe {
    width: 100% !important;
    height: 100vh !important;
    height: 100dvh !important;
    border: 0;
  }
}

/* ==========================================================
   PHONES  (<=767px)
   ========================================================== */
@media (max-width: 767px) {

  /* ---- FM card shells (makers, test, loader, similar, review) ---- */
  .FM-maker {
    width: 96%;
    height: auto;
    max-height: none;
    margin-top: 0;
  }

  .FM-maker__title {
    width: 96%;
    height: auto;
    min-height: 2rem;
    padding: 0.75rem 0.5rem;
    box-sizing: border-box;
  }

  .FM-maker__bottom {
    width: 100%;
    height: auto;
    padding: 1rem 0.75rem;
    box-sizing: border-box;
  }

  .FM-top-infos {
    flex-wrap: wrap;
    row-gap: 0.5rem;
  }

  /* question blocks: kill fixed widths (e.g. 30rem in similarQ_maker) */
  .FM-question,
  .FM-question-Selection,
  .FM-question-Ordering,
  .FM-question-TandF,
  .FM-question-Typing,
  .FM-question-Blank,
  .FM-question-Matching {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* answer choices readable + tappable in test/review lists */
  .selections__selection {
    height: auto;
    min-height: 2.5rem;
    box-sizing: border-box;
  }

  /* ---- main-FM-maker create dialog: stack label/value rows ---- */
  .maker-row {
    flex-wrap: wrap;
    height: auto;
    min-height: 2.6rem;
  }

  .maker-row .row-desc {
    width: 100%;
  }

  .maker-row .row-right {
    width: 100%;
  }

  /* ---- question maker editors & footers ---- */
  .FM-maker-editor {
    width: 100%;
    max-width: 100%;
    height: 18rem;
  }

  .FM-maker__footer {
    width: 100%;
    height: auto;
    flex-wrap: wrap;
    row-gap: 0.5rem;
  }

  .bottom__btns {
    width: 100%;
    height: auto;
    min-height: 2.5rem;
  }

  .bottom__btn {
    height: auto;
    padding: 0.4rem 0.5rem;
  }

  /* answer/choice editor rows (Blank/Selection/Typing/TandF): keep room
     for the absolute +/- circles enlarged to 40px */
  .FM-maker__answer-row,
  .selection-row,
  .FM-maker__answer {
    max-width: calc(100% - 3rem);
  }

  .selection__delete,
  .selection__plus,
  .answer__add,
  .answer__delete {
    width: 2.5rem;
    height: 2.5rem;
    margin-right: -2.9rem;
  }

  /* ---- matching maker: stack the two 15rem columns ---- */
  .match-row {
    flex-wrap: wrap;
    height: auto;
    row-gap: 0.4rem;
  }

  .match-row__question,
  .match-row__answer {
    width: calc(100% - 3rem);
    margin-right: 0;
  }

  /* ---- OMR (maker + study-OMR): full-width rows, 40px bubbles ---- */
  .OMR-cell {
    width: 100%;
    max-width: 24rem;
    height: auto;
    min-height: 3rem;
  }

  .OMR-selection {
    width: 2.5rem;
    height: 2.5rem;
    margin-right: 0.4rem;
  }

  .FM-maker__OMR {
    width: 96%;
  }

  /* stray fixed-width voice row in maker settings */
  .detail__voice {
    width: 100%;
    max-width: 45rem;
    height: auto;
    min-height: 1.5rem;
    flex-wrap: wrap;
  }

  /* ---- mobile-FM: fixed 800px list / 5rem paddings ---- */
  .FM-questions {
    height: auto;
  }

  .FM-questions .FM-question {
    padding-top: 2rem;
  }

  /* ---- study player pages (learning-mode-study / embededLM) ---- */
  .title-section,
  .desc-section {
    width: 94%;
  }

  .wrapper {
    width: 94%;
    height: auto;
  }

  .player-section {
    width: 100%;
    height: 58vw;
    max-height: 25rem;
  }

  .controller-section {
    width: 100%;
    height: auto;
    min-height: 3.25rem;
    flex-wrap: wrap;
    row-gap: 0.25rem;
  }

  .controller__playBtn {
    min-width: 2.5rem;
    min-height: 2.5rem;
  }

  .controller__playBar-section {
    width: auto;
    flex: 1 1 10rem;
    min-width: 8rem;
  }

  /* quiz overlay over the video: let long questions scroll, keep the
     submit row reachable */
  .quiz-section {
    overflow-y: auto;
  }

  .omr__selection {
    font-size: 1.2rem;
  }

  .selection__bottom__btn,
  .omr__bottom__btn,
  .typing__bottom__btn {
    width: auto;
    min-width: 6rem;
    height: auto;
    padding: 0.3rem 0.75rem;
  }

  /* caption list was pushed off-screen with margin-right:-260% */
  .caption-list-view {
    margin-right: 0;
    right: 0.5rem;
    left: auto;
    max-width: 82vw;
    max-height: 50vh;
    overflow-y: auto;
  }

  /* ---- middle/final result cards (desktop + mobile + embedded) ---- */
  .result-view {
    width: 96%;
    height: auto;
    min-height: 55vh;
    margin-top: 0;
  }

  .result__btns {
    width: 100%;
    max-width: 22rem;
    height: auto;
    flex-direction: column;
    align-items: center;
    row-gap: 0.6rem;
  }

  .result__btn {
    width: 100%;
    max-width: 16rem;
    height: 3.25rem;
  }

  /* ---- result-total statistics: 4-across chart row -> 2x2 ---- */
  .FM-middle-statistics {
    flex-wrap: wrap;
    row-gap: 1rem;
  }

  .middle-statistics1,
  .middle-statistics2,
  .middle-statistics3,
  .middle-statistics4 {
    width: 50%;
    min-width: 8.5rem;
    box-sizing: border-box;
  }

  /* ---- mobile result pages: fixed bottom bars ---- */
  .FM-maker:has(> .bottom__btns) {
    padding-bottom: 5.5rem;
    box-sizing: border-box;
  }

  .FM-maker:has(> .bottom__btns) > .bottom__btns {
    left: 0;
    bottom: 0;
    z-index: 50;
    padding-bottom: env(safe-area-inset-bottom);
  }

  body#body:has(.bottom__btns--mobile) .FM-maker {
    padding-bottom: 5.5rem;
    box-sizing: border-box;
  }

  .bottom__btns--mobile {
    height: auto;
    min-height: 3rem;
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 50;
  }

  /* ---- FM-loader search row ---- */
  .search-bar {
    max-width: 100%;
  }

  .search-input {
    max-width: 65vw;
  }

  /* ---- misc maker settings ---- */
  .setting__save-btn {
    margin-bottom: 2rem;
  }
}

/* ==========================================================
   SMALL PHONES  (<=480px: 360 / 375 / 390 / 430)
   ========================================================== */
@media (max-width: 480px) {

  .FM-maker,
  .FM-maker__title {
    width: 98%;
  }

  .FM-maker__bottom {
    padding: 0.75rem 0.5rem;
  }

  .FM-maker__title {
    font-size: 1.25rem;
  }

  .FM-maker-editor {
    height: 15rem;
  }

  .FM-maker-menu-btn {
    font-size: 0.85rem;
  }

  .result-view {
    width: 100%;
  }

  .top-menu-btn {
    width: auto;
    padding: 0.3rem 0.5rem;
  }

  .OMR-cell {
    max-width: 100%;
  }

  .OMR-selection {
    margin-right: 0.25rem;
  }
}

/* ==========================================================
   LANDSCAPE PHONES  (short viewports)
   ========================================================== */
@media (max-width: 1023px) and (orientation: landscape) and (max-height: 520px) {

  /* keep the video visible without swallowing the whole viewport */
  .player-section {
    height: 62vh;
    max-height: none;
  }

  .maker__section-video .section-video__video {
    height: 55vh;
    max-height: none;
  }

  .FM-maker-editor {
    height: 12rem;
  }

  .result-view {
    min-height: 0;
  }

  /* stack result buttons back into a wrapping row to save height */
  .result__btns {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 100%;
    column-gap: 0.6rem;
  }

  .result__btn {
    width: auto;
    min-width: 9rem;
  }

  .modal1__view,
  .modal5__view {
    max-height: 94vh;
  }

  .top-bar {
    min-height: 2.75rem;
  }

  body:has(.top-bar) .FM-maker {
    margin-top: 4.5rem;
  }
}
