/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .reading-progress-bar {
        transition: none;
    }

    .back-to-top {
        transition: none;
    }
}

:root {
    /* Colors - Premium Islamic Finance Theme */
    --primary-color: #0F4C3A;
    /* Deep Emerald Green */
    --accent-color: #D4AF37;
    /* Metallic Gold */
    --text-color: #333333;
    --bg-color: #FFFFFF;
    --sidebar-bg: #051a14;
    /* Very dark green, almost black */
    --sidebar-text: #FFFFFF;
    --light-gray: #f4f4f4;

    /* Layout */
    --sidebar-width-desktop: 20vw;
    --content-width-desktop: 80vw;
    --sidebar-width-post: 25vw;
    /* Smaller sidebar for posts */

    /* Typography */
    --font-heading: 'Alegreya', serif;
    /* Calligraphic serif with full Azeri support */
    --font-body: 'Inter', sans-serif;
    /* Clean, modern */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    color: var(--text-color);
    background: var(--bg-color);
    line-height: 1.6;
}

/* Article body typography */
.entry-content {
    font-size: 1.125rem;
    /* 18px */
    line-height: 1.8;
    color: var(--color-text);
}

.entry-content p {
    margin-bottom: 1.4em;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    color: var(--primary-color);
    margin-bottom: 1rem;
}

/* Article heading spacing */
.entry-content h2 {
    margin-top: 3rem;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.entry-content h3 {
    margin-top: 2.5rem;
    margin-bottom: 0.8rem;
    font-size: 1.3rem;
}

.entry-content h4 {
    margin-top: 2rem;
    margin-bottom: 0.5rem;
    font-size: 1.15rem;
}

.entry-content h5 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.entry-content h6 {
    margin-top: 1.2rem;
    margin-bottom: 0.5rem;
}

.entry-content ul,
.entry-content ol {
    margin-bottom: 1.4rem;
    margin-left: 1.5rem;
    padding-left: 0.5rem;
}

.entry-content li {
    margin-bottom: 0.5rem;
    line-height: 1.7;
}

/* Blockquotes — gold left border */
.entry-content blockquote {
    border-left: 4px solid var(--accent-color);
    padding: 1.25rem 1.5rem;
    margin: 2rem 0;
    background: var(--color-bg-warm);
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--color-text);
    border-radius: 0 6px 6px 0;
}

.entry-content blockquote p {
    margin-bottom: 0.75em;
}

.entry-content blockquote p:last-child {
    margin-bottom: 0;
}

/* Hide section dividers */
.entry-content hr {
    display: none;
}

/* Bold highlight for scannability */
.entry-content strong {
    color: var(--color-text);
    background: linear-gradient(to top, var(--color-highlight) 0%, var(--color-highlight) 45%, transparent 45%);
    padding: 0 2px;
}


a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s;
}

a:hover {
    color: var(--accent-color);
}

/* Layout Container */
.layout-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Sidebar (Hero) */
.hero-sidebar {
    position: relative;
    width: 100%;
    min-height: 20vh;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

/* ... (pseudo element remains) ... */

.hero-content {
    position: relative;
    z-index: 2;
    max-width: 600px;
    margin: 0;
    text-align: left;
}

.sidebar-footer {
    position: relative;
    z-index: 2;
    text-align: left;
    font-size: 0.75rem;
    opacity: 0.6;
    margin-top: auto;
    width: 100%;
}

/* Desktop Sidebar Navigation */
.desktop-sidebar-nav {
    margin-top: 2rem;
    display: none;
}

.desktop-sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.desktop-sidebar-nav li {
    margin-bottom: 0.25rem;
}

.desktop-sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    font-size: 0.95rem;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.desktop-sidebar-nav a:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    text-decoration: none;
}

.desktop-sidebar-nav a.active {
    color: var(--gold);
    background: rgba(255, 255, 255, 0.05);
}

.desktop-sidebar-nav .nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* ... (site-title, site-tagline remain) ... */

/* Main Content Area - Mobile First */
.main-content {
    padding: 1rem;
    width: 100%;
    margin: 0 auto;
}

/* Blog Post List (Single Column) */
.posts-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    /* Reduced from 2rem */
}

/* Mobile Title Adjustment */
.site-title {
    font-size: 2rem;
}


.post-card {
    margin-bottom: 0;
    /* Remove bottom margin as grid handles gap */
    padding-bottom: 0;
    border-bottom: none;
    background: white;
    padding: 1.5rem;
    border: 1px solid #eee;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s;
}

