/*
Theme Name: هیستوری‌گرام
Theme URI: https://historygram.ir
Author: هیستوری‌گرام
Description: قالب خبری مدرن و مینیمال فارسی — بدون سایدبار، گرید چهارستونه، سیستم کامنت با لایک/دیسلایک، کاملاً RTL
Version: 2.0.0
Requires at least: 6.0
Tested up to: 6.5
Requires PHP: 8.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: rouzno
Tags: rtl-language, news, minimal, blog, no-sidebar, custom-logo, comments
*/

/* ──────────────────────────────────────────────
   RESET & BASE
────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg:            #F9F8F5;
    --surface:       #FFFFFF;
    --text-primary:  #1A1A18;
    --text-secondary:#6B6B66;
    --text-muted:    #A3A39E;
    --border:        rgba(26,26,24,0.10);
    --border-strong: rgba(26,26,24,0.18);
    --accent:        #3B6D11;
    --radius:        2px;
    --transition:    0.22s cubic-bezier(0.4,0,0.2,1);
    --max-width:     1200px;
    --font-main:     'Vazirmatn', sans-serif;
}

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

body {
    font-family: var(--font-main);
    background: var(--bg);
    color: var(--text-primary);
    direction: rtl;
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

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

/* ──────────────────────────────────────────────
   TYPOGRAPHY
────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
    line-height: 1.4;
    font-weight: 700;
}

/* ──────────────────────────────────────────────
   SKIP LINK (دسترسی‌پذیری)
────────────────────────────────────────────── */
.skip-link {
    position: absolute;
    top: -100%;
    right: 0;
    background: var(--accent);
    color: #fff;
    padding: 0.5rem 1rem;
    font-size: 13px;
    z-index: 999;
}
.skip-link:focus { top: 0; }

/* ──────────────────────────────────────────────
   HEADER
────────────────────────────────────────────── */
.site-header {
    background: var(--surface);
    border-bottom: 0.5px solid var(--border-strong);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: 60px;
    gap: 2rem;
}

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

.site-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.site-title a:hover { opacity: 0.8; }

/* ناوبری اصلی */
.main-navigation {
    display: flex;
    align-items: center;
}

.main-navigation ul {
    list-style: none;
    display: flex;
    gap: 2rem;
}

.main-navigation a {
    font-size: 13px;
    color: var(--text-secondary);
    transition: color var(--transition);
    padding: 4px 0;
}

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

/* تاریخ روز */
.header-date {
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* ──────────────────────────────────────────────
   MAIN LAYOUT (بدون سایدبار)
────────────────────────────────────────────── */
.site-content {
    flex: 1;
}

.content-area {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 3rem 2rem 4rem;
}

/* ──────────────────────────────────────────────
   SECTION BAR — ردیف لیبل + تیکر
────────────────────────────────────────────── */
.section-bar {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 1.5rem;
    border-bottom: 0.5px solid var(--border);
}

/* ──────────────────────────────────────────────
   SECTION LABEL
────────────────────────────────────────────── */
.section-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.section-label::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent);
}

/* جداکننده عمودی بین لیبل و تیکر */
.section-label::after {
    content: '';
    display: inline-block;
    width: 0.5px;
    height: 14px;
    background: var(--border-strong);
    margin-right: 1rem;
    margin-right: 1rem;
    margin-bottom: -2px;
}

/* ──────────────────────────────────────────────
   TICKER — مارکی عناوین اخبار
────────────────────────────────────────────── */
.ticker-wrap {
    overflow: hidden;
    flex: 1;
    display: flex;
    align-items: center;
    height: 36px;
    padding-bottom: 0.75rem;
    -webkit-mask-image: linear-gradient(to left, transparent 0%, black 6%, black 94%, transparent 100%);
    mask-image: linear-gradient(to left, transparent 0%, black 6%, black 94%, transparent 100%);
}

.ticker-wrap:hover .ticker-track {
    animation-play-state: paused;
}

.ticker-track {
    display: flex;
    align-items: center;
    white-space: nowrap;
    animation: ticker-rtl 55s linear infinite;
    will-change: transform;
}

@keyframes ticker-rtl {
    0%   { transform: translateX(0); }
    100% { transform: translateX(50%); }
}

.ticker-item {
    font-size: 12.5px;
    color: var(--text-secondary);
    padding: 0 0.5rem;
    cursor: pointer;
    transition: color var(--transition);
    white-space: nowrap;
}

.ticker-item:hover { color: var(--text-primary); }

.ticker-sep {
    font-size: 10px;
    color: var(--text-muted);
    padding: 0 0.75rem;
    user-select: none;
}

/* ──────────────────────────────────────────────
   NEWS GRID — گرید ۴ ستونه
────────────────────────────────────────────── */
.news-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--border);
    border: 0.5px solid var(--border-strong);
}

/* ──────────────────────────────────────────────
   NEWS CARD — کارت مطلب
────────────────────────────────────────────── */
.news-card {
    background: var(--surface);
    padding: 1.5rem;
    transition: background var(--transition);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    aspect-ratio: 1 / 1;
    position: relative;
    overflow: hidden;
}

