/**
 * style.css — Arabic Blog CMS
 * Bootstrap 5 RTL base. Cairo font. Full RTL.
 * ─────────────────────────────────────────────
 */

/* ════════════════════════════════════════════
   0. FONT FALLBACK — size-adjust to match Cairo
   Minimises CLS when Cairo swaps in asynchronously.
   ════════════════════════════════════════════ */
@font-face {
    font-family: 'Cairo-fallback';
    src: local('Arial'), local('Helvetica Neue'), local('sans-serif');
    size-adjust: 105%;
    ascent-override: 105%;
    descent-override: 35%;
    line-gap-override: 0%;
}

/* ════════════════════════════════════════════
   0. ROOT / TOKENS
   ════════════════════════════════════════════ */
:root {
    --font-primary:   'Cairo', 'Cairo-fallback', sans-serif;
    --color-primary:  #2563eb;
    --color-secondary:#6b7280;
    --color-dark:     #111827;
    --color-light:    #f9fafb;
    --color-border:   #e5e7eb;
    --color-primary-soft: rgba(37,99,235,.08);
    --radius-sm:  .375rem;
    --radius-md:  .75rem;
    --radius-lg:  1.25rem;
    --shadow-sm:  0 1px 3px rgba(0,0,0,.06);
    --shadow-md:  0 4px 16px rgba(0,0,0,.1);
    --shadow-lg:  0 8px 32px rgba(0,0,0,.14);
    --transition: .2s ease;
}

/* ════════════════════════════════════════════
   1. GLOBAL RESET / BASE
   ════════════════════════════════════════════ */
*,::before,::after { box-sizing: border-box; }

html {
    font-size: 16px;
    scroll-behavior: smooth;
    direction: rtl;
}

body {
    font-family: var(--font-primary);
    color: var(--color-dark);
    background: #f5f6fa;
    line-height: 1.8;
    -webkit-font-smoothing: antialiased;
}

h1,h2,h3,h4,h5,h6 {
    font-family: var(--font-primary);
    font-weight: 700;
    line-height: 1.4;
    color: var(--color-dark);
}

a { color: var(--color-primary); transition: color var(--transition); }
a:hover { color: #1d4ed8; }
img { max-width: 100%; height: auto; }

/* scrollbar (optional cosmetic) */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 3px; }

/* ════════════════════════════════════════════
   2. UTILITY OVERRIDES
   ════════════════════════════════════════════ */
.bg-primary-soft { background: var(--color-primary-soft) !important; }
.text-primary    { color: var(--color-primary) !important; }
.object-fit-cover{ object-fit: cover; }

/* ════════════════════════════════════════════
   3. SITE HEADER / NAVBAR
   ════════════════════════════════════════════ */
.site-header { z-index: 1030; }

.navbar {
    padding-top: .75rem;
    padding-bottom: .75rem;
    box-shadow: var(--shadow-md);
}

.navbar-brand {
    font-size: 1.4rem;
    letter-spacing: -0.02em;
}

.navbar .nav-link {
    font-weight: 500;
    padding-left: 1rem;
    padding-right: 1rem;
    border-radius: var(--radius-sm);
    transition: background var(--transition), color var(--transition);
}

.navbar .nav-link:hover,
.navbar .nav-link.active {
    background: rgba(255,255,255,.12);
}

.search-form .form-control {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    min-width: 180px;
}

/* dropdown RTL fix */
.dropdown-menu {
    animation: fadeDown .15s ease;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--color-border);
    min-width: 200px;
}

.dropdown-menu-end[data-bs-popper] {
    left: auto;
    right: 0;
}

.mega-menu-dropdown .mega-categories-menu {
    min-width: min(90vw, 980px);
    max-width: min(90vw, 980px);
    border-radius: var(--radius-md);
}

.mega-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem 1.2rem;
    align-items: start;
}

.mega-col {
    padding: .25rem 0;
}

.mega-cat-title {
    font-weight: 700;
    color: #1f2937;
    text-decoration: none;
}

.mega-cat-title:hover {
    color: var(--color-primary);
}

.mega-sub-list li + li {
    margin-top: .3rem;
}

.mega-sub-link {
    color: #4b5563;
    font-size: .95rem;
    text-decoration: none;
}

.mega-sub-link .bi-dot {
    font-size: 1.1rem;
    line-height: 1;
    color: #9ca3af;
}

.mega-sub-link:hover {
    color: var(--color-primary);
}

