/* ==========================================================================
   BARSÄZ — Article Detail (صفحهٔ خواندن مقاله)
   فقط صفحهٔ خواندن مقاله — با detail.css لود می‌شود.
   هدر و متن مثل بقیهٔ سایت است؛ پیشرفت مطالعه، اشتراک‌گذاری و سایدبار جدید است.
   ========================================================================== */

/* --------------------------------------------------------------------------
   نوار پیشرفت مطالعه — بالای صفحه
   -------------------------------------------------------------------------- */
.article-progress {
    position: fixed;
    top: 0;
    inset-inline: 0;
    z-index: 130;
    height: 3px;
    background: transparent;
    pointer-events: none;
}

.article-progress span {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--accent), var(--accent-bright, var(--accent)));
    border-radius: 0 var(--radius-pill) var(--radius-pill) 0;
    transition: width .12s linear;
}

/* در RTL پیشرفت از راست شروع می‌شود */
[dir="rtl"] .article-progress span {
    border-radius: var(--radius-pill) 0 0 var(--radius-pill);
}

/* تیتر مقاله — دسکتاپ جا‌مجم‌تشتر و در موبایل کوچک */
.article-header h1 {
    font-size: clamp(1.5rem, 2.6vw, 2.05rem);
}

@media (max-width: 640px) {
    .article-header h1 {
        font-size: clamp(1.3rem, 5.5vw, 1.55rem);
        overflow-wrap: anywhere;
    }
}

/* --------------------------------------------------------------------------
   نوار اشتراک‌گذاری
   -------------------------------------------------------------------------- */
.article-share {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 26px;
    padding: 18px 22px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.article-share .share-label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.article-share .share-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-inline-start: auto;
}

.article-share .share-btn {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex: none;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--bg);
    color: var(--ink-2);
    cursor: pointer;
    transition:
        background-color var(--dur) var(--ease),
        border-color var(--dur) var(--ease),
        color var(--dur) var(--ease),
        box-shadow var(--dur) var(--ease),
        transform .18s var(--ease);
}

/* آیکن‌ها — هم‌اندازه و هم‌سبک (همه ۱۸px) */
.article-share .share-btn svg {
    width: 18px;
    height: 18px;
}

.article-share .share-btn:hover {
    transform: translateY(-2px) scale(1.06);
}

