/* ══════════════════════════════════════════════════════════════════
   dashboard-analysis.css — in-map PJT (AOI) analysis panel.

   Opened by clicking an AOI tree card OR its map marker (dashboard-
   assessments.js dispatches `ngip:open-pjt`; pjt-analysis-panel.js
   builds this DOM inside .dash-map). A dimmed backdrop over the map
   closes on outside click. The card is edge-anchored (NOT a fixed
   16:9): height = the folder-tree panel (top/bottom 14px), width runs
   from just right of the Layers toggle to just left of the tree.

   Price-Analysis-style tabs (mirrors .pr-ctab): Overview | Details.
   ══════════════════════════════════════════════════════════════════ */

/* Sizing knobs — see the geometry note above (.dash-map coordinate space). */
:root {
  --dpa-gap:      14px;   /* equal gap from the Layers toggle (left) + tree (right) */
  --dpa-left:     70px;   /* Layers toggle right edge (~56) + gap */
  --dpa-right:    268px;  /* tree width (240) + its inset (14) + gap */
}

.dpa-root {
  position: absolute;
  inset:    0;
  z-index:  var(--z-raised);          /* above the tree (800) + legend (850) */
  display:  none;
}
.dpa-root.dpa-open { display: block; }

.dpa-backdrop {
  position:   absolute;
  inset:      0;
  background: var(--scrim);
  cursor:     pointer;     /* click the dimmed map to close */
}

/* ── The card ─────────────────────────────────────────────────────── */
.dpa-card {
  position:       absolute;
  top:            var(--dpa-gap);
  bottom:         var(--dpa-gap);
  left:           var(--dpa-left);
  right:          var(--dpa-right);
  display:        flex;
  flex-direction: column;
  background:     var(--bg1);
  border:         1px solid var(--bdr2);
  border-radius:  var(--radius);
  box-shadow:     var(--sh-modal);
  overflow:       hidden;
}

/* ── Header: tabs · title · close ─────────────────────────────────── */
.dpa-head {
  flex-shrink:   0;
  display:       flex;
  align-items:   center;
  gap:           12px;
  padding:       var(--space-md) var(--space-xl);
  border-bottom: 1px solid var(--bdr);
}
.dpa-tabs { display: inline-flex; gap: 6px; flex-shrink: 0; }
.dpa-tab {
  font-size:     var(--fs-sm);
  font-weight:   600;
  color:         var(--t1);
  padding:       var(--space-sm) var(--space-xl);
  border:        none;
  border-radius: var(--radius);
  background:    none;
  cursor:        pointer;
  font-family:   inherit;
  transition:    color .12s, background .12s;
}
.dpa-tab:hover:not(.active) { background: var(--bg2); color: var(--t0); }
.dpa-tab.active             { color: var(--on-acc); background: var(--acc); }

.dpa-title {
  flex:          1;
  min-width:     0;
  text-align:    right;
  font-size:     var(--fs-sm);
  font-weight:   600;
  color:         var(--t0);
  white-space:   nowrap;
  overflow:      hidden;
  text-overflow: ellipsis;
}
.dpa-title-sub { font-weight: 400; color: var(--t2); font-size: var(--fs-micro); }
.dpa-close {
  flex-shrink:     0;
  display:         flex;
  align-items:     center;
  justify-content: center;
  width:           26px;
  height:          26px;
  padding:         0;
  color:           var(--t2);
  background:      none;
  border:          none;
  border-radius:   var(--radius);
  cursor:          pointer;
}
.dpa-close:hover { color: var(--t0); background: var(--bg2); }

/* ── Body / panes ─────────────────────────────────────────────────── */
.dpa-body { flex: 1; min-height: 0; }
.dpa-pane { display: none; height: 100%; box-sizing: border-box; }
.dpa-pane.active { display: block; }

/* Overview: full-width stat strip on top, then map (left) + rail (right). */
.dpa-ov {
  display:        flex;
  flex-direction: column;
  gap:            10px;
  height:         100%;
  padding:        var(--space-xl);
  box-sizing:     border-box;
}
.dpa-ov-main {
  flex:                  1;
  min-height:            0;
  display:               grid;
  grid-template-columns: 1fr 1fr;         /* 5:5 — route map | Key Takeaways */
  grid-template-rows:    minmax(0, 1fr);  /* pin the row to the flex height — else the
                                             implicit auto row grows to content (the tall
                                             Key Takeaways read) and overflows the card */
  gap:                   12px;
}

