/* =========================================================
   Despair 3.1 — لغة الأشكال الجديدة
   ---------------------------------------------------------
   تُحمَّل بعد كل أنماط القالب، وتعيد صياغة الهوية البصرية:
   أغلفة بزوايا مقصوصة قطرياً، عناوين بعمود جمري، بطاقات
   مسطّحة بخطّ سفلي متوهّج، ورفوف بحواف متلاشية.
   ========================================================= */

/* ---------------------------------------------------------
   1. الأساسيات
   --------------------------------------------------------- */
body {
    font-family: var(--font);
    background:
        radial-gradient(1200px 620px at 100% -10%, rgba(255, 107, 53, 0.055), transparent 62%),
        radial-gradient(900px 520px at 0% 8%, rgba(255, 201, 74, 0.035), transparent 60%),
        var(--bg);
    background-attachment: fixed;
}

h1, h2, h3, .galsa-section-title, .wt-title {
    letter-spacing: -0.015em;
}

::selection { background: var(--primary-soft2); color: var(--text); }

/* ---------------------------------------------------------
   2. الأغلفة — الزوايا المقصوصة هي توقيع القالب
   --------------------------------------------------------- */
.cover-wrapper,
.cover-image,
.cover-placeholder,
.slide-cover,
.slide-image,
.slide-placeholder,
.list-cover,
.rf-grid-item .cover-wrapper,
.wt-reco-cover,
.trend-img,
.ru-cover,
.dsp-chaprow-thumb,
.dsp-teamcard-logo {
    border-radius: var(--radius-poster) !important;
    overflow: hidden;
}

.wt-cover,
.wt-cover img {
    border-radius: 6px 28px 6px 28px !important;
}

/* وهج جمري خفيف خلف الغلاف عند المرور */
.webtoon-card .cover-wrapper,
.slide-card .slide-cover {
    position: relative;
    transition: transform var(--t) var(--ease-out), box-shadow var(--t);
}

.webtoon-card:hover .cover-wrapper,
.slide-card:hover .slide-cover {
    transform: translateY(-5px);
    box-shadow: 0 16px 34px rgba(0, 0, 0, .5), 0 0 0 1px var(--primary-ring);
}

html.light .webtoon-card:hover .cover-wrapper,
html.light .slide-card:hover .slide-cover {
    box-shadow: 0 16px 34px rgba(48, 32, 18, .18), 0 0 0 1px var(--primary-ring);
}

/* ---------------------------------------------------------
   3. البطاقات — مسطّحة بخط سفلي يتوهّج
   --------------------------------------------------------- */
