/* QPal answering-session split surface.
   Presentation only: Study Practice, Exam, and Mock Board question sessions
   use the dashboard orange as the control zone, while the adaptive QPal page
   surface is the question/answer zone. */

:root {
  --qpal-assessment-lower-radius: 28px;
  --qpal-assessment-card-overlap: 18px;
}

/* Keep answering sessions anchored to the viewport without the older mobile
   full-height centering canvas. The assessment composition itself receives a
   measured top offset so the lower question area -- and the orange controls
   immediately above it -- move together around the viewport center. */
body.qpal-answering-session-active {
  height: auto !important;
  min-height: 100svh !important;
  justify-content: flex-start !important;
  align-items: center !important;
  padding-top: max(6px, env(safe-area-inset-top, 0px)) !important;
  padding-bottom: 0 !important;
  overflow-y: auto !important;
  overscroll-behavior-y: none;
}

body.qpal-answering-session-active .app-workspace,
body.qpal-answering-session-active.qpal-persistent-dashboard-shell .app-workspace {
  flex: 0 0 auto !important;
  min-height: 0 !important;
  justify-content: flex-start !important;
  margin-block: 0 !important;
  padding-bottom: 0 !important;
}

body.qpal-answering-session-active .game-container.qpal-answering-session {
  margin-top: var(--qpal-assessment-composition-offset, 0px) !important;
  margin-bottom: 0 !important;
}

/* The orange area itself is deliberately square. Only the LOWER neutral area
   owns the smooth/rounded transition edge. */
.qpal-assessment-upper-surface {
  position: absolute;
  z-index: -1;
  top: var(--qpal-assessment-upper-top, 0px);
  left: 50%;
  width: 100vw;
  height: var(--qpal-assessment-upper-height, 0px);
  max-width: none;
  box-sizing: border-box;
  transform: translateX(-50%);
  pointer-events: none;
  border-radius: 0 !important;
  background: var(--qpal-dashboard-upper-surface);
  box-shadow: none;
}

.qpal-assessment-upper-surface[hidden],
body:not(.qpal-answering-session-active) .qpal-assessment-upper-surface {
  display: none !important;
}

body.qpal-session-active .game-container.qpal-answering-session {
  overflow: visible;
  width: 100%;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  color: var(--text-primary) !important;
  filter: none !important;
}

/* Orange control zone.
   Row 1: Back arrow | TTS
   Row 2: Mode + subject pill | optional Mock Board section | Question number.
   Extra bottom breathing room keeps every pill fully inside the orange zone
   before the rounded LOWER surface overlaps it. */
.qpal-assessment-top-region {
  position: relative;
  z-index: 2;
  display: grid;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
  padding: 12px 22px calc(14px + var(--qpal-assessment-card-overlap));
  color: var(--text-primary);
}

.qpal-assessment-primary-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

/* Assessment back button adopts the compact QPal Pro arrow-control language. */
.qpal-assessment-primary-row .qpal-assessment-back-button {
  display: grid;
  place-items: center;
  justify-self: start;
  width: 42px;
  height: 40px;
  min-width: 42px;
  padding: 0 !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: 12px !important;
  background: var(--surface-muted) !important;
  color: var(--text-primary) !important;
  box-shadow: var(--inner-highlight) !important;
  font-family: var(--app-font) !important;
  font-size: 19px !important;
  font-weight: 800 !important;
  line-height: 1 !important;
}

.qpal-assessment-primary-row .qpal-assessment-back-button:hover,
.qpal-assessment-primary-row .qpal-assessment-back-button:focus-visible {
  outline: none;
  border-color: var(--accent-border) !important;
  color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--focus-ring), var(--inner-highlight) !important;
}

.qpal-assessment-secondary-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

/* Mode + subject stays fully inside the orange area and truncates before the
   item pill instead of extending into the rounded lower surface. */