/* Left column: the best-netback ROUTE map — "carried by <operator>" head, the
   route mini-map, and the pipeline chain caption below (mirrors the AOI Routes
   card). Flex column so the map fills the space between head + caption. */
.dpa-route-col {
  display:        flex;
  flex-direction: column;
  min-height:     0;
  min-width:      0;
  gap:            6px;
}
.dpa-route-head {
  flex-shrink: 0;
  font-size:   var(--fs-micro);
  color:       var(--t1);
  line-height: 1.3;
}
.dpa-route-head b        { color: var(--t0); font-weight: 700; }
.dpa-route-head-dim      { color: var(--t2); }
.dpa-route-box {
  position:      relative;
  flex:          1 1 auto;
  min-height:    0;
  border-radius: var(--radius);
  overflow:      hidden;
  border:        1px solid var(--bdr);
  background:    var(--bg2);
}
.dpa-map { position: absolute; inset: 0; }
/* Placeholder / loading state — fills the map box. */
.dpa-route-empty {
  position:        absolute;
  inset:           0;
  display:         flex;
  align-items:     center;
  justify-content: center;
  text-align:      center;
  padding:         var(--space-xl);
  font-size:       var(--fs-micro);
  color:           var(--t2);
  line-height:     1.5;
}
.dpa-route-loading { font-style: italic; }

/* Pipeline chain caption (dpa-cap-*) — via › joint › target ‹type› › hub pill,
   colour-keyed to the drawn route. */
.dpa-route-cap {
  flex-shrink: 0;
  display:     flex;
  flex-wrap:   wrap;
  align-items: center;
  gap:         4px 6px;
  font-size:   var(--fs-micro);
  color:       var(--t1);
  line-height: 1.5;
}
.dpa-cap-node    { display: inline-flex; align-items: center; gap: 4px; color: var(--t0); font-weight: 600; }
.dpa-cap-dot     { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }
.dpa-cap-node em { font-style: normal; color: var(--t2); font-weight: 500; font-size: var(--fs-2xs); }
.dpa-cap-sep     { color: var(--t2); opacity: .7; }
.dpa-cap-joint   { color: var(--t2); font-style: italic; }
.dpa-cap-hub {
  display:       inline-block;
  padding:       1px 8px;
  font-weight:   700;
  color:         var(--acc);
  background:    color-mix(in srgb, var(--acc) 14%, transparent);
  border-radius: var(--radius);
}
.dpa-cap-note { color: var(--t2); font-style: italic; }

/* Market chip on the map ("ANR-SE →") — neutralise the default leaflet div-icon
   frame, then draw our own pill. */
.dpa-route-chip-ic { background: transparent !important; border: 0 !important; }
.dpa-route-chip {
  display:       inline-flex;
  align-items:   center;
  gap:           4px;
  white-space:   nowrap;
  padding:       2px 8px;
  font-size:     var(--fs-2xs);
  font-weight:   700;
  color:         var(--t0);
  background:    var(--bg1);
  border:        1px solid var(--bdr2);
  border-radius: 999px;
  box-shadow:    var(--sh-raised);
}
.dpa-route-chip-arr { color: var(--acc); font-weight: 800; }

/* Map controls (focus mask / Color toggle / Layers / zoom skin) moved to the
   shared components/analysis-map.css — the analysis-map factory renders them
   (amap-*). Only the panel-local hosts remain below. */

/* Operator legend — now lives in the RIGHT RAIL (below Key Takeaways), not on
   the map, so the area map stays clean for power/upstream layers later. Vertical
   list of the parent operators whose pipelines intersect the AOI box:
     · click a row  → isolate that operator on the map (spotlight; click again clears)
     · the eye icon → hide / show that operator's pipelines
     · Reset        → clear all isolation + hides */
.dpa-legend {
  display:        flex;
  flex-direction: column;
  min-height:     90px;
  flex:           1 1 auto;   /* fill the remaining rail height */
  gap:            5px;
}
/* Right rail: hero stat strip + Key Takeaways + operator legend.
   overflow hidden so the operator list (flex:1) scrolls inside itself rather
   than pushing the rail. */
.dpa-side { display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow: hidden; }

/* One row of three: Basin/State · Benchmark · Best Netback. Numbers are MOCK
   until the economics port lands (pjt-analysis-panel.js mockEcon). */