.webtoon-card,
.slide-card {
    position: relative;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.webtoon-card::after,
.slide-card::after {
    content: '';
    position: absolute;
    inset-inline: 6px;
    bottom: -4px;
    height: 2px;
    border-radius: 2px;
    background: var(--grad-accent);
    transform: scaleX(0);
    transform-origin: right;
    transition: transform var(--t) var(--ease-out);
    pointer-events: none;
}

.webtoon-card:hover::after,
.slide-card:hover::after { transform: scaleX(1); }

.webtoon-title-card a,
.slide-title a,
.slide-title {
    transition: color var(--t-fast);
}

.webtoon-card:hover .webtoon-title-card a,
.slide-card:hover .slide-title { color: var(--primary-400); }

/* شارات الحالة — شكل مائل مميّز */
.status-badge,
.slide-new,
.new-badge {
    border-radius: 3px 10px 3px 10px !important;
    font-weight: 800 !important;
    letter-spacing: .01em;
}

/* ---------------------------------------------------------
   4. عناوين الأقسام — عمود جمري بدل الخط السفلي
   --------------------------------------------------------- */
.galsa-section-head,
.wt-chapters-head,
.rf-results-head {
    position: relative;
}

.galsa-section-title {
    position: relative;
    padding-inline-start: 15px;
    border: 0 !important;
}

.galsa-section-title::before {
    content: '';
    position: absolute;
    inset-inline-start: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 72%;
    min-height: 18px;
    border-radius: 4px;
    background: var(--grad-accent);
}

.galsa-section-title::after { display: none !important; }

.galsa-section-icon {
    border-radius: var(--radius-poster-sm) !important;
    background: var(--primary-soft) !important;
    color: var(--primary-400) !important;
}

.galsa-more {
    border-radius: var(--radius-pill);
    transition: gap var(--t-fast), color var(--t-fast);
}
.galsa-more:hover { gap: 10px; color: var(--primary-400); }

/* ---------------------------------------------------------
   5. الرفوف الأفقية — حواف متلاشية
   --------------------------------------------------------- */
.galsa-rail {
    -webkit-mask-image: linear-gradient(to left, transparent 0, #000 26px, #000 calc(100% - 26px), transparent 100%);
    mask-image: linear-gradient(to left, transparent 0, #000 26px, #000 calc(100% - 26px), transparent 100%);
    scroll-padding-inline: 20px;
}

@media (max-width: 640px) {
    .galsa-rail {
        -webkit-mask-image: linear-gradient(to left, #000 0, #000 calc(100% - 18px), transparent 100%);
        mask-image: linear-gradient(to left, #000 0, #000 calc(100% - 18px), transparent 100%);
    }
}

/* ---------------------------------------------------------
   6. صفحة العمل — ترويسة بقصّة قطرية
   --------------------------------------------------------- */
.wt-backdrop::after {
    content: '';
    position: absolute;
    inset-inline: 0;
    bottom: -1px;
    height: 90px;
    background: var(--bg);
    clip-path: polygon(0 100%, 100% 22%, 100% 100%);
    pointer-events: none;
}

.wt-title {
    font-size: clamp(22px, 4vw, 36px);
    font-weight: 900;
}

.wt-badge {
    border-radius: 4px 14px 4px 14px !important;
    font-weight: 700;
}

.wt-cta {
    border-radius: var(--radius-sm) !important;
}

/* صفوف الفصول — علامة جمرية على الحافة */
.chapter-item {
    position: relative;
    border-radius: var(--radius-sm) !important;
    transition: background var(--t-fast), transform var(--t-fast);
}

.chapter-item::before {
    content: '';
    position: absolute;
    inset-inline-start: 0;
    top: 50%;
    transform: translateY(-50%) scaleY(0);
    width: 3px;
    height: 58%;
    border-radius: 3px;
    background: var(--grad-accent);
    transition: transform var(--t-fast) var(--ease-out);
}

.chapter-item:hover { transform: translateX(-3px); }
.chapter-item:hover::before { transform: translateY(-50%) scaleY(1); }

/* ---------------------------------------------------------
   7. الأرشيف والفلاتر
   --------------------------------------------------------- */
.rf-chip,
.rf-active-chip {
    border-radius: var(--radius-pill) !important;
}

.rf-panel,
.rf-bar {
    border-radius: var(--radius-lg) !important;
}

.rf-icon-btn { border-radius: var(--radius-sm) !important; }

/* ---------------------------------------------------------
   8. القارئ — شريط علوي أنحف وأدكن
   --------------------------------------------------------- */
.ch-topbar {
    backdrop-filter: blur(18px) saturate(150%);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
}

.ch-back-btn { border-radius: var(--radius-sm); }

/* ---------------------------------------------------------
   9. الفرق
   --------------------------------------------------------- */
.dsp-teamcard {
    border-radius: var(--radius-lg) !important;
    overflow: hidden;
}

.dsp-team-badge { border-radius: var(--radius-pill) !important; }

.dsp-rank-chip { border-radius: 4px 12px 4px 12px !important; }

/* ---------------------------------------------------------
   10. المدخلات
   --------------------------------------------------------- */
input[type="text"],
input[type="search"],
input[type="url"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
    font-family: var(--font);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ---------------------------------------------------------
   11. شريط التمرير
   --------------------------------------------------------- */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--surface4) transparent;
}

*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
    border-radius: var(--radius-pill);
    background: var(--surface4);
    border: 2px solid transparent;
    background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--primary-600); background-clip: content-box; }

/* ---------------------------------------------------------
   12. تقليل الحركة عند الطلب
   --------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---------------------------------------------------------
   13. تحسينات الجوال العامة
   --------------------------------------------------------- */
@media (max-width: 640px) {
    .galsa-section { margin-bottom: 30px; }
    .galsa-section-title { font-size: 17px; padding-inline-start: 12px; }

    .wt-page { padding-bottom: 20px; }

    /* أهداف لمس أكبر */
    .dsp-btn { min-height: 42px; }
    .dsp-chip, .rf-chip { min-height: 34px; }

    /* لا تمرير أفقي للصفحة */
    html, body { overflow-x: hidden; }
}

/* ---------------------------------------------------------
   14. توافق: عناصر قديمة ما زالت مستخدمة في بعض القوالب
   --------------------------------------------------------- */
.dsp-icon-btn {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text2);
    font-size: 15px;
    cursor: pointer;
    transition: all var(--t-fast);
}
.dsp-icon-btn:hover {
    color: var(--text);
    border-color: var(--border-primary);
    background: var(--surface2);
}

.dsp-icon-badge {
    position: absolute;
    top: -5px;
    inset-inline-end: -5px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-pill);
    background: var(--primary-color);
    color: var(--text-on-primary);
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
}
