/* ==========================================================================
   دراسة بوليفيا — جمعية أصول
   ورقة أنماط واحدة، بلا مكتبات خارجية وبلا @import
   ========================================================================== */

/* --------------------------------------------------------------------------
   1) الرموز التصميمية (Design Tokens)
   -------------------------------------------------------------------------- */
:root {
  /* ألوان الهوية: تراب الأنديز + أخضر بترولي + عاجي */
  --c-bg:            #fbf7f0;
  --c-bg-alt:        #f4ece0;
  --c-surface:       #ffffff;
  --c-ink:           #221c15;
  --c-ink-soft:      #4a4034;
  --c-muted:         #6b6153;
  --c-line:          #e2d6c4;
  --c-brand:         #0f4c4a;   /* أخضر بترولي داكن */
  --c-brand-soft:    #d8e6e3;
  --c-accent:        #b4491f;   /* تراكوتا */
  --c-accent-soft:   #f7e2d7;
  --c-gold:          #a8781f;
  --c-ok:            #1f6b4f;
  --c-warn:          #8a5a00;

  /* الخطوط: خطان فقط + بدائل النظام */
  --f-title: "Amiri", "Scheherazade New", "Times New Roman", serif;
  --f-body: "Noto Naskh Arabic", "Segoe UI", Tahoma, system-ui, -apple-system, sans-serif;

  /* المقاسات */
  --fs-base: 17px;
  --lh: 1.95;
  --w-page: 1180px;
  --w-text: 74ch;
  --r-sm: 6px;
  --r-md: 12px;
  --r-lg: 20px;
  --sp: 1rem;
  --shadow: 0 1px 2px rgba(34,28,21,.05), 0 8px 28px rgba(34,28,21,.06);
}

/* --------------------------------------------------------------------------
   2) الأساسيات
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--f-body);
  font-size: var(--fs-base);
  line-height: var(--lh);
  color: var(--c-ink);
  background-color: var(--c-bg);
  background-image:
    radial-gradient(circle at 12% 4%, rgba(15,76,74,.05), transparent 42%),
    radial-gradient(circle at 88% 22%, rgba(180,73,31,.05), transparent 40%);
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
}

p { margin: 0 0 1.05em; max-width: var(--w-text); }
ul, ol { margin: 0 0 1.15em; padding-inline-start: 1.35em; max-width: var(--w-text); }
li { margin-bottom: .5em; }
strong { color: var(--c-brand); font-weight: 700; }
abbr[title] { text-decoration: underline dotted; cursor: help; }

a { color: var(--c-brand); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--c-accent); }
a:focus-visible,
summary:focus-visible,
details:focus-visible {
  outline: 3px solid var(--c-accent);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}

img { max-width: 100%; height: auto; display: block; }

/* --------------------------------------------------------------------------
   3) العناوين
   -------------------------------------------------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--f-title);
  line-height: 1.45;
  color: var(--c-ink);
  margin: 0 0 .5em;
  font-weight: 700;
}
h1 { font-size: clamp(2rem, 5.2vw, 3.5rem); letter-spacing: -.01em; }
h2 { font-size: clamp(1.6rem, 3.4vw, 2.35rem); }
h3 { font-size: clamp(1.22rem, 2.2vw, 1.5rem); color: var(--c-brand); }
h4 { font-size: 1.08rem; color: var(--c-accent); }

/* --------------------------------------------------------------------------
   4) التخطيط العام
   -------------------------------------------------------------------------- */
.wrap { width: min(100% - 2.5rem, var(--w-page)); margin-inline: auto; }

.section {
  padding-block: clamp(2.6rem, 6vw, 4.6rem);
  border-top: 1px solid var(--c-line);
}
.section:first-of-type { border-top: 0; }
.section > .wrap > p,
.section > .wrap > ul,
.section > .wrap > ol { color: var(--c-ink-soft); }