.dpa-stats {
  flex-shrink:           0;
  display:               grid;
  grid-template-columns: repeat(5, 1fr);
  gap:                   8px;
}
.dpa-stat {
  display:        flex;
  flex-direction: column;
  gap:            3px;
  min-width:      0;
  padding:        var(--space-md) var(--space-xl);
  background:     var(--bg2);
  border:         1px solid var(--bdr);
  border-radius:  var(--radius);
}
.dpa-stat-lbl {
  font-size:      var(--fs-2xs);
  font-weight:    700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color:          var(--t2);
}
.dpa-stat-val {
  font-family: var(--font-num);
  font-size:   var(--fs-md);
  font-weight: 700;
  line-height: 1.15;
  color:       var(--t0);
  overflow-wrap: anywhere;
  overflow:      hidden;   /* never paint past the cell's right padding */
}
.dpa-stat.num .dpa-stat-val { font-size: var(--fs-lg); white-space: nowrap; }
.dpa-stat.hero .dpa-stat-val { color: var(--acc); }
/* Basis vs HH sign colours (the basis cell is not .hero, so no clash). */
.dpa-stat-val.pos { color: var(--ok);  }
.dpa-stat-val.neg { color: var(--err); }
.dpa-stat-sub {
  font-size:     var(--fs-micro);
  color:         var(--t2);
  white-space:   nowrap;
  overflow:      hidden;
  text-overflow: ellipsis;
}
/* Best-outlet hub name as an accent chip in the sub (mirrors AOI's .s-hub). */
.dpa-stat-hub {
  display:        inline-block;
  padding:        var(--space-2xs) var(--space-sm);
  font-weight:    600;
  color:          var(--acc);
  background:     color-mix(in srgb, var(--acc) 14%, transparent);
  border-radius:  var(--radius);
  vertical-align: middle;
}
.dpa-stat-hub:empty { display: none; }

/* Key Takeaways — fills the rail below the stat strip; the head stays pinned and
   the analyst read scrolls inside itself (the rail is overflow:hidden, so without
   this the long read overflowed the card and the tail was clipped). */
.dpa-kt { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 6px; }
.dpa-kt-head {
  flex-shrink:    0;
  font-size:      var(--fs-2xs);
  font-weight:    700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color:          var(--t2);
}
.dpa-kt-mock { color: var(--t2); opacity: .7; font-weight: 600; text-transform: none; letter-spacing: 0; }
.dpa-kt-item {
  display:       flex;
  gap:           7px;
  align-items:   flex-start;
  padding:       var(--space-sm) var(--space-md);
  font-size:     var(--fs-micro);
  line-height:   1.45;
  color:         var(--t1);
  background:    var(--bg2);
  border-radius: var(--radius);
}
.dpa-kt-item strong { color: var(--t0); font-weight: 700; }
.dpa-kt-ic {
  flex-shrink: 0;
  display:     inline-flex;
  align-items: center;
  margin-top:  2px;
  color:       var(--acc);
}
.dpa-kt-ic svg { width: 13px; height: 13px; }
.dpa-kt-loading,
.dpa-kt-empty {
  padding:     var(--space-md);
  font-size:   var(--fs-micro);
  line-height: 1.5;
  color:       var(--t2);
}
/* Key Takeaways = LIORA's Analyst Read (server HTML) — SAME structure as the
   /assessment Overview's .aoi-analyst-read, sized down for the compact rail so
   the panel and the AOI page read as one report. */
/* Match the AOI Overview's analyst read — responsive ~12.5→16px (--rpt-lg lives
   in assessment.css which the dashboard doesn't load, so inline the same clamp as
   a fallback). Was too small (--fs-2xs ≈ 9px). */
.dpa-kt .aoi-analyst-read { flex: 1 1 auto; min-height: 0; overflow-y: auto; font-size: var(--rpt-lg, clamp(12.5px, 0.5vw + 3.2px, 16px)); line-height: 1.55; color: var(--t1); }
.dpa-kt .aoi-analyst-read > p { margin: 0 0 12px; color: var(--t0); font-weight: 500; }
.dpa-kt .aoi-analyst-read ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.dpa-kt .aoi-analyst-read li { position: relative; padding-left: 18px; }
.dpa-kt .aoi-analyst-read li::before { content: ""; position: absolute; left: 2px; top: .6em;
  width: 7px; height: 7px; border-radius: 2px; background: var(--acc); }
