/* Presentation adapter for the existing exam shell and reading split layout.
   The placement test retains its original questions, audio and scoring script. */
body.reading-exam-layout {
  --panel: #fff;
  --line: #dce3ea;
  --reading-font-size: 18px;
}

body:has(.exam-page:not(.hidden)) { overflow: hidden; }
body:has(.exam-page:not(.hidden)) > .app {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  margin: 0;
  padding: 0;
}
body:has(.exam-page:not(.hidden)) .header {
  flex: 0 0 auto;
  margin: 0;
  padding: 10px 24px;
  border-radius: 0;
  box-shadow: none;
}
body:has(.exam-page:not(.hidden)) .brand { gap: 12px; }
body:has(.exam-page:not(.hidden)) .brand img { width: 44px; padding: 3px; border-radius: 6px; }
body:has(.exam-page:not(.hidden)) .header h1 { margin: 0; font-size: 18px; }
body:has(.exam-page:not(.hidden)) .header p { display: none; }
body:has(.exam-page:not(.hidden)) .progress { margin-top: 8px; gap: 6px; }
body:has(.exam-page:not(.hidden)) .step { padding: 3px 9px; font-size: 12px; }

.exam-page:not(.hidden) {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  min-height: 0;
  margin: 0;
  padding: 12px 24px 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
}
.exam-page > h2 { flex: 0 0 auto; margin: 0 0 4px; font-size: 21px; }
.exam-page > .lead { flex: 0 0 auto; margin: 0; font-size: 13px; }
.exam-page > .exam-bar {
  flex: 0 0 auto;
  margin: 8px 0;
  padding: 6px 12px;
  border-radius: 5px;
  font-size: 13px;
}
.exam-page .timer-pill { padding: 4px 12px; font-variant-numeric: tabular-nums; }
.exam-page > .actions {
  flex: 0 0 auto;
  margin: 0;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.exam-page .pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.exam-page .pane-body:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.exam-page .answer-input { max-width: 100%; }
.exam-page .q {
  padding: 0 0 20px;
  margin: 0 0 20px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}
.exam-page .q:last-child { margin-bottom: 0; border-bottom: 0; }
.exam-page .option { padding-left: 0; }

/* Listening uses the engine's single-pane structure: audio above questions. */
.listening-page .audio-box {
  flex: 0 0 auto;
  margin: 0 0 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #f8fafc;
  font-size: 13px;
}
.listening-page audio { margin-top: 0; }
.listening-page .single-layout { display: flex; flex: 1 1 0; min-height: 0; }
.listening-page .single-pane { flex: 1 1 0; }
body.reading-exam-layout .listening-page .pane-body {
  padding: 18px max(20px, calc((100% - 960px) / 2)) 36px;
}
.listening-page .twocol { grid-template-columns: minmax(0, 1fr); gap: 16px; }
.listening-page .answer-input { width: 220px; margin: 4px 0; }

/* Reuse reading-exam-layout.css/js, including its accessible drag handle. */
body.reading-exam-layout #app.reading-workspace {
  flex: 1 1 0;
  height: auto;
  min-width: 0;
}
#page-reading #reading-passage {
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow-wrap: break-word;
}
#page-reading .q-title, #page-reading .option { overflow-wrap: anywhere; }
#page-reading .answer-input { width: 190px; }

@media (max-width: 740px) {
  body:has(.exam-page:not(.hidden)) .header { padding: 8px 10px; }
  body:has(.exam-page:not(.hidden)) .brand img { width: 32px; }
  body:has(.exam-page:not(.hidden)) .header h1 { font-size: 16px; }
  body:has(.exam-page:not(.hidden)) .progress { flex-wrap: nowrap; overflow-x: auto; }
  body:has(.exam-page:not(.hidden)) .step { flex: 0 0 auto; padding: 2px 6px; }
  .exam-page:not(.hidden) { padding: 8px 10px 0; }
  .exam-page > h2 { font-size: 17px; }
  body.reading-exam-layout { --reading-font-size: 16px; }
  body.reading-exam-layout .listening-page .pane-body { padding: 12px 10px 28px; }
  .exam-page > .actions { padding: 8px 0; }
  .exam-page > .actions button { padding: 9px 12px; }
}

@media (max-height: 560px) {
  /* Short landscape windows scroll the page while retaining two reading panes. */
  body:has(.exam-page:not(.hidden)) { overflow: auto; }
  body:has(.exam-page:not(.hidden)) > .app { height: auto; min-height: 100dvh; }
  .exam-page:not(.hidden) { flex: none; }
  body.reading-exam-layout #app.reading-workspace,
  .listening-page .single-layout { flex: none; height: 65vh; min-height: 240px; }
}