/* رنگ‌های برند شبکه‌های اجتماعی */
.article-share .share-btn.is-telegram {
    background: #229ED9;
    border-color: #229ED9;
    color: #fff;
    box-shadow: 0 8px 18px -10px color-mix(in srgb, #229ED9 70%, transparent);
}
.article-share .share-btn.is-telegram:hover { background: #1E8FC4; border-color: #1E8FC4; color: #fff; }

.article-share .share-btn.is-whatsapp {
    background: #25D366;
    border-color: #25D366;
    color: #fff;
    box-shadow: 0 8px 18px -10px color-mix(in srgb, #25D366 70%, transparent);
}
.article-share .share-btn.is-whatsapp:hover { background: #1DAA53; border-color: #1DAA53; color: #fff; }

.article-share .share-btn.is-facebook {
    background: #1877F2;
    border-color: #1877F2;
    color: #fff;
    box-shadow: 0 8px 18px -10px color-mix(in srgb, #1877F2 70%, transparent);
}
.article-share .share-btn.is-facebook:hover { background: #1262CC; border-color: #1262CC; color: #fff; }

.article-share .share-btn.is-x {
    background: #111111;
    border-color: #111111;
    color: #fff;
    box-shadow: 0 8px 18px -10px color-mix(in srgb, #111111 70%, transparent);
}
.article-share .share-btn.is-x:hover { background: #000; border-color: #000; color: #fff; }

/* اینستاگرام — پس‌زمینهٔ گرادیانی مثل اپ */
.article-share .share-btn.is-instagram {
    background: radial-gradient(circle at 28% 110%,
            #fdf497 0%,
            #fdf497 5%,
            #fd5949 45%,
            #d6249f 60%,
            #285AEB 90%);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 8px 18px -10px color-mix(in srgb, #d6249f 70%, transparent);
}
.article-share .share-btn.is-instagram:hover {
    background: radial-gradient(circle at 28% 110%,
            #fdf497 0%,
            #fdf497 10%,
            #ef5f45 50%,
            #c92b9b 68%,
            #2057e0 92%);
    color: #fff;
}

/* دکمهٔ کپی لینک */
.article-share .share-btn.is-copy {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--ink-2);
}

.article-share .share-btn.is-copy:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* دو آیکن کپی/تیک — تیک فقط بعد از کپی دیده می‌شود */
.article-share .share-btn.is-copy .ic-copy {
    transition: transform .28s var(--ease), opacity .28s var(--ease);
}

.article-share .share-btn.is-copy .ic-check {
    position: absolute;
    inset: 0;
    margin: auto;
    opacity: 0;
    transform: scale(.4);
    transition: transform .32s var(--ease), opacity .28s var(--ease);
}

.article-share .share-btn.is-copy.copied {
    color: var(--success, #4f7a4a);
    border-color: color-mix(in srgb, var(--success, #4f7a4a) 50%, var(--line));
}

.article-share .share-btn.is-copy.copied .ic-copy {
    opacity: 0;
    transform: scale(1.35) rotate(-12deg);
}

.article-share .share-btn.is-copy.copied .ic-check {
    opacity: 1;
    transform: scale(1);
}

/* جهش مقیاسی هنگام کپی شدن */
.article-share .share-btn.is-copy.pop {
    animation: share-copy-pop .45s var(--ease);
}

@keyframes share-copy-pop {
    0% { transform: scale(1); }
    40% { transform: scale(1.22); }
    100% { transform: scale(1); }
}

/* حباب «کپی شد!» بالای دکمه */
.article-share .share-btn.is-copy::after {
    content: "کپی شد!";
    position: absolute;
    bottom: calc(100% + 9px);
    inset-inline-start: 50%;
    transform: translate(50%, 5px);
    padding: 5px 12px;
    border-radius: var(--radius-pill);
    background: var(--ink, #242425);
    color: var(--on-dark, #f8f4e9);
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: transform .3s var(--ease), opacity .3s var(--ease);
}

.article-share .share-btn.is-copy::before {
    content: "";
    position: absolute;
    bottom: calc(100% + 4px);
    inset-inline-start: 50%;
    transform: translate(50%, 5px) rotate(45deg);
    width: 7px;
    height: 7px;
    background: var(--ink, #242425);
    border-radius: 2px;
    opacity: 0;
    pointer-events: none;
    transition: transform .3s var(--ease), opacity .3s var(--ease);
}

.article-share .share-btn.is-copy.copied::after,
.article-share .share-btn.is-copy.copied::before {
    opacity: 1;
    transform: translate(50%, 0);
}

/* --------------------------------------------------------------------------
   سایدبار
   -------------------------------------------------------------------------- */
.article-side {
    position: sticky;
    top: calc(var(--header-h) + 24px);
    display: grid;
    gap: 18px;
}

.aside-card {
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

.aside-card > h3 {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 16px;
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 900;
}

.aside-card > h3 svg {
    width: 17px;
    height: 17px;
    color: var(--accent);
}

.aside-card > h3::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--line);
    border-radius: var(--radius-pill);
}

/* لیست دسته‌ها */
.aside-cats {
    display: grid;
    gap: 4px;
}

.aside-cats a {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--ink-2);
    font-size: 13.5px;
    font-weight: 700;
    transition:
        background-color var(--dur) var(--ease),
        color var(--dur) var(--ease),
        padding-inline-start var(--dur) var(--ease);
}

.aside-cats a .dot {
    width: 6px;
    height: 6px;
    flex: none;
    border-radius: 50%;
    background: var(--line-strong);
    transition: background-color var(--dur) var(--ease);
}

.aside-cats a:hover {
    background: var(--surface-2);
    color: var(--ink);
    padding-inline-start: 15px;
}

.aside-cats a:hover .dot {
    background: var(--accent);
}

.aside-cats a.active {
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    color: var(--accent);
}

.aside-cats a.active .dot {
    background: var(--accent);
}

.aside-cats .count {
    margin-inline-start: auto;
    min-width: 26px;
    padding: 1px 8px;
    border-radius: var(--radius-pill);
    background: var(--bg);
    color: var(--muted);
    font-size: 11px;
    text-align: center;
}

.aside-cats a.active .count {
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    color: var(--accent);
}

/* مقالات مرتبط — کارت‌های افقی کوچک با تصویر */
.aside-related {
    display: grid;
    gap: 14px;
}

.aside-related a {
    display: flex;
    align-items: center;
    gap: 13px;
}

.aside-related .thumb {
    width: 78px;
    height: 62px;
    display: grid;
    place-items: center;
    flex: none;
    overflow: hidden;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--surface-2);
}

.aside-related .thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .5s var(--ease);
}

.aside-related a:hover .thumb img {
    transform: scale(1.08);
}

.aside-related .thumb svg {
    width: 22px;
    height: 22px;
    color: var(--muted);
}

.aside-related b {
    font-size: 12.5px;
    line-height: 1.9;
    color: var(--ink-2);
    transition: color var(--dur) var(--ease);
}

.aside-related a:hover b {
    color: var(--accent);
}

/* --------------------------------------------------------------------------
   فرم نظرات مقاله — چیدمان شکیل‌تر + ستارهٔ امتیاز
   -------------------------------------------------------------------------- */
.article-main .review-form {
    padding: 26px 28px;
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--accent) 4%, var(--bg));
    box-shadow: var(--shadow-sm);
}

.article-main .review-form-title {
    flex-direction: row;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px 14px;
}

.article-main .review-form-title b {
    font-size: 17px;
}

.article-main .review-form-title .muted {
    font-size: 12.5px;
    line-height: 1.9;
}

.article-main .star-input {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    gap: 6px;
    direction: ltr;
    padding: 4px 0 2px;
}

.article-main .star-input label {
    font-size: 30px;
    line-height: 1.25;
}

.article-main .review-form textarea.input {
    min-height: 112px;
    border-radius: var(--radius-sm);
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.article-main .review-form textarea.input:focus {
    border-color: color-mix(in srgb, var(--accent) 55%, var(--line-strong));
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent);
    outline: none;
}

.article-main .review-form .btn {
    justify-self: start;
    min-width: 140px;
}

@media (max-width: 640px) {
    .article-main .review-form {
        padding: 20px 16px;
        border-radius: var(--radius);
    }

    .article-main .review-form-title {
        flex-direction: column;
        align-items: flex-start;
    }

    .article-main .review-form .btn {
        justify-self: stretch;
    }
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
    /* اشتراک‌گذاری: در موبایل متن و آیکن‌ها زیر هم وسط‌چین */
    .article-share {
        flex-direction: column;
        align-items: center;
        gap: 14px;
        padding: 16px 14px;
        text-align: center;
    }

    .article-share .share-label {
        justify-content: center;
    }

    .article-share .share-row {
        width: 100%;
        justify-content: center;
        gap: 10px;
        margin-inline-start: 0;
    }

    .article-share .share-btn {
        width: 44px;
        height: 44px;
    }

    .aside-card {
        padding: 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .article-share .share-btn,
    .aside-related .thumb img {
        transition: none;
    }
}