.dpa-kt .aoi-analyst-read strong { color: var(--t0); font-weight: 600; }
.dpa-kt .aoi-analyst-read li > strong:first-child { color: var(--acc); font-weight: 700; }
.dpa-kt .aoi-analyst-read a { color: var(--acc); text-decoration: none; }
.dpa-kt .aoi-analyst-read a:hover { text-decoration: underline; }

/* "Details" tab is a deep-link to the full AOI screen, not an in-panel pane —
   an external-open arrow marks it as navigation, and it never gets .active. */
.dpa-tab-link { display: inline-flex; align-items: center; gap: 4px; }
.dpa-tab-ext  { opacity: .55; }

/* Details pane (increment 2) — placeholder for now. */
.dpa-details-stub { padding: var(--space-2xl); font-size: var(--fs-caption); color: var(--t2); }

/* ── Narrow fallback (full mobile reconstruction is a later task) ──── */
@media (max-width: 900px) {
  .dpa-card { left: 12px; right: 12px; top: 12px; bottom: 12px; }

  /* Header: the title gets its own FULL-WIDTH second row under the tabs
     (hairline in between) instead of being crushed to "Haynesville — C…"
     beside them. Desktop keeps the inline single-row header. */
  .dpa-head  { flex-wrap: wrap; padding: var(--space-md) var(--space-xl) 0; }
  .dpa-close { margin-left: auto; }
  .dpa-title {
    order:       3;
    flex:        1 1 100%;
    min-width:   100%;
    text-align:  left;
    white-space: normal;      /* never hide the name — wrap if it must */
    overflow:    visible;
    border-top:  1px solid var(--bdr);
    padding:     var(--space-md) 0 var(--space-md);
  }

  /* One scrolling column: stats → map (fixed height) → takeaways → legend.
     .dpa-ov-main must take its CONTENT height here (flex:none) — with the
     desktop flex:1 it is pinned to the leftover viewport space and the grid
     content overflows it, painting the map OVER the takeaways below. */
  .dpa-ov { overflow: auto; }
  .dpa-ov-main {
    flex:                  none;
    min-height:            0;
    grid-template-columns: 1fr;
    grid-auto-rows:        auto;
  }
  /* Route column stacks under the stats; the map box takes a fixed height while
     the "carried by" head + chain caption sit at natural height around it. */
  .dpa-route-col { min-height: 0; }
  .dpa-route-box { flex: none; min-height: 0; height: 220px; }
  /* The rail stacks under the map and scrolls with the sheet — natural
     heights, no inner scroll boxes. */
  .dpa-side        { overflow: visible; }
  .dpa-legend      { flex: none; min-height: 0; }
  .dpa-legend-list { overflow: visible; }

  /* Stat strip → one clean row split by hairlines (mirrors the AOI Overview
     mobile band): Best Netback hero (wider, accent) · Hub Price · Basis. No
     cards — transparent cells with dividers. */
  .dpa-stats {
    display:               flex;
    grid-template-columns: none;   /* drop the desktop grid — 5 KPIs won't fit fixed */
    gap:                   0;
    align-items:           stretch;
    overflow-x:            auto;
    scroll-snap-type:      x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width:       none;
  }
  .dpa-stats::-webkit-scrollbar { display: none; }
  .dpa-stat {
    flex:          0 0 auto;
    width:         max-content;
    max-width:     70vw;
    background:    transparent;
    border:        none;
    border-radius: 0;
    padding:       0 var(--space-xl);
    min-width:     0;
    scroll-snap-align: start;
  }
  .dpa-stat + .dpa-stat { border-left: 1px solid var(--bdr); }   /* dividers between cells */
  .dpa-stat:last-child  { padding-right: 0; }
  /* Pinned hero — Best Netback stays flush at the left edge while the rest scroll
     behind it; opaque bg hides the scrollers, soft right shadow sells the depth
     (mirrors the AOI Overview mobile band). */
  .dpa-stat.hero {
    position:     sticky;
    left:         0;
    z-index:      3;
    padding-left: 0;
    background:   var(--bg1);
    box-shadow:   6px 0 10px -6px color-mix(in srgb, var(--shadow, #000) 22%, transparent);
    border-left:  none;
  }
  .dpa-stat.hero .dpa-stat-val,
  .dpa-stat.hero.num .dpa-stat-val      { font-size: var(--fs-2xl); line-height: 1.05; }
  .dpa-stat:not(.hero).num .dpa-stat-val { font-size: var(--fs-md); }
}