@media (max-width: 991.98px) {
    .mega-menu-dropdown .mega-categories-menu {
        position: static;
        transform: none;
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        margin-top: .4rem;
    }

    .mega-grid {
        grid-template-columns: 1fr;
        gap: .75rem;
    }

    .navbar .navbar-collapse {
        padding-top: .5rem;
    }

    .mobile-cats-dropdown .mobile-cats-menu {
        position: static !important;
        float: none;
        width: 100%;
        min-width: 100%;
        margin-top: .35rem;
        padding: .25rem;
        border-radius: var(--radius-md);
        max-height: 45vh;
        overflow-y: auto;
    }

    .mobile-cats-menu .dropdown-item {
        border-radius: .55rem;
        padding: .6rem .7rem;
        font-weight: 600;
    }

    .mobile-cats-menu .dropdown-item + .dropdown-item {
        margin-top: .15rem;
    }
}

@keyframes fadeDown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ════════════════════════════════════════════
   4. HERO SLIDER
   ════════════════════════════════════════════ */
.hero-section {
    position: relative;
    overflow: hidden;
    background: #000;
}

.hero-slider {
    position: relative;
    height: 520px;
}

@media (max-width: 767px) { .hero-slider { height: 320px; } }

.hero-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity .6s ease;
    pointer-events: none;
}

.hero-slide.active {
    opacity: 1;
    pointer-events: auto;
}

.hero-slide-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.hero-slide-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transform: scale(1.03);
    transition: transform 6s ease;
}

.hero-slide.active .hero-slide-image {
    transform: scale(1);
}

.hero-slide-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to left, rgba(0,0,0,.7) 0%, rgba(0,0,0,.3) 100%);
}

.hero-slide-content {
    position: relative;
    z-index: 2;
    padding-top: 100px;
    padding-bottom: 60px;
}

@media (max-width: 767px) {
    .hero-slide-content { padding-top: 60px; padding-bottom: 30px; }
}

.hero-title {
    font-size: clamp(1.4rem, 3vw, 2.4rem);
    font-weight: 800;
    line-height: 1.3;
    text-shadow: 0 2px 8px rgba(0,0,0,.3);
}

.hero-excerpt { font-size: .95rem; }

.hero-prev,
.hero-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    background: rgba(255,255,255,.18);
    border: none;
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: background var(--transition);
}

.hero-prev:hover,
.hero-next:hover { background: rgba(255,255,255,.32); }

.hero-prev { right: 16px; }
.hero-next { left: 16px; }

.hero-dots {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 5;
}

.hero-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255,255,255,.5);
    border: none;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition);
    padding: 0;
}

.hero-dot.active {
    background: #fff;
    transform: scale(1.3);
}

/* ════════════════════════════════════════════
   5. SECTION HEADINGS
   ════════════════════════════════════════════ */
.section-title {
    position: relative;
    padding-bottom: .5rem;
    font-size: 1.25rem;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 48px;
    height: 3px;
    background: var(--color-primary);
    border-radius: 2px;
}

/* ════════════════════════════════════════════
   6. POST CARDS
   ════════════════════════════════════════════ */
.post-card {
    border-radius: var(--radius-md) !important;
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition);
}

.post-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg) !important;
}

.post-thumb {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    transition: transform .4s ease;
}

.post-card:hover .post-thumb { transform: scale(1.04); }

.home-categories-section {
    border-top: 1px solid var(--color-border);
    padding-top: 1.5rem;
}

.home-cat-card {
    border-radius: var(--radius-md) !important;
}

.home-cat-title {
    color: var(--color-text);
    font-weight: 700;
    font-size: 1.1rem;
}

.home-cat-title:hover {
    color: var(--color-primary);
}

.home-cat-sub-list {
    border-top: 1px solid var(--color-border);
    margin-top: .65rem;
    padding-top: .65rem;
}

.home-cat-sub-list li + li {
    margin-top: .4rem;
}

.home-cat-sub-link {
    color: #4b5563;
    font-size: .95rem;
}

.home-cat-sub-link .bi-dot {
    color: #9ca3af;
    margin-left: .2rem;
}

.home-cat-sub-link:hover {
    color: var(--color-primary);
}

.card-img-link { overflow: hidden; display: block; }

.post-title-link { line-height: 1.4; }
.post-title-link:hover { color: var(--color-primary) !important; }

.post-cats .badge {
    font-size: .72rem;
    font-weight: 600;
    padding: .3em .7em;
    border-radius: 20px;
}

.post-meta { font-size: .8rem; }

/* ════════════════════════════════════════════
   7. SINGLE POST
   ════════════════════════════════════════════ */
