/* =============================================================================
   ASES — responsive layer.  Loaded LAST, after style.css → brand.css → rtl.css.
   -----------------------------------------------------------------------------
   Why a separate file rather than editing brand.css:
     1. sw.js serves brand.css / style.css cache-first from a versioned CACHE, and
        asset() emits no ?v=, so an in-place edit reaches no returning visitor until
        the cache constant is bumped. A brand-new URL has no cache entry at all.
     2. brand.css sets `!important` on rules we must override (e.g. .ases-logo height).
        Between competing !important declarations of equal specificity the LATER
        source wins — which only works from a file that loads after it.
     3. Reverting the whole responsive change is deleting one <link>.

   BREAKPOINT LADDER — the only values allowed in this file:
     359.98   small phones      (Galaxy S 360, iPhone SE 375)
     429.98   phones            (390 / 412)
     575.98   large phones      (430 iPhone Pro Max, 480+)
     767.98   tablets portrait
     991.98   tablets landscape
     1199.98  small laptops (nav collapses into the drawer here)
   The two phone steps sit BELOW the entire existing corpus (style.css floors at
   479px, brand.css at 420px), so they cannot collide with an existing block.
   Never invent a new breakpoint. Never edit style.css or brand.css to fix layout.
   ============================================================================= */


/* -----------------------------------------------------------------------------
   1. body{position:fixed}  —  style.css:72-77, inherited from the Charitics theme.
   main.js:5 already forces position:static on every page that runs scripts, so this
   is a no-op there. _layout_bare.php loads NO scripts, which is why /doc/{id} and
   /academy/certificate/{serial} could not be scrolled at all.
   -------------------------------------------------------------------------- */
body { position: static; }

/* Bootstrap's .overflow-hidden{overflow:hidden!important} on <main> made it a scroll
   container, which silently killed EVERY position:sticky on the site (including the
   account rail). overflow-x:clip clips without creating one. */
.ases-main { overflow-x: clip; }

/* brand.css:931 put overflow-x:clip + max-width on html AND body. html alone is enough;
   the permanent off-viewport element is .ul-sidebar (translateX(100%)), plus decorative
   decals. Keep the net — once the header fits it is no longer masking a real bug. */
html { overflow-x: clip; }
body { overflow-x: visible; max-width: none; }

/* QA escape hatch: ?qa=overflow reveals anything the clip is hiding. Zero production cost. */
html.ases-qa-overflow, html.ases-qa-overflow body { overflow-x: visible !important; }
html.ases-qa-overflow *:not(html):not(body) { outline: 1px solid rgba(255, 0, 0, .35); }


/* =============================================================================
   2. HEADER — the actual "Galaxy breaks, iPhone Pro Max is fine" bug.
   -----------------------------------------------------------------------------
   Container at <=991px is calc(100% - 30px) -> 330px of room on a 360px phone.
   The action row needed 456.5px: logo 116.5 + 44 wrapper gap + 147 icons + 74 report
   button + 45 burger + 30 inner gaps. style.css:1019 pinned flex-shrink:0 on every
   child, so nothing could give, and overflow-x:clip made the overflow unreachable
   rather than scrollable. In RTL the action row is the LEFTMOST item, so the part
   that fell off the edge was the hamburger itself.
   ============================================================================= */