.news-card:hover {
    background: #F5F4F0;
}

.news-card:hover .entry-title a {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

/* دسته‌بندی روی کارت */
.cat-label {
    display: inline-flex;
    width: fit-content;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--accent);
    padding: 3px 8px;
    background: rgba(59,109,17,0.08);
    border-radius: var(--radius);
    transition: opacity var(--transition);
}

.cat-label:hover { opacity: 0.7; }

/* عنوان مطلب */
.entry-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.5;
    flex: 1;
}

.entry-title a {
    color: var(--text-primary);
}

/* خلاصه مطلب */
.entry-excerpt {
    font-size: 12.5px;
    color: var(--text-secondary);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* متا کارت */
.entry-meta-card {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: auto;
    padding-top: 0.5rem;
    border-top: 0.5px solid var(--border);
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* ──────────────────────────────────────────────
   AD CARD — باکس تبلیغاتی
────────────────────────────────────────────── */
.ad-card {
    position: relative;
    overflow: hidden;
    display: block;
    text-decoration: none;
    cursor: pointer;
}

/* تصویر پس‌زمینه تمام باکس */
.ad-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    transition: transform 0.4s ease;
}
.ad-card:hover .ad-bg { transform: scale(1.03); }

/* پوشش تیره روی تصویر برای خوانایی */
.ad-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        rgba(0,0,0,0.08) 0%,
        rgba(0,0,0,0.02) 100%
    );
    transition: background var(--transition);
}
.ad-card:hover::after {
    background: linear-gradient(
        135deg,
        rgba(0,0,0,0.14) 0%,
        rgba(0,0,0,0.06) 100%
    );
}

/* نشان Ad — گوشه بالا چپ */
.ad-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.9);
    background: rgba(0,0,0,0.38);
    padding: 2px 6px;
    border-radius: 2px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    line-height: 1.6;
}

/* ──────────────────────────────────────────────
   SINGLE POST — صفحه مطلب تمام‌عرض
────────────────────────────────────────────── */
.single-post-wrap,
.single-post-full {
    max-width: none;
    width: 100%;
}

.single-cat-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--accent);
    padding: 3px 8px;
    background: rgba(59,109,17,0.08);
    border-radius: var(--radius);
    display: inline-block;
    margin-bottom: 1rem;
}

.single-title {
    font-size: 32px;
    font-weight: 700;
    line-height: 1.4;
    color: var(--text-primary);
    margin-bottom: 1rem;
    max-width: none;
}

.single-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    gap: 1.5rem;
    align-items: center;
    margin-bottom: 2.5rem;
    padding-bottom: 2rem;
    border-bottom: 0.5px solid var(--border);
}

.single-meta a { color: var(--text-muted); }
.single-meta a:hover { color: var(--text-primary); }

/* محتوای مطلب — تمام‌عرض، دو ستونه */
.entry-content,
.single-entry-content {
    font-size: 16px;
    line-height: 1.9;
    color: var(--text-primary);
    max-width: none;
    width: 100%;
    columns: 2;
    column-gap: 4rem;
    column-rule: 0.5px solid var(--border);
}

@media (max-width: 860px) {
    .entry-content,
    .single-entry-content { columns: 1; column-gap: 0; column-rule: none; }
    .single-title { font-size: 24px; }
}

/* ریپورتاژ آگهی — تصویر هیرو */
.reportage-hero {
    width: 100%;
    height: 380px;
    background-size: cover;
    background-position: center;
    border-radius: 2px;
    margin-bottom: 2rem;
}

.reportage-content {
    columns: 1 !important; /* ریپورتاژ تک‌ستونه */
    max-width: 760px;
}

.entry-content p          { margin-bottom: 1.3rem; }
.entry-content h2         { font-size: 20px; margin: 2rem 0 0.75rem; }
.entry-content h3         { font-size: 17px; margin: 1.5rem 0 0.6rem; }
.entry-content blockquote {
    border-right: 3px solid var(--accent);
    padding-right: 1.25rem;
    margin: 1.5rem 0;
    color: var(--text-secondary);
    font-style: italic;
}
.entry-content a          { color: var(--accent); text-decoration: underline; }
.entry-content ul, .entry-content ol {
    padding-right: 1.5rem;
    margin-bottom: 1rem;
}
.entry-content li         { margin-bottom: 0.4rem; }

/* ──────────────────────────────────────────────
   CATEGORY PAGE — صفحه دسته‌بندی
────────────────────────────────────────────── */
.archive-header {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 0.5px solid var(--border-strong);
}

.archive-title {
    font-size: 22px;
    font-weight: 700;
}

.archive-count {
    font-size: 13px;
    color: var(--text-muted);
}

/* ──────────────────────────────────────────────
   PAGINATION
────────────────────────────────────────────── */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 0.5px solid var(--border);
}

.page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    font-size: 13px;
    border: 0.5px solid var(--border-strong);
    background: var(--surface);
    color: var(--text-secondary);
    transition: all var(--transition);
    border-radius: var(--radius);
}

