/* ═══════════════════════════════════════════════════════════════
   مفضلاتي — الطبقة 2: الأساس
   الخطوط، إعادة الضبط، الطباعة العربية، التركيز، الوصول، الطباعة الورقية.
   ═══════════════════════════════════════════════════════════════ */

@layer base {
    /* ── الخطوط (محلية بالكامل — بلا أي طلب خارجي) ─────────────── */
    @font-face {
        font-family: "IBM Plex Sans Arabic";
        font-style: normal;
        font-weight: 400;
        font-display: swap;
        src: url("../fonts/plex-arabic-400.woff2") format("woff2");
        unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200E, U+2010-2011, U+204F, U+FB50-FDFF, U+FE70-FEFF;
    }
    @font-face {
        font-family: "IBM Plex Sans Arabic";
        font-style: normal;
        font-weight: 400;
        font-display: swap;
        src: url("../fonts/plex-latin-400.woff2") format("woff2");
        unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
    }
    @font-face {
        font-family: "IBM Plex Sans Arabic";
        font-style: normal;
        font-weight: 600;
        font-display: swap;
        src: url("../fonts/plex-arabic-600.woff2") format("woff2");
        unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200E, U+2010-2011, U+204F, U+FB50-FDFF, U+FE70-FEFF;
    }
    @font-face {
        font-family: "IBM Plex Sans Arabic";
        font-style: normal;
        font-weight: 600;
        font-display: swap;
        src: url("../fonts/plex-latin-600.woff2") format("woff2");
        unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
    }

    /* ── إعادة الضبط ──────────────────────────────────────────── */
    *,
    *::before,
    *::after {
        box-sizing: border-box;
    }

    * {
        margin: 0;
        padding: 0;
    }

    html {
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    body {
        min-height: 100dvh;
        background: var(--bg);
        color: var(--text);
        font-family: var(--font);
        font-size: var(--fs-base);
        line-height: var(--lh-body);
        /* لا letter-spacing مطلقاً: يفكّ اتصال الحروف العربية */
        text-rendering: optimizeLegibility;
        -webkit-font-smoothing: antialiased;
    }

    h1, h2, h3, h4 {
        font-weight: 600;
        line-height: var(--lh-tight);
        text-wrap: balance;
    }

    h1 { font-size: var(--fs-lg); }
    h2 { font-size: var(--fs-md); }
    h3 { font-size: var(--fs-base); }

    a {
        color: var(--accent);
        text-decoration: none;
    }

    a:hover {
        color: var(--accent-hover);
    }

    img, svg {
        display: block;
        max-width: 100%;
    }

    button, input, select, textarea {
        font: inherit;
        color: inherit;
    }

    button {
        background: none;
        border: 0;
        cursor: pointer;
    }

    ul, ol {
        list-style: none;
    }

    table {
        border-collapse: collapse;
        border-spacing: 0;
    }

    pre, code {
        font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
        font-size: 0.8125rem;
    }

    /* ── التركيز: واضح دائماً، وبلا حركة ──────────────────────── */
    :focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
        border-radius: var(--r-xs);
    }

    :focus:not(:focus-visible) {
        outline: none;
    }

    ::selection {
        background: var(--accent-soft);
        color: var(--text);
    }

    ::placeholder {
        color: var(--text-faint);
        opacity: 1;
    }

    /* ── شريط التمرير ─────────────────────────────────────────── */
    ::-webkit-scrollbar {
        width: 10px;
        height: 10px;
    }

    ::-webkit-scrollbar-track {
        background: transparent;
    }

    ::-webkit-scrollbar-thumb {
        background: var(--border-strong);
        border: 3px solid var(--bg);
        border-radius: var(--r-full);
    }

    ::-webkit-scrollbar-thumb:hover {
        background: var(--text-faint);
    }

    /* ── الوصول: مخفي بصرياً ومتاح لقارئات الشاشة ─────────────── */
    .sr-only {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
        border: 0;
    }

    .skip {
        position: absolute;
        inset-inline-start: var(--s-4);
        inset-block-start: -100px;
        z-index: 100;
        padding: var(--s-2) var(--s-4);
        background: var(--solid);
        color: var(--on-solid);
        border-radius: var(--r-sm);
        font-weight: 600;
        transition: inset-block-start var(--d-2) var(--ease);
    }

    .skip:focus {
        inset-block-start: var(--s-4);
        color: var(--on-solid);
    }

    /* ── احترام تفضيل تقليل الحركة ────────────────────────────── */
    @media (prefers-reduced-motion: reduce) {
        *,
        *::before,
        *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
            scroll-behavior: auto !important;
        }
    }

    /* ── الطباعة ──────────────────────────────────────────────── */
    @media print {
        body {
            background: #fff;
            color: #000;
        }

        .rail,
        .toolbar,
        .app__foot,
        .toasts,
        .iconbtn,
        .btn,
        .skip {
            display: none !important;
        }

        .card {
            break-inside: avoid;
            box-shadow: none !important;
        }
    }
}
