/* =========================================================
   ARABIYYATI — Quiz & Latihan components
   ========================================================= */

/* ---------- Level selection ---------- */
.level-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1.6rem; }
.level-card {
  position: relative; text-align: left; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 1.3rem; box-shadow: var(--shadow-sm);
  transition: transform .22s var(--ease), box-shadow .22s, border-color .22s;
}
.level-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--emerald-500) 40%, var(--line)); }
.level-card.selected { border-color: var(--emerald-600); box-shadow: 0 0 0 3px color-mix(in srgb, var(--emerald-500) 22%, transparent), var(--shadow-md); }
.level-card .lv-badge { display: inline-flex; align-self: flex-start; padding: .22rem .6rem; border-radius: var(--radius-pill); font-size: .64rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; background: var(--emerald-50); color: var(--emerald-700); margin-bottom: .7rem; }
[data-theme="dark"] .level-card .lv-badge { color: var(--emerald-100); }
.level-card[data-level="dasar"] .lv-badge { background: var(--gold-100); color: var(--gold-600); }
[data-theme="dark"] .level-card[data-level="dasar"] .lv-badge { color: var(--gold-300); }
.level-card[data-level="menengah"] .lv-badge { background: var(--info-bg); color: var(--info); }
.level-card h3 { font-size: 1.1rem; margin-bottom: .25rem; }
.level-card p { font-size: .84rem; color: var(--muted); margin-bottom: 1rem; }
.level-card .lv-meta { display: flex; flex-wrap: wrap; gap: .35rem .9rem; font-size: .72rem; font-weight: 700; color: var(--muted); margin-top: auto; }
.level-card .lv-lock {
  position: absolute; top: 1rem; right: 1rem; color: var(--muted);
  display: inline-flex; align-items: center; gap: .3rem; font-size: .68rem; font-weight: 800;
}
.level-card .lv-lock svg { width: 14px; height: 14px; }
.level-card.locked { opacity: .72; }
.level-card.locked:hover { transform: none; }
.level-card .lv-progress { margin-top: .8rem; }
.level-card .lv-progress .progress { height: 6px; }

/* ---------- Quiz shell ---------- */
.quiz-shell { max-width: 780px; margin-inline: auto; }
.quiz-topbar { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.quiz-topbar .qt-exit {
  display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); border-radius: var(--radius-pill);
  padding: .4rem .75rem; font-size: .78rem; font-weight: 700; flex: none;
}
.quiz-topbar .qt-exit:hover { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.quiz-topbar .qt-exit svg { width: 15px; height: 15px; }
.quiz-topbar .qt-progress { flex: 1; }
.quiz-topbar .qt-count { font-size: .74rem; font-weight: 800; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

.quiz-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-xl);
  padding: clamp(1.2rem, 3vw, 2rem); box-shadow: var(--shadow-md); position: relative; overflow: hidden;
}
.quiz-card::before {
  content: ""; position: absolute; inset: 0 auto auto 0; height: 4px; width: 100%;
  background: linear-gradient(90deg, var(--emerald-600), var(--gold-500));
}
.quiz-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .9rem; }
.quiz-meta .qm-type { font-size: .64rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.quiz-meta .qm-tag { font-size: .64rem; font-weight: 800; letter-spacing: .06em; padding: .18rem .5rem; border-radius: var(--radius-pill); background: var(--emerald-50); color: var(--emerald-700); }
[data-theme="dark"] .quiz-meta .qm-tag { color: var(--emerald-100); }
.quiz-question { font-size: clamp(1rem, 2vw, 1.18rem); font-weight: 700; margin-bottom: .5rem; }
.quiz-ar-display {
  font-family: var(--font-ar); direction: rtl; text-align: center;
  font-size: clamp(2.1rem, 5vw, 3rem); line-height: 1.75; color: var(--emerald-800);
  padding: 1rem; margin: .4rem 0 .9rem; background: var(--surface-2); border-radius: var(--radius);
  border: 1px solid var(--line);
}
[data-theme="dark"] .quiz-ar-display { color: var(--gold-300); }
.quiz-ar-display.small { font-size: clamp(1.5rem, 3.4vw, 2rem); }
.quiz-audio-center { display: flex; justify-content: center; margin: .3rem 0 1rem; }
.quiz-audio-center .btn-audio { width: 58px; height: 58px; }
.quiz-audio-center .btn-audio svg { width: 24px; height: 24px; }

.answer-list { display: grid; gap: .6rem; margin-top: 1rem; }
.answer {
  display: flex; align-items: center; gap: .8rem; width: 100%; text-align: left;
  padding: .8rem 1rem; border-radius: var(--radius); border: 1.5px solid var(--line);
  background: var(--surface); font-size: .94rem; font-weight: 600;
  transition: border-color .15s, background .15s, transform .15s;
}
.answer:hover:not([disabled]) { border-color: var(--emerald-500); background: var(--emerald-50); transform: translateX(2px); }
[data-theme="dark"] .answer:hover:not([disabled]) { background: var(--emerald-50); }
.answer .a-key {
  flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: var(--surface-2); color: var(--muted); font-size: .72rem; font-weight: 800;
}
.answer .a-body { min-width: 0; flex: 1; }
.answer .a-ar { font-family: var(--font-ar); direction: rtl; font-size: 1.4rem; line-height: 1.7; }
.answer .a-sub { font-size: .74rem; color: var(--muted); font-weight: 500; }
.answer.selected { border-color: var(--emerald-600); background: var(--emerald-50); }
[data-theme="dark"] .answer.selected { background: var(--emerald-50); }
.answer.correct { border-color: var(--success); background: var(--success-bg); }
.answer.correct .a-key { background: var(--success); color: #fff; }
.answer.wrong { border-color: var(--danger); background: var(--danger-bg); }
.answer.wrong .a-key { background: var(--danger); color: #fff; }
.answer[disabled] { cursor: default; }
.answer.dim { opacity: .55; }

.quiz-feedback { margin-top: 1rem; border-radius: var(--radius); padding: .8rem 1rem; font-size: .88rem; display: none; border: 1px solid transparent; }
.quiz-feedback.show { display: block; animation: fadeUp .25s var(--ease); }
.quiz-feedback.ok { background: var(--success-bg); color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.quiz-feedback.no { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.quiz-feedback strong { display: block; margin-bottom: .1rem; }
.quiz-feedback .qf-ar { font-family: var(--font-ar); direction: rtl; font-size: 1.1rem; }
.quiz-actions { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-top: 1.1rem; flex-wrap: wrap; }
.quiz-actions .qa-left { display: flex; align-items: center; gap: .5rem; }

/* ---------- Answer input (tipe isi kata) ---------- */
.answer-input {
  width: 100%;
  min-height: 58px;
  padding: .6rem 1rem;
  margin-top: .4rem;
  border-radius: var(--radius);
  border: 1.5px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--font-ar);
  font-size: clamp(1.4rem, 3vw, 1.8rem);
  line-height: 1.7;
  text-align: center;
  direction: rtl;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.answer-input::placeholder { color: var(--muted); font-size: .95rem; font-family: var(--font-ui); direction: rtl; }
.answer-input:focus {
  outline: none;
  border-color: var(--emerald-500);
  background: var(--surface);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--emerald-500) 18%, transparent);
}
.answer-input:disabled { opacity: .8; }

/* ---------- Match game ---------- */
.match-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-top: 1rem; }
.match-col { display: grid; gap: .5rem; align-content: start; }
.match-col-head { font-size: .66rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); padding: 0 .2rem; }
.match-item {
  width: 100%; padding: .7rem .8rem; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line); background: var(--surface);
  font-size: .9rem; font-weight: 600; text-align: center; transition: all .15s;
  min-height: 54px; display: grid; place-items: center;
}
.match-item.ar { font-family: var(--font-ar); direction: rtl; font-size: 1.3rem; line-height: 1.6; }
.match-item:hover:not([disabled]) { border-color: var(--emerald-500); }
.match-item.selected { border-color: var(--gold-500); background: var(--gold-100); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold-500) 20%, transparent); }
.match-item.matched { border-color: var(--success); background: var(--success-bg); color: var(--success); opacity: .75; }
.match-item.wrong { border-color: var(--danger); background: var(--danger-bg); animation: shake .35s; }

