/* ============================================================
   Excel Training — same layout as trainings/word-training,
   Excel green identity + feedback, progress dots and review.
   ============================================================ */
:root{
  --ink: #17301F;
  --ink-soft: #5C7266;
  --card-bg: #FFFFFF;
  --accent: #1D7044;
  --accent-dark: #135232;
  --accent-soft: #E2F2E8;
  --green: #1E8A50;
  --green-soft: #E3F7EB;
  --red: #C0392B;
  --red-soft: #FDECEC;
  --amber: #C97D0E;
  --line: rgba(23,48,31,.10);
  --grid: rgba(29,112,68,.07);
  --radius: 20px;
  --shadow: 0 16px 34px rgba(17,46,29,.10);
  --font-ar: 'Tajawal', sans-serif;
}

*{ box-sizing: border-box; }
html, body{ margin:0; min-height: 100%; }
html{ background: #DCEDE2; }

body{
  /* soft green gradient + a faint spreadsheet grid */
  background:
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 100% 28px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 96px 100%,
    linear-gradient(160deg, #EEF7F1 0%, #CFE6D8 100%);
  color: var(--ink);
  font-family: var(--font-ar);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}
html[lang="en"] body, html[lang="fr"] body{ font-family: 'Inter', var(--font-ar); }

a{ color: inherit; text-decoration: none; }
.hidden{ display: none !important; }

/* ---------------- Top bar (fixed LTR order) ---------------- */

.tb{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  max-width: 1200px;
  margin: 0 auto;
}
.tb-logo{ display: flex; align-items: center; flex: none; }
.tb-logo img{
  width: 42px; height: 42px; border-radius: 50%; display: block;
  box-shadow: 0 0 0 2px rgba(255,255,255,.85), 0 4px 10px rgba(17,46,29,.18);
}
.icon-btn{
  width: 42px; height: 42px; flex: none;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card-bg);
  color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(17,46,29,.08);
}
.icon-btn svg{ width: 19px; height: 19px; }
.tb-title{
  font-family: var(--font-ar);
  font-size: 1.05rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 0 1 auto;
}
.tb-fill{ flex: 1; min-width: 0; }
/* the shared "Contact us" button (site-nav.js) lands here: fixed width so its label length never shifts it */
.tb .mrb-contact{ width: 156px; }

.lang-switch{
  display: flex;
  gap: 4px;
  flex: none;
  background: var(--card-bg);
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(17,46,29,.08);
}
.lang-btn{
  width: 52px; /* fixed width: switching language never moves anything */
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--font-ar);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 0;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.lang-btn:hover{ color: var(--ink); }
.lang-btn.active{ background: var(--accent); color: #fff; }

/* ---------------- Layout ---------------- */

.wrap{
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 32px 60px;
}
.screen{ text-align: center; }

.page-title{
  font-size: clamp(2rem, 4.5vw, 2.8rem);
  font-weight: 900;
  margin: 20px 0 14px;
}
.page-sub{
  font-size: 1.05rem;
  color: var(--ink-soft);
  margin: 0 0 50px;
}
.formula-note{
  max-width: 640px;
  margin: 44px auto 0;
  font-size: .85rem;
  color: var(--ink-soft);
  background: rgba(255,255,255,.65);
  border: 1px dashed rgba(29,112,68,.35);
  border-radius: 14px;
  padding: 10px 16px;
}
.formula-note:empty{ display: none; }

/* inline formulas / keys ({{ }} in questions.js) */
.f{
  display: inline-block;
  direction: ltr;
  unicode-bidi: isolate;
  font-family: 'Consolas', 'Menlo', 'Courier New', monospace;
  font-weight: 700;
  font-size: .9em;
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 1px 8px;
  border-radius: 7px;
  max-width: 100%;
  overflow-wrap: anywhere; /* long formulas break only when they do not fit */
}

/* ---------------- Level select ---------------- */

.levels-grid{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 28px;
  max-width: 950px;
  margin: 0 auto;
}
.level-card{
  position: relative;
  cursor: pointer;
  padding: 10px 10px 6px;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  transition: transform .22s cubic-bezier(.2,.8,.3,1.4);
}
.level-card:hover, .level-card:focus-visible{ transform: translateY(-8px) scale(1.06); outline: none; }
.level-card.locked{ opacity: .6; }
.level-card.locked:hover{ transform: translateY(-3px) scale(1.02); }
.level-lock{
  position: absolute;
  top: -6px;
  inset-inline-end: 6px;
  font-size: 1.4rem;
  z-index: 2;
}
.level-num{
  display: flex;
  align-items: center;
  justify-content: center;
  width: 108px;
  height: 108px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #fff;
  font-size: 2.6rem;
  font-weight: 900;
  font-family: 'Inter', sans-serif;
  box-shadow: 0 16px 34px rgba(19,82,50,.28);
}
.level-card.passed .level-num{ box-shadow: 0 0 0 5px #fff, 0 0 0 8px var(--green), 0 16px 34px rgba(19,82,50,.28); }
.level-card.locked .level-num{
  background: linear-gradient(135deg, #9DB0A4 0%, #6C7E73 100%);
  box-shadow: 0 12px 26px rgba(17,46,29,.18);
}
.level-label{ font-size: 1.15rem; font-weight: 800; margin: 0 0 4px; }
.level-topics{ font-size: .8rem; color: var(--ink-soft); margin: 0 0 6px; line-height: 1.45; min-height: 2.3em; }
.level-meta{ font-size: .85rem; color: var(--ink-soft); margin: 0; font-weight: 600; }
.level-best{ font-size: .85rem; color: var(--green); font-weight: 700; margin: 8px 0 0; }
.level-locked-text{ font-size: .8rem; color: var(--ink-soft); margin: 8px 0 0; }

/* ---------------- Quiz screen ---------------- */

.quiz-head{ text-align: center; margin-bottom: 26px; }

.quiz-meta{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-bottom: 12px;
}
.meta-chip{
  min-width: 92px;
  font-size: .85rem;
  font-weight: 800;
  color: var(--accent-dark);
  background: rgba(255,255,255,.8);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
}
.meta-score{ color: var(--green); }

.timer-display{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.timer-emoji{ font-size: 2.2rem; line-height: 1; }
.timer-display #timerText{
  font-family: 'Inter', sans-serif;
  font-size: clamp(2.6rem, 7vw, 3.6rem);
  font-weight: 900;
  color: var(--accent-dark);
  direction: ltr;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
  transition: color .2s ease;
}
.timer-display.urgent #timerText{
  color: var(--red);
  animation: pulse-urgent .5s ease infinite;
}
.timer-display.paused #timerText{ color: var(--ink-soft); }
@keyframes pulse-urgent{
  0%, 100%{ transform: scale(1); }
  50%{ transform: scale(1.06); }
}

.time-track{
  max-width: 480px;
  height: 6px;
  margin: 0 auto 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.7);
  overflow: hidden;
}
.time-fill{
  height: 100%;
  width: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 1s linear, background .2s ease;
}
.time-fill.urgent{ background: var(--red); }

.progress-dots{
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  max-width: 520px;
  margin: 0 auto 8px;
}
.progress-dots span{
  width: 12px; height: 12px;
  border-radius: 50%;
  background: rgba(255,255,255,.85);
  border: 1px solid rgba(29,112,68,.25);
  transition: background .2s ease, transform .2s ease;
}
.progress-dots span.ok{ background: var(--green); border-color: var(--green); }
.progress-dots span.ko{ background: var(--red); border-color: var(--red); }
.progress-dots span.cur{ transform: scale(1.35); border: 2px solid var(--accent-dark); }

.progress-label{
  font-size: .95rem;
  font-weight: 700;
  color: var(--ink-soft);
  margin: 0;
}

.question-card{
  padding: 10px 40px 20px;
  max-width: 920px;
  margin: 0 auto;
}
.question-text{
  font-size: clamp(1.35rem, 3.2vw, 1.9rem);
  font-weight: 900;
  margin: 0 0 30px;
  line-height: 1.7;
}

.options-grid{
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}
.option-btn{
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 76px;
  border: 1px solid var(--line);
  border-bottom: 3px solid #C3D3C9;
  background: linear-gradient(180deg, #FFFFFF 0%, #F0F6F2 100%);
  color: var(--ink);
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.5;
  border-radius: 18px;
  padding: 16px 20px 16px 44px;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(17,46,29,.10), inset 0 1px 0 rgba(255,255,255,.8);
  transition: transform .18s cubic-bezier(.2,.8,.3,1.4), box-shadow .18s ease, border-color .18s ease, background .18s ease, opacity .18s ease;
}
html[dir="rtl"] .option-btn{ padding: 16px 44px 16px 20px; }
.option-key{
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  inset-inline-start: 14px;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 6px;
  font-family: 'Inter', sans-serif;
  font-size: .72rem;
  font-weight: 800;
  color: var(--ink-soft);
  background: var(--accent-soft);
}
.option-btn:hover:not(:disabled){
  transform: translateY(-5px) scale(1.03);
  border-color: var(--accent);
  background: linear-gradient(180deg, #FFFFFF 0%, var(--accent-soft) 100%);
  box-shadow: 0 16px 30px rgba(17,46,29,.16), inset 0 1px 0 rgba(255,255,255,.9);
}
.option-btn:active:not(:disabled){ transform: translateY(-1px) scale(1.01); }
.option-btn:disabled{ cursor: default; }
.option-btn.dim{ opacity: .5; }
.option-btn.correct{
  background: linear-gradient(180deg, #F2FCF6 0%, var(--green-soft) 100%);
  border-color: var(--green);
  border-bottom-color: var(--green);
  color: var(--green);
  opacity: 1;
  transform: scale(1.03);
  box-shadow: 0 12px 24px rgba(30,138,80,.22), inset 0 1px 0 rgba(255,255,255,.8);
}
.option-btn.wrong{
  background: linear-gradient(180deg, #FDF2F0 0%, var(--red-soft) 100%);
  border-color: var(--red);
  border-bottom-color: var(--red);
  color: var(--red);
  opacity: 1;
  box-shadow: 0 8px 18px rgba(192,57,43,.18), inset 0 1px 0 rgba(255,255,255,.8);
}
.option-btn.correct .option-key{ background: var(--green); color: #fff; }
.option-btn.wrong .option-key{ background: var(--red); color: #fff; }

/* ---------------- Feedback after each answer ---------------- */

.feedback{
  margin: 26px auto 0;
  max-width: 720px;
  background: var(--card-bg);
  border-radius: 18px;
  border-inline-start: 6px solid var(--green);
  box-shadow: var(--shadow);
  padding: 18px 22px 20px;
  text-align: start;
  animation: fb-in .25s ease;
}
.feedback.is-wrong{ border-inline-start-color: var(--red); }
@keyframes fb-in{ from{ opacity: 0; transform: translateY(8px); } to{ opacity: 1; transform: none; } }
.fb-status{ margin: 0 0 4px; font-size: 1.1rem; font-weight: 900; color: var(--green); }
.feedback.is-wrong .fb-status{ color: var(--red); }
.fb-answer{ margin: 0 0 8px; font-weight: 700; }
.fb-answer:empty{ display: none; }
.fb-exp{ margin: 0 0 16px; color: var(--ink-soft); font-size: .95rem; line-height: 1.75; }
.fb-next{ min-width: 160px; }

.quit-btn{
  margin-top: 22px;
  border: none;
  background: none;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: .85rem;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

/* ---------------- Result screen ---------------- */

.result-card{
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 30px;
  max-width: 460px;
  margin: 20px auto 0;
}
.result-emoji{ font-size: 3.4rem; margin-bottom: 10px; }
.result-title{ font-size: 1.4rem; font-weight: 900; margin: 0 0 8px; }
.result-msg{ font-size: .92rem; color: var(--ink-soft); margin: 0 0 22px; }
.result-pct{
  font-size: 3rem;
  font-weight: 900;
  color: var(--accent-dark);
  font-family: 'Inter', sans-serif;
}
.result-score{ font-size: .92rem; color: var(--ink-soft); margin: 4px 0 18px; }
.cert-hint{
  font-size: .82rem;
  color: var(--amber);
  background: #FFF6E6;
  border-radius: 12px;
  padding: 8px 12px;
  margin: 0 0 16px;
  line-height: 1.6;
}

.btn-cert{
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  background: linear-gradient(135deg, #EF9F27 0%, #C97D0E 100%);
  color: #fff;
  border: none; border-radius: 999px;
  font-family: inherit; font-size: .92rem; font-weight: 800;
  padding: 13px 20px; cursor: pointer; margin-bottom: 16px;
  box-shadow: 0 10px 22px rgba(201,125,14,.3);
  transition: transform .15s ease;
}
.btn-cert:hover{ transform: translateY(-2px); }
.btn-cert svg{ width: 19px; height: 19px; }

.result-actions{
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 22px;
}
.btn{
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-size: .95rem;
  font-weight: 800;
  padding: 14px 20px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn-block{ width: 100%; }
.btn svg{ width: 18px; height: 18px; flex: none; }
.cert-preview-actions .btn{ display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-primary{
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #fff;
  box-shadow: 0 12px 26px rgba(19,82,50,.28);
}
.btn-primary:hover{ transform: translateY(-2px); }
.btn-secondary{
  background: var(--card-bg);
  border: 1px solid var(--line);
  color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-secondary:hover{ background: var(--accent-soft); }
.btn-secondary svg{ width: 18px; height: 18px; }

.share-row{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.share-label{ font-size: .82rem; color: var(--ink-soft); font-weight: 600; }
.share-btn{
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card-bg);
  color: var(--ink);
  transition: background .15s ease, transform .15s ease;
}
#shareWhatsapp{ color: #1FA855; }
#shareTelegram{ color: #229ED9; }
.share-btn:hover{ background: var(--accent-soft); transform: translateY(-2px); }
.share-btn svg{ width: 18px; height: 18px; }

/* ---------------- Review of wrong answers ---------------- */

.review-box{
  max-width: 760px;
  margin: 26px auto 0;
  text-align: start;
}
.review-title{ font-size: 1.15rem; font-weight: 900; margin: 0 0 14px; text-align: center; }
.review-list{ list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.review-item{
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: 0 8px 20px rgba(17,46,29,.08);
  padding: 16px 18px;
  border-inline-start: 5px solid var(--red);
}
.review-q{ font-weight: 800; margin: 0 0 8px; line-height: 1.7; }
.review-row{ margin: 0 0 4px; font-size: .92rem; }
.review-row b{ font-weight: 800; }
.review-row.yours{ color: var(--red); }
.review-row.right{ color: var(--green); }
.review-exp{ margin: 8px 0 0; font-size: .88rem; color: var(--ink-soft); line-height: 1.7; }

/* ---------------- Locked screen ---------------- */

.locked-card{
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 44px 30px;
  max-width: 440px;
  margin: 30px auto 0;
}
.locked-icon{ font-size: 3rem; margin-bottom: 14px; }
.locked-title{ font-size: 1.25rem; font-weight: 900; margin: 0 0 10px; }
.locked-msg{ font-size: .9rem; color: var(--ink-soft); margin: 0 0 26px; line-height: 1.7; }

/* ---------------- Overlays (certificate) ---------------- */

.overlay{
  position: fixed; inset: 0; background: rgba(14,32,22,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.overlay-box{
  background: var(--card-bg); border-radius: 22px; padding: 28px 26px;
  max-width: 400px; width: 100%; box-shadow: 0 30px 70px rgba(8,24,15,.35);
  text-align: center;
  max-height: 92vh; overflow-y: auto;
}
.overlay-box-wide{ max-width: 640px; }
.overlay-title{ font-size: 1.2rem; font-weight: 900; margin: 0 0 8px; }
.overlay-hint{ font-size: .82rem; color: var(--ink-soft); margin: 0 0 20px; line-height: 1.6; }
.overlay-actions{ margin-top: 6px; }

.cert-input{
  width: 100%; border: 1px solid #C9D6CE; background: var(--card-bg);
  border-radius: 12px; padding: 12px 14px; font-size: .92rem; color: var(--ink);
  font-family: inherit; outline: none; margin-bottom: 12px;
}
.cert-input:focus{ border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cert-input.invalid{ border-color: var(--red); }

.cert-lang-row{ display: flex; gap: 8px; margin-bottom: 18px; }
.cert-lang-btn{
  flex: 1; border: 1px solid var(--line); background: var(--card-bg);
  border-radius: 999px; padding: 10px; font-family: inherit; font-size: .85rem;
  font-weight: 700; color: var(--ink-soft); cursor: pointer;
}
.cert-lang-btn.active{ background: var(--accent); border-color: var(--accent); color: #fff; }

.cert-preview-wrap{
  border-radius: 12px; overflow: hidden; margin-bottom: 18px;
  max-height: 62vh; overflow-y: auto; background: var(--accent-soft);
}
.cert-preview-wrap img{ width: 100%; display: block; }
.cert-preview-actions{ display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.cert-preview-actions .btn{ flex: 1; min-width: 120px; }

/* ---------------- Footer ---------------- */

.site-footer{
  text-align: center;
  padding: 20px;
  font-size: .82rem;
  color: var(--ink-soft);
}

/* ---------------- Responsive (mobile) ---------------- */

@media (max-width: 640px){
  .tb{ padding: 12px 16px; gap: 8px; }
  .tb-logo img{ width: 38px; height: 38px; }
  .icon-btn{ width: 38px; height: 38px; }
  .tb-title{ display: none; }
  .lang-btn{ width: 42px; font-size: 12px; padding: 7px 0; }

  .wrap{ padding: 8px 16px 40px; }
  .page-title{ font-size: 1.6rem; }
  .page-sub{ font-size: .85rem; margin-bottom: 30px; }

  .levels-grid{ grid-template-columns: repeat(2, 1fr); gap: 18px; }
  .level-num{ width: 78px; height: 78px; font-size: 1.9rem; }
  .level-label{ font-size: 1rem; }
  .level-topics{ font-size: .74rem; }

  .quiz-meta{ gap: 8px; }
  .meta-chip{ min-width: 0; font-size: .75rem; padding: 5px 9px; }
  .timer-emoji{ font-size: 1.6rem; }
  .timer-display #timerText{ font-size: 2.3rem; }
  .progress-dots span{ width: 9px; height: 9px; }
  .question-card{ padding: 6px 0 16px; }
  .question-text{ font-size: 1.15rem; margin-bottom: 20px; }
  .options-grid{ grid-template-columns: 1fr; gap: 12px; }
  .option-btn{ min-height: 58px; font-size: .98rem; }
  .feedback{ padding: 16px; }
  .fb-next{ width: 100%; }

  .result-card, .locked-card{ padding: 32px 20px; }
  .result-pct{ font-size: 2.4rem; }
}
@media (max-width: 380px){
  .lang-btn{ width: 36px; }
}
