/* fixes-visual.css — Visual-defect fixes (visual check 2026-12-03 02:00).
   NEW file, loads AFTER fixes.css. Covers ONLY the V1–V10 visual defects
   plus the E33 remainder — nothing already fixed in ux2.css §3.22
   (GAP-1/2/3/4) or fixes.css/fixes.js (b204) is repeated here:
   - §3.22 GAP-3 already spans a lone last spec item; V8 only tightens
     margins/gaps and switches the detail specs grid to auto-fit.
   - fixes.css scroll-padding-bottom / .u-panel.db scroll-margin /
     #root +32px are NOT re-declared, except the detail #root padding
     below, which intentionally raises the total to 48px (32 + 16).
   - fixes.js autoHideBottomNav covers .ux2-bottomnav only; V2 covers
     the OTHER floating elements (.u-pbar, .u-tray, .ux2-fab-sell) via
     the .fv-hidden class toggled by fixes-visual.js. b207: the real
     bar is .u-pbar (main.js t1) — .u-tray is defined in main.css but
     never rendered by main.js (see fixes-visual.js header).
   - HUB-LOAD (b207): hub .u-pagehead keeps its navy gradient while
     loading, so the white title (§3.24) never sits on a light
     section tint (#ede9fe elec-soft — the loading flash).
   - NV (b210): «المنصة ما تبانش AI» — de-templating (see §NV below).
   Version: b210.
   Wire: <link rel="stylesheet" href="/fixes-visual.css?v=b210"> right
   AFTER the fixes.css link in index.html (and every page that loads
   fixes.css: 404/about/featured/help/pro). */

/* ============ V1 — «صفقة اليوم» card: two-thirds empty pink/white ============
   The banner (built by ux2.js addDealOfDay) has NO image at all — it is a
   full-width block (max-width 1080px) with stacked lines on a pale-pink
   gradient, so it reads as an empty pink slab. Compress it into one
   compact horizontal strip: tag + title + price + discount inline,
   the <br> between title and price removed, gradient flattened to the
   surface colour (the red border + red tag keep the "deal" identity).
   Any empty image/placeholder area inside the banner is hidden. */
.ux2-dealday-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  padding: 10px 14px;
  background: var(--surface);
  border-width: 1px;
}
.ux2-dealday-inner br { display: none; }
.ux2-dealday-inner b.ux2-dd-tag { margin-bottom: 0; flex: none; }
.ux2-dealday-inner .ux2-dd-title { flex: 1 1 220px; min-width: 0; }
.ux2-dealday-inner .ux2-dd-price { white-space: nowrap; }
.ux2-dealday-inner .u-nophoto,
.ux2-dealday-inner img:only-child { display: none; }
.u-dark .ux2-dealday-inner { background: var(--surface); }

/* ============ V2 + V4 — floating bars stop covering content ============
   .u-pbar is the fixed bottom bar on detail pages («اسأل عن الإعلان» /
   «اطلب معاينة», main.js t1 «إجراءات الإعلان»); .u-tray is kept
   defensively (defined in main.css, never rendered by main.js);
   .ux2-fab-sell is the floating «انشر إعلان» button
   (mobile only, bottom:76px). fixes-visual.js adds .fv-hidden while
   scrolling down and removes it on scroll up. The transition lives
   here so the hide/show is smooth; pointer-events:none keeps a hidden
   bar from intercepting taps. */
.u-pbar,
.u-tray,
.ux2-fab-sell { transition: transform .25s ease, opacity .25s ease; }
.u-pbar.fv-hidden {
  transform: translateY(160%);
  opacity: 0;
  pointer-events: none;
}
.u-tray.fv-hidden {
  transform: translateY(160%);
  opacity: 0;
  pointer-events: none;
}
.ux2-fab-sell.fv-hidden {
  transform: translateY(calc(100% + 90px));
  opacity: 0;
  pointer-events: none;
}
/* V4 (part): safe margin for the sell FAB — clear of the bottom nav and
   of the iOS/Android safe area, so it never sits on content or chrome. */
