/**
 * Clean, Minimalist & Fast CSS for Personal Website
 * Fully Responsive, Persian RTL-first, Accessible (WCAG AA)
 * Supports Light & Dark Modes, Micro-interactions, Crisp 1px Borders, Micro-shadows
 */

:root {
    --bg-color: #ffffff;
    --surface-color: #f8fafc;
    --surface-card: #ffffff;
    --surface-border: #e5e7eb;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --brand-primary: #2563eb;
    --brand-hover: #1d4ed8;
    --accent-color: #0284c7;
    --code-bg: #f8fafc;
    --border-radius: 10px;
    --max-width: 1200px;
    --transition-fast: 0.15s ease;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
    --card-shadow-hover: 0 6px 16px rgba(0, 0, 0, 0.06);
    --header-bg: #ffffff;
    --footer-bg: #ffffff;
}

[data-theme="dark"] {
    --bg-color: #0b0f19;
    --surface-color: #111827;
    --surface-card: #141d2f;
    --surface-border: #1f293d;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --brand-primary: #3b82f6;
    --brand-hover: #60a5fa;
    --accent-color: #38bdf8;
    --code-bg: #111827;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
    --card-shadow-hover: 0 6px 18px rgba(0, 0, 0, 0.45);
    --header-bg: #0b0f19;
    --footer-bg: #0b0f19;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

body {
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.7;
    direction: rtl;
    text-align: right;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Container */
.container {
    width: 100%;
    max-width: var(--max-width);
    margin-inline: auto;
    padding-inline: 20px;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 0.75rem;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

a {
    color: var(--brand-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover, a:focus {
    color: var(--brand-hover);
    text-decoration: underline;
}

/* Header & Navigation [Point 7] */
.site-header {
    background: var(--header-bg);
    border-bottom: 1px solid var(--surface-border);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.header-inner {
    display: flex;
    align-items: center;
    height: 70px;
    position: relative;
}

.site-logo {
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--text-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.logo-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--brand-primary);
    display: inline-block;
}

.site-nav-container {
    margin-inline-start: 36px;
    flex: 1;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 16px;
    list-style: none;
}

.nav-link {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    padding: 6px 12px;
    border-radius: var(--border-radius);
    transition: all var(--transition-fast);
}

.nav-link:hover, .nav-link.active {
    color: var(--brand-primary);
    background-color: var(--surface-color);
    text-decoration: none;
}

/* Header Actions & Theme Toggle [Point 6, Point 7] */
.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-inline-start: auto;
}

.theme-toggle-btn {
    background: transparent;
    border: 1px solid var(--surface-border);
    color: var(--text-primary);
    border-radius: 8px;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all var(--transition-fast);
}

.theme-toggle-btn:hover {
    background: var(--surface-color);
    border-color: var(--brand-primary);
}

[data-theme="dark"] .theme-icon-moon {
    display: none;
}
[data-theme="dark"] .theme-icon-sun {
    display: inline-block;
}
:not([data-theme="dark"]) .theme-icon-sun {
    display: none;
}
:not([data-theme="dark"]) .theme-icon-moon {
    display: inline-block;
}

/* Mobile Nav Toggle [Point 7: strictly left in RTL] */
.mobile-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--surface-border);
    border-radius: 8px;
    width: 38px;
    height: 38px;
    cursor: pointer;
    padding: 8px 7px;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    transition: all var(--transition-fast);
}

.mobile-toggle:hover {
    background: var(--surface-color);
    border-color: var(--brand-primary);
}

.mobile-toggle .bar {
    width: 20px;
    height: 2px;
    background-color: var(--text-primary);
    border-radius: 2px;
    transition: all 0.2s ease;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 18px;
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    border: 1px solid transparent;
    transition: all var(--transition-fast);
}

.btn-primary {
    background-color: var(--brand-primary);
    color: #ffffff !important;
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
    background-color: var(--brand-hover);
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

.btn-outline {
    background-color: transparent;
    color: var(--text-primary);
    border-color: var(--surface-border);
}

.btn-outline:hover {
    background-color: var(--surface-color);
    border-color: var(--brand-primary);
    color: var(--brand-primary);
    text-decoration: none;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.82rem;
}

/* Hero Section */
.hero-section {
    padding: 60px 0 40px;
    border-bottom: 1px solid var(--surface-border);
}

.hero-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 40px;
    align-items: center;
}

.hero-content h1 {
    font-size: 2.2rem;
    margin-bottom: 8px;
}

.hero-title {
    font-size: 1.15rem;
    color: var(--brand-primary);
    font-weight: 600;
    margin-bottom: 16px;
}

.hero-bio {
    font-size: 1.05rem;
    color: var(--text-secondary);
    max-width: 650px;
    margin-bottom: 24px;
    line-height: 1.8;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.hero-avatar {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--surface-border);
    box-shadow: var(--card-shadow);
}

/* Section styling */
.section {
    padding: 50px 0;
    border-bottom: 1px solid var(--surface-border);
}

.section-header {
    margin-bottom: 32px;
}

.section-header h2 {
    font-size: 1.6rem;
    margin-bottom: 6px;
}

.section-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Skills [Point 3] */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.skill-card {
    background: var(--surface-card);
    border: 1px solid var(--surface-border);
    border-radius: var(--border-radius);
    padding: 22px;
    box-shadow: var(--card-shadow);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.skill-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-shadow-hover);
    border-color: var(--brand-primary);
}

.skill-card h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
}

