/* إسعاف المتلوي — self-contained, no CDNs */
:root {
  --bg: #f6f1e8;
  --bg-2: #efe7d8;
  --card: #fffdf8;
  --ink: #1c2422;
  --muted: #4a5854;
  --line: #e4d9cc;
  --teal: #0e443e;
  --teal-deep: #0a332e;
  --teal-soft: #e4eeec;
  --urgent: #b42318;
  --urgent-dark: #8b1a14;
  --urgent-soft: #fdecea;
  --warn: #9a3412;
  --warn-soft: #fff1e6;
  --ok: #0e443e;
  --ok-soft: #e6f2ef;
  --shadow: 0 1px 2px rgba(28, 36, 34, 0.06), 0 8px 24px rgba(28, 36, 34, 0.06);
  --radius: 16px;
  --tap: 52px;
  --max: 40rem;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: light;
}

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

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: auto;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(800px 240px at 50% calc(-80px + var(--safe-t)), #eadfcb 0%, transparent 70%),
    var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", sans-serif;
  font-size: 1.0625rem;
  line-height: 1.55;
  padding: 0;
}

html[lang="ar"] body {
  font-family: "Noto Naskh Arabic", "Noto Sans Arabic", "SF Arabic", "Geeza Pro", "Tahoma", "Segoe UI", sans-serif;
  line-height: 1.75;
}

[hidden] { display: none !important; }

html[lang="fr"] .t-ar { display: none !important; }
html[lang="ar"] .t-fr { display: none !important; }
html:not([lang="fr"]) .t-fr { display: none !important; }

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

.skip {
  position: absolute;
  inset-inline-start: 0.75rem;
  top: -4rem;
  z-index: 20;
  background: var(--teal);
  color: #fff;
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  text-decoration: none;
}
.skip:focus { top: calc(0.5rem + var(--safe-t)); }

.wrap {
  width: min(100%, var(--max));
  margin: 0 auto;
  padding-inline: calc(1rem + var(--safe-l)) calc(1rem + var(--safe-r));
  padding-bottom: calc(1.5rem + var(--safe-b));
}

/* Header */
.top {
  position: sticky;
  top: 0;
  z-index: 8;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  padding-top: var(--safe-t);
}
.top.is-stuck { border-bottom-color: var(--line); }

.top-inner {
  width: min(100%, var(--max));
  margin: 0 auto;
  padding: 0.7rem 1rem;
  padding-inline: calc(1rem + var(--safe-l)) calc(1rem + var(--safe-r));
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  flex: 1;
  text-decoration: none;
  color: inherit;
}

.brand img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
}

.brand-text { min-width: 0; }

.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.25;
  color: var(--teal-deep);
}

.brand p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.3;
}

.lang-toggle {
  flex-shrink: 0;
  display: inline-flex;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.lang-toggle button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  min-height: 36px;
  min-width: 44px;
  padding: 0 0.7rem;
  border-radius: 999px;
  cursor: pointer;
}

.lang-toggle button[aria-pressed="true"] {
  background: var(--teal);
  color: #fff;
}

.back-btn {
  appearance: none;
  border: 0;
  background: var(--teal-soft);
  color: var(--teal-deep);
  font: inherit;
  font-weight: 650;
  font-size: 0.9rem;
  min-height: 40px;
  padding: 0 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  flex-shrink: 0;
}

/* Emergency */
.emergency {
  display: grid;
  gap: 0.65rem;
  margin: 1rem 0 1.15rem;
}

.call {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-height: 64px;
  padding: 0.7rem 1rem;
  border-radius: 14px;
  text-decoration: none;
  color: #fff;
  background: var(--urgent);
  box-shadow: 0 1px 0 rgba(255,255,255,0.12) inset, var(--shadow);
}

.call:active { background: var(--urgent-dark); }

.call-num {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  font-family: system-ui, "Segoe UI", Roboto, sans-serif;
  line-height: 1;
  dir: ltr;
  unicode-bidi: isolate;
}

