/* GT exam screen — layout only.
   The GT visual design is frozen: this file declares NO colour, font or shadow
   on the exam screen. It only fixes sizing, scrolling and phone reflow. */

/* ---- root: full-height flex column that never overflows ---- */
#exam{
  height:100dvh;
  max-height:100dvh;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}
#exam > .topbar,
#exam > .titlebar{flex:0 0 auto}

/* the middle region owns all remaining height */
#exam > .mid{flex:1 1 auto;min-height:0;overflow:hidden}

/* question pane is the single scroller on wider screens */
.mid > .qwrap{min-height:0;min-width:0}
.mid > .qwrap .qbody{min-height:0;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}

/* palette rail: its own scroller, never grows the page */
.mid > .palette{
  flex:0 0 auto;
  min-height:0;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}
.mid > .palette > *{min-height:0}
.mid > .palette [id="palGrid"],
.mid > .palette .palgrid{
  overflow-y:auto;
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
}

/* ================= phones / small tablets ================= */
@media (max-width:900px){
  /* the palette leaves the flex row and becomes a bottom sheet */
  .mid > .palette{
    position:fixed;
    left:0; right:0; bottom:0;
    top:auto;
    z-index:60;
    max-height:min(64dvh,560px);
    transform:translateY(100%);
    transition:transform .24s cubic-bezier(.23,1,.32,1);
    will-change:transform;
  }
  .mid > .palette.open{transform:translateY(0)}

  /* question pane goes full width */
  .mid > .qwrap{border-right:0}

  /* scrim behaves as an overlay, not a layout node */
  #palScrim{
    position:fixed;
    inset:0;
    z-index:55;
  }
  #palScrim[hidden],
  #palScrim.hide{display:none}

  /* on a phone the page scrolls as a document rather than trapping
     scroll inside a sub-pane */
  #exam{height:auto;max-height:none;min-height:100dvh}
  #exam > .mid{overflow:visible}
  .mid > .qwrap .qbody{overflow-y:visible}
}

/* ================= desktop ================= */
@media (min-width:901px){
  .mid > .palette{transform:none}
  #palScrim{display:none}
}

/* landscape phones: keep the question visible, shrink chrome */
@media (max-height:430px){
  #exam > .topbar,
  #exam > .titlebar{padding-top:4px;padding-bottom:4px}
}

/* very short landscape: let the sheet be shorter */
@media (max-width:900px) and (max-height:430px){
  .mid > .palette{max-height:80dvh}
}
