/* =====================================================================
   نظام التصميم — طابع تحريري دافئ (ورق كريمي، حبر أسود، لهجة زعفرانية واحدة)
   يعمل مع Tailwind (CDN أو مبنيّ) — المكوّنات هنا، التخطيط بالـutilities.
   ===================================================================== */
:root {
  --cream: #F6F4EE;
  --paper: #FDFCFA;
  --paper-2: #F3EFE7;
  --line: #E8E4DB;
  --line-strong: #D6D1C5;
  --ink: #0B0B0B;
  --ink-2: #4D4D4D;
  --ink-3: #8A867E;
  --accent: #E8671C;
  --accent-ink: #B84D0E;
  --accent-soft: #FBE9DD;
  --ok: #2F7A4F;   --ok-soft: #E3F1E7;
  --info: #2D5F8A; --info-soft: #E2ECF5;
  --warn: #B7791F; --warn-soft: #FBF0D9;
  --bad: #C0392B;  --bad-soft: #FBE3E0;
  --r-sm: 12px; --r: 20px; --r-lg: 28px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 10px 30px -16px rgba(0,0,0,.18);
  --shadow-lg: 0 2px 4px rgba(0,0,0,.05), 0 24px 48px -20px rgba(0,0,0,.28);
  --font: 'IBM Plex Sans Arabic', 'Cairo', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --quran: 'Amiri Quran', 'Scheherazade New', 'Noto Naskh Arabic', serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- الأساس ---------- */
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--cream);
  color: var(--ink);
  font-feature-settings: "kern", "liga", "calt";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  position: relative;
}
/* حبيبات ورق خفيفة جدًا — عمق بلا ضوضاء */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .035;
  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='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
body > * { position: relative; z-index: 1; }
::selection { background: var(--accent-soft); color: var(--accent-ink); }
.font-quran, .quran-text { font-family: var(--quran); line-height: 2.1; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
h1, h2, h3 { letter-spacing: -0.005em; }
a { color: inherit; }
a.link { color: var(--accent-ink); text-underline-offset: 3px; }
a.link:hover { text-decoration: underline; }

/* ---------- الشريط العلوي ---------- */
.t-nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--cream) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.wordmark { display: inline-flex; align-items: baseline; gap: 6px; font-weight: 700; font-size: 24px; letter-spacing: -0.01em; line-height: 1; }
.wordmark .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); transform: translateY(-1px); }
.navlink {
  display: inline-flex; align-items: center; height: 38px; padding: 0 14px; border-radius: 999px;
  font-size: 15px; font-weight: 500; color: var(--ink-2); white-space: nowrap;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.navlink:hover { background: var(--paper-2); color: var(--ink); }
.navlink.active { background: var(--paper); color: var(--ink); border: 1px solid var(--line); font-weight: 600; }
.nav-scroll { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none; }
.nav-scroll::-webkit-scrollbar { display: none; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); padding: 0 6px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--paper); font-weight: 700; font-size: 13px; }

/* ---------- الأزرار (حبّات) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px; border-radius: 999px; border: 1px solid transparent;
  font-size: 15px; font-weight: 600; line-height: 1; cursor: pointer; white-space: nowrap;
  transition: transform .15s var(--ease), background .18s var(--ease), border-color .18s var(--ease), box-shadow .18s var(--ease), color .18s;
  text-decoration: none;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn-ink { background: var(--ink); color: var(--paper); }
.btn-ink:hover { background: #222; box-shadow: var(--shadow); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-ink); box-shadow: var(--shadow); }
.btn-outline { background: var(--paper); color: var(--ink); border-color: var(--line-strong); }
.btn-outline:hover { border-color: var(--ink); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--paper-2); color: var(--ink); }
.btn-soft { background: var(--paper-2); color: var(--ink); }
.btn-soft:hover { background: var(--line); }
.btn-danger { background: var(--bad-soft); color: var(--bad); }
.btn-danger:hover { background: #F6CFC9; }
.btn-light { background: rgba(255,255,255,.12); color: var(--paper); border-color: rgba(255,255,255,.25); }
.btn-light:hover { background: rgba(255,255,255,.2); }
.btn-sm { height: 34px; padding: 0 14px; font-size: 13.5px; }
.btn-lg { height: 50px; padding: 0 26px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-icon { width: 42px; padding: 0; }
.btn .ic { width: 18px; height: 18px; flex: none; }

/* ---------- البطاقات ---------- */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); }
.card-hover { transition: transform .22s var(--ease), box-shadow .22s var(--ease), border-color .22s; }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.card-body { padding: 22px; }
.card-title { font-size: 17px; font-weight: 700; }
.hairline { border-top: 1px solid var(--line); }

