/* ============================================================
   Addaliil — Midnight Market · layout.css
   Global chrome restyle over EXISTING markup classes (no view edits):
   navbar (.ad-topnav), centered tabs (.aa-tab), app-rail user menu (.aa-tree),
   bottom bar + FAB, page shell (.hm-shell/.hm-grid). Breakpoint = 860px.
   Drawer JS hooks: body.rail-open (mobile), body.rail-collapsed (desktop).
   ============================================================ */

/* ---- responsive visibility utilities (design model) ---- */
@media (max-width:859px){ .mm-desktop-only{display:none!important} }
@media (min-width:860px){ .mm-mobile-only{display:none!important} }

/* =====================================================================
   TOP NAVBAR (.ad-topnav)  — 3 zones, centered icon tab strip
   ===================================================================== */
.ad-topnav{position:fixed;top:0;inset-inline:0;height:58px;z-index:1030;display:flex;align-items:center;justify-content:space-between;gap:.75rem;padding:0 18px;background:var(--surface);border-bottom:1px solid var(--border);box-shadow:0 1px 4px rgba(13,31,23,.05)}
.nav-start{display:flex;align-items:center;gap:10px;min-width:0}
.ad-logo-d{display:inline-flex;align-items:center;justify-content:center;width:38px;height:38px;border-radius:11px;background:linear-gradient(135deg,var(--brand-neon),var(--brand));color:var(--on-brand);font-size:17px;box-shadow:var(--shadow-glow)}
.ad-logo-d:hover{color:var(--on-brand)}
.ad-brand-d{font-weight:700;font-size:21px;color:var(--text)}
.ad-brand-d:hover{color:var(--text)}

.nav-center{position:absolute;left:50%;transform:translateX(-50%);display:flex;gap:4px}
/* Below 860 the bottom bar carries the same three MainTabs, labelled. Left visible, this absolutely-centred
   strip slid UNDER the end cluster at phone widths — the Questions tab over "Sign in", the Market tab over the
   language button (UX study item B-1, measured at 390px). */
@media (max-width:859px){ .nav-center{display:none} }
.aa-tab{display:inline-flex;align-items:center;justify-content:center;min-width:74px;height:46px;border-radius:10px;font-size:18px;color:var(--muted);border-bottom:3px solid transparent;transition:.15s}
.aa-tab:hover{color:var(--brand-dark);background:var(--surface2)}
.aa-tab.active{background:var(--brand-soft);color:var(--brand-dark);border-bottom-color:var(--brand)}

