/* ============================================================
   بومة التضاد والترادف — لوحة مدرسية رقمية
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --paper: #FFF6E5;
  --rule: #EADFC8;
  --ink: #22333F;
  --ink-soft: #5A6B74;
  --card: #FFFFFF;
  --teal: #2AA79B;
  --teal-deep: #1D867C;
  --sun: #FFC94D;
  --coral: #E8604C;
  --green: #3FA45B;
  --purple: #7B5EA7;
  --gold: #C9A227;
  --shadow: 6px 6px 0 rgba(34, 51, 63, .12);
  --font-display: 'Baloo Bhaijaan 2', 'Tajawal', Tahoma, system-ui, sans-serif;
  --font-body: 'Tajawal', 'Segoe UI', Tahoma, system-ui, sans-serif;
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--paper);
  background-image: repeating-linear-gradient(var(--rule) 0 1px, transparent 1px 28px);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, p { margin: 0; }
strong { font-weight: 700; }

button {
  font-family: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.hidden { display: none !important; }

/* ============================ التخطيط ============================ */

.app {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 14px 44px;
}

.screen { animation: fadeUp .26s ease-out both; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card {
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px 16px;
}

/* ============================ العناوين ============================ */

.app-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(26px, 7.4vw, 36px);
  line-height: 1.25;
  margin-bottom: 4px;
}

.app-sub {
  font-size: 15.5px;
  color: var(--ink-soft);
  margin-bottom: 18px;
}

.section-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  margin: 18px 0 10px;
  padding-inline-start: 10px;
  border-inline-start: 6px solid var(--sun);
  border-radius: 3px;
}

.foot-note {
  margin-top: 16px;
  text-align: center;
  font-size: 14px;
  color: var(--ink-soft);
}

/* ============================ البومة ============================ */

.owl { width: 112px; height: 112px; flex: 0 0 auto; }
.owl--sm { width: 84px; height: 84px; }
.owl--lg { width: 132px; height: 132px; }
.owl svg { width: 100%; height: 100%; display: block; overflow: visible; }

.owl .owl-body,
.owl .wing,
.owl .pupil {
  transform-box: fill-box;
  transition: transform .32s cubic-bezier(.3, 1.4, .5, 1);
}

.owl .owl-body { transform-origin: 50% 88%; }
.owl .wing-left { transform-origin: 50% 8%; }
.owl .wing-right { transform-origin: 50% 8%; }
.owl .pupil { transform-origin: 50% 50%; }

/* التعابير */
.owl.is-happy .owl-body { transform: translateY(-4px); }
.owl.is-happy .wing-left { transform: rotate(36deg); }
.owl.is-happy .wing-right { transform: rotate(-36deg); }

.owl.is-thinking .owl-body { transform: rotate(-6deg); }
.owl.is-thinking .wing-right { transform: rotate(48deg); }
.owl.is-thinking .pupil { transform: translateY(-3px); }

.owl.is-oops .owl-body { transform: scale(.95) translateY(3px); }
.owl.is-oops .wing-left { transform: rotate(-12deg); }
.owl.is-oops .wing-right { transform: rotate(12deg); }

/* العيون */
.eyes-happy, .eyes-oops { display: none; }
.owl.is-happy .eyes-normal { display: none; }
.owl.is-happy .eyes-happy { display: block; }
.owl.is-oops .eyes-normal { display: none; }
.owl.is-oops .eyes-oops { display: block; }

/* قبعة التخرج */
.owl-cap { display: none; }
.owl.is-graduate .owl-cap { display: block; }
.owl.is-graduate .owl-body { transform: translateY(2px); }

/* الرمش */
.owl .lid {
  transform-box: fill-box;
  transform-origin: top center;
  transform: scaleY(0);
  animation: owlBlink 5.6s infinite;
}
@keyframes owlBlink {
  0%, 91%, 100% { transform: scaleY(0); }
  94% { transform: scaleY(1); }
  96% { transform: scaleY(0); }
}

/* ============================ فقاعة الكلام ============================ */

.guide {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 14px;
}
.guide--top { align-items: center; }
.guide--quiz { margin: 14px 0; align-items: flex-end; }
.guide--result { margin-bottom: 8px; }

.bubble {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 11px 15px;
  font-size: 16px;
  line-height: 1.6;
  box-shadow: 4px 4px 0 rgba(34, 51, 63, .1);
}
.bubble::after {
  content: '';
  position: absolute;
  top: 20px;
  right: -13px;
  width: 0; height: 0;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-left: 13px solid var(--ink);
}
.bubble::before {
  content: '';
  position: absolute;
  top: 23px;
  right: -7.5px;
  width: 0; height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 9px solid #fff;
  z-index: 1;
}

/* ============================ النماذج ============================ */

.field { margin-bottom: 16px; }

.field-label {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 6px;
}

