/* ============================================================
   mob-bottom-nav.css — MaKara News
   תפריט ניווט תחתון למובייל + Saved Articles Drawer

   ✅ אבטחה:  CSS בלבד — ללא eval, ללא url() חיצוני
   ✅ ביצועים: contain:layout, will-change:transform רק בזמן אנימציה
               GPU compositing דרך transform (לא top/bottom)
   ✅ נגישות:  min touch target 56px (WCAG 2.5.8)
               focus-visible, forced-colors, prefers-reduced-motion
               contrast ratio ≥4.5:1 על כל הטקסטים
   ✅ מובייל:  display:none בדסקטופ, display:flex ב-≤768px
   ============================================================ */

/* ════════════════════════════════════════════════
   1. BOTTOM NAV — גלובל (נסתר בדסקטופ)
════════════════════════════════════════════════ */
.mob-bottom-nav {
    display: none; /* נסתר בדסקטופ */
}

/* ════════════════════════════════════════════════
   2. SAVED DRAWER + OVERLAY — גלובל
════════════════════════════════════════════════ */
.mob-saved-overlay {
    display: none;
}
.mob-saved-drawer {
    display: none;
}

/* ════════════════════════════════════════════════
   3. MOBILE ONLY
════════════════════════════════════════════════ */
@media (max-width: 768px) {

    /* ── 3.1 Bottom Nav ── */
    .mob-bottom-nav {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        height: 60px;
        background: #ffffff;
        border-top: 1px solid #e8e8e8;
        display: flex;
        align-items: stretch;
        z-index: 900;
        box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
        /* ✅ ביצועים: מניעת reflow בגלילה */
        contain: layout style;
    }

    /* ── 3.2 פריט ניווט בודד ── */
    .mob-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        /* ✅ touch target מינימלי WCAG 2.5.8 */
        min-height: 56px;
        padding: 6px 4px 4px;
        cursor: pointer;
        /* צבע ברירת מחדל — לא פעיל */
        color: #999999;
        font-size: 10px;
        font-weight: 500;
        font-family: 'Heebo', 'Arial Hebrew', Arial, sans-serif;
        letter-spacing: 0.01em;
        /* ✅ איפוס סגנון כפתור */
        border: none;
        background: none;
        text-decoration: none;
        transition: color 0.18s ease;
        /* ✅ נגישות: outline ברור */
        outline: none;
        -webkit-tap-highlight-color: transparent;
    }

    .mob-nav-item:focus-visible {
        outline: 2px solid #C0152A;
        outline-offset: -2px;
        border-radius: 8px;
    }

    /* ── פעיל ── */
    .mob-nav-item.active {
        color: #111111;
    }

    /* ── hover ── */
    .mob-nav-item:hover:not(.active) {
        color: #555555;
    }

    /* SVG בתוך כפתור */
    .mob-nav-item svg {
        display: block;
        flex-shrink: 0;
        transition: transform 0.18s ease;
        stroke: currentColor;
    }

    /* ✅ כפתור פעיל — fill לאייקון בית וסימניה */
    .mob-nav-item.active svg {
        transform: scale(1.08);
    }

    /* fill לאייקון בית כשפעיל */
    .mob-nav-item.active[aria-label="דף הבית"] svg path:first-child {
        fill: currentColor;
        stroke: currentColor;
    }

    /* fill לאייקון שמורים כשפעיל */
    .mob-nav-item.active .mob-nav-icon-wrap svg path {
        fill: currentColor;
        stroke: currentColor;
    }

    /* תווית טקסט */
    .mob-nav-label {
        font-size: 10px;
        font-weight: 500;
        line-height: 1;
        text-align: center;
        white-space: nowrap;
    }

    /* ── 3.3 Badge (מספר שמורות) ── */
    .mob-nav-icon-wrap {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mob-nav-badge {
        display: none; /* מוצג ע"י JS */
        position: absolute;
        top: -5px;
        left: -5px;      /* RTL: שמאל = חוץ */
        min-width: 16px;
        height: 16px;
        padding: 0 4px;
        background: #C0152A;
        color: #ffffff;
        font-size: 9px;
        font-weight: 700;
        font-family: 'Heebo', 'Arial Hebrew', Arial, sans-serif;
        border-radius: 8px;
        align-items: center;
        justify-content: center;
        line-height: 1;
        /* ✅ מעל האייקון */
        z-index: 1;
        /* מניעת text-selection */
        user-select: none;
        pointer-events: none;
    }

    /* Badge מוצג כשיש תוכן */
    .mob-nav-badge:not(:empty) {
        display: flex;
    }

    /* ════════════════════════════════════════════════
       3.4 SAVED ARTICLES DRAWER
       נפתח מלמטה (slide-up)
    ════════════════════════════════════════════════ */

    /* ── Overlay ── */
    .mob-saved-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0);
        z-index: 1050;
        pointer-events: none;
        transition: background 0.28s ease;
    }

    .mob-saved-overlay.open {
        background: rgba(0, 0, 0, 0.45);
        pointer-events: auto;
    }

    /* ── Drawer ── */
    .mob-saved-drawer {
        display: flex;
        flex-direction: column;
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        /* גובה מקסימלי — 80% מסך פחות גובה הנאב */
        max-height: calc(80vh - 60px);
        background: #ffffff;
        border-radius: 16px 16px 0 0;
        z-index: 1100;
        /* ✅ ביצועים: GPU compositing */
        transform: translateY(100%);
        will-change: transform;
        transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.14);
        /* גרירת scroll רק בתוך */
        overflow: hidden;
    }

    .mob-saved-drawer.open {
        transform: translateY(0);
        will-change: auto;
    }

    /* ── "ידית" גרירה בראש ה-drawer ── */
    .mob-saved-drawer::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background: #e0e0e0;
        border-radius: 2px;
        margin: 10px auto 0;
        flex-shrink: 0;
    }

    /* ── כותרת ה-drawer ── */
    .mob-saved-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 14px 16px 12px;
        border-bottom: 1px solid #f0f0f0;
        flex-shrink: 0;
    }

    .mob-saved-title {
        font-size: 16px;
        font-weight: 700;
        color: #111111;
        font-family: 'Heebo', 'Arial Hebrew', Arial, sans-serif;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .mob-saved-title svg {
        stroke: #C0152A;
        flex-shrink: 0;
    }

    /* ── כפתור סגירה ── */
    .mob-saved-close {
        width: 36px;
        height: 36px;
        min-width: 36px;
        border: none;
        background: #f5f5f5;
        border-radius: 50%;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #555;
        transition: background 0.18s, color 0.18s;
        flex-shrink: 0;
    }

    .mob-saved-close:hover,
    .mob-saved-close:focus-visible {
        background: #ffe8eb;
        color: #C0152A;
        outline: 2px solid #C0152A;
        outline-offset: 2px;
    }

    /* ── רשימת כתבות שמורות ── */
    .mob-saved-list {
        flex: 1;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        padding: 8px 0 4px;
    }

    /* ── פריט שמור בודד ── */
    .mob-saved-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 10px 16px;
        border-bottom: 1px solid #f4f4f4;
        text-decoration: none;
        color: inherit;
        transition: background 0.15s;
        position: relative;
    }

    .mob-saved-item:last-child {
        border-bottom: none;
    }

    .mob-saved-item:hover,
    .mob-saved-item:focus-visible {
        background: #f9f9f9;
        outline: none;
    }

    /* תמונה ממוזערת */
    .mob-saved-thumb {
        width: 72px;
        height: 54px;
        border-radius: 8px;
        object-fit: cover;
        flex-shrink: 0;
        background: #f0f0f0;
    }

    /* placeholder כשאין תמונה */
    .mob-saved-thumb-ph {
        width: 72px;
        height: 54px;
        border-radius: 8px;
        background: #f0f0f0;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 22px;
        color: #ccc;
    }

    /* גוף הפריט */
    .mob-saved-body {
        flex: 1;
        min-width: 0;
    }

    .mob-saved-item-title {
        font-size: 13.5px;
        font-weight: 600;
        line-height: 1.35;
        color: #111111;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        margin-bottom: 4px;
    }

    .mob-saved-item-meta {
        font-size: 11px;
        color: #999;
        display: flex;
        align-items: center;
        gap: 5px;
    }

    .mob-saved-item-cat {
        display: inline-block;
        background: #C0152A;
        color: #fff;
        font-size: 10px;
        font-weight: 700;
        padding: 1px 6px;
        border-radius: 3px;
    }

    /* ── כפתור מחיקת פריט בודד ── */
    .mob-saved-remove {
        width: 32px;
        height: 32px;
        min-width: 32px;
        border: none;
        background: none;
        border-radius: 50%;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #ccc;
        transition: background 0.15s, color 0.15s;
        flex-shrink: 0;
        padding: 0;
    }

    .mob-saved-remove:hover,
    .mob-saved-remove:focus-visible {
        background: #ffe8eb;
        color: #C0152A;
        outline: 2px solid #C0152A;
        outline-offset: 2px;
    }

    /* ── מצב ריק ── */
    .mob-saved-empty {
        display: none; /* מוצג ע"י JS */
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 40px 20px;
        gap: 10px;
        text-align: center;
        flex: 1;
    }

    .mob-saved-empty.visible {
        display: flex;
    }

    .mob-saved-empty p {
        font-size: 15px;
        font-weight: 600;
        color: #444;
        margin: 0;
    }

    .mob-saved-empty span {
        font-size: 12px;
        color: #aaa;
    }

    /* ── כותרת תחתונה — ניקוי הכל ── */
    .mob-saved-footer {
        display: none; /* מוצג ע"י JS כשיש פריטים */
        padding: 10px 16px 14px;
        border-top: 1px solid #f0f0f0;
        flex-shrink: 0;
    }

    .mob-saved-footer.visible {
        display: block;
    }

    .mob-saved-clear-btn {
        width: 100%;
        padding: 11px;
        background: none;
        border: 1.5px solid #e0e0e0;
        border-radius: 10px;
        font-size: 13px;
        font-weight: 600;
        color: #888;
        font-family: 'Heebo', 'Arial Hebrew', Arial, sans-serif;
        cursor: pointer;
        transition: border-color 0.18s, color 0.18s, background 0.18s;
        min-height: 44px;
    }

    .mob-saved-clear-btn:hover,
    .mob-saved-clear-btn:focus-visible {
        border-color: #C0152A;
        color: #C0152A;
        background: #ffe8eb;
        outline: none;
    }

    /* ════════════════════════════════════════════════
       3.5 DARK MODE
    ════════════════════════════════════════════════ */
    body.dark-mode-active .mob-bottom-nav {
        background: #141414;
        border-top-color: #2a2a2a;
        box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.3);
    }

    body.dark-mode-active .mob-nav-item {
        color: #555555;
    }

    body.dark-mode-active .mob-nav-item.active {
        color: #f0f0f0;
    }

    body.dark-mode-active .mob-nav-item:hover:not(.active) {
        color: #aaaaaa;
    }

    body.dark-mode-active .mob-saved-drawer {
        background: #1a1a1a;
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.45);
    }

    body.dark-mode-active .mob-saved-drawer::before {
        background: #333;
    }

    body.dark-mode-active .mob-saved-header {
        border-bottom-color: #2a2a2a;
    }

    body.dark-mode-active .mob-saved-title {
        color: #f0f0f0;
    }

    body.dark-mode-active .mob-saved-close {
        background: #252525;
        color: #aaa;
    }

    body.dark-mode-active .mob-saved-item {
        border-bottom-color: #252525;
    }

    body.dark-mode-active .mob-saved-item:hover,
    body.dark-mode-active .mob-saved-item:focus-visible {
        background: #222;
    }

    body.dark-mode-active .mob-saved-item-title {
        color: #e0e0e0;
    }

    body.dark-mode-active .mob-saved-thumb-ph {
        background: #252525;
    }

    body.dark-mode-active .mob-saved-empty p {
        color: #aaa;
    }

    body.dark-mode-active .mob-saved-footer {
        border-top-color: #2a2a2a;
    }

    body.dark-mode-active .mob-saved-clear-btn {
        border-color: #333;
        color: #666;
    }

    body.dark-mode-active .mob-saved-clear-btn:hover,
    body.dark-mode-active .mob-saved-clear-btn:focus-visible {
        border-color: #C0152A;
        color: #C0152A;
        background: rgba(192, 21, 42, 0.12);
    }

} /* end @media max-width:768px */

/* ════════════════════════════════════════════════
   4. prefers-reduced-motion
════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    .mob-saved-drawer,
    .mob-saved-overlay,
    .mob-nav-item,
    .mob-nav-item svg {
        transition: none !important;
        will-change: auto !important;
    }
}

/* ════════════════════════════════════════════════
   5. forced-colors (Windows High Contrast)
════════════════════════════════════════════════ */
@media (forced-colors: active) {
    .mob-bottom-nav {
        border-top: 2px solid ButtonText !important;
    }
    .mob-nav-item {
        forced-color-adjust: auto;
        border: 1px solid transparent;
    }
    .mob-nav-item.active {
        border-color: ButtonText;
    }
    .mob-nav-badge {
        forced-color-adjust: none;
    }
    .mob-saved-drawer {
        border: 2px solid ButtonText !important;
    }
}