@media (max-width: 575.98px) {

  /* 2a. Reclaim 44px of pure waste. .ul-header-nav-wrapper is a PHANTOM below 1200px:
         main.js:22 re-parents the <nav> into the drawer, leaving a zero-width flex item
         that still costs a full gap on both sides. justify-content:space-between already
         distributes free space, so gap:0 changes nothing visually when there IS room. */
  .ul-header-bottom-wrapper { gap: 0; min-width: 0; }

  /* 2b. Invert the shrink hierarchy: the LOGO gives way, the CONTROLS never do.
         order:99 pins the burger last so it is structurally impossible to clip. */
  .ul-header-bottom-wrapper > *  { flex-shrink: 1; min-width: 0; }
  .logo-container                { flex: 0 1 auto; min-width: 0; overflow: hidden; }
  .ul-header-actions             { flex: 0 0 auto; min-width: 0; }
  .ul-header-actions > *         { flex: 0 0 auto !important; }
  .ul-header-sidebar-opener      { flex: 0 0 auto !important; order: 99; }

  /* 2c. One token drives every control size. */
  .ul-header-actions {
    --hdr-btn: clamp(34px, 9.6vw, 40px);
    gap: clamp(4px, 1.4vw, 8px);                       /* supersedes brand.css:938 (6px) */
  }
  .ases-lang-toggle,
  .ases-cart-link,
  .ases-acct-icon,
  .ases-report-btn {
    width: var(--hdr-btn) !important;
    height: var(--hdr-btn) !important;
    min-width: 0; padding: 0 !important; gap: 0;
    border-radius: 50%;
    justify-content: center; align-items: center;
  }
  .ases-mbell               { width: var(--hdr-btn); height: var(--hdr-btn); padding: 0; }
  .ul-header-sidebar-opener { height: clamp(38px, 10.6vw, 45px) !important; }

  /* 2d. «بلّغ» becomes icon-only. The labelled version survives in the floating
         speed-dial (.ases-fab-item--report), so the wording is not lost. */
  .ases-report-btn [data-lang] { display: none !important; }
  .ases-report-btn svg         { width: 18px; height: 18px; }

  /* 2e. Logo: brand.css:681 pins height:clamp(34px,3.4vw,46px)!important on a 548x160
         wordmark -> 116.5px. Later !important wins. */
  .ases-logo { height: clamp(24px, 7vw, 32px) !important; max-width: 100%; object-fit: contain; }

  /* 2f. 44px tap targets without widening the row: grow the HIT box vertically only
         (the header bar is ~64px tall, so there is vertical room to spare). */
  .ul-header-actions > a,
  .ul-header-actions > button,
  .ul-header-actions .ases-mbell,
  .ul-header-sidebar-opener { position: relative; }
  .ul-header-actions > a::after,
  .ul-header-actions > button::after,
  .ul-header-actions .ases-mbell::after,
  .ul-header-sidebar-opener::after {
    content: ""; position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 100%; height: 44px;
  }
  .ul-header-actions .ases-mnotif { position: relative; }   /* keep the panel anchored */
}

/* Below 430px the wordmark is swapped for the square mark — language-neutral, so the
   phone header also loads ONE image instead of two. */
.ases-logomark { display: none; }
@media (max-width: 429.98px) {
  .logo-container .ases-logo     { display: none !important; }
  .logo-container .ases-logomark { display: inline-block; height: clamp(24px, 7vw, 32px); width: auto; max-width: none; }
  .logo-container .ases-logomark--dark  { display: none; }
  .ul-header-bottom.sticky .logo-container .ases-logomark--light { display: none; }
  .ul-header-bottom.sticky .logo-container .ases-logomark--dark  { display: inline-block; }
}


/* =============================================================================
   3. GRIDS whose minimum track exceeded the phone content box (290-330px).
   ============================================================================= */
@media (max-width: 575.98px) {
  .ases-projects-grid, .ases-news-grid, .ases-events-grid,
  .ases-grid-2, .ases-grid-3, .ases-involve-grid,
  .ba-grid, .eco-grid, .ases-dash-grid, .ases-acct-grid,
  .ases-pricing-grid, .ases-services-grid,
  /* These four shipped with 248–300px minimum tracks and were never on the list:
     .eai-grid (/eco-ai board), .forest-grid, .ases-recap-videos, .ases-shop-grid.
     They fit a 290px content box only until the a11y text-size tool zooms. */
  .eai-grid, .forest-grid, .ases-recap-videos, .ases-shop-grid {
    grid-template-columns: 1fr !important;
  }
}

/* brand.css:528 pins the donation amounts to repeat(3,1fr) with NO phone override —
   three buttons stayed 3-up down to 320px (~93px each). Fluid instead of stepped. */