/* Timeline */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 24px;
    border-right: 2px solid var(--surface-border);
    padding-right: 20px;
    margin-right: 10px;
}

.timeline-item {
    position: relative;
}

.timeline-item::after {
    content: '';
    position: absolute;
    top: 6px;
    right: -26px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--brand-primary);
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
}

.timeline-title {
    font-size: 1.05rem;
    font-weight: 700;
}

.timeline-period {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.timeline-sub {
    font-size: 0.9rem;
    color: var(--brand-primary);
    margin-bottom: 6px;
}

/* Projects Grid [Point 3] */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

.project-card {
    background: var(--surface-card);
    border: 1px solid var(--surface-border);
    border-radius: var(--border-radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--card-shadow);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.project-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--card-shadow-hover);
    border-color: rgba(37, 99, 235, 0.4);
}

.project-img {
    width: 100%;
    height: 190px;
    object-fit: cover;
    background: var(--surface-color);
}

.project-body {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.project-title {
    font-size: 1.15rem;
    margin-bottom: 8px;
}

.project-summary {
    font-size: 0.9rem;
    color: var(--text-secondary);
    flex: 1;
    margin-bottom: 16px;
    line-height: 1.6;
}

.project-tech {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.badge-tech {
    background: var(--surface-color);
    color: var(--text-secondary);
    border: 1px solid var(--surface-border);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.78rem;
    direction: ltr;
}

.project-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: auto;
}

/* ======================================================================
   3-COLUMN BLOG LAYOUT
   ====================================================================== */
.blog-layout {
    display: grid;
    grid-template-columns: 240px 1fr 240px;
    gap: 28px;
    padding: 40px 0;
    align-items: start;
}

.blog-main {
    min-width: 0;
}

.blog-sidebar {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Widgets [Point 3, Point 9] */
.widget {
    background: var(--surface-card);
    border: 1px solid var(--surface-border);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--card-shadow);
}

.widget-title {
    font-size: 0.98rem;
    font-weight: 700;
    border-bottom: 2px solid var(--surface-border);
    padding-bottom: 8px;
    margin-bottom: 14px;
    color: var(--text-primary);
}

.widget-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.widget-list a {
    color: var(--text-secondary);
    font-size: 0.88rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: color var(--transition-fast);
}

.widget-list a:hover {
    color: var(--brand-primary);
    text-decoration: none;
}

.widget-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.widget-tag-item {
    background: var(--surface-color);
    border: 1px solid var(--surface-border);
    color: var(--text-secondary);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.widget-tag-item:hover {
    background: var(--brand-primary);
    color: #ffffff;
    text-decoration: none;
}

/* Post Cards [Point 3] */
.post-card {
    background: var(--surface-card);
    border: 1px solid var(--surface-border);
    border-radius: var(--border-radius);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--card-shadow);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.post-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-shadow-hover);
    border-color: rgba(37, 99, 235, 0.4);
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.post-meta-category {
    color: var(--brand-primary);
    font-weight: 600;
}

.post-card-title {
    font-size: 1.3rem;
    margin-bottom: 10px;
}

.post-card-title a {
    color: var(--text-primary);
    text-decoration: none;
}

.post-card-title a:hover {
    color: var(--brand-primary);
}

.post-card-excerpt {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 16px;
    line-height: 1.7;
}

.post-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Single Post View */
.post-detail {
    background: var(--surface-card);
    border: 1px solid var(--surface-border);
    border-radius: var(--border-radius);
    padding: 36px;
    box-shadow: var(--card-shadow);
}

.post-header {
    border-bottom: 1px solid var(--surface-border);
    padding-bottom: 24px;
    margin-bottom: 28px;
}

.post-header h1 {
    font-size: 1.9rem;
    margin-bottom: 14px;
}

.post-content {
    font-size: 1.05rem;
    line-height: 1.85;
    color: var(--text-primary);
}

.post-content h2, .post-content h3 {
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--border-radius);
    margin: 1.5rem 0;
}

