/* ============================================================
   NCEPT Flow Atlas — /ncept/flow
   Self-contained dark "theater" section rendered inside the
   normal site chrome; deliberately theme-independent.
   ============================================================ */
/* Keep the site's standard 1260px column. Once the viewport is narrow enough
   that the dark band already spans it, drop the shell's top/bottom gaps so the
   band meets the header and footer instead of leaving light strips. */
@media (max-width: 1260px) {
  main#main { padding-top: 0; padding-bottom: 0; }
}

.fa-page {
  --fa-bg: #0a0e16; --fa-bg-2: #0f1524; --fa-panel: #121a2b; --fa-panel-2: #172037;
  --fa-line: #26314b; --fa-line-2: #1a2338; --fa-text: #e7ecf6; --fa-muted: #8a94ab;
  --fa-faint: #7a86a0; --fa-accent: #6ea8ff;   /* faint must still clear 4.5:1 AA on --fa-panel (axis labels live there) */
  --pos: #4edd9e; --neg: #ff6f6f;
  background: radial-gradient(1200px 700px at 60% -10%, #131c30 0%, var(--fa-bg) 60%);
  color: var(--fa-text);
  padding: 1.1rem 0 2.5rem;
  -webkit-font-smoothing: antialiased;
}
.fa-page a { color: var(--fa-accent); text-decoration: none; }
.fa-page a:hover { text-decoration: underline; }
.fa-shell { max-width: 1500px; margin: 0 auto; padding: 0 1.5rem; }

/* hero */
.fa-hero { margin-bottom: .75rem; }
.fa-title { margin: 0 0 .15rem; font-size: 1.6rem; font-weight: 700; letter-spacing: -.01em; color: var(--fa-text); }
.fa-sub { margin: 0; color: var(--fa-muted); font-size: .88rem; }
.fa-eras { display: flex; gap: .4rem; margin-top: .6rem; }
.fa-eras .fa-tab { flex: 0 0 auto; text-decoration: none; color: var(--fa-muted); }
.fa-eras .fa-tab:hover { text-decoration: none; }
.fa-eras .fa-tab.on { color: var(--fa-text); }

/* layout */
.fa-main { display: flex; gap: 1rem; align-items: flex-start; }
.fa-mapcol { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

/* toolbar (above map) */
.fa-toolbar { display: flex; align-items: center; gap: .45rem .55rem; flex-wrap: wrap; margin-bottom: .6rem; min-height: 32px; }
.fa-ctl { display: inline-flex; align-items: center; gap: .5rem; background: var(--fa-panel); border: 1px solid var(--fa-line-2); border-radius: 999px; padding: .3rem .75rem; font-size: .77rem; color: var(--fa-muted); margin: 0; }
.fa-ctl input[type=range] { width: 120px; accent-color: var(--fa-accent); cursor: pointer; }
.fa-ctl b { color: var(--fa-text); font-variant-numeric: tabular-nums; }
.fa-chips { display: flex; gap: .45rem; flex-wrap: wrap; }
.fa-chip { display: inline-flex; align-items: center; gap: .4rem; padding: .28rem .6rem; border: 1px solid var(--fa-line-2); border-radius: 999px; font-size: .76rem; font-family: inherit; line-height: 1.2; color: var(--fa-text); cursor: pointer; background: var(--fa-panel); user-select: none; }
.fa-chip:hover { border-color: var(--fa-line); }
.fa-chip .sw { width: 9px; height: 9px; border-radius: 50%; }
.fa-chip.off { opacity: .38; }
.fa-chip:disabled { opacity: .3; cursor: default; }
.fa-chip:disabled:hover { border-color: var(--fa-line-2); }
.fa-tb-note { font-size: .72rem; color: var(--fa-faint); }
.fa-below { display: flex; align-items: center; gap: .6rem; margin-top: .45rem; min-height: 24px; }
.fa-below .fa-chip { margin-left: auto; }
.fa-about { margin: .7rem 0 0; max-width: 85ch; font-size: .84rem; line-height: 1.65; color: var(--fa-muted); }

/* search (doubles as the focus indicator: shows "ID · Name" + a clear button when focused) */
.fa-search { position: relative; display: inline-flex; align-items: center; }
.fa-search input { background: var(--fa-panel); border: 1px solid var(--fa-line-2); border-radius: 999px; color: var(--fa-text); font-size: .78rem; font-family: inherit; padding: .3rem 1.7rem .3rem .8rem; width: 196px; outline: none; }
.fa-search input::placeholder { color: var(--fa-faint); }
.fa-search input:focus { border-color: var(--fa-accent); }
.fa-search.focused input { border-color: var(--fa-accent); color: #fff; }
.fa-search-x { position: absolute; right: 5px; border: none; background: var(--fa-panel-2); color: var(--fa-text); border-radius: 50%; width: 20px; height: 20px; line-height: 1; font-size: .72rem; cursor: pointer; }
.fa-search-x:hover { background: var(--neg); }
.fa-search-x[hidden] { display: none; }
.fa-search-list { position: absolute; top: calc(100% + 4px); left: 0; min-width: 235px; background: var(--fa-panel); border: 1px solid var(--fa-line); border-radius: 10px; padding: .25rem; z-index: 40; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.fa-search-list .opt { padding: .3rem .55rem; border-radius: 7px; font-size: .8rem; cursor: pointer; color: var(--fa-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fa-search-list .opt span { color: var(--fa-muted); font-size: .74rem; }
.fa-search-list .opt:hover, .fa-search-list .opt.active { background: var(--fa-panel-2); }

/* map stage: aspect-locked, and height-capped to the viewport so the map never
   grows past the fold on wide-but-short windows (canvas math needs the box to
   keep the 975:610 ratio, so the cap constrains WIDTH, centered) */
.fa-stage { position: relative; width: min(100%, max(460px, calc((100vh - 240px) * 975 / 610))); margin-inline: auto; aspect-ratio: 975 / 610; background: linear-gradient(180deg, var(--fa-bg-2), var(--fa-bg)); border: 1px solid var(--fa-line-2); border-radius: 14px; overflow: hidden; touch-action: none; cursor: grab; scroll-margin-top: 10px; }
.fa-stage:active { cursor: grabbing; }
.fa-stage.inert { touch-action: pan-y; }   /* page scrolls over the map until the gate is tapped */
.fa-touchgate { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 7; border: 1px solid var(--fa-line); background: rgba(10, 14, 22, .82); color: var(--fa-text); font-family: inherit; font-size: .75rem; padding: .35rem .85rem; border-radius: 999px; cursor: pointer; backdrop-filter: blur(4px); }
.fa-stage:not(.inert) .fa-touchgate { display: none; }
#fa-basemap, #fa-canvas, #fa-dots { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#fa-basemap, #fa-canvas { pointer-events: none; }
#fa-dots { pointer-events: none; }
#fa-dots .fa-dot { pointer-events: all; }
.fa-nation { fill: #0e1626; stroke: none; }
.fa-state { fill: none; stroke: var(--fa-line); stroke-width: .6; vector-effect: non-scaling-stroke; }
.fa-inset-box { fill: rgba(255,255,255,.015); stroke: var(--fa-line-2); stroke-width: .8; vector-effect: non-scaling-stroke; }
.fa-inset-label { fill: var(--fa-faint); font-size: 9px; letter-spacing: .06em; text-transform: uppercase; }
.fa-dot { cursor: pointer; stroke: rgba(10,14,22,.85); stroke-width: .5; vector-effect: non-scaling-stroke; transition: opacity .15s; }
.fa-dot:hover { stroke: #fff; stroke-width: 1; }
.fa-dot.dim { opacity: .1; }

/* facility labels: hubs always on; the rest appear once zoomed in (k >= 3) */
.fa-lbl { display: none; fill: var(--fa-muted); font-weight: 600; paint-order: stroke; stroke: #0a1020; stroke-width: .28em; stroke-linejoin: round; pointer-events: none; }
.fa-lbl.hub { display: block; fill: #c7d2e8; }
#g-labels.zoomed .fa-lbl { display: block; }

/* focus pulse ring */
.fa-pulse { fill: none; stroke: #fff; stroke-width: 1.5; vector-effect: non-scaling-stroke; pointer-events: none; transform-box: fill-box; transform-origin: center; animation: fa-pulse .9s ease-out forwards; }
@keyframes fa-pulse { from { transform: scale(1); opacity: .9; } to { transform: scale(3); opacity: 0; } }

.fa-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--fa-muted); font-size: .9rem; margin: 0; }
.fa-loading.hidden { display: none; }

/* side leaderboard (one card; JS turns the stacked sections into tabs) */
.fa-side { flex: 0 0 300px; display: flex; flex-direction: column; gap: 1rem; }
.fa-tabs { display: flex; gap: .3rem; margin-bottom: .65rem; }
.fa-tab { flex: 1 1 0; border: 1px solid var(--fa-line-2); background: transparent; color: var(--fa-muted); font-family: inherit; font-size: .74rem; padding: .28rem .4rem; border-radius: 999px; cursor: pointer; }
.fa-tab:hover { border-color: var(--fa-line); }
.fa-tab.on { background: var(--fa-panel-2); color: var(--fa-text); border-color: var(--fa-accent); }
.fa-board-sec + .fa-board-sec { margin-top: 1rem; }
.fa-boards.tabbed .fa-board-sec > h2 { display: none; }
.fa-boards.tabbed .fa-board-sec + .fa-board-sec { margin-top: 0; }
.fa-boards-hint { display: none; }                      /* rows are only clickable with JS */
.fa-boards.tabbed .fa-boards-hint { display: block; }
.fa-panel { background: var(--fa-panel); border: 1px solid var(--fa-line-2); border-radius: 12px; padding: .85rem 1rem 1rem; }
.fa-panel h2 { margin: 0 0 .15rem; font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--fa-text); font-weight: 700; }
.fa-note { margin: 0 0 .6rem; font-size: .74rem; color: var(--fa-muted); }
.fa-lead { margin: 0 0 .4rem; font-size: .92rem; color: var(--fa-text); line-height: 1.55; }
.fa-board { list-style: none; margin: 0; padding: 0; }
.fa-board li { display: flex; align-items: center; gap: .5rem; padding: .28rem .35rem; border-radius: 7px; font-size: .82rem; }
.fa-board.is-interactive li { cursor: pointer; }
.fa-board li:hover { background: var(--fa-panel-2); }
.fa-board li.hot { background: var(--fa-panel-2); outline: 1px solid var(--fa-line); }
.fa-code { font-weight: 700; font-variant-numeric: tabular-nums; width: 2.6em; color: var(--fa-text); }
.fa-name { flex: 1 1 auto; color: var(--fa-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fa-route { flex: 1 1 auto; color: var(--fa-text); font-variant-numeric: tabular-nums; }
.fa-val { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--fa-muted); }
.fa-val.pos { color: var(--pos); } .fa-val.neg { color: var(--neg); }

/* insights: level movement + type-to-type (table & chord together) + volume */
.fa-insights { display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem; }
.fa-typerow { display: flex; gap: 1.6rem; align-items: center; flex-wrap: wrap; }
.fa-typetable { flex: 1 1 340px; min-width: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.fa-corner { font-size: .6rem; line-height: 1.2; color: var(--fa-faint); text-align: left; font-weight: 600; }
.fa-matrix td.mx { color: #fff; font-weight: 700; }
.fa-matrix { width: 100%; border-collapse: collapse; font-size: .8rem; font-variant-numeric: tabular-nums; }
.fa-matrix th, .fa-matrix td { padding: .32rem .5rem; border: 1px solid var(--fa-line-2); text-align: right; color: var(--fa-text); }
.fa-matrix thead th { color: var(--fa-muted); font-weight: 600; font-size: .72rem; }
.fa-matrix th[scope=row] { text-align: left; color: var(--fa-muted); font-weight: 600; }
.fa-matrix td.h { background: rgba(110, 168, 255, var(--h, 0)); }
.fa-matrix .tot { color: var(--fa-muted); font-weight: 700; }
.fa-chordwrap { flex: 0 1 420px; min-width: 300px; margin: 0 auto; }
.fa-chordwrap svg { display: block; width: 100%; height: auto; }
.fa-ch-lbl { fill: #c7d2e8; font-size: 12px; font-weight: 600; }
.fa-ch-ribbon { stroke: rgba(10, 14, 22, .45); stroke-width: .5; transition: fill-opacity .15s; }
.fa-ch-group { cursor: default; }
.fa-ch-group:hover { stroke: #fff; stroke-width: 1; }
.fa-volwrap svg { display: block; width: 100%; height: auto; }
.fa-v-grid { stroke: var(--fa-line-2); stroke-width: 1; }
.fa-v-lbl { fill: var(--fa-faint); font-size: 10px; }
.fa-vbar { fill: var(--fa-accent); opacity: .8; transition: opacity .1s; }
.fa-vbar:hover { fill: #9ecbff; opacity: 1; }
.fa-matrix td.h[data-n] { cursor: default; }
.fa-matrix td.h[data-n]:hover { outline: 1px solid var(--fa-accent); outline-offset: -1px; }

/* level movement */
.fa-lvlrow { display: flex; gap: 1.6rem; align-items: center; flex-wrap: wrap; }
.fa-lvlstat { flex: 0 0 230px; }
.fa-lvlchart { flex: 1 1 300px; min-width: 260px; }
.fa-lvlchart svg { display: block; width: 100%; height: auto; }
.fa-lvlavg { font-size: 2.2rem; font-weight: 700; color: var(--pos); line-height: 1.1; font-variant-numeric: tabular-nums; }
.fa-lvlavg.neg { color: var(--neg); }
.fa-dirstrip { display: flex; height: 14px; border-radius: 7px; overflow: hidden; margin: .7rem 0 .4rem; }
.fa-dirstrip span { display: block; height: 100%; }
.fa-dirstrip .up { background: var(--pos); }
.fa-dirstrip .same { background: var(--fa-faint); }
.fa-dirstrip .down { background: var(--neg); }
.fa-dirlegend { display: flex; gap: .9rem; font-size: .72rem; color: var(--fa-muted); }
.fa-dirlegend b { color: var(--fa-text); font-variant-numeric: tabular-nums; }
.fa-dirlegend b.pos { color: var(--pos); }
.fa-dirlegend b.neg { color: var(--neg); }
.fa-lvbar { opacity: .85; transition: opacity .1s; }
.fa-lvbar.up { fill: var(--pos); }
.fa-lvbar.same { fill: var(--fa-faint); }
.fa-lvbar.down { fill: var(--neg); }
.fa-lvbar:hover { opacity: 1; }

/* methodology */
.fa-method { border-top: 1px solid var(--fa-line-2); margin-top: 1.6rem; padding-top: 1.1rem; max-width: 85ch; }
.fa-method h2 { margin: 0 0 .5rem; font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--fa-text); font-weight: 700; }
.fa-method p { margin: 0 0 .6rem; font-size: .84rem; line-height: 1.65; color: var(--fa-muted); }

/* tooltip */
.fa-tooltip { position: fixed; z-index: 1050; pointer-events: none; background: rgba(8,12,20,.94); border: 1px solid #26314b; border-radius: 9px; padding: .5rem .65rem; font-size: .8rem; max-width: 240px; color: #e7ecf6; box-shadow: 0 8px 28px rgba(0,0,0,.5); transform: translate(-50%, calc(-100% - 12px)); }
.fa-tooltip[hidden] { display: none; }
.fa-tt-name { font-weight: 700; margin-bottom: .15rem; }
.fa-tt-meta { color: #8a94ab; font-size: .74rem; }
.fa-tt-row { display: flex; justify-content: space-between; gap: 1.25rem; font-variant-numeric: tabular-nums; }
.fa-tt-row .pos { color: #4edd9e; } .fa-tt-row .neg { color: #ff6f6f; }
.fa-noscript { margin: 1rem 0 0; color: var(--fa-muted); font-size: .88rem; }

/* responsive: below ~1100px the sidebar steals too much map, so it drops under */
@media (max-width: 1100px) {
  .fa-main { flex-direction: column; }
  .fa-side { flex-basis: auto; width: 100%; flex-direction: row; flex-wrap: wrap; }
  .fa-panel { flex: 1 1 260px; }
  .fa-tb-note { display: none; }
}
@media (max-width: 430px) {
  .fa-chips { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .fa-chips .fa-chip { justify-content: center; }
}
@media (max-width: 640px) {
  /* full-bleed the visuals on phones: the stage, insight cards, and boards card
     break out of .fa-shell's 1.5rem side padding (portrait widths only, where the
     viewport-height cap never binds); their own padding keeps content off the edge */
  .fa-stage, .fa-insights .fa-panel, .fa-side .fa-panel {
    width: calc(100% + 3rem); margin-inline: -1.5rem;
    border-radius: 0; border-left: none; border-right: none;
  }
  /* the type-to-type table: tighter cells so it fits a phone card; scrolls if not */
  .fa-matrix { font-size: .68rem; }
  .fa-matrix th, .fa-matrix td { padding: .22rem .3rem; }
  /* the insight SVGs scale with their viewBoxes; raise their type so it stays legible */
  .fa-v-lbl { font-size: 19px; }
  .fa-ch-lbl { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  .fa-dot { transition: none; }
  .fa-pulse { animation: none; opacity: 0; }
}