.page-numbers:hover {
    background: var(--text-primary);
    color: var(--surface);
    border-color: var(--text-primary);
}

.page-numbers.current {
    background: var(--text-primary);
    color: var(--surface);
    border-color: var(--text-primary);
}

/* ──────────────────────────────────────────────
   FOOTER
────────────────────────────────────────────── */
.site-footer {
    background: var(--surface);
    border-top: 0.5px solid var(--border-strong);
    padding: 1.5rem 2rem;
    margin-top: auto;
}

.footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.footer-logo {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    flex-shrink: 0;
}

.footer-nav ul {
    list-style: none;
    display: flex;
    gap: 1.5rem;
}

.footer-nav a {
    font-size: 12px;
    color: var(--text-muted);
    transition: color var(--transition);
}

.footer-nav a:hover { color: var(--text-primary); }

.footer-copy {
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ──────────────────────────────────────────────
   RESPONSIVE — موبایل و تبلت
────────────────────────────────────────────── */

/* تبلت: ۲ ستون */
@media (max-width: 1024px) {
    .news-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .news-card {
        aspect-ratio: auto;
        min-height: 220px;
    }
}

/* موبایل: ۱ ستون */
@media (max-width: 640px) {
    .header-inner {
        padding: 0 1rem;
        height: 52px;
    }
    .header-date { display: none; }
    .main-navigation { display: none; }

    .content-area {
        padding: 1.5rem 1rem 3rem;
    }

    .news-grid {
        grid-template-columns: 1fr;
    }

    .news-card {
        aspect-ratio: auto;
        min-height: auto;
        padding: 1.25rem 1rem;
    }

    .single-title { font-size: 22px; }

    .footer-inner {
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
    }
}

/* ──────────────────────────────────────────────
   UTILITIES
────────────────────────────────────────────── */
.screen-reader-text {
    clip: rect(1px, 1px, 1px, 1px);
    height: 1px;
    overflow: hidden;
    position: absolute;
    width: 1px;
    word-wrap: normal !important;
}

.no-sidebar #secondary { display: none; }

/* ──────────────────────────────────────────────
   FEATURED IMAGE — تصویر شاخص در کارت
────────────────────────────────────────────── */
.card-thumb-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    transition: transform 0.4s ease;
    z-index: 0;
}
.news-card:hover .card-thumb-bg { transform: scale(1.04); }

/* پوشش تیره روی تصویر برای خوانایی متن */
.card-thumb-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to top,
        rgba(0,0,0,0.72) 0%,
        rgba(0,0,0,0.32) 50%,
        rgba(0,0,0,0.10) 100%
    );
    z-index: 1;
}

/* وقتی کارت تصویر دارد، متن‌ها روی تصویر قرار می‌گیرن */
.news-card.has-thumb { background: #111; }
.news-card.has-thumb .cat-label,
.news-card.has-thumb .entry-title,
.news-card.has-thumb .entry-title a,
.news-card.has-thumb .entry-excerpt,
.news-card.has-thumb .entry-meta-card {
    position: relative;
    z-index: 2;
    color: rgba(255,255,255,0.92);
}
.news-card.has-thumb .cat-label {
    background: rgba(255,255,255,0.18);
    color: #fff;
}
.news-card.has-thumb .entry-meta-card {
    border-top-color: rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.65);
}

/* ──────────────────────────────────────────────
   FEATURED IMAGE — تصویر شاخص در صفحه مطلب
────────────────────────────────────────────── */
.single-featured-img {
    width: 100%;
    margin-bottom: 2rem;
    overflow: hidden;
}
.single-featured-img img {
    width: 100%;
    height: 420px;
    object-fit: cover;
    display: block;
}

@media (max-width: 640px) {
    .single-featured-img img { height: 220px; }
}

/* ──────────────────────────────────────────────
   POST VOTE BAR — لایک / دیسلایک مطلب
────────────────────────────────────────────── */
.post-vote-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 0.5px solid var(--border);
}

.post-vote-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 8px 18px;
    border: 0.5px solid var(--border-strong);
    background: var(--surface);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    border-radius: 0;
    transition: all var(--transition);
    line-height: 1;
}

.post-vote-btn svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.post-vote-btn:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
}

.post-vote-btn.voted {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.post-vote-btn.voted svg { stroke: #fff; }

.post-vote-btn.disliked {
    background: #c0392b;
    border-color: #c0392b;
    color: #fff;
}

.pv-count {
    font-size: 12px;
    font-weight: 600;
    min-width: 8px;
}

.post-vote-btn:disabled { opacity: 0.6; cursor: wait; }

/* ──────────────────────────────────────────────
   LOGO SETTINGS — لوگوی هدر/فوتر
────────────────────────────────────────────── */
.site-header .custom-logo-link img,
.site-header .hg-logo-img {
    max-height: 44px;
    width: auto;
    display: block;
}
.site-footer .hg-footer-logo-img {
    max-height: 32px;
    width: auto;
    display: block;
}