.input {
  width: 100%;
  min-height: 56px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 10px 16px;
  font-family: var(--font-body);
  font-size: 19px;
  color: var(--ink);
  background: #FFFDF7;
  box-shadow: inset 0 2px 0 rgba(34, 51, 63, .05);
}
.input::placeholder { color: #A7A18F; }
.input:focus { outline: 3px solid var(--teal); outline-offset: 2px; }
.input--error { border-color: var(--coral); background: #FFF3F0; }

.grade-switch { display: flex; gap: 10px; }

.grade-btn {
  flex: 1;
  min-height: 54px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  color: var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  transition: transform .12s ease, background-color .15s ease, box-shadow .12s ease;
}
.grade-btn.is-active { background: var(--teal); color: #08302C; }
.grade-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.grade-btn:focus-visible { outline: 3px solid var(--purple); outline-offset: 3px; }

.error-msg {
  margin-top: 12px;
  font-size: 15px;
  font-weight: 700;
  color: #B2392A;
  text-align: center;
}

.best-line {
  margin-top: 12px;
  font-size: 15px;
  font-weight: 700;
  color: var(--teal-deep);
  text-align: center;
}

/* ============================ الأزرار ============================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 10px 22px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  line-height: 1.2;
  color: var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background-color .15s ease;
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 0 0 var(--ink); }
.btn:focus-visible { outline: 3px solid var(--purple); outline-offset: 3px; }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: 0 4px 0 rgba(34, 51, 63, .45); }

.btn--primary { background: var(--sun); color: var(--ink); }
.btn--teal { background: var(--teal); color: #08302C; }
.btn--purple { background: var(--purple); color: #fff; }
.btn--ghost { background: #fff; color: var(--ink); }

.btn--block { width: 100%; }
.btn--lg { min-height: 60px; font-size: 21px; }
.btn--sm { min-height: 46px; font-size: 16px; padding: 8px 18px; }

.icon-btn {
  width: 46px; height: 46px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 3px 0 var(--ink);
  cursor: pointer;
  transition: transform .1s ease, box-shadow .1s ease;
}
.icon-btn:active { transform: translateY(3px); box-shadow: none; }
.icon-btn svg { width: 22px; height: 22px; }

/* ============================ لوحة الاختبار ============================ */

.quiz-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.dots { display: flex; gap: 6px; flex-wrap: wrap; }

.dot {
  width: 15px; height: 15px;
  border-radius: 50%;
  border: 2.5px solid var(--ink);
  background: #fff;
  transition: background-color .25s ease, transform .25s ease;
}
.dot.is-current { background: var(--sun); transform: scale(1.2); }
.dot.is-correct { background: var(--green); }
.dot.is-wrong { background: var(--coral); }

.stats { display: flex; gap: 8px; }

.stat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  background: #fff;
  font-weight: 700;
  font-size: 15px;
}
.stat--ok { color: #2A7A42; }
.stat--bad { color: #B2392A; }

.q-counter {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.question-card { animation: cardIn .25s ease-out both; }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.shake { animation: shakeIt .36s ease-in-out; }
@keyframes shakeIt {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  45% { transform: translateX(6px); }
  70% { transform: translateX(-4px); }
  88% { transform: translateX(2px); }
}

.type-badge {
  display: inline-block;
  padding: 3px 15px;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  background: #FFE7A3;
  color: var(--ink);
}
.type-badge--syn { background: #E4D8F5; color: #463072; }

.q-prompt {
  font-size: 22px;
  font-weight: 700;
  margin: 12px 0 8px;
}

.word-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.word-chip {
  display: inline-block;
  padding: 2px 22px;
  background: var(--sun);
  border: 3px solid var(--ink);
  border-radius: 14px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(28px, 8vw, 36px);
  line-height: 1.4;
  box-shadow: 3px 3px 0 rgba(34, 51, 63, .16);
}

.options { display: flex; flex-direction: column; gap: 12px; }

.option {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 64px;
  padding: 10px 16px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: #fff;
  font-family: var(--font-body);
  font-size: 21px;
  font-weight: 700;
  text-align: start;
  color: var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  transition: transform .1s ease, background-color .16s ease, color .16s ease, opacity .2s ease;
}
.option:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 0 0 var(--ink); }
.option:focus-visible { outline: 3px solid var(--purple); outline-offset: 3px; }
.option:disabled { cursor: default; }

@media (hover: hover) {
  .option:not(:disabled):hover { background: #FFF7E4; }
}

.option.is-correct { background: var(--green); color: #fff; }
.option.is-wrong { background: var(--coral); color: #fff; }
.option.is-correct .opt-num,
.option.is-wrong .opt-num { background: #fff; border-color: #fff; color: var(--ink); }
.option.is-faded { opacity: .5; }

.opt-num {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  display: grid;
  place-items: center;
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
  font-size: 15px;
  font-weight: 700;
}
.opt-text { flex: 1; }

.hint-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.tag {
  display: inline-block;
  padding: 3px 11px;
  border: 2px solid var(--purple);
  border-radius: 999px;
  background: #EFE7F8;
  color: #5A3F80;
  font-size: 13px;
  font-weight: 700;
}

/* ============================ النتيجة ============================ */

.score-circle {
  position: relative;
  width: min(186px, 54vw);
  aspect-ratio: 1;
  margin: 10px auto 8px;
}
.circle-svg { width: 100%; height: 100%; display: block; }
.score-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
#score-pct {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 38px;
  line-height: 1;
}
.score-center small { font-size: 13px; color: var(--ink-soft); }

.result-line {
  text-align: center;
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 10px;
}

.cert-note {
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--purple);
  background: #F4EEFB;
  border: 2px dashed var(--purple);
  border-radius: 12px;
  padding: 8px 12px;
  margin-bottom: 6px;
}

.review-list { display: flex; flex-direction: column; gap: 12px; }

.review-item {
  border: 2.5px solid #E6D8BE;
  border-inline-start: 6px solid var(--coral);
  border-radius: 14px;
  background: #FFFCF3;
  padding: 12px 14px;
}
.review-q { font-weight: 700; font-size: 17px; margin-bottom: 6px; }
.review-ans { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 16px; margin-bottom: 6px; }
.tag-wrong { color: #B2392A; font-weight: 700; }
.tag-right { color: #2A7A42; font-weight: 700; }
.review-why { font-size: 15.5px; line-height: 1.65; color: #44555E; }
.review-hint { margin-top: 6px; }

.review-empty {
  text-align: center;
  padding: 18px 10px;
  border: 2.5px dashed var(--green);
  border-radius: 14px;
  background: #F3FAF4;
  color: #2A7A42;
  font-weight: 700;
}

.result-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 20px;
}
.result-actions .btn { flex: 1 1 150px; }

/* ============================ الشهادة ============================ */

.cert-shell { padding: 2px; }

.cert-card {
  background: #FFFDF6;
  border: 3px solid var(--ink);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 9px;
}

.cert-frame {
  border: 6px double var(--gold);
  border-radius: 12px;
  padding: 20px 14px 18px;
  text-align: center;
  background-image: repeating-linear-gradient(transparent 0 27px, rgba(234, 223, 200, .5) 27px 28px);
}

.cert-head { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.cert-org { font-size: 14px; color: var(--ink-soft); letter-spacing: 0; }
.cert-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(26px, 7.2vw, 40px);
  line-height: 1.2;
}
.cert-line { font-size: 15px; color: #44555E; margin-top: 14px; }
.cert-name {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(24px, 6.6vw, 36px);
  color: var(--teal-deep);
  padding: 0 22px 4px;
  border-bottom: 3px dotted var(--gold);
  margin: 6px 0 12px;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.cert-body { font-size: 16px; line-height: 1.75; margin-bottom: 10px; }
.cert-meta { font-size: 13.5px; color: var(--ink-soft); margin-bottom: 16px; }

.cert-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.sign { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.sign-name { font-family: var(--font-display); font-weight: 700; font-size: 19px; }
.sign-line { width: 118px; height: 2px; border-radius: 2px; background: var(--ink); opacity: .35; }
.sign-role { font-size: 13px; color: var(--ink-soft); }

.stamp {
  width: 88px; height: 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  border: 3px solid var(--teal);
  border-radius: 50%;
  color: var(--teal-deep);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  line-height: 1.15;
  transform: rotate(-9deg);
  box-shadow: inset 0 0 0 3px rgba(42, 167, 155, .22);
}
.stamp small { font-size: 10px; color: var(--purple); }

.cert-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}
.cert-actions .btn { flex: 1 1 140px; }

.cert-status {
  margin-top: 10px;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--teal-deep);
}

/* ============================ القصاصات ============================ */

#confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 60;
}

/* ============================ الشاشات الصغيرة ============================ */

@media (max-width: 420px) {
  .owl { width: 94px; height: 94px; }
  .owl--sm { width: 74px; height: 74px; }
  .owl--lg { width: 106px; height: 106px; }
  .bubble { font-size: 15px; padding: 10px 13px; }
  .app { padding: 14px 12px 36px; }
  .card { padding: 16px 13px; }
  .q-prompt { font-size: 20px; }
  .option { font-size: 19px; gap: 11px; }
  .stat { font-size: 14px; padding: 3px 10px; }
  .dot { width: 13px; height: 13px; }
}

/* ============================ الطباعة ============================ */

@media print {
  @page { margin: 10mm; }
  body {
    background: #fff !important;
    background-image: none !important;
  }
  .app { padding: 0; max-width: none; }
  .app > .screen { display: none !important; }
  #screen-cert { display: block !important; }
  .no-print, #confetti, .cert-status { display: none !important; }
  .cert-card {
    box-shadow: none !important;
    border-radius: 0;
    padding: 0;
    border: none;
  }
  .cert-frame { padding: 14px 12px; }
  .cert-title { font-size: 30px; }
  .cert-name { font-size: 26px; }
  .cert-body { font-size: 14px; }
  .stamp { width: 74px; height: 74px; }
}

/* ============================ تقليل الحركة ============================ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .owl .lid { animation: none; transform: scaleY(0); }
}