/* رقم الفصل + عنوانه */
.sec-head { margin-bottom: 1.8rem; }
.sec-num {
  display: inline-block;
  font-family: var(--f-title);
  font-size: .82rem;
  letter-spacing: .22em;
  color: var(--c-accent);
  background: var(--c-accent-soft);
  border-radius: 999px;
  padding: .2rem .9rem;
  margin-bottom: .7rem;
}
/* ملخص الفصل */
.sec-lede {
  font-size: 1.08rem;
  color: var(--c-ink-soft);
  border-inline-start: 4px solid var(--c-brand);
  padding-inline-start: 1rem;
  max-width: 72ch;
  margin-bottom: 1.8rem;
}

/* --------------------------------------------------------------------------
   5) أسلوب الفرشاة (Brush) — فواصل وخلفيات عناوين واقتباسات
   -------------------------------------------------------------------------- */
.brush h2 {
  display: inline-block;
  position: relative;
  padding: .1em .55em;
}
.brush h2::before {
  content: "";
  position: absolute;
  inset: 32% -.15em 8% -.15em;
  background: linear-gradient(97deg, rgba(216,230,227,.95), rgba(247,226,215,.85));
  border-radius: 40% 60% 55% 45% / 60% 40% 60% 40%;
  z-index: -1;
}
.brush-rule {
  height: 14px;
  border: 0;
  margin: 2.4rem 0;
  background:
    radial-gradient(ellipse 46% 70% at 12% 50%, var(--c-accent) 0 60%, transparent 61%),
    radial-gradient(ellipse 34% 55% at 40% 50%, var(--c-brand) 0 60%, transparent 61%),
    radial-gradient(ellipse 26% 42% at 66% 50%, var(--c-gold) 0 60%, transparent 61%),
    radial-gradient(ellipse 18% 30% at 86% 50%, var(--c-accent) 0 60%, transparent 61%);
  opacity: .55;
}
blockquote {
  margin: 1.8rem 0;
  padding: 1.4rem 1.6rem;
  background: var(--c-brand-soft);
  border-radius: var(--r-lg) var(--r-sm) var(--r-lg) var(--r-sm);
  font-family: var(--f-title);
  font-size: 1.14rem;
  color: #10332f;
  max-width: 70ch;
}
blockquote p:last-child { margin-bottom: 0; }
blockquote cite { display: block; margin-top: .7rem; font-size: .88rem; font-style: normal; color: var(--c-muted); font-family: var(--f-body); }

/* --------------------------------------------------------------------------
   6) رابط التخطي وشريط التنقل اللاصق
   -------------------------------------------------------------------------- */
.skip-link {
  position: absolute;
  inset-inline-start: 1rem;
  top: -100px;
  z-index: 200;
  background: var(--c-brand);
  color: #fff;
  padding: .7rem 1.2rem;
  border-radius: 0 0 var(--r-md) var(--r-md);
  transition: top .15s ease-in;
}
.skip-link:focus { top: 0; color: #fff; }

.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(251,247,240,.94);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--c-line);
}
.navbar .wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 60px;
  flex-wrap: wrap;
}
.nav-brand {
  font-family: var(--f-title);
  font-weight: 700;
  color: var(--c-brand);
  text-decoration: none;
  white-space: nowrap;
}
.nav-links {
  display: flex;
  gap: .2rem;
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-x: auto;
  scrollbar-width: thin;
  max-width: 100%;
}
.nav-links li { margin: 0; }
.nav-links a {
  display: block;
  padding: .45rem .7rem;
  font-size: .93rem;
  color: var(--c-ink-soft);
  text-decoration: none;
  border-radius: var(--r-sm);
  white-space: nowrap;
}
.nav-links a:hover { background: var(--c-brand-soft); color: var(--c-brand); }

/* زر القائمة (يظهر في الشاشات الصغيرة فقط) */
.nav-toggle-input { position: absolute; opacity: 0; pointer-events: none; }
.nav-toggle { display: none; }
.nav-toggle .bars,
.nav-toggle .bars::before,
.nav-toggle .bars::after {
  display: block; width: 18px; height: 2px; background: currentColor; border-radius: 2px;
}
.nav-toggle .bars { position: relative; }
.nav-toggle .bars::before, .nav-toggle .bars::after { content: ""; position: absolute; inset-inline-start: 0; }
.nav-toggle .bars::before { top: -6px; }
.nav-toggle .bars::after { top: 6px; }

