/* بوابة SIGS: هوية عاجية ورقية — كحلي للنصوص والأزرار الأساسية، وحدود ذهبية رفيعة، وأخضر داكن للحالات. */
:root {
  --paper: #F4EFE4;
  --panel: #FBF8F1;
  --card: #FFFDF8;
  --cover-bg: #F1EADB;
  --navy: #14284B;
  --navy-deep: #0D1D38;
  --navy-soft: #EEF2F8;
  --navy-line: #9DB0CF;
  --gold: #B8913F;
  --gold-line: #E2D3AE;
  --gold-soft: #EFE5CC;
  --green: #1F5A3E;
  --green-bg: #EDF4EE;
  --green-line: #9CC3A7;
  --amber: #8A5A12;
  --amber-bg: #FBF1DC;
  --amber-line: #E3C78A;
  --muted-bg: #EFEAE0;
  --muted-line: #D9CDB3;
  --text: #1B2B48;
  --text-muted: #5A6377;
  --font-body: 'IBM Plex Sans Arabic', -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, sans-serif;
  --font-heading: 'Cairo', 'IBM Plex Sans Arabic', sans-serif;
  --radius: 14px;
  --shadow-card: 0 1px 2px rgba(60, 45, 20, 0.05), 0 8px 22px rgba(60, 45, 20, 0.07);
  --focus: 0 0 0 3px #FBF8F1, 0 0 0 6px var(--gold);
  --wrap: 1240px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex; flex-direction: column;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  /* ورق عاجي بملمس خفيف (ضجيج SVG بشفافية منخفضة) */
  background-color: var(--paper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .38 0 0 0 0 .25 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}
a { color: inherit; }
h1, h2, h3 { font-family: var(--font-heading); line-height: 1.35; margin: 0; color: var(--navy); }
.icon { display: inline-flex; width: 1.15em; height: 1.15em; flex: none; }
.icon svg { width: 100%; height: 100%; }

.skip-link {
  position: absolute; inset-inline-start: 12px; top: -60px; z-index: 50;
  background: var(--navy); color: #FFF; padding: 10px 16px; border-radius: 10px; font-weight: 700; text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* ---------- الرأس */
.site-header {
  position: relative; z-index: 20;
  background: #FAF7F0;
  border-bottom: 3px solid var(--navy);
  box-shadow: 0 1px 0 var(--gold) inset, 0 4px 14px rgba(20, 40, 75, 0.10);
}
.site-header::after { content: ''; position: absolute; inset: auto 0 -6px 0; height: 1px; background: var(--gold); opacity: .8; }
.site-header-in {
  position: relative;
  max-width: var(--wrap); margin: 0 auto; padding: 10px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: inline-flex; align-items: center; gap: 14px; text-decoration: none; min-height: 48px; border-radius: 10px; }
.brand-logo {
  display: inline-grid; place-items: center; flex: none;
  font-family: var(--font-heading); font-weight: 800; font-size: 1.05rem; letter-spacing: 1px; line-height: 1;
  color: var(--navy); border: 2px solid var(--navy); border-radius: 8px; padding: 9px 10px 8px;
}
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-family: var(--font-heading); font-weight: 800; font-size: 1.3rem; color: var(--navy); line-height: 1.3; }
.brand-sub { font-size: 0.86rem; color: var(--text-muted); line-height: 1.4; }

.site-nav { display: flex; align-items: center; gap: 6px; }
.nav-item { position: relative; }
.nav-btn {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 8px 14px; border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: var(--navy); cursor: pointer;
  font-family: var(--font-heading); font-weight: 700; font-size: 1rem;
  transition: background-color .15s ease, border-color .15s ease;
}
.nav-btn:hover, .nav-btn[aria-expanded="true"] { background: var(--gold-soft); border-color: var(--gold-line); }
.nav-btn .chev { width: 12px; height: 12px; transition: transform .15s ease; }
.nav-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.nav-menu {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 30;
  min-width: 270px; margin: 0; padding: 6px; list-style: none;
  background: var(--card); border: 1px solid var(--gold-line); border-radius: 12px;
  box-shadow: 0 14px 34px rgba(20, 40, 75, 0.16);
}
.nav-menu[hidden] { display: none; }
.nav-menu a {
  display: flex; flex-direction: column; justify-content: center; min-height: 48px;
  padding: 6px 12px; border-radius: 8px; text-decoration: none;
}
.nav-menu a:hover { background: var(--gold-soft); }
.nav-menu a[aria-current="page"] { background: var(--navy-soft); }
.menu-title { font-family: var(--font-heading); font-weight: 700; color: var(--navy); line-height: 1.4; }
.menu-meta { font-size: 0.8rem; color: var(--text-muted); line-height: 1.4; }

/* ---------- مشهد المكتبة */
.scene { position: relative; height: 230px; overflow: hidden; background: #3B2A1A; }
.scene img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center 42%; }
.scene::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(30, 20, 8, 0.18), rgba(30, 20, 8, 0) 40%, rgba(244, 239, 228, 0.10)); }

