/* ==========================================================================
   Telkini v149 — Lesen Teil 1: لوحة النتيجة · الشرح · التنقل · ورقة الاختيار على الجوال
   يتبع ألوان Telkini الحالية (أخضر emerald للصحيح، أحمر للخطأ، أزرق للتحديد).
   ========================================================================== */

/* ---------- حالة البطاقات بعد التصحيح ---------- */
#exercise-view[data-tk-checked] .text-card[data-tk-state="ok"] { border-color: #6ee7b7 !important; }
#exercise-view[data-tk-checked] .text-card[data-tk-state="bad"],
#exercise-view[data-tk-checked] .text-card[data-tk-state="none"] { border-color: #fca5a5 !important; }
#exercise-view[data-tk-checked] .text-card[data-tk-state].border-\[\#60a5fa\] { border-color: #60a5fa !important; }
html.dark #exercise-view[data-tk-checked] .text-card[data-tk-state="ok"] { border-color: rgba(52, 211, 153, .55) !important; }
html.dark #exercise-view[data-tk-checked] .text-card[data-tk-state="bad"],
html.dark #exercise-view[data-tk-checked] .text-card[data-tk-state="none"] { border-color: rgba(248, 113, 113, .5) !important; }

/* ---------- لوحة النتيجة ---------- */
.tk-t1-results { display: none; }
.tk-t1-results.is-on {
  display: block; max-width: 820px; margin: 0 auto 28px; padding: 22px 24px;
  border-radius: 24px; background: #fff; border: 1px solid #e2e8f0;
  box-shadow: 0 10px 30px -12px rgba(15, 23, 42, .15);
  font-family: Cairo, Tajawal, sans-serif; scroll-margin-top: 24px;
  animation: tkT1In .45s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes tkT1In { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.tk-t1-results.is-pass { border-color: #a7f3d0; background: linear-gradient(180deg, #f0fdf4, #fff 60%); }
.tk-t1-results.is-fail { border-color: #fde68a; background: linear-gradient(180deg, #fffbeb, #fff 60%); }
html.dark .tk-t1-results.is-on { background: #0f172a; border-color: #1f2937; box-shadow: 0 10px 30px -12px rgba(0, 0, 0, .6); }
html.dark .tk-t1-results.is-pass { border-color: rgba(16, 185, 129, .35); background: linear-gradient(180deg, rgba(6, 78, 59, .35), #0f172a 60%); }
html.dark .tk-t1-results.is-fail { border-color: rgba(245, 158, 11, .35); background: linear-gradient(180deg, rgba(120, 53, 15, .3), #0f172a 60%); }

.tk-t1-res-top { display: flex; align-items: center; gap: 18px; }
.tk-t1-ring {
  --p: 0; --c: #10b981;
  position: relative; flex-shrink: 0; width: 84px; height: 84px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), #e5e7eb 0);
}
.tk-t1-results.is-fail .tk-t1-ring { --c: #f59e0b; }
.tk-t1-ring::before { content: ''; position: absolute; inset: 7px; border-radius: 50%; background: #fff; }
html.dark .tk-t1-ring { background: conic-gradient(var(--c) calc(var(--p) * 1%), #1f2937 0); }
html.dark .tk-t1-ring::before { background: #0f172a; }
.tk-t1-ring b, .tk-t1-ring small { position: relative; font-family: Outfit, Poppins, Inter, sans-serif; line-height: 1; }
.tk-t1-ring b { font-size: 22px; font-weight: 800; color: #0f172a; }
.tk-t1-ring small { margin-top: 3px; font-size: 11px; font-weight: 700; color: #64748b; }
html.dark .tk-t1-ring b { color: #f8fafc; }
.tk-t1-res-txt { min-width: 0; }
.tk-t1-res-txt h3 { margin: 0 0 4px; font-size: 17px; font-weight: 800; color: #0f172a; }
.tk-t1-res-txt p { margin: 0; font-size: 13.5px; color: #475569; line-height: 1.7; }
html.dark .tk-t1-res-txt h3 { color: #f8fafc; }
html.dark .tk-t1-res-txt p { color: #cbd5e1; }
.tk-t1-res-stats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tk-t1-res-stats span { padding: 2px 10px; border-radius: 9999px; font-size: 11.5px; font-weight: 700; }
.tk-t1-res-stats .is-ok { background: #d1fae5; color: #047857; }
.tk-t1-res-stats .is-bad { background: #fee2e2; color: #b91c1c; }
.tk-t1-res-stats .is-none { background: #f1f5f9; color: #475569; }
html.dark .tk-t1-res-stats .is-ok { background: rgba(16, 185, 129, .18); color: #6ee7b7; }
html.dark .tk-t1-res-stats .is-bad { background: rgba(239, 68, 68, .18); color: #fca5a5; }
html.dark .tk-t1-res-stats .is-none { background: rgba(148, 163, 184, .15); color: #cbd5e1; }

.tk-t1-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; direction: ltr; justify-content: center; }
.tk-t1-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 12px;
  border: 1.5px solid transparent; font-family: Outfit, Poppins, Inter, sans-serif; font-size: 13px; font-weight: 800;
  cursor: pointer; transition: transform .15s ease, box-shadow .15s ease;
}
.tk-t1-chip:hover { transform: translateY(-2px); box-shadow: 0 6px 14px -6px rgba(15, 23, 42, .25); }
.tk-t1-chip:focus-visible { outline: 3px solid rgba(59, 130, 246, .45); outline-offset: 2px; }
.tk-t1-chip.is-ok { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.tk-t1-chip.is-bad { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.tk-t1-chip.is-none { background: #f8fafc; color: #64748b; border-color: #e2e8f0; }
html.dark .tk-t1-chip.is-ok { background: rgba(16, 185, 129, .12); color: #6ee7b7; border-color: rgba(16, 185, 129, .35); }
html.dark .tk-t1-chip.is-bad { background: rgba(239, 68, 68, .12); color: #fca5a5; border-color: rgba(239, 68, 68, .35); }
html.dark .tk-t1-chip.is-none { background: rgba(148, 163, 184, .08); color: #94a3b8; border-color: #334155; }
.tk-t1-chip-n { opacity: .7; font-weight: 700; }

.tk-t1-res-acts { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 18px; }
.tk-t1-btn {
  padding: 10px 18px; border-radius: 12px; border: 1px solid #e2e8f0; background: #fff; color: #0f172a;
  font-family: Cairo, Tajawal, sans-serif; font-size: 13.5px; font-weight: 800; cursor: pointer;
  transition: background-color .2s ease, transform .15s ease, box-shadow .2s ease;
}
.tk-t1-btn:hover { background: #f8fafc; }
.tk-t1-btn:active { transform: scale(.97); }
.tk-t1-btn:focus-visible { outline: 3px solid rgba(59, 130, 246, .45); outline-offset: 2px; }
.tk-t1-btn.is-primary { background: #1d4ed8; border-color: #1d4ed8; color: #fff; box-shadow: 0 6px 16px -6px rgba(29, 78, 216, .55); }
.tk-t1-btn.is-primary:hover { background: #1e40af; }
.tk-t1-btn.is-ghost { background: transparent; color: #047857; border-color: #a7f3d0; }
html.dark .tk-t1-btn { background: #1e293b; border-color: #334155; color: #f1f5f9; }
html.dark .tk-t1-btn:hover { background: #273449; }
html.dark .tk-t1-btn.is-primary { background: #2563eb; border-color: #2563eb; }
html.dark .tk-t1-btn.is-ghost { background: transparent; color: #6ee7b7; border-color: rgba(16, 185, 129, .4); }
.tk-t1-stale { display: none; margin: 12px 0 0; text-align: center; font-size: 12px; font-weight: 700; color: #b45309; }
.tk-t1-results.is-stale .tk-t1-stale { display: block; }
.tk-t1-results.is-stale .tk-t1-ring, .tk-t1-results.is-stale .tk-t1-chips { opacity: .45; }

/* ---------- الشرح داخل الخانة ---------- */
.tk-t1-why { margin-top: 10px; padding-top: 10px; border-top: 1px dashed rgba(148, 163, 184, .5); text-align: right; font-family: Cairo, Tajawal, sans-serif; font-weight: 500; }
.tk-t1-why-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: #047857; }
.tk-t1-why-right b { display: inline-flex; width: 24px; height: 24px; border-radius: 8px; align-items: center; justify-content: center; background: #10b981; color: #fff; font-family: Outfit, Inter, sans-serif; font-size: 12px; }
.tk-t1-why-right span { font-family: Inter, sans-serif; font-weight: 700; color: #065f46; }
.tk-t1-why-right em { font-style: normal; font-size: 11px; opacity: .75; }
.tk-t1-why-t { margin-top: 8px; font-size: 11.5px; font-weight: 800; color: #1d4ed8; }
.tk-t1-why-t.is-trap { color: #b45309; }
.tk-t1-why p { margin: 3px 0 0; font-size: 12.5px; line-height: 1.8; color: #334155; white-space: pre-line; }
html.dark .tk-t1-why-right { color: #6ee7b7; }
html.dark .tk-t1-why-right span { color: #a7f3d0; }
html.dark .tk-t1-why-t { color: #93c5fd; }
html.dark .tk-t1-why-t.is-trap { color: #fcd34d; }
html.dark .tk-t1-why p { color: #cbd5e1; }

/* ---------- التنقل بين الأسئلة ---------- */
.tk-t1-step { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 10px; font-family: Cairo, Tajawal, sans-serif; }
.tk-t1-step-btn {
  width: 30px; height: 30px; border-radius: 10px; border: 1px solid #e2e8f0; background: #fff; color: #334155;
  font-size: 18px; line-height: 1; font-weight: 800; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}
.tk-t1-step-btn:hover:not(:disabled) { border-color: #60a5fa; color: #1d4ed8; background: #eff6ff; }
.tk-t1-step-btn:disabled { opacity: .35; cursor: default; }
.tk-t1-step-btn:focus-visible { outline: 3px solid rgba(59, 130, 246, .45); outline-offset: 2px; }
.tk-t1-step-lab { min-width: 92px; text-align: center; font-size: 12px; font-weight: 800; color: #475569; }
html.dark .tk-t1-step-btn { background: #1e293b; border-color: #334155; color: #e2e8f0; }
html.dark .tk-t1-step-btn:hover:not(:disabled) { background: rgba(59, 130, 246, .15); border-color: #3b82f6; color: #93c5fd; }
html.dark .tk-t1-step-lab { color: #cbd5e1; }

/* ---------- ورقة الاختيار (جوال / تابلت) ---------- */
.tk-t1-sheet { position: fixed; inset: 0; z-index: 120; display: none; }
.tk-t1-sheet.is-open { display: block; }
.tk-t1-sheet-bg { position: absolute; inset: 0; background: rgba(2, 6, 23, .45); animation: tkT1Fade .2s ease both; }
@keyframes tkT1Fade { from { opacity: 0; } to { opacity: 1; } }
.tk-t1-sheet-card {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 78vh; display: flex; flex-direction: column;
  border-radius: 24px 24px 0 0; background: #fff; box-shadow: 0 -20px 40px -10px rgba(2, 6, 23, .35);
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  animation: tkT1Up .28s cubic-bezier(.2, .8, .2, 1) both; font-family: Cairo, Tajawal, sans-serif;
}
@keyframes tkT1Up { from { transform: translateY(100%); } to { transform: none; } }
html.dark .tk-t1-sheet-card { background: #0f172a; }
.tk-t1-sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 10px; border-bottom: 1px solid #f1f5f9; }
.tk-t1-sheet-head b { font-size: 15px; font-weight: 800; color: #0f172a; }
html.dark .tk-t1-sheet-head { border-color: #1f2937; }
html.dark .tk-t1-sheet-head b { color: #f8fafc; }
.tk-t1-sheet-x { width: 34px; height: 34px; border-radius: 10px; border: 1px solid #e2e8f0; background: #f8fafc; color: #475569; font-size: 14px; cursor: pointer; }
html.dark .tk-t1-sheet-x { background: #1e293b; border-color: #334155; color: #cbd5e1; }
.tk-t1-sheet-list { overflow-y: auto; overscroll-behavior: contain; padding: 12px 14px 4px; display: flex; flex-direction: column; gap: 8px; }
.tk-t1-sheet-opt {
  display: flex; align-items: stretch; width: 100%; min-height: 56px; text-align: left; padding: 0; overflow: hidden;
  border-radius: 14px; border: 1.5px solid #e2e8f0; background: #fff; cursor: pointer; transition: border-color .15s ease, background-color .15s ease;
}
.tk-t1-sheet-opt:active { background: #eff6ff; }
.tk-t1-sheet-opt:focus-visible { outline: 3px solid rgba(59, 130, 246, .45); outline-offset: 1px; }
.tk-t1-sheet-opt.is-mine { border-color: #60a5fa; background: #eff6ff; }
.tk-t1-sheet-opt.is-used { opacity: .55; }
html.dark .tk-t1-sheet-opt { background: #111827; border-color: #1f2937; }
html.dark .tk-t1-sheet-opt.is-mine { border-color: #3b82f6; background: rgba(59, 130, 246, .12); }
.tk-t1-sheet-k { width: 44px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: #f8fafc; border-right: 1px solid #f1f5f9; font-family: Outfit, Inter, sans-serif; font-weight: 800; font-size: 13px; color: #475569; }
html.dark .tk-t1-sheet-k { background: #0b1222; border-color: #1f2937; color: #94a3b8; }
.tk-t1-sheet-t { flex: 1; min-width: 0; padding: 10px 12px; display: flex; flex-direction: column; justify-content: center; gap: 3px; }
.tk-t1-sheet-de { font-family: Inter, sans-serif; font-size: 13.5px; font-weight: 700; line-height: 1.35; color: #0f172a; overflow-wrap: anywhere; }
.tk-t1-sheet-ar { font-size: 12px; color: #1d4ed8; text-align: right; }
.tk-t1-sheet-used { font-size: 11px; font-weight: 700; color: #b45309; text-align: right; }
html.dark .tk-t1-sheet-de { color: #f1f5f9; }
html.dark .tk-t1-sheet-ar { color: #93c5fd; }
html.tk-t1-lock, html.tk-t1-lock body { overflow: hidden !important; }

/* ---------- تجاوب ---------- */
@media (max-width: 639px) {
  .tk-t1-results.is-on { padding: 18px 16px; border-radius: 20px; margin-bottom: 20px; }
  .tk-t1-res-top { gap: 14px; }
  .tk-t1-ring { width: 70px; height: 70px; }
  .tk-t1-ring b { font-size: 18px; }
  .tk-t1-res-acts { flex-direction: column; }
  .tk-t1-btn { width: 100%; }
  #exercise-view #exercise-texts-container .text-card { padding: 18px !important; border-radius: 20px !important; }
}
@media (prefers-reduced-motion: reduce) {
  .tk-t1-results.is-on, .tk-t1-sheet-card, .tk-t1-sheet-bg { animation: none !important; }
  .tk-t1-chip:hover { transform: none; }
}
