/* =========================================================
   EnglishBac4U.ma — English Level Placement Test
   Matches the site identity: Moroccan blue / red / green,
   zellige dividers, soft cards.
   ========================================================= */

:root {
  --primary: #1E3A8A;
  --primary-dark: #172F70;
  --primary-soft: #EEF2FB;
  --accent-blue: #2563EB;
  --moroccan-red: #C1272D;
  --moroccan-green: #006233;
  --muted: #64748B;
  --border: #E5E7EB;
  --card: #FFFFFF;
  --background: #F8FAFC;
  --foreground: #0F172A;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--foreground);
  background: var(--background);
  line-height: 1.6;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }

.container {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.hidden { display: none !important; }

a:focus-visible, button:focus-visible {
  outline: 3px solid var(--accent-blue);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Zellige divider ---------- */
.zellige-divider {
  height: 5px;
  background:
    repeating-linear-gradient(90deg, var(--moroccan-red) 0 14px, transparent 14px 22px),
    repeating-linear-gradient(90deg, transparent 0 22px, var(--moroccan-green) 22px 36px);
  background-size: 36px 5px;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 25px;
}

.logo { display: flex; align-items: center; flex-shrink: 0; }
.logo img { width: auto; height: 52px; max-width: 230px; object-fit: contain; }
.logo-text { font-weight: 800; font-size: 1.05rem; color: var(--primary); }

.main-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }

.main-nav a {
  color: #475569;
  font-size: .92rem;
  font-weight: 600;
  padding: 10px 13px;
  border-radius: 8px;
  transition: .2s ease;
}
.main-nav a:hover { background: #F1F5F9; color: var(--primary); }
.main-nav a.active { color: var(--primary); background: var(--primary-soft); }

.header-button {
  background: var(--primary);
  color: #fff;
  padding: 10px 17px;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 700;
  white-space: nowrap;
}
.header-button:hover { background: var(--primary-dark); }

@media (max-width: 980px) {
  .main-nav, .header-button { display: none; }
}

/* ---------- Page hero + progress ---------- */
.page-hero {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  padding: 44px 0 30px;
}

.kicker {
  display: inline-block;
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.25);
  padding: 5px 11px;
  border-radius: 999px;
}

.page-hero h1 { margin: 14px 0 6px; font-size: clamp(1.6rem, 4vw, 2.3rem); line-height: 1.2; }
.page-hero p { margin: 0; color: #D6E0F5; font-size: .95rem; }

.hero-meta {
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.badge {
  background: #fff;
  color: var(--primary);
  font-weight: 800;
  font-size: .85rem;
  padding: 5px 12px;
  border-radius: 999px;
}

.progress-text { font-size: .85rem; color: #D6E0F5; font-weight: 600; }

.bar {
  margin-top: 10px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,.22);
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--moroccan-green), #34D399);
  transition: width .35s ease;
}

/* ---------- Layout ---------- */
.wrap { padding: 32px 0 60px; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 26px;
  margin-bottom: 20px;
  box-shadow: 0 10px 30px rgba(15,23,42,.05);
}

.card h1, .card h2 { margin: 0 0 12px; font-size: 1.25rem; color: var(--primary); }
.card h3 { margin: 22px 0 10px; font-size: 1rem; color: var(--foreground); }
.card p { margin: 0 0 12px; }

.muted { color: var(--muted); font-size: .92rem; }
.card ul.muted { padding-left: 20px; }
.card ul.muted li { margin: 6px 0; }

.tag {
  display: inline-block;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 999px;
  margin-bottom: 14px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .7rem 1.35rem;
  border-radius: 10px;
  font-weight: 700;
  font-size: .92rem;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: background-color .2s, opacity .2s;
}
.btn-primary, .btn { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Question ---------- */
#passageBox { margin-bottom: 16px; }

#passageBox .passage {
  background: #F5F8FE;
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  padding: 16px 18px;
  font-size: .95rem;
  color: #1E293B;
  white-space: pre-line;
}

.qtext { font-size: 1.1rem; font-weight: 600; margin-bottom: 18px; }

.opts { display: grid; gap: 10px; }

.opt, .option {
  text-align: left;
  width: 100%;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: .97rem;
  font-family: inherit;
  color: var(--foreground);
  cursor: pointer;
  transition: .18s ease;
}
.opt:hover:not(:disabled), .option:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-soft); }
.opt:disabled, .option:disabled { cursor: default; }
.opt.good, .option.correct { border-color: var(--moroccan-green); background: #ECFDF5; color: #065F46; font-weight: 600; }
.opt.bad, .option.wrong { border-color: var(--moroccan-red); background: #FEF2F2; color: #991B1B; font-weight: 600; }

.explain {
  margin-top: 16px;
  border-radius: 10px;
  padding: 14px 16px;
  background: #FFFBEB;
  border-left: 4px solid #F59E0B;
  font-size: .92rem;
  color: #78350F;
}

/* ---------- Foot bar ---------- */
.footbar {
  position: sticky;
  bottom: 0;
  background: rgba(255,255,255,.97);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 18px;
  box-shadow: 0 -6px 24px rgba(15,23,42,.06);
}

.timer-track {
  height: 6px;
  border-radius: 999px;
  background: #E2E8F0;
  overflow: hidden;
}
.timer-track > i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--accent-blue);
  transition: width .95s linear, background-color .3s;
}
.timer-track.low > i { background: var(--moroccan-red); }

