/* Applied only to active exam workspaces. Ordinary site pages and print keep their own layout. */
@media screen {
  [data-exam-workspace] {
    --exam-pane-height: max(14rem, calc(100vh - var(--exam-controls, 0px) - 2.5rem));
    --exam-pane-height: max(14rem, calc(100dvh - var(--exam-controls, 0px) - 2.5rem));
    min-width: 0;
  }
  [data-exam-workspace] [data-exam-pane] {
    box-sizing: border-box;
    position: static;
    align-self: stretch;
    min-width: 0;
    min-height: 0;
    max-height: none;
    max-width: 100%;
    margin-top: 0;
    overflow-wrap: anywhere;
  }
  [data-exam-workspace] [data-exam-pane]:focus-visible,
  [data-exam-switch] button:focus-visible {
    outline: 2px solid #225ca8;
    outline-offset: -3px;
  }
  [data-exam-switch] { display: none; }
  .b2-page [data-b2-app] .b2-grid[data-exam-single] {
    grid-template-columns: minmax(0,1fr);
  }
  [data-exam-workspace] .ir-mobile-nav { display: none; }
  .page-practice [data-exam-workspace] .practice-question { width: auto; }
  .page-practice [data-exam-workspace] .practice-submit-confirm { margin-top: .8rem; }
  .page-iw [data-exam-workspace] .iw-editor,
  .page-bw [data-exam-workspace] .iw-editor { min-height: clamp(12rem, 35dvh, 22rem); }

  @media (min-width: 761px) and (min-height: 480px) {
    /* The focus stylesheet's legacy rules have higher specificity than the general player. */
    body:is(.b2-page,.page-ielts,.page-iw,.page-bw) [data-exam-workspace],
    html.pt-focus-exercise body.page-practice [data-exam-workspace] {
      display: grid;
      grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr);
      gap: clamp(.7rem, 1.4vw, 1.15rem);
      align-items: start;
    }
    body:is(.b2-page,.page-ielts,.page-iw,.page-bw) [data-exam-workspace] > [data-exam-pane],
    html.pt-focus-exercise body.page-practice [data-exam-workspace] > [data-exam-pane] {
      position: static;
      width: auto;
      height: var(--exam-pane-height);
      max-height: var(--exam-pane-height);
      overflow: auto;
      overscroll-behavior-y: contain;
      scrollbar-gutter: stable;
    }
  }

  @media (max-width: 760px), (max-height: 479px) {
    [data-exam-switch] {
      position: sticky;
      top: var(--exam-sticky-top, 0px);
      z-index: 10;
      scroll-margin-top: var(--exam-sticky-top, 0px);
      display: grid;
      grid-template-columns: repeat(2,minmax(0,1fr));
      gap: .3rem;
      padding: .3rem;
      margin: .5rem 0;
      border: 1px solid #d8e0e9;
      border-radius: .6rem;
      background: #faf8f4;
    }
    [data-exam-switch] button {
      border: 1px solid #bccadb;
      border-radius: .4rem;
      background: white;
      color: #112039;
      cursor: pointer;
      font: inherit;
      font-weight: 700;
      min-height: 44px;
      min-width: 0;
      padding: .35rem .2rem;
      overflow-wrap: anywhere;
    }
    [data-exam-switch] button[aria-pressed="true"] {
      background: #112039;
      color: white;
      border-color: #112039;
    }
    body:is(.b2-page,.page-ielts,.page-iw,.page-bw) [data-exam-workspace],
    html.pt-focus-exercise body.page-practice [data-exam-workspace] {
      display: block;
    }
    body:is(.b2-page,.page-ielts,.page-iw,.page-bw) [data-exam-workspace] > [data-exam-pane],
    html.pt-focus-exercise body.page-practice [data-exam-workspace] > [data-exam-pane] {
      height: auto;
      max-height: none;
      overflow: visible;
    }
    [data-exam-workspace] { position: relative; }
    /* Keep the inactive panel rendered but inert. Writing uses innerText, including
       line breaks, when time expires while the learner is reading the prompt. */
    body [data-exam-workspace][data-exam-view="response"] > [data-exam-pane="source"][inert],
    body [data-exam-workspace][data-exam-view="source"] > [data-exam-pane="response"][inert],
    html.pt-focus-exercise body.page-practice [data-exam-workspace][data-exam-view="response"] > [data-exam-pane="source"][inert],
    html.pt-focus-exercise body.page-practice [data-exam-workspace][data-exam-view="source"] > [data-exam-pane="response"][inert] {
      position: absolute;
      inset: 0 0 auto;
      height: 1px;
      overflow: hidden;
      clip-path: inset(50%);
      pointer-events: none;
    }
  }
  @media (max-height: 479px) {
    /* Leave room for content when a phone keyboard is open or a viewport is very short. */
    body.b2-page [data-b2-app] .b2-run-head,
    body:is(.page-iw,.page-bw) .iw-status { position: static; }
  }
}
@media print {
  [data-exam-switch] { display: none !important; }
  [data-exam-workspace] [data-exam-pane] { overflow: visible; height: auto; max-height: none; }
}