/* ---------- لوحة المحتوى (تتداخل مع أسفل المشهد) */
.panel {
  position: relative; z-index: 2;
  width: calc(100% - 48px); max-width: var(--wrap);
  margin: -96px auto 40px; padding: 26px 32px 34px;
  background: var(--panel); border: 1px solid var(--gold-line); border-radius: 18px;
  box-shadow: 0 -6px 24px rgba(30, 20, 8, 0.10), 0 10px 30px rgba(60, 45, 20, 0.06);
  flex: 1 0 auto;
}
.panel:focus { outline: none; }
.panel-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 22px; }
.panel-title { min-width: 0; }
.panel h1 { font-size: 2rem; font-weight: 800; }
.panel-sub { margin: 2px 0 0; color: var(--text-muted); font-size: 1rem; }
.counter {
  display: inline-flex; align-items: center; gap: 12px; margin: 0;
  font-family: var(--font-heading); font-weight: 700; font-size: 1.05rem; color: var(--navy);
  padding: 4px 4px 8px; border-bottom: 2px solid var(--gold-line);
}
.counter[hidden] { display: none; }
.counter-icon { width: 46px; height: 36px; }

/* ---------- مسار التنقل */
.crumbs { font-size: 0.9rem; margin-bottom: 4px; }
.crumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; }
.crumbs li + li::before { content: '/'; margin-inline-end: 6px; color: var(--gold); }
.crumbs a { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; color: var(--navy); font-weight: 600; text-decoration: underline; text-decoration-color: var(--gold-line); text-underline-offset: 4px; border-radius: 6px; }
.crumbs a:hover { text-decoration-color: var(--gold); }
.crumbs [aria-current] { color: var(--text-muted); font-weight: 600; }

/* ---------- الشبكات والبطاقات */
.grid { display: grid; gap: 22px; }
.grade-grid, .feature-grid, .compact-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card {
  background: var(--card); border: 1px solid var(--gold-line); border-radius: var(--radius);
  box-shadow: var(--shadow-card); display: flex; flex-direction: column; min-width: 0;
}

/* بطاقة الصف */
.grade-card { padding: 20px 20px 18px; gap: 6px; }
.grade-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.grade-icon {
  width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-family: var(--font-heading); font-weight: 800; font-size: 1.55rem; line-height: 1; color: var(--navy);
  background: var(--panel); border: 1.5px solid var(--gold); box-shadow: inset 0 0 0 4px var(--panel), inset 0 0 0 5px var(--gold-line);
}
.grade-stage { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); background: var(--muted-bg); border-radius: 999px; padding: 2px 12px; }
.grade-card h3 { font-size: 1.35rem; font-weight: 800; }
.grade-count { margin: 0 0 12px; color: var(--text-muted); font-size: 0.95rem; flex: 1; }
.grade-card.has-books .grade-count { color: var(--green); font-weight: 600; }

/* بطاقة الكتاب الكبيرة */
.book-feature { padding: 10px; }
.book-cover { display: flex; align-items: center; justify-content: center; background: var(--cover-bg); border-radius: 10px; overflow: hidden; }
.cover-feature { height: 330px; padding: 14px; }
.book-cover img { display: block; height: 100%; width: auto; max-width: 100%; object-fit: contain; border-radius: 3px; box-shadow: 0 2px 4px rgba(40, 30, 10, .12), 0 8px 18px rgba(40, 30, 10, .16); }
.book-body { padding: 14px 8px 6px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.book-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.book-head h3 { font-size: 1.3rem; font-weight: 800; }
.book-note { margin: 0; color: var(--text-muted); font-size: 0.92rem; }
.status { font-size: 0.82rem; font-weight: 700; padding: 3px 14px; border-radius: 999px; border: 1px solid; white-space: nowrap; line-height: 1.6; }
.status.is-available { color: var(--green); background: var(--green-bg); border-color: var(--green-line); }
.status.is-preparing { color: var(--amber); background: var(--amber-bg); border-color: var(--amber-line); }
.status.is-missing { color: var(--text-muted); background: var(--muted-bg); border-color: var(--muted-line); }
.book-feature .book-note { min-height: 1.7em; }
.actions { display: flex; flex-direction: column; gap: 10px; padding-top: 6px; }
.actions-pdf { margin-top: auto; padding-top: 10px; }
.unavailable {
  display: flex; align-items: center; gap: 8px; margin: 0;
  min-height: 48px; padding: 8px 14px; border-radius: 10px;
  color: var(--text-muted); background: var(--muted-bg); font-size: 0.92rem;
}

/* بطاقة المادة المدمجة */
.book-compact { flex-direction: row; align-items: stretch; gap: 14px; padding: 12px; }
.cover-compact { width: 76px; flex: none; align-self: flex-start; padding: 6px; border-radius: 8px; }
.cover-compact img { width: 100%; height: auto; }
.compact-body { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }
.compact-body .book-head h3 { font-size: 1.1rem; }
.compact-body .unavailable { min-height: 0; padding: 0; background: none; font-size: 0.88rem; }
.preview-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 4px; }
.preview-links .btn { flex: 1 1 auto; }
.compact-pdfs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.compact-pdfs .btn { flex: 1 1 auto; }

