/* تعريف الهوية البصرية لسديم - الإصدار المحدث (Cyberpunk / Dark Gold & Violet Edition) */
:root { 
    --sadeem-bg: #09090d;                  /* أسود كوني عميق ومستقبلي */
    --royal-gold: linear-gradient(135deg, #7c4dff 0%, #b388ff 50%, #f1d38e 100%); /* مزيج مستقبلي يجمع الأرجواني بالذهبي */
    --soft-gold: #e1b12c;                  /* ذهبي نيون مشع ومتوهج */
    --color-accent: #7c4dff;               /* الأرجواني الحيوي للنقاط المضيئة */
    --glass: rgba(18, 18, 24, 0.75);       /* الحاويات الشفافة الزجاجية */
    --border-gold: rgba(225, 177, 44, 0.15); /* حدود الحاويات الشفافة المشوبة بالذهبي */
    --text-muted: #9c9cab;                 /* النصوص الثانوية الرمادية */
    --blur: blur(18px);                    /* تأثير الضبابية الزجاجي الخلفي */
    --transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    --radius: 24px;                        /* انحناء عصري موحد للحاويات */
    --radius-sm: 14px;                     /* انحناء الكروت والأزرار */
}

body { 
    font-family: 'IBM Plex Sans Arabic', 'Tajawal', Tahoma, sans-serif; 
    background: var(--sadeem-bg);
    color: #ffffff; 
    margin: 0; 
    line-height: 1.6; 
    overflow-x: hidden;
}

/* خلفية سديمية متوهجة ومتحركة خلف التصميم */
body::before {
    content: "";
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: 
        radial-gradient(circle at 20% 30%, rgba(124, 77, 255, 0.12) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(225, 177, 44, 0.08) 0%, transparent 50%);
    z-index: -1;
}

/* --- Header --- */
header { 
    background: rgba(10, 10, 15, 0.6); 
    backdrop-filter: var(--blur);
    padding: 1rem 5%; 
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05); 
    position: sticky; 
    top: 0; 
    z-index: 1000;
    box-shadow: var(--shadow);
    height: 80px;
}

.brand { display: flex; flex-direction: column; text-decoration: none; }
.brand .top { 
    font-family: 'Cinzel', serif; 
    color: #ffffff; 
    letter-spacing: 2px; 
    font-size: 1.3rem; 
    font-weight: 900; 
    text-shadow: 0 0 10px rgba(124, 77, 255, 0.5);
}
.brand .sub { 
    color: var(--soft-gold); 
    font-size: 0.65rem; 
    opacity: 0.9; 
    letter-spacing: 1px; 
    text-align: center; 
    margin-top: 2px;
}

.nav-links-desktop { display: flex; gap: 2rem; list-style: none; margin: 0; padding: 0; align-items: center; }
.nav-links-desktop a { text-decoration: none; color: #ddd; font-size: 0.95rem; transition: var(--transition); font-weight: 500; }
.nav-links-desktop a:hover { color: var(--soft-gold); text-shadow: 0 0 8px rgba(225, 177, 44, 0.4); }

.menu-btn { background: none; border: none; color: var(--soft-gold); font-size: 1.8rem; cursor: pointer; display: none; }

/* --- Sidebar --- */
.sidebar {
    position: fixed; top: 0; right: -300px; width: 280px; height: 100%;
    background: #111117; 
    border-left: 1px solid var(--border-gold);
    z-index: 2000; transition: var(--transition); display: flex; flex-direction: column;
    box-shadow: -10px 0 30px rgba(0,0,0,0.7);
    padding: 1.5rem 0;
}
.sidebar.active { right: 0; }
.sidebar-header { padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-gold); }
.sidebar ul { list-style: none; padding: 20px 0; margin: 0; }
.sidebar ul li a { text-decoration: none; color: #ffffff; display: flex; align-items: center; gap: 15px; padding: 14px 20px; transition: var(--transition); border-bottom: 1px solid rgba(255, 255, 255, 0.03); }
.sidebar ul li a:hover { background: rgba(124, 77, 255, 0.1); color: var(--soft-gold); }

.overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 1500; display: none; }
.overlay.active { display: block; }

/* --- About Section --- */
.about-agatha {
    padding: 40px 5%; display: flex; align-items: center; gap: 40px;
    background: var(--glass);
    backdrop-filter: var(--blur);
    margin: 40px 5%; border-radius: var(--radius); border: 1px solid var(--border-gold);
    box-shadow: var(--shadow);
}
.about-img { width: 130px; height: 130px; object-fit: cover; border-radius: 50%; border: 2px solid var(--soft-gold); box-shadow: 0 0 15px rgba(225, 177, 44, 0.2); }

