/*
Theme Name: Cartfa
Theme URI: https://blog.cartfa.com
Author: Cartfa Team
Author URI: https://cartfa.com
Description: قالب سبک و پرمیوم وردپرس برای بلاگ خبری و آموزشی کارتفا با فونت فارسی وزیرمتن، پشتیبانی کامل RTL، آپلود لوگو و تنظیم سایز لوگو.
Version: 2.0.0
Requires at least: 6.0
Tested up to: 6.8
Requires PHP: 8.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: cartfa
Tags: blog, news, education, rtl-language-support, custom-logo, custom-menu, featured-images, threaded-comments, translation-ready, two-columns, right-sidebar
*/

@font-face {
    font-family: 'Vazirmatn';
    src: url('assets/fonts/Vazirmatn-Variable.woff2') format('woff2-variations'),
         url('assets/fonts/Vazirmatn-Variable.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

:root {
    --c-primary: #0f4c68;
    --c-primary-soft: #e8f3f8;
    --c-accent: #d4a017;
    --c-accent-soft: #fbf4e0;
    --c-text: #1c2430;
    --c-text-muted: #667085;
    --c-border: #e7ebf0;
    --c-bg: #f6f7f9;
    --c-surface: #ffffff;
    --c-footer: #0b2f3f;
    --c-success: #0d9488;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(15, 36, 56, 0.04);
    --shadow: 0 8px 24px rgba(15, 36, 56, 0.06);
    --shadow-lg: 0 18px 40px rgba(15, 36, 56, 0.08);
    --container: 1400px;
    --header-h: 78px;
    --logo-h: 44px;
    --logo-max-w: 220px;
    --font: 'Vazirmatn', Tahoma, system-ui, sans-serif;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.85;
    color: var(--c-text);
    background: var(--c-bg);
    direction: rtl;
    text-align: right;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--c-primary); text-decoration: none; transition: color .2s var(--ease); }
a:hover { color: #0a3550; }
ul, ol { list-style: none; }
button, input, textarea, select { font-family: inherit; }

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font);
    font-weight: 700;
    line-height: 1.35;
    color: var(--c-text);
    letter-spacing: -0.01em;
}

h1 { font-size: clamp(1.75rem, 2.4vw, 2.35rem); }
h2 { font-size: clamp(1.4rem, 2vw, 1.85rem); }
h3 { font-size: 1.3rem; }
h4 { font-size: 1.1rem; }
p { margin-bottom: 1.15rem; }

.container {
    width: min(100% - 2.5rem, var(--container));
    margin-inline: auto;
}

@media (max-width: 640px) {
    .container {
        width: min(100% - 1.25rem, var(--container));
    }
}

.screen-reader-text {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0);
    white-space: nowrap; border: 0;
}

.skip-link:focus {
    position: fixed; top: 1rem; right: 1rem; z-index: 9999;
    width: auto; height: auto; clip: auto;
    padding: .75rem 1rem;
    background: var(--c-primary); color: #fff;
    border-radius: 8px;
}

