/* ============================================================
   A9X MOBILE HEADER SUITE — dedicated phone design files (L124)
   Owner order: «تعمل ملفات جديده للتصميم دا لما اي موبايل او تلفون
   يفتح الموقع يفتح الملفات المخصصه للموبايل علشان يكون متناسق
   وخلي التصميم متناسق جدا علي التلفون وسهله وسلس».
   Self-gated: NOTHING below applies on desktop. Loaded site-wide
   from partials/ember-chrome.blade.php with ?v=filemtime.
   Companion JS: media/a9x-ui/mobile-header.js (burger drawer).
   ============================================================ */
@media (max-width: 760px) {

  /* ---------- Topbar shell: sticky cinematic glass ---------- */
  .em-topbar {
    position: sticky;
    top: 0;
    z-index: 60;
    min-height: 56px;
    padding: 8px 10px 7px;
    gap: 6px;
    flex-wrap: wrap;
    row-gap: 5px;
    border-radius: 16px 16px 0 0;
    border-bottom: 1px solid rgba(125, 211, 252, .22);
    background: linear-gradient(180deg, rgba(8, 11, 20, .92), rgba(5, 7, 14, .88));
    backdrop-filter: blur(18px) saturate(1.35);
    -webkit-backdrop-filter: blur(18px) saturate(1.35);
    box-shadow: 0 18px 40px -26px rgba(0, 0, 0, .9), inset 0 1px 0 rgba(255, 255, 255, .06);
  }
  .em-topbar::after {
    content: "";
    position: absolute;
    inset-inline: 0;
    bottom: -1px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(240, 185, 90, .55), rgba(56, 189, 248, .6), rgba(139, 92, 246, .5), transparent);
    background-size: 220% 100%;
    animation: mh-scan 9s linear infinite;
  }

  /* Burger — injected by mobile-header.js, desktop-never */
  .mh-burger {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 13px;
    border: 1px solid rgba(125, 211, 252, .3);
    background: linear-gradient(160deg, rgba(56, 189, 248, .18), rgba(139, 92, 246, .14));
    color: #bae6fd;
    cursor: pointer;
    transition: transform .25s cubic-bezier(.2, .9, .25, 1), box-shadow .25s, border-color .25s;
    animation: mh-rise .55s cubic-bezier(.2, .9, .25, 1) backwards;
  }
  .mh-burger:active { transform: scale(.92); }
  .mh-burger:focus-visible { outline: 2px solid rgba(125, 211, 252, .7); outline-offset: 2px; }
  .mh-burger i {
    position: absolute;
    inset-inline-start: 10px;
    width: 19px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transition: translate .3s cubic-bezier(.2, .9, .25, 1), rotate .3s;
    box-shadow: 0 0 8px rgba(125, 211, 252, .5);
  }
  .mh-burger i:nth-child(1) { top: 13px; }
  .mh-burger i:nth-child(2) { top: 19px; }
  .mh-burger i:nth-child(3) { top: 25px; }
  html.mh-nav-open .mh-burger { border-color: rgba(125, 211, 252, .65); box-shadow: 0 0 22px -6px rgba(56, 189, 248, .6); color: #e0f2fe; }
  html.mh-nav-open .mh-burger i:nth-child(1) { translate: 0 6px; rotate: 45deg; }
  html.mh-nav-open .mh-burger i:nth-child(2) { opacity: 0; scale: .4; }
  html.mh-nav-open .mh-burger i:nth-child(3) { translate: 0 -6px; rotate: -45deg; }

  /* Brand: keep the wordmark, calm it down */
  .em-brand--top { font-size: 13.5px; }
  .em-brand--top span { letter-spacing: .04em; }

  /* ---------- Action clusters: full ribbon on its own row ---------- */
  .em-top-actions {
    flex: 0 0 100%;
    min-width: 0;
    justify-content: flex-end;
    gap: 4px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 3px;
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
    mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
  }
  .em-top-actions::-webkit-scrollbar { display: none; }
  .em-top-group {
    gap: 2px;
    padding: 3px;
    border-radius: 14px;
    border-color: rgba(255, 255, 255, .08);
    background: linear-gradient(180deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .015));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);
  }
  .em-top-group + .em-top-group { margin-inline-start: 3px; }
  .em-top-group + .em-top-group::before { height: 20px; opacity: .8; }
  .em-top-group > * { animation: mh-rise .5s cubic-bezier(.2, .9, .25, 1) backwards; }

  .em-icon-btn,
  .em-langpill {
    width: 34px;
    height: 34px;
  }
  .em-langpill { min-width: 34px; padding: 0 4px; border-radius: 50%; gap: 0; }
  .em-langpill span { font-size: 11px; }
  .em-avatar { width: 34px; height: 34px; }

  /* Balance chip: compact vault — coins stay, tag condenses */
  .em-balance { padding: 4px 8px; gap: 5px; border-radius: 999px; }
  .em-balance__tag { font-size: 8.5px; letter-spacing: .14em; }
  .em-planbadge { padding: 4px 7px; gap: 4px; }
  .em-planbadge__name { display: none; }

  /* Popovers live comfortably on the phone: full-width sheets
     (backdrop-filter makes the topbar their containing block, so
     calc(100% + 6px) = right under the bar either way). */
  .em-topbar .em-navpanel,
  .em-topbar .em-pop,
  .em-topbar .em-pop--notif,
  .em-topbar .em-pop--menu,
  .em-topbar .em-pop--music {
    position: fixed;
    top: calc(100% + 8px);
    inset-inline-start: 4px;
    inset-inline-end: 4px;
    width: auto;
    max-height: min(66vh, 520px);
    z-index: 70;
    border-radius: 18px;
    box-shadow: 0 30px 60px -22px rgba(0, 0, 0, .95);
    animation: mh-pop .32s cubic-bezier(.2, .9, .25, 1) both;
  }

  /* ---------- Drawer: the sidebar returns on phones ---------- */
  /* Rail-collapsed desktop state must never squeeze the phone grid
     (`.em-app[data-side="rail"]` forces 58px first column and won —
     the topbar ate a 58px sliver on collapsed-rail phones). */
  .em-app .em-app-grid,
  .em-app[data-side="rail"] .em-app-grid,
  .em-app[data-side] .em-app-grid:has(.ch-workspace) {
    grid-template-columns: minmax(0, 1fr);
  }
  .em-app .em-side {
    position: fixed;
    top: 0;
    bottom: 0;
    inset-inline-start: 0;
    z-index: 90;
    width: min(286px, 82vw);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 12px 10px 18px;
    border-inline-end: 1px solid rgba(125, 211, 252, .25);
    border-radius: 0 22px 22px 0;
    background: linear-gradient(165deg, rgba(9, 13, 24, .97), rgba(4, 6, 13, .99));
    backdrop-filter: blur(22px) saturate(1.3);
    -webkit-backdrop-filter: blur(22px) saturate(1.3);
    box-shadow: 26px 0 60px -30px rgba(0, 0, 0, .95);
    translate: -110% 0;
    transition: translate .38s cubic-bezier(.2, .9, .25, 1);
    animation: none;
  }
  [dir="rtl"] .em-app .em-side,
  html[dir="rtl"] .em-app .em-side {
    border-radius: 22px 0 0 22px;
    box-shadow: -26px 0 60px -30px rgba(0, 0, 0, .95);
  }
  html.mh-nav-open .em-app .em-side { translate: 0 0; }
  .em-app .em-side .em-icon-plain { display: none; }
  .em-app .em-side .em-upgrade { display: none; }
  .em-app .em-side nav { flex: 1; }
  .em-app .em-side .em-side-item { padding: 11px 12px; font-size: 14px; }
  .em-app .em-side .em-side-item:active { background: rgba(125, 211, 252, .12); }
  .em-app .em-side .em-tierchip { margin-top: 14px; }

  /* Scrim behind the drawer */
  .mh-scrim {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(2, 4, 10, .62);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s ease;
  }
  html.mh-nav-open .mh-scrim { opacity: 1; pointer-events: auto; }

  /* ---------- Light theme harmony ---------- */
  html[data-theme="light"] .em-topbar {
    background: linear-gradient(180deg, rgba(248, 250, 253, .94), rgba(240, 245, 251, .9));
    border-bottom-color: rgba(37, 99, 235, .22);
    box-shadow: 0 14px 30px -22px rgba(15, 23, 42, .35);
  }
  html[data-theme="light"] .em-topbar::after {
    background: linear-gradient(90deg, transparent, rgba(37, 99, 235, .5), rgba(2, 132, 199, .45), rgba(109, 40, 217, .4), transparent);
  }
  html[data-theme="light"] .mh-burger {
    border-color: rgba(37, 99, 235, .35);
    background: linear-gradient(160deg, rgba(125, 211, 252, .25), rgba(191, 219, 254, .3));
    color: #1d4ed8;
    box-shadow: none;
  }
  html[data-theme="light"] .em-top-group {
    border-color: rgba(148, 163, 184, .4);
    background: linear-gradient(180deg, rgba(255, 255, 255, .9), rgba(241, 245, 250, .75));
    box-shadow: 0 6px 16px -12px rgba(15, 23, 42, .3);
  }
  html[data-theme="light"] .em-app .em-side {
    background: linear-gradient(165deg, rgba(250, 252, 255, .99), rgba(240, 245, 251, 1));
    border-inline-end-color: rgba(37, 99, 235, .22);
    box-shadow: 26px 0 60px -34px rgba(15, 23, 42, .4);
  }
  html[data-theme="light"] .mh-scrim { background: rgba(15, 23, 42, .35); }

  /* ---------- Motion ---------- */
  @keyframes mh-scan { 0% { background-position: 0% 0; } 100% { background-position: 220% 0; } }
  @keyframes mh-rise { from { opacity: 0; transform: translateY(6px) scale(.95); } to { opacity: 1; transform: none; } }
  @keyframes mh-pop { from { opacity: 0; transform: translateY(-8px) scale(.97); } to { opacity: 1; transform: none; } }
}

/* Ultra-narrow phones: the vault tag folds into the coin only */
@media (max-width: 380px) {
  .em-balance__tag { display: none; }
  .em-balance { padding: 4px 6px; }
  .em-top-group { gap: 1px; padding: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  .mh-burger i,
  .mh-scrim,
  .em-app .em-side,
  .em-topbar::after,
  .em-top-actions *,
  .mh-burger,
  .em-topbar .em-navpanel,
  .em-topbar .em-pop,
  .em-topbar [class*="em-pop"] {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-delay: 0ms !important;
  }
}