.post-single { background: #fff; border-radius: var(--radius-lg); padding: 2rem; box-shadow: var(--shadow-sm); }

.post-featured-img img {
    width: 100%;
    max-height: 480px;
    object-fit: cover;
}

.post-title { font-size: clamp(1.5rem, 3vw, 2.2rem); }

/* Article body typography */
.article-body {
    font-size: 1.05rem;
    line-height: 2;
    color: #1f2937;
}

.article-body h2 { font-size: 1.5rem; margin-top: 2rem; margin-bottom: 1rem; }
.article-body h3 { font-size: 1.25rem; margin-top: 1.5rem; margin-bottom: .75rem; }
.article-body h4 { font-size: 1.1rem; margin-top: 1.25rem; }

.article-body p { margin-bottom: 1.25rem; }

.article-body a {
    color: var(--color-primary);
    text-decoration: underline;
    text-decoration-color: rgba(37,99,235,.3);
}

.article-body a:hover { text-decoration-color: var(--color-primary); }

.article-body img {
    max-width: 100%;
    border-radius: var(--radius-md);
    margin: 1rem 0;
    box-shadow: var(--shadow-sm);
}

.article-body blockquote {
    border-right: 4px solid var(--color-primary);
    border-left: none;
    background: var(--color-primary-soft);
    padding: 1rem 1.5rem;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    margin: 1.5rem 0;
    font-style: italic;
}

.article-body ul,
.article-body ol {
    padding-right: 1.5rem;
    padding-left: 0;
    margin-bottom: 1.25rem;
}

.article-body li { margin-bottom: .4rem; }

.article-body pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1.25rem;
    border-radius: var(--radius-md);
    overflow-x: auto;
    font-size: .9rem;
    margin: 1.25rem 0;
}

.article-body code {
    background: #f1f5f9;
    padding: .1em .4em;
    border-radius: 4px;
    font-size: .88em;
}

.article-body table {
    width: 100%;
    margin: 1.25rem 0;
    border-collapse: collapse;
}

.article-body th,
.article-body td {
    border: 1px solid var(--color-border);
    padding: .6rem 1rem;
    text-align: right;
}

.article-body th { background: var(--color-primary-soft); font-weight: 700; }

/* ════════════════════════════════════════════
   8. BREADCRUMBS
   ════════════════════════════════════════════ */
.breadcrumb-nav { background: transparent; margin-bottom: 1rem; }

.breadcrumb {
    background: transparent;
    padding: 0;
    font-size: .85rem;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "‹";
    padding-left: .5rem;
    padding-right: .5rem;
    color: var(--color-secondary);
    direction: ltr;
}

/* ════════════════════════════════════════════
   9. SIDEBAR
   ════════════════════════════════════════════ */
.sidebar-widget { border-radius: var(--radius-md) !important; }

.widget-title { font-size: 1rem; font-weight: 700; }

.category-tree-list > .list-group-item {
    border-color: var(--color-border);
}

.category-sub-list {
    border-right: 2px solid var(--color-border);
    padding-right: .65rem;
    margin-right: .35rem;
}

.category-sub-list .badge {
    font-size: .7rem;
}

.category-collapse-toggle {
    color: #6b7280;
}

.category-collapse-toggle:hover {
    color: var(--color-primary);
}

.category-collapse-toggle .bi {
    transition: transform .2s ease;
}

.category-collapse-toggle[aria-expanded="true"] .bi {
    transform: rotate(180deg);
}

