@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&display=swap");

:root {
  color-scheme: dark;
  --bg: #161820;
  --surface: #1d202a;
  --raised: #252936;
  --line: #3c4152;
  --text: #ebeaf0;
  --muted: #bec1cf;
  --accent: #cdbdf9;
  --mint: #a4dfcd;
  --arabic: "IBM Plex Sans Arabic", Tahoma, sans-serif;
  --english: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 50% 1rem, #332c47 0, transparent 37rem),
    var(--bg);
  color: var(--text);
  font: 400 1rem/1.75 var(--arabic);
}

h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.2; }
[lang="en"] { font-family: var(--english); }
a { color: inherit; }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.shell {
  width: min(1056px, calc(100% - 2.5rem));
  margin-inline: auto;
}

.skip {
  position: fixed;
  inset: .6rem .6rem auto auto;
  z-index: 20;
  padding: .5rem .85rem;
  border-radius: .55rem;
  background: var(--accent);
  color: #242033;
  transform: translateY(-180%);
}

.skip:focus { transform: none; }

.hero {
  padding-block: clamp(2.4rem, 7vw, 4.5rem) clamp(1.35rem, 4vw, 2.5rem);
  text-align: center;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  margin-bottom: .85rem;
  color: var(--muted);
  font: 600 .8rem/1.3 var(--english);
}

.brand strong {
  padding: .28rem .6rem;
  border: 1px solid #6d608e;
  border-radius: .5rem;
  background: #312a45;
  color: var(--accent);
  letter-spacing: .12em;
}

.hero h1 {
  font-size: clamp(2.7rem, 8.5vw, 5.85rem);
  letter-spacing: -.06em;
}

.hero p {
  margin-top: .4rem;
  color: var(--accent);
  font-size: clamp(1.08rem, 3vw, 1.3rem);
}

.chapter-nav {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: .5rem;
  padding: .55rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: #1a1d27;
}

.chapter-nav button {
  min-width: 0;
  min-height: 3.1rem;
  padding: .35rem;
  border: 1px solid #454c60;
  border-radius: .65rem;
  background: var(--raised);
  color: var(--text);
  cursor: pointer;
  font: 700 .95rem/1.3 var(--english);
}

.chapter-nav button:hover { border-color: #9688b7; }

.chapter-nav button[aria-pressed="true"] {
  border-color: #a797d2;
  background: linear-gradient(160deg, #423956, #2c293a);
  color: #eee5ff;
  box-shadow: inset 0 -2px var(--accent), 0 0 16px #cdbdf927;
}

.reader {
  margin-block: 1.1rem 2rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface);
  box-shadow: 0 12px 35px #0e10174d;
}

.reader-header {
  padding: clamp(1.1rem, 4vw, 2rem);
  border-bottom: 1px solid var(--line);
  border-radius: 1rem 1rem 0 0;
  background: linear-gradient(115deg, #292b3d, #242733);
}

.reader-header h2 {
  scroll-margin-top: 1rem;
  font-size: clamp(1.45rem, 4vw, 2.6rem);
  letter-spacing: -.03em;
}

.reader-header p { margin-top: .3rem; color: var(--accent); }

.reader-body {
  max-width: 52rem;
  margin-inline: auto;
  padding: clamp(.85rem, 4vw, 2rem);
}

.contents {
  padding: .65rem .85rem;
  border: 1px solid #46485d;
  border-radius: .7rem;
  background: #222431;
}

.contents summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 700;
}

.contents nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .35rem .7rem;
  padding-top: .55rem;
}

.contents a {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  padding: .3rem .55rem;
  border-radius: .45rem;
  color: var(--muted);
  text-decoration: none;
}

.contents a:hover { background: var(--raised); color: var(--text); }

.topic {
  margin-top: 1rem;
  padding: clamp(.85rem, 3vw, 1.25rem);
  border: 1px solid var(--line);
  border-radius: .8rem;
  background: #202431;
  scroll-margin-top: 1rem;
}

.topic-heading {
  margin-bottom: .7rem;
  padding-left: .7rem;
  border-left: 3px solid var(--accent);
}

.topic-heading h3 { font-size: clamp(1.2rem, 3vw, 1.55rem); }
.topic-heading p { margin-top: .3rem; color: var(--accent); }

.pair {
  padding: .72rem 0;
  border-top: 1px solid #3a4050;
}

.pair:last-child { padding-bottom: 0; }

.pair [lang="en"] {
  font-size: clamp(1rem, 2vw, 1.08rem);
  line-height: 1.65;
}

.translation { margin-top: .25rem; color: var(--muted); }

