/* ═══ Assessment — routes ═══════════════════════════════════════════
   Routes screen (rail, focus, mini map, netback waterfall) + Netback Analysis.

   Part 6 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.
   ═══════════════════════════════════════════════════════════════ */

/* ══ Routes — egress + netback, one screen ═══════════════════════ */
.rt-page { display: flex; flex-direction: column; gap: var(--space-xl); min-height: 100%; }

.rt-toolbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.rt-toolbar .aoi-rpt-sec-title { margin: 0; }
.rt-tool-meta {
  margin-left: auto; font-family: var(--font-sans); font-size: var(--fs-micro); color: var(--t2);
  display: flex; align-items: center; gap: var(--space-lg);
}
.rt-tool-meta b { color: var(--t1); }
/* basis label carries a hover tooltip explaining how Hub Price is derived */
.rt-basis-tip { cursor: help; text-decoration: underline dotted; text-underline-offset: 2px; }
.rt-clear-pins {
  font-family: var(--font-sans); font-size: var(--fs-xs); padding: var(--space-2xs) var(--space-md);
  border: 1px solid var(--bdr); border-radius: var(--radius); background: var(--bg1);
  color: var(--t2); cursor: pointer;
}
.rt-clear-pins:hover { border-color: var(--err); color: var(--err); }

.rt-split { display: grid; grid-template-columns: minmax(225px, 3fr) 9fr; gap: 14px;
  align-items: stretch; grid-auto-rows: 1fr; flex: 1 1 auto; min-height: 0; }

/* ── Left rail — ranked route list ── */
.rt-list { display: flex; flex-direction: column; gap: var(--space-sm); min-width: 0; }
.rt-group { display: flex; flex-direction: column; gap: var(--space-sm); }
.rt-group-head {
  display: flex; align-items: center; gap: var(--space-md); margin-top: var(--space-xs); padding: 0 var(--space-2xs);
  font-family: var(--font-sans); font-size: var(--fs-sm); letter-spacing: .04em;
  text-transform: uppercase; color: var(--t1); font-weight: 600;
}
.rt-group-n {
  font-family: var(--font-sans); font-size: var(--fs-xs); color: var(--t2);
  border: 1px solid var(--bdr); border-radius: 20px; padding: 0 var(--space-sm);
}

.rt-item {
  display: flex; align-items: center; gap: var(--space-md); width: 100%; text-align: left;
  padding: var(--space-sm) var(--space-md); border: 1px solid var(--bdr); border-radius: var(--radius);
  background: var(--bg1); cursor: pointer; transition: all .12s; min-width: 0;
}
.rt-item:hover { border-color: var(--bdr2); background: var(--bg2); }
.rt-item.rt-focused { border-color: var(--acc); background: color-mix(in srgb, var(--acc) 6%, transparent); }
.rt-item.rt-best { box-shadow: inset 3px 0 0 var(--ok); }
.rt-item-main { display: flex; flex-direction: column; gap: var(--space-2xs); min-width: 0; flex: 1; }
.rt-item-name {
  font-size: var(--fs-caption); font-weight: 600; color: var(--t0);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: var(--space-sm);
}
.rt-item-sub { display: flex; align-items: center; gap: var(--space-sm); min-width: 0; }
.rt-hops { font-size: var(--fs-3xs); letter-spacing: 1px; color: var(--acc); flex: none; }
.rt-item-nb {
  flex: none; font-family: var(--font-num); font-size: var(--fs-sm); font-weight: 700;
  color: var(--t0); text-align: right; white-space: nowrap;
}
.rt-item-nb small { font-size: var(--fs-2xs); font-weight: 400; color: var(--t2); margin-left: var(--space-2xs); }
.rt-best-tag {
  font-family: var(--font-badge); font-size: var(--fs-3xs); color: var(--ok);
  border: 1px solid color-mix(in srgb, var(--ok) 45%, transparent);
  border-radius: var(--radius); padding: var(--space-2xs) var(--space-xs); flex: none;
}
.rt-pin {
  flex: none; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: var(--radius); color: var(--t2);
  font-size: var(--fs-sm); transition: all .12s;
}
.rt-pin:hover { border-color: var(--bdr2); color: var(--t1); }
.rt-pin.on { border-color: var(--acc); color: var(--acc); background: color-mix(in srgb, var(--acc) 10%, transparent); }