.recent-thumb {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.recent-post-title {
    font-size: .875rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.recent-post-item:last-child { border-bottom: none !important; }

.footer-links a:hover { color: #fff !important; }

/* ════════════════════════════════════════════
   10. CATEGORY HEADER
   ════════════════════════════════════════════ */
.category-header {
    border-right: 4px solid var(--color-primary);
}

/* ════════════════════════════════════════════
   11. SEARCH
   ════════════════════════════════════════════ */
.search-thumb {
    width: 120px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

/* ════════════════════════════════════════════
   12. PAGINATION
   ════════════════════════════════════════════ */
.pagination .page-link {
    border-radius: var(--radius-sm) !important;
    margin: 0 2px;
    color: var(--color-primary);
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
}

.pagination .page-item.active .page-link {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.pagination .page-link:hover { background: var(--color-primary-soft); }

/* ════════════════════════════════════════════
   13. POST NAV (prev/next)
   ════════════════════════════════════════════ */
.post-nav { border-radius: var(--radius-md) !important; margin-top: 2rem; }


/* ════════════════════════════════════════════
   14. SOCIAL SHARE
   ════════════════════════════════════════════ */
.social-share .btn { border-radius: 20px !important; font-size: .85rem; }

/* ════════════════════════════════════════════
   15. AD SLOTS
   ════════════════════════════════════════════ */
.ad-slot {
    border-radius: var(--radius-sm);
    contain: layout paint style;
    content-visibility: auto;
    contain-intrinsic-size: 120px;
}
.ad-slot:empty {
    min-height: 90px;
    border-radius: var(--radius-sm);
    /* remove the below in production — only for dev visibility */
    background: rgba(0,0,0,.02);
    border: 1px dashed rgba(0,0,0,.07);
}
.ad-sidebar  { min-height: 250px; }
.ad-article-top,
.ad-article-middle,
.ad-article-bottom { min-height: 120px; }
.ad-top,
.ad-content-top,
.ad-bottom { min-height: 100px; }
.ad-in-feed { min-height: 150px; }

@media (max-width: 767px) {
    /* Reserve realistic ad space on mobile to reduce CLS when ad scripts inject content. */
    .ad-top,
    .ad-content-top,
    .ad-in-feed { min-height: 250px; }
}

/* ════════════════════════════════════════════
   16. FOOTER
   ════════════════════════════════════════════ */
.site-footer { font-size: .9rem; }

.footer-heading {
    font-size: .75rem;
    letter-spacing: .08em;
    color: rgba(255,255,255,.45);
    margin-bottom: .75rem;
}

.footer-links a {
    color: rgba(255,255,255,.55);
    text-decoration: none;
    transition: color var(--transition);
}

.footer-links a:hover { color: #fff; }

/* ════════════════════════════════════════════
   17. ADMIN – OVERRIDES
   ════════════════════════════════════════════ */
.admin-sidebar {
    min-height: 100vh;
    background: #1e293b;
    width: 260px;
    flex-shrink: 0;
}

.admin-sidebar .nav-link {
    color: rgba(255,255,255,.7);
    border-radius: var(--radius-sm);
    padding: .6rem 1rem;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
}

.admin-sidebar .nav-link:hover,
.admin-sidebar .nav-link.active {
    background: rgba(255,255,255,.1);
    color: #fff;
}

.admin-sidebar .nav-link .bi { width: 1.25rem; }

.admin-content { flex: 1; overflow: auto; }

.admin-topbar {
    background: #fff;
    border-bottom: 1px solid var(--color-border);
    padding: .75rem 1.5rem;
}

/* ════════════════════════════════════════════
   18. IMAGE UPLOAD PREVIEW
   ════════════════════════════════════════════ */
.img-preview-wrap {
    position: relative;
    display: inline-block;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 2px solid var(--color-border);
}

.img-preview-wrap img {
    width: 200px;
    height: 130px;
    object-fit: cover;
    display: block;
}

/* ════════════════════════════════════════════
   19. STATIC PAGES (about / privacy / terms)
   ════════════════════════════════════════════ */
.static-page { background: #fff; border-radius: var(--radius-lg); padding: 2rem; box-shadow: var(--shadow-sm); }
.static-page h1 { font-size: clamp(1.4rem, 2.5vw, 2rem); margin-bottom: 1.5rem; }
.static-page h2 { font-size: 1.25rem; margin-top: 1.75rem; }
.static-page p  { margin-bottom: 1rem; line-height: 1.9; }

/* ════════════════════════════════════════════
   20. RESPONSIVE
   ════════════════════════════════════════════ */
@media (max-width: 991px) {
    .admin-sidebar { width: 100%; min-height: auto; }
}

@media (max-width: 767px) {
    .post-single  { padding: 1.25rem; }
    .article-body { font-size: 1rem; }
    .hero-title   { font-size: 1.3rem; }
    .post-thumb   { height: 170px; }
}

@media (max-width: 575px) {
    .search-thumb { width: 80px; height: 60px; }
}

/* ════════════════════════════════════════════
   21. PRINT
   ════════════════════════════════════════════ */
@media print {
    .site-header,
    .site-footer,
    .sidebar,
    .ad-slot,
    .social-share,
    .related-posts,
    .post-nav { display: none !important; }

    .article-body { font-size: 12pt; line-height: 1.7; }
    a::after { content: " (" attr(href) ")"; font-size: 9pt; color: #555; }
}


.footer-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: #fff;
}

.footer-description {
    font-size: 0.95rem;
    line-height: 1.8;
    color: rgba(255, 255, 255, 0.7);
}
[itemprop="description"] {
    display: none;
}
