/* ==========================================================================
   install-prompt.css — ההזמנה להוסיף את האתגר למסך הבית
   LeviLife · אתגר עשרה הימים · הותאם למותג 2026-08-30

   שני רכיבים, שני מסלולים שונים לגמרי:
     · .ip-banner  — פס תחתון לאנדרואיד/כרום. שם יש כפתור אמיתי שמפעיל
                     את חלון ההוספה של הדפדפן.
     · .ip-overlay — גיליון הסבר לאייפון/ספארי. שם אין שום כפתור תכנותי,
                     ולכן הרכיב הזה **מסביר** במקום לבצע.

   שפת המותג (css/brand.css):
     · המשטח הוא הסגול העמוק של המותג (--brand-deep-purple #241B47),
       ולא שחור. שחור זר לפלטה ונראה כמו רכיב מודבק מפרויקט אחר.
     · הזהב (--brand-gold #FDBF04) הוא האקסנט: פס עליון, ריבוע מספור,
       אייקון, וכפתור ראשי. זהב על הסגול העמוק = יחס ניגודיות ~11:1.
     · טקסט הכפתור הוא הסגול העמוק, בדיוק כמו --btn-text ב-brand.css.
     · הטקסט הלבן מילולי (#FFFFFF) ולא var(--text-strong) — mentor.html
       ו-admin.html דורסים טוקנים מקומית, וזה היה מוחק את הכיתוב.

   נטען ע"י js/install-prompt.js אם אין בעמוד <link> אליו.
   ========================================================================== */

/* ── משתני הרכיב. מרוכזים כאן כדי שהתחזוקה תהיה בשורה אחת ─────────────── */
.ip-banner,
.ip-overlay {
    --ip-surface: #241B47;
    --ip-text: #FFFFFF;
    --ip-text-muted: rgba(231, 225, 245, 0.78);
    --ip-accent: var(--brand-gold, #FDBF04);
    --ip-hairline: rgba(255, 255, 255, 0.16);
    font-family: var(--font, 'Assistant', 'Segoe UI', sans-serif);
    direction: rtl;
    text-align: right;
    box-sizing: border-box;
}

.ip-banner *,
.ip-overlay * { box-sizing: border-box; }

/* ==========================================================================
   1. הפס התחתון — אנדרואיד / כרום
   ========================================================================== */

/* z-index 8500: מתחת למנוע הפופ-אפים (9000) בכוונה. אם פופ-אפ פתוח,
   הוא הבעלים של המסך וההזמנה הזאת מחכה בתור. */
.ip-banner {
    position: fixed;
    inset-block-end: 0;
    inset-inline: 0;
    z-index: 8500;
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    background: var(--ip-surface);
    color: var(--ip-text);
    border-top: 3px solid var(--ip-accent);
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45);
    /* מגרעת האייפון ופס הניווט של אנדרואיד. בלי זה הכפתור נחתך למטה. */
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
    transform: translateY(110%);
    transition: transform 240ms ease;
}

.ip-banner.is-open { transform: translateY(0); }

/* שורת התוכן. flex ולא grid — grid-template-columns: 1fr לבד קורס במובייל. */
.ip-banner-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    /* מפנה מקום לכפתור ה-X שיושב בפינה הפתוחה (שמאל למעלה ב-RTL),
       אחרת הכותרת נכנסת מתחתיו. */
    padding-inline-start: 44px;
}

.ip-banner-glyph {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ip-accent);
}

.ip-banner-glyph svg { width: 100%; height: 100%; display: block; }

/* min-width: 0 מכריח את הטקסט להישבר בתוך ה-flex במקום למתוח את הפס */
.ip-banner-text { min-width: 0; }

.ip-banner-title {
    display: block;
    font-family: var(--font, inherit);
    font-weight: 900;
    font-size: 1.06rem;
    line-height: 1.25;
    color: var(--ip-text);
    margin-bottom: 4px;
    overflow-wrap: anywhere;
}

.ip-banner-sub {
    display: block;
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--ip-text-muted);
    overflow-wrap: anywhere;
}

.ip-banner-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
}

/* ==========================================================================
   2. כפתורים משותפים
   ========================================================================== */
.ip-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* 44px = יעד המגע המינימלי. גם כשהטקסט קצר. */
    min-height: 46px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-pill, 999px);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

/* זהב על הסגול העמוק. אותה זהות של .btn-primary ב-theme.css.
   בלי הצל הקשיח שיש שם: על המשטח הכהה הוא בלתי נראה. */
