/* quiz: styles for this feature. Uses the tokens in /app.css. */

/* ── Quiz editor (inside dialog.studio) ─────────────────────────────── */
.quiz-editor .studio-title { margin-bottom: 24px; }
.qz-label { margin: 0; font: 700 12px/1.4 Lato, sans-serif; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.qz-label .muted { margin-left: 6px; font-weight: 400; letter-spacing: 0; text-transform: none; font-size: 13px; }
.qz-label.small { display: block; margin-bottom: 8px; }
.qz-intro { display: grid; gap: 10px; margin: 0 0 36px; padding: 16px 18px 6px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow-1); }
.qz-intro .rte.bare .rte-area { min-height: 72px; padding: 6px 0 14px; font-size: 16px; line-height: 1.65; }
.qz-intro .rte.bare .rte-tools { margin: 0 -8px 4px; }
.qz-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 14px; }
.qz-count { font-variant-numeric: tabular-nums; line-height: 1.4; }
.qz-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; }

.qz-card { display: grid; gap: 12px; padding: 18px 20px 16px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow-1); transition: box-shadow var(--dur-2) var(--ease-out); }
.qz-card:focus-within { box-shadow: var(--shadow-2); }
.qz-card.has-error { box-shadow: inset 0 0 0 1.5px var(--danger), var(--shadow-1); }
.qz-card-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.qz-card-head .spacer { flex: 1; }
.qz-num { display: grid; place-items: center; min-width: 30px; height: 30px; padding: 0 8px; border-radius: 99px; background: var(--tint); color: var(--blue); font: 700 14px/1 Lato, sans-serif; font-variant-numeric: tabular-nums; }
.qz-type { display: inline-flex; padding: 3px; border-radius: 99px; background: var(--sunken); box-shadow: inset 0 0 0 1px var(--line); }
.qz-type button { min-height: 30px; padding: 4px 12px; border: 0; border-radius: 99px; background: none; color: var(--muted); font: 600 13px/1.4 Lato, sans-serif; cursor: pointer; transition: background-color var(--dur-1), color var(--dur-1), box-shadow var(--dur-1); }
.qz-type button:hover { color: var(--deep); }
.qz-type button[aria-checked="true"] { background: var(--card); color: var(--deep); box-shadow: var(--shadow-1); }
.qz-type button:focus-visible { outline: 2px solid var(--sky); outline-offset: 1px; color: var(--deep); }
.qz-type button[aria-checked="true"]:focus-visible { box-shadow: var(--shadow-1), var(--focus); }
.qz-card-tools, .qz-choice-tools { display: inline-flex; gap: 2px; }