/* ── Right — focus detail ── */
/* fills the tab body vertically: the map region grows to the bottom instead of
   leaving dead space under the cards on tall screens */
.rt-detail { min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.rt-compare { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-xl);
  flex: 1 1 auto; grid-auto-rows: 1fr; }
.rt-detail-card {
  border: 1px solid var(--bdr); border-radius: var(--radius); background: var(--bg1);
  padding: var(--space-2xl) 18px; display: flex; flex-direction: column; gap: var(--space-xl); min-width: 0; min-height: 0;
}
/* map + caption stack; the map takes the slack so the card reaches the bottom */
.rt-compare .rt-strip { flex: 1 1 auto; min-height: 190px; display: flex; flex-direction: column; }
.rt-compare .rt-map { flex: 1 1 auto; height: auto; min-height: 170px; }
.rt-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-xl); flex-wrap: wrap; }
.rt-detail-title { display: flex; align-items: center; gap: var(--space-md); flex-wrap: wrap; min-width: 0; }
.rt-detail-name { font-size: var(--fs-lg); font-weight: 700; color: var(--t0); }
.rt-detail-nums { display: flex; align-items: center; gap: var(--space-2xl); }
.rt-detail-nb { display: flex; flex-direction: column; align-items: flex-end; }
.rt-detail-nb-val { font-family: var(--font-num); font-size: var(--fs-3xl); font-weight: 700; color: var(--t0); line-height: 1; }
.rt-detail-nb-lbl { font-size: var(--fs-2xs); color: var(--t2); text-transform: uppercase; letter-spacing: .05em; margin-top: 3px; }
.rt-detail-prem {
  font-family: var(--font-sans); font-size: var(--fs-base); font-weight: 600; color: var(--t2);
  display: flex; flex-direction: column; align-items: flex-end;
}
.rt-detail-prem span { font-size: var(--fs-2xs); font-weight: 400; text-transform: uppercase; letter-spacing: .05em; color: var(--t2); margin-top: 3px; }
.rt-detail-prem.pos { color: var(--ok); }
.rt-detail-prem.neg { color: var(--err); }
.rt-detail-op { font-family: var(--font-sans); font-size: var(--fs-micro); color: var(--t2); margin-top: -4px; }
.rt-detail-op b { color: var(--t1); font-weight: 600; }

.rt-sec-lbl {
  font-family: var(--font-sans); font-size: var(--fs-xs); letter-spacing: .06em;
  text-transform: uppercase; color: var(--t2);
  padding-bottom: var(--space-xs); border-bottom: 1px solid var(--bdr);
}
.rt-detail-alt { color: var(--t2); font-weight: 400; }
.rt-group-empty {
  font-size: var(--fs-caption); color: var(--t1); font-style: italic;
  padding: var(--space-sm) var(--space-lg); border: 1px dashed var(--bdr); border-radius: var(--radius);
}

/* ── Physical path — focused-route mini map ── */
.rt-strip { padding: var(--space-2xs) 0; }
.rt-map {
  position: relative; height: 200px; background: var(--bg2);
  border: 1px solid var(--bdr); border-radius: var(--radius); overflow: hidden; z-index: 0;
}
.rt-map-lg { height: 360px; }
.rt-line-cap {
  margin-top: 9px; font-size: var(--fs-body); line-height: 1.7;
}
.rt-cap-node { font-weight: 500; color: var(--t0); }
.rt-cap-node em { font-style: normal; font-weight: 400; font-size: var(--fs-micro); color: var(--t2); }
.rt-cap-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 2px;
  margin-right: 5px; vertical-align: middle;
}
.rt-cap-sep { color: var(--t2); font-size: var(--fs-sm); margin: 0 5px; }
.rt-cap-joint { font-size: var(--fs-micro); color: var(--t1); }
.rt-cap-hub {
  font-size: var(--fs-micro); font-weight: 500; color: var(--t0);
  border: 1px solid var(--acc); border-radius: var(--radius); padding: var(--space-2xs) var(--space-md); white-space: nowrap;
}
.rt-cap-note { font-size: var(--fs-micro); color: var(--t2); }

/* Solo focus — map left (large), header + waterfall right, so a single route
   card keeps compare-card proportions instead of ballooning to full width */
.rt-solo { display: grid; grid-template-columns: 5fr 4fr; gap: 20px; align-items: stretch;
  flex: 1 1 auto; grid-auto-rows: 1fr; }