.post-content pre {
    background: var(--code-bg);
    border: 1px solid var(--surface-border);
    border-radius: var(--border-radius);
    padding: 16px;
    overflow-x: auto;
    font-family: Consolas, Monaco, monospace;
    font-size: 0.9rem;
    direction: ltr !important;
    text-align: left !important;
    margin: 1.5rem 0;
}

.post-content code {
    font-family: Consolas, Monaco, monospace;
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.88em;
    direction: ltr;
    display: inline-block;
}

.post-content pre code {
    padding: 0;
    background: none;
    display: block;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 32px 0;
    list-style: none;
}

.page-item a, .page-item span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 10px;
    border: 1px solid var(--surface-border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
}

.page-item.active span, .page-item a:hover {
    background: var(--brand-primary);
    color: #ffffff;
    border-color: var(--brand-primary);
}

/* Form Controls */
.form-control {
    background-color: var(--surface-card);
    border: 1px solid var(--surface-border);
    color: var(--text-primary);
    border-radius: 6px;
    padding: 8px 12px;
    width: 100%;
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Footer [Point 8] */
.site-footer {
    background: var(--footer-bg);
    border-top: 1px solid var(--surface-border);
    padding: 40px 0 24px;
    margin-top: 60px;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.footer-copy {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.footer-links {
    display: flex;
    gap: 16px;
    font-size: 0.88rem;
}

.footer-links a {
    color: var(--text-muted);
}

.footer-links a:hover {
    color: var(--brand-primary);
}

/* Responsive Breakpoints & Mobile Header Fix [Point 7] */
@media (max-width: 992px) {
    .blog-layout {
        grid-template-columns: 1fr;
    }
    .blog-main {
        order: 1;
    }
    .blog-sidebar-left {
        order: 2;
    }
    .blog-sidebar-right {
        order: 3;
    }
    .hero-grid {
        grid-template-columns: 1fr;
        text-align: center;
    }
    .hero-avatar {
        margin: 0 auto;
    }
    .hero-actions {
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .site-nav-container {
        margin-inline-start: 0;
        flex: 0;
    }
    .site-nav {
        display: none;
        position: absolute;
        top: 70px;
        right: 0;
        left: 0;
        background: var(--header-bg);
        border-bottom: 1px solid var(--surface-border);
        box-shadow: var(--card-shadow-hover);
        flex-direction: column;
        padding: 16px;
        gap: 12px;
        z-index: 99;
    }
    .site-nav.open {
        display: flex;
    }
    .mobile-toggle {
        display: flex;
    }
    .post-detail {
        padding: 20px;
    }
}

/* Print CSS */
@media print {
    .site-header, .site-footer, .blog-sidebar, .btn, .no-print, .theme-toggle-btn, .mobile-toggle {
        display: none !important;
    }
    body {
        background: #fff;
        color: #000;
        font-size: 11pt;
    }
    .container {
        max-width: 100% !important;
        padding: 0 !important;
    }
    a {
        text-decoration: none !important;
        color: #000 !important;
    }
}