.call-label {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.call-label strong {
  font-size: 1.05rem;
  font-weight: 700;
}

.call-label span {
  font-size: 0.8rem;
  opacity: 0.92;
}

.call--pc { background: #9a3412; }
.call--pc:active { background: #7c2d12; }

.call--police {
  background: var(--teal);
  min-height: 56px;
}
.call--police:active { background: var(--teal-deep); }
.call--police .call-num { font-size: 1.35rem; }

.share-btn,
.btn {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: var(--tap);
  padding: 0.65rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--teal-deep);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}

.share-btn:active, .btn:active { background: var(--bg-2); }

.share-status {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
  word-break: break-word;
}
.share-status a { color: var(--teal); }
.share-status.is-error { color: var(--urgent-dark); }
.share-status.is-ok { color: var(--teal); }

/* Cards / nav */
.section-title {
  margin: 1.35rem 0 0.65rem;
  font-size: 1.05rem;
  font-weight: 750;
  color: var(--teal-deep);
}

.grid {
  display: grid;
  gap: 0.65rem;
}

.card-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  min-height: 64px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  cursor: pointer;
  font: inherit;
  text-align: inherit;
  width: 100%;
}

.card-link:active { background: #fbf6ec; }

.card-ico {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--teal-soft);
  color: var(--teal);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.card-ico svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.card-link strong {
  display: block;
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.3;
}
.card-link span {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.35;
  margin-top: 0.1rem;
}

.chev {
  margin-inline-start: auto;
  color: var(--muted);
  flex-shrink: 0;
}

/* Credit / footer */
.credit {
  margin: 1.35rem 0 0.4rem;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--ink);
  text-align: center;
}
.credit a {
  color: var(--teal);
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.site-foot {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}
.site-foot p { margin: 0 0 0.5rem; }
.site-foot .credit { font-size: 0.88rem; color: var(--ink); margin: 0.35rem 0; }

.disclaimer-box {
  margin: 1rem 0;
  padding: 0.9rem 1rem;
  background: var(--warn-soft);
  border: 1px solid #f0d3b8;
  border-radius: 12px;
  font-size: 0.92rem;
  color: #5c2e12;
}
.disclaimer-box p { margin: 0 0 0.45rem; }
.disclaimer-box p:last-child { margin-bottom: 0; }

.thanks {
  margin: 1.35rem 0 0;
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--muted);
  text-align: center;
}

/* Guide detail */
.red-flag {
  margin: 1rem 0;
  padding: 0.95rem 1rem;
  background: var(--urgent-soft);
  border: 1px solid #f5c2c0;
  border-radius: 12px;
  color: #6b1210;
}
.red-flag h3 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  color: var(--urgent-dark);
}
.red-flag ul { margin: 0; padding-inline-start: 1.2rem; }
.red-flag li { margin: 0.25rem 0; }

.steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
.steps li {
  position: relative;
  padding-inline-start: 2.6rem;
  margin: 0 0 0.85rem;
  min-height: 1.9rem;
}
.steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  inset-inline-start: 0;
  top: 0.1rem;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  font-family: system-ui, "Segoe UI", sans-serif;
}

.dont {
  margin: 1rem 0;
  padding: 0.95rem 1rem;
  background: #f4f1ea;
  border-radius: 12px;
  border: 1px solid var(--line);
}
.dont h3 { margin: 0 0 0.4rem; font-size: 1rem; }
.dont ul { margin: 0; padding-inline-start: 1.2rem; }
.dont li { margin: 0.25rem 0; }

.guide-lead {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.98rem;
}

article.guide h2 {
  margin: 0.2rem 0 0.55rem;
  font-size: 1.35rem;
  line-height: 1.3;
  color: var(--teal-deep);
}

/* Triage */
.triage-q {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.1rem 1.2rem;
  box-shadow: var(--shadow);
}
.triage-q .progress {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 0.55rem;
  font-weight: 600;
}
.triage-q h2 {
  margin: 0 0 1rem;
  font-size: 1.2rem;
  line-height: 1.45;
}
.triage-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}
.triage-actions button {
  appearance: none;
  border: 0;
  min-height: 56px;
  border-radius: 12px;
  font: inherit;
  font-weight: 750;
  font-size: 1.05rem;
  cursor: pointer;
}
.btn-yes { background: var(--urgent); color: #fff; }
.btn-yes:active { background: var(--urgent-dark); }
.btn-no { background: var(--teal); color: #fff; }
.btn-no:active { background: var(--teal-deep); }

.result {
  border-radius: var(--radius);
  padding: 1.15rem 1.1rem;
  border: 1px solid var(--line);
}
.result h2 { margin: 0 0 0.5rem; font-size: 1.25rem; line-height: 1.35; }
.result p { margin: 0 0 0.65rem; }
.result--call { background: var(--urgent-soft); border-color: #f5c2c0; }
.result--urgent { background: var(--warn-soft); border-color: #f0d3b8; }
.result--doctor { background: var(--ok-soft); border-color: #c5ddd7; }

.places-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.05rem 1.1rem;
  box-shadow: var(--shadow);
}
.places-card h2 { margin: 0 0 0.35rem; font-size: 1.15rem; }
.places-card p { margin: 0 0 0.85rem; color: var(--muted); font-size: 0.95rem; }

.sticky-call {
  position: sticky;
  bottom: 0;
  margin: 1.25rem -0.25rem 0;
  padding: 0.55rem 0.25rem calc(0.4rem + var(--safe-b));
  background: linear-gradient(transparent, var(--bg) 30%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.sticky-call a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 48px;
  border-radius: 12px;
  text-decoration: none;
  color: #fff;
  font-weight: 700;
  background: var(--urgent);
}
.sticky-call a.pc { background: #9a3412; }

.view-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.85rem 0 0.9rem;
}
.view-head h2 {
  margin: 0;
  font-size: 1.28rem;
  color: var(--teal-deep);
}

.noscript {
  margin: 1rem 0;
  padding: 0.9rem 1rem;
  background: var(--warn-soft);
  border-radius: 12px;
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}

html[lang="ar"] .chev { transform: scaleX(-1); }
