/* ═══ Assessment — mobile ═══════════════════════════════════════════
   mobile (<=900px) view-only report.

   Part 7 of 9 of what was one 3,418-line static/css/pages/assessment.css
   (audit C3). LOAD ORDER IS LOAD-BEARING -- for CSS the cascade IS the
   behaviour, so two rules of equal specificity are decided by which came
   last. templates/base.html links them in exactly this sequence:

     shell -> panels -> tree -> overview -> tabs -> routes -> mobile -> region -> demand

   Moving a rule between these files, or reordering the links, can change
   rendering even though nothing was edited. tests/test_css_split.py holds
   the order and the byte content.
   ═══════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════════
   Mobile (≤900px) — VIEW-ONLY report
   · No editing on phones: every edit affordance (Add New Area, the Edit
     masthead button, per-node delete) is hidden.
   · The left folder-tree sidebar becomes a bottom-docked DRAWER that floats
     up when its header bar is tapped — mirrors the Dashboard Assessments
     panel (.dap). Default = collapsed to the header bar; the report/landing
     map fills the screen behind it.
   ═══════════════════════════════════════════════════════════════════ */

/* Count badge + fold chevron in the sidebar header — mobile-only chrome. */
.aoi-lp-count,
.aoi-lp-chev { display: none; }