@media (max-width: 760px) {
  .navbar .wrap { flex-wrap: nowrap; gap: .5rem; justify-content: space-between; }
  .nav-toggle {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .5rem .8rem; border: 1px solid var(--c-line); border-radius: var(--r-sm);
    color: var(--c-brand); background: var(--c-brand-soft);
    font-family: var(--f-title); font-size: .95rem; cursor: pointer;
  }
  .nav-toggle:focus-visible { outline: 3px solid var(--c-brand); outline-offset: 2px; }
  .nav-links {
    display: none;
    overflow-x: visible;
    flex-basis: 100%;
    flex-direction: column;
    gap: 0;
    max-height: 65vh;
    overflow-y: auto;
    padding-block: .4rem .8rem;
    border-top: 1px solid var(--c-line);
  }
  .nav-toggle-input:checked ~ .nav-links { display: flex; }
  .nav-links a { padding: .7rem .4rem; font-size: 1rem; border-bottom: 1px solid var(--c-line); }
}

/* --------------------------------------------------------------------------
   7) الغلاف
   -------------------------------------------------------------------------- */
.cover { position: relative; padding-block: 0; border: 0; background: #241d16; }
.cover-media { position: relative; }
.cover-media img {
  width: 100%;
  height: clamp(200px, 34vh, 360px);
  object-fit: cover;
}
.cover-media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(34,28,21,.95) 4%, rgba(34,28,21,.3) 70%, rgba(34,28,21,.12));
}
.cover-text {
  position: relative;
  margin-top: 0;
  padding-block: 1.8rem 2.4rem;
  z-index: 2;
  color: #fff5e9;
}

.cover-text h1 { color: #fff8ee; text-shadow: 0 2px 18px rgba(0,0,0,.5); margin-bottom: .3em; }
.cover-kicker {
  display: inline-block;
  font-size: .86rem;
  letter-spacing: .2em;
  background: rgba(255,248,238,.16);
  border: 1px solid rgba(255,248,238,.4);
  padding: .3rem 1rem;
  border-radius: 999px;
  margin-bottom: 1rem;
}
.cover-sub { color: #f0e2cf; font-size: 1.1rem; max-width: 62ch; text-shadow: 0 1px 10px rgba(0,0,0,.5); }
.cover-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem;
  list-style: none;
  padding: 0;
  margin: 1.4rem 0 2.6rem;
  font-size: .95rem;
  color: #f6ead9;
}
.cover-meta li { margin: 0; }
/* ضمان بياض النص فوق صورة الغلاف */
.cover-text,
.cover-text *,
.cover-meta strong,
.cover-meta b,
.cover-sub strong { color: #ffffff !important; }
.cover-text { text-shadow: 0 1px 12px rgba(0,0,0,.55); }
.cover-meta strong { font-weight: 700; opacity: .9; }


/* --------------------------------------------------------------------------
   8) البطاقات والشبكات
   -------------------------------------------------------------------------- */
.grid { display: grid; gap: 1.1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); }

.card {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
}
.card h3, .card h4 { margin-top: 0; }
.card p:last-child, .card ul:last-child { margin-bottom: 0; }

/* بطاقة رقم */
.stat {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-top: 4px solid var(--c-brand);
  border-radius: var(--r-md);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow);
}
.stat.is-accent { border-top-color: var(--c-accent); }
.stat.is-gold { border-top-color: var(--c-gold); }
.stat-value {
  font-family: var(--f-title);
  font-size: clamp(1.65rem, 3.4vw, 2.2rem);
  font-weight: 700;
  color: var(--c-brand);
  line-height: 1.25;
  display: block;
}
.stat.is-accent .stat-value { color: var(--c-accent); }
.stat.is-gold .stat-value { color: var(--c-gold); }
.stat-label { display: block; font-size: .95rem; color: var(--c-ink-soft); margin-top: .15rem; }
.stat-src { display: block; font-size: .78rem; color: var(--c-muted); margin-top: .55rem; }

