/* =====================================================================
   content — الصفحات القانونية، الإعلانات، المدوّنة (النافذة J). كل الأصناف بالبادئة ct-
   • ألوان من رموز الثيمات (theme-base: --primary/--accent/--danger/--surface…) مع بدائل،
     فتعمل الثيمات الثلاثة. بلا تدرّجات وبلا إيموجي: الأيقونات SVG بقناع CSS.
   • خصائص منطقية (inline/block) فتعمل RTL وLTR بلا قواعد مكرّرة.
   ===================================================================== */

:root {
    --ct-ico-info: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5M12 7.6v.01'/%3E%3C/svg%3E");
    --ct-ico-warning: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3.5 2.8 19.5h18.4z'/%3E%3Cpath d='M12 10v4.2M12 17v.01'/%3E%3C/svg%3E");
    --ct-ico-promo: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20.6 13.4 13.4 20.6a2 2 0 0 1-2.8 0L3 13V3h10l7.6 7.6a2 2 0 0 1 0 2.8z'/%3E%3Ccircle cx='7.5' cy='7.5' r='1.5'/%3E%3C/svg%3E");
    --ct-ico-x: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6 6 18'/%3E%3C/svg%3E");
    --ct-ico-doc: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 3h7l5 5v13H7z'/%3E%3Cpath d='M14 3v5h5M10 13h6M10 17h6'/%3E%3C/svg%3E");
}

.ct-sr {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap;
}