/* ---------- عناوين الأقسام ---------- */
.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.section-head .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--paper); border: 1px solid var(--line); font-size: 16px; }
.section-head h2 { font-size: 21px; font-weight: 700; }
.section-head .count { color: var(--ink-3); font-weight: 500; font-size: 15px; }
.eyebrow { font-size: 12.5px; font-weight: 600; letter-spacing: .02em; color: var(--accent-ink); text-transform: uppercase; }

/* ---------- البيانات الوصفية (سطر المؤلّف/التاريخ) ---------- */
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 13px; color: var(--ink-3); }
.meta b { color: var(--ink-2); font-weight: 600; }
.meta .sep::before { content: "•"; color: var(--line-strong); margin: 0 2px; }
.meta .sun { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); margin-inline-end: 4px; vertical-align: -1px; }

/* ---------- الحالات (حبّات صغيرة) ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill-ok    { background: var(--ok-soft);   color: var(--ok); }
.pill-info  { background: var(--info-soft); color: var(--info); }
.pill-warn  { background: var(--warn-soft); color: var(--warn); }
.pill-bad   { background: var(--bad-soft);  color: var(--bad); }
.pill-muted { background: var(--paper-2);   color: var(--ink-2); }
.pill-ink   { background: var(--ink);       color: var(--paper); }
.pill-live::before { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.5); opacity: .4; } }

/* ---------- التنبيهات ---------- */
.flash { display: flex; align-items: flex-start; gap: 10px; padding: 14px 18px; border-radius: var(--r-sm); border: 1px solid; font-size: 14.5px; }
.flash-ok  { background: var(--ok-soft);  border-color: #C7E3D1; color: #1F5A38; }
.flash-bad { background: var(--bad-soft); border-color: #F0C4BE; color: #8E2A20; }
.flash-warn{ background: var(--warn-soft); border-color: #EBD6A6; color: #7A4F0D; }
.flash-info{ background: var(--info-soft); border-color: #C3D6E8; color: #234A6B; }

/* ---------- النماذج ---------- */
.label { display: block; font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 7px; }
.label .hint { color: var(--ink-3); font-weight: 400; font-size: 12.5px; }
.field {
  width: 100%; height: 46px; padding: 0 14px; border-radius: var(--r-sm);
  background: var(--paper); border: 1px solid var(--line-strong); color: var(--ink); font: inherit; font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
.field:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 4px rgba(11,11,11,.06); }
.field::placeholder { color: var(--ink-3); }
select.field { appearance: none; -webkit-appearance: none; padding-inline-end: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%234D4D4D' stroke-width='2'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 14px center; }
input[type=number].field, .field-mono { font-family: var(--mono); direction: ltr; }
input[type=color].field { padding: 4px; height: 46px; cursor: pointer; }
input[type=file].field { padding: 10px 14px; height: auto; }
.field-sm { height: 34px; font-size: 13.5px; padding: 0 10px; border-radius: 10px; }

/* ---------- المربّعات الملوّنة (مثل نشرات ثمانية) ---------- */
.tile { position: relative; aspect-ratio: 1 / 1; border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; padding: 18px; color: var(--paper); isolation: isolate; }
.tile .big { font-size: clamp(28px, 4vw, 40px); font-weight: 700; line-height: 1.05; }
.tile .small { font-size: 13.5px; opacity: .85; margin-top: 6px; line-height: 1.6; }
.tile .idx { position: absolute; top: 14px; right: 16px; font-family: var(--mono); font-size: 13px; opacity: .7; }
.tile-ink { background: var(--ink); }
.tile-accent { background: var(--accent); }
.tile-sage { background: #2F5E4E; }
.tile-plum { background: #4B2C4E; }
.tile-sand { background: #C9A062; color: var(--ink); }
.tile-pattern::after { content: ""; position: absolute; inset: 0; z-index: -1; opacity: .12;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48' fill='none' stroke='%23ffffff' stroke-width='1'%3E%3Cpath d='M24 2l6 16 16 6-16 6-6 16-6-16-16-6 16-6z'/%3E%3C/svg%3E"); background-size: 48px 48px; }

/* ---------- البطل التحريري الأسود ---------- */
.hero-ink { position: relative; overflow: hidden; background: var(--ink); color: var(--paper); border-radius: var(--r-lg); isolation: isolate; }
.hero-ink::before { content: ""; position: absolute; inset: 0; z-index: -1; opacity: .07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96' viewBox='0 0 96 96' fill='none' stroke='%23F6F4EE' stroke-width='1'%3E%3Cpath d='M48 4l10 28 28 10-28 10-10 28-10-28-28-10 28-10z'/%3E%3Ccircle cx='48' cy='48' r='46'/%3E%3C/svg%3E"); background-size: 96px 96px; }
.hero-ink::after { content: ""; position: absolute; width: 520px; height: 520px; right: -160px; top: -200px; z-index: -1; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(232,103,28,.35), transparent 70%); }
.hero-ink .basmala { font-family: var(--quran); font-size: clamp(34px, 6vw, 64px); line-height: 1.7; color: var(--paper); opacity: .95; }
.hero-ink h1 { font-size: clamp(28px, 4.2vw, 48px); font-weight: 700; line-height: 1.25; }
.hero-ink .lead { color: rgba(246,244,238,.78); font-size: clamp(15px, 1.4vw, 18px); line-height: 1.9; max-width: 56ch; }
.hero-ink .rule { width: 56px; height: 3px; border-radius: 3px; background: var(--accent); }
.hero-stats { display: flex; flex-wrap: wrap; gap: 8px 22px; color: rgba(246,244,238,.65); font-size: 13.5px; }
.hero-stats b { color: var(--paper); font-weight: 600; }

/* ---------- صفوف المقالات (المشاريع) ---------- */
.row-card { display: grid; grid-template-columns: 1fr 132px; gap: 18px; padding: 18px; align-items: start; }
@media (min-width: 640px) { .row-card { grid-template-columns: 1fr 168px; gap: 22px; padding: 22px; } }
.row-card .thumb { aspect-ratio: 1 / 1; border-radius: 14px; overflow: hidden; background: var(--paper-2); position: relative; }
.row-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.row-card .thumb .ph { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--quran); font-size: 30px; color: var(--ink-3); }
.row-card .title { font-size: 19px; font-weight: 700; line-height: 1.4; }
@media (min-width: 640px) { .row-card .title { font-size: 22px; } }
.row-card .excerpt { color: var(--ink-2); font-size: 14.5px; line-height: 1.8; margin-top: 6px; }
.progress-hair { height: 4px; border-radius: 4px; background: var(--paper-2); overflow: hidden; }
.progress-hair > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .5s var(--ease); }

/* ---------- شريط التقدّم ---------- */
.progress { height: 10px; border-radius: 10px; background: var(--paper-2); overflow: hidden; border: 1px solid var(--line); }
.progress > i { display: block; height: 100%; width: 0; border-radius: 10px; background: linear-gradient(90deg, var(--accent-ink), var(--accent)); position: relative; transition: width .6s var(--ease); }
.progress > i::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent); transform: translateX(-100%); animation: shimmer 1.8s linear infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.steps { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.step { font-size: 10.5px; text-align: center; padding: 6px 2px; border-radius: 8px; background: var(--paper-2); color: var(--ink-3); border: 1px solid transparent; transition: all .2s; }
.step.done { background: var(--ok-soft); color: var(--ok); }
.step.active { background: var(--ink); color: var(--paper); }

/* ---------- الآيات ---------- */
.ayah { display: grid; grid-template-columns: 44px 1fr; gap: 14px; padding: 18px 20px; border-bottom: 1px solid var(--line); transition: background .18s; align-items: start; }
.ayah:last-child { border-bottom: 0; }
.ayah:hover { background: var(--paper-2); }
.ayah.active { background: var(--accent-soft); box-shadow: inset 4px 0 0 var(--accent); }
.ayah .play { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--paper); display: grid; place-items: center; cursor: pointer; transition: all .15s; color: var(--ink); }
.ayah .play:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.ayah.active .play { background: var(--accent); border-color: var(--accent); color: #fff; }
.ayah .text { font-family: var(--quran); font-size: 26px; line-height: 2; color: var(--ink); }
.ayah .num-badge { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 8px; background: var(--paper-2); color: var(--ink-2); font-size: 12px; font-weight: 600; }
.ayah.dirty .field-sm { border-color: var(--warn); background: var(--warn-soft); }

/* ---------- مشغّل الصوت ---------- */
audio { width: 100%; height: 48px; border-radius: 999px; }
audio::-webkit-media-controls-panel { background: var(--paper-2); }

/* ---------- الجداول ---------- */
.table { width: 100%; font-size: 14px; border-collapse: collapse; }
.table th { text-align: right; font-size: 12.5px; font-weight: 600; color: var(--ink-3); padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--paper-2); }

/* ---------- إحصاءات ---------- */
.stat { padding: 18px 20px; }
.stat .v { font-size: 30px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 13px; color: var(--ink-3); margin-top: 8px; }

/* ---------- حركة الدخول المتدرّجة ----------
   المحتوى مرئي افتراضيًا؛ الحركة تُفعَّل فقط عندما يضيف JS الصنف html.anim،
   ويُثبَّت الظهور بعد ثانيتين (html.settled) حتى لو توقّفت الحركة (تبويب خلفي مثلًا). */
html.anim:not(.settled) .reveal { opacity: 0; transform: translateY(10px); animation: reveal .7s var(--ease) forwards; animation-delay: calc(var(--i, 0) * 70ms); }
@keyframes reveal { to { opacity: 1; transform: none; } }

/* ---------- تفاصيل ---------- */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 14.5px; }
.kv dt { color: var(--ink-3); }
.kv dd { color: var(--ink); font-weight: 500; }
.dropzone { border: 1.5px dashed var(--line-strong); border-radius: var(--r); background: var(--paper); padding: 34px 20px; text-align: center; transition: all .2s; cursor: pointer; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.tabs { display: inline-flex; padding: 4px; background: var(--paper-2); border-radius: 999px; gap: 4px; }
.tab { height: 36px; padding: 0 16px; border-radius: 999px; font-size: 14px; font-weight: 600; color: var(--ink-2); display: inline-flex; align-items: center; cursor: pointer; border: 0; background: transparent; }
.tab.active { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.tpl-tile { position: relative; aspect-ratio: 16 / 10; border-radius: 14px; overflow: hidden; background: var(--ink); border: 2px solid transparent; transition: border-color .15s, transform .2s var(--ease); }
.tpl-tile img, .tpl-tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tpl-tile .veil { position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,.55), rgba(0,0,0,.05)); }
.tpl-tile .name { position: absolute; bottom: 10px; right: 12px; left: 12px; color: #fff; font-weight: 700; font-size: 14px; text-shadow: 0 1px 6px rgba(0,0,0,.6); }
.tpl-tile .tag { position: absolute; top: 8px; left: 8px; font-family: var(--mono); font-size: 11px; background: rgba(0,0,0,.55); color: #fff; padding: 2px 7px; border-radius: 6px; }
.peer:checked + .tpl-tile { border-color: var(--accent); transform: scale(1.02); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px; border: 2px solid var(--cream); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html.anim .reveal { opacity: 1; transform: none; }
}
