/* PelegSoft -כלי נגישות (תקן ישראלי): כפתור בסרגל, פאנל, ומצבי הנגשה */

/* מניעת סימון טקסט בעת לחיצה על פקדי הנגישות */
.a11y-btn, .a11y-panel {
    -webkit-user-select: none;
    user-select: none;
}

/* ---- כפתור הנגישות בסרגל העליון ---- */
.a11y-btn {
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    border: 2px solid rgba(255, 231, 163, 0.6);
    background: linear-gradient(180deg, #9a6a3c, var(--c-wood) 55%, var(--c-wood-deep));
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 0 var(--c-wood-deep), 0 5px 12px rgba(13, 62, 120, 0.4), inset 0 1px 0 rgba(255, 231, 163, 0.5);
    transition: transform 0.15s, filter 0.2s;
    flex: 0 0 auto;
}
.a11y-btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
.a11y-btn:active { transform: translateY(1px); }

/* ---- מובייל: כפתור מרחף (fixed) -מיקום/גודל/צבע נשלטים מפאנל הניהול ---- */
@media (max-width: 640px) {
    /* מצב "בסרגל" (a11y-m-bar) -ההתנהגות הישנה: צמוד לשמאל הסרגל העליון */
    body.a11y-m-bar .a11y-btn {
        position: absolute;
        left: max(0.7rem, env(safe-area-inset-left)); /* לא מתחת לחריץ בלנדסקייפ */
        top: 0.5rem;
        z-index: 2;
    }
    /* כל שאר המצבים -כפתור מרחף מעל התוכן, מחוץ לסרגל */
    body:not(.a11y-m-bar) .a11y-btn {
        position: fixed;
        z-index: 115; /* מתחת לפאנל (120) ומעל התוכן */
        width: var(--a11y-size, 3rem);
        height: var(--a11y-size, 3rem);
        background: linear-gradient(180deg,
            color-mix(in srgb, var(--a11y-color, #7B4F28) 78%, #fff),
            var(--a11y-color, #7B4F28) 55%,
            color-mix(in srgb, var(--a11y-color, #7B4F28) 72%, #000));
        box-shadow: 0 4px 0 color-mix(in srgb, var(--a11y-color, #7B4F28) 65%, #000),
                    0 8px 18px rgba(13, 62, 120, 0.45),
                    inset 0 1px 0 rgba(255, 231, 163, 0.5);
        opacity: var(--a11y-opacity, 1);
        transition: transform 0.15s, filter 0.2s, opacity 0.2s;
    }
    /* במגע/פתיחה הכפתור תמיד אטום לגמרי -שלא יישאר דהוי כשמשתמשים בו */
    body:not(.a11y-m-bar) .a11y-btn:hover,
    body:not(.a11y-m-bar) .a11y-btn:focus-visible,
    body:not(.a11y-m-bar) .a11y-btn:active,
    body:not(.a11y-m-bar) .a11y-btn[aria-expanded="true"] { opacity: 1; }
    body:not(.a11y-m-bar) .a11y-icon {
        width: calc(var(--a11y-size, 3rem) * 0.6);
        height: calc(var(--a11y-size, 3rem) * 0.6);
        color: var(--a11y-icon-color, #FFF3D0);
    }
    /* ארבע פינות -מרווח שמכבד את ה-safe-area של iPhone */
    body.a11y-m-bl .a11y-btn { bottom: calc(0.9rem + env(safe-area-inset-bottom)); left: max(0.9rem, env(safe-area-inset-left)); }
    body.a11y-m-br .a11y-btn { bottom: calc(0.9rem + env(safe-area-inset-bottom)); right: max(0.9rem, env(safe-area-inset-right)); }
    body.a11y-m-tl .a11y-btn { top: calc(0.9rem + env(safe-area-inset-top)); left: max(0.9rem, env(safe-area-inset-left)); }
    body.a11y-m-tr .a11y-btn { top: calc(0.9rem + env(safe-area-inset-top)); right: max(0.9rem, env(safe-area-inset-right)); }

    /* הפאנל נפתח ליד הכפתור ולא בפינה השמאלית-עליונה הקבועה */
    body.a11y-m-bl .a11y-panel,
    body.a11y-m-br .a11y-panel { top: auto; bottom: calc(var(--a11y-size, 3rem) + 1.6rem + env(safe-area-inset-bottom)); }
    body.a11y-m-tl .a11y-panel,
    body.a11y-m-tr .a11y-panel { top: calc(var(--a11y-size, 3rem) + 1.6rem + env(safe-area-inset-top)); bottom: auto; }
    body.a11y-m-bl .a11y-panel, body.a11y-m-tl .a11y-panel { left: 0.9rem; right: auto; }
    body.a11y-m-br .a11y-panel, body.a11y-m-tr .a11y-panel { right: 0.9rem; left: auto; }
}
.a11y-icon {
    width: 1.45rem;
    height: 1.45rem;
    color: #FFF3D0; /* קרם-זהב על העץ */
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
}

/* ---- פאנל האפשרויות ---- */
.a11y-panel {
    position: fixed;
    top: 3.8rem;
    left: 1rem; /* מתחת לכפתור (צד שמאל פיזי) */
    z-index: 120;
    width: min(17.5rem, 92vw);
    background: linear-gradient(180deg, rgba(255, 246, 230, 0.98), rgba(255, 240, 214, 0.98));
    border: 2px solid var(--c-gold-deep);
    border-radius: 16px;
    box-shadow: 0 16px 40px rgba(13, 62, 120, 0.45);
    color: var(--c-wood-deep);
    overflow: hidden;
    animation: a11y-rise 0.25s cubic-bezier(0.2, 1.3, 0.4, 1) both;
}
.a11y-panel[hidden] { display: none; }
@keyframes a11y-rise {
    from { opacity: 0; transform: translateY(-10px) scale(0.97); }
    to   { opacity: 1; transform: none; }
}

.a11y-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.8rem;
    background: linear-gradient(180deg, #9a6a3c, var(--c-wood));
    color: var(--c-paper);
}
.a11y-title { font-family: 'Suez One', serif; font-size: 1rem; display: inline-flex; align-items: center; gap: 0.4rem; }
.a11y-title-icon { width: 1.1rem; height: 1.1rem; }
.a11y-close {
    width: 1.6rem; height: 1.6rem;
    border: none; border-radius: 50%;
    background: rgba(0, 0, 0, 0.18);
    color: #fff; cursor: pointer; font-size: 0.8rem;
}
.a11y-close:hover { background: rgba(224, 69, 46, 0.6); }

.a11y-body { padding: 0.8rem; display: flex; flex-direction: column; gap: 0.55rem; }

.a11y-font {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    background: rgba(211, 154, 26, 0.12);
    border: 1px solid rgba(211, 154, 26, 0.35);
    border-radius: 10px;
    padding: 0.35rem 0.5rem;
}
.a11y-font-mid { font-size: 0.85rem; }
.a11y-font-mid b { color: var(--c-gold-deep); }
.a11y-fbtn {
    min-width: 2.2rem;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--c-gold-deep);
    border-radius: 8px;
    background: linear-gradient(180deg, var(--c-gold-light), var(--c-gold));
    color: var(--c-wood-deep);
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
}
.a11y-fbtn:hover { filter: brightness(1.05); }

.a11y-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }
.a11y-opt {
    font-family: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    color: var(--c-wood-deep);
    background: #fff;
    border: 1px solid rgba(211, 154, 26, 0.45);
    border-radius: 10px;
    padding: 0.5rem 0.4rem;
    text-align: center;
    transition: background 0.15s, border-color 0.15s;
}
.a11y-opt:hover { background: rgba(255, 231, 163, 0.4); }
.a11y-opt.is-on {
    background: linear-gradient(180deg, var(--c-gold-light), var(--c-gold-deep));
    border-color: var(--c-gold-deep);
    color: var(--c-wood-deep);
    font-weight: 700;
    box-shadow: inset 0 1px 0 #fff;
}

.a11y-reset, .a11y-statement {
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 10px;
    padding: 0.45rem;
    text-align: center;
}
.a11y-reset {
    background: rgba(224, 69, 46, 0.12);
    border: 1px solid rgba(224, 69, 46, 0.4);
    color: #a5301c;
}
.a11y-reset:hover { background: rgba(224, 69, 46, 0.22); }
.a11y-statement {
    background: linear-gradient(180deg, #9a6a3c, var(--c-wood));
    border: 1px solid var(--c-wood-deep);
    color: var(--c-paper);
    /* הוא ‎<a>‎ מאז שהפך לקישור אמיתי (ראה ‎templates/a11y.php‎), ולכן הוא
       יורש קו תחתון מברירת המחדל של הדפדפן -בתוך כפתור מלא הוא נקרא כתקלה.
       ‎display: block‎ אינו נדרש (‎.a11y-body‎ הוא flex column), אבל מפורש
       כדי שהריפוד לא יהיה תלוי בפריסת ההורה. */
    display: block;
    text-decoration: none;
}
.a11y-statement:hover { filter: brightness(1.08); }

/* =================== מצבי הנגשה (מוחלים על <html>) =================== */

/* הדגשת קישורים */
html.a11y-links a {
    text-decoration: underline !important;
    text-underline-offset: 2px;
    outline: 1px dashed currentColor;
    outline-offset: 2px;
}

/* גופן קריא */
html.a11y-readable, html.a11y-readable * {
    font-family: Arial, 'Heebo', 'Segoe UI', sans-serif !important;
    letter-spacing: 0.01em !important;
}

/* עצירת הנפשות ומעברים */
html.a11y-nomotion *,
html.a11y-nomotion *::before,
html.a11y-nomotion *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
}

/* (ניגודיות/אפור/היפוך מוחלים כ-filter על <html> ישירות מ-JS) */

@media (prefers-reduced-motion: reduce) {
    .a11y-panel { animation: none; }
}

/* ============================================================
   דילוג לתוכן (WCAG 2.4.1)
   ============================================================ */

/* מוסתר מחוץ למסך ולא ‎display:none‎ -אלמנט שאינו מוצג אינו ניתן למיקוד, ואז
   הקישור פשוט לא קיים למי שהוא נועד לו. ‎top‎ שלילי (פיזי, לא לוגי): המיקום
   כאן אנכי, וב-RTL אין לו צד. */
.skip-link {
    position: fixed;
    top: -100vh;
    inset-inline-start: 0.75rem;
    z-index: 300;                 /* מעל הסרגל העליון והסצנה */
    padding: 0.7rem 1.2rem;
    background: var(--c-gold, #ffd76a);
    color: #1a1205;
    font-weight: 700;
    border-radius: 0 0 10px 10px;
    text-decoration: none;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
    transition: top 0.15s ease;
}
.skip-link:focus,
.skip-link:focus-visible {
    top: 0;
    outline: 3px solid #1a1205;
    outline-offset: -6px;
}

/* יעד הדילוג. ‎scroll-margin‎ כדי שהכותרת לא תסתתר מתחת לסרגל העליון. */
#content { scroll-margin-block-start: 5rem; }

/* בעצירת הנפשות גם הקישור לא מחליק -הוא פשוט מופיע */
html.a11y-nomotion .skip-link { transition: none; }

/* יעד הדילוג מקבל ‎tabindex="-1"‎ כדי שיוכל לקבל פוקוס, ולכן הדפדפן מצייר עליו
   טבעת פוקוס על כל רוחב התוכן. זה נראה כתקלה ולא כחיווי, ולכן מוסר -החיווי
   שהמשתמש צריך הוא הגלילה עצמה. */
#content:focus { outline: none; }