/* ========== Header ========== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255,255,255,.86);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(231,235,240,.9);
    min-height: var(--header-h);
}

.header-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    min-height: var(--header-h);
    padding-block: .65rem;
}

.site-branding { flex-shrink: 0; }

.logo-link {
    display: inline-flex;
    align-items: center;
    gap: .85rem;
    color: inherit;
}

.site-logo-img {
    height: var(--logo-h);
    width: auto;
    max-width: var(--logo-max-w);
    object-fit: contain;
}

.logo-icon {
    width: 42px; height: 42px;
    display: grid; place-items: center;
    border-radius: 12px;
    background: linear-gradient(145deg, var(--c-primary), #176987);
    color: #fff;
    font-weight: 800;
    font-size: 1.1rem;
    box-shadow: 0 8px 18px rgba(15,76,104,.25);
}

.logo-text-content { display: flex; flex-direction: column; gap: .1rem; }

.site-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--c-text);
}

.site-description {
    margin: 0;
    font-size: .78rem;
    color: var(--c-text-muted);
    font-weight: 400;
}

.main-navigation { display: flex; align-items: center; gap: 1rem; }

.main-navigation > .menu,
.main-navigation > ul.menu,
.admin-menu-items {
    display: flex;
    align-items: center;
    gap: .2rem;
    flex-wrap: wrap;
}

.main-navigation a {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .55rem .85rem;
    border-radius: 999px;
    color: var(--c-text);
    font-size: .92rem;
    font-weight: 500;
}

.main-navigation a:hover,
.main-navigation .current-menu-item > a {
    background: var(--c-primary-soft);
    color: var(--c-primary);
}

.menu-item-admin a { color: var(--c-text-muted); font-size: .85rem; }
.menu-item-logout a { color: #b42318; }

.menu-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--c-border);
    border-radius: 10px;
    padding: .45rem;
    cursor: pointer;
    color: var(--c-text);
}

.menu-overlay {
    position: fixed; inset: 0;
    background: rgba(12, 24, 36, .35);
    opacity: 0; visibility: hidden;
    transition: .25s var(--ease);
    z-index: 998;
}
.menu-overlay.active { opacity: 1; visibility: visible; }

/* ========== Layout ========== */
.site-main { padding: 1.75rem 0 3rem; min-height: 55vh; }

.breadcrumbs {
    display: flex; flex-wrap: wrap; align-items: center; gap: .4rem;
    margin-bottom: 1.35rem;
    font-size: .85rem;
    color: var(--c-text-muted);
}
.breadcrumbs a { color: var(--c-text-muted); }
.breadcrumbs a:hover { color: var(--c-primary); }

.content-area {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(250px, 280px);
    gap: 2.25rem;
    align-items: start;
    width: 100%;
}
.content-area.sidebar-left { grid-template-columns: minmax(250px, 280px) minmax(0, 1fr); }
.content-area.sidebar-left .posts-container,
.content-area.sidebar-left > article,
.content-area.sidebar-left > .post { order: 2; }
.content-area.sidebar-left .sidebar { order: 1; }
.content-area.no-sidebar {
    grid-template-columns: 1fr;
    max-width: none;
    width: 100%;
    margin-inline: 0;
}

.posts-container {
    display: flex;
    flex-direction: column;
    gap: 1.35rem;
    width: 100%;
    min-width: 0;
}

/* ========== Cards / Posts ========== */
.post,
.no-posts {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow .25s var(--ease), transform .25s var(--ease), border-color .25s var(--ease);
}

.posts-container .post:hover {
    box-shadow: var(--shadow);
    border-color: #d9e2ea;
    transform: translateY(-2px);
}

.post-wrapper {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    min-height: 0;
    width: 100%;
}
.post-wrapper.has-thumbnail,
.post-wrapper:has(.post-thumbnail) {
    grid-template-columns: minmax(220px, 28%) minmax(0, 1fr);
    min-height: 210px;
}

.post-thumbnail {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #e8f3f8, #f4f0e4);
    min-height: 210px;
    height: 100%;
}
.post-thumbnail img {
    width: 100%; height: 100%;
    object-fit: cover;
    transition: transform .45s var(--ease);
}
.posts-container .post:hover .post-thumbnail img { transform: scale(1.04); }

.post-content {
    padding: 1.55rem 1.85rem 1.7rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    width: 100%;
}
.post-wrapper:not(.has-thumbnail) .post-content,
.post-wrapper:not(:has(.post-thumbnail)) .post-content {
    padding: 1.7rem 2rem 1.85rem;
    max-width: none;
}
.single-post .post-wrapper { grid-template-columns: 1fr; }
.single-post .post-thumbnail { min-height: 280px; max-height: 460px; }
.single-post .post-content { padding: 1.85rem 2rem 2.25rem; display: block; }
.page .post-header,
.page .post-content { padding: 1.7rem 2rem; }
.page .post-featured-image { margin: 0 2rem 1rem; border-radius: var(--radius-sm); overflow: hidden; }

.post-title { margin: 0 0 .75rem; font-size: clamp(1.25rem, 1.1vw + .85rem, 1.65rem); }
.post-title a { color: var(--c-text); }
.post-title a:hover { color: var(--c-primary); }
.single-post .post-title,
.page .post-title { font-size: clamp(1.55rem, 2.5vw, 2.25rem); margin-bottom: .85rem; }

