/* ============================================================
   flow.css: production and revenue flow chart (system, crofton),
   corridor map frame and layout diagram hooks (system), offtaker
   table as cards on phones (partners).
   Loaded after css/motion.css.
   ============================================================ */

.flow-figure {
  --flow-inlet: #0F2A30;
  --flow-accent: #1E4F5C;
  --flow-muted: #53666B;
  --flow-glacier: #BFD9E3;
  --flow-buoy: #F2B705;
  --flow-rule: #D3DCD9;
  margin: 8px 0 0;
  font-family: 'Archivo', system-ui, sans-serif;
  color: var(--flow-inlet);
}

.flow-intro {
  font-size: 17px;
  line-height: 1.55;
  color: #1C2A2E;
  max-width: 68ch;
  margin: 0 0 20px;
}

/* ---------------------------------------------------------------- chart */
.flow-chart {
  background: #fff;
  border: 1px solid var(--flow-rule);
  border-radius: 3px;
  padding: 16px 8px 8px;
  overflow: hidden;
}
.flow-svg { display: block; width: 100%; height: auto; font-family: 'Archivo', system-ui, sans-serif; }

.flow-heading { font-size: 15px; font-weight: 700; fill: var(--flow-inlet); }

.flow-link { fill: none; stroke: var(--flow-glacier); stroke-opacity: 0.75; }
.flow-link.is-h2 { stroke: var(--flow-buoy); stroke-opacity: 0.8; }
.flow-svg.is-focus .flow-link { stroke-opacity: 0.2; }
.flow-svg.is-focus .flow-link.is-on { stroke-opacity: 0.95; }

.flow-node { cursor: default; }
.flow-label { fill: var(--flow-inlet); }
.flow-label.has-halo {
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 5px;
  stroke-linejoin: round;
}
.flow-label-name { font-size: 15px; font-weight: 650; }
.flow-label-sub { font-size: 14px; font-weight: 400; fill: var(--flow-muted); }

@media (prefers-reduced-motion: no-preference) {
  .flow-link { transition: stroke-opacity 0.15s ease-out; }
}

/* ---------------------------------------------------------------- stacked rows (narrow screens) */
.flow-rows { display: none; }
.flow-figure.is-compact .flow-chart { display: none; }
.flow-figure.is-compact .flow-rows { display: block; }

.flow-col + .flow-col { margin-top: 24px; }
.flow-col-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--flow-inlet);
  margin: 0 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--flow-rule);
}
.flow-list { list-style: none; margin: 0; padding: 0; }
.flow-row { padding: 10px 0; border-bottom: 1px solid var(--flow-rule); }
.flow-row-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.flow-row-name { font-size: 16px; font-weight: 650; color: var(--flow-inlet); }
.flow-row-value { font-size: 16px; font-weight: 700; color: var(--flow-inlet); font-variant-numeric: tabular-nums; white-space: nowrap; }
.flow-row-track { height: 8px; background: #EEF2F1; border-radius: 2px; margin: 6px 0 4px; overflow: hidden; }
.flow-row-track i { display: block; height: 100%; background: var(--flow-accent); border-radius: 2px; }
.flow-kind-input .flow-row-track i,
.flow-kind-coproduct .flow-row-track i { background: var(--flow-muted); }
.flow-kind-h2 .flow-row-track i,
.flow-kind-buyer .flow-row-track i { background: var(--flow-buoy); }
.flow-row-qty { display: block; font-size: 14px; color: var(--flow-muted); }

/* ---------------------------------------------------------------- summary */
.flow-summary {
  font-size: 15px;
  line-height: 1.55;
  color: #1C2A2E;
  margin: 14px 0 0;
  max-width: 80ch;
}
.flow-note { color: var(--flow-muted); }

/* ---------------------------------------------------------------- headline figures under the chart */
.flow-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 40px;
  margin: 24px 0 0;
  padding: 16px 0 0;
  border-top: 1px solid #D3DCD9;
  font-family: 'Archivo', system-ui, sans-serif;
}
.flow-stat b { display: block; font-size: 24px; font-weight: 800; color: #0F2A30; font-variant-numeric: tabular-nums; }
.flow-stat span { font-size: 15px; color: #53666B; }

@media (max-width: 640px) {
  .flow-figure .flow-chart { display: none; }
  .flow-figure .flow-rows { display: block; }
}

/* ---------------------------------------------------------------- corridor map (system.html) */
.corridor-map {
  position: relative;
  border: 1px solid #D3DCD9;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: none;
  font-family: 'Archivo', system-ui, sans-serif;
}
.corridor-map img { display: block; width: 100%; height: auto; }

/* ---------------------------------------------------------------- layout diagram (system.html)
   Nodes carry .diagram-node and data-diagram-step="1..4" in left-to-right DOM order;
   connectors carry .diagram-connector and data-diagram-step="1.5, 2.5, 3.5". */
.diagram-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

/* ---------------------------------------------------------------- offtaker table as cards (partners.html) */
@media (max-width: 640px) {
  .data-table.offtaker-table {
    display: block;
    overflow: visible;
    white-space: normal;
    border: 0;
    background: transparent;
  }
  .data-table.offtaker-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .data-table.offtaker-table tbody,
  .data-table.offtaker-table tfoot {
    display: block;
    width: 100%;
  }
  .data-table.offtaker-table tr {
    display: block;
    width: auto;
    table-layout: auto;
    background: #fff;
    border: 1px solid #D3DCD9;
    border-radius: 3px;
    padding: 14px 16px 10px;
    margin: 0 0 12px;
  }
  .data-table.offtaker-table tbody tr:nth-child(even),
  .data-table.offtaker-table tbody tr:hover { background: #fff; }
  .data-table.offtaker-table tbody td,
  .data-table.offtaker-table tfoot td {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: baseline;
    column-gap: 12px;
    padding: 6px 0;
    border: 0;
    border-top: 1px solid #E6ECEA;
    text-align: left !important;
    font-size: 15px;
    white-space: normal;
  }
  .data-table.offtaker-table td[data-label]::before {
    content: attr(data-label);
    font-size: 14px;
    color: #53666B;
  }
  .data-table.offtaker-table td:first-child {
    display: block;
    border-top: 0;
    padding: 0 0 8px;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.3;
    color: #0F2A30;
  }
  .data-table.offtaker-table td:empty { display: none; }
  .data-table.offtaker-table .bar-cell .bar-value {
    text-align: right;
    font-size: 15px;
    margin: 0;
  }
  .data-table.offtaker-table .bar-cell .bar-track {
    grid-column: 1 / -1;
    margin-top: 4px;
  }
  .data-table.offtaker-table .sector-badge { justify-self: end; }
  /* Source (i) button: top-right of the card, beside the name, not over values */
  .data-table.offtaker-table tr.has-source { position: relative; }
  .data-table.offtaker-table tr.has-source td:first-child { padding-right: 40px; }
  .data-table.offtaker-table tr.has-source > .source-btn,
  .data-table.offtaker-table tr.has-source:hover > .source-btn { top: 12px; right: 12px; transform: none; }
}
