/* PracQ-APP styles (simplified for formative feedback) */
body {
  font-family: Arial, Helvetica, sans-serif;
  /* increase overall layout width by one-third */
  max-width: 1333px; /* 1000px * 1.333 */
  margin: clamp(8px, 2vh, 30px) auto;
  padding: 18px;
  background: #fff;
  color: #222;
}

/* allow host page/app to decide scrolling naturally (do not force a scrollbar) */
html { overflow-y: auto; }

header h1 {
  font-size: 22px;
  margin: 0 0 6px 0;
  text-align: center;
}
.sub {
  text-align: center;
  color: #555;
  margin-top: 4px;
  margin-bottom: 18px;
}

#question-text {
  font-size: 18px;
  margin-bottom: 0; /* we'll offset choices separately */
  text-align: left;
  overflow-y: visible;
}

#question-media {
  width: 200mm;
  max-width: 100%;
  box-sizing: border-box;
  margin-top: 10px;
}

#stem-area {
  width: 200mm;
  max-width: 100%;
  box-sizing: border-box;
  height: clamp(170px, calc(var(--app-available-height, 100vh) * 0.34), 300px);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}

#stem-content {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.question-media-item {
  margin: 0 0 10px 0;
}

.question-stem-image {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 320px;
  object-fit: contain;
  border: 1px solid #d9d9d9;
  border-radius: 8px;
  background: #fafafa;
}

.question-media-caption {
  margin-top: 6px;
  font-size: 14px;
  color: #444;
}

#layout { display:flex; justify-content:center; }
.layout {
  display: flex;
  gap: 18px;
  align-items: stretch;
  width: 200mm;
  max-width: 100%;
  margin: 0 auto;
  height: var(--app-available-height, calc(100vh - 96px));
  min-height: 360px;
}

/* compressed left-side question navigator: show a short horizontal line per question
  and expand it to a readable pill without scaling text (prevents distorted numbers). */
#sidebar { width: 34px; position: fixed; top: 50%; transform: translateY(-50%); z-index: 1100; }

#question-list { list-style: none; margin: 0; padding: 6px 4px; display:flex; flex-direction:column; gap:5px; align-items: center; overflow: visible; }
/* each li reserves enough height so expansion does not push siblings */
#question-list li { width: 100%; min-height: 20px; display:flex; justify-content: center; align-items: center; overflow: visible; }

/* default small horizontal line */
#question-list button {
  width: 28px;
  height: 6px;
  padding: 0;
  border-radius: 4px;
  border: none;
  background: #cfdffb;
  cursor: pointer;
  position: relative;
  transition: height 160ms ease, border-radius 160ms ease, background 160ms ease, box-shadow 160ms ease, color 160ms ease;
  box-shadow: none;
  outline: none;
  overflow: hidden;
  z-index: 1;
  display: inline-flex; /* center injected text */
  align-items: center;
  justify-content: center;
  font-size: 0; /* hide text when collapsed */
  line-height: 1;
  color: transparent;
  font-weight: 700;
}

/* disable tooltip-style duplicate number display */
#question-list button::after {
  content: none;
}

/* expand visually on hover/focus and show number */
#question-list button:hover, #question-list button:focus, #question-list button:focus-visible {
  height: 24px;
  border-radius: 8px;
  background: #007acc;
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
  font-size: 11px;
  color: #ffffff;
  font-weight: 700;
}

/* active/focused state remains expanded and shows the number */
#question-list button.active {
  height: 24px;
  border-radius: 8px;
  background: #005a9e;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
}

#question-list button.answered { box-shadow: inset 0 -3px 0 rgba(0,0,0,0.06); }

#choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  margin-bottom: 12px;
}

/* Compress choice rows when a question has many options to avoid layout overflow. */
#choices.compact-choices { gap: 6px; }
#choices.compact-choices .choice-button {
  padding: 7px 12px;
  font-size: 14px;
  line-height: 1.2;
}

#choices.dense-choices { gap: 4px; }
#choices.dense-choices .choice-button {
  padding: 5px 10px;
  font-size: 13px;
  line-height: 1.15;
}

