/* ===== الخطوط ===== */
@font-face {
  font-family: "Noto Kufi Arabic";
  src: url("/fonts/noto-kufi-arabic-arabic-wght-normal.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "Noto Kufi Arabic";
  src: url("/fonts/noto-kufi-arabic-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Noto Naskh Arabic";
  src: url("/fonts/noto-naskh-arabic-arabic-wght-normal.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "Noto Naskh Arabic";
  src: url("/fonts/noto-naskh-arabic-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ===== الرموز ===== */
:root {
  --paper: #f5f6f0;
  --paper-2: #eaece3;
  --ink: #16231b;
  --ink-2: #4b5b50;
  --rule: #d3d8ca;
  --board: #1d3a2b;
  --board-2: #234636;
  --chalk: #eaf0e2;
  --chalk-2: #9fb3a3;
  --chalk-faint: #71907a;
  --chalk-line: rgba(234, 240, 226, 0.16);
  --leaf: #2d6a3e;
  --leaf-dark: #22532f;
  --gold: #e0ae2e;
  --red: #b3261e;

  --kufi: "Noto Kufi Arabic", "Noto Naskh Arabic", "Geeza Pro", Tahoma, sans-serif;
  --naskh: "Noto Naskh Arabic", "Geeza Pro", "Times New Roman", serif;

  --t-sm: 0.875rem;
  --t-base: 1.125rem;
  --t-md: 1.3125rem;
  --t-lg: 1.625rem;
  --t-xl: clamp(1.75rem, 1.4rem + 1.4vw, 2.25rem);
  --t-2xl: clamp(2.25rem, 1.6rem + 2.6vw, 3.5rem);
  --t-num: clamp(3.75rem, 2.2rem + 5.4vw, 7rem);

  --gutter: clamp(16px, 4vw, 40px);
  --r-btn: 6px;
  --r-img: 4px;
  color-scheme: light;
}

/* ===== الأساس ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--naskh);
  font-size: var(--t-base);
  line-height: 1.9;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
h1, h2, h3, h4 { font-family: var(--kufi); font-weight: 600; line-height: 1.35; margin: 0; }
p { margin: 0; }
a { color: var(--leaf); text-underline-offset: 0.3em; text-decoration-thickness: 1px; }
a:hover { color: var(--leaf-dark); text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
button { font: inherit; color: inherit; cursor: pointer; }
.wrap { width: 100%; max-width: 1200px; margin-inline: auto; padding-inline: var(--gutter); }
.narrow { max-width: 780px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; inset-inline-start: 16px; top: -100px; background: var(--ink); color: var(--paper); padding: 8px 16px; z-index: 50; font-family: var(--kufi); }
.skip:focus { top: 12px; }

/* ===== الرأس ===== */
.site-head { background: var(--paper); border-bottom: 1px solid var(--rule); position: relative; z-index: 20; }
.head-in { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 80px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.brand:hover { color: var(--ink); }
.brand img { width: auto; height: 52px; }
.brand-name { font-family: var(--kufi); font-weight: 600; font-size: 1.25rem; line-height: 1.25; }
.brand-name small { display: block; font-weight: 400; font-size: var(--t-sm); color: var(--ink-2); }
.nav { display: flex; gap: clamp(16px, 2.4vw, 32px); align-items: center; }
.nav a {
  font-family: var(--kufi); font-size: 1.0625rem; color: var(--ink-2); text-decoration: none;
  padding-block: 6px; border-bottom: 3px solid transparent;
}
.nav a:hover { color: var(--ink); border-bottom-color: var(--rule); }
.nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--gold); }
.menu { display: none; }

@media (max-width: 860px) {
  .head-in { min-height: 68px; }
  .brand img { height: 44px; }
  .brand-name { font-size: 0.9375rem; white-space: nowrap; }
  .brand-name small { font-size: 0.75rem; }
  .head-in > .nav { display: none; }
  .menu { display: block; }
  .menu summary {
    list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer;
    font-family: var(--kufi); font-size: 0.9375rem; padding: 8px 12px; border: 1px solid var(--rule); border-radius: var(--r-btn); flex: none;
    min-height: 44px;
  }
  .menu summary::-webkit-details-marker { display: none; }
  .menu svg { width: 20px; height: 20px; }
  .menu[open] summary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
  .menu .nav {
    position: absolute; inset-inline: 0; top: 100%;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--paper); border-bottom: 1px solid var(--rule); padding: 8px var(--gutter) 16px;
  }
  .menu .nav a { padding: 14px 0; border-bottom: 1px solid var(--rule); font-size: 1.125rem; }
  .menu .nav a:last-child { border-bottom: 0; }
  .menu .nav a[aria-current="page"] { border-bottom-color: var(--rule); color: var(--leaf); }
}

/* ===== السلايدر ===== */
.stage { position: relative; background: var(--ink); }
.stage-track {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth;
  scrollbar-width: none; overscroll-behavior-x: contain;
}
.stage-track::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 100%; scroll-snap-align: start; scroll-snap-stop: always; position: relative; margin: 0; }
.slide img { width: 100%; height: clamp(340px, 64vh, 640px); object-fit: cover; }
.slide figcaption {
  position: absolute; inset-inline-start: var(--gutter); bottom: 72px;
  width: min(480px, calc(100% - 2 * var(--gutter)));
  background: var(--paper); color: var(--ink); padding: 22px 26px 24px;
  border-inline-start: 6px solid var(--gold);
}
.slide h2 { font-size: var(--t-lg); }
.slide p { color: var(--ink-2); font-size: 1.0625rem; line-height: 1.8; margin-top: 6px; }
.slide figcaption a { display: inline-block; margin-top: 10px; font-family: var(--kufi); }
.stage-bar {
  position: absolute; bottom: 0; inset-inline: 0;
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 14px var(--gutter);
}
.stage-btn {
  width: 44px; height: 44px; display: grid; place-items: center;
  background: rgba(22, 35, 27, 0.78); color: var(--chalk); border: 1px solid rgba(234, 240, 226, 0.35); border-radius: var(--r-btn);
}
.stage-btn:hover { background: var(--ink); }
.stage-btn svg { width: 20px; height: 20px; }
.stage-count { direction: ltr; unicode-bidi: isolate; font-family: var(--kufi); color: var(--chalk); background: rgba(22, 35, 27, 0.78); padding: 8px 12px; border-radius: var(--r-btn); min-width: 64px; text-align: center; }
.stage[data-single] .stage-bar { display: none; }

@media (max-width: 760px) {
  .slide img { height: auto; aspect-ratio: 4 / 3; }
  .slide figcaption { position: static; width: auto; border-inline-start: 0; border-top: 5px solid var(--gold); padding: 18px var(--gutter) 76px; }
  .slide h2 { font-size: var(--t-md); }
  .stage-bar { background: var(--paper); border-top: 1px solid var(--rule); justify-content: space-between; }
  .stage-btn { background: var(--paper); color: var(--ink); border-color: var(--rule); }
  .stage-btn:hover { background: var(--paper-2); }
  .stage-count { background: transparent; color: var(--ink); order: -1; margin-inline-end: auto; text-align: start; padding-inline: 0; }
}

/* ===== رف الكتب ===== */
/* ألوان تجليد الصفوف: قماش كتب داكن متناسق */
.g1 { --c: #2f5d46; } .g2 { --c: #7a3b2e; } .g3 { --c: #2e4a6b; } .g4 { --c: #8a6a2b; }
.g5 { --c: #3c6e5f; } .g6 { --c: #6b3f5e; } .g7 { --c: #4f5b2a; } .g8 { --c: #8a4b2a; }
.g9 { --c: #2c5560; } .g10 { --c: #5a4636; } .g11 { --c: #34495e; } .g12 { --c: #6e2f3a; }

.library {
  background: var(--paper-2);
  padding-block: clamp(44px, 6vw, 80px) 0;
  border-bottom: 1px solid var(--rule);
  overflow: hidden;
}
.lib-title { font-size: var(--t-2xl); line-height: 1.15; margin-bottom: clamp(20px, 3vw, 36px); }
.resume { margin: -12px 0 20px; font-family: var(--kufi); color: var(--ink-2); font-size: var(--t-sm); }

.shelf {
  list-style: none; margin: 0; padding: 0 clamp(4px, 2vw, 28px);
  display: flex; align-items: flex-end; gap: clamp(4px, 0.7vw, 10px);
  height: clamp(300px, 30vw, 390px);
}
.shelf li { flex: 1 1 0; min-width: 0; height: 92%; }
/* أطوال مختلفة قليلاً كما على رف حقيقي */
.shelf li:nth-child(1) { height: 90%; } .shelf li:nth-child(2) { height: 84%; } .shelf li:nth-child(3) { height: 95%; }
.shelf li:nth-child(4) { height: 88%; } .shelf li:nth-child(5) { height: 100%; } .shelf li:nth-child(6) { height: 92%; }
.shelf li:nth-child(7) { height: 86%; } .shelf li:nth-child(8) { height: 97%; } .shelf li:nth-child(9) { height: 89%; }
.shelf li:nth-child(10) { height: 94%; } .shelf li:nth-child(11) { height: 87%; } .shelf li:nth-child(12) { height: 99%; }

.spine {
  position: relative; display: flex; flex-direction: column; align-items: center; height: 100%;
  padding: 16px 4px 14px; border-radius: 4px 4px 1px 1px;
  background-color: var(--c);
  /* نسيج قماش التجليد وظل الحافتين */
  background-image:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 3px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.22), transparent 18%, transparent 82%, rgba(255, 255, 255, 0.08));
  color: var(--chalk); text-decoration: none;
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.28s;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}
/* شريطان مذهّبان على الكعب */
.spine::before, .spine::after {
  content: ""; position: absolute; inset-inline: 7px; height: 5px;
  border-top: 1.5px solid rgba(224, 174, 46, 0.75); border-bottom: 1px solid rgba(224, 174, 46, 0.5);
}
.spine::before { top: 8px; }
.spine::after { bottom: 44px; }
.spine-label {
  margin-top: 12px; min-width: min(54px, 84%); padding: 4px 6px 2px;
  background: #f7f6ef; color: var(--ink); border-radius: 2px;
  font-family: var(--kufi); font-weight: 700; font-size: clamp(1.25rem, 0.6rem + 1.6vw, 2.125rem); line-height: 1.25; text-align: center;
  box-shadow: inset 0 0 0 1px rgba(22, 35, 27, 0.18);
}
.spine-title {
  /* هوامش فيزيائية: الكتابة العمودية تقلب معنى margin-block */
  writing-mode: vertical-rl; margin: 18px 0 auto;
  font-family: var(--kufi); font-weight: 600; font-size: clamp(0.8125rem, 0.5rem + 0.75vw, 1.125rem); white-space: nowrap; letter-spacing: 0.01em;
}
.spine-count { font-family: var(--kufi); font-size: 0.75rem; color: var(--gold); white-space: nowrap; margin-top: 10px; }
a.spine:hover, a.spine:focus-visible { transform: translateY(-16px); box-shadow: 0 18px 22px -14px rgba(22, 35, 27, 0.55); color: var(--chalk); }
a.spine:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.shelf li.is-mine a.spine { transform: translateY(-8px); }

/* مكان كتاب لم يُضف بعد: إطار متقطع */
.is-empty .spine {
  background: transparent; color: var(--ink-2); box-shadow: none;
  border: 1.5px dashed #a9b2a4;
}
.is-empty .spine::before, .is-empty .spine::after { border-color: #c3cabd; }
.is-empty .spine-label { background: transparent; color: #7f8b81; box-shadow: inset 0 0 0 1px #c3cabd; }
.is-empty .spine-count { color: #6f7c72; }

.plank {
  height: 18px; margin-inline: 0; position: relative;
  background: #4a3b2b; border-top: 4px solid #6e5940;
  box-shadow: 0 10px 18px -10px rgba(22, 35, 27, 0.6);
}

/* الهاتف: الكتب تنام فوق بعضها كومةً واحدة */
@media (max-width: 640px) {
  .library { padding-top: 36px; }
  .shelf { flex-direction: column; align-items: stretch; height: auto; gap: 3px; padding: 0; }
  .shelf li, .shelf li:nth-child(n) { height: auto; }
  .shelf li:nth-child(1) { margin-inline: 10px 2px; } .shelf li:nth-child(2) { margin-inline: 0 14px; }
  .shelf li:nth-child(3) { margin-inline: 6px 4px; } .shelf li:nth-child(4) { margin-inline: 14px 0; }
  .shelf li:nth-child(5) { margin-inline: 2px 10px; } .shelf li:nth-child(6) { margin-inline: 8px 6px; }
  .shelf li:nth-child(7) { margin-inline: 0 16px; } .shelf li:nth-child(8) { margin-inline: 12px 2px; }
  .shelf li:nth-child(9) { margin-inline: 4px 8px; } .shelf li:nth-child(10) { margin-inline: 16px 0; }
  .shelf li:nth-child(11) { margin-inline: 2px 12px; } .shelf li:nth-child(12) { margin-inline: 8px 4px; }
  .spine {
    flex-direction: row; align-items: center; height: 58px; padding: 0 16px 0 14px; border-radius: 2px 6px 6px 2px;
    background-image:
      repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 3px),
      linear-gradient(0deg, rgba(0, 0, 0, 0.22), transparent 30%, transparent 75%, rgba(255, 255, 255, 0.08));
  }
  .spine::before, .spine::after { inset-inline: auto; inset-block: 7px; width: 5px; height: auto; border-top: 0; border-bottom: 0; border-inline-start: 1.5px solid rgba(224, 174, 46, 0.75); border-inline-end: 1px solid rgba(224, 174, 46, 0.5); }
  .spine::before { top: 7px; inset-inline-start: 74px; }
  .spine::after { bottom: 7px; inset-inline-end: 12px; }
  .is-empty .spine::before, .is-empty .spine::after { border-color: #c3cabd; }
  .spine-label { margin: 0; min-width: 44px; font-size: 1.375rem; padding: 2px 6px 0; }
  .spine-title { writing-mode: horizontal-tb; margin: 0 26px 0 auto; font-size: 1rem; }
  .spine-count { margin: 0 0 0 18px; font-size: 0.8125rem; }
  a.spine:hover, a.spine:focus-visible { transform: translateX(-8px); }
  .shelf li.is-mine a.spine { transform: translateX(-6px); }
  .plank { height: 14px; margin-top: 3px; }
}

/* ===== أقسام عامة ===== */
.section { padding-block: clamp(48px, 7vw, 88px); }
.section + .section { border-top: 1px solid var(--rule); }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 24px; margin-bottom: 28px; }
.section-head h2 { font-size: var(--t-xl); }
.more { font-family: var(--kufi); font-size: 1.0625rem; }
.kind { font-family: var(--kufi); font-size: var(--t-sm); color: var(--leaf); font-weight: 600; }
.date { font-size: var(--t-sm); color: var(--ink-2); }
.meta { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; }

/* ===== الأخبار في الرئيسية ===== */
.news-home { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: clamp(28px, 4vw, 56px); }
.lead-item { text-decoration: none; color: inherit; display: block; }
.mat { background: var(--paper-2); border-radius: var(--r-img); overflow: hidden; display: grid; place-items: center; }
.mat img { max-width: 100%; height: auto; }
/* إطار بنسبة ثابتة: الصورة تظهر كاملة داخله دون قص */
.mat-wide, .mat-square, .mat-wide img, .mat-square img, .mat-wide { aspect-ratio: 16 / 10; }
.mat-square { aspect-ratio: 1; }
.lead-item h3 { font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); margin-top: 6px; }
.lead-item:hover h3 { color: var(--leaf); }
.lead-item p.sum { color: var(--ink-2); margin-top: 8px; }
.news-rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.news-row { border-bottom: 1px solid var(--rule); }
.news-row a { display: grid; grid-template-columns: 76px 1fr; gap: 16px; padding-block: 18px; text-decoration: none; color: inherit; }
.news-row a:hover h3 { color: var(--leaf); }
.news-row h3 { font-size: 1.1875rem; margin-top: 2px; }

@media (max-width: 860px) { .news-home { grid-template-columns: 1fr; } }

/* ===== عن المبادرة (شريط مختصر) ===== */
.about-band { display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); gap: clamp(28px, 5vw, 72px); align-items: start; }
.about-band h2 { font-size: var(--t-xl); margin-bottom: 14px; }
.about-band p { max-width: 60ch; }
.about-band .more { display: inline-block; margin-top: 16px; }
.values { list-style: none; margin: 0; padding: 0; }
.values li {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding-block: 12px; border-bottom: 1px solid var(--rule); font-family: var(--kufi); font-size: var(--t-md);
}
.values li:first-child { border-top: 1px solid var(--rule); }
.values-title { font-family: var(--kufi); color: var(--ink-2); margin-bottom: 8px; }
@media (max-width: 860px) { .about-band { grid-template-columns: 1fr; } }

/* ===== التذييل ===== */
.site-foot { background: var(--ink); color: #c9d3c4; padding-block: 48px 28px; font-size: 1rem; }
.foot-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 32px; }
.foot-brand { display: flex; gap: 14px; align-items: center; }
.foot-brand img { height: 64px; width: auto; }
.foot-brand b { font-family: var(--kufi); font-weight: 600; font-size: 1.25rem; color: var(--chalk); display: block; }
.site-foot h2 { font-size: 1rem; color: #8fa394; font-weight: 500; margin-bottom: 10px; }
.site-foot ul { list-style: none; margin: 0; padding: 0; }
.site-foot li { margin-bottom: 6px; }
.site-foot a { color: var(--chalk); text-decoration: none; }
.site-foot a:hover { color: var(--gold); text-decoration: underline; }
.foot-base { margin-top: 36px; padding-top: 20px; border-top: 1px solid rgba(234, 240, 226, 0.14); font-size: var(--t-sm); color: #8fa394; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
@media (max-width: 760px) { .foot-grid { grid-template-columns: 1fr; gap: 24px; } }

/* ===== صفحة الصف: غلاف الكتاب ثم الفهرس ===== */
.cover {
  position: relative; color: var(--chalk); background-color: var(--c);
  background-image:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.03) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.05) 0 1px, transparent 1px 4px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.18), transparent 30%);
}
.cover-in { position: relative; padding-top: 26px; }
/* إطار مذهّب كما على أغلفة الكتب */
.cover-in::before {
  content: ""; position: absolute; inset: 14px var(--gutter) 0; pointer-events: none;
  border: 1px solid rgba(224, 174, 46, 0.55); border-bottom: 0; box-shadow: inset 0 0 0 4px transparent, inset 0 0 0 5px rgba(224, 174, 46, 0.25);
}
.crumbs { position: relative; font-family: var(--kufi); font-size: var(--t-sm); padding-inline: 24px; }
.crumbs a { color: rgba(234, 240, 226, 0.8); }
.crumbs a:hover { color: var(--chalk); }
.cover-body { position: relative; display: flex; align-items: center; gap: clamp(18px, 3vw, 36px); padding: clamp(18px, 3vw, 34px) 24px clamp(28px, 4vw, 48px); }
.cover-plate {
  display: grid; place-items: center; min-width: clamp(96px, 12vw, 150px); aspect-ratio: 4 / 5;
  background: #f7f6ef; color: var(--ink); border-radius: 3px;
  font-family: var(--kufi); font-weight: 700; font-size: clamp(3.25rem, 2rem + 4vw, 5.75rem); line-height: 1;
  box-shadow: 0 0 0 1px rgba(22, 35, 27, 0.25), 0 0 0 6px rgba(247, 246, 239, 0.12), 0 14px 26px -16px rgba(0, 0, 0, 0.7);
}
.cover h1 { font-size: var(--t-2xl); line-height: 1.15; }
.cover-sub { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; font-family: var(--kufi); color: var(--gold); }

.mini-shelf {
  position: relative; display: flex; align-items: flex-end; gap: 4px; height: 70px;
  padding-inline: 24px; border-bottom: 6px solid #4a3b2b; margin-inline: calc(var(--gutter) * -0);
}
.mini-shelf a {
  flex: 1 1 0; min-width: 26px; height: 74%; display: flex; justify-content: center; padding-top: 6px;
  background: var(--c); color: var(--chalk); text-decoration: none; border-radius: 3px 3px 0 0;
  font-family: var(--kufi); font-weight: 700; font-size: 0.875rem;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  transition: height 0.2s ease;
}
.mini-shelf a:nth-child(3n) { height: 82%; } .mini-shelf a:nth-child(4n+1) { height: 68%; }
.mini-shelf a:hover { height: 92%; color: var(--chalk); }
.mini-shelf a[aria-current="page"] { height: 100%; box-shadow: inset 0 0 0 2px var(--gold); }
.mini-shelf a.is-empty { background: rgba(255, 255, 255, 0.06); color: rgba(234, 240, 226, 0.55); box-shadow: inset 0 0 0 1px rgba(234, 240, 226, 0.3); }

.contents { padding-block: clamp(28px, 4vw, 48px) clamp(56px, 7vw, 88px); max-width: 960px; }

/* ألسنة الفهرس: المواد والفروع */
.index-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding-inline: 18px; position: relative; z-index: 1; }
.index-tabs[hidden] { display: none; }
.index-tabs button, .index-tabs a {
  font-family: var(--kufi); font-size: 0.9375rem; color: var(--ink); text-decoration: none;
  padding: 9px 16px 8px; min-height: 42px; display: inline-flex; align-items: center; gap: 8px;
  background: #e1e4d9; border: 1px solid var(--rule); border-bottom: 0; border-radius: 8px 8px 0 0;
  border-top: 4px solid var(--tab, #b9c1b4);
}
.index-tabs button:hover, .index-tabs a:hover { background: #eef0e8; }
.index-tabs [aria-pressed="true"], .index-tabs [aria-current="page"] { background: #fff; position: relative; top: 1px; }
.index-tabs small { font-size: 0.75rem; color: var(--ink-2); }
.index-tabs .s1 { --tab: #2d6a3e; } .index-tabs .s2 { --tab: #b0761b; } .index-tabs .s3 { --tab: #3d5f8a; }
.index-tabs .s4 { --tab: #8a3f3a; } .index-tabs .s5 { --tab: #5b6b2a; } .index-tabs .s6 { --tab: #6a4f86; }
.branch-tabs { margin-bottom: 0; }
.branch-tabs + .sheet, .index-tabs + .sheet { border-top-right-radius: 0; }

/* الورقة البيضاء */
.sheet {
  background: #fff; border: 1px solid var(--rule); border-radius: 6px;
  padding: clamp(22px, 4vw, 44px) clamp(18px, 4vw, 48px);
  box-shadow: 0 1px 0 var(--rule), 0 6px 0 -3px #fafaf6, 0 7px 0 -3px var(--rule), 0 12px 0 -6px #f6f7f2, 0 13px 0 -6px var(--rule);
}
.sheet-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; padding-bottom: 14px; border-bottom: 2px solid var(--ink); }
.sheet-head h2 { font-size: var(--t-xl); }
.sheet-empty { text-align: start; }
.sheet-empty h2 { font-size: var(--t-lg); margin-bottom: 8px; }
.sheet-empty p { color: var(--ink-2); max-width: 58ch; }
.sheet-empty .btn { margin-top: 18px; }

.subject { padding-top: 26px; }
.subject[hidden], .book[hidden] { display: none; }
.subject-name { display: flex; align-items: center; gap: 10px; font-size: var(--t-md); }
.subject-name::before { content: ""; width: 12px; height: 12px; background: var(--spine, var(--leaf)); border-radius: 2px; }
.s1 { --spine: #2d6a3e; } .s2 { --spine: #b0761b; } .s3 { --spine: #3d5f8a; }
.s4 { --spine: #8a3f3a; } .s5 { --spine: #5b6b2a; } .s6 { --spine: #6a4f86; }
.toc { list-style: none; margin: 6px 0 0; padding: 0; }
.toc .book {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 20px;
  padding-block: 14px; border-bottom: 1px dashed var(--rule);
}
.toc-line { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.toc-line h4 { font-family: var(--kufi); font-weight: 500; font-size: 1.125rem; margin: 0; }
.leader { flex: 1 1 24px; border-bottom: 2px dotted #b9c1b4; transform: translateY(-5px); min-width: 24px; }
.toc-sem { font-family: var(--kufi); font-size: var(--t-sm); color: var(--ink-2); white-space: nowrap; }
.toc .desc { grid-column: 1; color: var(--ink-2); font-size: 1rem; }
.toc .btn { grid-column: 2; grid-row: 1 / span 2; white-space: nowrap; }
@media (max-width: 620px) {
  .cover-body { padding-inline: 14px; }
  .cover-in::before { inset-inline: 8px; }
  .crumbs, .mini-shelf { padding-inline: 14px; }
  .mini-shelf { gap: 3px; height: 58px; }
  .mini-shelf a { min-width: 0; font-size: 0.75rem; }
  .index-tabs { padding-inline: 8px; gap: 4px; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .index-tabs button, .index-tabs a { white-space: nowrap; padding-inline: 12px; }
  .toc .book { grid-template-columns: 1fr; }
  .leader { display: none; }
  .toc-line { flex-wrap: wrap; justify-content: space-between; }
  .toc .btn { grid-column: 1; grid-row: auto; justify-self: start; }
}

/* ===== درج القيم ===== */
.stairs { margin: 0; }
.stairs figcaption { font-family: var(--kufi); color: var(--ink-2); margin-bottom: 14px; }
.stairs ol { list-style: none; margin: 0; padding: 0; display: flex; align-items: flex-end; gap: 4px; height: 230px; border-bottom: 2px solid var(--ink); }
.stairs li { flex: 1 1 0; display: flex; align-items: flex-start; justify-content: center; padding-top: 12px; border-radius: 3px 3px 0 0; font-family: var(--kufi); font-weight: 600; color: var(--ink); }
.stairs li:nth-child(1) { height: 34%; background: #ece4c8; font-size: 0.9375rem; }
.stairs li:nth-child(2) { height: 50%; background: #e8d9a6; font-size: 1rem; }
.stairs li:nth-child(3) { height: 66%; background: #e5cd7d; font-size: 1.0625rem; }
.stairs li:nth-child(4) { height: 82%; background: #e2bd52; font-size: 1.125rem; }
.stairs li:nth-child(5) { height: 100%; background: var(--gold); font-size: 1.25rem; }
@media (max-width: 480px) { .stairs ol { height: 180px; } .stairs li:nth-child(n) { font-size: 0.8125rem; } }

/* شريط تقدّم السلايدر */
.stage-progress { display: block; height: 3px; background: rgba(234, 240, 226, 0.18); position: relative; z-index: 2; }
.stage-progress::after { content: ""; position: absolute; inset: 0; background: var(--gold); transform-origin: right; transform: scaleX(0); }
.stage.is-playing .stage-progress::after { animation: stage-fill 6.5s linear forwards; }
@keyframes stage-fill { to { transform: scaleX(1); } }


/* ===== الأزرار ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--kufi); font-size: 1rem; font-weight: 500; text-decoration: none; text-align: center;
  min-height: 46px; padding: 10px 18px; border-radius: var(--r-btn);
  background: var(--leaf); color: var(--chalk); border: 1px solid var(--leaf);
}
.btn:hover { background: var(--leaf-dark); border-color: var(--leaf-dark); color: var(--chalk); text-decoration: none; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn-ghost:hover { background: var(--paper-2); color: var(--ink); border-color: var(--ink-2); }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: var(--r-btn); overflow: hidden; background: #fff; }
.seg[hidden] { display: none; }
.seg button { font-family: var(--kufi); font-size: 0.9375rem; border: 0; background: transparent; padding: 8px 14px; min-height: 40px; }
.seg button + button { border-inline-start: 1px solid var(--rule); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.empty { padding-block: 40px; max-width: 60ch; }
.empty h2 { font-size: var(--t-lg); margin-bottom: 8px; }
.empty p { color: var(--ink-2); }

/* ===== صفحات المحتوى ===== */
.page-head { padding-block: clamp(36px, 6vw, 64px) 24px; border-bottom: 1px solid var(--rule); }
.page-head h1 { font-size: var(--t-2xl); line-height: 1.2; }
.page-head p { color: var(--ink-2); margin-top: 10px; max-width: 60ch; }


.pager { display: flex; justify-content: space-between; gap: 16px; padding-block: 28px; font-family: var(--kufi); }

.article { padding-block: clamp(32px, 5vw, 56px) 72px; }
.article h1 { font-size: clamp(1.875rem, 1.4rem + 2vw, 2.75rem); line-height: 1.3; margin-top: 10px; }
.article .meta { margin-top: 4px; }
.article figure { margin: 28px 0; }
.article figure .mat { max-height: 78vh; }
.article figure img { max-height: 78vh; width: auto; }
.prose p { margin-bottom: 1.1em; font-size: 1.1875rem; line-height: 2; }
.back { font-family: var(--kufi); display: inline-block; margin-bottom: 4px; }

.about-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 4fr); gap: clamp(28px, 5vw, 72px); padding-block: 40px 72px; }
.about-grid h2 { font-size: var(--t-lg); margin: 32px 0 10px; }
.about-grid h2:first-child { margin-top: 0; }
.about-grid aside h2 { font-size: var(--t-md); }
.plain { list-style: none; margin: 0; padding: 0; }
.plain li { padding-block: 10px; border-bottom: 1px solid var(--rule); }
.plain li:first-child { border-top: 1px solid var(--rule); }
.photo { margin: 0 0 24px; }
.photo img { width: 100%; height: auto; border-radius: var(--r-img); aspect-ratio: 3 / 2; object-fit: cover; }
.about-grid p + p { margin-top: 0.9em; }
.photo figcaption { font-size: var(--t-sm); color: var(--ink-2); margin-top: 6px; }
@media (max-width: 860px) { .about-grid { grid-template-columns: 1fr; } }

.contact { padding-block: 32px 72px; }

.notfound { padding-block: 80px; }
.notfound h1 { font-size: var(--t-2xl); }
.notfound p { color: var(--ink-2); margin-top: 8px; }

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

/* ===== ختم التاريخ ===== */
.stamp {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  min-width: 86px; padding: 6px 10px 5px; line-height: 1.15;
  color: #9b2c22; font-family: var(--kufi); font-weight: 600; text-align: center;
  border: 2px solid currentColor; outline: 1px solid currentColor; outline-offset: 2px; border-radius: 4px;
  transform: rotate(-5deg); opacity: 0.88; mix-blend-mode: multiply; background: rgba(255, 255, 255, 0.35);
}
.stamp b { font-size: 1.75rem; font-weight: 700; }
.stamp span { font-size: 0.75rem; }
.stamp-sm { min-width: 64px; padding: 4px 6px 3px; transform: rotate(-4deg); }
.stamp-sm b { font-size: 1.375rem; }

.kind { font-family: var(--kufi); font-size: var(--t-sm); font-weight: 600; color: var(--kind, var(--leaf)); }
.k-ws { --kind: #2d6a3e; } .k-ann { --kind: #3d5f8a; } .k-win { --kind: #9a6a12; }
.k-honor { --kind: #8a3f3a; } .k-media { --kind: #6a4f86; } .k-event { --kind: #2c5560; }

/* الأخبار في الرئيسية */
.lead-media { position: relative; }
.lead-media .stamp { position: absolute; top: 14px; left: 14px; background: rgba(255, 255, 255, 0.85); }
.lead-item .kind { display: block; margin-top: 18px; }
.news-row a { grid-template-columns: 76px 1fr; align-items: center; }
.news-row .stamp-sm { justify-self: center; }

/* ===== بطاقات الفهرسة (صفحة الأخبار) ===== */
.cards { list-style: none; margin: 32px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 480px), 1fr)); gap: 36px 28px; }
.card a {
  position: relative; display: block;
  min-height: 236px; padding: 46px 26px 96px; text-decoration: none; color: var(--ink);
  background-color: #fff;
  background-image:
    linear-gradient(transparent 0 38px, rgba(196, 72, 60, 0.5) 38px 39.5px, transparent 39.5px),
    repeating-linear-gradient(transparent 0 31px, #d8e5ec 31px 32px);
  background-position: 0 0, 0 14px;
  border: 1px solid var(--rule); border-radius: 3px;
  box-shadow: 0 1px 0 var(--rule), 0 10px 22px -18px rgba(22, 35, 27, 0.5);
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.25s;
}
.card a:hover { transform: translateY(-4px) rotate(-0.4deg); box-shadow: 0 1px 0 var(--rule), 0 18px 28px -18px rgba(22, 35, 27, 0.55); color: var(--ink); }
.card-tab {
  position: absolute; top: -14px; inset-inline-start: 22px; padding: 2px 14px 3px;
  background: var(--kind, var(--leaf)); color: #fff; font-family: var(--kufi); font-size: 0.8125rem; border-radius: 6px 6px 0 0;
}
.card-text h2 { font-size: 1.25rem; line-height: 32px; }
.card-text p { color: var(--ink-2); font-size: 1rem; line-height: 32px; margin-top: 0; }
.card .stamp { position: absolute; bottom: 16px; left: 24px; }
.card-hole { position: absolute; bottom: 12px; left: 50%; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--paper); box-shadow: inset 0 1px 2px rgba(22, 35, 27, 0.35); }
@media (max-width: 520px) {
  .card a { grid-template-columns: 1fr; padding: 44px 18px 84px; }
    .card .stamp { left: 16px; }
}

/* ===== صفحة الخبر ===== */
.article-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-top: 14px; }
.article-head .stamp { flex: none; margin-top: 8px; }
.article-head h1 { margin-top: 4px; }
.link-line { margin: 24px 0; }
.ticket {
  position: relative; display: grid; grid-template-columns: 120px minmax(0, 1fr); margin-block: 28px;
  background: #fff; border: 1px solid var(--rule); border-radius: 8px;
  box-shadow: 0 12px 26px -20px rgba(22, 35, 27, 0.6);
}
/* الثقبان على خط القطع */
.ticket::before, .ticket::after {
  content: ""; position: absolute; inset-inline-start: 109px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--paper); border: 1px solid var(--rule);
}
.ticket::before { top: -12px; } .ticket::after { bottom: -12px; }
.ticket-stub {
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 18px 8px;
  background: var(--gold); color: var(--ink); border-radius: 0 8px 8px 0; border-inline-end: 2px dashed rgba(22, 35, 27, 0.35);
  font-family: var(--kufi); text-align: center; line-height: 1.2;
}
.ticket-stub b { font-size: 2.75rem; font-weight: 700; line-height: 1; margin: 4px 0; }
.ticket-stub span { font-size: 0.875rem; }
.ticket-main { padding: 20px 26px; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.ticket-label { font-family: var(--kufi); font-size: var(--t-sm); color: var(--ink-2); }
.ticket-main strong { font-family: var(--kufi); font-weight: 600; font-size: var(--t-md); line-height: 1.5; }
.ticket-main .btn { margin-top: 6px; }
.ticket.is-past .ticket-stub { background: var(--paper-2); }
@media (max-width: 520px) {
  .ticket { grid-template-columns: 88px minmax(0, 1fr); }
  .ticket::before, .ticket::after { inset-inline-start: 77px; }
  .ticket-stub b { font-size: 2.125rem; }
  .ticket-main { padding: 16px; }
  .ticket-main strong { font-size: 1.0625rem; }
  .article-head { flex-direction: column-reverse; gap: 8px; }
}

/* ===== كومة كتب التسجيلات ===== */
.stack { list-style: none; margin: 18px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.stack .spine {
  flex-direction: row; align-items: center; gap: 0; height: auto; min-height: 76px; padding: 10px 16px 10px 14px; border-radius: 3px;
  background-image:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 3px),
    linear-gradient(0deg, rgba(0, 0, 0, 0.22), transparent 30%, transparent 75%, rgba(255, 255, 255, 0.08));
}
.stack .spine::before, .stack .spine::after { inset-inline: auto; inset-block: 7px; width: 5px; height: auto; border-top: 0; border-bottom: 0; border-inline-start: 1.5px solid rgba(224, 174, 46, 0.75); border-inline-end: 1px solid rgba(224, 174, 46, 0.5); }
.stack .spine::before { top: 7px; inset-inline-start: 72px; }
.stack .spine::after { bottom: 7px; inset-inline-end: 12px; }
.stack .spine-label { margin: 0; min-width: 42px; font-size: 1.25rem; padding: 2px 6px 0; }
.stack .spine-title { writing-mode: horizontal-tb; margin: 0 28px 0 16px; flex: 1; white-space: normal; font-size: 1rem; line-height: 1.55; }
.stack .spine-count { margin: 0 0 0 18px; font-size: 0.75rem; min-width: 84px; text-align: left; }
.stack a.spine:hover, .stack a.spine:focus-visible { transform: translateX(-10px); }
.stack-plank { height: 12px; margin-top: 4px; background: #4a3b2b; border-top: 4px solid #6e5940; }
@media (max-width: 520px) { .stack .spine-count { display: none; } .stack .spine-title { margin-inline-end: 10px; font-size: 0.9375rem; } }

/* ===== بطاقة التواصل ===== */
.member-card {
  max-width: 600px; background: #fff; border: 1px solid var(--rule); border-radius: 12px; overflow: hidden;
  box-shadow: 0 24px 40px -28px rgba(22, 35, 27, 0.55); transform: rotate(-0.6deg);
}
.mc-head { display: flex; align-items: center; gap: 14px; padding: 18px 24px; background: var(--board); color: var(--chalk); border-bottom: 4px solid var(--gold); }
.mc-head img { width: 54px; height: auto; background: var(--paper); border-radius: 50%; padding: 3px; }
.mc-head b { display: block; font-family: var(--kufi); font-weight: 600; font-size: 1.125rem; }
.mc-head span { font-family: var(--kufi); font-size: var(--t-sm); color: var(--gold); }
.mc-fields { margin: 0; padding: 10px 24px 4px; }
.mc-fields div { display: grid; grid-template-columns: 96px 1fr; align-items: baseline; gap: 12px; padding: 14px 0 6px; border-bottom: 1.5px dotted #b9c1b4; }
.mc-fields dt { font-family: var(--kufi); color: var(--ink-2); font-size: var(--t-sm); }
.mc-fields dd { margin: 0; font-family: var(--kufi); font-size: var(--t-md); }
.mc-foot { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px 20px; font-family: var(--kufi); font-size: var(--t-sm); color: var(--ink-2); }
.mc-code { width: 150px; height: 30px; background: repeating-linear-gradient(90deg, var(--ink) 0 2px, transparent 2px 4px, var(--ink) 4px 5px, transparent 5px 8px, var(--ink) 8px 11px, transparent 11px 13px); opacity: 0.85; }
@media (max-width: 520px) { .member-card { transform: none; } .mc-fields div { grid-template-columns: 1fr; gap: 0; } .mc-fields dd { font-size: 1.0625rem; } }

/* ===== صفحة غير موجودة ===== */
.lost-shelf { display: flex; align-items: flex-end; gap: 6px; height: 170px; max-width: 360px; padding-inline: 10px; border-bottom: 14px solid #4a3b2b; margin-bottom: 32px; }
.lost-shelf span { flex: 1; height: 86%; background: var(--c); border-radius: 3px 3px 0 0; box-shadow: inset 3px 0 0 rgba(255, 255, 255, 0.1), inset -4px 0 0 rgba(0, 0, 0, 0.2); }
.lost-shelf span:nth-child(2) { height: 74%; } .lost-shelf span:nth-child(3) { height: 96%; } .lost-shelf span:nth-child(5) { height: 80%; } .lost-shelf span:nth-child(6) { height: 92%; }
.lost-shelf .lost-slot { display: grid; place-items: center; height: 88%; background: transparent; border: 2px dashed #a9b2a4; box-shadow: none; font-family: var(--kufi); font-weight: 700; font-size: 2rem; color: #7f8b81; }
.lost-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

/* ===== التذييل جالس على حافة الرف ===== */
.site-foot { position: relative; padding-top: 66px; }
.site-foot::before { content: ""; position: absolute; inset: 0 0 auto; height: 16px; background: #4a3b2b; border-top: 4px solid #6e5940; }