.ip-btn-primary {
    flex: 1 1 auto;
    min-width: 0;
    background: var(--ip-accent);
    color: var(--btn-text, #241B47);
    font-family: var(--font, inherit);
    font-weight: 900;
    font-size: 1.02rem;
    transition: transform 100ms ease, filter 200ms ease;
}

.ip-btn-primary:hover { filter: brightness(0.92); color: var(--btn-text, #241B47); }
.ip-btn-primary:active { transform: scale(0.98); }

.ip-btn-ghost {
    flex: 0 0 auto;
    background: none;
    color: var(--ip-text-muted);
    text-decoration: underline;
    font-weight: 400;
    padding-inline: 8px;
}

.ip-btn-ghost:hover { color: var(--ip-text); }

/* סימון פוקוס. על משטח שחור רק הצהוב נראה — מסגרת שחורה נבלעת. */
.ip-btn:focus-visible,
.ip-close:focus-visible,
.ip-banner-close:focus-visible {
    outline: 3px solid var(--ip-accent);
    outline-offset: 2px;
}

/* ==========================================================================
   3. כפתורי הסגירה — 44px גם כשהסימן עצמו קטן
   ========================================================================== */
.ip-banner-close,
.ip-close {
    position: absolute;
    inset-block-start: 6px;
    inset-inline-start: 6px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 1.6rem;
    line-height: 1;
    color: var(--ip-text-muted);
    cursor: pointer;
}

.ip-banner-close:hover,
.ip-close:hover { color: var(--ip-text); }

/* ==========================================================================
   3ב. קישור "רואים כאן" — בכל שלושת המסלולים, ונגן הסרטון שהוא פותח.
   נוסף 2026-08-30. אין כפתור אם אין מקור סרטון למכשיר (videoSrc() ב-JS
   מחזיר ריק) — עדיף היעדר קישור מקישור מת.
   ========================================================================== */
.ip-banner-watch,
.ip-sheet-watch {
    display: flex;
    justify-content: center;
}

.ip-banner-watch:empty,
.ip-sheet-watch:empty { display: none; }

.ip-banner-watch { margin-top: 10px; }
.ip-sheet-watch { margin-top: 14px; }

.ip-watch-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    padding: 8px 4px;
    /* יעד מגע: הגובה נמוך מ-44 בכוונה כי זו פעולה משנית, לא ראשית —
       אבל הרוחב האפקטיבי כולל את הריפוד וה-gap מספיק לנגיעה נוחה. */
    min-height: 32px;
    color: var(--ip-text-muted);
    font-family: inherit;
    font-size: 0.86rem;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}

.ip-watch-link:hover { color: var(--ip-text); }

.ip-watch-icon {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    color: var(--ip-accent);
}

.ip-watch-icon svg { width: 100%; height: 100%; display: block; }

/* ==========================================================================
   4. גיליון ההסבר — אייפון / ספארי
   ========================================================================== */
.ip-overlay {
    position: fixed;
    inset: 0;
    z-index: 8600;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(0, 0, 0, 0.62);
    opacity: 0;
    transition: opacity 180ms ease;
}

.ip-overlay.is-open { opacity: 1; }

.ip-sheet {
    position: relative;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    background: var(--ip-surface);
    color: var(--ip-text);
    border-top: 4px solid var(--ip-accent);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.4);
    padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px));
    transform: translateY(18px);
    transition: transform 200ms ease;
    max-height: 88vh;
    overflow-y: auto;
}

.ip-overlay.is-open .ip-sheet { transform: translateY(0); }

.ip-grip {
    width: 44px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.22);
    margin: 0 auto 16px;
}

.ip-title {
    margin: 0 0 8px 0;
    padding-inline-start: 44px;   /* לא נכנס מתחת ל-X */
    font-family: var(--font, inherit);
    font-weight: 900;
    font-size: 1.2rem;
    line-height: 1.28;
    color: var(--ip-text);
    overflow-wrap: anywhere;
}

.ip-lead {
    margin: 0 0 18px 0;
    font-size: 0.92rem;
    line-height: 1.6;
    color: var(--ip-text-muted);
    overflow-wrap: anywhere;
}

/* ── שני הצעדים ─────────────────────────────────────────────────────────── */
.ip-steps {
    list-style: none;
    margin: 0 0 16px 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ip-step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

/* ריבוע מספור צהוב. זה בדיוק התפקיד שהמותג מייעד לצהוב על שחור. */
.ip-step-num {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ip-accent);
    color: var(--btn-text, #241B47);
    border-radius: 50%;
    font-weight: 800;
    font-size: 0.92rem;
    line-height: 1;
}

.ip-step-text {
    min-width: 0;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--ip-text);
    overflow-wrap: anywhere;
}

/* אייקון השיתוף של iOS, משובץ בתוך שורת הטקסט */
.ip-share-inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    margin: 0 4px;
    vertical-align: -9px;
    background: rgba(255, 255, 255, 0.10);
    border: 1px solid var(--ip-hairline);
    color: var(--ip-accent);
}

.ip-share-inline svg { width: 17px; height: 17px; display: block; }

/* ציטוט של הכיתוב שהמאזין מחפש בתפריט של ספארי */
.ip-quote {
    display: inline-block;
    padding: 2px 7px;
    background: rgba(255, 255, 255, 0.10);
    border: 1px solid var(--ip-hairline);
    font-weight: 700;
    white-space: nowrap;
}