.post-meta {
    display: flex; flex-wrap: wrap; gap: .7rem 1.1rem;
    margin-bottom: .95rem;
    color: var(--c-text-muted);
    font-size: .86rem;
}
.post-meta span { display: inline-flex; align-items: center; gap: .35rem; }
.post-meta svg { opacity: .7; flex-shrink: 0; }
.post-meta a { color: var(--c-text-muted); }
.post-meta a:hover { color: var(--c-primary); }

.reading-time {
    display: inline-flex; align-items: center; gap: .35rem;
    margin-bottom: 1rem;
    padding: .3rem .7rem;
    border-radius: 999px;
    background: var(--c-accent-soft);
    color: #8a6a08;
    font-size: .8rem;
    font-weight: 600;
    width: fit-content;
}

.post-excerpt {
    color: var(--c-text-muted);
    font-size: 1.02rem;
    line-height: 1.9;
    max-width: none;
    flex: 1;
}
.post-excerpt p { margin-bottom: .85rem; }

.read-more {
    display: inline-flex; align-items: center; gap: .35rem;
    margin-top: .55rem;
    font-weight: 700;
    font-size: .95rem;
    color: var(--c-primary);
    width: fit-content;
}
.read-more:hover { gap: .55rem; }

.single-post .post-content,
.page .post-content {
    font-size: 1.02rem;
    line-height: 1.95;
}
.single-post .post-content h2,
.single-post .post-content h3 {
    margin-top: 1.75rem;
    margin-bottom: .75rem;
}
.single-post .post-content ul,
.single-post .post-content ol {
    margin: 0 1.2rem 1.2rem 0;
    list-style: disc;
}
.single-post .post-content ol { list-style: decimal; }
.single-post .post-content blockquote {
    margin: 1.4rem 0;
    padding: 1rem 1.2rem;
    border-right: 3px solid var(--c-accent);
    background: var(--c-accent-soft);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: #4a3b12;
}
.single-post .post-content img { border-radius: var(--radius-sm); margin: 1.2rem 0; }
.single-post .post-content a { text-decoration: underline; text-underline-offset: 3px; }

.post-tags {
    display: flex; flex-wrap: wrap; gap: .5rem;
    padding: 0 1.75rem 1.5rem;
}
.post-tags a {
    padding: .35rem .75rem;
    border-radius: 999px;
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    color: var(--c-text-muted);
    font-size: .8rem;
}
.post-tags a:hover { background: var(--c-primary-soft); color: var(--c-primary); border-color: transparent; }

/* Share / author / related */
.share-buttons,
.author-box,
.related-posts {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 1.25rem 1.4rem;
    margin-top: 1.15rem;
    box-shadow: var(--shadow-sm);
}
.share-buttons { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.share-buttons .share-title { font-weight: 700; margin-left: .4rem; }
.share-buttons a {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .45rem .8rem;
    border-radius: 999px;
    background: var(--c-bg);
    color: var(--c-text);
    font-size: .85rem;
    border: 1px solid var(--c-border);
}
.share-buttons a:hover { background: var(--c-primary); color: #fff; border-color: transparent; }

.author-box { display: flex; gap: 1rem; align-items: flex-start; }
.author-box img { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; }
.author-box h3 { margin-bottom: .35rem; font-size: 1.05rem; }

.related-posts-title { margin-bottom: 1rem; font-size: 1.15rem; }
.related-posts-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .9rem;
}
.related-post-item {
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--c-bg);
}
.related-post-thumbnail { width: 100%; height: 120px; object-fit: cover; }
.related-post-content { padding: .75rem; }
.related-post-title { margin: 0; font-size: .92rem; }
.related-post-title a { color: var(--c-text); }

.post-navigation {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .9rem;
    margin-top: 1.15rem;
}
.post-navigation a {
    display: block;
    padding: 1rem 1.15rem;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    color: var(--c-text);
}
.post-navigation a:hover { border-color: var(--c-primary); box-shadow: var(--shadow-sm); }
.post-navigation .nav-subtitle { display: block; color: var(--c-text-muted); font-size: .78rem; margin-bottom: .25rem; }
.post-navigation .nav-title { font-weight: 700; font-size: .95rem; }

