/* ══════════════════════════════════════════════════════════════════════
   نوار دسترس‌پذیری (Accessibility Toolbar) — شهرداری اشنویه
   مطابق با پالت و متغیرهای CSS موجود در main.css؛ تمام حالت‌ها به‌صورت
   کلاس روی <html> اعمال می‌شن و در localStorage ذخیره می‌مونن (accessibility.js)
   ══════════════════════════════════════════════════════════════════════ */

/* ---------- دکمه‌ی شناور ---------- */
.a11y-fab {
    position: fixed;
    bottom: 22px;
    left: 22px;
    z-index: 900;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--forest-700);
    color: #fff;
    border: 2px solid rgba(255,255,255,.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(18,41,30,.35);
    transition: transform .18s ease, background .18s ease;
}
.a11y-fab:hover, .a11y-fab:focus-visible { background: var(--leaf-700); transform: translateY(-2px); }
.a11y-fab:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

/* روی موبایل کمی بالاتر بره تا با نوار قیمت/دکمه‌های شناور دیگه تداخل نکنه */
@media (max-width: 700px) { .a11y-fab { bottom: 16px; left: 16px; width: 46px; height: 46px; font-size: 18px; } }

/* ---------- پنل ---------- */
.a11y-panel {
    position: fixed;
    bottom: 84px;
    left: 22px;
    z-index: 900;
    width: 300px;
    max-width: calc(100vw - 32px);
    max-height: 72vh;
    overflow-y: auto;
    background: var(--paper-card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 16px 40px rgba(18,41,30,.22);
    padding: 16px;
    transform: translateY(12px) scale(.97);
    opacity: 0;
    pointer-events: none;
    transition: transform .18s ease, opacity .18s ease;
}
.a11y-panel.open { transform: translateY(0) scale(1); opacity: 1; pointer-events: auto; }
@media (max-width: 700px) { .a11y-panel { bottom: 70px; left: 16px; } }

.a11y-panel-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line);
}
.a11y-panel-head strong { font-size: 15px; color: var(--forest-700); display: flex; align-items: center; gap: 8px; }
.a11y-panel-close { background: none; border: none; font-size: 16px; color: var(--muted); cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.a11y-panel-close:hover, .a11y-panel-close:focus-visible { background: var(--paper); color: var(--ink); }

.a11y-group { margin-bottom: 12px; }
.a11y-group-label { font-size: 12.5px; font-weight: 700; color: var(--muted); margin-bottom: 6px; display: block; }

.a11y-stepper { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.a11y-stepper button {
    flex: 1; background: var(--paper); border: none; padding: 8px 4px; cursor: pointer;
    font-family: inherit; font-size: 13px; color: var(--ink); border-inline-start: 1px solid var(--line);
}
.a11y-stepper button:first-child { border-inline-start: none; }
.a11y-stepper button.active { background: var(--forest-700); color: #fff; font-weight: 700; }
.a11y-stepper button:hover:not(.active) { background: #EDE9DB; }
.a11y-stepper button:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }

.a11y-toggle-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px;
    background: var(--paper);
}
.a11y-toggle-row span { font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.a11y-toggle-row span i { color: var(--forest-700); width: 16px; text-align: center; }

.a11y-switch { position: relative; width: 38px; height: 22px; flex-shrink: 0; }
.a11y-switch input { opacity: 0; width: 0; height: 0; }
.a11y-switch .a11y-track {
    position: absolute; inset: 0; background: #D8D2C0; border-radius: 999px; cursor: pointer; transition: background .15s ease;
}
.a11y-switch .a11y-track::before {
    content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #fff;
    top: 3px; right: 3px; transition: transform .15s ease; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.a11y-switch input:checked + .a11y-track { background: var(--forest-700); }
.a11y-switch input:checked + .a11y-track::before { transform: translateX(-16px); }
.a11y-switch input:focus-visible + .a11y-track { outline: 2px solid var(--gold); outline-offset: 2px; }

.a11y-reset-btn {
    width: 100%; margin-top: 4px; padding: 9px; border-radius: 10px; border: 1px dashed var(--line);
    background: none; color: var(--urgent); font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}
.a11y-reset-btn:hover, .a11y-reset-btn:focus-visible { background: rgba(178,58,46,.08); }

.a11y-panel-foot { font-size: 11px; color: var(--muted); text-align: center; margin-top: 6px; }

/* ══════════════════════════════════════════════════════════════════════
   حالت‌های اعمال‌شده روی <html>
   ══════════════════════════════════════════════════════════════════════ */

/* --- بزرگ‌نمایی متن (۴ سطح) --- */
html.a11y-font-1 { font-size: 106.25%; }
html.a11y-font-2 { font-size: 112.5%; }
html.a11y-font-3 { font-size: 125%; }

/* --- کنتراست بالا (بازنویسیِ متغیرهای رنگ، در کل سایت جاری می‌شه) --- */
html.a11y-contrast {
    --forest-900: #000000;
    --forest-700: #000000;
    --leaf-500: #0a6b2e;
    --leaf-700: #000000;
    --gold: #ffd400;
    --gold-deep: #8a6400;
    --gold-text: #000000;
    --paper: #ffffff;
    --paper-card: #ffffff;
    --ink: #000000;
    --muted: #000000;
    --line: #000000;
    --urgent: #b00000;
}
html.a11y-contrast * { text-shadow: none !important; }
html.a11y-contrast a { text-decoration: underline; }
html.a11y-contrast img:not(.brand-emblem img) { filter: contrast(1.08); }

/* --- حالت شب --- */
html.a11y-dark {
    --paper: #12161c;
    --paper-card: #1b212a;
    --ink: #ECE9DE;
    --muted: #A9B3AA;
    --line: #303a34;
    --forest-900: #0b1710;
    --forest-700: #1a3a2c;
}
html.a11y-dark img:not(.brand-emblem img) { filter: brightness(.88) contrast(1.02); }
/* دو حالت هم‌زمان قابل استفاده نیستن (کنتراست بالا اولویت داره) */
html.a11y-dark.a11y-contrast { --paper: #000000; --paper-card: #000000; --ink: #ffffff; --line: #ffffff; }

/* --- فونت خواناتر (فاصله‌ی حروف/خط بیشتر، مناسب دیس‌لکسی) --- */
html.a11y-readable body, html.a11y-readable input, html.a11y-readable textarea, html.a11y-readable select {
    font-family: "Vazirmatn", Tahoma, sans-serif !important;
    letter-spacing: .015em;
    line-height: 2.05 !important;
    word-spacing: .04em;
}
html.a11y-readable p, html.a11y-readable li { max-width: 68ch; }

/* --- برجسته‌سازی لینک‌ها --- */
html.a11y-underline a { text-decoration: underline !important; text-underline-offset: 3px; }

/* --- توقف انیمیشن‌ها و اسکرول خودکار (نوار اخبار، اسلایدر و...) --- */
html.a11y-motion-off *, html.a11y-motion-off *::before, html.a11y-motion-off *::after {
    animation-play-state: paused !important;
    transition: none !important;
    scroll-behavior: auto !important;
}

/* --- خط‌کش مطالعه (ردیاب افقیِ نگاه، دنبال‌کننده‌ی نشانگر ماوس) --- */
#a11y-reading-guide {
    position: fixed; left: 0; right: 0; height: 40px; pointer-events: none;
    z-index: 895; background: rgba(217,164,65,.22); border-top: 2px solid var(--gold);
    border-bottom: 2px solid var(--gold); display: none;
}
html.a11y-guide-on #a11y-reading-guide { display: block; }

/* --- فوکوس همیشه واضح، حتی اگه کاربر تنظیمات دیگه رو خاموش کرده باشه --- */
html.a11y-contrast :focus-visible, html.a11y-dark :focus-visible {
    outline: 3px solid var(--gold) !important; outline-offset: 2px !important;
}