/* --- Progress Bar --- */
.progress-container { max-width: 800px; margin: 30px auto; padding: 0 5%; text-align: center; }
.progress-bar-bg { width: 100%; height: 10px; background: rgba(255, 255, 255, 0.03); border-radius: 10px; overflow: hidden; border: 1px solid var(--border-gold); }
.progress-bar-fill { height: 100%; background: var(--royal-gold); box-shadow: 0 0 10px rgba(179, 136, 255, 0.5); transition: width 1.5s ease; }

/* --- Book Grid --- */
.book-grid { 
    display: grid; 
    grid-template-columns: repeat(4, 1fr); 
    gap: 25px; padding: 30px 5%; 
}

.book-card { 
    background: var(--glass); 
    backdrop-filter: var(--blur);
    border: 1px solid var(--border-gold); 
    border-radius: var(--radius-sm); padding: 20px; transition: var(--transition); 
    text-align: center; display: flex; flex-direction: column;
    box-shadow: var(--shadow);
}
.book-card:hover { transform: translateY(-8px); border-color: rgba(225, 177, 44, 0.4); box-shadow: 0 12px 24px rgba(0,0,0,0.6); }

.cover-container { border-radius: 10px; overflow: hidden; aspect-ratio: 2/3; margin-bottom: 15px; border: 1px solid rgba(255, 255, 255, 0.05); }
.cover-container img { width: 100%; height: 100%; object-fit: cover; transition: var(--transition); }
.book-card:hover .cover-container img { transform: scale(1.03); }