.community {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-block: 0 5.5rem;
  padding: clamp(1rem, 4vw, 1.6rem);
  border: 1px solid #4d7e70;
  border-radius: .95rem;
  background: radial-gradient(ellipse at 100% 0, #285145, transparent 70%), var(--surface);
}

.community-heading {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.community h2 { font-size: clamp(1.2rem, 4vw, 1.7rem); }

.whatsapp-icon {
  display: grid;
  place-items: center;
  flex: 0 0 3.1rem;
  aspect-ratio: 1;
  border: 1px solid #78b9a2;
  border-radius: .8rem;
  background: #275345;
  color: #e0fff1;
}

.whatsapp-icon svg { width: 1.65rem; height: 1.65rem; }

.join {
  display: grid;
  place-items: center;
  min-height: 2.85rem;
  padding: .35rem 1rem;
  border: 1px solid #c2f0db;
  border-radius: .65rem;
  background: var(--mint);
  box-shadow: 0 4px #376854, 0 0 19px #a4dfcd47;
  color: #142920;
  font-weight: 700;
  text-decoration: none;
}

.join:hover { filter: brightness(1.12); }
.join:active { transform: translateY(2px); }

.back-top {
  position: fixed;
  left: max(.8rem, env(safe-area-inset-left));
  bottom: max(1.1rem, env(safe-area-inset-bottom));
  z-index: 5;
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border: 1px solid #ded0ff;
  border-radius: .85rem;
  background: linear-gradient(145deg, #584a74, #342c48);
  box-shadow: 0 4px #171320, 0 0 18px #cdbdf964;
  color: #f0e9ff;
  font: 700 1.5rem/1 system-ui, sans-serif;
  text-decoration: none;
  transition: box-shadow .18s ease, transform .18s ease;
}

.back-top:hover,
.back-top:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 6px #171320, 0 0 25px #cdbdf995;
}

.back-top:active { transform: translateY(2px); }

@media (max-width: 620px) {
  .shell { width: calc(100% - 1.25rem); }
  .chapter-nav { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .35rem; }
  .chapter-nav button { font-size: .88rem; }
  .contents nav { grid-template-columns: minmax(0, 1fr); }
  .join { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .back-top { transition: none; }
}

.community {
  margin-bottom: 1rem;
}

.telegram-community {
  margin-bottom: 5.5rem;
  border-color: #527a9c;
  background:
    radial-gradient(ellipse at 100% 0, #244d67, transparent 70%),
    var(--surface);
}

.telegram-community .telegram-icon {
  border-color: #79b9e8;
  background: #24536e;
  color: #e6f7ff;
}

.telegram-community .telegram-join {
  border-color: #c3ecff;
  background: linear-gradient(155deg, #bdeaff, #77bfef);
  box-shadow: 0 4px #335f82, 0 0 20px #77bfef60;
  color: #10283a;
}

/* Animal Health — تحسين قراءة الشرح */
body {
  background: #19242d;
  color: #eef3f6;
}

#chapter-body .topic {
  background: #222f3a;
  border: 1px solid #3c4e5d;
  border-radius: 16px;
  padding: clamp(16px, 3vw, 28px);
}

#chapter-body .topic-heading h3 {
  color: #a7e4d8;
  font-size: clamp(1.3rem, 1.15rem + 0.6vw, 1.65rem);
  line-height: 1.4;
}

#chapter-body .pair {
  background: #293744;
  border-radius: 12px;
  padding: clamp(14px, 2.5vw, 22px);
}

#chapter-body .pair + .pair {
  margin-block-start: 12px;
}

#chapter-body .pair p[lang="en"] {
  margin: 0;
  color: #f1f5f8;
  font-family: system-ui, "Segoe UI", sans-serif;
  font-size: clamp(1.0625rem, 1rem + 0.3vw, 1.1875rem);
  line-height: 1.65;
}

#chapter-body .pair .translation {
  margin-block: 0.65rem 0;
  color: #d3e2ea;
  font-family: "IBM Plex Sans Arabic", Tahoma, sans-serif;
  font-size: clamp(1.125rem, 1.05rem + 0.35vw, 1.25rem);
  line-height: 1.85;
}

#chapter-body .pair p {
  overflow-wrap: anywhere;
}

/* أزرار الشابترات */
.chapter-nav button {
  min-height: 48px;
  padding: 0.65rem 1rem;
  border: 1px solid #536a7b;
  border-radius: 12px;
  background: linear-gradient(160deg, #344655, #263440);
  color: #eef5f8;
  font: 650 1rem/1.35 system-ui, "Segoe UI", sans-serif;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease,
    border-color 180ms ease;
}

.chapter-nav button[aria-pressed="true"] {
  border-color: #9de7d7;
  background: linear-gradient(160deg, #a9e8db, #79c7ba);
  color: #122e2b;
  box-shadow: 0 4px 18px #79c7ba38;
}

@media (hover: hover) {
  .chapter-nav button:hover {
    transform: translateY(-2px);
    border-color: #9de7d7;
    box-shadow: 0 6px 16px #0e191f66;
  }
}

.chapter-nav button:focus-visible {
  outline: 2px solid #b1f1e4;
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .chapter-nav button {
    transition: none;
  }

  .chapter-nav button:hover {
    transform: none;
  }
}

/* Animal Health — ألوان بنفسجية أفتح */
body {
  background: #454056;
  color: #faf6ff;
}

#chapter-body .topic {
  background: #514a63;
  border-color: #786d8b;
}

#chapter-body .topic-heading h3 {
  color: #f0d7ff;
}

#chapter-body .topic-heading p {
  color: #e6dcef;
}

#chapter-body .pair {
  background: #5d556f;
  border-color: #80748f;
}

#chapter-body .pair p[lang="en"] {
  color: #fffaff;
}

#chapter-body .pair .translation {
  color: #f0e7f6;
}

#chapter-body .contents {
  background: #514a63;
  border-color: #786d8b;
  color: #faf6ff;
}

#chapter-body .contents a {
  color: #f0d7ff;
}

.chapter-nav button {
  background: #625974;
  border-color: #8c7d9e;
  color: #fffaff;
}

.chapter-nav button[aria-pressed="true"] {
  background: #e5c9f5;
  border-color: #f2ddff;
  color: #362541;
  box-shadow: 0 4px 16px #2c20394d;
}

.chapter-nav button:focus-visible {
  outline-color: #f2ddff;
}

:root {
  --bg: #454056;
  --surface: #514a63;
  --raised: #625974;
  --line: #786d8b;
  --text: #faf6ff;
  --muted: #e6dcef;
}

body {
  background: var(--bg);
  color: var(--text);
}

.chapter-nav {
  background: var(--surface);
}

.reader-header {
  background: linear-gradient(115deg, #625974, #514a63);
}