/* ==========================================================================
   MAGAZINE - مجله برساد (Barsad Ultimate 3.5)
   فقط در صفحات مجله/مقاله/آرشیو/جستجو/۴۰۴ و صفحه اصلی لود می‌شود.
   رنگ‌ها از متغیرهای قالب (قابل تغییر از سفارشی‌سازی) می‌آیند.
   ========================================================================== */

.mag-icon { flex-shrink: 0; vertical-align: -3px; }

/* ---------- Hero / header of magazine & archives ---------- */
.mag-hero {
    padding: 48px 0 28px;
    background: linear-gradient(180deg, rgba(201, 161, 74, 0.08) 0%, transparent 100%);
    border-bottom: 1px solid var(--border-light, rgba(255, 255, 255, 0.08));
}
.mag-hero__title {
    font-size: clamp(1.9rem, 4.2vw, 3rem);
    font-weight: 900;
    line-height: 1.35;
    color: var(--text, #f5f5f5);
    margin: 6px 0 14px;
    text-wrap: balance;
}
.mag-hero__page { font-size: 0.5em; color: var(--text-muted, #a0a0a0); font-weight: 600; }
.mag-hero__intro {
    max-width: 70ch;
    color: var(--text-muted, #a0a0a0);
    font-size: 1.05rem;
    line-height: 2;
    margin-bottom: 22px;
}
.mag-hero__intro p { margin: 0 0 0.6em; }

/* ---------- Category chips ---------- */
.mag-cats ul {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    list-style: none;
    margin: 0;
    padding: 0;
}
.mag-cats a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 6px 16px;
    border-radius: 999px;
    border: 1px solid var(--border, rgba(201, 161, 74, 0.18));
    background: rgba(255, 255, 255, 0.03);
    color: var(--text, #f5f5f5);
    font-size: 0.9rem;
    font-weight: 600;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.mag-cats a:hover { border-color: var(--gold, #c9a14a); color: var(--gold-light, #e8c476); }
.mag-cats a[aria-current="page"] {
    background: var(--gold, #c9a14a);
    border-color: var(--gold, #c9a14a);
    color: #0a0a0a;
}
.mag-cats__count {
    font-size: 0.78rem;
    opacity: 0.75;
    font-weight: 500;
}

/* ---------- Sections & grid ---------- */
.mag-section { padding: 40px 0 70px; }
.mag-section__title {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text, #f5f5f5);
    margin: 0 0 22px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.mag-section__title::before {
    content: "";
    width: 6px;
    height: 1.3em;
    border-radius: 3px;
    background: var(--gold, #c9a14a);
}
.mag-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 26px;
}

/* ---------- Card ---------- */
.mag-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: linear-gradient(160deg, var(--bg-card, #141414), var(--bg-card-light, #1c1c1c));
    border: 1px solid var(--border-light, rgba(255, 255, 255, 0.08));
    border-radius: 18px;
    overflow: hidden;
    transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.mag-card:hover {
    transform: translateY(-4px);
    border-color: rgba(201, 161, 74, 0.45);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}
.mag-card:focus-within { border-color: var(--gold, #c9a14a); }
.mag-card__media {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #111;
}
.mag-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}
.mag-card:hover .mag-card__media img { transform: scale(1.04); }
.mag-thumb-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 30% 30%, rgba(201, 161, 74, 0.35), rgba(201, 161, 74, 0.05) 70%);
}
.mag-thumb-placeholder span {
    font-size: 3rem;
    font-weight: 900;
    color: var(--gold, #c9a14a);
    opacity: 0.8;
}
.mag-card__body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 20px 22px 22px;
    flex: 1;
}
.mag-chip {
    position: relative;
    z-index: 2;
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 3px 12px;
    border-radius: 999px;
    background: rgba(201, 161, 74, 0.14);
    border: 1px solid rgba(201, 161, 74, 0.35);
    color: var(--gold-light, #e8c476) !important;
    font-size: 0.8rem;
    font-weight: 700;
}
.mag-chip:hover { background: var(--gold, #c9a14a); color: #0a0a0a !important; }
.mag-card__title {
    font-size: 1.12rem;
    font-weight: 800;
    line-height: 1.65;
    margin: 0;
}
.mag-card__link {
    color: var(--text, #f5f5f5);
    text-decoration: none;
}
/* کل کارت قابل کلیک (لینک کشیده) - چیپ دسته جداگانه کلیک‌پذیر می‌ماند */
.mag-card__link::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
}
.mag-card__link:hover { color: var(--gold-light, #e8c476); }
.mag-card__link:focus-visible { outline: none; }
.mag-card__link:focus-visible::after {
    outline: 2px solid var(--gold-light, #e8c476);
    outline-offset: -3px;
    border-radius: 18px;
}
.mag-card__excerpt {
    color: var(--text-muted, #a0a0a0);
    font-size: 0.93rem;
    line-height: 1.95;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---------- Meta row ---------- */
.mag-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 18px;
    margin-top: auto;
    color: var(--text-muted, #a0a0a0);
    font-size: 0.82rem;
}
.mag-meta > span { display: inline-flex; align-items: center; gap: 6px; }
.mag-meta .mag-icon { color: var(--gold, #c9a14a); }
.mag-meta a { color: inherit; position: relative; z-index: 2; }
.mag-meta a:hover { color: var(--gold-light, #e8c476); }

/* ---------- Featured card ---------- */
.mag-card--featured {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    margin-bottom: 46px;
    border-color: rgba(201, 161, 74, 0.3);
}
.mag-card--featured .mag-card__media { aspect-ratio: auto; min-height: 340px; }
.mag-card--featured .mag-card__body { padding: 34px 36px; justify-content: center; gap: 14px; }
.mag-card--featured .mag-card__title { font-size: clamp(1.35rem, 2.4vw, 2rem); line-height: 1.55; }
.mag-card--featured .mag-card__excerpt { -webkit-line-clamp: 4; font-size: 1rem; }
.mag-card--featured .mag-meta { margin-top: 6px; }

/* ---------- Pagination ---------- */
.mag-pagination { margin-top: 46px; }
.mag-pagination ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
}
.mag-pagination a,
.mag-pagination span.page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 6px 14px;
    border-radius: 12px;
    border: 1px solid var(--border-light, rgba(255, 255, 255, 0.08));
    background: rgba(255, 255, 255, 0.04);
    color: var(--text, #f5f5f5);
    font-weight: 600;
}
.mag-pagination a:hover { border-color: var(--gold, #c9a14a); color: var(--gold-light, #e8c476); }
.mag-pagination span.current { background: var(--gold, #c9a14a); border-color: var(--gold, #c9a14a); color: #0a0a0a; }

/* ---------- Empty ---------- */
.mag-empty {
    text-align: center;
    padding: 60px 20px;
    border: 1px dashed rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    margin-bottom: 40px;
}
.mag-empty__title { color: var(--text, #f5f5f5); font-size: 1.1rem; margin: 0 0 18px; }

/* ---------- CTA box ---------- */
.mag-cta {
    margin: 50px 0 10px;
    padding: 28px 30px;
    border-radius: 20px;
    border: 1px solid rgba(201, 161, 74, 0.45);
    background: linear-gradient(135deg, rgba(201, 161, 74, 0.16), rgba(201, 161, 74, 0.03));
}
.mag-cta__title { font-size: 1.25rem; font-weight: 800; color: var(--gold-light, #e8c476); margin: 0 0 8px; }
.mag-cta__text { color: var(--text, #f5f5f5); opacity: 0.9; line-height: 2; margin: 0 0 18px; max-width: 70ch; }
.mag-cta__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 22px; }
.mag-cta__phone {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text, #f5f5f5);
    font-weight: 700;
    font-size: 1.05rem;
}
.mag-cta__phone:hover { color: var(--gold-light, #e8c476); }
.mag-cta__phone .mag-icon { color: var(--gold, #c9a14a); width: 18px; height: 18px; }

/* ---------- Article ---------- */
.mag-container-narrow { max-width: 860px !important; }
.mag-container-wide { max-width: 1180px !important; }
.mag-article__header { padding: 40px 0 26px; }
.mag-article__header .mag-chip { margin: 6px 0 12px; }
.mag-article__title {
    font-size: clamp(1.7rem, 3.6vw, 2.6rem);
    font-weight: 900;
    line-height: 1.5;
    color: var(--text, #f5f5f5);
    margin: 0 0 14px;
    text-wrap: balance;
}
.mag-article__dek {
    font-size: 1.12rem;
    line-height: 2;
    color: var(--text-muted, #a0a0a0);
    margin: 0 0 18px;
    max-width: 70ch;
}
.mag-meta--article { margin-top: 0; font-size: 0.88rem; gap: 10px 22px; }
.mag-meta__author img { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border, rgba(201, 161, 74, 0.3)); }
.mag-meta__author a { color: var(--text, #f5f5f5); font-weight: 700; }

.mag-article__media { margin: 0 auto 10px; }
.mag-article__media img {
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    object-fit: cover;
    border-radius: 20px;
    border: 1px solid var(--border-light, rgba(255, 255, 255, 0.08));
}
.mag-article__media figcaption { color: var(--text-muted, #a0a0a0); font-size: 0.85rem; text-align: center; margin-top: 10px; }

.mag-article__layout {
    display: grid;
    grid-template-columns: minmax(0, 760px);
    justify-content: center;
    gap: 40px;
    padding-top: 30px;
    padding-bottom: 40px;
}
.mag-article__layout.has-toc { grid-template-columns: 270px minmax(0, 760px); }
.mag-article__aside { position: relative; }
.mag-article__aside .mag-toc { position: sticky; top: 130px; }

/* ---------- Table of contents ---------- */
.mag-toc {
    background: var(--bg-card, #141414);
    border: 1px solid var(--border, rgba(201, 161, 74, 0.18));
    border-radius: 16px;
    padding: 6px 6px 10px;
    max-height: calc(100vh - 160px);
    overflow: auto;
}
.mag-toc summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 12px 8px;
    cursor: pointer;
    font-weight: 800;
    color: var(--gold-light, #e8c476);
    list-style: none;
}
.mag-toc summary::-webkit-details-marker { display: none; }
.mag-toc ol { list-style: none; margin: 0; padding: 0 6px; counter-reset: toc; }
.mag-toc li { margin: 0; }
.mag-toc a {
    display: block;
    padding: 7px 10px;
    border-radius: 10px;
    color: var(--text-muted, #a0a0a0);
    font-size: 0.9rem;
    line-height: 1.8;
    border-right: 2px solid transparent;
}
.mag-toc a:hover, .mag-toc a.is-active {
    color: var(--text, #f5f5f5);
    background: rgba(201, 161, 74, 0.1);
    border-right-color: var(--gold, #c9a14a);
}
.mag-toc__l3 a { padding-right: 24px; font-size: 0.85rem; }

/* ---------- Article content typography ---------- */
.mag-content {
    color: #e4e4e4;
    font-size: 1.08rem;
    line-height: 2.05;
    max-width: 72ch;
}
.mag-content > * + * { margin-top: 1.1em; }
.mag-content h2, .mag-content h3, .mag-content h4 {
    color: var(--text, #f5f5f5);
    line-height: 1.6;
    scroll-margin-top: 130px;
    margin-top: 1.9em;
    margin-bottom: 0.6em;
}
.mag-content h2 {
    font-size: 1.55rem;
    font-weight: 800;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border, rgba(201, 161, 74, 0.2));
}
.mag-content h3 { font-size: 1.25rem; font-weight: 800; color: var(--gold-light, #e8c476); }
.mag-content h4 { font-size: 1.08rem; font-weight: 700; }
.mag-content p { margin: 0 0 1.1em; }
.mag-content a { color: var(--gold-light, #e8c476); text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }
.mag-content a:hover { color: var(--gold, #c9a14a); }
.mag-content strong { color: #fff; }
.mag-content ul, .mag-content ol { padding-right: 1.4em; margin: 0 0 1.2em; }
.mag-content ul { list-style: disc; }
.mag-content ol { list-style: decimal; }
.mag-content li { margin-bottom: 0.45em; padding-right: 0.2em; }
.mag-content li::marker { color: var(--gold, #c9a14a); }
.mag-content blockquote {
    margin: 1.6em 0;
    padding: 16px 22px;
    border-right: 4px solid var(--gold, #c9a14a);
    background: rgba(201, 161, 74, 0.07);
    border-radius: 12px;
    color: var(--text, #f5f5f5);
}
.mag-content img { border-radius: 14px; height: auto; }
.mag-content figure { margin: 1.6em 0; }
.mag-content figcaption { color: var(--text-muted, #a0a0a0); font-size: 0.85rem; text-align: center; margin-top: 8px; }
.mag-content table {
    width: 100%;
    border-collapse: collapse;
    display: block;
    overflow-x: auto;
    font-size: 0.95rem;
}
.mag-content th, .mag-content td { border: 1px solid rgba(255, 255, 255, 0.1); padding: 10px 12px; text-align: right; }
.mag-content th { background: rgba(201, 161, 74, 0.12); color: var(--text, #f5f5f5); }
.mag-content code { background: rgba(255, 255, 255, 0.08); padding: 2px 6px; border-radius: 6px; font-size: 0.9em; }

/* ---------- Tags / share / author / prev-next ---------- */
.mag-tags, .mag-share {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 28px;
}
.mag-tags__label, .mag-share__label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted, #a0a0a0);
    font-size: 0.9rem;
}
.mag-tags a, .mag-share a, .mag-share__copy {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 4px 14px;
    border-radius: 999px;
    border: 1px solid var(--border-light, rgba(255, 255, 255, 0.1));
    background: rgba(255, 255, 255, 0.04);
    color: var(--text, #f5f5f5);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
}
.mag-tags a:hover, .mag-share a:hover, .mag-share__copy:hover { border-color: var(--gold, #c9a14a); color: var(--gold-light, #e8c476); }
.mag-share__copy.is-copied { background: var(--gold, #c9a14a); color: #0a0a0a; border-color: var(--gold, #c9a14a); }

.mag-author {
    display: flex;
    gap: 18px;
    align-items: flex-start;
    margin-top: 34px;
    padding: 22px;
    border-radius: 18px;
    background: var(--bg-card, #141414);
    border: 1px solid var(--border-light, rgba(255, 255, 255, 0.08));
}
.mag-author img { width: 72px; height: 72px; border-radius: 50%; flex-shrink: 0; }
.mag-author__name { margin: 0 0 6px; font-weight: 800; color: var(--text, #f5f5f5); }
.mag-author__name a { color: var(--gold-light, #e8c476); }
.mag-author__bio { margin: 0; color: var(--text-muted, #a0a0a0); line-height: 1.9; font-size: 0.93rem; }

.mag-prevnext {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 34px;
}
.mag-prevnext__item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 18px;
    border-radius: 14px;
    border: 1px solid var(--border-light, rgba(255, 255, 255, 0.08));
    background: rgba(255, 255, 255, 0.03);
}
.mag-prevnext__item span { color: var(--text-muted, #a0a0a0); font-size: 0.82rem; }
.mag-prevnext__item strong { color: var(--text, #f5f5f5); line-height: 1.7; font-size: 0.95rem; }
.mag-prevnext__item:hover { border-color: var(--gold, #c9a14a); }
.mag-prevnext__item--next { text-align: left; }

.mag-comments { margin-top: 40px; }
.mag-related { padding: 30px 0 70px; border-top: 1px solid var(--border-light, rgba(255, 255, 255, 0.08)); }

/* ---------- Homepage magazine section ---------- */
.home-mag .mag-grid { margin-top: 10px; }
.home-mag__more { text-align: center; margin-top: 34px; }

/* ---------- Search & 404 ---------- */
.mag-search { margin-top: 18px; max-width: 560px; }
.mag-search .search-form,
.mag-404 .search-form { display: flex; gap: 10px; }
.mag-search .search-form label,
.mag-404 .search-form label { flex: 1; }
.mag-search .search-field,
.mag-404 .search-field {
    width: 100%;
    min-height: 48px;
    padding: 10px 16px;
    border-radius: 12px;
    border: 1px solid var(--border, rgba(201, 161, 74, 0.25));
    background: var(--bg-card, #141414);
    color: var(--text, #f5f5f5);
}
.mag-search .search-submit,
.mag-404 .search-submit {
    min-height: 48px;
    padding: 10px 20px;
    border-radius: 12px;
    background: var(--gold, #c9a14a);
    color: #0a0a0a;
    font-weight: 800;
}
.mag-404 { text-align: center; padding: 70px 24px 80px; }
.mag-404__code { font-size: clamp(4rem, 12vw, 7rem); font-weight: 900; color: var(--gold, #c9a14a); line-height: 1; margin: 0 0 10px; }
.mag-404 h1 { font-size: 1.8rem; margin: 0 0 12px; }
.mag-404__text { color: var(--text-muted, #a0a0a0); margin: 0 auto 20px; max-width: 60ch; line-height: 2; }
.mag-404 .mag-search { margin: 0 auto 24px; }
.mag-404__links { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-bottom: 50px; }
.mag-404 .mag-grid { text-align: right; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .mag-article__layout.has-toc { grid-template-columns: minmax(0, 760px); }
    .mag-article__aside .mag-toc { position: static; max-height: none; }
}
@media (max-width: 900px) {
    .mag-card--featured { grid-template-columns: 1fr; }
    .mag-card--featured .mag-card__media { aspect-ratio: 16 / 9; min-height: 0; }
    .mag-card--featured .mag-card__body { padding: 22px; }
}
@media (max-width: 600px) {
    .mag-hero { padding: 30px 0 22px; }
    .mag-grid { grid-template-columns: 1fr; gap: 20px; }
    .mag-card__body { padding: 18px; }
    .mag-content { font-size: 1.02rem; line-height: 2; }
    .mag-content h2 { font-size: 1.32rem; }
    .mag-prevnext { grid-template-columns: 1fr; }
    .mag-prevnext__item--next { text-align: right; }
    .mag-cta { padding: 22px 18px; }
    .mag-author { flex-direction: column; }
    .mag-search .search-form, .mag-404 .search-form { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
    .mag-card, .mag-card__media img, .mag-cats a { transition: none !important; }
    .mag-card:hover, .mag-card:hover .mag-card__media img { transform: none !important; }
}
