/* Jin Seon Learn quiz screens: the exam player and the colour-blind test (JinSeon.Learn.Client). Full screen, a
   header and a footer that never cover the question, and two columns where there is room (landscape phones,
   tablets, desktops); on a portrait phone the question sits above the answers. */

html:has(.quiz-app), html:has(.quiz-app) body { overscroll-behavior: none; height: 100%; }
html:has(.quiz-app) body { background: var(--surface); overflow: hidden; }

.quiz-app { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--surface); }

/* Loading screen until the player has downloaded and drawn. */
.quiz-boot { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; text-align: center; padding: 24px; color: var(--text-2); }
.quiz-boot img { border-radius: 50%; }
.quiz-boot p { font-size: 14px; }
.quiz-app:has(.quiz-screen) .quiz-boot { display: none; }

.quiz-screen { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; animation: fade-in 160ms; }

/* ------------------------------------------------------------------------------------------------- header / footer */
.quiz-top { flex: none; display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 6px 16px; padding-top: max(6px, env(safe-area-inset-top));
  background: var(--white); border-bottom: 1px solid var(--border-subtle); }
.quiz-logo { width: 30px; height: 30px; border-radius: 50%; flex: none; }
.quiz-heading { font: 700 15px var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.quiz-name { display: none; font: 600 18px var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; max-width: 34vw; }
.quiz-qno { font: 600 15px var(--font-display); white-space: nowrap; }
.quiz-qno strong { font-weight: 700; }
.quiz-qno span { color: var(--text-3); font-weight: 500; }
.quiz-top .spacer { flex: 1; }
.quiz-top .btn-sm { height: 34px; padding: 0 12px; }
.timer-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px; background: var(--text); color: #fff;
  font: 700 16px var(--font-display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.timer-pill.urgent { background: var(--red); }

.quiz-bottom { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 64px;
  padding: 8px 16px; padding-bottom: max(8px, env(safe-area-inset-bottom)); background: var(--white); border-top: 1px solid var(--border-subtle); }
.quiz-bottom .btn { gap: 6px; padding: 0 16px; }

.quiz-banner { flex: none; display: flex; align-items: flex-start; gap: 8px; padding: 5px 16px; font-size: 12px; line-height: 1.6; }
.quiz-banner.warn { background: var(--warning-50); color: var(--warning-fg); }
.quiz-banner.playing { background: var(--red-50); color: var(--red-deep); }
.quiz-banner.playing .icon { color: var(--red); margin-top: 3px; flex: none; }
.quiz-banner.playing .mm { font-weight: 600; font-size: 12px; }

@media (min-width: 900px) {
  .quiz-top { min-height: 64px; padding-left: 32px; padding-right: 32px; gap: 14px; }
  .quiz-logo { width: 36px; height: 36px; }
  .quiz-name { display: block; }
  .timer-pill { font-size: 18px; padding: 6px 14px; }
  .quiz-bottom { min-height: 76px; padding-left: 32px; padding-right: 32px; }
  .quiz-bottom .btn { height: 52px; padding: 0 28px; border-radius: 16px; }
}
@media (max-width: 420px) { .hide-xs { display: none; } .quiz-bottom .btn { padding: 0 14px; } }
.quiz-leave { gap: 4px; }
/* Phones: the header keeps the section, the question number and the timer; Leave becomes an ✕. */
@media (max-width: 479px) {
  .quiz-top { gap: 8px; padding-left: 12px; padding-right: 12px; }
  .quiz-logo { width: 26px; height: 26px; }
  .quiz-qno { font-size: 14px; }
  .timer-pill { font-size: 15px; padding: 5px 8px; gap: 4px; }
  .quiz-leave { width: 34px; padding: 0; }
  .quiz-leave .leave-text { display: none; }
}

/* --------------------------------------------------------------------------------------------------- the question */
.quiz-body { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 12px 16px; }
.quiz-center { display: grid; place-items: center; }
.exam-body { display: flex; flex-direction: column; gap: 14px; }
.quiz-question, .quiz-answers { min-width: 0; }
.quiz-qno-wide { display: none; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.q-instruction { font: 500 14px/1.5 var(--font-kr); color: var(--text-2); }
.q-text { margin-top: 8px; padding: 14px; font: 400 16px/1.7 var(--font-kr); color: var(--text); }
.q-image { all: unset; box-sizing: border-box; position: relative; display: grid; place-items: center; margin-top: 8px; width: 100%; background: var(--white);
  border-radius: var(--r-card); overflow: hidden; cursor: zoom-in; }
.q-image img { max-width: 100%; max-height: 220px; object-fit: contain; display: block; }
.q-image:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Two columns where there's room: the question (scrolling on its own) beside the answers. */
@media (min-width: 720px) and (min-aspect-ratio: 1/1), (min-width: 1000px) {
  .exam-body { display: grid; grid-template-columns: 10fr 10fr; gap: 16px; overflow: hidden; padding-top: 12px; padding-bottom: 12px; }
  .exam-body > .quiz-question, .exam-body > .quiz-answers { overflow: auto; overscroll-behavior: contain; padding: 2px 4px 2px 2px; }
}
@media (min-width: 1000px) {
  .exam-body { grid-template-columns: 11fr 10fr; gap: 24px; padding: 16px 32px; }
  .quiz-qno-wide { display: block; }
  .q-instruction { font-size: 16px; }
  .q-text { font-size: 18px; }
  .q-image img { max-height: 300px; }
}

/* ------------------------------------------------------------------------------------------------------- answers */
.options { display: flex; flex-direction: column; gap: 6px; }
.answers-image .options, .answers-audio .options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.opt { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 46px; padding: 8px 12px; text-align: left;
  background: var(--white); border: 1.5px solid transparent; border-radius: var(--r-inline); box-shadow: var(--card-shadow); color: var(--text);
  font: 400 15px/1.45 var(--font-kr); cursor: pointer; transition: background var(--dur), border-color var(--dur), transform var(--dur); }
.opt:hover:not(:disabled) { border-color: var(--line); }
.opt:active:not(:disabled) { transform: scale(.99); }
.opt.selected { background: var(--selected-bg); border-color: var(--primary); }
.opt:disabled { cursor: default; }
.opt-key { width: 26px; height: 26px; border-radius: 50%; background: var(--surface); color: var(--text-2); display: grid; place-items: center; flex: none;
  font: 700 13px var(--font-display); }
.opt.selected .opt-key { background: var(--primary); color: #fff; }
.opt-label { flex: 1; min-width: 0; }
@media (min-width: 1000px) { .opt { min-height: 56px; font-size: 17px; } .opt-key { width: 30px; height: 30px; } .options { gap: 10px; } }

.opt-wrap { position: relative; }
.opt-image { flex-direction: column; justify-content: space-between; padding: 8px; aspect-ratio: 1.35; }
.opt-image img { flex: 1; min-height: 0; width: 100%; object-fit: contain; }
.opt-zoom { position: absolute; top: 4px; right: 4px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff;
  display: grid; place-items: center; cursor: zoom-in; }

.opt-audio { flex-direction: column; align-items: stretch; gap: 0; padding: 10px; cursor: pointer; }
.opt-audio.is-playing { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue), var(--card-shadow); }
.opt-audio.is-locked { opacity: .45; }
.opt-audio-label { flex: 1; text-align: right; font-size: 11px; line-height: 1.3; color: var(--text-3);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Question audio (and the play buttons of audio answers). */
.audio-card { display: flex; align-items: center; gap: 12px; margin-top: 8px; padding: 14px; border: 1.5px solid transparent; }
.audio-card.is-playing { background: var(--selected-bg); border-color: var(--primary); }
.audio-card.is-error { background: var(--danger-bg); border-color: var(--danger-border); }
.audio-btn { width: 52px; height: 52px; border-radius: 50%; border: 0; display: grid; place-items: center; flex: none; cursor: pointer; color: #fff; background: var(--surface); }
.audio-btn.sm { width: 36px; height: 36px; }
.audio-btn.ready { background: var(--red); box-shadow: 0 4px 12px rgba(255, 0, 0, .25); }
.audio-btn.playing { background: var(--blue); }
.audio-btn.played { background: var(--success); }
.audio-btn.played-soft, .audio-btn.off { background: var(--surface); color: var(--icon-muted); }
.audio-btn.error { background: var(--red-50); color: var(--red); }
.audio-btn:disabled { cursor: default; }
.audio-btn .spin { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .8s linear infinite; }
.audio-btn.sm .spin { width: 16px; height: 16px; border-width: 2px; }
.bars { display: inline-flex; align-items: center; gap: 3px; height: 24px; }
.bars i { width: 4px; border-radius: 2px; background: #fff; animation: bars 900ms ease-in-out infinite; }
.bars i:nth-child(1) { height: 16px; } .bars i:nth-child(2) { height: 24px; animation-delay: .15s; } .bars i:nth-child(3) { height: 12px; animation-delay: .3s; }
@keyframes bars { 50% { transform: scaleY(.5); } }
.audio-info { flex: 1; min-width: 0; }
.audio-title { font: 600 14px var(--font-body); color: var(--text); }
.audio-progress { height: 6px; border-radius: 6px; background: var(--border-subtle); overflow: hidden; margin: 8px 0 6px; flex: 1; }
.audio-progress.thin { height: 4px; margin: 0; }
.audio-progress span { display: block; height: 100%; background: var(--red); transition: width 250ms linear; }
.audio-card.is-playing .audio-progress span, .opt-audio.is-playing .audio-progress span { background: var(--blue); }
.audio-card .audio-progress span[style^="width:100"] { background: var(--text-3); }
.audio-note { font-size: 12px; line-height: 1.4; color: var(--text-2); }

/* The current section's grid under the answers, on big screens (the app's tablet layout). */
.mini-grid { display: none; }
@media (min-width: 1000px) and (min-height: 640px) { .mini-grid { display: block; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border-subtle); } }

/* ------------------------------------------------------------------------------------------------- navigator */
.qgrid + .qgrid { margin-top: 12px; }
.qgrid-label { font: 600 15px var(--font-body); margin-bottom: 6px; }
.qgrid-blocks { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
@media (min-width: 480px) { .qgrid-blocks { grid-template-columns: repeat(10, minmax(0, 1fr)); } }
.qblock { height: var(--block-h, 40px); border-radius: 6px; border: 1px solid var(--border); background: var(--white); color: var(--text);
  font: 600 14px var(--font-body); cursor: pointer; padding: 0; }
.qblock:hover:not(:disabled) { border-color: var(--text-3); }
.qblock.answered { background: var(--red); border-color: var(--red); color: #fff; }
.qblock.current { border: 2px solid var(--blue); color: var(--blue); background: var(--white); }
.qblock.missing { border: 2px solid var(--red); color: var(--red); background: var(--red-50); }
.qblock:disabled { cursor: default; }

.quiz-nav { flex: 1; min-height: 0; overflow: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 16px; }
.quiz-nav-side { display: flex; flex-direction: column; gap: 10px; }
.quiz-nav-side .t-h1 { margin-top: 2px; }
.legend { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--text-2); }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--border); background: var(--white); }
.swatch.answered { background: var(--red); border-color: var(--red); }
.swatch.current { border: 2px solid var(--blue); }
.swatch.missing { border: 2px solid var(--red); background: var(--red-50); }
.quiz-nav-actions { display: flex; flex-direction: column; gap: 8px; margin-top: auto; }
@media (min-width: 720px) and (min-aspect-ratio: 1/1), (min-width: 1000px) {
  .quiz-nav { flex-direction: row; overflow: hidden; }
  .quiz-nav-grids { flex: 1; min-width: 0; overflow: auto; padding-right: 4px; }
  .quiz-nav-side { width: 220px; flex: none; }
  .legend { flex-direction: column; }
}
@media (min-width: 1000px) { .quiz-nav { padding: 20px 32px; gap: 24px; } .qgrid-blocks { --block-h: 46px; } }

/* ---------------------------------------------------------------------------------------- watermark, dialogs */
/* The logo, faint, over the question and answers: a watermark, never in the way of a tap or a screen reader. */
.quiz-watermark { position: absolute; inset: 0; pointer-events: none; opacity: .05;
  background: url("/img/logo.png") center / min(55vmin, 320px) no-repeat; }
.exam-screen { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.busy-card { text-align: center; display: grid; justify-items: center; gap: 12px; }
.busy-card h2 { margin: 0; }
.busy-card p { font-size: 14px; line-height: 1.8; color: var(--text); }
.busy-card .countdown { font-weight: 600; font-size: 13px; color: var(--blue); }
.missing-summary { margin-top: 10px; font-size: 14px; font-weight: 600; color: var(--red); }
.warn-strong { color: var(--red); font-weight: 600; font-size: 14px; }

/* Left the exam / couldn't open it. */
.quiz-message { display: grid; place-items: center; padding: 20px; overflow: auto; }
.left-card { width: min(440px, 100%); display: flex; flex-direction: column; gap: 10px; padding: 20px; border-radius: var(--r-dialog); }
.left-card .badge { align-self: flex-start; }
.left-card > .icon { align-self: center; }
.left-card .mm { font-size: 14px; line-height: 1.7; color: var(--text); }

/* -------------------------------------------------------------------------------------------- colour-blind test */
.cbt-body { display: flex; flex-direction: column; gap: 12px; overflow: auto; }
.cbt-plate-side { display: grid; place-items: center; min-height: 0; }
.cbt-plate-btn { all: unset; cursor: zoom-in; display: block; width: min(100%, 46dvh, 420px); aspect-ratio: 1; border-radius: 50%; overflow: hidden; }
.cbt-plate-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cbt-plate-btn:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
.cbt-entry { position: relative; display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 440px; margin: 0 auto; }
.answer-display { height: 52px; border-radius: var(--r-field); border: 1px solid var(--border); background: var(--white); display: grid; place-items: center; }
.answer-display .placeholder { color: var(--text-3); }
.answer-display strong { font: 800 28px var(--font-display); letter-spacing: 4px; }
.numpad button.key { cursor: pointer; }
.numpad button.key:active:not(:disabled) { background: var(--surface); }
.numpad button.key:disabled { opacity: .45; cursor: default; }
@media (min-width: 720px) and (min-aspect-ratio: 1/1), (min-width: 1000px) {
  .cbt-body { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: center; padding: 16px 32px; overflow: hidden; }
  .cbt-plate-btn { width: min(100%, calc(100dvh - 190px), 520px); }
  .numpad button.key { min-height: 56px; }
}

.cbt-result { width: min(860px, 100%); display: grid; gap: 20px; align-items: center; }
.cbt-result .verdict { display: grid; justify-items: center; gap: 6px; text-align: center; }
.verdict-ic { width: 88px; height: 88px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 10px; }
.verdict-ic.pass { background: var(--success-50); color: var(--success); }
.verdict-ic.fail { background: var(--red-50); color: var(--red); }
@media (min-width: 720px) { .cbt-result { grid-template-columns: 4fr 6fr; gap: 32px; } }

@media (prefers-reduced-motion: reduce) { .bars i, .audio-btn .spin { animation: none; } .quiz-screen { animation: none; } }
