/* =====================================================================
   DYNAMIC MOBILE ARCHITECTURES — css/skins/_dynamic_mobile.css
   إبراز الفروق الهيكلية الفعلية بين الهياكل الـ 8 على شاشات الهاتف والتابلت
   ===================================================================== */

@media (max-width: 1080px) {

    /* ضبط مشترك لعدم قصّ القوائم المنبثقة داخل الأشرطة القابلة للتمرير */
    .dyn-pop-menu {
        max-width: calc(100vw - 24px);
    }

    /* =================================================================
       1) COMMAND_DOCK (clay, aurora, lavender, rose_blush, sky_mist)
          شريط تطبيقات سفلي عائم مثبّت (Native App Bottom Dock)
       ================================================================= */
    html[data-shell="command_dock"] body {
        padding-bottom: 94px !important;
    }
    html[data-shell="command_dock"] .dyn-island {
        margin: 8px 10px 6px !important;
        width: calc(100% - 20px) !important;
        border-radius: 20px !important;
    }
    html[data-shell="command_dock"] .dyn-dock {
        display: flex !important;
        position: fixed !important;
        bottom: 10px !important;
        left: 10px !important;
        right: 10px !important;
        top: auto !important;
        transform: none !important;
        width: auto !important;
        max-width: none !important;
        padding: 6px !important;
        gap: 4px !important;
        border-radius: 22px !important;
        justify-content: flex-start !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        z-index: 950 !important;
    }
    html[data-shell="command_dock"] .dyn-dock::-webkit-scrollbar {
        display: none;
    }
    html[data-shell="command_dock"] .dyn-dock-tile {
        flex: 1 0 64px !important;
        min-width: 64px !important;
        padding: 6px 6px !important;
        border-radius: 16px !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 2px !important;
    }
    html[data-shell="command_dock"] .dyn-dock-ic {
        font-size: 1.15rem !important;
        line-height: 1 !important;
    }
    html[data-shell="command_dock"] .dyn-dock-lbl {
        display: block !important;
        font-size: 0.65rem !important;
        font-weight: 800;
        max-width: 72px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    html[data-shell="command_dock"] .dyn-dock-group .dyn-dock-up {
        position: fixed !important;
        bottom: 84px !important;
        top: auto !important;
        left: 12px !important;
        right: 12px !important;
        width: auto !important;
        min-width: 0 !important;
        max-height: 54vh !important;
        overflow-y: auto !important;
        transform: none !important;
        border-radius: 22px !important;
        z-index: 1250 !important;
    }

    /* =================================================================
       2) BENTO_HUB (bento_studio)
          هيدر Bento مؤطّر + إبقاء زر Mega-Board وشريط الروابط + بطاقات أفقية
       ================================================================= */
    html[data-shell="bento_hub"] .dyn-bento-bar {
        flex-wrap: wrap;
        padding: 8px 10px;
        border-radius: 20px;
        gap: 8px;
    }
    html[data-shell="bento_hub"] .dyn-bento-board-btn {
        display: inline-flex !important;
        padding: 7px 10px;
        font-size: 0.78rem;
        border-radius: 12px;
    }
    html[data-shell="bento_hub"] .dyn-bento-pills {
        display: flex !important;
        order: 3;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 4px;
        border-radius: 14px;
    }
    html[data-shell="bento_hub"] .dyn-bento-pills::-webkit-scrollbar {
        display: none;
    }
    html[data-shell="bento_hub"] .dyn-bento-pill {
        flex: 0 0 auto;
        padding: 6px 11px;
        font-size: 0.78rem;
    }
    html[data-shell="bento_hub"] .dyn-bento-overlay {
        padding: 16px 10px 24px;
        align-items: center;
    }
    html[data-shell="bento_hub"] .dyn-bento-board {
        padding: 16px;
        border-radius: 22px;
        max-height: 86vh;
        overflow-y: auto;
    }
    html[data-shell="bento_hub"] .dyn-bento-board-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    /* =================================================================
       3) SPLIT_COMMAND (obsidian_deck)
          إبقاء زر Command Palette + شريط التبويبات الأفقي ظاهراً على الهاتف
       ================================================================= */
    html[data-shell="split_command"] .dyn-cmd-top {
        gap: 8px;
        min-height: 50px;
    }
    html[data-shell="split_command"] .dyn-cmd-trigger {
        display: inline-flex !important;
        flex: 0 0 auto;
        width: 36px;
        height: 36px;
        padding: 0;
        justify-content: center;
        border-radius: 8px;
    }
    html[data-shell="split_command"] .dyn-cmd-trigger > span:first-child > span,
    html[data-shell="split_command"] .dyn-cmd-trigger .dyn-cmd-kbd {
        display: none;
    }
    html[data-shell="split_command"] .dyn-cmd-ribbon {
        display: block !important;
    }
    html[data-shell="split_command"] .dyn-cmd-ribbon-inner {
        padding-block: 5px;
    }
    html[data-shell="split_command"] .dyn-cmd-tab {
        padding: 5px 10px;
        font-size: 0.77rem;
    }
    html[data-shell="split_command"] .dyn-palette-overlay {
        padding: 12px 10px;
        align-items: flex-start;
    }

    /* =================================================================
       4) EDITORIAL_FOLIO (atelier_luxe)
          ترويسة مجلة متمركزة + إبقاء شريط التنقل السفلي التحريري على الهاتف
       ================================================================= */
    html[data-shell="editorial_folio"] .dyn-folio-masthead {
        padding: 14px 0 12px;
        text-align: center;
    }
    html[data-shell="editorial_folio"] .dyn-folio-masthead .container {
        display: grid;
        grid-template-columns: 38px 1fr 38px;
        align-items: center;
    }
    html[data-shell="editorial_folio"] .dyn-folio-brand {
        grid-column: 2;
        justify-self: center;
        gap: 8px;
    }
    html[data-shell="editorial_folio"] .dyn-folio-masthead .dyn-hamburger {
        grid-column: 3;
        justify-self: end;
    }
    html[data-shell="editorial_folio"] .dyn-folio-wordmark {
        font-size: 1.28rem;
    }
    html[data-shell="editorial_folio"] .dyn-folio-nav-bar {
        display: block !important;
    }
    html[data-shell="editorial_folio"] .dyn-folio-nav {
        flex-wrap: nowrap;
        justify-content: flex-start;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        min-height: 42px;
        gap: 2px;
    }
    html[data-shell="editorial_folio"] .dyn-folio-nav::-webkit-scrollbar {
        display: none;
    }
    html[data-shell="editorial_folio"] .dyn-folio-link {
        white-space: nowrap;
        padding: 10px 12px;
        font-size: 0.82rem;
    }
    html[data-shell="editorial_folio"] .dyn-folio-nav .dyn-pop-menu {
        position: fixed !important;
        left: 12px !important;
        right: 12px !important;
        top: auto !important;
        width: auto !important;
        max-height: 55vh;
        overflow-y: auto;
        z-index: 1250;
    }

    /* =================================================================
       5) RAIL_DRAWER (crimson, emerald, velvet_amethyst, velvet_onyx)
          تحويل قائمة الهاتف إلى Bottom Sheet منبثقة من الأسفل
       ================================================================= */
    html[data-shell="rail_drawer"] .dyn-rail-top {
        border-bottom: 2px solid var(--primary) !important;
    }
    html[data-shell="rail_drawer"] .mobile-nav-drawer {
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        inset-inline: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        max-height: 82vh !important;
        border-radius: 26px 26px 0 0 !important;
        border-top: 3px solid var(--primary) !important;
        transform: translateY(105%) !important;
        transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1) !important;
    }
    html[data-shell="rail_drawer"] .mobile-nav-drawer::before {
        content: "";
        display: block;
        width: 44px;
        height: 5px;
        border-radius: 999px;
        background: var(--border);
        margin: 10px auto 2px;
        flex-shrink: 0;
    }
    html[data-shell="rail_drawer"] .mobile-nav-drawer.open {
        transform: translateY(0) !important;
    }

    /* =================================================================
       6) MEGA_PORTAL (executive, ocean, swiss)
          إبقاء الطابق الثاني كشريط بوابة قابل للتمرير على الهاتف
       ================================================================= */
    html[data-shell="mega_portal"] .dyn-portal-tier2 {
        display: block !important;
    }
    html[data-shell="mega_portal"] .dyn-portal-nav {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 4px;
    }
    html[data-shell="mega_portal"] .dyn-portal-nav::-webkit-scrollbar {
        display: none;
    }
    html[data-shell="mega_portal"] .dyn-portal-tab {
        white-space: nowrap;
        flex: 0 0 auto;
        padding: 9px 12px;
        font-size: 0.82rem;
    }
    html[data-shell="mega_portal"] .dyn-portal-nav .dyn-pop-menu {
        position: fixed !important;
        left: 12px !important;
        right: 12px !important;
        top: auto !important;
        width: auto !important;
        grid-template-columns: 1fr !important;
        max-height: 55vh;
        overflow-y: auto;
        z-index: 1250;
    }
}