/* Pagination */
.navigation.pagination {
    display: flex; justify-content: center;
    margin-top: .5rem;
}
.nav-links { display: flex; gap: .4rem; flex-wrap: wrap; }
.page-numbers {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 40px; height: 40px;
    padding: 0 .75rem;
    border-radius: 10px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    color: var(--c-text);
    font-weight: 600;
}
.page-numbers.current,
.page-numbers:hover { background: var(--c-primary); color: #fff; border-color: transparent; }

/* Sidebar */
.sidebar .widget {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 1.15rem 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}
.widget-title {
    position: relative;
    margin: 0 0 1rem;
    padding-bottom: .7rem;
    font-size: 1rem;
}
.widget-title::after {
    content: '';
    position: absolute;
    right: 0; bottom: 0;
    width: 36px; height: 3px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--c-accent), var(--c-primary));
}
.widget ul li { padding: .45rem 0; border-bottom: 1px dashed var(--c-border); }
.widget ul li:last-child { border-bottom: 0; }
.widget a { color: var(--c-text); }
.widget a:hover { color: var(--c-primary); }
.widget input[type="search"],
.widget input[type="text"],
.search-form input[type="search"] {
    width: 100%;
    padding: .7rem .9rem;
    border: 1px solid var(--c-border);
    border-radius: 10px;
    background: var(--c-bg);
    outline: none;
}
.widget input:focus,
.search-form input:focus { border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(15,76,104,.12); }
.search-form { display: flex; gap: .5rem; }
.search-form .search-submit,
.search-submit {
    padding: .7rem 1rem;
    border: 0;
    border-radius: 10px;
    background: var(--c-primary);
    color: #fff;
    cursor: pointer;
    font-weight: 700;
}

/* Comments */
.comments-area {
    margin-top: 1.25rem;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 1.4rem;
}
.comment-list { margin: 1rem 0; }
.comment {
    padding: 1rem 0;
    border-bottom: 1px solid var(--c-border);
}
.comment-form textarea,
.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"] {
    width: 100%;
    padding: .75rem .9rem;
    border: 1px solid var(--c-border);
    border-radius: 10px;
    margin-bottom: .75rem;
    background: var(--c-bg);
}
.comment-form .submit {
    background: var(--c-primary);
    color: #fff;
    border: 0;
    border-radius: 10px;
    padding: .75rem 1.25rem;
    cursor: pointer;
    font-weight: 700;
}