.rt-solo-map { min-width: 0; display: flex; flex-direction: column; }
.rt-solo-map .rt-strip { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.rt-solo-map .rt-map-lg { flex: 1 1 auto; height: auto; min-height: 300px; }
.rt-solo-side { min-width: 0; display: flex; flex-direction: column; gap: var(--space-xl); }
@media (max-width: 1180px) {
  .rt-solo { grid-template-columns: 1fr; align-items: start; }
  .rt-solo-map .rt-map-lg { flex: none; height: 260px; }
}

/* ── Netback build-up — vertical waterfall (rows descend, costs step left) ── */
/* cap at the authored viewBox width so the numbers/labels never up-scale past
   their design size on wide cards (esp. Compare's "Netback" row) */
.rt-wf-svg { width: 100%; max-width: 540px; height: auto; display: block; overflow: visible; }
.rt-wf-conn { stroke: var(--t2); stroke-width: 1; stroke-dasharray: 3 3; opacity: .6; }
.rt-wf-axis { stroke: var(--bdr); stroke-width: 1; }
.rt-wf-num { font-family: var(--font-num); font-size: var(--fs-md); font-weight: 700; }
.rt-wf-num-base { fill: var(--t0); }
.rt-wf-num-cost { fill: var(--err); font-weight: 600; }
.rt-wf-num-net  { fill: var(--ok); }
.rt-wf-ylbl { font-size: var(--fs-base); fill: var(--t2); text-anchor: end; }
.rt-wf-ylbl-net { fill: var(--t1); font-weight: 700; }
.rt-nowf { font-size: var(--fs-caption); color: var(--t2); padding: var(--space-lg) 0; }

/* Physical-flow view — full-route frame, chevron stream, market badge */
.rt-map .gf-hub-badge.rt-badge { cursor: pointer; pointer-events: auto; transition: box-shadow .15s, transform .15s; }
.rt-map .gf-hub-badge.rt-badge:hover { box-shadow: 0 1px 6px rgba(0,0,0,.25); transform: translateY(-1px); }
.rt-map .gf-hub-badge.rt-badge-on { background: var(--bg1); }
.rt-badge-wrap { display: inline-block; }
.rt-badge-wrap.rt-badge-onhub { transform: translate(-50%, -24px); }
.rt-flow-pin { background: none; border: none; }
.rt-flow-dot { position: relative; display: block; width: 14px; height: 14px; }
.rt-flow-dot::before {
  content: ''; position: absolute; inset: 3px; border-radius: 50%;
  background: currentColor; box-shadow: 0 0 0 2px #ffffff;
}
.rt-flow-dot::after {
  content: ''; position: absolute; inset: -4px; border-radius: 50%;
  border: 1.5px solid; animation: rt-pulse 2.2s ease-out infinite;
}
.rt-flow-dst::after { inset: -6px; animation-duration: 2.6s; }
@keyframes rt-pulse {
  0%   { transform: scale(.35); opacity: .8; }
  100% { transform: scale(1.6); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  /* .rt-chev stays visible + animating on purpose — see rtStartFlow: the flow
     stream is the core signal, and battery-saver must not hide it. */
  .rt-flow-dot::after { animation: none; opacity: 0; }
}

/* ══ Netback Analysis (Analysis tab) ═════════════════════════════ */
.nba-sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 7px; vertical-align: middle; }
.nba-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: var(--space-xs) 0 var(--space-sm); }
.nba-col { min-width: 0; }
.nba-sub {
  font-family: var(--font-sans); font-size: var(--fs-xs); letter-spacing: .04em; text-transform: uppercase;
  color: var(--t1); margin-bottom: var(--space-lg); display: flex; align-items: baseline; gap: var(--space-md); flex-wrap: wrap;
}
.nba-sub span { text-transform: none; letter-spacing: 0; color: var(--t2); font-size: var(--fs-2xs); }