.qz-icon { width: 32px; height: 32px; display: grid; place-items: center; flex: none; border: 0; border-radius: var(--r-sm); background: none; color: var(--muted); cursor: pointer; transition: background-color var(--dur-1), color var(--dur-1); }
.qz-icon:hover:not(:disabled) { background: var(--sunken); color: var(--blue); }
.qz-icon.danger:hover:not(:disabled) { color: var(--danger); background: #fdecea; }
.qz-icon:focus-visible { outline: none; box-shadow: var(--focus); }
.qz-icon:disabled { opacity: .3; cursor: default; }

.qz-question { display: block; width: 100%; resize: none; overflow: hidden; margin: 0; padding: 4px 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none; color: var(--deep); font: 700 18px/1.45 Lato, sans-serif; transition: border-color var(--dur-1); }
.qz-question::placeholder { color: var(--ink-4); font-weight: 400; }
.qz-question:focus, .qz-question:focus-visible { outline: none; box-shadow: none; border-bottom-color: var(--sky); }
.qz-hint { margin: -4px 0 0; line-height: 1.45; }

.qz-choices { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.qz-choice { display: flex; align-items: flex-start; gap: 10px; padding: 4px 6px 4px 10px; border-radius: var(--r-md); background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); transition: background-color var(--dur-1), box-shadow var(--dur-1); }
.qz-choice:focus-within { box-shadow: inset 0 0 0 1px var(--sky), var(--focus); background: var(--card); }
.qz-choice.is-correct { background: #e7f5ec; box-shadow: inset 0 0 0 1px rgba(31, 138, 91, .35); }
.qz-choice.is-correct:focus-within { box-shadow: inset 0 0 0 1px var(--ok), 0 0 0 3px rgba(31, 138, 91, .2); }
.qz-choice-text { flex: 1; min-width: 0; min-height: 38px; margin: 0; padding: 8px 2px; border: 0; border-radius: 0; background: none; resize: none; overflow: hidden; color: var(--ink); font: 400 15px/1.45 Lato, sans-serif; }
.qz-choice-text:focus, .qz-choice-text:focus-visible { outline: none; box-shadow: none; }
.qz-choice-text::placeholder { color: var(--ink-4); }
.qz-choice-tools { margin-top: 5px; opacity: .45; transition: opacity var(--dur-1); }
.qz-choice:hover .qz-choice-tools, .qz-choice:focus-within .qz-choice-tools { opacity: 1; }
.qz-choice-tools .qz-icon { width: 28px; height: 28px; }

.qz-mark { position: relative; display: grid; place-items: center; width: 28px; height: 28px; margin-top: 5px; flex: none; cursor: pointer; }
.qz-mark input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.qz-mark-ui { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line-strong); background: var(--card); color: transparent; transition: background-color var(--dur-1), border-color var(--dur-1), color var(--dur-1), transform 100ms var(--ease-out); }
.qz-mark-ui.square { border-radius: 6px; }
.qz-mark:hover .qz-mark-ui { border-color: var(--ok); color: rgba(31, 138, 91, .45); }
.qz-mark input:checked + .qz-mark-ui { background: var(--ok); border-color: var(--ok); color: #fff; }
.qz-mark input:focus-visible + .qz-mark-ui { box-shadow: var(--focus); }
.qz-mark input:active + .qz-mark-ui { transform: scale(.92); }

.qz-card-foot { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.qz-link { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 4px 8px 4px 4px; border: 0; border-radius: var(--r-sm); background: none; color: var(--blue); font: 600 14px/1.4 Lato, sans-serif; cursor: pointer; transition: background-color var(--dur-1); }
.qz-link svg { width: 16px; height: 16px; }
.qz-link:hover:not(:disabled) { background: var(--tint); }
.qz-link:focus-visible { outline: none; box-shadow: var(--focus); }
.qz-link:disabled { color: var(--muted); cursor: default; }
.qz-explain { padding-top: 12px; border-top: 1px solid var(--line); }
.qz-explain-row { display: flex; gap: 8px; align-items: flex-start; }
.qz-explain textarea { resize: none; overflow: hidden; line-height: 1.5; font-size: 15px; }
.qz-error { margin: 0; color: var(--danger); font-size: 14px; line-height: 1.45; font-weight: 600; }
.qz-error:empty { display: none; }

.qz-add { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 56px; margin: 18px 0 0; border: 1.5px dashed var(--line-strong); border-radius: var(--radius); background: none; color: var(--blue); font: 700 15px/1.4 Lato, sans-serif; cursor: pointer; transition: background-color var(--dur-1), border-color var(--dur-1); }
.qz-add:hover:not(:disabled) { background: var(--card); border-color: var(--sky); }
.qz-add:focus-visible { outline: none; box-shadow: var(--focus); }
.qz-add:disabled { opacity: .5; cursor: default; }
.quiz-editor .studio-error { margin: 16px 0 0; }

.qz-pass { position: relative; display: block; max-width: 120px; }
.qz-pass .field { padding-right: 32px; font-variant-numeric: tabular-nums; }
.qz-pass > span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 400; }

@media (max-width: 860px) {
  .qz-card { padding: 16px 14px 14px; }
  .qz-card-head { gap: 10px; }
  .qz-card-head .spacer { display: none; }
  .qz-card-tools { margin-left: auto; }
  .qz-type { order: 3; width: 100%; }
  .qz-type button { flex: 1; }
  .qz-choice-tools { opacity: 1; }
  .qz-choice-tools [data-act=choice-up], .qz-choice-tools [data-act=choice-down] { display: none; }
  .qz-choice:focus-within .qz-choice-tools [data-act=choice-up], .qz-choice:focus-within .qz-choice-tools [data-act=choice-down] { display: grid; }
  .qz-intro { padding: 14px 14px 4px; }
}

/* ── Quiz player additions ──────────────────────────────────────────── */
.quiz-explain { clear: both; margin: 10px 0 0; padding: 10px 12px; border-radius: var(--r-md); background: var(--sunken); color: var(--ink-2); font-size: 15px; line-height: 1.55; }

/* Result states: "done" is a single-attempt quiz below the pass mark, which still completes the lesson. */
.quiz-result strong { font-size: 16px; line-height: 1.4; }
.quiz-score { font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.45; }
.quiz-result.done { background: var(--sunken); color: var(--deep); box-shadow: inset 3px 0 0 var(--sky); }

/* ── Host results drawer ────────────────────────────────────────────── */
.crumb .quiz-results-btn { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; }
.crumb .quiz-results-btn + .edit-lesson { margin-left: 0; }
dialog.qz-results { position: fixed; inset: 0 0 0 auto; width: min(460px, 100vw); height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: var(--bg); color: var(--ink); box-shadow: var(--shadow-3); display: none; flex-direction: column; }
dialog.qz-results[open] { display: flex; animation: qzr-in 260ms var(--ease-out) both; }
dialog.qz-results::backdrop { background: rgba(9, 48, 77, .32); backdrop-filter: blur(2px); }
@keyframes qzr-in { from { transform: translateX(24px); opacity: 0; } }
.qzr-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 20px 16px; background: var(--card); box-shadow: 0 1px 0 var(--line); }
.qzr-head h2 { margin: 0; font: 700 20px/1.3 Lato, sans-serif; color: var(--deep); }
.qzr-head p { margin: 4px 0 0; }
.qzr-body { flex: 1; overflow-y: auto; padding: 18px 20px 28px; display: grid; align-content: start; gap: 14px; }
.qzr-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.qzr-stat { display: grid; gap: 2px; padding: 12px 14px; border-radius: var(--r-md); background: var(--card); box-shadow: var(--shadow-1); }
.qzr-stat strong { font: 700 22px/1.2 Lato, sans-serif; font-variant-numeric: tabular-nums; color: var(--deep); }
.qzr-stat span { font-size: 13px; line-height: 1.35; color: var(--muted); }
.qzr-rule { margin: 0; }
.qzr-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.qzr-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 14px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow-1); }
.qzr-who { display: grid; gap: 4px; min-width: 0; }
.qzr-who strong { font-size: 15px; line-height: 1.35; color: var(--deep); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qzr-meta { display: flex; flex-wrap: wrap; gap: 0 6px; font-size: 13.5px; line-height: 1.45; color: var(--muted); font-variant-numeric: tabular-nums; }
.qzr-score { font-weight: 700; color: var(--ink); }
.qzr-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.qzr-tags .pill svg { margin-left: -2px; }
.qzr-reset { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.qzr-empty { margin: 24px 0; text-align: center; line-height: 1.5; }
@media (max-width: 560px) {
  dialog.qz-results { inset: auto 0 0 0; width: 100vw; height: min(88dvh, 760px); border-radius: 20px 20px 0 0; }
  @keyframes qzr-in { from { transform: translateY(32px); opacity: 0; } }
  .qzr-head { padding: 18px 16px 14px; border-radius: 20px 20px 0 0; }
  .qzr-body { padding: 16px 16px 24px; }
  .qzr-row { grid-template-columns: auto 1fr; }
  .qzr-reset { grid-column: 1 / -1; justify-content: center; }
}