/* ألوان الأنواع: معلومة = الأساسي، تنبيه = الخطر، عرض = البرتقالي */
.ct-bar, .ct-type, .ct-news-item {
    --ct-c: var(--primary);
    --ct-bg: var(--primary-soft, color-mix(in srgb, var(--primary) 10%, var(--surface)));
    --ct-ico: var(--ct-ico-info);
}
.ct-bar--warning, .ct-type--warning, .ct-news-item--warning {
    --ct-c: var(--danger, #d93a3f);
    --ct-bg: color-mix(in srgb, var(--danger, #d93a3f) 11%, var(--surface));
    --ct-ico: var(--ct-ico-warning);
}
.ct-bar--promo, .ct-type--promo, .ct-news-item--promo {
    --ct-c: var(--accent, #ff7a1a);
    --ct-bg: var(--accent-soft, color-mix(in srgb, var(--accent, #ff7a1a) 12%, var(--surface)));
    --ct-ico: var(--ct-ico-promo);
}

/* ===== شريط الإعلان (تحت الهيدر) ===== */
.ct-bar {
    background: var(--ct-bg);
    border-bottom: 1px solid color-mix(in srgb, var(--ct-c) 30%, var(--border));
    color: var(--text);
}
.ct-bar-in { display: flex; align-items: center; gap: 12px; padding: 9px 0; min-height: 48px; }
.ct-bar-ico {
    flex: none; width: 20px; height: 20px; background: var(--ct-c);
    -webkit-mask: var(--ct-ico) center / contain no-repeat;
            mask: var(--ct-ico) center / contain no-repeat;
}
.ct-bar-txt { margin: 0; flex: 1 1 auto; min-width: 0; font-size: .93rem; line-height: 1.6; overflow-wrap: anywhere; }
.ct-bar-txt strong { font-weight: 800; margin-inline-end: 6px; }
.ct-bar-body { color: var(--text); opacity: .86; }
.ct-bar-more {
    margin-inline-start: 6px; font-weight: 700; white-space: nowrap;
    text-decoration: underline; text-decoration-color: var(--ct-c); text-underline-offset: 3px;
}
.ct-bar-x { margin: 0; flex: none; }
.ct-bar-x button {
    width: 34px; height: 34px; padding: 0; border-radius: var(--radius-sm, 8px);
    border: 1px solid transparent; background: transparent; color: var(--text-dim);
    cursor: pointer; display: grid; place-items: center; transition: background .15s, color .15s;
}
.ct-bar-x button:hover { background: color-mix(in srgb, var(--ct-c) 16%, transparent); color: var(--text); }
.ct-bar-x button span {
    width: 16px; height: 16px; background: currentColor;
    -webkit-mask: var(--ct-ico-x) center / contain no-repeat;
            mask: var(--ct-ico-x) center / contain no-repeat;
}

/* ===== روابط الفوتر ===== */
.ct-foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 20px; margin: 0 0 12px; }
.ct-foot a { color: var(--text-dim); font-weight: 600; font-size: .9rem; }
.ct-foot a:hover { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }

/* ===== هيكل الصفحات ===== */
.ct-page, .ct-news, .ct-post, .ct-blog { padding: 26px 0 56px; }
.container.ct-narrow { max-width: 780px; }
.ct-head { margin: 0 0 24px; }
.ct-head h1 { font-size: clamp(1.65rem, 4vw, 2.3rem); font-weight: 800; margin: 10px 0 8px; line-height: 1.3; }
.ct-head--wide .ct-lead { max-width: 64ch; }
.ct-lead { color: var(--text-dim); font-size: 1.04rem; margin: 0; }
.ct-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--text-dim); font-size: .9rem; margin: 0; }
.ct-dot { width: 4px; height: 4px; border-radius: 50%; background: currentColor; opacity: .6; flex: none; }

.ct-crumbs ol {
    list-style: none; margin: 0 0 6px; padding: 0;
    display: flex; flex-wrap: wrap; gap: 6px; font-size: .86rem; color: var(--text-dim);
}
.ct-crumbs li { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.ct-crumbs li + li::before { content: '/'; color: var(--border-strong, var(--border)); }
.ct-crumbs a:hover { color: var(--primary); }
/* العنصر الأخير يلتفّ ولا يُقصّ: القصّ بنقاط في RTL كان يبتر الكلمات والأرقام («…في 26») */
.ct-crumbs [aria-current] { color: var(--text); font-weight: 600; }

/* ===== النصوص الطويلة (المقال، الصفحات القانونية، المحرّر) ===== */
.ct-prose { font-size: 1.02rem; line-height: 1.9; color: var(--text); overflow-wrap: anywhere; }
[dir="ltr"] .ct-prose { line-height: 1.75; }
.ct-prose > :first-child { margin-top: 0; }
.ct-prose p { margin: 0 0 1em; }
.ct-prose h2 { font-size: 1.36rem; font-weight: 800; margin: 1.8em 0 .55em; line-height: 1.4; }
.ct-prose h3 { font-size: 1.15rem; font-weight: 800; margin: 1.5em 0 .5em; line-height: 1.45; }
.ct-prose h4 { font-size: 1.02rem; font-weight: 800; margin: 1.3em 0 .4em; }
.ct-prose ul, .ct-prose ol { margin: 0 0 1.1em; padding-inline-start: 1.5em; }
.ct-prose li { margin: .35em 0; }
.ct-prose li::marker { color: var(--primary); }
.ct-prose a { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.ct-prose strong { font-weight: 800; }
.ct-prose blockquote {
    margin: 1.3em 0; padding: .8em 1.1em; border-inline-start: 3px solid var(--primary);
    background: var(--surface-2, var(--surface)); border-radius: var(--radius-sm, 8px); color: var(--text);
}
.ct-prose blockquote > :last-child { margin-bottom: 0; }
.ct-prose hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
.ct-prose img { display: block; max-width: 100%; height: auto; margin: 1.3em auto; border-radius: var(--radius, 12px); }
.ct-prose figure { margin: 1.4em 0; }
.ct-prose figure img { margin: 0 auto; }
.ct-prose figcaption { margin-top: .5em; text-align: center; color: var(--text-dim); font-size: .88rem; }
.ct-prose code {
    font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .88em;
    background: var(--surface-2, var(--surface)); padding: .1em .35em; border-radius: 4px;
}
.ct-prose pre {
    direction: ltr; text-align: left; overflow-x: auto; margin: 1.2em 0; padding: 1em;
    background: var(--surface-2, var(--surface)); border: 1px solid var(--border); border-radius: var(--radius-sm, 8px);
    line-height: 1.6;
}
.ct-prose pre code { background: none; padding: 0; }
/* الجدول يمرَّر أفقياً على الهاتف بدل أن يفيض الصفحة */
.ct-prose table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; margin: 1.2em 0; }
.ct-prose th, .ct-prose td { border: 1px solid var(--border); padding: .5em .8em; text-align: start; vertical-align: top; }
.ct-prose th { background: var(--surface-2, var(--surface)); font-weight: 700; }

/* صفحات ذات صلة (أسفل الصفحة القانونية) */
.ct-more { margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--border); }
.ct-more h2 { font-size: 1rem; margin: 0 0 10px; color: var(--text-dim); }
.ct-more ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 18px; }
.ct-more a { color: var(--primary); font-weight: 600; }

/* ===== الشارات ===== */
.ct-chip {
    display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px;
    font-size: .78rem; font-weight: 700; line-height: 1.6;
    background: var(--surface-2, var(--surface)); color: var(--text-dim); border: 1px solid var(--border);
}
.ct-chip--cat { background: var(--primary-soft, var(--surface-2)); color: var(--primary); border-color: transparent; }
.ct-chip--cat:hover { text-decoration: underline; }
.ct-chip--new { background: var(--primary); color: var(--primary-ct, #fff); border-color: var(--primary); }
.ct-type {
    display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: 999px;
    font-size: .8rem; font-weight: 700; line-height: 1.6; background: var(--ct-bg); color: var(--text);
}
[dir="rtl"] .ct-type { padding: 2px 8px 2px 10px; }
.ct-type-ico {
    width: 14px; height: 14px; flex: none; background: var(--ct-c);
    -webkit-mask: var(--ct-ico) center / contain no-repeat;
            mask: var(--ct-ico) center / contain no-repeat;
}

/* ===== أرشيف الإعلانات ===== */
.ct-news-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.ct-news-item {
    background: var(--surface); border: 1px solid var(--border); border-inline-start: 3px solid var(--ct-c);
    border-radius: var(--radius, 12px); padding: 16px 18px; scroll-margin-top: 90px;
}
.ct-news-item.is-new { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); border-inline-start-color: var(--ct-c); }
.ct-news-item.is-expired { opacity: .74; }
.ct-news-item:target { box-shadow: 0 0 0 3px var(--ring, rgba(14, 107, 255, .35)); }
.ct-news-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--text-dim); font-size: .85rem; margin: 0 0 8px; }
.ct-news-title { font-size: 1.12rem; font-weight: 800; margin: 0 0 6px; line-height: 1.45; }
.ct-news-body { line-height: 1.85; overflow-wrap: anywhere; }
.ct-news-body a { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.ct-empty {
    padding: 28px 18px; text-align: center; color: var(--text-dim);
    border: 1px dashed var(--border); border-radius: var(--radius, 12px);
}

/* ===== المدوّنة: الأقسام والبطاقات ===== */
.ct-cats { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 24px; }
.ct-cat {
    display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text-dim);
    font-weight: 600; font-size: .9rem; transition: border-color .15s, color .15s;
}
.ct-cat:hover { border-color: var(--primary); color: var(--text); }
.ct-cat.is-active { background: var(--primary); border-color: var(--primary); color: var(--primary-ct, #fff); }
.ct-cat-n { font-size: .75rem; opacity: .75; font-variant-numeric: tabular-nums; }

.ct-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 20px; }
.ct-card {
    display: flex; flex-direction: column; min-width: 0; overflow: hidden;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg, 16px);
    transition: border-color .15s, box-shadow .15s, transform .15s;
}
.ct-card:hover { border-color: var(--border-strong, var(--border)); box-shadow: var(--shadow); transform: translateY(-2px); }
.ct-card-media { display: block; aspect-ratio: 16 / 9; background: var(--surface-2, var(--bg)); overflow: hidden; }
.ct-card-media img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ct-card-ph { display: grid; place-items: center; width: 100%; height: 100%; }
.ct-card-ph::before {
    content: ''; width: 44px; height: 44px; background: var(--text-dim); opacity: .45;
    -webkit-mask: var(--ct-ico-doc) center / contain no-repeat;
            mask: var(--ct-ico-doc) center / contain no-repeat;
}
.ct-card-body { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 16px 18px 18px; flex: 1; }
.ct-card-title { font-size: 1.1rem; font-weight: 800; line-height: 1.45; margin: 0; }
.ct-card-title a {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ct-card-title a:hover { color: var(--primary); }
.ct-card-ex {
    margin: 0; color: var(--text-dim); font-size: .93rem; line-height: 1.7;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.ct-card-date { margin-top: auto; color: var(--text-dim); font-size: .82rem; }

/* ===== المقال ===== */
.ct-post .ct-head h1 { font-size: clamp(1.7rem, 4.4vw, 2.5rem); }
.ct-cover { margin: 6px 0 26px; }
.ct-cover img {
    display: block; width: 100%; height: auto; border-radius: var(--radius-lg, 16px);
    background: var(--surface-2, var(--surface));
}
.ct-alt-lang { margin: 28px 0 0; padding-top: 16px; border-top: 1px dashed var(--border); }
.ct-alt-lang a { color: var(--primary); font-weight: 700; }
.ct-related { margin-top: 40px; padding: 36px 0 8px; border-top: 1px solid var(--border); }
.ct-related h2 { font-size: 1.3rem; font-weight: 800; margin: 0 0 18px; }
.ct-preview {
    margin: 0 0 14px; padding: 10px 14px; border-radius: var(--radius-sm, 8px);
    background: var(--accent-soft, var(--surface-2)); border: 1px dashed var(--accent, var(--border)); font-weight: 600;
}

/* ===== الترقيم ===== */
.ct-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; margin: 32px 0 0; }
.ct-pager-info { color: var(--text-dim); font-size: .9rem; }

/* ===== الهاتف ===== */
@media (max-width: 720px) {
    .ct-page, .ct-news, .ct-post, .ct-blog { padding: 18px 0 44px; }
    .ct-bar-in { align-items: flex-start; gap: 10px; padding: 8px 0; }
    .ct-bar-ico { width: 18px; height: 18px; margin-top: 3px; }
    .ct-bar-txt { font-size: .88rem; }
    .ct-bar-x button { width: 32px; height: 32px; }
    .ct-prose { font-size: 1rem; }
    .ct-prose h2 { font-size: 1.24rem; }
    .ct-news-item { padding: 14px; }
    .ct-grid { gap: 16px; }
    .ct-cats { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; margin-inline: -4%; padding-inline: 4%; scrollbar-width: thin; }
    .ct-cat { flex: none; }
}

/* =====================================================================
   اللوحة (داخل غلاف D) — المحرّر والنماذج
   ===================================================================== */
.ct-adm-lang > legend, .ct-adm-lang .adm-h2 { font-weight: 800; }
.ct-adm-lang .adm-h2 { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 0; }
.ct-adm-clock { margin: 4px 0 12px; color: var(--text-dim); font-size: .9rem; }
.ct-adm-restore { border-style: dashed; }
.ct-adm-cover { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; margin-top: 6px; }
.ct-adm-cover-prev { margin: 0; }
.ct-adm-cover-prev img { display: block; width: 220px; max-width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--border); }
.ct-adm-seo, .ct-adm-del, .ct-adm-rowedit { margin: 6px 0; }
.ct-adm-seo > summary, .ct-adm-del > summary, .ct-adm-rowedit > summary { cursor: pointer; font-weight: 700; }
.ct-adm-seo[open] > summary, .ct-adm-rowedit[open] > summary { margin-bottom: 10px; }
.ct-adm-del > summary { color: var(--danger, #dc2626); list-style: none; }
.ct-adm-del > summary::-webkit-details-marker { display: none; }
.ct-adm-del > summary:hover { text-decoration: underline; }
.ct-time { white-space: nowrap; }
.ct-adm-del form, .ct-adm-del-inline { display: grid; gap: 8px; margin-top: 8px; }
.ct-adm-lang-row { align-items: end; }
.ct-count { margin-inline-start: 6px; font-size: .78rem; font-weight: 600; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.ct-count.is-over { color: var(--danger, #dc2626); }

/* المحرّر: textarea عادي بلا JS؛ مع JS شريط أدوات + منطقة تحرير */
.ct-ed { border: 1px solid var(--border); border-radius: 10px; background: var(--bg); overflow: hidden; }
.ct-ed:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring, rgba(14, 107, 255, .35)); }
.ct-ed-bar {
    display: flex; flex-wrap: wrap; gap: 4px; padding: 6px;
    border-bottom: 1px solid var(--border); background: var(--surface-2, var(--surface));
}
.ct-ed-btn {
    min-width: 34px; height: 32px; padding: 0 8px; border-radius: 7px; border: 1px solid transparent;
    background: transparent; color: var(--text); font: inherit; font-size: .8rem; font-weight: 700;
    cursor: pointer; display: inline-grid; place-items: center; white-space: nowrap;
}
.ct-ed-btn:hover { background: var(--surface); border-color: var(--border); }
.ct-ed-btn[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--primary-ct, #fff); }
.ct-ed-btn:disabled { opacity: .45; cursor: default; }
.ct-ed-btn i {
    --ico: none;   /* القيمة الحقيقية يضعها content-editor.js على العنصر نفسه (style) */
    display: block; width: 18px; height: 18px; background: currentColor;
    -webkit-mask: var(--ico) center / contain no-repeat;
            mask: var(--ico) center / contain no-repeat;
}
.ct-ed-sep { width: 1px; align-self: stretch; margin: 4px 2px; background: var(--border); }
.ct-ed-area {
    min-height: 300px; max-height: 70vh; overflow-y: auto; padding: 14px 16px;
    background: var(--surface); outline: none;
}
.ct-ed-area img { cursor: default; }
.ct-ed .ct-ed-src {
    display: none; width: 100%; min-height: 300px; border: 0; border-radius: 0; padding: 14px 16px;
    font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .84rem; line-height: 1.6;
    direction: ltr; text-align: left; background: var(--surface); color: var(--text); resize: vertical;
}
.ct-ed.is-source .ct-ed-src { display: block; }
.ct-ed.is-source .ct-ed-area { display: none; }
.ct-ed-status { padding: 4px 10px; font-size: .8rem; color: var(--text-dim); border-top: 1px solid var(--border); }
.ct-ed-status:empty { display: none; }
textarea.ct-ed-src { width: 100%; }
