/* ---------- Theme palettes (light default, dark via system or toggle) ---------- */
:root {
    --bg: #f1f2f4;
    --surface: #ffffff;
    --surface-2: #f6f7f9;
    --text: #14181f;
    --text-soft: #4a515c;
    --muted: #7a828f;
    --line: #e4e7eb;
    --brand: #0a8f5b;
    --brand-ink: #067045;
    --accent: #e11d48;
    --header-bg: rgba(255, 255, 255, .88);
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
    --shadow-hover: 0 8px 26px rgba(16, 24, 40, .14);
    --placeholder: linear-gradient(135deg, #dfe4ea, #eef1f4);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #121317;
        --surface: #1c1d22;
        --surface-2: #24262c;
        --text: #f2f3f5;
        --text-soft: #c3c8d0;
        --muted: #8b909a;
        --line: #2c2f37;
        --brand: #22c55e;
        --brand-ink: #4ade80;
        --accent: #f43f5e;
        --header-bg: rgba(20, 21, 25, .82);
        --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
        --shadow-hover: 0 10px 30px rgba(0, 0, 0, .5);
        --placeholder: linear-gradient(135deg, #23252b, #2c2f37);
    }
}

/* توگل دستی (بر تنظیم سیستم اولویت دارد) */
:root[data-theme="light"] {
    --bg: #f1f2f4;
    --surface: #ffffff;
    --surface-2: #f6f7f9;
    --text: #14181f;
    --text-soft: #4a515c;
    --muted: #7a828f;
    --line: #e4e7eb;
    --brand: #0a8f5b;
    --brand-ink: #067045;
    --accent: #e11d48;
    --header-bg: rgba(255, 255, 255, .88);
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
    --shadow-hover: 0 8px 26px rgba(16, 24, 40, .14);
    --placeholder: linear-gradient(135deg, #dfe4ea, #eef1f4);
}

:root[data-theme="dark"] {
    --bg: #121317;
    --surface: #1c1d22;
    --surface-2: #24262c;
    --text: #f2f3f5;
    --text-soft: #c3c8d0;
    --muted: #8b909a;
    --line: #2c2f37;
    --brand: #22c55e;
    --brand-ink: #4ade80;
    --accent: #f43f5e;
    --header-bg: rgba(20, 21, 25, .82);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
    --shadow-hover: 0 10px 30px rgba(0, 0, 0, .5);
    --placeholder: linear-gradient(135deg, #23252b, #2c2f37);
}

:root {
    --radius: 10px;
    --container: 1320px;
    font-family: IRANYekan, "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: IRANYekan, "Segoe UI", Tahoma, sans-serif;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

.container {
    width: 100%;
    max-width: var(--container);
    margin-inline: auto;
    padding-inline: 18px;
}

/* ---------- Header ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--header-bg);
    backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--line);
}

.site-header__inner {
    display: flex;
    align-items: center;
    gap: 22px;
    height: 62px;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand__mark { color: var(--brand); display: flex; }
.brand__text { display: flex; flex-direction: column; line-height: 1.1; }
.brand__fa { font-weight: 800; font-size: 19px; letter-spacing: -.2px; }
.brand__en { font-size: 11px; color: var(--brand-ink); font-weight: 700; letter-spacing: .5px; }

.topnav { display: flex; align-items: center; gap: 4px; margin-inline-start: 6px; }
.topnav__link {
    padding: 7px 13px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 14px;
    color: var(--text-soft);
    transition: background .15s, color .15s;
}
.topnav__link:hover { background: var(--surface-2); color: var(--text); }
.topnav__link--active { color: var(--brand-ink); background: color-mix(in srgb, var(--brand) 14%, transparent); }

.site-header__meta { margin-inline-start: auto; display: flex; align-items: center; gap: 14px; }
.site-date { color: var(--muted); font-size: 13px; }

.theme-toggle {
    display: grid;
    place-items: center;
    width: 38px; height: 38px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text-soft);
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--muted); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .i-sun { display: none; }
.theme-toggle.is-dark .i-sun { display: block; }
.theme-toggle.is-dark .i-moon { display: none; }

.site-main { padding-block: 18px 44px; }

/* ---------- Mosaic ---------- */
.mosaic {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 128px;          /* واحد ردیف کوچک؛ کاشی‌ها جمع‌وجورتر */
    grid-auto-flow: row dense;
    gap: 12px;
}

.tile {
    position: relative;
    display: flex;
    flex-direction: column;
    grid-column: span 1;
    grid-row: span 2;               /* پیش‌فرض: کاشی متوسط = ۱×۲ */
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    transition: transform .16s ease, box-shadow .16s ease;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }

.t-big { grid-column: span 2; grid-row: span 3; }   /* بزرگ = ۲×۳ */
.t-std { grid-row: span 2; }                        /* متوسط = ۱×۲ */
.t-small { grid-row: span 1; flex-direction: row; } /* کوچک = ۱×۱ افقی */

.tile__media { position: relative; flex: 1 1 auto; min-height: 0; width: 100%; overflow: hidden; background: var(--surface-2); }
.tile__media img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.tile:hover .tile__media img { transform: scale(1.05); }
.tile__media--placeholder { display: grid; place-items: center; background: var(--placeholder); color: var(--muted); font-weight: 800; font-size: 16px; }

.tile__content {
    flex: 0 0 auto;
    padding: 9px 11px 11px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--surface);
    min-width: 0;
}
.tile__title {
    margin: 0;
    font-size: 13.5px;
    font-weight: 700;
    line-height: 1.5;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* کاشیِ بزرگ: تصویر تمام‌قد، عنوان روی تصویر */
.t-big .tile__media { position: absolute; inset: 0; flex: none; }
.tile__grad {
    position: absolute; inset: 0;
    background: linear-gradient(to top, rgba(6, 10, 18, .92) 4%, rgba(6, 10, 18, .35) 44%, rgba(6, 10, 18, 0) 72%);
}
.t-big .tile__content {
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    padding: 16px 18px 16px;
    background: none;
    color: #fff;
    z-index: 2;
    gap: 8px;
}
.t-big .tile__title {
    font-size: clamp(16px, 1.5vw, 22px);
    font-weight: 800;
    line-height: 1.45;
    color: #fff;
    text-shadow: 0 1px 10px rgba(0, 0, 0, .45);
    -webkit-line-clamp: 3;
}

/* کاشیِ کوچک: بندانگشتی کنار تیتر */
.t-small { align-items: stretch; }
.t-small .tile__thumb { flex: 0 0 40%; max-width: 116px; overflow: hidden; background: var(--surface-2); }
.t-small .tile__thumb img { width: 100%; height: 100%; object-fit: cover; }
.t-small .tile__content { flex: 1 1 auto; justify-content: center; padding: 8px 11px; }
.t-small .tile__title { font-size: 12.8px; -webkit-line-clamp: 3; }
.t-small--text .tile__content { justify-content: center; }
.t-small--text .tile__title { -webkit-line-clamp: 3; }

.tile__meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    color: var(--muted);
}
.t-big .tile__meta { color: #d7dbe2; }
.tile__agency { font-weight: 700; color: var(--brand-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-big .tile__agency { color: #fff; }
.tile__meta .dot { opacity: .55; }
.tile__meta time { white-space: nowrap; }

.chip {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 999px;
}
.chip--sport { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand-ink); }
.chip--soft { background: var(--surface-2); color: var(--text-soft); }
.tile__media .chip--sport {
    position: absolute;
    inset-inline-start: 8px;
    top: 8px;
    background: rgba(6, 10, 18, .68);
    color: #fff;
    backdrop-filter: blur(4px);
}
.t-big .chip--sport { background: var(--accent); color: #fff; }

/* ---------- Hero tile (slider) — کاشیِ بزرگ ۲×۳ ---------- */
.hero-tile { padding: 0; display: block; }
.hero-tile__track { display: flex; height: 100%; transition: transform .5s cubic-bezier(.4, 0, .2, 1); }
.hslide { position: relative; min-width: 100%; height: 100%; display: block; }
.hslide .tile__media { position: absolute; inset: 0; flex: none; }
.hslide .tile__media img { width: 100%; height: 100%; object-fit: cover; }
.hslide .tile__grad { z-index: 1; }
.hslide .tile__content {
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    z-index: 2;
    padding: 20px 22px 22px;
    background: none;
    color: #fff;
    gap: 8px;
}
.hslide .tile__title {
    font-size: clamp(18px, 1.9vw, 26px);
    font-weight: 800;
    line-height: 1.45;
    color: #fff;
    text-shadow: 0 1px 12px rgba(0, 0, 0, .5);
    -webkit-line-clamp: 3;
}
.hslide .tile__meta { color: #e2e6ec; }

.hero-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    width: 56px; height: 56px;
    border: none;
    background: none;
    padding: 0;
    color: #fff;
    cursor: pointer;
    display: grid; place-items: center;
    opacity: .92;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, .6));
    transition: opacity .15s, transform .15s;
}
.hero-nav:hover { opacity: 1; }
.hero-nav:active { transform: translateY(-50%) scale(.9); }
.hero-nav svg { width: 46px; height: 46px; }
.hero-nav--prev { inset-inline-end: 8px; }
.hero-nav--next { inset-inline-start: 8px; }

.hero-dots {
    position: absolute;
    bottom: 14px;
    inset-inline-end: 20px;
    z-index: 3;
    display: flex;
    gap: 6px;
}
.hero-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, .5);
    cursor: pointer;
    padding: 0;
    transition: background .15s, width .2s;
}
.hero-dot.is-active { background: #fff; width: 22px; border-radius: 5px; }

/* ---------- Infinite scroll footer ---------- */
.feed-sentinel { height: 4px; }
.feed-loader { display: flex; justify-content: center; padding: 26px 0; }
.spinner {
    width: 30px; height: 30px;
    border: 3px solid var(--line);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.feed-end { text-align: center; color: var(--muted); padding: 26px 0; font-size: 14px; }

/* ---------- Article page ---------- */
.breadcrumb { display: flex; gap: 8px; color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.breadcrumb a:hover { color: var(--brand-ink); }

.article-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }

.article {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 30px 34px 34px;
    box-shadow: var(--shadow);
}
.article__title { margin: 0 0 18px; font-size: clamp(22px, 3vw, 30px); font-weight: 800; line-height: 1.55; }
.article__meta {
    display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
    padding-bottom: 18px; margin-bottom: 20px;
    border-bottom: 1px solid var(--line);
    color: var(--muted); font-size: 13px;
}
.article__agency-logo { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
.article__image { width: 100%; border-radius: 12px; margin-bottom: 22px; }
.article__summary {
    font-size: 17px; font-weight: 700; color: var(--text);
    background: var(--surface-2);
    border-inline-start: 4px solid var(--brand);
    padding: 14px 18px; border-radius: 10px; margin: 0 0 22px;
}
.article__body { font-size: 16.5px; line-height: 2.1; color: var(--text-soft); }
.article__body p { margin: 0 0 18px; }
.article__body img { border-radius: 10px; margin: 18px auto; }
.article__body h2, .article__body h3 { font-weight: 800; margin: 26px 0 12px; color: var(--text); }
.article__body a { color: var(--brand-ink); text-decoration: underline; }

.tag-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.tag { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); color: var(--text-soft); padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; }
.tag__img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; }
.article__source { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); }
.article__source a { color: var(--brand-ink); font-weight: 700; }

.section-head { display: flex; align-items: center; gap: 14px; margin: 2px 0 16px; }
.section-head__title { margin: 0; font-size: 18px; font-weight: 800; position: relative; padding-inline-start: 12px; }
.section-head__title::before { content: ""; position: absolute; inset-inline-start: 0; top: 50%; transform: translateY(-50%); width: 4px; height: 18px; border-radius: 3px; background: var(--brand); }
.section-head__rule { flex: 1; height: 1px; background: var(--line); }

.related__list { display: flex; flex-direction: column; gap: 14px; }

/* کارت‌های ساده (اخبار مرتبط) */
.card { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); transition: transform .16s, box-shadow .16s; }
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.card__media { position: relative; width: 116px; flex: 0 0 116px; aspect-ratio: auto; background: var(--surface-2); }
.card__img { width: 100%; height: 100%; object-fit: cover; }
.card__img--placeholder { display: grid; place-items: center; background: var(--placeholder); color: var(--muted); font-weight: 800; font-size: 12px; }
.card__body { padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }
.card__title { margin: 0; font-size: 13.5px; font-weight: 700; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card__meta { margin-top: auto; display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.card__agency { color: var(--brand-ink); font-weight: 700; }
.card .chip--sport { display: none; }

/* ---------- Misc ---------- */
.empty, .notice { text-align: center; color: var(--text-soft); padding: 60px 20px; }
.notice h1 { font-size: 22px; }
.btn { display: inline-block; margin-top: 16px; background: var(--brand); color: #fff; font-weight: 700; padding: 10px 22px; border-radius: 999px; }

.site-footer { border-top: 1px solid var(--line); background: var(--surface); margin-top: 30px; }
.site-footer__inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 24px; flex-wrap: wrap; }
.site-footer__brand { display: flex; align-items: baseline; gap: 10px; }
.site-footer__brand .brand__fa { font-size: 17px; font-weight: 800; }
.site-footer__tag { color: var(--muted); font-size: 13px; }
.site-footer__copy { color: var(--muted); font-size: 13px; margin: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
    .mosaic { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
    .article-layout { grid-template-columns: 1fr; }
    .topnav { display: none; }
    .article { padding: 22px; }
}
@media (max-width: 760px) {
    .mosaic { grid-template-columns: repeat(2, 1fr); grid-auto-rows: 108px; gap: 10px; }
    .t-big { grid-column: span 2; }
}
@media (max-width: 440px) {
    .site-date { display: none; }
    .mosaic { grid-auto-rows: 96px; }
}
