/* Mobile navigation + drawer + bottom bar */
/* Phase A UX Remediation Additions: header compact mode, burger visibility, scoped control hiding */
/* Implementation: dual gating (flag + media), desktop-safe defaults, namespaced tokens */

/* ------------------------------------------------------------------ */
/* 1. Desktop & flag-off SAFE DEFAULTS (nothing mobile-visible)        */
/* ------------------------------------------------------------------ */
.mobile-nav-toggle,
.mobile-drawer,
.mobile-drawer-backdrop,
.bottom-nav { display:none; }

/* Provide a minimal structural reset so elements don't shift layout if present */
.mobile-nav-toggle { font-size:0; line-height:1; background:transparent; border:0; padding:0; }
.mobile-nav-toggle svg { width:22px; height:22px; stroke:currentColor; }

/* ------------------------------------------------------------------ */
/* 2. Scoped MOBILE BEHAVIOR (requires viewport + body.mf-mobile-enabled) */
/*    All variables & overrides live inside this block to avoid bleed.  */
/* ------------------------------------------------------------------ */
@media (max-width:700px){
  body.mf-mobile-enabled {
    /* Tokens (namespaced) */
    --fm-burger-size: 42px;
    --fm-bottom-nav-height: 58px;
    --fm-drawer-width: 82%;
    --fm-drawer-bg: var(--color-surface-elevated, #1b1e23);
    --fm-drawer-text: #fff; /* forced contrast */
    --fm-bottom-nav-bg: var(--color-surface, #181b1f);
    --fm-bottom-nav-border: var(--color-border, #262a30);
    --fm-accent: var(--color-accent, #5aa2ff);
    --fm-focus-ring: var(--fm-accent);
    --fm-bottom-nav-inactive: var(--color-accent, #fc4902);
    --fm-bottom-nav-active: var(--color-text-primary, #fff);
  }

  /* Reserve space only when mobile flag active */
  body.mf-mobile-enabled { padding-bottom: var(--fm-bottom-nav-height); }

  /* Burger button (visible only under flag) */
  body.mf-mobile-enabled .mobile-nav-toggle { display:inline-flex; appearance:none; border:0; background:transparent; padding:8px; margin:0; align-items:center; justify-content:center; border-radius:10px; color:var(--fm-drawer-text); line-height:1; -webkit-tap-highlight-color:transparent; width:var(--fm-burger-size); height:var(--fm-burger-size); position:relative; z-index:1100; background:rgba(255,255,255,0.15); backdrop-filter:blur(4px); }
  body.mf-mobile-enabled .mobile-nav-toggle:focus-visible { outline:2px solid var(--fm-focus-ring); outline-offset:2px; }
  body.mf-mobile-enabled .mobile-nav-toggle .icon-bars { position:relative; width:26px; height:18px; display:block; }
  body.mf-mobile-enabled .mobile-nav-toggle .icon-bars::before,
  body.mf-mobile-enabled .mobile-nav-toggle .icon-bars::after,
  body.mf-mobile-enabled .mobile-nav-toggle .icon-bars span {
    content:""; position:absolute; left:0; width:100%; height:2px; background:currentColor; border-radius:2px; transition:transform .32s cubic-bezier(.4,0,.2,1), opacity .25s ease; will-change:transform;
  }
  body.mf-mobile-enabled .mobile-nav-toggle .icon-bars::before { top:0; }
  body.mf-mobile-enabled .mobile-nav-toggle .icon-bars span { top:8px; }
  body.mf-mobile-enabled .mobile-nav-toggle .icon-bars::after { bottom:0; }
  body.mf-mobile-enabled .mobile-nav-toggle[aria-expanded="true"] .icon-bars::before { transform:translateY(8px) rotate(45deg); }
  body.mf-mobile-enabled .mobile-nav-toggle[aria-expanded="true"] .icon-bars::after { transform:translateY(-8px) rotate(-45deg); }
  body.mf-mobile-enabled .mobile-nav-toggle[aria-expanded="true"] .icon-bars span { opacity:0; }

  /* Drawer */
  body.mf-mobile-enabled .mobile-drawer { display:flex; position:fixed; top:0; left:0; height:100dvh; width:var(--fm-drawer-width); background:rgba(27,30,35,0.78); color:var(--fm-drawer-text); padding:20px 18px 36px; box-shadow:0 6px 24px -4px rgba(0,0,0,.55); transform:translateX(-105%); transition:transform .38s cubic-bezier(.4,0,.2,1); flex-direction:column; gap:22px; overflow-y:auto; z-index:1000; overscroll-behavior:contain; border-right:1px solid rgba(255,255,255,0.08); backdrop-filter:blur(14px) saturate(1.25); -webkit-backdrop-filter:blur(14px) saturate(1.25); }
  body.mf-mobile-enabled .mobile-drawer[aria-hidden="false"] { transform:translateX(0); }
  body.mf-mobile-enabled.drawer-open { touch-action:none; }
  body.mf-mobile-enabled.drawer-open, body.mf-mobile-enabled.drawer-open html { overscroll-behavior:none; }

  body.mf-mobile-enabled .mobile-drawer__section-title { font-size:.70rem; font-weight:600; text-transform:uppercase; letter-spacing:.09em; opacity:.75; margin:0 0 6px; }
  body.mf-mobile-enabled .mobile-drawer .drawer-block { background:rgba(255,255,255,0.04); border:1px solid rgba(255,255,255,0.08); border-radius:12px; padding:12px 14px 14px; display:flex; flex-direction:column; gap:10px; }
  body.mf-mobile-enabled .mobile-drawer a,
  body.mf-mobile-enabled .mobile-drawer button,
  body.mf-mobile-enabled .mobile-drawer label { color:var(--fm-drawer-text); }
  body.mf-mobile-enabled .mobile-drawer button:not(.unstyled):focus-visible,
  body.mf-mobile-enabled .drawer-filter-chips button:focus-visible { outline:2px solid var(--fm-focus-ring); outline-offset:2px; }

  /* Backdrop */
  body.mf-mobile-enabled .mobile-drawer-backdrop { display:block; position:fixed; inset:0; background:rgba(0,0,0,.50); opacity:0; pointer-events:none; transition:opacity .28s ease; z-index:999; }
  body.mf-mobile-enabled .mobile-drawer-backdrop[data-active="true"] { opacity:1; pointer-events:auto; }

  /* Scoped hiding (unchanged logic) */
  body.mf-mobile-enabled:not([data-keep-inline-controls='1']) .filters,
  body.mf-mobile-enabled:not([data-keep-inline-controls='1']) .filters-bar,
  body.mf-mobile-enabled:not([data-keep-inline-controls='1']) .filter-panel,
  body.mf-mobile-enabled:not([data-keep-inline-controls='1']) .quick-filters,
  body.mf-mobile-enabled:not([data-keep-inline-controls='1']) .view-options,
  body.mf-mobile-enabled:not([data-keep-inline-controls='1']) .sort-controls,
  body.mf-mobile-enabled:not([data-keep-inline-controls='1']) .sort-control,
  body.mf-mobile-enabled:not([data-keep-inline-controls='1']) .sort { display:none !important; }

  /* Compact header layout */
  body.mf-mobile-enabled .header { flex-wrap:wrap; }
  body.mf-mobile-enabled .header-container { flex:1 1 100%; order:2; }
  body.mf-mobile-enabled .header-left { flex:1 1 auto; min-width:0; }
  body.mf-mobile-enabled .header-right { flex:1 1 100%; display:flex; gap:8px; align-items:center; justify-content:space-between; margin-top:6px; }
  body.mf-mobile-enabled .header-search { flex:1 1 auto; min-width:0; }
  body.mf-mobile-enabled .logo, body.mf-mobile-enabled .logo a, body.mf-mobile-enabled .logo-link { display:flex; align-items:center; }

  /* Bottom nav */
  body.mf-mobile-enabled .bottom-nav { display:flex; position:fixed; left:0; right:0; bottom:0; height:var(--fm-bottom-nav-height); background:var(--fm-bottom-nav-bg); border-top:1px solid var(--fm-bottom-nav-border); justify-content:space-around; align-items:center; padding:0 env(safe-area-inset-right) calc(env(safe-area-inset-bottom)); z-index:900; }
  body.mf-mobile-enabled .bottom-nav a { flex:1; text-align:center; text-decoration:none; font-size:.82rem; display:flex; flex-direction:column; align-items:center; gap:4px; padding:6px 0 4px; font-weight:500; color: var(--fm-bottom-nav-inactive); }
  body.mf-mobile-enabled .bottom-nav a[data-active='true'] { font-weight:600; color: var(--fm-bottom-nav-active); }
  body.mf-mobile-enabled .bottom-nav a .bn-icon { width:20px; height:20px; stroke:currentColor; display:inline-block; }

  /* Inline single-row controls */
  body.mf-mobile-enabled .mobile-inline-controls,
  body.mf-mobile-enabled .media-toolbar,
  body.mf-mobile-enabled .listing-controls,
  body.mf-mobile-enabled .controls-row { display:flex; flex-wrap:nowrap!important; align-items:center; gap:10px; overflow-x:auto; -webkit-overflow-scrolling:touch; scrollbar-width:none; padding:0 4px 8px; }
  body.mf-mobile-enabled .mobile-inline-controls::-webkit-scrollbar,
  body.mf-mobile-enabled .media-toolbar::-webkit-scrollbar,
  body.mf-mobile-enabled .listing-controls::-webkit-scrollbar,
  body.mf-mobile-enabled .controls-row::-webkit-scrollbar { display:none; }
  body.mf-mobile-enabled .view-options,
  body.mf-mobile-enabled .pagination,
  body.mf-mobile-enabled .page-controls,
  body.mf-mobile-enabled .sort-control { display:flex; flex-wrap:nowrap!important; align-items:center; gap:8px; flex:0 0 auto; }
  body.mf-mobile-enabled .view-options > *,
  body.mf-mobile-enabled .pagination > *,
  body.mf-mobile-enabled .sort-control > * { flex:0 0 auto; }

  /* Drawer filter chips */
  body.mf-mobile-enabled .drawer-filter-chips { display:flex; flex-wrap:wrap; gap:8px; }
  body.mf-mobile-enabled .drawer-filter-chips button { background:rgba(255,255,255,0.06); color:var(--fm-drawer-text); border:1px solid rgba(255,255,255,0.15); padding:6px 14px; font-size:.75rem; border-radius:20px; cursor:pointer; line-height:1.15; transition:background .18s,border-color .18s; }
  body.mf-mobile-enabled .drawer-filter-chips button[aria-pressed="true"] { background:var(--fm-accent); border-color:var(--fm-accent); color:#fff; }
  body.mf-mobile-enabled .drawer-filter-extra-group { display:flex; flex-direction:column; gap:6px; }
  body.mf-mobile-enabled .drawer-filter-extra-group details { background:rgba(255,255,255,0.04); border:1px solid rgba(255,255,255,0.08); border-radius:8px; padding:6px 10px; }
  body.mf-mobile-enabled .drawer-filter-extra-group summary { cursor:pointer; font-size:.72rem; letter-spacing:.05em; text-transform:uppercase; opacity:.8; list-style:none; }
  body.mf-mobile-enabled .drawer-filter-extra-group summary::-webkit-details-marker { display:none; }

  /* Drawer content-type tabs */
  body.mf-mobile-enabled .drawer-content-type-tabs { display:flex; gap:10px; flex-wrap:wrap; }
  body.mf-mobile-enabled .drawer-content-type-tabs .content-type-tab { background:rgba(255,255,255,0.08); border:1px solid rgba(255,255,255,0.15); color:var(--fm-drawer-text); padding:8px 12px; border-radius:14px; font-size:.72rem; display:flex; align-items:center; gap:6px; cursor:pointer; line-height:1.1; }
  body.mf-mobile-enabled .drawer-content-type-tabs .content-type-tab.active { background:var(--fm-accent); border-color:var(--fm-accent); color:#fff; }
  body.mf-mobile-enabled .drawer-content-type-tabs .content-type-tab i { font-size:.85rem; }

  /* Motion reduction */
  @media (prefers-reduced-motion:reduce){
    body.mf-mobile-enabled .mobile-drawer,
    body.mf-mobile-enabled .mobile-nav-toggle .icon-bars::before,
    body.mf-mobile-enabled .mobile-nav-toggle .icon-bars::after,
    body.mf-mobile-enabled .mobile-nav-toggle .icon-bars span { transition:none!important; }
  }
}


@media (min-width:701px){
  .bottom-nav, .mobile-drawer, .mobile-drawer-backdrop { display:none!important; }
}