/* ---------- الأزرار والروابط */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px; border-radius: 10px; border: 1px solid transparent;
  font-family: var(--font-heading); font-weight: 700; font-size: 1.02rem; line-height: 1.3; text-align: center; text-decoration: none; cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.btn-sm { min-height: 44px; padding: 8px 14px; font-size: 0.92rem; }
.btn-primary { background: var(--navy); color: #FBF8F1; box-shadow: 0 2px 6px rgba(20, 40, 75, 0.22); }
.btn-primary:hover { background: var(--navy-deep); }
.btn-secondary { background: var(--navy-soft); color: var(--navy); border-color: var(--navy-line); }
.btn-secondary:hover { background: #E2E9F4; }
.btn-link { background: var(--card); color: var(--navy); border-color: var(--muted-line); font-family: var(--font-body); font-weight: 600; font-size: 0.95rem; }
.btn-link:hover { border-color: var(--gold); background: #FFFFFF; }
.btn-link .icon { color: var(--gold); }
a:focus-visible, button:focus-visible, .btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn-primary:focus-visible { box-shadow: var(--focus); }

/* ---------- ملاحظات وحالات فارغة */
.local-note {
  display: flex; align-items: center; gap: 14px; margin: 26px 0 22px;
  font-size: 0.88rem; color: var(--text-muted); text-align: center;
}
.local-note::before, .local-note::after { content: ''; flex: 1; height: 1px; background: var(--gold-line); min-width: 24px; }
.local-note .icon { color: var(--navy); }
.empty {
  background: var(--card); border: 1px dashed var(--muted-line); border-radius: var(--radius);
  padding: 30px 18px; text-align: center; color: var(--text-muted);
}
.empty p { margin: 0 0 14px; font-size: 1.05rem; font-weight: 600; color: var(--text); }

/* ---------- التذييل */
.site-footer { background: var(--navy); color: #EDE6D6; border-top: 3px solid var(--gold); margin-top: auto; }
.site-footer-in { max-width: var(--wrap); margin: 0 auto; padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; gap: 10px 20px; flex-wrap: wrap; }
.footer-brand { display: inline-flex; align-items: center; gap: 12px; font-family: var(--font-heading); font-weight: 700; font-size: 1.05rem; }
.footer-brand .brand-logo { color: #F6F1E6; border-color: #D9CFB8; font-size: 0.95rem; padding: 7px 8px 6px; }
.footer-sub { font-size: 0.9rem; color: #CFC6B2; }

/* ---------- الشاشات المتوسطة: عمودان */
@media (max-width: 1000px) {
  .grade-grid, .feature-grid, .compact-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scene { height: 190px; }
  .panel { margin-top: -70px; padding: 22px 22px 28px; }
}

/* ---------- الهاتف: بطاقة واحدة في الصف */
@media (max-width: 640px) {
  .site-header-in { flex-direction: column; align-items: stretch; gap: 4px; padding: 8px 12px 6px; }
  .brand { gap: 10px; }
  .brand-name { font-size: 1.12rem; }
  .brand-sub { font-size: 0.8rem; }
  .brand-logo { font-size: 0.92rem; padding: 7px 8px 6px; }
  .site-nav { gap: 6px; }
  .nav-item { position: static; flex: 1; }
  .nav-btn { width: 100%; justify-content: center; font-size: 0.95rem; background: var(--panel); border-color: var(--gold-line); }
  .nav-menu { left: 12px; right: 12px; top: calc(100% + 4px); min-width: 0; }
  .scene { height: 120px; }
  .panel { width: calc(100% - 24px); margin: -28px auto 24px; padding: 18px 14px 22px; border-radius: 14px; }
  .panel h1 { font-size: 1.5rem; }
  .panel-head { margin-bottom: 16px; }
  .grade-grid, .feature-grid, .compact-grid { grid-template-columns: 1fr; gap: 16px; }
  .cover-feature { height: 300px; }
  .site-footer-in { justify-content: center; text-align: center; padding: 14px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