@media (max-width: 640px) {
  .ux2-fab-sell { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
}
/* V2 (part): extra air at the very end of a detail page — 48px total
   here, overriding the 32px from fixes.css (this file loads after it),
   i.e. 32px (fixes.css) + 16px (here), on top of the 170px (200px
   <=720px) FIX-4 padding already in ux2.css. */
body[data-ux3route="detail"] #root { padding-bottom: 48px; }
/* V2 (post-deploy tray fix, 2026-12-03): bottom padding on the detail
   content container itself — .u-detail is the correct class: it is
   the detail page's content wrapper (className:"u-detail" in main.js)
   and already carries the ux2.css FIX-4 padding. This rule re-asserts
   that padding in the fixes layer (fixes-visual.css loads AFTER
   ux2.css) so the clearance survives even if FIX-4 is ever moved or
   dropped. b207 CORRECTION of the height basis: the b205/b206 comment
   measured the phantom .u-tray (43/78px) — the real bar is .u-pbar:
   - .u-pbar in main.css: position:fixed, inset-inline:12px,
     bottom:calc(88px + env(safe-area-inset-bottom)), display:grid
     1fr 1fr, gap:10px, padding:10px; its buttons .u-pb are height:48px.
   - Bar height = 48 + 10 + 10 = 68px.
   - Viewport footprint = bottom offset 88px + 68px = 156px (+ the
     safe-area inset on mobile, 0–34px).
   - 170px desktop clears the 156px footprint by 14px; 200px
     (<=720px) clears 156px + safe-area by >=10px. The values are
     KEPT (not lowered — lowering would be a regression); they also
     clear the mobile bottom nav and the back-to-top / filter FABs
     that FIX-4 was written for. With this padding the last spec rows
     and the «الفرق مع أقل بديل» table can scroll fully above the bar
     even while it is visible. */
body[data-ux3route="detail"] .u-detail { padding-bottom: 170px; }
@media (max-width: 720px) {
  body[data-ux3route="detail"] .u-detail { padding-bottom: 200px; }
}
@media (prefers-reduced-motion: reduce) {
  .u-tray, .ux2-fab-sell { transition: none; }
}

/* ============ V3 — assistant FAB covers the «بحث» icon (<=720px) ============
   .savo-fab (assistant.css) is fixed left:16px bottom:16px — exactly
   where the mobile bottom nav sits, so on narrow screens it covers a
   nav icon. Below 720px move the whole assistant cluster clear of the
   nav: the FAB goes to the top-right of the floating stack (bottom:76px,
   visual right side — the sell FAB occupies bottom:76px on the LEFT in
   RTL, so the two never collide), z-index 70 keeps it above the nav
   (z-index 60) and the sell FAB (61) without covering any nav icon,
   and the chat panel is re-anchored above the moved FAB. */
@media (max-width: 720px) {
  .savo-fab {
    left: auto !important;
    right: 12px !important;
    bottom: 76px !important;
    z-index: 70;
  }
  .savo-panel {
    left: auto !important;
    right: 12px !important;
    bottom: 140px !important;
  }
}

/* ============ V5 — sticky top bar covers stats numbers on scroll ============
   .u-top is sticky (main.css) with z-index 60; anchor jumps and
   scroll-into-view land the hero / stats strip underneath it. Reserve
   room above every scroll target (92px desktop; the top bar wraps to
   two rows on narrow screens, so 120px there). This is the TOP
   counterpart of fixes.css scroll-padding-bottom — different property,
   no duplication. */
html { scroll-padding-top: 92px; }
.u-hero, .u-hero-in, .u-hstart, .u-pagehead-stats, .u-hc, .u-pagehead,
.u-top { scroll-margin-top: 92px; }
@media (max-width: 720px) {
  html { scroll-padding-top: 120px; }
  .u-hero, .u-hero-in, .u-hstart, .u-pagehead-stats, .u-hc, .u-pagehead,
  .u-top { scroll-margin-top: 120px; }
}

/* ============ V7 — zoom button overlaps the «صورة توضيحية» label ============
   ux2.js sets the zoom button inline as bottom:8px + inset-inline-end:8px
   (bottom-LEFT in RTL) — exactly where the photo's bottom caption area
   sits. Move it to top-RIGHT (top + inset-inline-start in RTL).
   !important is required: the position comes from an inline style, and
   only an !important rule overrides inline styles. The count badge
   (.ux3-count, bottom-inline-start = bottom-right in RTL) is untouched,
   so the bottom edge keeps badge + label with no overlap. */
.u-detail-media .ux2-zoom-btn,
.u-media .ux2-zoom-btn {
  top: 8px !important;
  bottom: auto !important;
  inset-inline-start: 8px !important;
  inset-inline-end: auto !important;
  z-index: 5;
}

/* ============ V8 — big white gap between «نصايح أمان» and «المواصفات» ====
   Spirit of §3.22 without repeating its rules: .u-panel has
   margin-block-start:16px (main.css). On detail pages halve the gap
   around the safety panel and the specs panel, tighten the specs grid
   gap, and switch the detail specs grid from auto-fill to auto-fit so
   the last row's items stretch and fill the full width instead of
   leaving a blank cell. (GAP-3's lone-last-item span-2 rule still
   applies underneath; auto-fit is what finishes E33 — see below.) */
.u-detail .u-panel.u-safe,
body[data-ux3route="detail"] .u-panel.u-safe { margin-block-start: 8px; margin-block-end: 8px; }
.u-detail section.u-panel:has(.u-facts),
body[data-ux3route="detail"] section.u-panel:has(.u-facts) { margin-block-start: 8px; }
.u-detail .u-facts {
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.u-detail .u-facts > * { min-width: 0; }

/* ============ V9 — alternative cards: one thumbnail, the rest empty =====
   .u-sim cards (main.js «similar» section, .u-simrow) show the model's
   photo when one exists and a hole when it does not. Give every card
   the same fixed-height media block with the same grey illustrative
   background, so a missing/broken photo reads as an intentional
   placeholder instead of an empty card — all cards look uniform. */
.u-simrow .u-sim { grid-template-rows: 120px auto auto; }
.u-simrow .u-sim img,
.u-simrow .u-sim .u-nophoto {
  height: 120px;
  min-height: 120px;
  width: 100%;
  object-fit: cover;
  background: linear-gradient(135deg, #eef2f7, #dfe6f0);
}
.u-dark .u-simrow .u-sim img,
.u-dark .u-simrow .u-sim .u-nophoto {
  background: linear-gradient(135deg, #1c2742, #141b30);
}

/* ============ HUB-LOAD — hub header loading flash (b207) ============
   Follow-up to ux2.css §3.24 (post-publish fix 2026-12-03): §3.24 made
   the hub .u-pagehead h1 white (#fff) for the navy gradient (main.css:
   linear-gradient 135deg #0b1647 -> #1e3a8a) — 10.36:1 to 17.21:1. But
   the WHITE title is applied by the same selectors while the BACKGROUND
   can still be a light section tint: ux2.css §3.1 lines 525–528 give
   .u-pagehead a soft per-section background (body[data-ux3sec="elec"]
   -> var(--ux3-elec-soft) #ede9fe, pale violet) whenever that section
   attribute lingers from the previous page / before setRouteData()
   runs — white on #ede9fe measures ~1.17:1, nearly unreadable. That
   is the greyish-violet flash the 02:52 check saw on #/hub/gov: white
   text on pale violet, then navy once the route hook settles.
   Fix: on hub pages the background is pinned to the same navy gradient
   by the SAME two selectors §3.24 uses (body[data-ux3route="hub"] and
   the :has() fallback), so title and background can never disagree —
   whatever the section attribute holds during loading. Specificity
   (0,2,1) / (0,3,1) matches or beats the section rules (0,2,1), and
   this file loads AFTER ux2.css, so it wins ties. The gradient is
   hardcoded, identical in light and dark mode — no theme split.
   Scope is hub-only: the only #/hub/gov links inside a .u-sec are on
   hub pages (zf index + detail «كل الأماكن», vS hub index); section
   pages keep their intended soft tints. */
body[data-ux3route="hub"] .u-pagehead,
.u-sec:has(a[href^="#/hub/gov"]) .u-pagehead {
  background: linear-gradient(135deg, #0b1647, #1e3a8a);
}

/* ============ E33 remainder — unbalanced specs grid ======================
   §3.22 GAP-3 already handles the 2-column case (lone last item spans
   both columns). What it does NOT cover: .u-facts is an auto-fill grid,
   so on wide screens the last row can still end with blank cells when
   the row has 3+ columns. The V8 auto-fit rule above closes that gap:
   with auto-fit the last row's items expand to fill the row, so no
   blank cell remains under «الحالة» or anywhere else. No extra rule
   is needed here — this comment records the coverage decision. */

/* ============ HUB-LOAD-2 — hub header flash at FIRST paint (b208) ============
   Root cause (verified 2026-12-03 against the served Preview 4989aaf5):
   the b207 HUB-LOAD pin gated the navy background on body[data-ux3route=
   "hub"] (set by deferred ux2.js setRouteData()) or on :has() matching a
   gov link rendered by React. Since the 2026-12-03 SPEED rewrite,
   setRouteData() runs ONLY inside runPass()'s requestAnimationFrame
   callback, after ~10 setup functions, with later calls collapsed by a
   120ms debounce — so on a full reload it can lag React's first paint of
   the pagehead; and the :has() gate needs the governorate links, which
   arrive in a later React burst (async gov data). In that window the
   header is styled by whatever body[data-ux3sec] holds (a section tint
   such as --ux3-elec-soft #ede9fe, pale violet — the light flash the
   03:07 check saw twice, white title on ~1.17:1), then flips navy once
   the hook settles. The served CSS was verified byte-identical to local,
   so this is a timing/order defect, not a missing rule.
   Fix: the choice no longer depends on any post-paint JS. An inline
   script in index.html <head> sets html.ux3-hub synchronously during
   parsing (before any paint, before main.js, before deferred ux2.js)
   from the initial hash, and keeps it in sync on hashchange — so this
   rule is true at the very first paint. Specificity (0,2,1) ties the
   §3.1 section rules and wins by load order (this file loads after
   ux2.css); the h1 rule (0,2,2) beats §3.1's brand colour (0,1,1).
   Scope is hub-only (#/hub, #/hub/gov, #/hub/gov/<name>); the class is
   removed on hashchange away from #/hub*, so section pages keep their
   intended soft tints. The gradient is hardcoded, identical in light
   and dark mode — no theme split. */
html.ux3-hub .u-pagehead {
  background: linear-gradient(135deg, #0b1647, #1e3a8a);
}
html.ux3-hub .u-pagehead h1,
html.ux3-hub .u-pagehead h2 {
  color: #fff;
}

/* ============ HUB-LOAD-3 — kill the page fade-in on hub pages (b209) ============
   Root cause (this investigation, 2026-12-03): the b208 synchronous class
   and its navy/white rules were CORRECT from the first paint — but the
   header was still invisible for 320ms. ux2.css §3.14 item 678 (line
   1459) puts a fade-in on the whole page container:
     .u-home, .u-sec { animation: ux3-fade var(--ux3-dur-slow) ease; }
     @keyframes ux3-fade { from { opacity: 0; } }   (line 1428)
     --ux3-dur-slow: 0.32s;                          (line 500)
   Every page is rendered by main.js as <main class="u-sec"> with the
   .u-pagehead inside it (hub index, #/hub/gov and every other page), so
   on every mount — full reload AND every in-app route change, because
   React swaps the page component and a fresh .u-sec is created — the
   entire section, navy header included, ramps opacity 0 -> 1 over
   0.32s. While it ramps, the navy gradient is composited over the light
   page background (--bg #f4f6fb, plus the light skeleton): mid-fade the
   header reads medium blue-grey, early-fade pale grey-violet, and only
   at the end of the 0.32s does it settle on navy — exactly the
   light-to-navy gradient/fade the 03:16-03:18 Preview check saw on both
   reloads and on in-app navigation. The b208 simulation missed it
   because it modelled only the COMPUTED background colour, never the
   composited opacity — the same class of blind spot as the b206 pbar
   sim (logic tested on a stub, not the real DOM/CSS behaviour).
   No transition on .u-pagehead's background exists anywhere to blame:
   main.css has transitions only on .u-btn/.u-card/.cmpw-ph img,
   fixes.css has zero transitions/animations, and ux2.css has no
   transition/animation rule touching .u-pagehead at all — the fade is
   an ANIMATION on the ancestor .u-sec, not a transition on the header.
   Fix: on hub pages only, cancel that animation (and, defensively, any
   transition/animation on the header itself — none exists today, this
   guards the rule if one is ever added). Specificity (0,2,1) beats the
   ux2.css rule (0,1,0), and this file loads after ux2.css anyway.
   Scope is hub-only: the deliberate page fade-in (item 678) is kept on
   every other page, and section pages keep their soft tints once the
   class is removed on hashchange away from #/hub*. */
html.ux3-hub .u-home,
html.ux3-hub .u-sec { animation: none; }
html.ux3-hub .u-pagehead,
html.ux3-hub .u-pagehead h1,
html.ux3-hub .u-pagehead h2 { transition: none; animation: none; }

/* ============ NV — «المنصة ما تبانش AI» (b210, أمر أحمد 06:55) ============
   The home offers row and the listing grids were six identical
   200px cards / one repeated card shape — the template look. These
   rules only vary SHAPE and RHYTHM; identity is untouched (same
   navy #1e3a8a / green #166534 / gold var(--gold) the site already
   uses, same logo, same name). Specificities are kept above the
   base rules they override (main.css .u-offer is (0,1,0); ux2.css
   .u-root .u-card radius uses !important, so radius is NOT varied
   here — only aspect-ratio and offset, which it does not lock).
   - NV1: «عروض النهاردة» becomes a distinct band with its own
     header treatment; the first card is featured (wider, taller
     photo); image heights alternate so the row stops reading as a
     photocopied strip; each card gets a coloured top edge cycling
     green / navy / gold; even cards sit 5px lower (staggered row).
   - NV2: listing grids (.u-grid) and similar rows (.u-simrow)
     alternate media ratios and stagger even cards; the first
     similar card spans two columns on wide screens.
   - NV3: the SPA compare page gets distinct identities for its two
     sides (first navy, second green) and a treated header; plus the
     display rules for the real photos fixes.js injects
     (.u-nophoto.nv-photo background, .cmpw-ph.nv-photo img). */
.u-offers {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px 12px 14px;
}
.u-offers h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  border-inline-start: 4px solid #166534;
  padding-inline-start: 10px;
}
.u-dark .u-offers h2 { border-inline-start-color: #86efac; }
.u-offer:nth-child(3n+1) { border-top: 3px solid #166534; }
.u-offer:nth-child(3n+2) { border-top: 3px solid #1e3a8a; }
.u-offer:nth-child(3n) { border-top: 3px solid var(--gold); }
.u-dark .u-offer:nth-child(3n+2) { border-top-color: #7f9bff; }
.u-offer:first-child { flex-basis: 232px; }
.u-offer:first-child img { height: 148px; }
.u-offer:nth-child(3n+2) img { height: 132px; }
.u-offer:nth-child(3n) img { height: 112px; }
@media (prefers-reduced-motion: no-preference) {
  .u-offer:nth-child(even) { transform: translateY(5px); }
}
@media (min-width: 700px) {
  .u-grid .u-card:nth-child(3n+2) .u-media { aspect-ratio: 3 / 2; }
  .u-grid .u-card:nth-child(3n) .u-media { aspect-ratio: 4 / 3; }
  .u-simrow .u-sim:first-child { grid-column: span 2; }
  .u-simrow .u-sim:first-child img,
  .u-simrow .u-sim:first-child .u-nophoto { height: 160px; min-height: 160px; }
}
@media (min-width: 700px) and (prefers-reduced-motion: no-preference) {
  .u-grid .u-card:nth-child(even) { transform: translateY(6px); }
  .u-simrow .u-sim:nth-child(3n+2) { transform: translateY(4px); }
}
.cmpw-h {
  border-inline-start: 4px solid #1e3a8a;
  padding-inline-start: 10px;
}
.cmpw-th b:first-child { color: #1e3a8a; }
.cmpw-th b:last-child { color: #166534; }
.u-dark .cmpw-th b:first-child { color: #7f9bff; }
.u-dark .cmpw-th b:last-child { color: #86efac; }
/* Photos injected by fixes.js (NV): a .u-nophoto that gained a real
   model photo keeps its size and shows the photo cover; its icon
   is hidden underneath. A .cmpw-ph that gained a photo shows it
   (the base rule keeps injected imgs at opacity:0 until .ok). */
.u-nophoto.nv-photo {
  background-size: cover;
  background-position: center;
}
.u-nophoto.nv-photo > * { opacity: 0; }
.cmpw-ph.nv-photo img { opacity: 1; }
