/* The quick quiz on the STUDENT surface (StudentView). Prefix .qz-s-.
   docs/class-app/quizzes/DESIGN.md, "The surfaces".

   PHONE FIRST. The base rules are the phone; 768px and 1025px only add room.
   The panel sits in StudentView's column (`.cl-student`, 44rem at most), so a
   laptop sees the same stack of cards, centred, rather than a second layout.

   RIGHT AND WRONG ARE NEVER A COLOUR ALONE. Blue (`--primary-color`) and red
   (`--alert-color`) mark them, and every such mark also carries a shape (the
   icon) and a word ("נכונה", "לא נכון"), because a colour is not a sentence for
   somebody who cannot tell the two apart. No brand gradient on this sheet:
   nothing here is a thin rule, and a filled or bold shape must not wear it.

   Every tap target is at least 44px: the options and the order rows by their
   minimum height, the drag handle and the arrows by their size, the Save
   buttons by `min-block-size`. */

.qz-s {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* Read by a screen reader, drawn nowhere: the live line of the ordering
   question and the right/wrong word beside a place mark. */
.qz-s-sr {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
}

.qz-s-icon {
  flex: none;
  inline-size: 16px;
  block-size: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Six dots drawn as zero-length strokes: the round cap is the dot. */
.qz-s-icon--grip {
  inline-size: 20px;
  block-size: 20px;
  stroke-width: 3.4;
}

/* ── The break banner ──────────────────────────────
   The break card's clock and closing sentence on one slim line over the quiz
   (QuizStudentPanel.vue says why it is not the card). */
.qz-s-break {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-xs) var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-md);
  background: var(--primary-light);
}

.qz-s-break__title {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-color);
}

.qz-s-break__clock {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--primary-color);
}

.qz-s-break__back {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* ── The header card ─────────────────────────────── */
.cl-card.qz-s-head {
  gap: var(--space-sm);
  padding: var(--space-md);
}

.qz-s-head__kicker {
  margin: 0;
  font-size: 13px;
  color: var(--text-tertiary);
}

.qz-s-head__title {
  margin: 0;
  font-size: 21px;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: var(--text-color);
  overflow-wrap: anywhere;
}

.qz-s-head__desc {
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.qz-s-head__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-xs) var(--space-lg);
}

.qz-s-head__clock {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-sm);
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
}

/* Fixed-width digits, so the line does not twitch every second. */
.qz-s-head__clock-value {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text-color);
}

.qz-s-head__progress {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.qz-s-head__status {
  margin: 0;
  padding-block-start: var(--space-sm);
  border-block-start: 1px solid var(--border-light);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* Out of time: the warm tone, with the words "הזמן נגמר" carrying the meaning. */
.qz-s-head__status--over {
  color: var(--warning-color);
}

.qz-s-head__status--score {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-color);
}

/* The two standing lines under the header: no connection, and the questions
   still on their way. */
.qz-s-note {
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* ── The question cards ──────────────────────────── */
.qz-s-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin: 0;
  padding: 0;
  list-style: none;
}

.cl-card.qz-s-q {
  gap: var(--space-md);
  padding: var(--space-md);
}

.qz-s-q__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-xs) var(--space-md);
}

.qz-s-q__number {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--primary-color);
}

.qz-s-q__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs) var(--space-sm);
  margin: 0;
  font-size: 13px;
  color: var(--text-tertiary);
}

.qz-s-q__meta > span + span::before {
  content: '·';
  margin-inline-end: var(--space-sm);
}

.qz-s-q__prompt {
  font-size: 17px;
  line-height: 1.6;
  color: var(--text-color);
}

.qz-s-q__hint {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-tertiary);
}

/* The last save's state, or the verdict. Reserves its line so the card does
   not grow under the student's thumb the moment "שומרים" appears. */
.qz-s-q__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  min-block-size: 20px;
}

.qz-s-input {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  min-inline-size: 0;
}

/* ── Options (single and multiple choice) ────────── */
.qz-s-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  min-inline-size: 0;
}

.qz-s-option {
  appearance: none;
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  inline-size: 100%;
  min-block-size: 48px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-color);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  text-align: start;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
}