.book-title { font-family: 'Tajawal', sans-serif; font-size: 1.1rem; font-weight: 700; color: #ffffff; margin: 10px 0; min-height: 2.4em; line-height: 1.4; }
.download-stats { font-size: 0.85rem; color: var(--soft-gold); opacity: 0.9; margin-bottom: 15px; font-weight: 500; }

.btn-royal {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px; border: 1px solid var(--soft-gold); border-radius: 10px;
    text-decoration: none; color: var(--soft-gold); font-size: 0.85rem; font-weight: 600; transition: var(--transition);
    background: transparent;
}
.btn-royal:hover { background: var(--soft-gold); color: #000; font-weight: 700; box-shadow: 0 0 15px rgba(225, 177, 44, 0.3); }

/* --- Source Section --- */
.source-notice { margin: 60px 5% 30px; }
.source-container {
    max-width: 900px; margin: 0 auto;
    background: var(--glass);
    backdrop-filter: var(--blur);
    border: 1px solid var(--border-gold); border-radius: var(--radius); padding: 30px;
    display: flex; gap: 20px; align-items: flex-start; box-shadow: var(--shadow);
}
.source-icon { flex-shrink: 0; width: 50px; height: 50px; background: rgba(124, 77, 255, 0.15); border: 1px solid var(--color-accent); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--soft-gold); font-size: 1.4rem; }
.source-content h4 { font-family: 'Tajawal', sans-serif; font-weight: 700; color: #ffffff; font-size: 1.2rem; margin: 0 0 10px 0; }
.source-content p { font-size: 0.9rem; margin: 0; color: var(--text-muted); }
.source-content a { color: var(--soft-gold); text-decoration: none; font-weight: 700; }
.source-content a:hover { text-decoration: underline; }

/* --- Footer --- */
.legal-footer { padding: 40px 5%; background: #0a0a0f; border-top: 1px solid rgba(255, 255, 255, 0.05); text-align: center; margin-top: 60px; color: var(--text-muted); font-size: 0.9rem; }

/* ══════════════════════════════════════════════════════
   Collection Header (صفحة المكتبة كـ Collection اجتماعية/تحريرية)
   ══════════════════════════════════════════════════════ */
.collection-hero {
    max-width: 1100px; margin: 40px auto 0; padding: 0 5%;
    display: flex; gap: 32px; align-items: flex-start; flex-wrap: wrap;
}
.collection-portrait {
    width: 150px; height: 150px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
    border: 3px solid var(--soft-gold); box-shadow: 0 0 25px rgba(225, 177, 44, 0.2);
}
.collection-info { flex: 1 1 260px; min-width: 0; }
.collection-kicker { font-family: 'Cinzel', serif; color: var(--soft-gold); font-size: 0.78rem; letter-spacing: 0.15em; text-transform: uppercase; opacity: 0.85; margin-bottom: 6px; }
.collection-title { font-family: 'Amiri', serif; font-size: 2.2rem; color: #fff; margin: 0 0 10px; }
.collection-bio { color: var(--text-muted); font-size: 0.95rem; line-height: 1.8; max-width: 640px; margin-bottom: 18px; }
.collection-stats { display: flex; gap: 28px; flex-wrap: wrap; margin-bottom: 18px; }
.collection-stat { display: flex; flex-direction: column; }
.collection-stat b { font-size: 1.3rem; color: #fff; font-family: 'Tajawal', sans-serif; }
.collection-stat span { font-size: 0.75rem; color: var(--text-muted); }
.collection-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-ghost-gold {
    display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 20px;
    border: 1px solid var(--border-gold); border-radius: var(--radius-sm);
    color: var(--text-muted); background: transparent; font-size: 0.85rem; font-weight: 600;
    text-decoration: none; cursor: pointer; font-family: inherit; transition: var(--transition);
}
.btn-ghost-gold:hover { border-color: var(--soft-gold); color: var(--soft-gold); }

/* --- Tabs --- */
.collection-tabs {
    max-width: 1100px; margin: 36px auto 0; padding: 0 5%;
    display: flex; gap: 4px; border-bottom: 1px solid var(--border-gold);
}
.collection-tab {
    background: none; border: none; padding: 12px 20px; font-family: 'Tajawal', sans-serif;
    font-size: 0.92rem; font-weight: 600; color: var(--text-muted); cursor: pointer;
    border-bottom: 2px solid transparent; margin-bottom: -1px; transition: var(--transition);
}
.collection-tab:hover { color: #fff; }
.collection-tab.active { color: var(--soft-gold); border-bottom-color: var(--soft-gold); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* --- Sort bar --- */
.sort-bar { max-width: 1100px; margin: 22px auto 0; padding: 0 5%; display: flex; gap: 8px; flex-wrap: wrap; }
.sort-link {
    display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 999px;
    border: 1px solid var(--border-gold); color: var(--text-muted); font-size: 0.85rem;
    text-decoration: none; transition: var(--transition);
}
.sort-link:hover { border-color: var(--soft-gold); color: var(--soft-gold); }
.sort-link.active { background: var(--soft-gold); color: #000; border-color: var(--soft-gold); font-weight: 700; }

/* --- Book card engagement badges --- */
.book-engagement { display: flex; justify-content: center; gap: 14px; margin-bottom: 12px; font-size: 0.78rem; color: var(--text-muted); }
.book-engagement span { display: inline-flex; align-items: center; gap: 5px; }
.book-engagement i { color: var(--soft-gold); opacity: 0.8; }

/* --- Discussions tab --- */
.discussion-list { max-width: 800px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.discussion-item {
    display: flex; gap: 14px; background: var(--glass); border: 1px solid var(--border-gold);
    border-radius: var(--radius-sm); padding: 16px; backdrop-filter: var(--blur); align-items: flex-start;
}
.discussion-avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border-gold); flex-shrink: 0; }
.discussion-book-thumb { width: 40px; height: 56px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.discussion-body { flex: 1; min-width: 0; }
.discussion-head { font-size: 0.82rem; margin-bottom: 4px; }
.discussion-head b { color: var(--soft-gold); }
.discussion-head a { color: var(--text-muted); text-decoration: none; }
.discussion-head a:hover { color: #fff; }
.discussion-text { color: #ddd; font-size: 0.88rem; line-height: 1.6; margin-bottom: 6px; }
.discussion-date { font-size: 0.7rem; color: var(--text-muted); }

/* --- Ecosystem bridge card (يربط المكتبة بالمنشورات — هوية بنفسجية مقصودة لتمييز الانتقال) --- */
.ecosystem-bridge {
    max-width: 900px; margin: 50px auto; padding: 0 5%;
}
.ecosystem-bridge-inner {
    display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
    background: linear-gradient(135deg, rgba(124,77,255,0.12), rgba(124,77,255,0.04));
    border: 1px solid rgba(124,77,255,0.3); border-radius: var(--radius); padding: 28px 32px;
}
.ecosystem-bridge h4 { color: #fff; margin: 0 0 6px; font-family: 'Tajawal', sans-serif; font-size: 1.15rem; }
.ecosystem-bridge p { color: var(--text-muted); margin: 0; font-size: 0.88rem; }
.btn-bridge {
    display: inline-flex; align-items: center; gap: 8px; padding: 12px 24px; border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #7c4dff, #b388ff); color: #fff; text-decoration: none;
    font-weight: 700; font-size: 0.88rem; white-space: nowrap; transition: var(--transition);
}
.btn-bridge:hover { box-shadow: 0 6px 20px rgba(124,77,255,0.4); transform: translateY(-2px); }

/* --- Related books (صفحة الرواية) --- */
.related-books-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 16px; max-width: 1100px; margin: 0 auto; padding: 0 5%; }
.related-book-card { text-decoration: none; display: block; }
.related-book-card img { width: 100%; aspect-ratio: 2/3; object-fit: cover; border-radius: 8px; border: 1px solid var(--border-gold); margin-bottom: 8px; transition: var(--transition); }
.related-book-card:hover img { border-color: var(--soft-gold); transform: translateY(-4px); }
.related-book-card span { color: #ddd; font-size: 0.82rem; display: block; line-height: 1.4; }

/* --- Responsive --- */
@media (max-width: 1024px) { .book-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px) {
    .nav-links-desktop { display: none; }
    .menu-btn { display: block; }
    .about-agatha { flex-direction: column; text-align: center; gap: 20px; }
    .book-grid { grid-template-columns: repeat(2, 1fr); gap: 15px; padding: 15px 3%; }
    .source-container { flex-direction: column; align-items: center; text-align: center; }
    .collection-hero { flex-direction: column; align-items: center; text-align: center; }
    .collection-stats { justify-content: center; }
    .collection-actions { justify-content: center; }
    .collection-tabs { justify-content: center; overflow-x: auto; }
    .ecosystem-bridge-inner { flex-direction: column; text-align: center; }
    .discussion-item { flex-wrap: wrap; }
}
@media (max-width: 420px) {
    .related-books-grid { grid-template-columns: repeat(3, 1fr); }
}
/* --- البحث أعلى المكتبة + اقتراحات فورية + فلاتر --- */
.lib-search { position: relative; max-width: 1100px; margin: 18px auto 0; padding: 0 5%; }
.lib-search__form { position: relative; display: flex; align-items: center; }
.lib-search__form > i { position: absolute; inset-inline-start: 16px; color: var(--soft-gold); pointer-events: none; }
.lib-search__form input {
    width: 100%; min-height: 52px; padding: 0 48px; border-radius: 14px;
    border: 1px solid rgba(225, 177, 44, 0.35); background: rgba(18, 18, 24, 0.9); color: #fff;
    font-family: inherit; font-size: 16px; outline: none;
}
.lib-search__form input:focus { border-color: var(--soft-gold); box-shadow: 0 0 0 3px rgba(225, 177, 44, 0.15); }
.lib-search__form input::-webkit-search-cancel-button { display: none; }
.lib-search__clear {
    position: absolute; inset-inline-end: 4px; width: 44px; height: 44px; border: none; border-radius: 50%;
    background: transparent; color: var(--text-muted); font-size: 1.1rem; cursor: pointer;
}
.lib-suggest {
    position: absolute; z-index: 50; inset-inline: 5%; top: calc(100% + 6px); margin: 0; padding: 6px; list-style: none;
    background: #12121a; border: 1px solid rgba(225, 177, 44, 0.3); border-radius: 14px; box-shadow: var(--shadow);
}
.lib-suggest li a, .lib-suggest li button {
    display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 6px 10px; border-radius: 10px;
    color: #fff; text-decoration: none; background: transparent; border: none; font-family: inherit; font-size: 16px; text-align: start; cursor: pointer;
}
.lib-suggest li img { width: 32px; height: 48px; object-fit: cover; border-radius: 4px; flex: none; }
.lib-suggest li small { display: block; color: var(--text-muted); font-size: 0.8rem; }
.lib-suggest li.is-active a, .lib-suggest li a:hover, .lib-suggest li button:hover { background: rgba(225, 177, 44, 0.12); }
.lib-filters { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.lib-filter-row { display: flex; align-items: center; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.lib-filter-row::-webkit-scrollbar { display: none; }
.lib-filter-row > span { flex: none; color: var(--text-muted); font-size: 0.85rem; min-width: 3.5em; }
.lib-chip {
    flex: none; min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border-gold);
    background: transparent; color: #ddd; font-family: inherit; font-size: 0.9rem; cursor: pointer;
}
.lib-chip[aria-pressed="true"] { background: var(--soft-gold); border-color: var(--soft-gold); color: #000; font-weight: 700; }
.book-card[hidden] { display: none; }
.lib-empty { grid-column: 1 / -1; text-align: center; color: var(--text-muted); padding: 2rem 0; line-height: 1.8; }
.lib-empty button { margin-top: 8px; min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--soft-gold); background: transparent; color: var(--soft-gold); font-family: inherit; cursor: pointer; }
.cover-container { position: relative; }
.week-badge {
    position: absolute; top: 8px; inset-inline-start: 8px; z-index: 1;
    display: inline-flex; align-items: center; gap: 4px; padding: 4px 9px; border-radius: 999px;
    background: rgba(9, 9, 13, 0.85); border: 1px solid var(--soft-gold); color: var(--soft-gold);
    font-size: 0.8rem; font-weight: 700; white-space: nowrap; backdrop-filter: blur(6px);
}
.book-meta-line { margin: -4px 0 10px; color: var(--text-muted); font-size: 0.8rem; }

/* --- الوضع الفاتح (data-theme="light" من partials/_theme_head.html) --- */
.book-card-desc { font-size: 1rem; line-height: 1.7; color: #ccc; margin-bottom: 15px; height: 3.4em; overflow: hidden; opacity: 0.75; }
/* بطاقتان في الصف على الجوال: الوصف كامل في صفحة الكتاب، والبطاقة للغلاف والعنوان والإجراء */
@media (max-width: 480px) { .book-card-desc { display: none; } }
.book-card-more {
    display: flex; align-items: center; justify-content: center; min-height: 44px; margin-bottom: 6px;
    color: var(--soft-gold); text-decoration: none; font-size: 0.95rem;
}
.collection-tab { min-height: 44px; }
.collection-bio { font-size: 1rem !important; line-height: 1.8; }
.ecosystem-bridge p, .source-content p { font-size: 1rem; line-height: 1.7; }
:root[data-theme="light"] {
    --sadeem-bg: #f7f4ee;
    --glass: rgba(255, 255, 255, 0.92);
    --soft-gold: #7d5f1a;
    --border-gold: rgba(125, 95, 26, 0.22);
    --text-muted: #5f6a79;
    --shadow: 0 8px 24px rgba(27, 34, 48, 0.08);
}
:root[data-theme="light"] body { color: #1b2230; }
:root[data-theme="light"] body::before { opacity: 0.5; }
:root[data-theme="light"] .book-title,
:root[data-theme="light"] .source-content h4,
:root[data-theme="light"] .collection-title,
:root[data-theme="light"] .collection-stat b,
:root[data-theme="light"] .collection-tab:hover,
:root[data-theme="light"] .discussion-head a:hover,
:root[data-theme="light"] .ecosystem-bridge h4,
:root[data-theme="light"] .sidebar ul li a { color: #1b2230; }
:root[data-theme="light"] .book-card-desc,
:root[data-theme="light"] .discussion-text,
:root[data-theme="light"] .related-book-card span,
:root[data-theme="light"] .nav-links-desktop a,
:root[data-theme="light"] .lib-chip { color: #46505f; }
:root[data-theme="light"] .sidebar { background: #ffffff; }
:root[data-theme="light"] .legal-footer { background: #efe9dd; border-top-color: rgba(27, 34, 48, 0.08); }
:root[data-theme="light"] .book-card:hover { box-shadow: 0 12px 24px rgba(27, 34, 48, 0.12); }
:root[data-theme="light"] .lib-search__form input { background: #ffffff; color: #1b2230; border-color: rgba(125, 95, 26, 0.35); }
:root[data-theme="light"] .lib-suggest { background: #ffffff; }
:root[data-theme="light"] .lib-suggest li a,
:root[data-theme="light"] .lib-suggest li button { color: #1b2230; }
:root[data-theme="light"] .lib-chip[aria-pressed="true"] { background: #d9bc74; border-color: #c4a35a; color: #1b1406; }
:root[data-theme="light"] .sort-link.active { background: #d9bc74; border-color: #c4a35a; color: #1b1406; }
:root[data-theme="light"] .btn-royal:hover { background: #d9bc74; color: #1b1406; }
:root[data-theme="light"] .week-badge { background: rgba(255, 253, 248, 0.92); }
:root[data-theme="light"] .progress-bar-bg { background: rgba(27, 34, 48, 0.06); }
