/* ============================================================================
   Barmaso Exam — the question paper
   ============================================================================ */

.paper { display: grid; gap: 14px; }

/* Sticks under the site header so the clock and the save state stay visible
   however far down the paper a taker has scrolled. */
.paper-bar {
  position: sticky;
  top: var(--header-h);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.paper-bar-left,
.paper-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.paper-title {
  font-weight: 700;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.paper-progress {
  flex: none;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-alt);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
}

.save-state {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.save-state.is-busy  { color: var(--ink-faint); }
.save-state.is-ok    { color: var(--success-ink); }
.save-state.is-error { color: var(--danger); }

.paper-clock-wrap {
  display: grid;
  justify-items: end;
  gap: 1px;
}

.paper-clock-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.paper-clock {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--ink);
}

.paper-clock.is-urgent {
  color: var(--danger);
  animation: clock-pulse 1s ease-in-out infinite;
}

@keyframes clock-pulse {
  50% { opacity: 0.45; }
}

/* --- Questions -------------------------------------------------------------- */
.paper-list { display: grid; gap: 12px; }

/* --- one question at a time ---------------------------------------------
   A long paper as one column means scrolling past questions, and a question
   scrolled past is a question left blank. One card fills the view; the strip
   of numbers above it is both the map and the way back to any of them. */

/* Wraps rather than scrolls sideways.
   A ten-question paper is wider than a phone, so a scrolling strip put the
   early questions off-screen exactly when someone on question eight wanted
   to go back and fix question one — a tap became a scroll-then-tap. Wrapped,
   every question is visible and one tap away, always. A very long paper
   scrolls the strip vertically instead of pushing the question off the
   screen. */
.paper-numbers {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 2px 6px;
  max-height: 150px;
  overflow-y: auto;
  scrollbar-width: none;
  /* Sticks under the bar so any question stays reachable however far down a
     long question the taker has scrolled. */
  position: sticky;
  top: calc(var(--header-h) + 58px);
  z-index: 19;
  background: var(--bg);
}

.paper-numbers::-webkit-scrollbar { display: none; }

.paper-number {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}

.paper-number.is-answered {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-deep);
}

/* The current question wins over the answered styling: where you are matters
   more than whether it is done. */
.paper-number.is-current {
  background: var(--action);
  border-color: var(--action);
  color: var(--action-ink);
}

.paper-stage {
  /* Holds its height between questions so the page does not jump when a
     short question follows a long one. */
  min-height: 340px;
}

.paper-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.paper-nav-btn { flex: 1; }
.paper-nav-btn:disabled { opacity: .4; cursor: default; }

.paper-position {
  flex: 0 0 auto;
  min-width: 62px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

.paper:focus { outline: none; }

.q-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.q-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.q-no {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-alt);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}

.q-text {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.q-options { display: grid; gap: 8px; }

.q-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}
.q-option:hover { border-color: var(--ink-faint); }

.q-option.is-picked {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* The radio itself is hidden; the whole row is the control, which is far
   easier to hit on a phone than a 16px dot. */
.q-radio {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* Keyboard focus has to land somewhere visible once the input is hidden. */
.q-radio:focus-visible + .q-letter {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.q-letter {
  display: grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
}

.q-option.is-picked .q-letter {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.q-option-text {
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

/* --- Submit ----------------------------------------------------------------- */
.paper-foot {
  display: flex;
  justify-content: center;
  padding: 8px 0 32px;
}

.paper-submit-btn {
  min-width: 220px;
  padding: 14px 28px;
  font-size: 15px;
}

@media (max-width: 640px) {
  .paper-bar { padding: 10px 12px; gap: 8px; }
  .paper-bar-left, .paper-bar-right { width: 100%; justify-content: space-between; }
  /* Thumb-sized targets, and a stage that is not taller than the phone. */
  .paper-number { width: 38px; height: 38px; font-size: 14px; }
  .paper-numbers { max-height: 138px; }
  .paper-stage { min-height: 0; }
  .paper-nav { position: sticky; bottom: 0; padding: 10px 0; background: var(--bg); }
  .paper-nav-btn { padding-top: 12px; padding-bottom: 12px; }
  .paper-title { font-size: 13px; }
  .q-card { padding: 14px; }
  .paper-submit-btn { width: 100%; }
}