.foot-row {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: .88rem;
  color: var(--muted);
}
.foot-row strong { color: var(--foreground); }
.foot-row .btn { margin-left: auto; }

/* ---------- Results ---------- */
.level-hero {
  background: linear-gradient(135deg, var(--primary) 0%, #2563EB 100%);
  color: #fff;
  border-radius: 18px;
  padding: 32px 26px;
  text-align: center;
  margin-bottom: 20px;
}
.level-hero-label { font-size: .85rem; color: #DBEAF7; font-weight: 600; }
.level-hero .lv { font-size: clamp(2.6rem, 9vw, 4rem); font-weight: 900; line-height: 1.05; }
.level-hero .eq { font-size: .98rem; color: #DBEAF7; }

.grid2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.stat {
  background: #F8FAFC;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}
.stat b { display: block; font-size: 1.5rem; color: var(--primary); }
.stat span { font-size: .8rem; }

.skill { margin-bottom: 14px; }
.skill .lbl {
  display: flex;
  justify-content: space-between;
  font-size: .9rem;
  font-weight: 600;
  margin-bottom: 6px;
}
.skill .meter {
  height: 9px;
  border-radius: 999px;
  background: #E2E8F0;
  overflow: hidden;
}
.skill .meter > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent-blue));
}

.weak-item, .rec-item {
  border: 1px solid var(--border);
  border-left: 4px solid var(--moroccan-red);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: #FEFEFE;
  font-size: .93rem;
}
.rec-item { border-left-color: var(--moroccan-green); }

.links { display: flex; flex-wrap: wrap; gap: 10px; }
.links a {
  border: 1px solid var(--primary);
  color: var(--primary);
  background: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: .9rem;
}
.links a:hover { background: var(--primary-soft); }

/* ---------- Footer ---------- */
footer { background: #0F172A; color: #fff; }

.footer-main {
  padding: 50px 0;
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 40px;
}

.footer-logo { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.footer-logo img { height: 42px; width: auto; }

.footer-description {
  max-width: 330px;
  margin-top: 14px;
  color: #CBD5E1;
  font-size: .88rem;
  line-height: 1.7;
}

footer h4 { margin: 0 0 15px; font-size: .95rem; }
footer ul { list-style: none; padding: 0; margin: 0; }
footer li { margin: 9px 0; }
footer a { color: #CBD5E1; font-size: .87rem; }
footer a:hover { color: #fff; }

.footer-bottom {
  border-top: 1px solid #1E293B;
  padding: 18px 0;
  font-size: .82rem;
  color: #94A3B8;
}

@media (max-width: 860px) {
  .footer-main { grid-template-columns: 1fr 1fr; gap: 28px; }
}
@media (max-width: 520px) {
  .footer-main { grid-template-columns: 1fr; }
  .card { padding: 20px; }
}

/* ---------- Result lists ---------- */
#rWeak ul, #rRecs ul { margin: 0; padding-left: 20px; }
#rWeak li, #rRecs li { margin: 8px 0; font-size: .93rem; }
#rWeak li { color: #991B1B; }

/* Embedded (in-page) test: progress row on light backgrounds */
.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.progress-head .badge {
  background: var(--primary);
  color: #fff;
}
.progress-head .progress-text { color: var(--primary); }
.progress-head + .bar {
  margin-top: 0;
  margin-bottom: 16px;
  background: rgba(30, 58, 138, .14);
}

/* ---------- Embedded homepage widget (index.html #level-test) ---------- */
/* Classes used by the inline script on the homepage that the standalone
   leveltest page never needed. */

.test-wrap { display: block; }

.question-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.question-level {
  display: inline-block;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 800;
  font-size: .78rem;
  padding: 4px 10px;
  border-radius: 999px;
}

/* Skill bars on the results screen (skillsBox) */
.skill-row { margin-bottom: 14px; }
.skill-head {
  display: flex;
  justify-content: space-between;
  font-size: .9rem;
  font-weight: 600;
  margin-bottom: 6px;
}
.track {
  height: 9px;
  border-radius: 999px;
  background: #E2E8F0;
  overflow: hidden;
}
.track > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent-blue));
}

/* Secondary "Take the test again" button */
.secondary-btn {
  background: #fff;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.secondary-btn:hover:not(:disabled) {
  background: var(--primary-soft);
}