/* قائمة بطاقة الدولة */
.dl-facts { margin: 0; }
.dl-facts div {
  display: grid;
  grid-template-columns: minmax(140px, 34%) 1fr;
  gap: .6rem 1rem;
  padding: .62rem 0;
  border-bottom: 1px dashed var(--c-line);
}
.dl-facts div:last-child { border-bottom: 0; }
.dl-facts dt { font-weight: 700; color: var(--c-brand); }
.dl-facts dd { margin: 0; color: var(--c-ink-soft); }

/* --------------------------------------------------------------------------
   9) فهرس المحتويات
   -------------------------------------------------------------------------- */
.toc ol {
  list-style: none;
  padding: 0;
  margin: 0;
  max-width: none;
  columns: 2;
  column-gap: 2.2rem;
}
.toc li { break-inside: avoid; margin-bottom: .18rem; }
.toc a {
  display: flex;
  gap: .6rem;
  align-items: baseline;
  padding: .42rem .6rem;
  border-radius: var(--r-sm);
  text-decoration: none;
  color: var(--c-ink-soft);
  border-bottom: 1px dotted var(--c-line);
}
.toc a:hover { background: var(--c-brand-soft); color: var(--c-brand); }
.toc .n { font-family: var(--f-title); color: var(--c-accent); font-size: .85rem; min-width: 2ch; }