/* Footer */
.site-footer {
    background: linear-gradient(180deg, #0d3648 0%, var(--c-footer) 100%);
    color: rgba(255,255,255,.82);
    padding: 2.75rem 0 1.5rem;
    margin-top: 1rem;
}
.site-footer a { color: rgba(255,255,255,.9); }
.site-footer a:hover { color: var(--c-accent); }
.footer-content {
    display: grid;
    gap: 1.5rem;
    margin-bottom: 2rem;
}
.footer-columns-1 { grid-template-columns: 1fr; }
.footer-columns-2 { grid-template-columns: repeat(2, 1fr); }
.footer-columns-3 { grid-template-columns: repeat(3, 1fr); }
.footer-columns-4 { grid-template-columns: repeat(4, 1fr); }
.site-footer .widget { background: transparent; border: 0; box-shadow: none; padding: 0; }
.site-footer .widget-title { color: #fff; }
.site-footer .widget-title::after { background: var(--c-accent); }
.footer-extra-content {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    margin-bottom: 1.75rem;
    padding-bottom: 1.75rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.footer-bottom {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-top: 1.25rem;
    border-top: 1px solid rgba(255,255,255,.1);
    font-size: .9rem;
}
.social-media { display: flex; gap: .55rem; flex-wrap: wrap; }
.social-media a {
    width: 38px; height: 38px;
    display: grid; place-items: center;
    border-radius: 10px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.1);
}
.social-media a:hover { background: var(--c-accent); color: #1a1400; border-color: transparent; }

.no-posts { padding: 2.5rem 1.5rem; text-align: center; }

/* Hero strip for home feel */
.site-main > .container > .breadcrumbs:first-child + .content-area {
    /* spacing handled above */
}

/* Scroll top */
.scroll-to-top {
    position: fixed;
    left: 1.25rem; bottom: 1.25rem;
    width: 44px; height: 44px;
    border: 0; border-radius: 12px;
    background: var(--c-primary);
    color: #fff;
    cursor: pointer;
    box-shadow: var(--shadow);
    opacity: 0; visibility: hidden;
    transition: .25s var(--ease);
    z-index: 90;
}
.scroll-to-top.visible { opacity: 1; visibility: visible; }

/* Dark mode optional */
body.dark-mode {
    --c-bg: #0f1720;
    --c-surface: #16202a;
    --c-text: #e8eef4;
    --c-text-muted: #9aa8b6;
    --c-border: #243140;
    --c-primary-soft: #163445;
}
body.dark-mode .site-header { background: rgba(15,23,32,.88); }

/* ========== Responsive ========== */
@media (max-width: 1200px) {
    .post-wrapper.has-thumbnail,
    .post-wrapper:has(.post-thumbnail) {
        grid-template-columns: minmax(200px, 28%) minmax(0, 1fr);
    }
    .post-content { padding: 1.25rem 1.4rem; }
}

@media (max-width: 1024px) {
    .content-area,
    .content-area.sidebar-left {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    .post-wrapper.has-thumbnail,
    .post-wrapper:has(.post-thumbnail) {
        grid-template-columns: minmax(200px, 30%) minmax(0, 1fr);
        min-height: 190px;
    }
    .related-posts-grid { grid-template-columns: 1fr 1fr; }
    .footer-columns-3,
    .footer-columns-4 { grid-template-columns: 1fr 1fr; }
    .single-post .post-content,
    .page .post-header,
    .page .post-content { padding-inline: 1.4rem; }
}

@media (max-width: 768px) {
    .site-main { padding: 1.25rem 0 2.25rem; }
    .post-wrapper {
        grid-template-columns: 1fr;
        min-height: 0;
    }
    .post-thumbnail {
        min-height: 200px;
        max-height: 240px;
        height: 220px;
    }
    .post-content { padding: 1.15rem 1.15rem 1.3rem; }
    .post-title { font-size: 1.15rem; }
    .post-excerpt { font-size: .98rem; line-height: 1.8; }
    .menu-toggle { display: inline-flex; }
    .main-navigation > .menu,
    .main-navigation > ul.menu,
    .admin-menu-items {
        position: fixed;
        top: 0; right: 0;
        width: min(88vw, 320px);
        height: 100vh;
        background: var(--c-surface);
        flex-direction: column;
        align-items: stretch;
        padding: 5rem 1.1rem 1.5rem;
        gap: .25rem;
        transform: translateX(105%);
        transition: transform .3s var(--ease);
        z-index: 999;
        box-shadow: var(--shadow-lg);
        overflow-y: auto;
    }
    .main-navigation.active > .menu,
    .main-navigation.active > ul.menu,
    .main-navigation.active .admin-menu-items { transform: translateX(0); }
    .main-navigation a { border-radius: 10px; }
    .related-posts-grid,
    .post-navigation,
    .footer-columns-1,
    .footer-columns-2,
    .footer-columns-3,
    .footer-columns-4,
    .footer-extra-content { grid-template-columns: 1fr; }
    .author-box { flex-direction: column; }
    .site-description { display: none; }
    .header-wrapper { gap: .75rem; }
    .footer-bottom { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
    body { font-size: 15px; }
    .post-thumbnail {
        min-height: 170px;
        max-height: 200px;
        height: 180px;
    }
    .post-meta { gap: .45rem .75rem; font-size: .8rem; }
    .single-post .post-content,
    .page .post-header,
    .page .post-content { padding: 1.1rem 1rem 1.4rem; }
    .share-buttons,
    .author-box,
    .related-posts,
    .comments-area { padding: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}
