:root {
  --paper: #f7f3ea;
  --surface: #fffdf8;
  --ink: #1c2b28;
  --muted: #5a6661;
  --line: #ddd5c4;
  --gold: #e2b866;
  --danger: #a32a22;
  --accent: #1f6f5c;
  --serif: 'Amiri', 'Traditional Arabic', 'Sakkal Majalla', Georgia, serif;
  --sans: 'IBM Plex Sans Arabic', 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --arabic: 'Amiri', 'Traditional Arabic', 'Sakkal Majalla', 'Times New Roman', serif;
}

[data-color='terracotta'] { --accent: #b4472a; }
[data-color='pine'] { --accent: #1f6f5c; }
[data-color='indigo'] { --accent: #3b4fa8; }
[data-color='plum'] { --accent: #7a3b78; }
[data-color='ochre'] { --accent: #8a6414; }
[data-color='slate'] { --accent: #3f5566; }

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.6 var(--sans);
}

main { flex: 1; width: 100%; }

h1, h2, h3 { font-family: var(--serif); font-weight: 650; line-height: 1.2; margin: 0; }

a { color: inherit; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.empty { color: var(--muted); }

/* ---------- Memorial banner ---------- */

.memorial {
  background: var(--ink);
  color: var(--paper);
  border-bottom: 3px solid var(--gold);
  padding: 1.1rem 1.25rem;
  text-align: center;
  font-family: var(--arabic);
}

.memorial p { margin: 0; font-size: clamp(1.35rem, 3.6vw, 1.9rem); line-height: 1.7; }

.memorial strong { color: var(--gold); font-weight: 700; }

.memorial .dua {
  margin-top: 0.55rem;
  font-size: clamp(1.05rem, 2.6vw, 1.4rem);
  line-height: 1.95;
  color: rgba(247, 243, 234, 0.92);
}

/* ---------- Header and footer ---------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  max-width: 68rem;
  width: 100%;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
}

.admin .site-header { max-width: 76rem; }

.brand { font: 650 1.15rem var(--serif); text-decoration: none; }

.header-actions { display: flex; gap: 0.5rem; }

.site-footer {
  max-width: 68rem;
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 2rem;
  font-size: 0.9rem;
  color: var(--muted);
  display: flex;
  gap: 1.5rem;
}

/* ---------- Home ---------- */

.hero { max-width: 68rem; margin: 0 auto; padding: 2.5rem 1.5rem 2.25rem; }

.hero h1 { font-size: clamp(2rem, 5.5vw, 3.4rem); max-width: 18em; font-weight: 700; line-height: 1.5; }

.hero p { font-size: 1.15rem; color: var(--muted); margin: 1rem 0 0; max-width: 34em; }

.track-grid {
  max-width: 68rem;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  gap: 1.25rem;
}

.track-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 5px solid var(--accent);
  border-radius: 6px;
  text-decoration: none;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.track-card:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgb(28 43 40 / 0.1); }

.track-card h2 { font-size: 1.7rem; color: var(--accent); }

.track-tagline { margin: 0; flex: 1; }

.track-meta { margin: 0; font-size: 0.9rem; color: var(--muted); }

.mini-route {
  list-style: none;
  display: flex;
  margin: 0.5rem 0 0;
  padding: 0;
}

.mini-route li {
  display: grid;
  place-items: center;
  width: 1.7rem;
  height: 1.7rem;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
}

.mini-route li + li { margin-inline-start: 0.85rem; position: relative; }

.mini-route li + li::before {
  content: '';
  position: absolute;
  inset-inline-end: 100%;
  width: 0.85rem;
  height: 2px;
  background: var(--accent);
}

/* ---------- Roadmap page ---------- */

.track-hero { max-width: 48rem; margin: 0 auto; padding: 2rem 1.5rem 1rem; }

.track-hero h1 { font-size: clamp(2.2rem, 6vw, 3.2rem); font-weight: 500; color: var(--accent); }

.track-hero p { font-size: 1.1rem; margin: 1rem 0 0; }

.track-hero .track-meta { font-size: 0.95rem; }

.route { list-style: none; max-width: 48rem; margin: 0 auto; padding: 1.5rem 1.5rem 0; }

.stage { display: grid; grid-template-columns: 2.75rem 1fr; gap: 1.25rem; position: relative; padding-bottom: 2.75rem; }

.stage:not(:last-child)::before {
  content: '';
  position: absolute;
  top: 0.5rem;
  bottom: -0.5rem;
  inset-inline-start: calc(1.375rem - 2px);
  width: 4px;
  background: var(--accent);
  opacity: 0.3;
}

.stage-marker {
  position: relative;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font: 650 1.1rem var(--serif);
}

.stage-body { min-width: 0; padding-top: 0.35rem; }

.stage-body h2 { font-size: 1.55rem; }

.stage-summary { margin: 0.6rem 0 0; color: var(--muted); }

.resource-list { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: 0.5rem; }

.resource {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.8rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  text-decoration: none;
  transition: border-color 150ms ease;
}

.resource:hover { border-color: var(--accent); }

.resource:hover .resource-title { color: var(--accent); }

.resource-type {
  flex: none;
  width: 5rem;
  padding-top: 0.15rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
}

.resource-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.resource-title { font-weight: 600; overflow-wrap: anywhere; }

.resource-note { margin: 0; font-size: 0.92rem; color: var(--muted); }

.resource-paid {
  flex: none;
  margin-inline-start: 0.5rem;
  padding: 0 0.45rem;
  border: 1px solid var(--muted);
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
}

.resource-arrow { flex: none; color: var(--accent); }

@media (max-width: 34rem) {
  .stage { grid-template-columns: 2.25rem 1fr; gap: 0.85rem; }
  .stage-marker { width: 2.25rem; height: 2.25rem; font-size: 0.95rem; }
  .stage:not(:last-child)::before { inset-inline-start: calc(1.125rem - 2px); }
  .resource { flex-wrap: wrap; gap: 0.25rem 0.75rem; }
  .resource-type { width: auto; }
  .resource-body { order: 3; flex-basis: 100%; }
  .resource-arrow { margin-inline-start: auto; }
}

/* ---------- Buttons and forms ---------- */

.btn {
  padding: 0.5rem 0.9rem;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--muted);
  border-radius: 5px;
  font: 500 0.95rem var(--sans);
  cursor: pointer;
}

.btn:hover:not(:disabled) { background: #efe9db; }

.btn:disabled { opacity: 0.5; cursor: default; }

.btn-small { padding: 0.25rem 0.6rem; font-size: 0.85rem; }

.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.btn-primary:hover:not(:disabled) { background: #30443f; }

.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }

.btn-danger:hover:not(:disabled) { background: #861f18; }

.btn-quiet-danger { color: var(--danger); border-color: var(--line); }

.btn-add { border-style: dashed; }

.icon-btn {
  width: 1.85rem;
  height: 1.85rem;
  padding: 0;
  background: none;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink);
  font-size: 0.9rem;
  cursor: pointer;
}

.icon-btn:hover:not(:disabled) { background: #efe9db; }

.icon-btn:disabled { opacity: 0.35; cursor: default; }

.field { display: flex; flex-direction: column; gap: 0.3rem; margin-top: 1rem; }

.field label { font-weight: 500; font-size: 0.92rem; }

.field input, .field select, .field textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--muted);
  border-radius: 5px;
  font: inherit;
}

.field textarea { resize: vertical; }

.field-check { display: flex; align-items: center; gap: 0.5rem; margin-top: 1rem; font-size: 0.95rem; }

.form-error { margin: 1rem 0 0; color: var(--danger); font-weight: 500; }

/* ---------- Dialog and toast ---------- */

dialog {
  width: min(32rem, calc(100vw - 2rem));
  padding: 1.5rem;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
}

dialog::backdrop { background: rgb(28 43 40 / 0.5); }

dialog h2 { font-size: 1.35rem; overflow-wrap: anywhere; }

.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.5rem; }

.toast {
  position: fixed;
  inset-block-end: 1.25rem;
  inset-inline-start: 50%;
  translate: -50% 0;
  padding: 0.6rem 1.1rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: 5px;
  z-index: 10;
}

/* ---------- Admin ---------- */

.login {
  max-width: 24rem;
  margin: 3rem auto;
  padding: 1.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.login h1 { font-size: 1.6rem; }

.login .btn { width: 100%; margin-top: 1.25rem; }

.dashboard {
  max-width: 76rem;
  margin: 0 auto;
  padding: 0.5rem 1.5rem 3rem;
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
}

.track-nav h1 { font-size: 1.3rem; margin-bottom: 0.75rem; }

.track-nav ul { list-style: none; margin: 0 0 0.75rem; padding: 0; display: grid; gap: 0.35rem; }

.track-nav .btn { width: 100%; }

.track-nav-item {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: none;
  border: 1px solid transparent;
  border-inline-start: 4px solid var(--accent);
  border-radius: 4px;
  color: var(--ink);
  font: inherit;
  text-align: start;
  cursor: pointer;
}

.track-nav-item:hover { background: #efe9db; }

.track-nav-item[aria-current='true'] { background: var(--surface); border-color: var(--line); border-inline-start-color: var(--accent); }

.track-nav-title { font-weight: 600; }

.track-nav-item .track-meta { font-size: 0.82rem; }

.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; flex: none; }

.admin-track-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.admin-track-head h2 { font-size: 2rem; color: var(--accent); }

.admin-track-head p { margin: 0.4rem 0; color: var(--muted); }

.admin-track-head a { font-size: 0.92rem; }

.admin-stage {
  padding: 1.25rem;
  margin-bottom: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-stage-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.85rem; }

.admin-stage-head .stage-marker { width: 2.1rem; height: 2.1rem; font-size: 0.95rem; }

.admin-stage-title { flex: 1 1 14rem; min-width: 0; }

.admin-stage-title h3 { font-size: 1.25rem; }

.admin-stage-title p { margin: 0.25rem 0 0; font-size: 0.92rem; color: var(--muted); }

.admin-stage > .empty { margin: 1rem 0 0; font-size: 0.92rem; }

.admin-links { list-style: none; margin: 1rem 0 0; padding: 0; }

.admin-link {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.7rem 0;
  border-top: 1px solid var(--line);
}

.admin-link-body { display: flex; gap: 0.75rem; flex: 1 1 18rem; min-width: 0; }

.admin-link-body a { font-weight: 600; overflow-wrap: anywhere; }

.admin-stage > .btn-add { margin-top: 0.9rem; }

@media (max-width: 52rem) {
  .dashboard { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .track-card, .resource { transition: none; }
  .track-card:hover { transform: none; }
}

/* ---------- Explainer article ---------- */

.article { max-width: 48rem; margin: 0 auto; padding: 0.5rem 1.5rem 1rem; }

.article h2 { font-size: 1.6rem; margin-top: 2.25rem; }

.article p, .article li { font-size: 1.05rem; line-height: 1.9; }

.article ul, .article ol { padding-inline-start: 1.5rem; margin: 0.75rem 0; }

.article li { margin-block: 0.35rem; }

.article .flow { list-style: none; display: grid; gap: 0.6rem; padding-inline-start: 0; }

.article .flow li {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin-block: 0;
  padding: 0.7rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.article .flow li::before {
  counter-increment: step;
  content: counter(step);
  flex: none;
  display: grid;
  place-items: center;
  width: 1.7rem;
  height: 1.7rem;
  margin-top: 0.15rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
}

.article .flow { counter-reset: step; }

.article code {
  font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
  font-size: 0.88em;
  background: #efe9db;
  padding: 0.08em 0.38em;
  border-radius: 4px;
  direction: ltr;
  unicode-bidi: isolate;
}

.article pre {
  direction: ltr;
  text-align: left;
  background: var(--ink);
  color: var(--paper);
  padding: 1rem 1.25rem;
  border-radius: 8px;
  overflow-x: auto;
  font: 400 0.9rem/1.6 ui-monospace, 'Cascadia Code', Consolas, monospace;
}

.article pre code { background: none; padding: 0; color: inherit; font-size: inherit; }

.article blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border-inline-start: 5px solid var(--gold);
  border-radius: 4px;
}

.article .btn { display: inline-block; text-decoration: none; }

/* ---------- Bilingual titles (Arabic part smaller) ---------- */

.title-sub {
  font-size: 0.55em;
  font-weight: 600;
  color: var(--muted);
  unicode-bidi: isolate;
}

h1 .title-sub, h2 .title-sub { display: block; }

/* ---------- Preparation panel on track pages ---------- */

.prep { max-width: 48rem; margin: 0 auto; padding: 0 1.5rem 1rem; }

.prep-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-inline-start: 5px solid var(--accent);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
}

.prep-title { font-size: 1.35rem; }

.prep-card p { margin: 0.75rem 0 0; line-height: 1.9; color: var(--ink); }

.prep-card p.prep-link-line { font-size: 0.98rem; color: var(--muted); }

.prep-card p.prep-link-line a { font-weight: 600; }

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

.quiz {
  max-width: 48rem;
  margin: 0 auto;
  padding: 0 1.5rem 2rem;
}

.quiz-q { font-size: 1.45rem; }

.quiz-options { display: grid; gap: 0.6rem; margin-top: 1.25rem; }

.quiz-option { text-align: start; padding: 0.8rem 1.05rem; line-height: 1.7; }

.quiz-option.quiz-right { border-color: #1f6f5c; box-shadow: inset 0 0 0 2px #1f6f5c; }

.quiz-option.quiz-wrong { border-color: var(--danger); color: var(--danger); }

.quiz-feedback { margin: 1rem 0 0; font-weight: 500; line-height: 1.9; }

.quiz-next { margin-top: 1rem; }

.quiz-actions { max-width: 48rem; margin: 0 auto; padding: 0 1.5rem 2.5rem; }

/* ---------- WhatsApp help contact ---------- */

.wa-float {
  position: fixed;
  z-index: 20;
  inset-block-end: 1.25rem;
  inset-inline-end: 1.25rem;
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 50%;
  background: #25d366;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.25);
  transition: transform 150ms ease;
}

.wa-float:hover { transform: translateY(-3px); }

.wa-float svg { width: 1.9rem; height: 1.9rem; fill: #fff; }

.help-contact { margin-top: 1.25rem; }

.help-contact a {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.95rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  text-decoration: none;
  color: var(--ink);
}

.help-contact a:hover { border-color: #25d366; }

.help-contact .wa-icon { width: 1.35rem; height: 1.35rem; fill: #25d366; flex: none; }

.help-contact .num {
  direction: ltr;
  unicode-bidi: isolate;
  font-weight: 600;
}

.quiz-report li { margin-block: 0.25rem; }



