/* =========================================================
   تم روشن / تاریک — کنترل‌های مشترک
   ========================================================= */

:root[data-theme="dark"] {
    color-scheme: dark;
}

/* دکمه آیکنی تم (هدر دسکتاپ و صفحات داخلی) */
.theme-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.9));
    border-radius: 14px;
    background: var(--glass-strong, rgba(255, 255, 255, 0.74));
    color: var(--ink, #0f172a);
    font-size: 17px;
    cursor: pointer;
    box-shadow: var(--shadow-sm, 0 6px 18px -10px rgba(15, 23, 42, 0.35));
    transition: transform var(--dur, 220ms) var(--ease, ease),
        background var(--dur, 220ms) var(--ease, ease),
        color var(--dur, 220ms) var(--ease, ease);
}

.theme-icon-btn:hover {
    background: #fff;
    transform: translateY(-1px);
}

.theme-icon-btn:active {
    transform: scale(0.95);
}

.theme-icon-btn[aria-pressed="true"] {
    color: var(--brand-strong, #c2410c);
    background: var(--brand-soft, #ffedd5);
}

.header .theme-icon-btn,
.site-header .theme-icon-btn {
    color: var(--ink);
}

.header .theme-icon-btn[aria-pressed="true"],
.site-header .theme-icon-btn[aria-pressed="true"] {
    color: var(--brand-strong);
}

/* سوییچ تم داخل منوی همبرگری */
.theme-switch {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.85));
    border-radius: var(--radius-md, 14px);
    background: rgba(255, 255, 255, 0.62);
    color: var(--ink, #0f172a);
    font-family: inherit;
    text-align: right;
    cursor: pointer;
    box-shadow: var(--shadow-sm, 0 6px 18px -10px rgba(15, 23, 42, 0.35));
    transition: background var(--dur, 220ms) var(--ease, ease),
        border-color var(--dur, 220ms) var(--ease, ease),
        transform var(--dur, 220ms) var(--ease, ease);
}

.theme-switch:hover {
    background: #fff;
    transform: translateY(-1px);
}

.theme-switch-icon {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 13px;
    background: var(--brand-soft, #ffedd5);
    color: var(--brand-deep, #9a3412);
    font-size: 16px;
}

.theme-switch-copy {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.theme-switch-copy strong {
    font-size: 14px;
    font-weight: 800;
    line-height: 1.6;
}

.theme-switch-copy small {
    font-size: 11px;
    font-weight: 500;
    color: var(--muted, #64748b);
    line-height: 1.6;
}

.theme-switch-track {
    position: relative;
    flex: 0 0 auto;
    width: 48px;
    height: 27px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.16);
    transition: background var(--dur, 220ms) var(--ease, ease);
}

.theme-switch-thumb {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 21px;
    height: 21px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.28);
    transition: transform var(--dur, 220ms) var(--ease, ease);
}

.theme-switch[aria-checked="true"] .theme-switch-track {
    background: var(--brand, #ea580c);
}

.theme-switch[aria-checked="true"] .theme-switch-thumb {
    transform: translateX(-21px);
}

/* حالت تاریک کنترل‌ها */
[data-theme="dark"] .theme-icon-btn {
    background: rgba(15, 23, 42, 0.68);
    border-color: rgba(255, 255, 255, 0.14);
    color: var(--ink, #f8fafc);
    box-shadow: 0 14px 30px -20px rgba(0, 0, 0, 0.9);
}

[data-theme="dark"] .theme-icon-btn:hover {
    background: rgba(30, 41, 59, 0.92);
}

[data-theme="dark"] .theme-icon-btn[aria-pressed="true"] {
    background: rgba(249, 115, 22, 0.18);
    border-color: rgba(249, 115, 22, 0.3);
    color: #fdba74;
}

[data-theme="dark"] .theme-switch {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
    color: var(--ink, #f8fafc);
    box-shadow: none;
}

[data-theme="dark"] .theme-switch:hover {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .theme-switch-icon {
    background: rgba(249, 115, 22, 0.16);
    color: #fdba74;
}

[data-theme="dark"] .theme-switch-copy small {
    color: var(--muted, #94a3b8);
}

[data-theme="dark"] .theme-switch-track {
    background: rgba(255, 255, 255, 0.18);
}

/* فوکوس و حرکت کمتر */
.theme-icon-btn:focus-visible,
.theme-switch:focus-visible {
    outline: 3px solid rgba(234, 88, 12, 0.55);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .theme-icon-btn,
    .theme-switch,
    .theme-switch-track,
    .theme-switch-thumb {
        transition: none;
    }
}