.qz-s-option:focus-visible,
.qz-s-option:has(.qz-s-option__box:focus-visible) {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Locked options stay fully legible: after the reveal they ARE the answer
   sheet. Only the pointer says they no longer take a tap. */
.qz-s-option:disabled,
.qz-s-option:has(.qz-s-option__box:disabled) {
  cursor: default;
}

.qz-s-option.is-chosen {
  border-color: var(--primary-color);
  background: var(--primary-light);
}

/* The radio-style mark of a single-choice option. A FILLED dot when chosen,
   not only a blue one: the shape changes with the state. */
.qz-s-option__mark {
  flex: none;
  inline-size: 20px;
  block-size: 20px;
  margin-block-start: 2px;
  border: 2px solid var(--border-default);
  border-radius: 50%;
  background: var(--bg-surface);
}

.qz-s-option.is-chosen .qz-s-option__mark {
  border-color: var(--primary-color);
  background: var(--primary-color);
  box-shadow: inset 0 0 0 3px var(--bg-surface);
}

.qz-s-option__box {
  flex: none;
  inline-size: 20px;
  block-size: 20px;
  margin: 2px 0 0;
  accent-color: var(--primary-color);
  cursor: inherit;
}

.qz-s-option__body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: var(--space-xs);
  min-inline-size: 0;
}

/* After the reveal: the correct option keeps the blue frame, a wrong choice
   turns red, and each carries its word (.qz-s-tag) as well. */
.qz-s-option.is-key {
  border-color: var(--primary-color);
}

.qz-s-option.is-wrong {
  border-color: var(--alert-border);
  background: var(--alert-light);
}

.qz-s-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
}

.qz-s-tag--right {
  color: var(--primary-color);
}

.qz-s-tag--wrong {
  color: var(--alert-color);
}

/* "בחרו 2" */
.qz-s-pick {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ── Save, and what became of it ─────────────────── */
.qz-s-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm) var(--space-md);
}

/* A Save alone on its row sits at the row's end, like the one beside a counter. */
.qz-s-actions > .qz-s-save:only-child {
  margin-inline-start: auto;
}

.qz-s-save {
  min-block-size: 44px;
}

.qz-s-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 13px;
  color: var(--text-tertiary);
}

.qz-s-state--saved {
  color: var(--text-secondary);
}

.qz-s-state--saved .qz-s-icon {
  color: var(--primary-color);
}

.qz-s-state--unsaved {
  color: var(--warning-color);
}

.qz-s-refusal {
  margin: 0;
}

/* ── Free text ───────────────────────────────────── */
/* Locked, the box still has to be READ: it is the student's own answer. */
.qz-s-text__input:disabled {
  opacity: 1;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  -webkit-text-fill-color: var(--text-secondary);
}

.qz-s-accepted {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.qz-s-accepted__title {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-tertiary);
}

.qz-s-accepted__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs) var(--space-sm);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* The rest of the key, counted rather than listed (QuizInputText.vue says
   why): plain text beside the chips, so it never reads as one more answer. */
.qz-s-accepted__more {
  align-self: center;
  font-size: 14px;
  color: var(--text-tertiary);
}

.qz-s-accepted__item {
  padding: 4px 10px;
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-color);
  overflow-wrap: anywhere;
}

/* ── Ordering ────────────────────────────────────── */
.qz-s-order {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin: 0;
  padding: 0;
  list-style: none;
}

.qz-s-order__row {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  min-block-size: 52px;
  padding: 3px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}

.qz-s-order__row.is-static {
  padding-inline: var(--space-sm);
}

/* The row in the finger: lifted over its neighbours and moved by the computed
   `transform` QuizInputOrder sets while it is held. */
.qz-s-order__row.is-dragging {
  z-index: 2;
  border-color: var(--primary-color);
  box-shadow: var(--shadow-lg);
}

/* THE ONLY ELEMENT THAT OWNS THE TOUCH. `touch-action: none` here and on
   nothing else is what lets a finger on the handle drag while a finger on the
   text still scrolls the page. No selection and no iOS long-press sheet. */
.qz-s-order__handle {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  inline-size: 44px;
  block-size: 44px;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.qz-s-order__row.is-dragging .qz-s-order__handle {
  color: var(--primary-color);
  cursor: grabbing;
}

.qz-s-order__handle.is-off {
  opacity: 0.35;
  cursor: default;
}

.qz-s-order__pos {
  flex: none;
  min-inline-size: 1.5em;
  font-family: var(--font-mono);
  font-size: 13px;
  text-align: center;
  color: var(--text-tertiary);
}

.qz-s-order__text {
  flex: 1 1 auto;
  min-inline-size: 0;
  padding-block: 8px;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-color);
}

.qz-s-order__moves {
  display: inline-flex;
  flex: none;
  gap: 4px;
}

.qz-s-order__move {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  inline-size: 44px;
  block-size: 44px;
  padding: 0;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
}

.qz-s-order__move:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 1px;
}

.qz-s-order__move:disabled {
  opacity: 0.35;
  cursor: default;
}

.qz-s-order__title {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-tertiary);
}