.qpal-assessment-secondary-row .mode-badge {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  min-width: 0;
  max-width: none;
  min-height: 38px;
  box-sizing: border-box;
  padding: 8px 13px;
  border: 1px solid color-mix(in srgb, var(--text-primary) 18%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 82%, transparent) !important;
  color: var(--text-primary) !important;
  box-shadow: var(--inner-highlight);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qpal-assessment-secondary-row .score-box {
  flex: 0 0 auto;
  margin: 0 0 0 auto !important;
  border-radius: 999px !important;
  white-space: nowrap;
}

.qpal-assessment-secondary-row .mock-board-section-badge {
  flex: 0 1 auto;
  max-width: 32%;
  margin: 0;
}

/* TTS now occupies the former item-pill position and uses the same fully
   rounded pill silhouette as QPal's other assessment controls. */
.qpal-assessment-primary-row .qpal-tts-assessment-button {
  display: inline-grid;
  place-items: center;
  justify-self: end;
  width: 58px;
  min-width: 58px;
  min-height: 40px;
  padding: 0 15px !important;
  border: 1px solid color-mix(in srgb, var(--text-primary) 18%, transparent) !important;
  border-radius: 999px !important;
  background: var(--surface) !important;
  color: var(--text-primary) !important;
  box-shadow: var(--shadow-control), var(--inner-highlight) !important;
}

.qpal-assessment-primary-row .qpal-tts-assessment-button svg {
  width: 20px;
  height: 20px;
}

.qpal-assessment-primary-row .qpal-tts-assessment-button:hover,
.qpal-assessment-primary-row .qpal-tts-assessment-button:focus-visible,
.qpal-assessment-primary-row .qpal-tts-assessment-button.is-active {
  background: var(--text-primary) !important;
  color: var(--surface) !important;
  border-color: var(--text-primary) !important;
}

/* Lower question AREA. Its natural question/options block is positioned as a
   whole near the viewport center. The rounded neutral surface therefore moves
   with the question instead of beginning far above centered content. */
.qpal-assessment-lower-card {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  width: 100%;
  min-height: 0;
  box-sizing: border-box;
  margin-top: 0;
  padding: 34px 22px 28px;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  background-image: none !important;
  color: var(--text-primary) !important;
  box-shadow: none !important;
}

/* The lower neutral color owns the smooth top corners. It overlaps the square
   orange layer so the curve is visibly formed by the LOWER surface, not by a
   rounded orange bottom edge. */
.qpal-assessment-lower-card::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: calc(-1 * var(--qpal-assessment-card-overlap));
  left: 50%;
  width: 100vw;
  height: calc(var(--qpal-assessment-card-overlap) + 52px);
  transform: translateX(-50%);
  border-radius:
    var(--qpal-assessment-lower-radius)
    var(--qpal-assessment-lower-radius)
    0 0;
  background: var(--page-bg);
  pointer-events: none;
}

/* The existing counting timer now belongs to the lower neutral area, aligned
   to the upper-right immediately above the draining line. */
.qpal-assessment-timer-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
  min-height: 40px;
  margin: 0 0 8px;
}

.qpal-assessment-timer-row .timer-box {
  margin: 0 !important;
  border-radius: 999px !important;
  white-space: nowrap;
}

/* Classic timer-aligned draining line. No numeric label is rendered here. */
.qpal-assessment-timer-progress {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  height: 7px;
  margin: 0 0 22px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-primary) 14%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text-primary) 7%, transparent);
}

.qpal-assessment-timer-progress[hidden] {
  display: none !important;
}

.qpal-assessment-timer-progress-fill {
  display: block;
  width: var(--qpal-assessment-timer-progress, 100%);
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 1000ms linear;
  will-change: width;
}

.qpal-assessment-lower-card > .question-title {
  margin-top: 0;
  padding: 0;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.qpal-assessment-lower-card .choices-list {
  position: relative;
  z-index: 1;
}

/* Remove the old divider below option D while preserving the answer actions. */
.qpal-assessment-lower-card .action-bar {
  margin-bottom: 0;
  border-top: 0 !important;
}

/* Small centered confirmation before the existing assessment quit handler is
   allowed to save the unfinished session and return to the dashboard. */
.qpal-assessment-back-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 31120;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  padding: 18px;
  background: rgba(10, 10, 10, 0.54);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.qpal-assessment-back-confirm-dialog {
  width: min(100%, 360px);
  box-sizing: border-box;
  padding: 20px;
  border: 1px solid var(--border-subtle);
  border-radius: 22px;
  background: var(--surface-elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-card), var(--inner-highlight);
  text-align: center;
}

.qpal-assessment-back-confirm-dialog h2 {
  margin: 0;
  color: var(--text-primary) !important;
  font-size: 18px;
  font-weight: 900;
}

.qpal-assessment-back-confirm-dialog p {
  margin: 9px 0 0;
  color: var(--text-secondary) !important;
  font-size: 12px;
  line-height: 1.5;
}

.qpal-assessment-back-confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 17px;
}

.qpal-assessment-back-confirm-actions button {
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 13px;
  background: var(--surface-muted);
  color: var(--text-primary);
  font-family: var(--app-font) !important;
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
}

.qpal-assessment-back-confirm-actions .is-continue {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border-subtle));
  background: var(--accent);
  color: #fff;
}

