/* ===========================================================================
   v049 — reachable controls  (fixes found while testing at 150% interface size)
   ---------------------------------------------------------------------------
   1. Interface size uses `zoom` on <html>, but `zoom` does NOT move the
      @media breakpoints. An 820px tablet at 150% still matches the "wide"
      rules while only ~547px of usable width remains, so the desktop filter
      grid overflows and the last column is clipped off screen with no way to
      scroll to it. src/ui-scale.mjs now publishes the width the user really
      has on <html data-ui-eff="narrow|mid|wide">; these rules let the grid
      collapse by that value instead.

   2. The paper workspace could hide BOTH "Finish paper" buttons at once: the
      one in the answer-book footer is display:none in split mode (v031.css)
      and the one in the header only showed in original mode (v042.css), so
      there was no way to submit a finished paper. The header now owns the
      single finish action and the footer duplicate is dropped.
   =========================================================================== */

/* ---------- 1. collapse the practice filter grid by EFFECTIVE width ----------
   Attribute selectors are used on purpose: media queries cannot see the zoom,
   so they are the wrong tool for this job. Only the mid/narrow cases are
   touched, so a genuinely wide screen keeps the desktop grid untouched. */
html[data-ui-eff="mid"] body.ial-v030 .practicePrimaryFilters,
html[data-ui-eff="mid"] body.ial-v030:not(.workspace-mode) .practicePrimaryFilters {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

html[data-ui-eff="narrow"] body.ial-v030 .practicePrimaryFilters,
html[data-ui-eff="narrow"] body.ial-v030:not(.workspace-mode) .practicePrimaryFilters {
  grid-template-columns: minmax(0, 1fr) !important;
}

html[data-ui-eff="mid"] body.ial-v030 .advancedFilters.show {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

html[data-ui-eff="narrow"] body.ial-v030 .advancedFilters.show {
  grid-template-columns: minmax(0, 1fr) !important;
}

/* Keep the fields from being forced wider than the column they sit in. */
html[data-ui-eff="narrow"] body.ial-v030 .practicePrimaryFilters .filterField,
html[data-ui-eff="mid"] body.ial-v030 .practicePrimaryFilters .filterField,
html[data-ui-eff="narrow"] body.ial-v030 .advancedFilters .filterField,
html[data-ui-eff="mid"] body.ial-v030 .advancedFilters .filterField {
  min-width: 0 !important;
}

html[data-ui-eff="narrow"] body.ial-v030 .practicePrimaryFilters select,
html[data-ui-eff="mid"] body.ial-v030 .practicePrimaryFilters select {
  max-width: 100% !important;
}

/* A safety net: if anything still overflows, make it reachable by scrolling
   rather than silently clipping it away. */
html[data-ui-eff="narrow"] body.ial-v030 .practiceFilterBar,
html[data-ui-eff="mid"] body.ial-v030 .practiceFilterBar {
  overflow-x: auto !important;
}

/* ---------- 2. one Finish paper, always visible ---------- */
body.ial-v030 .paperFinishOriginalBtn {
  display: inline-flex !important;
}

/* The footer copy sat in the answer book, which is hidden in split mode and in
   original mode alike, so it is dropped in favour of the header button. */
body.ial-v030 .paperAnswerBottom #finishPaperBtn {
  display: none !important;
}

/* Keep the header action row from pushing the Finish button out of view when
   the interface is enlarged. */
html[data-ui-eff="narrow"] body.ial-v030 .paperWorkspaceTop,
html[data-ui-eff="mid"] body.ial-v030 .paperWorkspaceTop {
  flex-wrap: wrap !important;
}

html[data-ui-eff="narrow"] body.ial-v030 .paperWorkspaceActions,
html[data-ui-eff="mid"] body.ial-v030 .paperWorkspaceActions {
  flex-wrap: wrap !important;
  justify-content: flex-end !important;
}
