/* Smart Clinic AI Academy — alreem.space
   Palette: clinical paper + petrol teal, with a sand accent that only ever
   marks progress, and a clay accent that only ever marks a problem. */

:root {
  --paper:   #F1F4F0;
  --surface: #FFFFFF;
  --raised:  #FAFCF9;
  --ink:     #12232A;
  --muted:   #5B6F6A;
  --line:    #DEE5DE;
  --teal:    #0F6E63;
  --teal-ink:#0A4A43;
  --teal-soft:#E1EFEB;
  --sand:    #C8901F;
  --sand-soft:#FAF0DA;
  --clay:    #B4523F;
  --clay-soft:#FBE8E4;
  --radius:  14px;
  --radius-s: 9px;
  --shadow:  0 1px 2px rgba(18,35,42,.06), 0 8px 24px -16px rgba(18,35,42,.28);
  --maxw:    1080px;
}
html[data-theme="dark"] {
  --paper:   #0D1A1D;
  --surface: #142529;
  --raised:  #182D32;
  --ink:     #E9F1ED;
  --muted:   #94AAA4;
  --line:    #24393E;
  --teal:    #4CC3AC;
  --teal-ink:#8FE0CE;
  --teal-soft:#123531;
  --sand:    #E0B25A;
  --sand-soft:#33290F;
  --clay:    #E38672;
  --clay-soft:#3A1E19;
  --shadow:  0 1px 2px rgba(0,0,0,.4), 0 10px 26px -18px rgba(0,0,0,.9);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .brand-text, .kpi-num, .day-num {
  font-family: "Noto Kufi Arabic", "IBM Plex Sans Arabic", Tahoma, sans-serif;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(1.35rem, 1.1rem + 1.3vw, 1.9rem); margin: 0 0 .35rem; }
h2 { font-size: clamp(1.1rem, 1rem + .6vw, 1.3rem); margin: 0 0 .5rem; }
h3 { font-size: 1rem; margin: 0 0 .35rem; }
p  { margin: 0 0 .8rem; }
a  { color: var(--teal-ink); text-underline-offset: 3px; }
html[data-theme="dark"] a { color: var(--teal-ink); }
.mono, code, .num { font-family: "IBM Plex Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }
code { background: var(--teal-soft); padding: .1em .35em; border-radius: 5px; font-size: .92em; }
:focus-visible { outline: 3px solid var(--sand); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; inset-inline-start: -9999px; }
.skip:focus { inset-inline-start: 8px; top: 8px; background: var(--surface); padding: .5rem .8rem; z-index: 99; }

/* ---------------------------------------------------------------- topbar -- */
.topbar {
  background: var(--surface);
  border-block-end: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
.topbar-in {
  max-width: var(--maxw); margin: 0 auto; padding: .55rem 1rem;
  display: flex; align-items: center; gap: .75rem; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: .5rem; text-decoration: none; color: var(--ink); min-width: 0; }
.brand-mark { color: var(--teal); font-size: 1.25rem; }
.brand-text { font-size: .98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-drop > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: .45rem;
  padding: .45rem .7rem; border: 1px solid var(--line); border-radius: 999px; font-size: .9rem;
}
.nav-drop > summary::-webkit-details-marker { display: none; }
.burger { width: 16px; height: 2px; background: currentColor; box-shadow: 0 5px currentColor, 0 -5px currentColor; display: block; }
.nav { display: none; }                 /* hidden on mobile until the menu opens */
.nav-drop[open] ~ .nav { display: flex; }
.nav {
  position: absolute; inset-inline-end: 1rem; top: 3.2rem; margin-block-start: .5rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: .5rem; display: flex; flex-direction: column; min-width: 200px; z-index: 50;
}
.nav a, .theme-btn {
  padding: .55rem .7rem; border-radius: var(--radius-s); text-decoration: none;
  color: var(--ink); font-size: .95rem; background: none; border: 0; text-align: start; cursor: pointer;
  font-family: inherit;
}
.nav a:hover, .theme-btn:hover { background: var(--teal-soft); }
.nav .is-admin { color: var(--sand); font-weight: 600; }
.nav .is-quiet { color: var(--muted); }
.nav-sep { height: 1px; background: var(--line); margin: .4rem 0; }
.nav .lang.on { background: var(--teal-soft); font-weight: 600; }
@media (min-width: 860px) {
  .nav-drop > summary { display: none; }
  .nav-drop { position: static; }
  .nav {
    position: static; flex-direction: row; align-items: center; border: 0; box-shadow: none;
    background: none; padding: 0; margin: 0; gap: .15rem; flex-wrap: wrap;
  }
  .nav-sep { width: 1px; height: 20px; margin-inline: .4rem; }
  .nav, .nav-drop[open] ~ .nav { display: flex; }   /* always visible on desktop */
}

/* ------------------------------------------------------------------ shell -- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 1rem 1rem 3rem; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem; margin-block-end: 1rem; box-shadow: var(--shadow);
}
.card.tight { padding: .85rem 1rem; }
.grid { display: grid; gap: 1rem; }
@media (min-width: 700px) { .grid.cols-2 { grid-template-columns: 1fr 1fr; } .grid.cols-3 { grid-template-columns: repeat(3, 1fr); } }
.muted { color: var(--muted); }
.small { font-size: .87rem; }
.row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.spread { justify-content: space-between; }
.stack > * + * { margin-block-start: .8rem; }
hr { border: 0; border-block-start: 1px solid var(--line); margin: 1rem 0; }

/* ---------------------------------------------------------------- buttons -- */
.btn, button.btn, input[type=submit] {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  background: var(--teal); color: #fff; border: 1px solid transparent; border-radius: 999px;
  padding: .62rem 1.15rem; font: inherit; font-weight: 600; font-size: .95rem;
  cursor: pointer; text-decoration: none; min-height: 44px;
}
html[data-theme="dark"] .btn { color: #08211E; }
.btn:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--teal-soft); }
.btn.danger { background: var(--clay); color: #fff; }
.btn.sand { background: var(--sand); color: #23180a; }
.btn.block { width: 100%; }
.btn.small { padding: .35rem .8rem; min-height: 36px; font-size: .85rem; }
.btn[disabled], .btn.off { opacity: .45; pointer-events: none; }

/* ------------------------------------------------------------------ forms -- */
label { display: block; font-weight: 600; font-size: .9rem; margin-block-end: .3rem; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--raised); color: var(--ink); font: inherit; font-size: 1rem;
}
textarea { min-height: 130px; resize: vertical; line-height: 1.7; }
.field { margin-block-end: .9rem; }
.hint { font-size: .85rem; color: var(--muted); margin-block-start: .25rem; }
.ltr { direction: ltr; text-align: start; }
.count { font-size: .8rem; color: var(--muted); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-s); padding: .8rem; margin: 0 0 .9rem; }
legend { font-weight: 600; font-size: .9rem; padding-inline: .35rem; }

/* ----------------------------------------------------------------- flashes -- */
.flash {
  border-radius: var(--radius-s); padding: .7rem .9rem; margin-block-end: .9rem;
  border-inline-start: 4px solid var(--teal); background: var(--teal-soft); font-size: .95rem;
}
.flash-error { border-color: var(--clay); background: var(--clay-soft); }
.flash-warn { border-color: var(--sand); background: var(--sand-soft); }

/* -------------------------------------------------------------------- kpi -- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: .7rem; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem .9rem; }
.kpi-label { font-size: .78rem; color: var(--muted); letter-spacing: .02em; }
.kpi-num { font-size: 1.7rem; line-height: 1.2; font-family: "IBM Plex Mono", monospace; font-weight: 600; }
.kpi-num small { font-size: .8rem; color: var(--muted); font-weight: 500; }

/* ------------------------------------------------- the progress signature -- */
.ribbon { display: block; }
.ribbon-row { display: flex; align-items: center; gap: .6rem; margin-block-end: .45rem; }
.ribbon-key { font-size: .8rem; color: var(--muted); width: 8.5rem; flex: none; }
.bar { flex: 1; height: 12px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--teal); transition: width .6s ease; }
.bar.sand > span { background: var(--sand); }
.ribbon-val { width: 3.4rem; text-align: end; font-family: "IBM Plex Mono", monospace; font-size: .9rem; }

/* the 100 tiles — completed tiles take their phase colour, so the map itself
   turns into a coloured spine as the learner moves through the curriculum */
.daygrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: .38rem; }
.tile {
  aspect-ratio: 1; border: 1px solid var(--line); border-radius: 10px; background: var(--raised);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-decoration: none; color: var(--ink); position: relative; overflow: hidden;
}
.tile .day-num { font-size: .95rem; font-family: "IBM Plex Mono", monospace; font-weight: 600; }
.tile .tile-tag { font-size: .58rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.tile.is-done { color: #fff; border-color: transparent; }
.tile.is-done .tile-tag { color: rgba(255,255,255,.85); }
.tile.is-next { border-color: var(--sand); border-width: 2px; background: var(--sand-soft); }
.tile.is-locked { opacity: .42; pointer-events: none; }
.tile:hover:not(.is-locked) { transform: translateY(-1px); }

/* ---------------------------------------------------------------- lessons -- */
.pill {
  display: inline-flex; align-items: center; gap: .3rem; font-size: .76rem; font-weight: 600;
  padding: .18rem .6rem; border-radius: 999px; background: var(--teal-soft); color: var(--teal-ink);
}
.pill.sand { background: var(--sand-soft); color: var(--sand); }
.pill.clay { background: var(--clay-soft); color: var(--clay); }
.lesson-body { font-size: 1.02rem; }
.lesson-body p { margin: 0 0 .75rem; }
.lesson-body ul { margin: 0 0 .8rem; padding-inline-start: 1.15rem; }
.lesson-body li { margin-block-end: .3rem; }
.lesson-body strong { color: var(--teal-ink); }

/* ---------------------------------------------------------------- stepper -- */
.stepper { display: flex; gap: .3rem; margin-block-end: 1rem; list-style: none; padding: 0; }
.stepper li { flex: 1; }
.stepper span, .stepper a {
  display: block; text-align: center; font-size: .72rem; color: var(--muted); text-decoration: none;
  padding-block-start: .45rem; border-block-start: 3px solid var(--line); border-radius: 2px;
}
.stepper .on span, .stepper .on a { color: var(--teal-ink); border-color: var(--teal); font-weight: 600; }
.stepper .past a { color: var(--ink); border-color: var(--teal); opacity: .7; }
@media (max-width: 520px) { .stepper span, .stepper a { font-size: .65rem; } }

.wizard-nav {
  position: sticky; bottom: 0; background: var(--surface); border-block-start: 1px solid var(--line);
  padding: .6rem 1rem calc(.6rem + env(safe-area-inset-bottom)); margin: 1rem -1rem -3rem;
  display: flex; gap: .6rem; justify-content: space-between; align-items: center; z-index: 30;
}
.wizard-nav .btn { flex: 1; max-width: 220px; }

/* ------------------------------------------------------------------- quiz -- */
.choice { display: block; border: 1px solid var(--line); border-radius: var(--radius-s); padding: .7rem .85rem; margin-block-end: .5rem; cursor: pointer; background: var(--raised); font-weight: 400; }
.choice:hover { border-color: var(--teal); }
.choice input { margin-inline-end: .55rem; accent-color: var(--teal); }
.choice.correct { border-color: var(--teal); background: var(--teal-soft); }
.choice.wrong { border-color: var(--clay); background: var(--clay-soft); }
.qblock { padding-block-end: .6rem; margin-block-end: .9rem; border-block-end: 1px dashed var(--line); }
.qblock:last-of-type { border: 0; }

/* ----------------------------------------------------------------- tables -- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: .55rem .6rem; border-block-end: 1px solid var(--line); text-align: start; vertical-align: middle; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: var(--raised); }

/* ----------------------------------------------------------------- badges -- */
.badges { display: flex; flex-wrap: wrap; gap: .45rem; }
.badge { display: inline-flex; align-items: center; gap: .35rem; border: 1px solid var(--line); background: var(--raised); border-radius: 999px; padding: .3rem .7rem; font-size: .84rem; }
.badge .ico { font-size: 1rem; }

/* ------------------------------------------------------------------- misc -- */
.phase-head { display: flex; align-items: center; gap: .6rem; margin-block: 1.4rem .6rem; }
.phase-dot { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.foot { border-block-start: 1px solid var(--line); background: var(--surface); }
.foot-in { max-width: var(--maxw); margin: 0 auto; padding: 1rem; font-size: .8rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: .4rem; }
.dot { opacity: .5; }
.tabs { display: flex; gap: .3rem; border-block-end: 1px solid var(--line); margin-block-end: 1rem; flex-wrap: wrap; }
.tabs button, .tabs a {
  background: none; border: 0; border-block-end: 3px solid transparent; padding: .5rem .8rem;
  font: inherit; font-size: .92rem; cursor: pointer; color: var(--muted); text-decoration: none;
}
.tabs .on { color: var(--ink); border-color: var(--teal); font-weight: 600; }
.auth-card { max-width: 420px; margin: 2.2rem auto; }
.center { text-align: center; }
.cert {
  background: var(--surface); border: 2px solid var(--teal); border-radius: var(--radius);
  padding: 2.2rem 1.4rem; text-align: center;
}
.cert h1 { font-size: clamp(1.5rem, 1.1rem + 2vw, 2.4rem); }
.cert .who { font-size: 1.5rem; color: var(--teal-ink); margin: 1rem 0; }
@media print {
  .topbar, .foot, .wizard-nav, .no-print { display: none !important; }
  body { background: #fff; }
  .cert { border-color: #0F6E63; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* -------------------------------------------------------------- study timer */
.timer { margin-block-start: .7rem; padding-block-start: .6rem; border-block-start: 1px solid var(--line); }
.timer .bar { display: block; height: 8px; }
.timer .bar > span { background: var(--sand); }
.cert tfoot th { border-block-start: 2px solid var(--teal); }

/* ----------------------------------------------------------------- diagram */
.diagram { margin: 1rem 0; padding: .9rem; background: var(--raised);
           border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.diagram svg { display: block; width: 100%; height: auto; max-width: 640px; margin-inline: auto; }

/* ------------------------------------------------- learning map modules */
.track-count { font-size: .8rem; font-weight: 400; color: var(--muted); }
/* المحاور عناوين فرعية تحت المسار، فتُزاح عن بداية السطر.
   على الشاشات الضيقة تصغر الإزاحة حتى لا تخنق النص. */
.qblock.module { margin-inline-start: 1cm; }
.module-no { color: var(--muted); font-weight: 600; font-size: .92em; }
@media (max-width: 600px) { .qblock.module { margin-inline-start: .5cm; } }

/* عنوان المسار: خلفية ملوّنة تفصله عن محاوره البيضاء تحته */
.phase-head.track-head {
  padding: .6rem .85rem;
  border-radius: 10px;
  border-inline-start: 4px solid;      /* اللون يأتي من نمط السطر */
  margin-block: 1.4rem .7rem;
}
.phase-head.track-head h3 { font-size: 1.05rem; }
