
html { -webkit-font-smoothing: antialiased; }
body { overflow-x: hidden; }


::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c9a24b66; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #c9a24b; }


.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.glass {
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(201, 162, 75, 0.18);
}
.dark .glass {
    background: rgba(24, 24, 38, 0.55);
    border: 1px solid rgba(201, 162, 75, 0.15);
}


.btn-gold {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.75rem 1.75rem;
    border-radius: 9999px;
    font-weight: 600;
    color: #0b0b12;
    background: linear-gradient(135deg, #e5c877, #c9a24b);
    box-shadow: 0 10px 30px -8px rgba(201,162,75,.6);
    transition: transform .3s ease, box-shadow .3s ease, filter .3s ease;
}
.btn-gold:hover { transform: translateY(-2px); box-shadow: 0 16px 40px -8px rgba(201,162,75,.8); filter: brightness(1.05); }
.btn-gold:active { transform: translateY(0); }

.btn-ghost {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.75rem 1.75rem;
    border-radius: 9999px;
    font-weight: 500;
    border: 1px solid rgba(201,162,75,.45);
    color: inherit;
    transition: all .3s ease;
}
.btn-ghost:hover { background: rgba(201,162,75,.12); border-color: #c9a24b; transform: translateY(-2px); }


.nav-link { position: relative; padding: .25rem 0; transition: color .3s; }
.nav-link::after {
    content: ""; position: absolute; inset-inline-start: 0; bottom: -2px;
    width: 0; height: 2px; background: #c9a24b; transition: width .3s ease;
}
.nav-link:hover { color: #c9a24b; }
.nav-link:hover::after { width: 100%; }

#navbar.scrolled {
    background: rgba(255,255,255,.7);
    backdrop-filter: blur(14px);
    box-shadow: 0 4px 30px rgba(0,0,0,.06);
}
.dark #navbar.scrolled {
    background: rgba(11,11,18,.7);
    box-shadow: 0 4px 30px rgba(0,0,0,.4);
}


.social-icon {
    width: 40px; height: 40px; border-radius: 9999px;
    display: grid; place-items: center;
    border: 1px solid rgba(201,162,75,.4);
    font-weight: 600; font-size: .85rem; text-transform: lowercase;
    transition: all .3s ease;
}
.social-icon:hover { background: #c9a24b; color: #0b0b12; transform: translateY(-3px); box-shadow: 0 8px 20px -6px rgba(201,162,75,.7); }


.aurora {
    position: absolute; inset: 0; z-index: -10; overflow: hidden;
}
.aurora::before, .aurora::after {
    content: ""; position: absolute; border-radius: 50%;
    filter: blur(90px); opacity: .55;
    animation: drift 16s ease-in-out infinite alternate;
}
.aurora::before {
    width: 45vw; height: 45vw; top: -10%; left: -5%;
    background: radial-gradient(circle, #c9a24b88, transparent 70%);
}
.aurora::after {
    width: 40vw; height: 40vw; bottom: -15%; right: -5%;
    background: radial-gradient(circle, #7c5cff66, transparent 70%);
    animation-delay: -8s;
}
@keyframes drift {
    0%   { transform: translate(0,0) scale(1); }
    100% { transform: translate(40px,-30px) scale(1.15); }
}


.book-3d-wrap {
    width: 320px; height: 440px;
    perspective: 1600px;
    display: flex; align-items: center; justify-content: center;
    position: relative;
}

/* طبقة نصّ الرواية التي تظهر فوق الكتاب عند تمرير الماوس */
.book-pages-overlay {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(.94);
    width: 88%; height: 84%;
    background: linear-gradient(135deg, #fbf7ee, #f0e8d5);
    border: 1px solid rgba(201,162,75,.45);
    border-radius: 6px;
    box-shadow: 0 24px 60px -20px rgba(0,0,0,.55), inset 0 0 0 5px rgba(255,255,255,.35);
    padding: 16px 16px 12px;
    opacity: 0; pointer-events: none;
    transition: opacity .55s ease, transform .55s ease;
    overflow-y: auto; direction: rtl; text-align: justify; z-index: 5;
}
.book-3d-wrap:hover .book-pages-overlay,
.book-3d-wrap.is-open .book-pages-overlay {
    opacity: 1; transform: translate(-50%, -50%) scale(1); pointer-events: auto;
}
.book-pages-overlay h4 {
    margin: 0 0 .5rem; text-align: center; color: #a07f2e;
    font-family: "Amiri", serif; font-weight: 700; font-size: 1rem;
    border-bottom: 1px solid rgba(201,162,75,.4); padding-bottom: .4rem;
}
.book-pages-overlay p {
    margin: 0; color: #2b2b33; font-family: "Tajawal", sans-serif;
    font-size: .74rem; line-height: 1.65;
}
.book-pages-overlay::-webkit-scrollbar { width: 6px; }
.book-pages-overlay::-webkit-scrollbar-thumb { background: #c9a24b88; border-radius: 6px; }

.css-book {
    position: relative; width: 220px; height: 320px;
    transform-style: preserve-3d;
    transform: rotateY(-28deg) rotateX(6deg);
    animation: bookFloat 6s ease-in-out infinite;
}
@keyframes bookFloat {
    0%,100% { transform: rotateY(-28deg) rotateX(6deg) translateY(0); }
    50%     { transform: rotateY(-20deg) rotateX(6deg) translateY(-18px); }
}

.css-book__cover, .css-book__page {
    position: absolute; inset: 0; border-radius: 10px 4px 4px 10px;
}
.css-book__cover {
    background: linear-gradient(135deg, #26314a, #141a2a);
    border: 1px solid rgba(201,162,75,.4);
    box-shadow: 0 30px 60px -20px rgba(0,0,0,.7);
    transform: translateZ(18px);
    transform-origin: right center;
    transition: transform .9s cubic-bezier(.6,.02,.2,1);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 2rem; text-align: center;
    backface-visibility: hidden;
}

.book-3d-wrap:hover .css-book__cover { transform: translateZ(18px) rotateY(145deg); }
.css-book__cover h3 { font-family: "Amiri", serif; color: #e5c877; font-size: 1.9rem; font-weight: 700; line-height: 1.2; }
.css-book__cover span { color: #c9a24b; font-size: .8rem; letter-spacing: .2em; margin-top: 1rem; }
.css-book__spine {
    position: absolute; right: 0; top: 0; width: 36px; height: 100%;
    background: linear-gradient(#a07f2e,#7a5f22);
    transform: rotateY(-90deg) translateZ(-18px) translateX(18px);
    border-radius: 0 4px 4px 0;
}
.css-book__pages {
    position: absolute; left: -2px; top: 6px; bottom: 6px; width: 32px;
    background: repeating-linear-gradient(to right, #f4f1e8, #f4f1e8 1px, #dcd8c9 2px, #f4f1e8 3px);
    transform: translateZ(0) rotateY(0);
    border-radius: 4px 0 0 4px;
}


.novel-card { display: block; transition: transform .4s ease; }
.novel-card-inner { transition: box-shadow .4s ease, transform .4s ease; will-change: transform; }
.novel-card:hover .novel-card-inner {
    transform: translateY(-8px);
    box-shadow: 0 30px 60px -20px rgba(201,162,75,.45);
}


.writing-card { display: block; transition: transform .4s ease; }
.writing-card-inner { transition: box-shadow .4s ease, transform .4s ease; will-change: transform; }
.writing-card:hover .writing-card-inner {
    transform: translateY(-8px);
    box-shadow: 0 30px 60px -20px rgba(201,162,75,.4);
}


/* ---------- Timeline (خطّ زمني أحادي الجانب، يعمل مع RTL) ---------- */
.timeline { position: relative; max-width: 760px; margin: 0 auto; }
/* الخطّ العمودي على جهة البداية (اليمين في RTL) */
.timeline::before {
    content: ""; position: absolute; top: .4rem; bottom: .4rem;
    inset-inline-start: 9px; width: 2px;
    background: linear-gradient(#c9a24b, rgba(201,162,75,.12));
}
/* كل عنصر بعرض كامل، والمحتوى إلى يسار الخطّ */
.timeline-item {
    position: relative; width: 100%; box-sizing: border-box;
    padding-inline-start: 2.75rem; padding-inline-end: 0;
    margin-bottom: 1.75rem; text-align: start;
}
.timeline-item:last-child { margin-bottom: 0; }
/* إلغاء التبديل القديم يمين/يسار */
.timeline-item.left, .timeline-item.right { left: 0; width: 100%; text-align: start; }
/* النقطة على الخطّ (جهة البداية) */
.timeline-dot {
    position: absolute; top: 1.5rem;
    inset-inline-start: 2px;
    width: 16px; height: 16px; border-radius: 50%;
    background: #c9a24b; box-shadow: 0 0 0 5px rgba(201,162,75,.2);
}
.timeline-item.left .timeline-dot, .timeline-item.right .timeline-dot {
    inset-inline-start: 2px; left: auto; right: auto;
}


.loader-book {
    width: 64px; height: 64px; position: relative;
    display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 4px;
}
.loader-book span {
    display: block; background: #c9a24b; border-radius: 3px;
    animation: loaderPulse 1.2s ease-in-out infinite;
}
.loader-book span:nth-child(2){ animation-delay: .15s; }
.loader-book span:nth-child(3){ animation-delay: .45s; }
.loader-book span:nth-child(4){ animation-delay: .3s; }
@keyframes loaderPulse {
    0%,100% { opacity: .25; transform: scale(.85); }
    50%     { opacity: 1;   transform: scale(1); }
}
#page-loader.hidden-loader { opacity: 0; pointer-events: none; }


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

/* =============================================================
   الاستجابة للجوال (Responsive)
   ============================================================= */

/* الكتاب ثلاثي الأبعاد: يتقلّص ليناسب عرض الشاشة دون تجاوز أفقي */
@media (max-width: 1023px) {
    .book-3d-wrap { width: 300px; height: 412px; }
}
@media (max-width: 640px) {
    .book-3d-wrap { width: min(80vw, 300px); height: min(110vw, 412px); }
    .book-pages-overlay { padding: 14px; }
    .book-pages-overlay h4 { font-size: .9rem; }
    .book-pages-overlay p  { font-size: .68rem; line-height: 1.6; }
}
@media (max-width: 400px) {
    .book-3d-wrap { width: 86vw; height: 118vw; }
    .book-pages-overlay p { font-size: .64rem; }
}
/* على الهاتف: إخفاء الكتاب ثلاثي الأبعاد نهائيًا (توفيرًا لموارد الجهاز) */
@media (max-width: 767px) {
    .book-3d-wrap { display: none !important; }
}

/* على اللمس: أظهِر تلميحًا بأن الكتاب قابل للنقر */
@media (hover: none) {
    .book-3d-wrap { cursor: pointer; }
}

/* تقليل حدّة الخلفية المتوهّجة على الجوال + منع أي تمرير أفقي */
@media (max-width: 640px) {
    html, body { overflow-x: hidden; max-width: 100%; }
    .aurora::before, .aurora::after { filter: blur(64px); opacity: .4; }
    /* تكبير مناطق اللمس للأزرار الدائرية الصغيرة */
    .social-icon { width: 44px; height: 44px; }
}

/* الخطّ الزمني: تأكيد المحاذاة على الجوال (RTL) */
@media (max-width: 640px) {
    .timeline-content { text-align: start; }
}

/* ---------- شريط الترقيم (صفحات المقالات والأرشيف) ---------- */
.pager-link {
    display: inline-grid;
    place-items: center;
    min-width: 44px;
    height: 44px;
    padding: 0 .9rem;
    border-radius: .75rem;
    border: 1px solid rgba(201,162,75,.25);
    font-size: .95rem;
    line-height: 1;
    color: inherit;
    transition: background-color .2s, border-color .2s, transform .2s;
}

.pager-link:hover {
    background: rgba(201,162,75,.12);
    border-color: #c9a24b;
    transform: translateY(-2px);
}

.pager-link--active {
    background: #c9a24b;
    border-color: #c9a24b;
    color: #0b0b12;
    font-weight: 600;
}

.pager-link--active:hover { transform: none; }

/* =============================================================
   سطح القراءة — صفحات المقالات
   القياس الفعلي قبل هذا: 90 حرفًا في السطر، والمريح 45–75.
   العرض بوحدة em حتى يتناسب مع حجم الخط الذي يختاره القارئ.
   ============================================================= */
.reading {
    --reading-size: 1.125rem;   /* 18px — الافتراضي */
    --reading-lead: 2;
    --reading-measure: 31em;    /* ≈ 70 حرفًا عند أي حجم خط */
}

.reading[data-reading-size="m"] { --reading-size: 1.28rem; --reading-lead: 1.95; }
.reading[data-reading-size="l"] { --reading-size: 1.45rem; --reading-lead: 1.9; }

.reading-body {
    font-size: var(--reading-size);
    line-height: var(--reading-lead);
    max-width: var(--reading-measure);
    margin-inline: auto;
}

/* الخلفية: الأبيض الناصع يُتعب العين في النصوص المتصلة.
   الفرق طفيف عمدًا حتى لا تتغيّر هوية الموقع. */
.reading-surface {
    background: #fdfbf7;
    border-radius: 1rem;
    padding: clamp(1.25rem, 4vw, 2.5rem) clamp(1rem, 3vw, 2rem);
}
.dark .reading-surface { background: #121220; }

/* ---------- شريط تفضيلات القراءة ----------
   عنوان صريح + ثلاثة أحجام متباينة بوضوح. الحالة الفعّالة نبرة ذهبية خفيفة
   لا كتلة صلبة، فهذه أداة ثانوية لا يجوز أن تسحب النظر من النصّ. */
.reading-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: .85rem;
    border-bottom: 1px solid rgba(201, 162, 75, .18);
}

.reading-bar__label {
    font-family: 'Tajawal', system-ui, sans-serif;
    font-size: .8rem;
    line-height: 1;
    letter-spacing: .04em;
    color: #9ca3af;
}
.dark .reading-bar__label { color: #6b7280; }

.reading-prefs {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
}

.reading-prefs__btn {
    font-family: 'Amiri', serif;
    line-height: 1;
    min-width: 2.3rem;
    height: 2.3rem;
    display: inline-grid;
    place-items: center;
    padding: 0;
    border: 1px solid transparent;
    border-radius: .55rem;
    background: transparent;
    color: #6b7280;  /* يعمل على الأرضيتين معًا: 4.68 على الفاتح و3.83 على الداكن */
    cursor: pointer;
    transition: color .18s, background-color .18s, border-color .18s;
}

.reading-prefs__btn:hover {
    color: #a07f2e;
    background: rgba(201, 162, 75, .09);
}
.reading-prefs__btn:focus-visible {
    outline: 2px solid #c9a24b;
    outline-offset: 2px;
}

.reading-prefs__btn[aria-pressed="true"] {
    color: #a07f2e;
    border-color: rgba(201, 162, 75, .45);
    background: rgba(201, 162, 75, .1);
}

/* فروق واضحة بالعين، لا مجرّد اختلاف رقمي */
.reading-prefs__btn[data-reading-size="s"] { font-size: .85rem; }
.reading-prefs__btn[data-reading-size="m"] { font-size: 1.15rem; }
.reading-prefs__btn[data-reading-size="l"] { font-size: 1.5rem; }