.nav-end{display:flex;align-items:center;gap:9px}
.nav-icon-btn{display:inline-flex;align-items:center;justify-content:center;width:38px;height:38px;border-radius:50%;background:var(--surface2);color:var(--text);border:0;cursor:pointer;font-size:15px;position:relative}
.nav-icon-btn:hover{color:var(--brand-dark)}
.nav-icon-btn.brand{background:linear-gradient(135deg,var(--accent),var(--accent-dark));color:#fff}
.nav-icon-btn.dropdown-toggle::after{display:none}
.nav-avatar{display:inline-flex;align-items:center;justify-content:center;width:38px;height:38px;border-radius:50%;background:linear-gradient(135deg,var(--brand-neon),var(--brand));color:var(--on-brand);font-weight:800;font-size:13px;border:0;cursor:pointer;letter-spacing:1px}

/* dropdown menus (country / language / create chooser) */
.ad-topnav .dropdown-menu{background:var(--surface);border:1px solid var(--border);border-radius:12px;box-shadow:var(--shadow);padding:6px}
.ad-topnav .dropdown-item{border-radius:8px;color:var(--text)}
.ad-topnav .dropdown-item:hover{background:var(--surface2)}
.ad-topnav .dropdown-item.active,.ad-topnav .dropdown-item:active{background:var(--brand-soft);color:var(--brand-dark)}

/* =====================================================================
   APP SHELL + USER-MENU RAIL  (.app-shell / .app-rail / .aa-tree)
   ===================================================================== */
.app-shell{min-height:calc(100vh - 58px)}
/* Balance the left rail with an equal phantom column on the right so the main content
   column is centered on the WHOLE viewport (not just the area after the rail). */
.app-shell.has-rail{display:grid;grid-template-columns:248px minmax(0,1fr) 248px;align-items:start}
.app-rail{position:sticky;top:58px;height:calc(100vh - 58px);overflow-y:auto;background:var(--surface);border-inline-end:1px solid var(--border);padding:14px}
body.rail-collapsed .app-shell.has-rail{grid-template-columns:0 minmax(0,1fr) 0}
body.rail-collapsed .app-rail{display:none}
.app-rail-backdrop{position:fixed;inset:0;background:rgba(8,12,10,.5);backdrop-filter:blur(2px);z-index:1044}

/* user-menu accordion tree */
.aa-tree{display:flex;flex-direction:column;gap:2px;height:100%}
.aa-branch__head,.aa-sub__head,.aa-leaf{display:flex;align-items:center;gap:11px;width:100%;padding:11px 10px;border-radius:10px;border:0;background:transparent;color:var(--text);font-size:.85rem;font-weight:600;cursor:pointer;text-align:start;text-decoration:none}
.aa-branch__head:hover,.aa-sub__head:hover,.aa-leaf:hover{background:var(--surface2)}
.aa-branch__head.is-active,.aa-leaf[aria-current="page"]{background:var(--brand-soft);color:var(--brand-dark);font-weight:800}
.aa-ico{display:inline-flex;align-items:center;justify-content:center;width:26px;height:26px;border-radius:8px;background:var(--surface2);color:var(--muted);font-size:.8rem;flex:none}
.aa-branch__head.is-active .aa-ico{background:var(--brand);color:var(--on-brand)}
.aa-branch__label{flex:1}
.aa-caret{margin-inline-start:auto;font-size:.7rem;color:var(--muted);transition:transform .15s}
.aa-branch.is-open>.aa-branch__head .aa-caret,.aa-sub.is-open>.aa-sub__head .aa-caret{transform:rotate(180deg)}
.aa-group{list-style:none;margin:0;padding:0 0 4px;display:flex;flex-direction:column;gap:1px}
.aa-group[hidden]{display:none}
.aa-sub__head{padding-inline-start:16px;font-weight:500}
.aa-leaf--deep{padding-inline-start:30px;font-weight:500;font-size:.82rem}
.aa-leaf__text{flex:1}
.aa-leaf--danger{color:var(--accent);margin-top:auto;font-weight:700}
.aa-leaf--danger:hover{background:rgba(var(--accent-glow),.10)}
.aa-theme-switch{margin-inline-start:auto}
.aa-theme-switch .form-check-input:checked{background-color:var(--brand);border-color:var(--brand)}
.mm-rail-lang{margin-inline-start:auto;display:inline-flex;gap:4px}
.mm-rail-lang form{margin:0}
.mm-rail-lang button{border:1px solid var(--border);background:var(--surface2);color:var(--text);border-radius:8px;padding:3px 8px;font-size:.7rem;font-weight:700;cursor:pointer}
.mm-rail-lang button.active{background:var(--brand-soft);color:var(--brand-dark);border-color:var(--brand)}

/* =====================================================================
   MAIN container + PAGE SHELL (.hm-shell / .hm-grid)  — 540 center cap
   ===================================================================== */
.main-contained{width:100%;max-width:1180px;margin-inline:auto}
.hm-shell{width:100%;max-width:1100px;margin-inline:auto;padding:16px 0}
.hm-grid{display:grid;grid-template-columns:232px minmax(0,540px) 244px;gap:16px;justify-content:center;align-items:start}
.hm-grid--no-left{grid-template-columns:minmax(0,1fr) 300px;max-width:920px;margin-inline:auto}
.hm-aside{position:sticky;top:74px}
.hm-center{min-width:0}
.hm-center.edit-page{max-width:none}

@media (max-width:1080px){
  .hm-grid{grid-template-columns:minmax(0,1fr)}
  .hm-aside.left{display:none}
  .ads-aside{display:none}   /* sponsored rail is desktop-only — hidden on tablet & mobile */
}
@media (max-width:859px){
  .hm-grid,.hm-grid--no-left{grid-template-columns:minmax(0,1fr)}
  .hm-aside{display:none}
}

/* =====================================================================
   MOBILE (<860): rail → off-canvas drawer, bottom bar, FAB
   ===================================================================== */
@media (max-width:859px){
  .app-shell.has-rail{display:block}
  .app-rail{position:fixed;top:58px;bottom:0;inset-inline-end:0;width:min(86vw,320px);transform:translateX(110%);transition:transform .2s ease;z-index:1045;border-inline-start:1px solid var(--border);border-inline-end:0}
  html[dir="rtl"] .app-rail{transform:translateX(-110%)}
  body.rail-open .app-rail{transform:none}
}

.ad-bottom-bar{position:fixed;inset-inline:0;bottom:0;height:64px;z-index:1040;display:flex;background:var(--surface);border-top:1px solid var(--border);box-shadow:0 -2px 12px rgba(13,31,23,.06)}
.ad-bot-tab{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;color:var(--muted);font-size:9.5px;font-weight:700;text-decoration:none}
.ad-bot-tab i{font-size:18px}
.ad-bot-tab.active{color:var(--brand-dark)}
.mm-fab-add{position:fixed;bottom:74px;inset-inline-start:16px;z-index:1045}
.mm-fab-btn{display:inline-flex;align-items:center;justify-content:center;width:56px;height:56px;border-radius:50%;background:linear-gradient(135deg,var(--accent),var(--accent-dark));color:#fff;font-size:22px;border:0;cursor:pointer;box-shadow:0 8px 22px rgba(var(--accent-glow),.45)}

/* =====================================================================
   SHARED PAGE ASIDES (_PageAsideLeft / _PageAsideRight) + promo
   ===================================================================== */
.col-inner{display:flex;flex-direction:column;gap:16px}
.side-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow-sm);padding:14px}
.profile-row{display:flex;align-items:center;gap:11px}
.p-av{display:flex;align-items:center;justify-content:center;width:44px;height:44px;flex:none;border-radius:50%;background:linear-gradient(135deg,var(--brand-neon),var(--brand));color:var(--on-brand);font-weight:800}
.p-name{font-weight:700;font-size:.9rem}
.p-meta{display:flex;align-items:center;gap:.3rem;color:var(--muted);font-size:.76rem}
.side-nav{display:flex;flex-direction:column;gap:2px}
.side-item{display:flex;align-items:center;gap:11px;padding:9px 10px;border-radius:10px;color:var(--text);text-decoration:none;font-size:.85rem;font-weight:600}
.side-item:hover{background:var(--surface2)}
.side-item.active{background:var(--brand-soft);color:var(--brand-dark);font-weight:800}
.si-ico{display:inline-flex;align-items:center;justify-content:center;width:26px;height:26px;flex:none;border-radius:8px;background:var(--surface2);color:var(--muted);font-size:.8rem}
.side-item.active .si-ico{background:var(--brand);color:var(--on-brand)}
.si-grow{flex:1;min-width:0}
.side-title{display:flex;align-items:center;font-weight:800;font-size:.9rem;margin-bottom:.6rem}
.tag-list{display:flex;flex-wrap:wrap;gap:.4rem}
.tag-pill{background:var(--surface2);color:var(--text);border:1px solid var(--border);border-radius:99px;padding:5px 11px;font-size:.76rem;font-weight:600}
.tag-pill.brand{background:var(--brand-soft);color:var(--brand-dark);border-color:transparent}
.hm-promo{background:linear-gradient(135deg,#13241d,#0c1714);color:#fff;border-radius:var(--radius);padding:18px}
.hm-promo h4{color:#fff;margin:.5rem 0;font-weight:800}
.hm-promo p{color:rgba(255,255,255,.75);font-size:.82rem;margin:0 0 .8rem}
.pc-tag{display:inline-flex;align-items:center;gap:.4rem;color:#facc15;font-weight:700;font-size:.75rem}
.pc-cta{display:inline-flex;align-items:center;gap:.4rem;background:linear-gradient(135deg,var(--brand-neon),var(--brand));color:var(--on-brand);font-weight:800;border-radius:10px;padding:9px 16px}

/* =====================================================================
   SPONSORED / ADS aside (first-party ad inventory) — desktop-only
   ===================================================================== */
.ads-head{display:flex;align-items:center;justify-content:flex-end;color:var(--muted);font-size:.7rem;font-weight:700;letter-spacing:.05em;text-transform:uppercase;padding:0 2px 2px}
.ad-card{display:flex;align-items:center;gap:11px;background:var(--surface);border:1px solid var(--border);border-radius:14px;box-shadow:var(--shadow-sm);padding:11px;text-decoration:none;color:var(--text);transition:border-color .15s,background .15s}
.ad-card:hover{border-color:var(--brand);background:var(--surface2)}
.ad-card-txt{flex:1;min-width:0}
.ad-card-title{font-weight:700;font-size:.85rem;line-height:1.3;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.ad-card-url{display:flex;align-items:center;gap:.3rem;color:var(--muted);font-size:.72rem;margin-top:.25rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.ad-card-img{flex:none;width:84px;height:64px;border-radius:10px;background:var(--ph);color:var(--ph-fg);display:flex;align-items:center;justify-content:center;overflow:hidden;font-size:1.1rem}
.ad-card-img img{width:100%;height:100%;object-fit:cover}
.ads-foot{text-align:center;color:var(--muted);font-size:.66rem;padding-top:2px}
.ads-invite .pc-tag{color:#facc15}

/* spec 027 fix — single user menu: when the global authenticated rail (#appRail) is
   present, hide the redundant page-level left aside. (<1080 already hides it.) */
@media (min-width:1081px){
  /* The home is the only page with its own right rail (the ads), which balances the left rail —
     so the home opts OUT of the phantom right spacer; its main spans to the right edge. */
  .app-shell.has-rail:has(.hm-grid){grid-template-columns:248px minmax(0,1fr)}

  /* The left-aside menu duplicates the global rail → hide it. */
  .app-shell.has-rail aside.hm-aside.left{display:none}

  /* Home search grid: flexible gaps on each side of the 675px search center it on the VIEWPORT
     (left rail ≈ right ads, so they balance), with the ads pinned flush to the right edge. */
  .app-shell.has-rail .hm-shell:has(.hm-grid){max-width:none}
  .app-shell.has-rail .hm-grid:not(.hm-grid--no-left){grid-template-columns:minmax(0,1fr) minmax(0,675px) minmax(0,1fr) 244px}
  .app-shell.has-rail .hm-grid:not(.hm-grid--no-left) > .hm-center{grid-column:2}
  /* …flush to the end edge, but not touching it: on an Arabic page that edge is the LEFT one, and the box sat on
     the window frame with no gutter (UX study ب-13). */
  .app-shell.has-rail .hm-grid:not(.hm-grid--no-left) > .ads-aside{grid-column:4;margin-inline-end:16px}
}

/* user identity header at the top of the app-rail (AppNavTree) */
.aa-user{display:flex;align-items:center;gap:11px;padding:4px 8px 14px;margin-bottom:8px;border-bottom:1px solid var(--border)}
.aa-user__av{display:inline-flex;align-items:center;justify-content:center;width:44px;height:44px;flex:none;border-radius:50%;background:linear-gradient(135deg,var(--brand-neon),var(--brand));color:var(--on-brand);font-weight:800;font-size:.9rem;letter-spacing:.5px}
.aa-user__meta{min-width:0}
.aa-user__name{display:flex;align-items:center;gap:.35rem;font-weight:800;font-size:.92rem;color:var(--text)}
.aa-user__verified{color:var(--brand)}
.aa-user__sub{color:var(--muted);font-size:.74rem}