.ases-amount-grid { grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)) !important; }

/* home.php:82/88 — .ases-ai-strip goes 4 -> 2 at 700px and never reaches 1 column. */
@media (max-width: 359.98px) { .ases-ai-strip { grid-template-columns: 1fr !important; } }

/* brand.css:1244 sets white-space:nowrap on footer links, so long Arabic labels
   («استوديو التصميم البيئي») clipped INVISIBLY in the 421-680px band. The nowrap was
   the bug, not the column count — restoring wrap keeps 2 columns, which reads better. */
@media (max-width: 767.98px) {
  .ul-footer-widget-links a { white-space: normal; font-size: 13px; line-height: 1.9; }
}


/* =============================================================================
   4. TABLES — .ases-acct-table (account.php) never got the .eco-table-wrap treatment
   that its sibling .eco-table has had since brand.css:876.
   role="region" + tabindex="0" on the wrapper make it keyboard-scrollable.
   ============================================================================= */
.eco-table-wrap .ases-acct-table { min-width: 380px; }
.eco-table-wrap .ases-acct-table th,
.eco-table-wrap .ases-acct-table td { padding-inline: 10px; white-space: nowrap; }
.eco-table-wrap .ases-acct-table td:nth-child(2) { white-space: normal; min-width: 130px; }
.eco-table-wrap:focus-visible { outline: 2px solid var(--ases-green, #216e97); outline-offset: 2px; }


/* =============================================================================
   5. SAFE AREA. _layout.php sets apple-mobile-web-app-status-bar-style:black-translucent,
   which in iOS standalone mode already extends content under the status bar. Without
   viewport-fit=cover AND env() padding the header sits under the clock. The two ship
   together. env() resolves to 0px on every non-notched device.
   ============================================================================= */
.ul-header-container {
  max-width: calc(100% - 30px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
}
@media (max-width: 1199.98px) {
  .ul-header-bottom:not(.sticky) { padding-top: calc(20px + env(safe-area-inset-top, 0px)); }
  .ul-header-bottom.sticky       { padding-top: calc(12px + env(safe-area-inset-top, 0px)); padding-bottom: 12px; }
}
.ul-sidebar {
  padding-top:    calc(clamp(20px, 1.58vw, 30px) + env(safe-area-inset-top, 0px));
  padding-bottom: calc(clamp(20px, 1.58vw, 30px) + env(safe-area-inset-bottom, 0px));
}
.ases-chat { bottom: calc(clamp(26px, 3vh, 40px) + env(safe-area-inset-bottom, 0px)) !important; }
.ases-a11y { bottom: calc(clamp(26px, 3vh, 40px) + 70px + env(safe-area-inset-bottom, 0px)); }
@media (max-width: 480px) {
  .ases-chat { bottom: calc(18px + env(safe-area-inset-bottom, 0px)) !important; }
  .ases-a11y { bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
}
.ases-cookie      { bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
.ases-adstrip     { padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
.ul-footer-bottom { padding-bottom: calc(clamp(14px, 1.16vw, 22px) + env(safe-area-inset-bottom, 0px)); }
@media (max-width: 575.98px) { .ases-cookie { bottom: calc(10px + env(safe-area-inset-bottom, 0px)); } }


/* =============================================================================
   6. TAP TARGETS outside the header, where horizontal room is not scarce.
   ============================================================================= */
@media (max-width: 991.98px) {
  .ases-dash-nav a, .ases-acct-link, .ases-share a,
  .eco-seg button, .ases-fav, .ul-footer-widget-links a { min-height: 44px; }
  .ases-dash-nav a, .eco-seg button { display: flex; align-items: center; }
  /* share_html() emits <button data-share>, not <a> — the .ases-share a selector above
     matches only the legacy rule, so the real share row never reached 44px (and dropped
     to 38px under 381px). Size the buttons the widget actually renders. */
  .ases-share button { min-width: 44px; min-height: 44px; width: 44px; height: 44px; }
}


/* =============================================================================
   7. MEMBER ACCOUNT SHELL — see app/account_ui.php.
   -----------------------------------------------------------------------------
   The rail is FIRST in the DOM, which on a phone meant scrolling the hero, the
   profile block and ~10 nav links (roughly 750-800px) before the first stat.
   The fix is to COMPACT the rail, not to reorder it: CSS `order` would decouple
   focus order from visual order (WCAG 2.4.3) and merely bury the nav instead.
   A ~94px identity-and-nav bar above the stats is the correct account context.
   ============================================================================= */
.ases-dash        { display: grid; grid-template-columns: 286px minmax(0, 1fr); gap: 22px; align-items: start; }
.ases-dash-side   { background: #fff; border: 1px solid #e4ecf1; border-radius: 18px; padding: 20px;
                    box-shadow: 0 14px 36px -26px rgba(12, 37, 54, .4); }
.ases-dash-main   { min-width: 0; }
.ases-dash-main--narrow { max-width: 720px; }          /* replaces five ad-hoc 720-920px widths */

.ases-dash-id     { text-align: center; padding-bottom: 16px; border-bottom: 1px solid #eef2f5; }
.ases-dash-id .av { width: 74px; height: 74px; border-radius: 50%; margin: 0 auto 10px; display: grid; place-items: center;
                    font-size: 30px; font-weight: 800; color: #fff; overflow: hidden;
                    background: linear-gradient(140deg, var(--ases-green, #216e97), #0c7a43); }
.ases-dash-id .av img { width: 100%; height: 100%; object-fit: cover; }
.ases-dash-id .nm { font-weight: 800; font-size: 15px; color: var(--ases-ink, #15212b); }
.ases-dash-id .em { font-size: 12px; color: #7a8a94; word-break: break-all; }
.ases-dash-id .lvl{ display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; font-size: 12px; font-weight: 700;
                    color: var(--ases-green, #216e97); background: var(--ases-green-pale, #e6f0f8);
                    border-radius: 999px; padding: 3px 10px; }
.ases-dash-mini   { display: flex; gap: 8px; margin: 14px 0 4px; }
.ases-dash-mini .t{ flex: 1; background: #f6f9fb; border: 1px solid #eef2f5; border-radius: 11px; padding: 9px; text-align: center; }
.ases-dash-mini .t b { display: block; font-size: 17px; color: var(--ases-green, #216e97); }
.ases-dash-mini .t span { font-size: 11px; color: #7a8a94; }
.ases-dash-prog   { height: 7px; background: #eef2f5; border-radius: 30px; overflow: hidden; margin: 12px 0 4px; }
.ases-dash-prog i { display: block; height: 100%; background: var(--ases-lime, #a8e10c); }
.ases-dash-nextlvl{ font-size: 11.5px; color: #7a8a94; }
.ases-dash-nav    { display: flex; flex-direction: column; gap: 2px; margin-top: 14px; }
.ases-dash-nav a  { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 11px; min-height: 44px;
                    color: var(--ases-ink, #15212b); text-decoration: none; font-weight: 700; font-size: 14px; transition: .15s; }
.ases-dash-nav a:hover      { background: #f6f9fb; }
.ases-dash-nav a.is-active  { background: var(--ases-green-pale, #e6f0f8); color: var(--ases-green, #216e97); }
.ases-dash-nav a.danger     { color: #b3261e; }
.ases-acct-empty  { color: #7a8a94; margin: 0; font-size: 14px; line-height: 1.9; }

/* Desktop: sticky finally works, now that <main> no longer creates a scroll container. */
@media (min-width: 992px) { .ases-dash-side { position: sticky; top: 24px; } }

@media (max-width: 991.98px) {
  /* minmax(0,1fr), not 1fr: `1fr` is minmax(AUTO,1fr), so the track floors at the item's
     min-content width — the 1300px chip row would blow the single column out to 1300px and
     the chips would clip instead of scrolling. */
  .ases-dash { grid-template-columns: minmax(0, 1fr); gap: 12px; }

  /* rail becomes a compact sticky bar at the top of every account page.
     min-width:0 is load-bearing: a grid item defaults to min-width:auto, so the chip row
     would size the rail to its own 1300px content and CLIP instead of scrolling. */
  .ases-dash-side { position: sticky; top: 0; z-index: 6; padding: 10px 12px 8px; min-width: 0;
                    border-radius: 0 0 16px 16px; box-shadow: 0 10px 24px -20px rgba(12, 37, 54, .5); }

  .ases-dash-id       { display: flex; align-items: center; gap: 10px; text-align: start; padding: 0 0 8px; }
  .ases-dash-id .av   { width: 40px; height: 40px; font-size: 17px; margin: 0; flex: none; }
  .ases-dash-idtxt    { min-width: 0; }
  .ases-dash-id .nm   { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ases-dash-id .em   { display: none; }
  .ases-dash-id .lvl  { margin: 0 0 0 auto; flex: none; }

  /* points already lead the page in the KPI row — don't show them twice */
  .ases-dash-stats    { display: none; }

  /* vertical rail -> horizontal chip scroller */
  .ases-dash-nav { flex-direction: row; gap: 6px; margin: 8px 0 0; overflow-x: auto; min-width: 0; max-width: 100%;
                   overscroll-behavior-x: contain; scroll-snap-type: x proximity; scrollbar-width: none;
                   -webkit-overflow-scrolling: touch; }
  .ases-dash-nav::-webkit-scrollbar { display: none; }
  .ases-dash-nav a { flex: 0 0 auto; scroll-snap-align: start; padding: 9px 13px; border: 1px solid #e4ecf1;
                     border-radius: 999px; font-size: 13px; white-space: nowrap; }
  .ases-dash-nav a.is-active { border-color: var(--ases-green, #216e97); }
}

/* Compact account hero. .ases-page-hero is clamp(130px,16vh,220px) top — that minimum exists because
   .ul-header-bottom is absolutely positioned over it. The header is ~79px tall at <=1199px, so 96px
   clears it with room to spare and reclaims ~112px above the fold. */
.ases-page-hero--acct { padding: clamp(96px, 12vh, 150px) 0 clamp(24px, 3vw, 40px); }
.ases-page-hero--acct h1 { font-size: clamp(21px, 2.4vw, 32px); margin: 0 0 8px; }
.ases-page-hero--acct .ases-breadcrumb { font-size: 12.5px; }
.ases-acct-section { padding-top: clamp(18px, 2vw, 34px) !important; padding-bottom: clamp(40px, 5vw, 90px) !important; }

/* These cards sit behind auth and above the fold — a 1s entrance animation on each is pure
   perceived latency on a dashboard. Keep wow on marketing pages. */
.ases-dash .ases-acct-card.animate__fadeInUp,
.ases-dash .ases-kpis.animate__fadeInUp,
.ases-dash-side.animate__fadeInUp { animation: none !important; visibility: visible !important; }

/* =============================================================================
   9. FIXED OVERLAYS ON PHONES — three shipped panels/FABs that overlap the
      viewport edge or each other. All three were found by measuring, not reading.
   ============================================================================= */

/* #33 — .ases-mnotif-panel is 330px wide and anchored to the BELL, not the viewport.
   `max-width:88vw` caps its width but not where it starts, so on a phone it runs off
   the inline edge and html{overflow-x:clip} silently amputates the part that hangs
   over. Detach it from the bell and pin it to the viewport instead. */
@media (max-width: 575.98px) {
  .ases-mnotif-panel {
    position: fixed;
    top: auto;
    inset-inline: 10px;
    width: auto;
    max-width: none;
    max-height: min(70vh, 460px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* #34 — .ases-a11y-panel sizes its width but not its height. With the shipped 8 tools
   it is ~457px tall and grows upward from `bottom:66px` inside a FAB that already sits
   88px up, so on a landscape phone its header (Close / Reset) and the text-size stepper
   render ABOVE the top of the viewport and cannot be reached at all. Its sibling
   .ases-chat-panel already does this correctly with height:min(540px, 100vh - 130px). */
.ases-a11y-panel {
  max-height: min(520px, calc(100vh - 130px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* #50 — the sitewide ad strip is fixed to the bottom across the full width, and its
   30x30 dismiss button sits at the inline end — directly under the 56px chat FAB in
   LTR, so the ad cannot be dismissed. Lift the FAB stack above the strip when a strip
   is present (body gets .has-adstrip) and move the X clear of it. */
@media (max-width: 767.98px) {
  body.has-adstrip .ases-chat,
  body.has-adstrip .ases-a11y { bottom: calc(84px + env(safe-area-inset-bottom)) !important; }
  .ases-adstrip-x { inset-inline-end: 6px; top: 6px; transform: none; }
}

/* =============================================================================
   10. NARROW-SCREEN SPACING — two places where a desktop measurement was applied
       unconditionally, so a phone either wasted the width or ran two elements
       into each other. Both were measured at 360px before and after.
   ========================================================================== */

/* 10a. The featured-event card is a hero: min-height 380px, content aligned to
   the BOTTOM, with the date chip and the «الأقرب» tag pinned at top:16px. On a
   wide card the two zones never meet. On a phone the title wraps to two lines
   and the body to five, so the content block grows upward until it sits under
   the pinned chips — measured at 360px, the date chip (278→329, y 9293→9346)
   covered 41×28px of the category pill and the right end of the first title
   line. Reserving the chip band as top padding keeps the card a single column
   with nothing overlapping; the height is no longer forced, so short cards stop
   carrying 380px of empty gradient. */
@media (max-width: 575.98px) {
    .ases-ev-spot { min-height: 0; }
    .ases-ev-spot-in { padding: 88px 18px 22px; }
    /* the two chips keep their pinned positions but no longer need to compete
       for the same band — give the date chip the start edge it already claims */
    .ases-ev-spot-tag,
    .ases-ev-cal { top: 18px; }
    /* 26px of side padding on a 330px card left 278px for text; 18px leaves 294 */
    .ases-ev-spot-in h3 { line-height: 1.35; }
}

/* 10b. .ul-footer-about carries max-width: clamp(267px, 14.19vw, 270px). The
   clamp FLOOR applies at every viewport, so inside the 330px footer column of a
   360px phone the about paragraph and the logo above it were pinned to 267px —
   63px, a fifth of the column, left empty down the whole block. The cap is a
   desktop column measure; below the point where the footer becomes one column
   there is no second column to protect. */
@media (max-width: 767.98px) {
    .ul-footer-about { max-width: none; }
}

/* 10c. The «إطلاق تجريبي» bar centres its text between padding-inline 46px / 18px, but the ✕
   dismiss button is pinned at inset-inline-end:12px and is 23px wide — so it needs ~35px of
   clearance on the END side, which is exactly the side given the SMALLER padding. The banner
   text ran under the button by 8px. Reserve the button's own band instead. */
@media (max-width: 575.98px) {
    .ases-betabar { padding-inline-end: 44px; }
}

/* =============================================================================
   11. TEAM GRID — a steady three across, instead of as many as fit.
   ========================================================================== */

/* .ases-team-grid is repeat(auto-fit, minmax(230px, 1fr)): on a 1200px content column that packs
   FIVE cards into the first row and strands the sixth alone on the second — which is exactly how
   the page looked. A team is a small, fixed set of people, not a feed, so it wants a deliberate
   rhythm rather than whatever fits: three across divides 6, 9 and 12 evenly, and gives each face
   enough width to read at a glance. Two across on tablets, one on phones — unchanged there. */
@media (min-width: 992px) {
    .ases-team-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 576px) and (max-width: 991.98px) {
    .ases-team-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* With three per row each card is ~380px instead of ~230, so the portrait no longer has to be a
   tall crop to fill it — cap it and keep the face centred rather than stretching the photo. */
@media (min-width: 992px) {
    .ases-team-card { max-width: 420px; margin-inline: auto; width: 100%; }
}