.qz-s-order__mark {
  display: inline-flex;
  flex: none;
  justify-content: center;
  inline-size: 24px;
}

.qz-s-order__mark--right {
  color: var(--primary-color);
}

.qz-s-order__mark--wrong {
  color: var(--alert-color);
}

/* ── After the reveal ────────────────────────────── */
.qz-s-verdict {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 15px;
  font-weight: 500;
}

.qz-s-verdict .qz-s-icon {
  inline-size: 18px;
  block-size: 18px;
}

.qz-s-verdict--right {
  color: var(--primary-color);
}

.qz-s-verdict--partial {
  color: var(--warning-color);
}

.qz-s-verdict--wrong {
  color: var(--alert-color);
}

.qz-s-verdict--unanswered {
  font-weight: 400;
  color: var(--text-tertiary);
}

.qz-s-verdict__points {
  font-weight: 400;
  color: var(--text-secondary);
}

.qz-s-explain {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border-inline-start: 2px solid var(--primary-border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.qz-s-explain__label {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-tertiary);
}

/* ── "סיום והגשה" (QuizStudentSubmit.vue) ───────── */
/* At the foot of the list. Full width on a phone, where it is the last thing
   the thumb reaches; centred at its own width from 768px. */
.qz-s-submit {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-sm);
  padding-block-start: var(--space-sm);
}

.qz-s-submit__button {
  min-block-size: 48px;
  font-size: 16px;
}

.qz-s-submit__note {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  color: var(--text-tertiary);
}

.qz-s-submit__error {
  margin: 0;
  text-align: center;
}

/* Submitted: where the button was. The check is blue and the title says it in
   words, so the colour is never the only sign. */
.cl-card.qz-s-submitted {
  gap: var(--space-xs);
  padding: var(--space-md);
  border-color: var(--primary-border);
}

/* Focused by script after a submit, never by a tab press: no ring. */
.cl-card.qz-s-submitted:focus {
  outline: none;
}

.qz-s-submitted__title {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  margin: 0;
  font-size: 17px;
  font-weight: 500;
  color: var(--text-color);
}

.qz-s-submitted__title .qz-s-icon {
  inline-size: 20px;
  block-size: 20px;
  color: var(--primary-color);
}

.qz-s-submitted__body {
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* The warning. A native modal <dialog> in the top layer, with the browser's
   backdrop. The sheet's global reset zeroes every margin, and the browser
   centres a modal dialog BY its auto margin, so it is put back here; without
   it the dialog sits in the top right corner. 16px from each edge on a phone. */
.qz-s-confirm {
  margin: auto;
  inline-size: min(26rem, calc(100% - 32px));
  max-inline-size: none;
  padding: var(--space-lg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  box-shadow: var(--shadow-lg);
  color: var(--text-color);
}

/* A browser without <dialog> (Safari before 15.4) has no rule hiding a closed
   one; the component falls back to the `open` attribute there. */
.qz-s-confirm:not([open]) {
  display: none;
}

.qz-s-confirm[open] {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.qz-s-confirm::backdrop {
  background: rgba(10, 20, 40, 0.45);
}

.qz-s-confirm__title {
  margin: 0;
  font-size: 19px;
  font-weight: 500;
  line-height: 1.4;
}

.qz-s-confirm__body {
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.qz-s-confirm__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.qz-s-confirm__actions > .cl-btn {
  flex: 1 1 9rem;
  min-block-size: 44px;
}

/* Hover only where a pointer hovers: on a phone a tapped option would keep its
   hover tint until the next tap somewhere else. */
@media (hover: hover) {
  .qz-s-option:not(:disabled):not(:has(:disabled)):not(.is-chosen):hover {
    border-color: var(--primary-border);
    background: var(--fsp-hover-bg);
  }

  .qz-s-order__move:not(:disabled):hover {
    border-color: var(--primary-border);
    background: var(--fsp-hover-bg);
  }
}

/* ── Tablet and up (past 767px): the room's ordinary card padding ── */
@media (min-width: 768px) {
  .cl-card.qz-s-head,
  .cl-card.qz-s-q {
    padding: var(--space-lg);
  }

  .qz-s-head__title {
    font-size: 24px;
  }

  .cl-card.qz-s-submitted {
    padding: var(--space-lg);
  }

  .qz-s-submit {
    align-items: center;
  }

  .qz-s-submit__button {
    min-inline-size: 16rem;
  }
}

/* ── Laptop (past 1024px): a little more room for a reader at a desk ── */
@media (min-width: 1025px) {
  .qz-s-q__prompt {
    font-size: 18px;
  }

  .qz-s-order__row {
    padding: 4px;
  }
}
