/* JR Landscape + Tablet Memory Table Fix */

body.jr-memory-page.jr-mobile-landscape,
body.jr-memory-page.jr-tablet {
  overflow-x: hidden !important;
}

body.jr-memory-page.jr-mobile-landscape #content-wrap,
body.jr-memory-page.jr-mobile-landscape .content-wrap,
body.jr-memory-page.jr-mobile-landscape #bp-memory-form-wrapper,
body.jr-memory-page.jr-mobile-landscape #memory-forms-container,
body.jr-memory-page.jr-mobile-landscape #memory-forms-container .memory-entry,
body.jr-memory-page.jr-tablet #content-wrap,
body.jr-memory-page.jr-tablet .content-wrap,
body.jr-memory-page.jr-tablet #bp-memory-form-wrapper,
body.jr-memory-page.jr-tablet #memory-forms-container,
body.jr-memory-page.jr-tablet #memory-forms-container .memory-entry {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

body.jr-memory-page.jr-mobile-landscape #memory-forms-container,
body.jr-memory-page.jr-tablet #memory-forms-container {
  margin-left: auto !important;
  margin-right: auto !important;
}

body.jr-memory-page.jr-mobile-landscape #bp-memory-form-wrapper,
body.jr-memory-page.jr-tablet #bp-memory-form-wrapper {
  overflow-x: hidden !important;
}

/* Reset portrait-only hard width plugins */
body.jr-memory-page.jr-mobile-landscape #bp-memory-form-wrapper .memory-entry .table-container,
body.jr-memory-page.jr-mobile-landscape #bp-memory-form-wrapper .memory-entry .table-container.table-container,
body.jr-memory-page.jr-tablet #bp-memory-form-wrapper .memory-entry .table-container,
body.jr-memory-page.jr-tablet #bp-memory-form-wrapper .memory-entry .table-container.table-container {
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  display: block !important;
}

/* Defeat broad base rules that turn the TABLE into the scroller */
body.jr-memory-page.jr-mobile-landscape #bp-memory-form-wrapper .memory-entry .table-container table,
body.jr-memory-page.jr-mobile-landscape #bp-memory-form-wrapper .memory-entry .table-container table.jr-mt-freeze2-target,
body.jr-memory-page.jr-tablet #bp-memory-form-wrapper .memory-entry .table-container table,
body.jr-memory-page.jr-tablet #bp-memory-form-wrapper .memory-entry .table-container table.jr-mt-freeze2-target {
  display: table !important;
  width: max-content !important;
  min-width: 100% !important;
  max-width: none !important;
  table-layout: auto !important;
}

/* Use the scroll wrapper as the ONLY horizontal scroller */
body.jr-memory-page.jr-mobile-landscape #bp-memory-form-wrapper .memory-entry .table-container .jr-mt-scroll,
body.jr-memory-page.jr-mobile-landscape #bp-memory-form-wrapper .memory-entry .table-container .jr-lt-mt-scroll,
body.jr-memory-page.jr-tablet #bp-memory-form-wrapper .memory-entry .table-container .jr-mt-scroll,
body.jr-memory-page.jr-tablet #bp-memory-form-wrapper .memory-entry .table-container .jr-lt-mt-scroll {
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  display: block !important;
  overflow-x: auto !important;
  overflow-y: visible !important;
  -webkit-overflow-scrolling: touch !important;
  box-sizing: border-box !important;
  padding-bottom: 8px !important;
}

/* If the table is already wrapped, container itself must not become another scroller */
body.jr-memory-page.jr-mobile-landscape #bp-memory-form-wrapper .memory-entry .table-container,
body.jr-memory-page.jr-tablet #bp-memory-form-wrapper .memory-entry .table-container {
  overflow-x: hidden !important;
  overflow-y: visible !important;
}

/* Keep cells from forcing the whole page wide */
body.jr-memory-page.jr-mobile-landscape #bp-memory-form-wrapper .memory-entry .table-container th,
body.jr-memory-page.jr-mobile-landscape #bp-memory-form-wrapper .memory-entry .table-container td,
body.jr-memory-page.jr-tablet #bp-memory-form-wrapper .memory-entry .table-container th,
body.jr-memory-page.jr-tablet #bp-memory-form-wrapper .memory-entry .table-container td {
  white-space: nowrap;
  background-clip: padding-box !important;
}

/* Preserve sticky frozen columns when present */
body.jr-memory-page.jr-mobile-landscape #bp-memory-form-wrapper .memory-entry .table-container .jr-mt-scroll > table.jr-mt-freeze2-target th:nth-child(1),
body.jr-memory-page.jr-mobile-landscape #bp-memory-form-wrapper .memory-entry .table-container .jr-mt-scroll > table.jr-mt-freeze2-target td:nth-child(1),
body.jr-memory-page.jr-tablet #bp-memory-form-wrapper .memory-entry .table-container .jr-mt-scroll > table.jr-mt-freeze2-target th:nth-child(1),
body.jr-memory-page.jr-tablet #bp-memory-form-wrapper .memory-entry .table-container .jr-mt-scroll > table.jr-mt-freeze2-target td:nth-child(1) {
  position: sticky !important;
  left: 0 !important;
  z-index: 6;
}

body.jr-memory-page.jr-mobile-landscape #bp-memory-form-wrapper .memory-entry .table-container .jr-mt-scroll > table.jr-mt-freeze2-target th:nth-child(2),
body.jr-memory-page.jr-mobile-landscape #bp-memory-form-wrapper .memory-entry .table-container .jr-mt-scroll > table.jr-mt-freeze2-target td:nth-child(2),
body.jr-memory-page.jr-tablet #bp-memory-form-wrapper .memory-entry .table-container .jr-mt-scroll > table.jr-mt-freeze2-target th:nth-child(2),
body.jr-memory-page.jr-tablet #bp-memory-form-wrapper .memory-entry .table-container .jr-mt-scroll > table.jr-mt-freeze2-target td:nth-child(2) {
  position: sticky !important;
  left: var(--jr-col1, 40px) !important;
  z-index: 5;
}

body.jr-memory-page.jr-mobile-landscape #bp-memory-form-wrapper .memory-entry .table-container .jr-mt-scroll > table.jr-mt-freeze2-target th,
body.jr-memory-page.jr-tablet #bp-memory-form-wrapper .memory-entry .table-container .jr-mt-scroll > table.jr-mt-freeze2-target th {
  z-index: 10;
}
