/* ============================================================
   توحيد عرض الكتب — salemalnuaimi.ae
   يُضاف في آخر ملف الأنماط الرئيسي (أو داخل <style> في /book والرئيسية)
   الألوان مأخوذة من الموقع الحالي: الخلفية #faf7ef، الأخضر #17362c، الذهبي #c6a15b
   ============================================================ */

:root {
  --sa-ink: #17362c;
  --sa-gold: #c6a15b;
  --sa-cream: #faf7ef;
  --sa-paper: #ffffff;
  --sa-muted: #5b6b63;
}

/* ---------- رف «مؤلفاتي» ---------- */
.books-shelf {
  max-width: 1180px;
  margin: 0 auto;
  padding: 64px 24px 40px;
  direction: rtl;
  font-family: Amiri, "Traditional Arabic", "Times New Roman", serif;
  color: var(--sa-ink);
}
.books-shelf .shelf-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.books-shelf .shelf-head h1,
.books-shelf .shelf-head h2 {
  margin: 4px 0 6px;
  font-size: calc(clamp(28px, 4vw, 40px) * var(--text-scale, 1));
  line-height: 1.3;
}
.books-shelf .shelf-head p {
  margin: 0;
  color: var(--sa-muted);
  font-size: calc(18px * var(--text-scale, 1));
  max-width: 640px;
}
.books-shelf .shelf-count {
  border: 1px solid var(--sa-gold);
  color: var(--sa-ink);
  padding: 4px 14px;
  border-radius: 999px;
  font-size: calc(15px * var(--text-scale, 1));
  white-space: nowrap;
}
.books-shelf .shelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 24px;
}
.shelf-card {
  background: var(--sa-paper);
  border-top: 3px solid var(--sa-gold);
  border-radius: 8px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 1px 0 rgba(23, 54, 44, 0.06);
}
.shelf-card .shelf-cover {
  display: block;
  aspect-ratio: 3 / 4;
  border-radius: 6px;
  overflow: hidden;
  background: var(--sa-cream);
}
.shelf-card .shelf-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.shelf-card .shelf-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: calc(14px * var(--text-scale, 1));
}
.shelf-card .shelf-type {
  color: var(--sa-gold);
  font-weight: 700;
}
.shelf-card .shelf-status {
  border-radius: 999px;
  padding: 1px 10px;
  font-size: calc(13px * var(--text-scale, 1));
}
.shelf-status.is-published { background: #e8f0ec; color: var(--sa-ink); }
.shelf-status.is-soon      { background: #f6ecd8; color: #7a5a1c; }
.shelf-card h3 {
  margin: 0;
  font-size: calc(22px * var(--text-scale, 1));
  line-height: 1.5;
}
.shelf-card p {
  margin: 0;
  color: var(--sa-muted);
  font-size: calc(16px * var(--text-scale, 1));
  line-height: 1.8;
  flex: 1;
}
.shelf-card .shelf-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.shelf-card .shelf-btn {
  display: inline-block;
  padding: 8px 18px;
  border-radius: 6px;
  text-decoration: none;
  font-size: calc(16px * var(--text-scale, 1));
  background: var(--sa-ink);
  color: #fff;
}
.shelf-card .shelf-btn.secondary {
  background: transparent;
  color: var(--sa-ink);
  border: 1px solid var(--sa-gold);
}
.shelf-card .shelf-btn:focus-visible { outline: 2px solid var(--sa-gold); outline-offset: 2px; }

/* ---------- بطاقات فصول الكتاب الثاني: تعيد استخدام .chapter-card الموجودة ---------- */
/* فقط ضبط بسيط لأن الكتاب الثاني فيه 12 فصلاً */
#second-book-chapters .chapters-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
}
#second-book-chapters .chapter-page {
  margin-inline-start: auto;
  font-size: calc(13px * var(--text-scale, 1));
  color: var(--sa-muted);
}

/* ---------- جدول بيانات الكتاب الثالث (نفس شكل جدول الكتابين) ---------- */
.book-facts {
  border-top: 2px solid var(--sa-gold);
  margin: 18px 0;
  padding: 0;
  list-style: none;
  max-width: 420px;
}
.book-facts li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(23, 54, 44, 0.12);
  font-size: calc(16px * var(--text-scale, 1));
}
.book-facts li span:first-child { color: var(--sa-muted); }

/* ---------- توحيد مكان الغلاف: الغلاف دائماً في جهة اليمين كالكتاب الأول ---------- */
/* إذا كان قسم الكتاب الثاني يستخدم grid أو flex فهذا يعيد الغلاف لجهة البداية */
#second-book .book-cover-wrap,
#second-book figure:first-of-type {
  order: -1;
}

@media (max-width: 640px) {
  .books-shelf { padding: 40px 16px 24px; }
  .shelf-card { padding: 18px; }
}

/* Preserve whole covers, narrow screens, and existing dark mode. */
.books-shelf .shelf-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
.shelf-card{min-width:0}.shelf-card .shelf-cover img{object-fit:contain}
#second-book .second-book-cover{order:-1}
#second-book-chapters .chapter-top{flex-wrap:wrap}
#second-book-chapters .chapter-card:last-child{grid-column:auto}
html[data-theme=dark] .books-shelf{--sa-ink:#edf0e7;--sa-paper:#1b2e25;--sa-cream:#14251d;--sa-muted:#c9d7cb}
html[data-theme=dark] .shelf-btn:not(.secondary){background:#c6a15b;color:#14251d}
@media(max-width:800px){.books-shelf .shelf-grid{grid-template-columns:1fr}}
@media(max-width:360px){#second-book-chapters .chapters-grid{grid-template-columns:minmax(0,1fr)}}
@media(min-width:701px){#second-book .second-book-layout{grid-template-columns:minmax(220px,340px) minmax(0,1fr)}}