/* --------------------------------------------------------------------------
   10) الجداول
   -------------------------------------------------------------------------- */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  background: var(--c-surface);
  margin-bottom: 1.4rem;
}
table { width: 100%; border-collapse: collapse; font-size: .96rem; min-width: 460px; }
caption {
  caption-side: top;
  text-align: start;
  padding: .85rem 1rem;
  font-weight: 700;
  color: var(--c-brand);
  background: var(--c-bg-alt);
  border-bottom: 1px solid var(--c-line);
}
thead th {
  background: var(--c-brand);
  color: #fff;
  text-align: start;
  padding: .7rem .9rem;
  font-weight: 700;
  font-size: .93rem;
}
tbody th { text-align: start; font-weight: 700; color: var(--c-ink); }
td, tbody th { padding: .68rem .9rem; border-top: 1px solid var(--c-line); vertical-align: top; }
tbody tr:nth-child(even) { background: #fcf9f4; }

/* --------------------------------------------------------------------------
   11) أشرطة النسب
   -------------------------------------------------------------------------- */
.bars { list-style: none; padding: 0; margin: 0 0 1.2rem; max-width: 62ch; }
.bars li { margin-bottom: .9rem; }
.bar-top { display: flex; justify-content: space-between; gap: 1rem; font-size: .95rem; margin-bottom: .28rem; }
.bar-top b { color: var(--c-brand); font-variant-numeric: tabular-nums; }
.bar-track {
  height: 12px;
  background: var(--c-bg-alt);
  border: 1px solid var(--c-line);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill { height: 100%; background: var(--c-brand); border-radius: 999px; }
.bar-fill.is-accent { background: var(--c-accent); }
.bar-fill.is-gold { background: var(--c-gold); }
.bar-fill.is-muted { background: #8b8577; }

/* --------------------------------------------------------------------------
   12) الصور والتعليقات
   -------------------------------------------------------------------------- */
figure {
  margin: 1.8rem 0;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow);
}
figure { max-width: 560px; margin-inline: auto; }
figure img { width: 100%; aspect-ratio: 16 / 9; max-height: 300px; object-fit: cover; }
figcaption { padding: .85rem 1.1rem; font-size: .9rem; color: var(--c-ink-soft); }
figcaption .src { display: block; color: var(--c-muted); font-size: .8rem; margin-top: .25rem; }

/* --------------------------------------------------------------------------
   13) الرسوم SVG
   -------------------------------------------------------------------------- */
.chart {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  padding: 1.15rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.4rem;
}
.chart svg { width: 100%; height: auto; display: block; }
.chart-note { font-size: .9rem; color: var(--c-ink-soft); margin: .9rem 0 0; max-width: 66ch; }

/* --------------------------------------------------------------------------
   14) SWOT ومصفوفة الأولويات
   -------------------------------------------------------------------------- */
.swot { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 1rem; }
.swot .card { border-top-width: 4px; border-top-style: solid; }
.swot .s { border-top-color: var(--c-ok); }
.swot .w { border-top-color: var(--c-accent); }
.swot .o { border-top-color: var(--c-brand); }
.swot .t { border-top-color: var(--c-warn); }
.swot h3 { margin-bottom: .5rem; }

.prio { list-style: none; padding: 0; margin: 0; }
.prio li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: .8rem;
  align-items: center;
  padding: .8rem .95rem;
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  background: var(--c-surface);
  margin-bottom: .6rem;
}
.rank {
  font-family: var(--f-title);
  font-size: 1.1rem;
  width: 2.1rem; height: 2.1rem;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--c-brand); color: #fff;
}
.tag {
  font-size: .8rem;
  padding: .18rem .7rem;
  border-radius: 999px;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.tag.hi { color: #8f2f0f; background: var(--c-accent-soft); }
.tag.mid { color: #7a5900; background: #fbf0d5; }
.tag.low { color: #12594a; background: var(--c-brand-soft); }

/* --------------------------------------------------------------------------
   15) الخط الزمني
   -------------------------------------------------------------------------- */
.timeline { list-style: none; margin: 0; padding: 0; border-inline-start: 3px solid var(--c-line); }
.timeline li { position: relative; padding: 0 1.6rem 1.4rem; }
.timeline li::before {
  content: "";
  position: absolute;
  inset-inline-start: -9px;
  top: .55rem;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--c-accent);
  border: 3px solid var(--c-bg);
}
.timeline time { display: block; font-family: var(--f-title); color: var(--c-brand); font-weight: 700; }

/* --------------------------------------------------------------------------
   16) details / summary وأدوات مساعدة
   -------------------------------------------------------------------------- */
details {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  padding: .35rem 1.1rem;
  margin-bottom: .75rem;
}
details[open] { padding-bottom: .9rem; }
summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--c-brand);
  padding: .8rem 0;
  list-style-position: inside;
}
summary::marker { color: var(--c-accent); }
details > *:not(summary) { color: var(--c-ink-soft); }

.review-flag {
  display: inline-block;
  font-size: .76rem;
  color: #7a4a00;
  background: #fbf0d5;
  border: 1px dashed #d8b45e;
  border-radius: var(--r-sm);
  padding: .05rem .5rem;
  margin-inline-start: .35rem;
  white-space: nowrap;
}

.callout {
  background: var(--c-bg-alt);
  border: 1px solid var(--c-line);
  border-inline-start: 5px solid var(--c-gold);
  border-radius: var(--r-md);
  padding: 1.1rem 1.25rem;
  margin: 1.5rem 0;
}
.callout p:last-child { margin-bottom: 0; }

.to-top {
  display: inline-block;
  margin-top: 1.6rem;
  font-size: .88rem;
  color: var(--c-muted);
  text-decoration: none;
  border: 1px solid var(--c-line);
  border-radius: 999px;
  padding: .3rem .95rem;
  background: var(--c-surface);
}
.to-top:hover { border-color: var(--c-accent); color: var(--c-accent); }

.refs { list-style: none; padding: 0; counter-reset: r; font-size: .93rem; max-width: none; }
.refs li {
  counter-increment: r;
  display: grid;
  grid-template-columns: 2.6rem 1fr;
  gap: .5rem;
  padding: .5rem 0;
  border-bottom: 1px dotted var(--c-line);
  color: var(--c-ink-soft);
  overflow-wrap: anywhere;
}
.refs li::before {
  content: "[" counter(r) "]";
  color: var(--c-accent);
  font-family: var(--f-title);
}

.footer {
  background: var(--c-brand);
  color: #e7f0ee;
  padding-block: 2.4rem;
  margin-top: 2rem;
}
.footer a { color: #fff; }
.footer address { font-style: normal; }
.footer p { color: #d6e3e0; max-width: none; }

/* --------------------------------------------------------------------------
   17) الاستجابة للشاشات
   -------------------------------------------------------------------------- */
@media (max-width: 760px) {
  :root { --fs-base: 17px; --lh: 1.85; }
  .toc ol { columns: 1; }
  .cover-media img { height: 30vh; }
  .chapter-nav { flex-direction: column; align-items: flex-start; }
  .dl-facts div { grid-template-columns: 1fr; gap: .1rem; }
  .prio li { grid-template-columns: auto 1fr; }
  .prio .tag { grid-column: 2; justify-self: start; }
}

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

/* --------------------------------------------------------------------------
   18) الطباعة — كتيب A4
   -------------------------------------------------------------------------- */
@media print {
  @page {
    size: A4 portrait;
    margin: 18mm 16mm 20mm;
  }
  html { scroll-behavior: auto; font-size: 11pt; }
  body {
    background: #fff !important;
    color: #000;
    font-size: 11pt;
    line-height: 1.6;
  }
  .navbar, .skip-link, .to-top, .toc, .nav-links { display: none !important; }
  .wrap { width: auto; }

  .section {
    break-before: page;
    border-top: 0;
    padding-block: 0 8mm;
  }
  .cover { break-after: page; }
  .cover-text { margin-top: 6mm; color: #000; }
  .cover-text h1, .cover-sub, .cover-meta { color: #000; text-shadow: none; }
  .cover-media::after { display: none; }
  .cover-media img { height: 70mm; }

  h1, h2, h3, h4 { break-after: avoid; color: #000; }
  p, li { orphans: 3; widows: 3; }
  .card, .stat, figure, table, .chart, blockquote, .prio li, details, .callout {
    break-inside: avoid;
    box-shadow: none;
    background: #fff !important;
  }
  thead { display: table-header-group; }
  thead th { background: #e8e8e8 !important; color: #000; border: 1px solid #999; }
  td, tbody th { border: 1px solid #bbb; }
  .brush h2::before { display: none; }
  .bar-fill { background: #555 !important; }
  details { border: 1px solid #ccc; }
  details > *:not(summary) { display: block !important; }

  /* إظهار الروابط كنص */
  .refs a::after,
  .print-url a::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    color: #333;
    word-break: break-all;
  }
  a { color: #000; text-decoration: none; }
}


/* --------------------------------------------------------------------------
   18) تنقل الفصول ووضع الكتاب
   -------------------------------------------------------------------------- */
.chapter-nav {
  display: flex;
  flex-wrap: wrap;
  gap: .7rem;
  align-items: center;
  justify-content: space-between;
  margin-top: 2.2rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--c-line);
}
.chapter-nav a {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .88rem;
  text-decoration: none;
  border: 1px solid var(--c-line);
  border-radius: 999px;
  padding: .35rem .95rem;
  background: var(--c-surface);
  color: var(--c-ink-soft);
}
.chapter-nav a:hover { border-color: var(--c-brand); color: var(--c-brand); }
.chapter-nav .up-link { background: var(--c-brand); color: #fff; border-color: var(--c-brand); }
.chapter-nav .up-link:hover { color: #fff; opacity: .9; }
.chapter-nav .pg-group { display: flex; flex-wrap: wrap; gap: .5rem; }
.chapter-nav .pg { display: none; }

.mode-input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.mode-bar { display: flex; justify-content: flex-end; padding: .5rem 1.2rem 0; }
.mode-toggle {
  cursor: pointer;
  font-size: .85rem;
  border: 1px solid var(--c-line);
  background: var(--c-surface);
  color: var(--c-ink-soft);
  border-radius: 999px;
  padding: .35rem 1rem;
}
.mode-toggle:hover { border-color: var(--c-brand); color: var(--c-brand); }
.mode-input:focus-visible + .mode-bar .mode-toggle { outline: 2px solid var(--c-brand); outline-offset: 2px; }
.mode-toggle .lbl-off { display: none; }
.mode-input:checked + .mode-bar .mode-toggle .lbl-on { display: none; }
.mode-input:checked + .mode-bar .mode-toggle .lbl-off { display: inline; }

#book-mode:checked ~ main .section { display: none; }
#book-mode:checked ~ main .section:target { display: block; }
#book-mode:checked ~ main:not(:has(.section:target)) > #cover,
#book-mode:checked ~ main:not(:has(.section:target)) > #toc { display: block; }
#book-mode:checked ~ main .chapter-nav .pg { display: inline-flex; }

@media print {
  .mode-bar, .chapter-nav { display: none !important; }
  .section { display: block !important; }
}

/* --------------------------------------------------------------------------
   14) مؤشر التقدم + زر العودة العائم (CSS فقط)
   -------------------------------------------------------------------------- */
.read-progress {
  position: fixed;
  inset-block-start: 0;
  inset-inline: 0;
  height: 4px;
  background: rgba(36, 29, 22, .14);
  z-index: 200;
  pointer-events: none;
}
.read-progress-bar {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: right center;
  transform: scaleX(0);
  background: linear-gradient(to left, var(--c-brand, #3c5a4a), var(--c-accent, #b4682c));
}

.fab-top {
  position: fixed;
  inset-block-end: 1.1rem;
  right: 1.1rem;
  z-index: 210;
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  font-size: 1.35rem;
  line-height: 1;
  text-decoration: none;
  color: #ffffff;
  background: #241d16;
  border: 2px solid rgba(255, 255, 255, .85);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
  transition: transform .18s ease, background-color .18s ease, opacity .25s ease;
}
.fab-top:hover { background: var(--c-brand, #3c5a4a); transform: translateY(-2px); color: #fff; }
.fab-top:focus-visible {
  outline: 3px solid var(--c-accent, #b4682c);
  outline-offset: 3px;
  background: var(--c-brand, #3c5a4a);
}
.up-link:focus-visible,
.chapter-nav a:focus-visible,
.to-top:focus-visible {
  outline: 3px solid var(--c-accent, #b4682c);
  outline-offset: 3px;
  border-radius: 6px;
}

/* يظهر عند التمرير فقط، ويتقدم شريط القراءة — بلا جافاسكربت */
@supports (animation-timeline: scroll()) {
  .read-progress-bar {
    animation: progress-grow linear both;
    animation-timeline: scroll(root block);
  }
  .fab-top {
    opacity: 0;
    visibility: hidden;
    animation: fab-reveal linear both;
    animation-timeline: scroll(root block);
    animation-range: 220px 420px;
  }
  .fab-top:focus-visible { opacity: 1; visibility: visible; }
}
@keyframes progress-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes fab-reveal { from { opacity: 0; visibility: hidden; } to { opacity: 1; visibility: visible; } }

@media (prefers-reduced-motion: reduce) {
  .fab-top { transition: none; }
}
@media print {
  .read-progress, .fab-top { display: none !important; }
}

/* --------------------------------------------------------------------------
   15) تحسين تباين نص الغلاف
   -------------------------------------------------------------------------- */
.cover-media::after {
  background:
    linear-gradient(to top, rgba(20, 16, 12, .97) 0%, rgba(20, 16, 12, .72) 45%, rgba(20, 16, 12, .28) 100%);
}
.cover-text {
  background: linear-gradient(to bottom, rgba(20, 16, 12, .92), rgba(20, 16, 12, .98));
  padding-block: 1.6rem 2.2rem;
}
.cover-text h1 {
  font-size: clamp(1.5rem, 4.2vw, 2.6rem);
  line-height: 1.25;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .85);
}
.cover-sub {
  font-size: clamp(.98rem, 2.4vw, 1.1rem);
  line-height: 1.85;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .8);
}
.cover-kicker { font-size: clamp(.74rem, 2vw, .86rem); letter-spacing: .14em; }
.cover-meta { gap: .7rem 1.2rem; margin-block: 1.1rem 1.4rem; font-size: clamp(.85rem, 2.2vw, .95rem); }

@media (max-width: 640px) {
  .cover-media img { height: clamp(160px, 26vh, 240px); }
  .cover-text { padding-block: 1.2rem 1.6rem; }
  .cover-meta { flex-direction: column; }
  .fab-top { width: 2.75rem; height: 2.75rem; inset-block-end: .8rem; right: .8rem; }
}
