/* ExtraPyrTract 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: 30px auto;
  padding: 18px;
  background: #fff;
  color: #222;
}

/* keep vertical scrollbar present to avoid layout shift when content height changes */
html { overflow-y: scroll; }

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;
  /* ensure scrolling behavior if JS sets fixed height */
  overflow-y: auto;
}

#layout { display:flex; justify-content:center; }
.layout { display: flex; gap: 18px; align-items: flex-start; width: 200mm; max-width: 100%; margin: 0 auto; }

/* compressed left-side question navigator: show a short horizontal line per question
   on hover/focus the line expands vertically and reveals the question number.
   Implementation uses CSS transforms (scaleY) so expansion is visual and doesn't
   affect layout flow. The number is provided via a data attribute set by JS. */
#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:10px; align-items: center; overflow: visible; }
/* each li reserves a small visual area but expansion uses transform so layout stable */
#question-list li { width: 100%; display:flex; justify-content: 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;
  transform-origin: center;
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
  box-shadow: none;
  outline: none;
  overflow: visible; /* allow the number pill to render outside the button */
  z-index: 1; /* keep button under the ::after number pill */
  display: inline-flex; /* center injected text */
  align-items: center;
  justify-content: center;
  font-size: 0; /* hide button text by default; JS will populate on hover/active */
  color: transparent;
}

/* show the question number in a small pill to the right when hovered/focused */
#question-list button::after {
  content: attr(data-number);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%) translateX(-8px);
  opacity: 0;
  pointer-events: none;
  /* larger filled white square with bold black number for readability */
  background: #ffffff;
  color: #000000;
  font-size: 16px;
  font-weight: 600;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 8px;
  white-space: nowrap;
  transition: opacity 140ms ease, transform 140ms ease, background 120ms ease, border-color 120ms ease;
  z-index: 9999; /* ensure it sits above other elements */
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  border: 1px solid #c8cfd6; /* subtle outline */
}

/* expand visually on hover/focus and show number */
#question-list button:hover, #question-list button:focus, #question-list button:focus-visible {
  transform: scaleY(4);
  background: #007acc;
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
  /* reveal the injected number inside the blue expanded button */
  font-size: 10px;
  color: #ffffff;
  font-weight: 700;
}

#question-list button:hover::after, #question-list button:focus::after, #question-list button:focus-visible::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
  background: transparent; /* keep transparent fill */
  color: #ffffff; /* black number text */
  border-color: #007acc;
}

/* active/focused state remains expanded and shows the number */
#question-list button.active {
  transform: scaleY(4);
  background: #005a9e;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
}
#question-list button.active::after { opacity: 1; transform: translateY(-50%) translateX(0); }

#question-list button.answered { box-shadow: inset 0 -3px 0 rgba(0,0,0,0.06); }

#choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* offset the choices from the stem by 20mm */
  margin-top: 20mm;
  margin-bottom: 12px;
}

/* Hard mm-based width for question stem and answer choices so layout is constant */
#question-text, #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; }

/* 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; overflow: auto; padding-bottom: 120px; }

/* keep controls at the bottom of the document flow, centered */
#controls {
  margin: 20px auto 0;
  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;
}

/* 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; }
  #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; }
}