.ip-note {
    margin: 0;
    padding-top: 14px;
    border-top: 1px solid var(--ip-hairline);
    font-size: 0.85rem;
    line-height: 1.55;
    color: var(--ip-text-muted);
}

.ip-sheet-actions {
    display: flex;
    margin-top: 18px;
}

.ip-sheet-actions .ip-btn { width: 100%; }

/* ==========================================================================
   4ב. נגן הסרטון — נפתח לפעמים **מעל** גיליון אחר (z-index זהה, מאוחר
   יותר ב-DOM ולכן מצויר מעליו). הבלוק הזה רק מצמצם את הריפוד הרגיל של
   .ip-sheet כדי שהווידאו יתפוס את רוב הגובה, לא מגדיר סוג חדש.
   ========================================================================== */
.ip-video-sheet {
    padding-inline: 12px;
    padding-block-end: calc(12px + env(safe-area-inset-bottom, 0px));
}

.ip-video-title {
    padding-inline-start: 44px;
    margin-bottom: 12px;
}

.ip-video-wrap {
    /* 9:16 — הסרטונים אנכיים (מסך טלפון). למסך רחב הגובה מוגבל כדי שלא
       ידחוף את הדיאלוג מעבר לגובה הנראה. */
    aspect-ratio: 9 / 16;
    max-height: 70vh;
    margin: 0 auto;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

.ip-video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

/* ==========================================================================
   5. מסכים רחבים — הגיליון הופך לכרטיס ממורכז, הפס מתקצר
   ========================================================================== */
@media (min-width: 481px) {
    .ip-overlay {
        align-items: center;
        padding: 24px;
    }

    .ip-sheet {
        max-width: 420px;
        padding: 26px 26px 24px;
        transform: translateY(0) scale(0.97);
    }

    .ip-overlay.is-open .ip-sheet { transform: translateY(0) scale(1); }

    .ip-grip { display: none; }

    .ip-banner {
        inset-block-end: 18px;
        inset-inline-end: 18px;
        inset-inline-start: auto;
        margin: 0;
        width: min(400px, calc(100vw - 36px));
        border: 1px solid var(--ip-hairline);
        border-top: 3px solid var(--ip-accent);
    }

    .ip-banner:not(.is-open) { transform: translateY(140%); }
}

/* ==========================================================================
   6. מסכים צרים במיוחד (360px ומטה) — הכפתורים לא נחתכים
   ========================================================================== */
@media (max-width: 360px) {
    .ip-banner { padding: 14px 12px calc(14px + env(safe-area-inset-bottom, 0px)); }
    .ip-banner-row { padding-inline-start: 40px; gap: 10px; }
    .ip-banner-title { font-size: 1rem; }
    .ip-banner-sub { font-size: 0.84rem; }

    /* מתחת ל-360 אין מקום לשני כפתורים זה לצד זה בלי חיתוך.
       הראשי תופס שורה מלאה, ו"לא עכשיו" יורד מתחתיו ונשאר במרכז. */
    .ip-banner-actions { flex-direction: column; align-items: stretch; gap: 6px; }
    .ip-btn-primary { width: 100%; font-size: 0.98rem; }
    .ip-btn-ghost { width: 100%; }

    .ip-sheet { padding: 18px 14px calc(18px + env(safe-area-inset-bottom, 0px)); }
    .ip-title { font-size: 1.1rem; }
    .ip-step-text { font-size: 0.92rem; }
}

/* ==========================================================================
   7. העדפות מערכת
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    .ip-banner,
    .ip-overlay,
    .ip-sheet,
    .ip-btn-primary { transition: none; }

    .ip-banner { transform: none; }
    .ip-banner:not(.is-open) { transform: none; display: none; }
    .ip-sheet { transform: none; }
    .ip-overlay.is-open .ip-sheet { transform: none; }
}

/* מצב ניגודיות גבוהה: מוסיפים מתאר לבן כדי שהמשטח לא ייבלע ברקע */
@media (prefers-contrast: more) {
    .ip-banner,
    .ip-sheet { border: 2px solid #FFFFFF; border-top: 3px solid var(--ip-accent); }
}

/* נעילת גלילת הרקע בזמן שהגיליון פתוח */
html.ip-locked,
body.ip-locked { overflow: hidden; }

/* ==========================================================================
   8. חגורת ביטחון — באפליקציה שכבר על מסך הבית לא מוצג כלום.
   ה-JS כבר לא מרנדר במצב הזה. זה הרובד השני, למקרה שקובץ ישן נשאר בקאש.
   ========================================================================== */
@media all and (display-mode: standalone) {
    .ip-banner,
    .ip-overlay { display: none !important; }
}

@media all and (display-mode: minimal-ui) {
    .ip-banner,
    .ip-overlay { display: none !important; }
}