.post-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.post-card h2 {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.post-meta {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 1rem;
}

.post-excerpt {
    font-size: 1rem;
    color: var(--color-text-secondary);
    flex-grow: 1;
    /* Push read more to bottom */
    margin-bottom: 1rem;
}

.read-more {
    font-weight: 600;
    font-size: 0.9rem;
}

/* Pagination */
.pagination {
    margin-top: 4rem;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.pagination a,
.pagination span {
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    color: var(--text-color);
    transition: all 0.2s;
}

.pagination a:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.pagination .current-page {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Footer */
.site-footer {
    padding: 2rem 0;
    text-align: center;
    background: transparent;
    border-top: 1px solid var(--light-gray);
    margin-top: auto;
}

/* Desktop Styles */
@media (min-width: 768px) {
    .layout-container {
        flex-direction: row;
    }

    .hero-sidebar {
        width: var(--sidebar-width-desktop);
        height: 100vh;
        position: fixed;
        top: 0;
        left: 0;
    }

    .desktop-sidebar-nav {
        display: block;
    }

    .main-content {
        margin-left: var(--sidebar-width-desktop);
        width: var(--content-width-desktop);
        padding: 4rem;
        max-width: none;
    }

    /* Restore Grid for Desktop */
    .posts-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 2rem;
    }

    .site-title {
        font-size: 2.5rem;
        /* Restore size */
    }

    /* Post Page: same sidebar width as homepage, but cap content width */
    body.single-post .main-content {
        max-width: 900px;
    }
}

/* Table Styles (Glossary) */
.entry-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    font-size: 0.95rem;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
}

.entry-content th,
.entry-content td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #eee;
    vertical-align: top;
}

.entry-content th {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
    white-space: nowrap;
}

.entry-content tr:nth-child(even) {
    background-color: #f9fcfb;
    /* Very subtle tint of primary */
}

.entry-content tr:hover {
    background-color: #f0f0f0;
}

/* Related Posts Section */
.related-posts-container {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid #eee;
}

.related-posts-title {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
}

.related-posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
}

.related-post-card {
    background: #fcfcfc;
    padding: 1.25rem;
    border-radius: 6px;
    border: 1px solid #eee;
    transition: all 0.2s ease;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.related-post-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: var(--primary-color);
    background: white;
}

.related-post-title {
    font-weight: 600;
    color: var(--primary-color);
    line-height: 1.4;
    font-size: 1rem;
}

.related-post-card:hover .related-post-title {
    color: var(--accent-color);
}

/* Mobile Nav Toggle (Optional for now) */
.mobile-menu-toggle {
    display: none;
    /* Implement if needed */
}

/* Search Styles */
.sidebar-search {
    margin-top: 1.5rem;
    width: 100%;
}

.sidebar-search input {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-family: var(--font-body);
}

.sidebar-search input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.sidebar-search input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent-color);
}

.search-header {
    margin-bottom: 2rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 1rem;
}

.search-bar-container {
    margin-bottom: 3rem;
}

#main-search-input {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    border: 2px solid #eee;
    border-radius: 6px;
    font-family: var(--font-body);
    transition: border-color 0.3s;
}

#main-search-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* =============================================
   Glossary — Card-based layout
   ============================================= */
.entry-content .glossary-entry {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-left: 4px solid var(--accent-color);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.entry-content .glossary-entry:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.entry-content .glossary-term {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.entry-content .term-name {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: 0.01em;
}

.entry-content .term-arabic {
    font-size: 1.1rem;
    color: var(--accent-color);
    direction: rtl;
    font-weight: 600;
    opacity: 0.85;
}

.entry-content .glossary-def {
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--color-text-secondary);
    margin: 0;
    padding-left: 0;
}

/* =============================================
   Sitemap Page — Human-readable article index
   ============================================= */
.sitemap-section {
    margin-bottom: 2.5rem;
}

.sitemap-section-title {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent-color);
}

.sitemap-count {
    font-size: 0.85rem;
    font-weight: 400;
    color: #888;
    font-family: var(--font-body);
}

.sitemap-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sitemap-list li {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    transition: background 0.15s ease;
}

.sitemap-list li:hover {
    background: #f9fcfb;
}

.sitemap-list li:last-child {
    border-bottom: none;
}

.sitemap-list a {
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.95rem;
    line-height: 1.4;
    flex: 1;
}

.sitemap-list a:hover {
    color: var(--primary-color);
}

.sitemap-date {
    font-size: 0.8rem;
    color: #aaa;
    white-space: nowrap;
    flex-shrink: 0;
}

/* =============================================
   Reading Progress Bar
   ============================================= */
.reading-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    width: 0%;
    z-index: 9999;
    transition: width 0.15s ease-out;
    pointer-events: none;
}

/* On desktop the sidebar is fixed left, so start bar after it */
@media (min-width: 768px) {
    body.single-post .reading-progress-bar {
        left: var(--sidebar-width-post);
    }
}

/* =============================================
   Back to Top Button
   ============================================= */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.2s ease;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    line-height: 1;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    background: var(--accent-color);
    transform: translateY(-2px);
}

.back-to-top:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* =============================================
   Read Time Badge
   ============================================= */
.read-time {
    color: #999;
    font-size: 0.85rem;
}