/* =====================================================================
   تخطيط المحتوى والبطاقات على الهاتف (<= 768px) — هوية بصرية متباينة لكل هيكل
   ===================================================================== */
@media (max-width: 768px) {

    /* --- 1. BENTO_HUB: بطاقات منتجات أفقية دائماً + أقسام Bento بعمودين --- */
    html[data-shell="bento_hub"] .dyn-bh-main {
        padding: 20px 18px;
        border-radius: 20px;
    }
    html[data-shell="bento_hub"] .dyn-bh-metrics-row {
        gap: 10px;
    }
    html[data-shell="bento_hub"] .dyn-bh-metric-tile {
        padding: 12px 14px;
        border-radius: 18px;
    }
    html[data-shell="bento_hub"] .dyn-bh-metric-tile strong {
        font-size: 1.35rem;
    }
    html[data-shell="bento_hub"] .categories-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }
    html[data-shell="bento_hub"] .category-card {
        padding: 10px 12px !important;
        border-radius: 18px !important;
    }
    html[data-shell="bento_hub"] .products-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    html[data-shell="bento_hub"] .product-card {
        flex-direction: row !important;
        border-radius: 20px !important;
        align-items: stretch;
    }
    html[data-shell="bento_hub"] .product-thumb {
        width: 108px !important;
        min-width: 108px !important;
        height: auto !important;
        min-height: 124px !important;
        border-inline-end: 1px solid var(--border) !important;
        border-bottom: none !important;
    }
    html[data-shell="bento_hub"] .product-thumb .digital-tag {
        font-size: 0.62rem;
        padding: 2px 6px;
        top: 6px;
        inset-inline-start: 6px;
    }
    html[data-shell="bento_hub"] .product-body {
        padding: 10px 12px !important;
        gap: 5px;
    }
    html[data-shell="bento_hub"] .product-title {
        font-size: 0.9rem !important;
        line-height: 1.3;
    }
    html[data-shell="bento_hub"] .product-desc {
        font-size: 0.78rem !important;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    html[data-shell="bento_hub"] .product-footer {
        gap: 6px;
        flex-wrap: wrap;
    }
    html[data-shell="bento_hub"] .product-footer .btn {
        padding: 6px 11px !important;
        font-size: 0.76rem !important;
    }

    /* --- 2. SPLIT_COMMAND: كبسولات أفقية + شبكة منتجات 2 عمود عالية الكثافة --- */
    html[data-shell="split_command"] .dyn-cmd-hero-tools {
        width: 100%;
    }
    html[data-shell="split_command"] .dyn-cmd-hero-tools .search-box {
        width: 100%;
    }
    html[data-shell="split_command"] .products-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }
    html[data-shell="split_command"] .product-thumb {
        height: 96px !important;
    }
    html[data-shell="split_command"] .product-body {
        padding: 10px !important;
        gap: 6px;
    }
    html[data-shell="split_command"] .product-title {
        font-size: 0.84rem !important;
        line-height: 1.3;
    }
    html[data-shell="split_command"] .product-desc {
        display: none;
    }
    html[data-shell="split_command"] .product-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }
    html[data-shell="split_command"] .product-footer .btn {
        width: 100%;
        padding: 6px 8px !important;
        font-size: 0.76rem !important;
        text-align: center;
    }

    /* --- 3. EDITORIAL_FOLIO: فهرس أقسام مرقّم + بطاقات معرض Portrait فاخرة --- */
    html[data-shell="editorial_folio"] .categories-grid {
        grid-template-columns: 1fr !important;
    }
    html[data-shell="editorial_folio"] .category-card {
        padding: 13px 14px !important;
    }
    html[data-shell="editorial_folio"] .products-grid {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    html[data-shell="editorial_folio"] .product-thumb {
        height: 225px !important;
    }
    html[data-shell="editorial_folio"] .product-body {
        text-align: center;
        align-items: center;
        padding: 18px 16px !important;
    }
    html[data-shell="editorial_folio"] .product-footer {
        width: 100%;
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    html[data-shell="editorial_folio"] .product-footer .btn {
        width: 100%;
    }

    /* --- 4. COMMAND_DOCK: أيقونات تطبيقات 3 أعمدة + بطاقات منفوخة ناعمة --- */
    html[data-shell="command_dock"] .categories-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }
    html[data-shell="command_dock"] .category-card {
        flex-direction: column !important;
        text-align: center !important;
        padding: 12px 8px !important;
        border-radius: 20px !important;
        gap: 6px !important;
    }
    html[data-shell="command_dock"] .category-icon {
        width: 46px !important;
        height: 46px !important;
        border-radius: 15px !important;
    }
    html[data-shell="command_dock"] .category-name {
        font-size: 0.78rem !important;
    }
    html[data-shell="command_dock"] .category-meta {
        font-size: 0.68rem !important;
    }
    html[data-shell="command_dock"] .products-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    html[data-shell="command_dock"] .product-card {
        border-radius: 26px !important;
    }

    /* --- 5. RAIL_DRAWER (Velvet Family): بانرات أقسام + بطاقات VIP بحد ملوّن --- */
    html[data-shell="rail_drawer"] .categories-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    html[data-shell="rail_drawer"] .category-card {
        border-inline-start: 5px solid var(--primary) !important;
        padding: 13px 16px !important;
    }
    html[data-shell="rail_drawer"] .products-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    html[data-shell="rail_drawer"] .product-card {
        border-top: 3px solid var(--primary) !important;
    }

    /* --- 6. MEGA_PORTAL: أقسام كاروسيل أفقي (Amazon/Noon) + منتجات عمودين --- */
    html[data-shell="mega_portal"] .categories-grid {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        gap: 10px !important;
        padding-bottom: 6px;
        scrollbar-width: none;
    }
    html[data-shell="mega_portal"] .categories-grid::-webkit-scrollbar {
        display: none;
    }
    html[data-shell="mega_portal"] .category-card {
        flex: 0 0 148px !important;
        flex-direction: column !important;
        text-align: center !important;
        padding: 12px 10px !important;
        gap: 8px !important;
    }
    html[data-shell="mega_portal"] .products-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }
    html[data-shell="mega_portal"] .product-thumb {
        height: 112px !important;
    }
    html[data-shell="mega_portal"] .product-body {
        padding: 10px !important;
    }
    html[data-shell="mega_portal"] .product-title {
        font-size: 0.85rem !important;
    }
    html[data-shell="mega_portal"] .product-desc {
        display: none;
    }
    html[data-shell="mega_portal"] .product-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 7px;
    }
    html[data-shell="mega_portal"] .product-footer .btn {
        width: 100%;
        padding: 7px 8px !important;
        font-size: 0.78rem !important;
        text-align: center;
    }

    /* --- 7. APP_SIDEBAR (cyber, linear, clay_mint, slate_pro): عمودان مضغوطان --- */
    html[data-shell="app_sidebar"] .categories-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }
    html[data-shell="app_sidebar"] .products-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }
    html[data-shell="app_sidebar"] .product-thumb {
        height: 105px !important;
    }
    html[data-shell="app_sidebar"] .product-body {
        padding: 10px !important;
    }
    html[data-shell="app_sidebar"] .product-title {
        font-size: 0.84rem !important;
    }
    html[data-shell="app_sidebar"] .product-desc {
        display: none;
    }
    html[data-shell="app_sidebar"] .product-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }
    html[data-shell="app_sidebar"] .product-footer .btn {
        width: 100%;
        padding: 6px 8px !important;
        font-size: 0.76rem !important;
        text-align: center;
    }

    /* --- 8. CONSOLE_STRIP: شخصية خاصة لكل ثيم داخل نفس الهيكل --- */
    /* Terminal CLI: صفوف أوامر مدمجة بدون صور ضخمة */
    html[data-skin="terminal"] .products-grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }
    html[data-skin="terminal"] .product-card {
        flex-direction: row !important;
        align-items: center;
        border-radius: 4px !important;
    }
    html[data-skin="terminal"] .product-thumb {
        width: 68px !important;
        min-width: 68px !important;
        height: 68px !important;
        margin: 8px;
        border-radius: 4px;
    }
    html[data-skin="terminal"] .product-thumb .digital-tag {
        display: none;
    }
    html[data-skin="terminal"] .product-body {
        padding: 10px 10px 10px 4px !important;
    }
    html[data-skin="terminal"] .product-desc {
        display: none;
    }

    /* Sunset / Sand: بطاقات Brutalist سميكة الحواف بظل صلب */
    html[data-skin="sunset"] .product-card,
    html[data-skin="sunset"] .category-card,
    html[data-skin="sand"] .product-card,
    html[data-skin="sand"] .category-card {
        border: 2px solid var(--text) !important;
        box-shadow: 4px 4px 0 var(--text) !important;
    }
}