/* ---------- Result screen ---------- */
.result-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-xl);
  padding: clamp(1.5rem, 4vw, 2.6rem); box-shadow: var(--shadow-lg); text-align: center;
  max-width: 720px; margin-inline: auto; position: relative; overflow: hidden;
}
.result-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 6px;
  background: linear-gradient(90deg, var(--emerald-600), var(--gold-500), var(--emerald-600));
}
.result-badge { display: inline-grid; place-items: center; width: 86px; height: 86px; border-radius: 50%; background: var(--gold-100); color: var(--gold-600); margin-bottom: .8rem; border: 1px solid color-mix(in srgb, var(--gold-500) 35%, transparent); }
.result-badge svg { width: 42px; height: 42px; }
.result-card h2 { margin-bottom: .2rem; }
.result-card .result-sub { color: var(--muted); margin-bottom: 1.2rem; }
.result-score { display: flex; flex-direction: column; align-items: center; margin-bottom: 1rem; }
.result-score .rs-value { font-size: 3rem; font-weight: 800; line-height: 1; letter-spacing: -.04em; color: var(--emerald-700); }
[data-theme="dark"] .result-score .rs-value { color: var(--gold-300); }
.result-score .rs-label { font-size: .74rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.stars { display: flex; justify-content: center; gap: .35rem; margin: .5rem 0 1rem; }
.star { width: 32px; height: 32px; color: var(--surface-3); }
.star.on { color: var(--gold-500); filter: drop-shadow(0 3px 6px rgba(212,175,55,.4)); }
.result-stats { display: flex; justify-content: center; flex-wrap: wrap; gap: .8rem 2rem; margin: 1rem 0 1.4rem; }
.result-stat { display: flex; flex-direction: column; }
.result-stat .rs-num { font-size: 1.3rem; font-weight: 800; }
.result-stat .rs-cap { font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.result-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: .6rem; }

/* Review */
.review { text-align: left; margin-top: 1.6rem; border-top: 1px solid var(--line); padding-top: 1.2rem; }
.review h3 { font-size: .95rem; }
.review-list { display: grid; gap: .6rem; margin-top: .7rem; }
.review-item { border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .85rem; background: var(--surface-2); }
.review-item .ri-q { font-size: .84rem; font-weight: 700; margin-bottom: .25rem; }
.review-item .ri-a { font-size: .8rem; color: var(--muted); }
.review-item .ri-a b { color: var(--success); }
.review-item .ri-wrong { color: var(--danger); text-decoration: line-through; }

/* ---------- Loader ---------- */
.loader { display: inline-flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .9rem; }
.loader::before {
  content: ""; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line-strong); border-top-color: var(--emerald-600);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .level-grid { grid-template-columns: 1fr; }
  .level-card { flex-direction: column; }
}
@media (max-width: 560px) {
  .match-wrap { grid-template-columns: 1fr; }
  .match-col-head { text-align: center; }
  .quiz-topbar { gap: .6rem; }
  .quiz-topbar .qt-exit span { display: none; }
  .answer { padding: .7rem .8rem; }
  .stars .star { width: 27px; height: 27px; }
  .result-stats { gap: .7rem 1.4rem; }
}