@media (max-width: 900px) {
  /* Stack: the in-flow selector trigger on top, content below.
     Flat background (white in light mode via --bg1) — no grey canvas band
     behind the trigger; the page reads uniform like LIORA's Ask. */
  .aoi-layout {
    position:       relative;
    flex-direction: column;
    background:     var(--bg1);
    height:   calc(100vh  - var(--nav-h));
    height:   calc(100dvh - var(--nav-h));
  }

  /* Content area fills below the trigger. Own stacking context (z:0) so its
     inner z-indexes (Leaflet "Search location…" control) can't paint over the
     open dropdown menu, which lives in the sidebar above it (z:10). */
  .aoi-main {
    order:         1;
    margin:        0;
    border:        none;
    border-radius: 0;
    box-shadow:    none;
    position:      relative;
    z-index:       0;
    min-height:    0;
  }

  /* ── Selector = an in-flow, text-style dropdown (LIORA model-picker feel) ──
     A plain "Areas of Interest ▾" trigger DOCKED at the top — not a floating
     pill. Tapping opens the tree as a dropdown card below it. Identical on the
     landing and the report screens. */
  .aoi-sidebar {
    order:         -1;               /* top of the column */
    position:      relative;         /* the open menu anchors to this */
    flex:          0 0 auto;
    align-items:   flex-start;       /* trigger hugs its text, doesn't stretch */
    width:         auto;
    max-height:    none;
    margin:        0;
    padding:       var(--space-lg) var(--space-xl) 0;
    background:    transparent;      /* flush — no card, no shadow, no float */
    border:        none;
    border-radius: 0;
    box-shadow:    none;
    overflow:      visible;
    z-index:       10;               /* above .aoi-main for the open menu */
  }

  /* Trigger — copied verbatim from LIORA's .ins-mobile-trigger: a flat
     text+chevron switcher (BLACK label, GREY icon + chevron), transparent
     (no background band), only a faint press/open tint. */
  .aoi-lp-hdr {
    display:       inline-flex;
    align-items:   center;
    gap:           var(--space-sm);
    width:         auto;
    margin-left:   -4px;             /* optically align the icon to the edge */
    padding:       var(--space-xs) var(--space-md) var(--space-xs) var(--space-sm);
    border:        none;
    border-radius: var(--radius);
    background:    transparent;
    color:         var(--t0);
    font-family:   var(--font-sans);
    font-size:     var(--fs-base);
    font-weight:   600;
    cursor:        pointer;
  }
  .aoi-lp-hdr:active,
  .aoi-sb-open .aoi-lp-hdr { background: var(--bg2); }
  .aoi-lp-sub, .aoi-lp-count { display: none; }
  .aoi-lp-name  { font-size: var(--fs-base); font-weight: 600; color: var(--t0); }
  .aoi-lp-badge { width: 17px; height: 17px; background: transparent; color: var(--t2); border-radius: 0; }
  .aoi-lp-badge svg { width: 17px; height: 17px; }
  .aoi-lp-chev {
    display:     inline-flex;
    flex-shrink: 0;
    width:       14px;
    height:      14px;
    color:       var(--t2);
    transition:  transform .18s ease;
  }
  .aoi-lp-chev svg { width: 14px; height: 14px; }
  /* Explicit rotate() both states (transitioning to `none` leaves Chrome
     reporting a stale transform): collapsed ▼ down, open ▲ up. */
  .aoi-lp-chev              { transform: rotate(0deg); }
  .aoi-sb-open .aoi-lp-chev { transform: rotate(180deg); }

  /* ── Tree menu = dropdown card, opens under the trigger (only when open) ── */
  .aoi-sb-menu {
    position:       absolute;
    top:            calc(100% + 4px);
    left:           14px;
    right:          14px;
    flex:           0 0 auto;
    max-height:     min(62vh, 460px);
    display:        flex;
    flex-direction: column;
    background:     var(--bg1);
    border:         1px solid var(--bdr);
    border-radius:  var(--radius);
    box-shadow:     var(--sh-float);
    overflow:       hidden;
    z-index:        50;
  }
  .aoi-sidebar:not(.aoi-sb-open) .aoi-sb-menu { display: none; }

  /* ── View-only: strip every edit affordance ─────────────────────── */
  .aoi-add-area              { display: none; }   /* no "Add New Area" */
  .aoi-mast-r                { display: none; }   /* Edit / New Area masthead buttons */
  .aoi-node-del,
  .aoi-card-del              { display: none; }   /* per-project delete */
  .aoi-node { padding-right: var(--space-md); }

  /* No separate page title — the trigger is the section identity. */
  #aoiEmpty .aoi-land-head { display: none; }

  /* Report masthead — a generous gap under the trigger; project name toned
     down so it doesn't dwarf the selector above it. */
  .aoi-ws-head     { padding-top: 20px; padding-bottom: var(--space-xl); }
  .aoi-rpt-title   { font-size: var(--fs-xl); line-height: 1.1; }
  .aoi-rpt-eyebrow { font-size: var(--fs-2xs); margin-bottom: 5px; }
  .aoi-rpt-sub     { margin-top: var(--space-sm); padding-right: 64px; }  /* clear the EN/KR toggle */

  /* Language switch moves off the tab bar and onto the masthead meta line —
     bottom-aligned, right edge under the close (X). */
  .aoi-sec-lang { display: none; }
  .aoi-ws-head .aoi-mast-lang {         /* higher specificity than the desktop hide */
    display:  flex;
    position: absolute;
    right:    12px;                     /* 2px closer to the right border (past the X) */
    bottom:   calc(var(--space-xl) - 2px);   /* 2px closer to the bottom hairline */
    z-index:  2;
  }

  /* Entry (landing) map — a generous gap under the trigger, 8px side insets. */
  .aoi-land-mapwrap {
    margin:        20px var(--space-md) var(--space-md);
    border-radius: var(--radius);
  }
  /* Phones pinch-zoom a full-screen map — the zoom buttons are just clutter on
     the entry map. The Map/Satellite toggle STAYS: since the entry map moved
     onto the shared analysis-map factory it carries the same layers as the
     Dashboard, and satellite is the one control worth its space on a phone. */
  .aoi-land-mapwrap .leaflet-control-zoom { display: none; }

  /* ── Stat band → pinned hero + horizontal-scroll deck ────────────
     Five KPIs won't fit a phone row. Best Netback stays pinned to the left;
     Hub Price · Basis · Seasonality · Volatility scroll horizontally and slide
     BEHIND the pinned hero (sticky + opaque bg + higher z-index over the same
     page surface). Dividers still hairline; no cards. */
  .aoi-ov2-stats {
    display:               flex;
    grid-template-columns: none;   /* drop the desktop grid */
    gap:                   0;
    align-items:           stretch;
    overflow-x:            auto;
    scroll-snap-type:      x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width:       none;
  }
  .aoi-ov2-stats::-webkit-scrollbar { display: none; }
  /* Every KPI hugs its own content (no fixed column = no dead trailing space),
     and carries a uniform 20px side padding → a consistent 40px gutter between
     each card, dividers centred in it. First card flush to the strip's left
     edge, last flush right, so the row still aligns to the Overview gutter. */
  .aoi-ov2-stat {
    flex:          0 0 auto;
    width:         max-content;
    max-width:     70vw;           /* safety for unusually long content */
    background:    transparent;
    border:        none;
    border-radius: 0;
    padding:       0 20px;
    min-width:     0;
    scroll-snap-align: start;
  }
  .aoi-ov2-stat + .aoi-ov2-stat { border-left: 1px solid var(--bdr); }  /* dividers */
  .aoi-ov2-stat:last-child  { padding-right: 0; }
  /* Pinned hero: stays at the left edge, opaque page-surface bg so the scrolling
     KPIs disappear behind it; a soft right shadow sells the depth. */
  .aoi-ov2-stat.hero {
    position:      sticky;
    left:          0;
    z-index:       3;
    order:         0;
    grid-column:   auto;
    padding-left:  0;                /* pinned flush to the strip's left edge */
    background:    var(--bg1);        /* mobile page surface — hides scrollers behind */
    box-shadow:    6px 0 10px -6px color-mix(in srgb, var(--shadow, #000) 22%, transparent);
    border-left:   none;             /* it's the pinned anchor, no divider on its right sibling side */
  }
  .aoi-ov2-stat.hero .s-lbl { color: var(--acc); }
  .aoi-ov2-stat.hero .s-val { font-size: var(--fs-3xl); line-height: 1.05; }
  .aoi-ov2-stat:not(.hero) .s-val { font-size: var(--fs-lg); color: var(--t0); }
  .aoi-ov2-stat .s-sub { margin-top: 5px; font-size: var(--fs-micro); }
  .aoi-ov2-stat .s-sub .s-hub { margin-left: 0; }   /* chip alone in the sub */

  /* ── One consistent L/R gutter down the whole Overview ────────────
     Stacked on mobile, the stat row + map + legend already sit at the
     .aoi-ov2 gutter (24px). The report rail (Route Economics + Key Takeaways)
     and its inner econ block carry desktop-only side paddings (for the old
     3-column layout) that indent them past that gutter — zero the sides so
     every section lines up left AND right. */
  .aoi-ov2-report { padding-left: 0; padding-right: 0; }
  .aoi-ov-econ    { padding-left: 0; padding-right: 0; }
  /* Trim the report econ table (desktop uses large report type) so its 4
     columns fit inside the gutter instead of scrolling past the right edge. */
  .aoi-rpt-sec .econ-table    { font-size: var(--fs-sm); }
  .aoi-rpt-sec .econ-table th { font-size: var(--fs-2xs); padding-right: var(--space-md); }
  .aoi-rpt-sec .econ-table td { padding: var(--space-lg) var(--space-md) var(--space-lg) 0; }

  /* Drop the card titles on the Overview map + operator-legend cards — the map
     and the operator list speak for themselves on a phone. (The legend keeps
     its own functional "OPERATORS · N / Reset" header inside.) */
  .aoi-ov2-mapcard > .aoi-sec-card-head,
  .aoi-ovleg-card  > .aoi-sec-card-head { display: none; }

  /* ── Price tab (mobile) — charts only, view-only ──────────────────
     Full-width stacked charts; no market-filter controls on a phone. */
  .ph-page.ph-mobile {
    display:        flex;
    flex-direction: column;
    gap:            24px;
    height:         auto;
    /* Match the Overview / Routes gutter: 24px sides (the .aoi-ov2 gutter) and
       a 20px top (Routes' .aoi-econ-wrap top) so the whole report shares one
       consistent inset off the section tab bar. */
    padding:        20px 24px 20px;
  }
  .ph-mobile .ph-charts { border-left: none; padding-left: 0; }
  /* Header: title + blue rule stay on one line; the timeframe buttons wrap to
     their own full-width row underneath (narrow screens can't fit all three). */
  .ph-mobile .ph-charts-head { flex-wrap: wrap; row-gap: var(--space-xl); }
  .ph-mobile .ph-charts-head .ph-exhibit-title { white-space: nowrap; }
  .ph-mobile .ph-charts-head .szn-btns { flex: 0 0 100%; }
  .ph-mobile .ph-chart-sec { padding: var(--space-xl) 0 0; min-height: 0; }
  .ph-mobile .ph-chart-sec + .ph-chart-sec { padding-top: 22px; }
  .ph-mobile .ph-note,
  .ph-mobile .ph-charts > .ph-note { margin-left: 0; }
  /* Drop the dense methodology footnote under the charts on mobile. */
  .ph-mobile #phChartFoot { display: none; }
}