.qpal-assessment-back-confirm-actions button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* Session-entry curtain: the same QPal orange band language as the launch
   curtain, reversed so it enters from the top and clears downward. It has no
   mascot/logo and performs no data or network work. */
.qpal-assessment-entry-curtain {
  position: fixed;
  inset: 0;
  z-index: 31010;
  overflow: hidden;
  background: #fff2e9;
  pointer-events: auto;
  touch-action: none;
  overscroll-behavior: none;
  transform: translate3d(0, 0, 0);
  transition: transform 460ms cubic-bezier(0.72, 0, 0.2, 1);
  will-change: transform;
}

.qpal-assessment-entry-band,
.qpal-assessment-entry-fill {
  position: absolute;
  display: block;
  pointer-events: none;
  will-change: transform;
}

.qpal-assessment-entry-band {
  left: -15%;
  top: -4%;
  width: 130%;
  border-radius: 0 0 48% 52% / 0 0 18% 21%;
  transform: translate3d(0, -118%, 0);
  animation: qpal-assessment-band-drop 590ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.qpal-assessment-entry-band.is-band-1 {
  height: 79%;
  background: #f8d3bd;
  animation-delay: 40ms;
}

.qpal-assessment-entry-band.is-band-2 {
  height: 69%;
  background: #efa577;
  animation-delay: 125ms;
}

.qpal-assessment-entry-band.is-band-3 {
  height: 59%;
  background: #df783f;
  animation-delay: 210ms;
}

.qpal-assessment-entry-band.is-band-4 {
  height: 50%;
  background: #c94e00;
  animation-delay: 295ms;
}

.qpal-assessment-entry-fill {
  inset: -12% -10%;
  border-radius: 0 0 50% 50% / 0 0 12% 12%;
  background: #c94e00;
  transform: translate3d(0, -118%, 0);
  animation: qpal-assessment-fill-drop 520ms 455ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.qpal-assessment-entry-curtain.is-exiting {
  pointer-events: none;
  transform: translate3d(0, 103%, 0);
}

@keyframes qpal-assessment-band-drop {
  from {
    transform: translate3d(0, -118%, 0);
  }
  to {
    transform: translate3d(0, 0, 0);
  }
}

@keyframes qpal-assessment-fill-drop {
  from {
    transform: translate3d(0, -118%, 0);
  }
  to {
    transform: translate3d(0, 0, 0);
  }
}

@media (max-width: 700px) {
  :root {
    --qpal-assessment-lower-radius: 24px;
    --qpal-assessment-card-overlap: 16px;
  }

  body.qpal-answering-session-active {
    padding-top: max(4px, env(safe-area-inset-top, 0px)) !important;
  }

  .qpal-assessment-top-region {
    gap: 8px;
    padding: 10px 16px calc(12px + var(--qpal-assessment-card-overlap));
  }

  .qpal-assessment-primary-row {
    gap: 8px;
  }

  .qpal-assessment-secondary-row {
    gap: 7px;
    flex-wrap: nowrap;
  }

  .qpal-assessment-secondary-row .mode-badge {
    min-height: 36px;
    padding: 7px 11px;
  }

  .qpal-assessment-primary-row .qpal-tts-assessment-button {
    width: 54px;
    min-width: 54px;
    min-height: 38px;
    padding-inline: 13px !important;
  }

  .qpal-assessment-secondary-row .mock-board-section-badge {
    max-width: 36%;
  }

  .qpal-assessment-lower-card {
    padding: 30px 16px 24px;
  }

  .qpal-assessment-timer-progress {
    height: 6px;
    margin-bottom: 18px;
  }
}

@media (max-width: 390px) {
  .qpal-assessment-top-region {
    padding-inline: 12px;
  }

  .qpal-assessment-primary-row {
    gap: 6px;
  }

  .qpal-assessment-secondary-row {
    flex-wrap: wrap;
  }

  .qpal-assessment-secondary-row .mode-badge {
    flex-basis: calc(100% - 76px);
  }

  .qpal-assessment-secondary-row .mock-board-section-badge {
    order: 3;
    max-width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .qpal-assessment-timer-progress-fill {
    transition: none;
  }

  .qpal-assessment-entry-curtain {
    transition: opacity 1ms linear;
  }

  .qpal-assessment-entry-band {
    display: none;
    animation: none;
  }

  .qpal-assessment-entry-fill {
    transform: translate3d(0, 0, 0);
    animation: none;
  }

  .qpal-assessment-entry-curtain.is-exiting {
    opacity: 0;
    transform: none;
  }
}