/* Hard mm-based width for question stem and answer choices so layout is constant */
#question-text, #question-media, #choices {
  width: 200mm;
  max-width: 100%;
  box-sizing: border-box;
}

/* make question-area a column so controls can be fixed at the bottom */
#question-area {
  display: flex;
  flex-direction: column;
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
}

/* content area scrolls if it's taller than available space; reserve space at bottom for controls */
/* reserve bottom space for fixed controls so content/choices are not hidden behind them */
#content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: hidden;
  overflow-x: hidden;
  padding-bottom: 12px;
}

/* keep controls at the bottom of the document flow, centered */
#controls {
  margin: 0 auto;
  background: rgba(255,255,255,0.98);
  padding: 8px 12px;
  z-index: 1000;
  display: flex;
  gap: 10px;
  align-items: center;
  box-shadow: 0 6px 18px rgba(0,0,0,0.08);
  border-radius: 10px;
  width: fit-content;
  position: sticky;
  bottom: 0;
  transform: translateY(calc(-1 * var(--controls-lift, 1cm)));
}

/* feedback/explanation box: placed inside the scrollable content and offset from the stem
   with a fixed 30mm gap; it will expand downward as its content grows. */
/* Feedback PANEL that sits to the right of the layout (positioned via JS) */
#feedback-panel {
  position: fixed; /* positioned by JS for left/top */
  width: 205px;
  max-width: 35vw;
  z-index: 40;
}

#feedback {
  border: 1px solid #cfcfcf;
  background: #fff;
  padding: 12px;
  border-radius: 6px;
  min-height: 36px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.choice-button {
  text-align: left;
  padding: 12px 14px;
  border-radius: 6px;
  border: 1px solid #cfdffb;
  background: #eef6ff;
  cursor: pointer;
  font-size: 16px;
  transition: background 0.15s ease, transform 0.05s ease;
}

/* make choice buttons fill the available width so layout remains consistent */
.choice-button { width: 100%; box-sizing: border-box; }
/* allow text to wrap inside choice buttons so long options don't expand layout */
.choice-button { white-space: normal; word-break: break-word; }
/* ensure long words in question text wrap rather than forcing width */
#question-text, #choices, .explanation { overflow-wrap: anywhere; }

/* constrain sidebar buttons so they cannot expand the layout */
#question-list button { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.choice-button:hover:not(:disabled) { background: #d7eaff; }
.choice-button:active:not(:disabled) { transform: translateY(1px); }
.choice-button[disabled] { opacity: 0.85; cursor: default; }

.choice-button.correct { background: #dff7e0; border-color: #8cd08a; }
.choice-button.incorrect { background: #fde7e7; border-color: #f08a8a; }

#feedback { margin-top: 8px; min-height: 22px; }
.fb-correct { color: #1d7a2d; font-weight: 600; }
.fb-incorrect { color: #a92b2b; font-weight: 600; }

.explanation { margin-top: 6px; color: #333; }

/* Controls are fixed via the rule above; this placeholder keeps layout consistency for any overrides */
#controls.placeholder { margin-top: 14px; display: flex; gap: 10px; justify-content: center; }
.primary { background: #007acc; color: white; border: none; padding: 10px 18px; border-radius: 6px; cursor: pointer; }
.primary[disabled] { opacity: 0.6; cursor: default; }
.secondary { background: #f0f0f0; color: #222; border: none; padding: 10px 18px; border-radius: 6px; cursor: pointer; }

/* When sidebar present on small screens, stack */
@media (max-width: 700px) {
  /* on small screens let layout collapse into column and use full width */
  .layout { width: 100%; flex-direction: column; height: auto; }
  #sidebar { width: 100%; }
  #question-list { flex-direction: row; overflow-x:auto; gap:6px; }
  #question-list button { width: 44px; height: 36px; }
}

@media (max-width: 600px) {
  body { margin: 12px; padding: 12px; }
  .choice-button { font-size: 15px; padding: 10px; }
}
