/*! ═══════════════════════════════════════════════════════════════════════════
   Findex News Runtime Pro — NATIVE MOBILE APP LAYER
   File: assets/fnrp-mobile-app.css   (pairs with assets/fnrp-mobile-app.js)
   ─────────────────────────────────────────────────────────────────────────────
   WHAT THIS IS
   A true app-shell experience for phones/tablets (≤ 768px): a fixed bottom
   tab bar, a slim sticky top bar, and five focused "views" that the JS layer
   organises the EXISTING sections into. Every feature is preserved — nothing is
   removed, only re-homed so the user sees one calm thing at a time (progressive
   disclosure) instead of an endless desktop stack.

   PSYCHOLOGY / UX PRINCIPLES BAKED IN
     • Thumb-zone first   — primary navigation lives at the BOTTOM where thumbs
                            reach, not the top (Bloomberg / Robinhood / X pattern).
     • One job per screen — each tab answers one question, lowering cognitive load.
     • News leads         — the app opens on the News tab (the hook), as requested.
     • Calm motion        — 220ms ease view-swaps, no jarring jumps; respects
                            prefers-reduced-motion.
     • Safe areas         — honours iOS notch / home-indicator insets.
     • Zero desktop bleed — every rule is inside @media (max-width:768px) or under
                            html.fnrp-mapp; desktop (≥769px) is 100% untouched.

   REVERSIBILITY
   Purely additive. To roll back, delete the two enqueue lines for
   'fnrp-mobile-app' in findex-news-runtime-pro.php. Nothing in frontend.css/js
   or the older fnrp-mobile.css is modified.
   ═══════════════════════════════════════════════════════════════════════════ */

/* The JS adds html.fnrp-mapp only when it actually mounts the shell (≤768px and
   the root exists). All structural rules are gated on BOTH that class AND the
   media query, so a stale class can never affect desktop. */

