@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700&display=swap');

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #ff8e6c;
    --primary-light: #ffe6dc;
    --primary-dark: #cc6b55;
    --text: #1a1a2e;
    --text-light: #555;
    --text-muted: #888;
    --bg: #fafafa;
    --white: #fff;
    --border: #e2e2e2;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --radius: 8px;
    --max-width: 900px;
}

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

body {
    font-family: 'Tajawal', sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    text-align: right;
    line-height: 1.8;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}
a:hover {
    color: var(--primary-dark);
}

img { max-width: 100%; height: auto; }

/* Header */
.site-header {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0.2rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.site-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}
.site-logo img {
    height: 72px;
    width: auto;
}
.site-logo:hover { opacity: 0.85; }
.site-slogan {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-muted);
    border-right: 1px solid var(--border);
    padding-right: 0.5rem;
    line-height: 1.3;
}

.header-nav {
    display: flex;
    gap: 1.2rem;
    align-items: center;
}
.header-nav a {
    color: var(--text-light);
    font-size: 0.95rem;
    font-weight: 500;
}
.header-nav a:hover { color: var(--primary); }

.search-box {
    display: flex;
    align-items: center;
}
.search-box form {
    display: flex;
    align-items: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    overflow: hidden;
    transition: border-color 0.2s;
}
.search-box form:focus-within {
    border-color: var(--primary);
}
.search-box input[type="text"] {
    border: none;
    background: transparent;
    padding: 0.4rem 0.8rem;
    font-family: inherit;
    font-size: 0.9rem;
    width: 160px;
    direction: rtl;
    outline: none;
}
.search-box button {
    background: none;
    border: none;
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1rem;
}
.search-box button:hover { color: var(--primary); }

/* Main */
.main-content {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem 1.5rem;
    min-height: 60vh;
}

/* Section Titles */
.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.2rem;
    color: var(--text);
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary);
    display: inline-block;
}

/* Category Pills */
.categories-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 2rem;
}
.cat-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem 1rem;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    transition: all 0.2s;
}
.cat-pill:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}
.cat-pill .count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Dream Cards */
.dreams-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}
.dream-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem 1.4rem;
    transition: box-shadow 0.2s, border-color 0.2s;
}
.dream-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}
.dream-card h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
}
.dream-card h3 a {
    color: var(--text);
}
.dream-card h3 a:hover { color: var(--primary); }
.dream-card p {
    font-size: 0.9rem;
    color: var(--text-light);
    line-height: 1.7;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.dream-card .card-meta {
    margin-top: 0.6rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Article Page */
.article-header {
    margin-bottom: 2rem;
}
.article-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.5;
    margin-bottom: 0.8rem;
    color: var(--text);
}
.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}
.article-intro {
    font-size: 1.05rem;
    line-height: 1.9;
    color: var(--text-light);
    padding: 1rem 1.2rem;
    background: var(--primary-light);
    border-radius: var(--radius);
    border-right: 4px solid var(--primary);
    margin-bottom: 2rem;
}

.inline-link {
    color: var(--primary);
    text-decoration: underline;
    text-decoration-color: var(--primary-light);
    text-underline-offset: 3px;
    transition: color 0.2s, text-decoration-color 0.2s;
}
.inline-link:hover {
    color: var(--primary);
    text-decoration-color: var(--primary);
}

/* Table of Contents */
.toc {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem 1.5rem;
    margin-bottom: 2rem;
}
.toc-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.8rem;
    color: var(--primary);
}
.toc ol {
    list-style: none;
    counter-reset: toc-counter;
    padding: 0;
}
.toc li {
    counter-increment: toc-counter;
    margin-bottom: 0.4rem;
}
.toc li::before {
    content: counter(toc-counter) ". ";
    color: var(--primary);
    font-weight: 700;
}
.toc a {
    color: var(--text);
    font-size: 0.95rem;
}
.toc a:hover { color: var(--primary); }

/* Article Sections */
.article-section {
    margin-bottom: 2rem;
    scroll-margin-top: 80px;
}
.article-section h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.8rem;
    color: var(--primary);
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border);
}
.article-section p {
    font-size: 1.1rem;
    line-height: 1.2;
    font-weight: 400;
    color: var(--text);
}

/* Scholars */
.scholars-info {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}
.scholar-badge {
    padding: 0.3rem 0.8rem;
    background: var(--primary-light);
    color: var(--primary-dark);
    border-radius: 15px;
    font-size: 0.85rem;
    font-weight: 500;
}

/* Related Dreams */
.related-dreams {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}
.related-dreams h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text);
}
.related-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
}
.related-item {
    padding: 0.8rem 1rem;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: all 0.2s;
}
.related-item:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
    margin-top: 2.5rem;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    padding: 0.5rem 0.9rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    border: 1px solid var(--border);
    background: var(--white);
    color: var(--text);
    transition: all 0.2s;
}
.pagination a:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}
.pagination .current {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

/* Search Page */
.search-form-page {
    margin-bottom: 2rem;
}
.search-form-page form {
    display: flex;
    gap: 0.5rem;
}
.search-form-page input[type="text"] {
    flex: 1;
    padding: 0.7rem 1rem;
    font-family: inherit;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    direction: rtl;
    outline: none;
    transition: border-color 0.2s;
}
.search-form-page input[type="text"]:focus {
    border-color: var(--primary);
}
.search-form-page button {
    padding: 0.7rem 1.5rem;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}
.search-form-page button:hover {
    background: var(--primary-dark);
}

.search-results-count {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* Footer */
.site-footer {
    margin-top: 3rem;
    padding: 2rem 1.5rem;
    background: var(--white);
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}
.footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
}
.footer-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 0.8rem;
}
.footer-links a {
    color: var(--text-muted);
}
.footer-links a:hover { color: var(--primary); }

/* Breadcrumb */
.breadcrumb {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb span { margin: 0 0.3rem; }

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state p {
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

/* 404 */
.error-page {
    text-align: center;
    padding: 4rem 1rem;
}
.error-page h1 {
    font-size: 4rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}
.error-page p {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}
.error-page a {
    display: inline-block;
    padding: 0.6rem 1.5rem;
    background: var(--primary);
    color: var(--white);
    border-radius: var(--radius);
    font-weight: 500;
}
.error-page a:hover {
    background: var(--primary-dark);
    color: var(--white);
}

/* Responsive */
@media (max-width: 768px) {
    .header-inner {
        flex-wrap: wrap;
    }
    .header-nav {
        gap: 0.8rem;
        font-size: 0.85rem;
    }
    .search-box input[type="text"] {
        width: 120px;
    }
    .article-header h1 {
        font-size: 1.4rem;
    }
    .related-list {
        grid-template-columns: 1fr;
    }
    .main-content {
        padding: 1.5rem 1rem;
    }
}

@media (max-width: 480px) {
    .header-nav {
        display: none;
    }
    .search-box input[type="text"] {
        width: 140px;
    }
}
