:root {
    --mag-primary-color: #2563eb;
    --mag-badge-bg: #f3e8ff;
    --mag-badge-text: #9333ea;
    --mag-card-radius: 18px;
    --mag-inner-radius: 14px;
    --mag-shadow-soft: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
    --mag-shadow-hover: 0 20px 30px -10px rgba(0, 0, 0, 0.25);
    --mag-transition-curve: cubic-bezier(0.16, 1, 0.3, 1);
}

.mag-wrapper {
    width: 100%;
    margin: 0 auto;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
    box-sizing: border-box;
}

/* شبکه ریسپانسیو ستون‌ها */
.mag-grid-container {
    display: grid;
    gap: 24px;
    width: 100%;
}

.mag-cols-1 { grid-template-columns: 1fr; }
.mag-cols-2 { grid-template-columns: repeat(2, 1fr); }
.mag-cols-3 { grid-template-columns: repeat(3, 1fr); }
.mag-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
    .mag-cols-3, .mag-cols-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
    .mag-grid-container { grid-template-columns: 1fr !important; }
}

/* کارت اصلی */
.mag-card-item {
    position: relative;
    height: 440px;
    border-radius: var(--mag-card-radius);
    overflow: hidden;
    box-shadow: var(--mag-shadow-soft);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 16px;
    box-sizing: border-box;
    cursor: pointer;
    background-color: #0f172a;
    transition: transform 0.4s var(--mag-transition-curve), box-shadow 0.4s var(--mag-transition-curve);
}

.mag-card-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--mag-shadow-hover);
}

.mag-card-link {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
}

/* لایه تصویر شاخص */
.mag-card-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    transition: transform 0.6s var(--mag-transition-curve), filter 0.5s ease;
    z-index: 1;
}

.mag-card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,0) 40%, rgba(0,0,0,0.65) 100%);
    transition: background 0.4s ease;
}

.mag-card-item:hover .mag-card-bg {
    transform: scale(1.06);
    filter: brightness(0.85) blur(1.5px);
}

/* کادر سفید شناور روی تصویر */
.mag-card-inner-box {
    position: relative;
    z-index: 2;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--mag-inner-radius);
    padding: 16px 18px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    transition: all 0.45s var(--mag-transition-curve);
}

/* بج دسته‌بندی */
.mag-badge-wrapper {
    margin-bottom: 8px;
}

.mag-category-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    background-color: var(--mag-badge-bg);
    color: var(--mag-badge-text);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* عنوان مقاله */
.mag-post-title {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 800;
    line-height: 1.45;
    color: #1e293b;
    transition: color 0.3s ease;
}

.mag-post-title a {
    text-decoration: none;
    color: inherit;
}

.mag-card-item:hover .mag-post-title {
    color: var(--mag-primary-color);
}

/* چکیده متن با انیمیشن باز شدن عمودی در حالت هاور */
.mag-post-excerpt {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.45s var(--mag-transition-curve), opacity 0.35s ease, margin-bottom 0.35s ease;
    margin-bottom: 0;
}

.mag-post-excerpt p {
    margin: 0;
    font-size: 12.5px;
    line-height: 1.6;
    color: #475569;
}

.mag-card-item:hover .mag-post-excerpt {
    max-height: 90px;
    opacity: 1;
    margin-bottom: 12px;
}

/* فوتر کارت و متادیتا */
.mag-post-meta {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    font-size: 12px;
    color: #64748b;
    border-top: 1px solid rgba(226, 232, 240, 0.8);
    padding-top: 10px;
}

.mag-author-info {
    display: flex;
    align-items: center;
    gap: 7px;
}

.mag-author-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #e2e8f0;
}

.mag-author-name {
    font-weight: 600;
    color: #334155;
}

.mag-date-bullet {
    color: #94a3b8;
}

.mag-post-date {
    color: #64748b;
}

/* استایل سیستم صفحه‌بندی هوشمند */
.mag-pagination-wrapper {
    margin-top: 40px;
    display: flex;
    justify-content: center;
}

.mag-pagination-wrapper ul.page-numbers {
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0;
    gap: 8px;
    align-items: center;
}

.mag-pagination-wrapper .page-numbers li a,
.mag-pagination-wrapper .page-numbers li span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    background-color: #f8fafc;
    color: #475569;
    border: 1px solid #e2e8f0;
    transition: all 0.25s ease;
}

.mag-pagination-wrapper .page-numbers li span.current {
    background-color: var(--mag-primary-color);
    color: #ffffff;
    border-color: var(--mag-primary-color);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.mag-pagination-wrapper .page-numbers li a:hover {
    background-color: #edf2f7;
    color: #0f172a;
    border-color: #cbd5e1;
}