@media (max-width: 768px) {

  /* ── Tokens for the app shell ─────────────────────────────────────────── */
  html.fnrp-mapp {
    --mapp-topbar-h: 50px;
    --mapp-tabbar-h: 60px;
    --mapp-gutter: 16px;
    --mapp-safe-top: env(safe-area-inset-top, 0px);
    --mapp-safe-bottom: env(safe-area-inset-bottom, 0px);
    /* glass surfaces tuned to the Reading-Room palette */
    --mapp-bar-bg: color-mix(in srgb, var(--bg, #0a0e15) 86%, transparent);
    --mapp-bar-border: var(--border-2, rgba(255,255,255,.095));
  }

  /* ── 0. Document hygiene ──────────────────────────────────────────────── */
  html.fnrp-mapp,
  html.fnrp-mapp body {
    overflow-x: hidden;
  }
  /* Reserve room for the fixed bars so content never hides under them. */
  html.fnrp-mapp #fnrp-root {
    padding-bottom: calc(var(--mapp-tabbar-h) + var(--mapp-safe-bottom) + 12px);
    max-width: 100vw;
    overflow-x: clip;
  }

  /* ════════════════════════════════════════════════════════════════════════
     1. STICKY TOP BAR  — slim, glassy, holds brand + live + clock + search btn
     The JS keeps the original .fh-bar but restyles it into this compact form
     and tucks the heavy controls (search field, ⌘K) away into the More view.
     ════════════════════════════════════════════════════════════════════════ */
  html.fnrp-mapp #fnrp-root .fh-bar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    height: calc(var(--mapp-topbar-h) + var(--mapp-safe-top));
    padding: var(--mapp-safe-top) var(--mapp-gutter) 0;
    background: var(--mapp-bar-bg);
    -webkit-backdrop-filter: saturate(140%) blur(14px);
            backdrop-filter: saturate(140%) blur(14px);
    border-bottom: 1px solid var(--mapp-bar-border);
    grid-template-columns: none;          /* defeat desktop grid */
  }
  html.fnrp-mapp #fnrp-root .fh-logo { font-size: 17px; gap: 2px; }
  html.fnrp-mapp #fnrp-root .fh-logo-tail { font-size: 12px; opacity: .55; }

  /* Search field + ⌘K hint move out of the bar; a search ICON button (added
     by JS, class .mapp-search-btn) opens the More/Search view instead. */
  html.fnrp-mapp #fnrp-root .fh-search-w,
  html.fnrp-mapp #fnrp-root .fh-kbd { display: none !important; }

  html.fnrp-mapp #fnrp-root .fh-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
  }
  html.fnrp-mapp #fnrp-root .fh-live {
    padding-inline-end: 0;
    border-inline-end: 0;
    font-size: 0;                         /* hide the word, keep the dot */
    gap: 0;
  }
  html.fnrp-mapp #fnrp-root .fh-live .fh-dot { width: 7px; height: 7px; }
  html.fnrp-mapp #fnrp-root .fh-clock {
    font-size: 11px;
    white-space: nowrap;
    letter-spacing: .02em;
    color: var(--muted, #8c98ad);
  }
  /* Theme + language stay reachable in the bar (small, glanceable). */
  html.fnrp-mapp #fnrp-root .fh-theme-btn { width: 30px; height: 30px; }

  /* The injected search button in the top bar */
  html.fnrp-mapp .mapp-search-btn {
    appearance: none;
    border: 1px solid var(--border-2, rgba(255,255,255,.095));
    background: var(--surface, #121823);
    color: var(--text-2, #b3bdce);
    width: 32px; height: 32px;
    border-radius: 9px;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background .12s ease, color .12s ease;
  }
  html.fnrp-mapp .mapp-search-btn:active { background: var(--surface-2, #1a2030); }
  html.fnrp-mapp .mapp-search-btn svg { width: 16px; height: 16px; }

  /* ════════════════════════════════════════════════════════════════════════
     2. THE VIEWS  — every existing top-level section gets tagged by the JS with
     data-mapp-view="news|markets|calendar|pulse|more". Only the active view is
     shown. The body grid collapses to a single column inside each view.
     ════════════════════════════════════════════════════════════════════════ */
  html.fnrp-mapp #fnrp-root [data-mapp-view] { display: none; }
  html.fnrp-mapp #fnrp-root [data-mapp-view].is-active { display: block; }

  /* The body becomes a plain single column; the sidebar de-stickies and its
     cards stack naturally inside whatever view they were routed to. */
  html.fnrp-mapp #fnrp-root #fnrp-body,
  html.fnrp-mapp #fnrp-root .fn-body {
    display: block;
    grid-template-columns: none;
    padding: 0 var(--mapp-gutter);
    margin-top: 12px;
  }
  html.fnrp-mapp #fnrp-root .fn-sidebar {
    position: static;
    top: auto;
    width: 100%;
    display: block;
  }
  html.fnrp-mapp #fnrp-root .fn-stream { min-width: 0; width: 100%; }

  /* A small, friendly view title the JS injects at the top of each view. */
  html.fnrp-mapp .mapp-view-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    padding: 14px var(--mapp-gutter) 4px;
  }
  html.fnrp-mapp .mapp-view-title {
    font-family: var(--sans, 'Inter', system-ui, sans-serif);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -.01em;
    color: var(--text, #e3e9f2);
    margin: 0;
  }
  html.fnrp-mapp.fnrp-rtl .mapp-view-title,
  html[dir="rtl"] html.fnrp-mapp .mapp-view-title {
    font-family: var(--sans-ar, 'IBM Plex Sans Arabic', sans-serif);
  }
  html.fnrp-mapp .mapp-view-sub {
    font-size: 12px;
    color: var(--muted, #8c98ad);
  }

  /* Soft enter animation when switching views. */
  html.fnrp-mapp #fnrp-root [data-mapp-view].is-active {
    animation: mappViewIn .22s cubic-bezier(.4,0,.2,1);
  }
  @keyframes mappViewIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* ── NEWS view — the hook. Comfortable reading column. ────────────────── */
  html.fnrp-mapp #fnrp-root .fn-item {
    padding: 16px 14px;
    min-width: 0;
  }
  html.fnrp-mapp #fnrp-root .fn-title,
  html.fnrp-mapp #fnrp-root .fn-title-lead {
    font-size: 16.5px;
    line-height: 1.36;
    overflow-wrap: anywhere;
  }
  html.fnrp-mapp #fnrp-root .fn-excerpt { font-size: 13.5px; line-height: 1.55; }
  html.fnrp-mapp #fnrp-root .fn-meta { flex-wrap: wrap; row-gap: 5px; column-gap: 6px; }
  html.fnrp-mapp #fnrp-root .fn-foot { flex-wrap: wrap; row-gap: 6px; column-gap: 14px; }
  html.fnrp-mapp #fnrp-root .fn-load-more { width: 100%; min-height: 48px; }

  /* Market tabs + sub-filter live at the top of the NEWS view as a swipe rail. */
  html.fnrp-mapp #fnrp-root .fm-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    height: 46px;
    padding: 0 var(--mapp-gutter);
    gap: 6px;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 22px), transparent);
            mask-image: linear-gradient(90deg, #000 calc(100% - 22px), transparent);
  }
  html.fnrp-mapp #fnrp-root .fm-tabs::-webkit-scrollbar { display: none; }
  html.fnrp-mapp #fnrp-root .fm-tab { flex: 0 0 auto; padding: 0 14px; font-size: 13px; }

  html.fnrp-mapp #fnrp-root .fm-subfilter,
  html.fnrp-mapp #fnrp-root .ff-bar {
    padding-left: var(--mapp-gutter);
    padding-right: var(--mapp-gutter);
  }
  html.fnrp-mapp #fnrp-root .fm-subfilter {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 8px;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 20px), transparent);
            mask-image: linear-gradient(90deg, #000 calc(100% - 20px), transparent);
  }
  html.fnrp-mapp #fnrp-root .fm-subfilter::-webkit-scrollbar { display: none; }
  html.fnrp-mapp #fnrp-root .fm-sub-chip,
  html.fnrp-mapp #fnrp-root .ff-chip {
    flex: 0 0 auto;
    min-height: 34px;
    display: inline-flex;
    align-items: center;
  }

  /* Price strip lives in NEWS view, just under the tabs, as a clean ticker. */
  html.fnrp-mapp #fnrp-root .fp-strip {
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 12px), transparent);
            mask-image: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 12px), transparent);
  }
  html.fnrp-mapp #fnrp-root .fp-tick { padding: 0 12px; font-size: 11px; gap: 6px; }

  /* ── MARKETS view — watchlist, chart, gainers/losers as full-width cards ─ */
  html.fnrp-mapp #fnrp-root .fs-card {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    border-radius: var(--radius-md, 8px);
    margin-bottom: 12px;
  }
  html.fnrp-mapp #fnrp-root .fs-card-hd { padding: 13px 14px 9px; }
  html.fnrp-mapp #fnrp-root #fs-gainers-body.fnrp-w2-grid,
  html.fnrp-mapp #fnrp-root #fs-losers-body.fnrp-w2-grid {
    grid-template-columns: 1fr !important;
  }
  html.fnrp-mapp #fnrp-root #fs-pairs-body.fnrp-w2-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  html.fnrp-mapp #fnrp-root .fnrp-w2-col .fs-mover {
    grid-template-columns: auto 1fr auto;
    column-gap: 8px;
    padding: 11px 12px;
    min-height: 44px;
  }
  html.fnrp-mapp #fnrp-root .fnrp-w2-col .fs-mover-sym {
    font-size: 12.5px; overflow: visible; text-overflow: clip; white-space: nowrap;
  }
  html.fnrp-mapp #fnrp-root .fnrp-w2-col .fs-mover-pct {
    font-size: 11.5px; white-space: nowrap; padding: 2px 6px;
  }

  /* ── CALENDAR view — pulse strip stacks; modal goes full-bleed ─────────── */
  html.fnrp-mapp #fnrp-root .fn-econ-strip {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px var(--mapp-gutter);
    margin: 12px var(--mapp-gutter) 14px;
  }
  html.fnrp-mapp #fnrp-root .fn-econ-spine {
    display: flex; gap: 6px; overflow-x: auto;
    -webkit-overflow-scrolling: touch; scrollbar-width: none; padding-bottom: 2px;
  }
  html.fnrp-mapp #fnrp-root .fn-econ-spine::-webkit-scrollbar { display: none; }
  html.fnrp-mapp #fnrp-root .fn-econ-spine-cell { flex: 1 0 44px; min-width: 44px; }
  html.fnrp-mapp #fnrp-root .fn-econ-next {
    max-width: none; border-inline-start: 0;
    border-top: 1px solid var(--border); padding-inline-start: 0; padding-top: 10px;
  }
  html.fnrp-mapp #fnrp-root .fn-econ-cta {
    width: 100%; justify-content: center; padding: 12px; font-size: 13px;
  }
  html.fnrp-mapp .fn-econ-modal {
    width: 100vw; max-width: 100vw;
    height: 100dvh; max-height: 100dvh; border-radius: 0;
  }

  /* ── PULSE view — breaking ribbon shown as a vertical readable feel ────── */
  html.fnrp-mapp #fnrp-root [data-mapp-view="pulse"] .fb-ribbon {
    border-radius: var(--radius-md, 8px);
    margin: 0 var(--mapp-gutter) 12px;
  }

  /* ── MORE view — search field re-homed here, big and usable ───────────── */
  html.fnrp-mapp .mapp-more-search {
    margin: 4px var(--mapp-gutter) 16px;
  }
  html.fnrp-mapp .mapp-more-search .fh-search-w {
    display: flex !important;       /* re-show the search field inside More */
    width: 100%;
  }
  html.fnrp-mapp .mapp-more-search .fh-search { width: 100%; font-size: 15px; }

  html.fnrp-mapp .mapp-more-group {
    margin: 0 var(--mapp-gutter) 18px;
  }
  html.fnrp-mapp .mapp-more-group-title {
    font-size: 11px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted, #8c98ad);
    margin: 0 0 8px 2px;
  }
  html.fnrp-mapp .mapp-more-row {
    display: flex; align-items: center; gap: 12px;
    width: 100%;
    padding: 14px;
    background: var(--surface, #121823);
    border: 1px solid var(--border, rgba(255,255,255,.05));
    border-radius: var(--radius-md, 8px);
    margin-bottom: 8px;
    color: var(--text, #e3e9f2);
    font-size: 14px;
    text-align: start;
    cursor: pointer;
    appearance: none;
  }
  html.fnrp-mapp .mapp-more-row:active { background: var(--surface-2, #1a2030); }
  html.fnrp-mapp .mapp-more-row .mapp-more-ic {
    width: 20px; height: 20px; color: var(--accent, #4dd4ac); flex: 0 0 auto;
  }
  html.fnrp-mapp .mapp-more-row .mapp-more-lbl { flex: 1 1 auto; }
  html.fnrp-mapp .mapp-more-row .mapp-more-chev {
    width: 16px; height: 16px; color: var(--muted-2, #555f70); flex: 0 0 auto;
  }

  /* The services-rail buttons (Verified / Complaint / Academy) are re-homed
     into the More view as full rows by the JS; hide the fixed rail itself. */
  html.fnrp-mapp #fsv-rail,
  html.fnrp-mapp .fsv-rail,
  html.fnrp-mapp .fnrp-services-rail { display: none !important; }

  /* ════════════════════════════════════════════════════════════════════════
     3. BOTTOM TAB BAR  — the heart of the native feel. Fixed, glassy, 5 tabs,
     each a stacked icon + label with an animated active pill.
     ════════════════════════════════════════════════════════════════════════ */
  html.fnrp-mapp .mapp-tabbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 60;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    align-items: stretch;
    height: calc(var(--mapp-tabbar-h) + var(--mapp-safe-bottom));
    padding-bottom: var(--mapp-safe-bottom);
    background: var(--mapp-bar-bg);
    -webkit-backdrop-filter: saturate(150%) blur(18px);
            backdrop-filter: saturate(150%) blur(18px);
    border-top: 1px solid var(--mapp-bar-border);
  }
  html.fnrp-mapp .mapp-tab {
    appearance: none;
    border: 0;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--muted, #8c98ad);
    font-family: var(--sans, 'Inter', system-ui, sans-serif);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: .01em;
    cursor: pointer;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    transition: color .16s ease;
    padding-top: 4px;
  }
  html.fnrp-mapp.fnrp-rtl .mapp-tab,
  html[dir="rtl"] html.fnrp-mapp .mapp-tab {
    font-family: var(--sans-ar, 'IBM Plex Sans Arabic', sans-serif);
  }
  html.fnrp-mapp .mapp-tab .mapp-tab-ic {
    width: 23px; height: 23px;
    transition: transform .2s cubic-bezier(.34,1.56,.64,1);
  }
  html.fnrp-mapp .mapp-tab .mapp-tab-ic svg { width: 100%; height: 100%; display: block; }
  html.fnrp-mapp .mapp-tab.is-active { color: var(--accent, #4dd4ac); }
  html.fnrp-mapp .mapp-tab.is-active .mapp-tab-ic { transform: translateY(-1px) scale(1.06); }
  /* active indicator: a small glowing dot above the icon */
  html.fnrp-mapp .mapp-tab::before {
    content: "";
    position: absolute;
    top: 0;
    width: 18px; height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--accent, #4dd4ac);
    box-shadow: 0 0 10px var(--accent, #4dd4ac);
    opacity: 0;
    transform: scaleX(.3);
    transition: opacity .2s ease, transform .2s ease;
  }
  html.fnrp-mapp .mapp-tab.is-active::before { opacity: 1; transform: scaleX(1); }
  html.fnrp-mapp .mapp-tab:active .mapp-tab-ic { transform: scale(.92); }

  /* Optional unread badge on a tab (e.g. breaking count) */
  html.fnrp-mapp .mapp-tab .mapp-tab-badge {
    position: absolute;
    top: 2px;
    inset-inline-start: calc(50% + 6px);
    min-width: 16px; height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--down, #f87171);
    color: #fff;
    font-size: 9.5px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--bg, #0a0e15);
  }

  /* ── Scroll-to-top FAB (appears after scrolling within News) ──────────── */
  html.fnrp-mapp .mapp-fab {
    position: fixed;
    inset-inline-end: 16px;
    bottom: calc(var(--mapp-tabbar-h) + var(--mapp-safe-bottom) + 14px);
    z-index: 55;
    width: 44px; height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border-2, rgba(255,255,255,.095));
    background: var(--surface, #121823);
    color: var(--text, #e3e9f2);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 20px rgba(0,0,0,.4);
    cursor: pointer;
    opacity: 0;
    transform: translateY(12px) scale(.9);
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
  }
  html.fnrp-mapp .mapp-fab.is-visible {
    opacity: 1; transform: translateY(0) scale(1); pointer-events: auto;
  }
  html.fnrp-mapp .mapp-fab svg { width: 20px; height: 20px; }

  /* v11.25.0 — the app shell already ships its own scroll-to-top FAB
     (.mapp-fab). Hide the generic floating back-to-top button here so the
     two never stack on top of each other in the native-app experience. */
  html.fnrp-mapp .fnrp-to-top { display: none !important; }

  /* Hide the old in-stream bottom watchlist slot from layout-fix on the app
     shell — the watchlist now lives properly in the Markets tab. */
  html.fnrp-mapp #fnrp-mobile-pairs-slot-bottom:empty { display: none; }
}

/* ── Reduced motion: kill view/tab animations entirely ──────────────────── */
@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
  html.fnrp-mapp #fnrp-root [data-mapp-view].is-active { animation: none; }
  html.fnrp-mapp .mapp-tab .mapp-tab-ic,
  html.fnrp-mapp .mapp-tab::before,
  html.fnrp-mapp .mapp-fab { transition: none; }
}

/* ── Desktop guard: if the class somehow lingers above 768px, neutralise the
   shell-only chrome so desktop is provably never affected. ───────────────── */
@media (min-width: 769px) {
  html.fnrp-mapp .mapp-tabbar,
  html.fnrp-mapp .mapp-fab,
  html.fnrp-mapp .mapp-search-btn { display: none !important; }
  html.fnrp-mapp #fnrp-root [data-mapp-view] { display: block !important; }
}