.nba-wins { display: flex; flex-direction: column; gap: var(--space-md); }
.nba-win-row { display: grid; grid-template-columns: 130px 1fr 34px; align-items: center; gap: var(--space-lg); }
.nba-win-lbl { font-size: var(--fs-micro); color: var(--t1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nba-win-track { height: 12px; background: var(--bg2); border-radius: 3px; overflow: hidden; }
.nba-win-bar { display: block; height: 100%; border-radius: 3px; opacity: .85; }
.nba-win-n { font-family: var(--font-sans); font-size: var(--fs-caption); font-weight: 700; color: var(--t0); text-align: right; }

.nba-insights { margin-top: 14px; display: flex; flex-direction: column; gap: var(--space-md); }
.nba-ins { display: flex; gap: var(--space-md); font-size: var(--fs-caption); color: var(--t1); line-height: 1.5; }
.nba-ins-dot { flex: none; width: 5px; height: 5px; border-radius: 50%; background: var(--acc); margin-top: var(--space-sm); }
.nba-ins b { color: var(--t0); font-weight: 600; }
.nba-thin { font-size: var(--fs-micro); color: var(--t2); font-style: italic; line-height: 1.5; }

.nba-stats { width: 100%; }
.nba-stats .nba-mo { color: var(--t2); font-size: var(--fs-micro); }

.nba-chart-head {
  font-family: var(--font-sans); font-size: var(--fs-xs); letter-spacing: .04em; text-transform: uppercase;
  color: var(--t1); margin: 14px 0 var(--space-md); display: flex; align-items: baseline; gap: var(--space-md);
  border-top: 1px solid var(--bdr); padding-top: var(--space-xl);
}
.nba-chart-head span { text-transform: none; letter-spacing: 0; color: var(--t2); font-size: var(--fs-2xs); }
.nba-chart-wrap { height: 220px; position: relative; }

@media (max-width: 900px) {
  .nba-grid { grid-template-columns: 1fr; }
  .nba-win-row { grid-template-columns: 110px 1fr 30px; }
}

@media (max-width: 900px) {
  .rt-split { grid-template-columns: 1fr; }
  .rt-compare { grid-template-columns: 1fr; }

  /* ── Routes → shopping-style card grid ───────────────────────────
     A 2-column grid of swipeable route cards. The card body (slides + dots)
     sits on a VERY LIGHT GREY fill — no border line, no shadow; the fill alone
     sets the card apart from the white page. Operator + netback sit BELOW the
     fill, on the page (like a product tile's title + price). */
  .rtc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px var(--space-2xl); }
  .rtc-card { display: flex; flex-direction: column; min-width: 0; }
  /* Operator name — the card's OWNER label, sitting just above the grey box
     (outside it) so it reads as the card's title. */
  .rtc-op { font-size: var(--fs-xs); font-weight: 600; letter-spacing: .04em;
            text-transform: uppercase; color: var(--t2);
            margin: 0 0 var(--space-sm) var(--space-2xs);
            max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* the grey card body — SQUARE (no rounded corners); holds only the slides */
  .rtc-box {
    background: var(--bg2); border: none; border-radius: 0;
    padding: var(--space-xl); overflow: hidden;
  }

  /* swipeable slides (native scroll-snap) */
  .rtc-slides {
    display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
    scrollbar-width: none; -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
  }
  .rtc-slides::-webkit-scrollbar { display: none; }
  .rtc-slide { flex: 0 0 100%; min-width: 0; scroll-snap-align: start; box-sizing: border-box;
               padding: 0 0 var(--space-xs); display: flex; flex-direction: column; gap: 7px; }

  /* hub-name title — black (only Net Back is accent-blue), shared by both slides */
  .rtc-hub { display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap;
             font-size: var(--fs-md); font-weight: 700; color: var(--t0);
             white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .rtc-hub .rt-best-tag { flex-shrink: 0; }

  /* slide 1 — clean netback build-up list */
  .rtc-bu { display: flex; flex-direction: column; gap: var(--space-xs); margin-top: 1px; }
  .rtc-bu-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-sm); }
  .rtc-bu-l { font-size: var(--fs-micro); line-height: 1.25; color: var(--t2); min-width: 0; }
  .rtc-bu-v { font-family: var(--font-num); font-size: var(--fs-caption); font-weight: 600; color: var(--t0);
              white-space: nowrap; flex-shrink: 0; }
  .rtc-bu-base .rtc-bu-l { color: var(--t1); }
  .rtc-bu-neg .rtc-bu-v  { color: var(--err); }
  .rtc-bu-net { margin-top: 3px; padding-top: var(--space-xs); border-top: 1px solid var(--bdr); }
  .rtc-bu-net .rtc-bu-l  { color: var(--acc); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; font-size: var(--fs-xs); }
  .rtc-bu-net .rtc-bu-v  { color: var(--acc); font-size: var(--fs-md); font-weight: 700; }

  /* slide 2 — physical-path map + "via" caption */
  .rtc-map { height: 150px; border-radius: var(--radius); }
  /* Always reserve 2 lines (min-height) so a 1-line vs 2-line "via" caption
     doesn't make one card's map slide taller than another's — the slides stretch
     to the tallest sibling, so an uneven caption would give the whole grey box
     (and thus the card) a different height. Fixed 2-line height = uniform cards. */
  .rtc-cap { font-size: var(--fs-micro); line-height: 1.4; color: var(--t2);
             min-height: 2.8em;
             overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
             -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

  /* under-row (below the grey box): centred dots + a ⇄ compare button on the right */
  .rtc-under { position: relative; display: flex; justify-content: center; align-items: center; min-height: 24px; margin-top: var(--space-md); }
  .rtc-dots { display: flex; justify-content: center; gap: 5px; }
  .rtc-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--t2); opacity: .3;
             transition: opacity .2s, width .2s, background .2s, border-radius .2s; cursor: pointer; }
  .rtc-dot.on { opacity: 1; width: 15px; border-radius: 3px; background: var(--acc); }
  /* ⇄ compare button — a subtle, slightly-raised circle (reads as clickable) */
  .rtc-cmp {
    position: absolute; right: 0; top: 50%; transform: translateY(-50%);
    display: flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; padding: 0; border-radius: 50%;
    border: 1px solid var(--bdr); background: var(--bg1); color: var(--t2);
    cursor: pointer; transition: background .14s, color .14s, border-color .14s, box-shadow .14s, transform .1s;
    box-shadow: var(--sh-raised);
  }
  .rtc-cmp:hover  { color: var(--acc); border-color: var(--acc); }
  .rtc-cmp:active { transform: translateY(-50%) scale(.9); }
  .rtc-cmp.on { background: var(--acc); border-color: var(--acc); color: var(--on-acc); }
  /* (Card + detail footers removed — operator moved above via .rtc-op, price dropped
     since Net Back already lives in the build-up.) */

  /* ── 1-column detail sheet (tap a card) / compare (two ⇄-pinned) ──── */
  .rtd-sheet {
    position: fixed; inset: 0; z-index: var(--z-raised);
    display: flex; align-items: flex-end; justify-content: center;
    background: var(--scrim);
  }
  .rtd-sheet[hidden] { display: none; }
  .rtd-panel {
    position: relative; width: 100%; max-height: 92dvh; max-height: 92vh;
    background: var(--bg1); border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 40px rgba(0,0,0,.4);
    overflow-y: auto; -webkit-overflow-scrolling: touch;
    padding: var(--space-xl) var(--space-2xl) calc(20px + env(safe-area-inset-bottom));
  }
  .rtd-close {
    position: sticky; top: 0; margin-left: auto; z-index: 3;
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border: none; border-radius: 50%;
    background: var(--bg2); color: var(--t1); cursor: pointer;
  }
  .rtd-body { margin-top: -18px; }
  .rtd-body.rtd-compare { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2xl); align-items: start; }
  .rtd-block { display: flex; flex-direction: column; gap: var(--space-md); min-width: 0; }
  .rtd-hub { font-size: var(--fs-lg); font-weight: 700; color: var(--t0); }
  .rtd-compare .rtd-hub { font-size: var(--fs-md); }
  .rtd-block .rtc-bu { gap: var(--space-sm); margin-top: var(--space-2xs); }
  .rtd-block .rtc-bu-l { font-size: var(--fs-caption); }
  .rtd-block .rtc-bu-v { font-size: var(--fs-sm); }
  .rtd-block .rtc-bu-net .rtc-bu-v { font-size: var(--fs-lg); }
  .rtd-seclbl { margin-top: var(--space-sm); font-family: var(--font-sans); font-size: var(--fs-xs); letter-spacing: .06em;
                text-transform: uppercase; color: var(--t2); }
  .rtd-map { height: 300px; border-radius: var(--radius); }
  .rtd-compare .rtd-map { height: 190px; }
  /* Operator label above the hub title in the detail sheet (reuses the card's
     .rtc-op — same style, just a touch more space below it here). */
  .rtd-block .rtc-op { margin-bottom: var(--space-sm); }
}

