/* The tender workflow figure in #flow. Colours come from tokens.css only. flow.js builds the
   timeline: one column per phase, five lanes, the gates as markers across all lanes. */

#flow .fl-labels { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
#flow .fl-wide { width: min(1400px, 100% - 2 * var(--gutter)); margin-inline: auto; display: grid; gap: 22px; }

/* Case header */
#flow .fl-case { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 32px; padding: 28px 30px; }
#flow .fl-case-title { margin: 0 0 18px; font-size: var(--text-h3); }
#flow .fl-case-facts { grid-template-columns: 1fr; }
#flow .fl-case-facts dd { color: var(--text); }
#flow .fl-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
#flow .fl-stat .stat-value { font-size: 2.1rem; }
#flow .fl-docs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

/* Tokens: an icon and a short name, typed by data-kind */
#flow .fl-token {
  display: inline-flex; align-items: flex-start; gap: 7px; max-width: 100%;
  padding: 6px 9px; border-radius: var(--radius-sm);
  background: var(--glass-1); border: 1px solid var(--border);
  font-size: 0.8rem; line-height: 1.3; color: var(--text); overflow-wrap: anywhere;
  --k: var(--accent);
}
#flow .fl-token .fl-ico { width: 15px; height: 15px; margin-top: 1px; }
#flow .fl-ico * { stroke: var(--k, var(--accent)); stroke-width: 1.8; }
#flow .fl-token-text { min-width: 0; }
#flow [data-kind="documents"] { --k: var(--accent); }
#flow [data-kind="norms"] { --k: var(--accent-2); }
#flow [data-kind="extended"] { --k: var(--ok); }
#flow [data-kind="experts"] { --k: var(--wait); }
#flow [data-kind="systems"] { --k: var(--primary); }
#flow [data-kind="person"] { --k: var(--wait); }
#flow [data-kind="agent"] { --k: var(--accent-2); }
#flow [data-kind="tool"] { --k: var(--text-muted); }
#flow [data-kind="out"] { --k: var(--ok); }
#flow [data-kind="sign"] { --k: var(--wait); }
#flow [data-kind="check"] { --k: var(--ok); }
#flow .fl-token[data-kind="documents"], #flow .fl-token[data-kind="norms"], #flow .fl-token[data-kind="extended"],
#flow .fl-token[data-kind="experts"], #flow .fl-token[data-kind="systems"] {
  border-color: color-mix(in srgb, var(--k) 40%, transparent);
  background: color-mix(in srgb, var(--k) 9%, var(--glass-1));
}
#flow .fl-token.fl-tool { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-muted); padding: 4px 8px; }
#flow .fl-token.fl-agent { border-color: color-mix(in srgb, var(--accent-2) 50%, transparent); background: color-mix(in srgb, var(--accent-2) 12%, var(--glass-1)); font-weight: 600; }
#flow .fl-token.fl-out { border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: var(--wash-ok); }
#flow .fl-token[data-first] { flex-wrap: wrap; box-shadow: 0 0 0 1px color-mix(in srgb, var(--k) 55%, transparent), 0 0 14px color-mix(in srgb, var(--k) 28%, transparent); }
#flow .fl-first, #flow .fl-type {
  flex-basis: 100%; padding-left: 22px;
  font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: var(--track-label); text-transform: uppercase; color: var(--k);
}

/* Legend */
#flow .fl-legend { display: flex; flex-wrap: wrap; gap: 10px 22px; padding: 0 4px; }
#flow .fl-legend-item { display: inline-flex; align-items: center; gap: 8px; font-size: 0.85rem; }
#flow .fl-legend-item .fl-ico { width: 18px; height: 18px; }
#flow .fl-legend-item small { font-family: var(--font-mono); font-size: var(--text-label); color: var(--text-muted); letter-spacing: 0.04em; }

/* Timeline grid. Row 1 days, row 2 phases, rows 3 to 7 the lanes. Columns share the rows by subgrid. */
#flow .fl-scroll { overflow-x: auto; overscroll-behavior-x: contain; border-radius: var(--radius-lg); }
#flow .fl-grid {
  position: relative; min-width: 1080px;
  display: grid; grid-template-columns: 128px var(--fl-cols, repeat(9, minmax(0, 1fr)));
  grid-template-rows: auto auto repeat(5, auto); column-gap: 8px;
  padding: 18px 16px 18px 12px;
  background: var(--glass-2); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--sheen);
}
#flow[data-ready] .fl-nojs { display: none; }
#flow .fl-day {
  grid-row: 1; margin-bottom: 10px; padding: 6px 10px 7px;
  font-family: var(--font-mono); font-size: var(--text-label); letter-spacing: var(--track-label); text-transform: uppercase; color: var(--text-muted);
  border-bottom: 1px solid var(--border-strong); position: relative;
}
#flow .fl-day::after { content: ""; position: absolute; left: 10px; bottom: -4px; width: 7px; height: 7px; border-radius: 2px; background: var(--accent); box-shadow: var(--glow-dot); }
#flow .fl-lane-name {
  grid-column: 1; align-self: stretch; display: flex; align-items: center;
  padding: 14px 10px 14px 4px; border-top: 1px dashed var(--border);
  font-family: var(--font-mono); font-size: var(--text-label); letter-spacing: var(--track-label); text-transform: uppercase; color: var(--text-muted);
}
#flow .fl-corner { grid-row: 2; border-top: 0; color: var(--accent); }
#flow .fl-track { grid-column: 2 / -1; grid-row: 2; align-self: center; z-index: 0; margin: 0 8px; }

#flow .fl-col {
  grid-row: 2 / span 6; display: grid; grid-template-rows: subgrid;
  position: relative; z-index: 1; min-width: 0; cursor: pointer;
  border-radius: var(--radius); border: 1px solid transparent;
  transition: background var(--dur-2), border-color var(--dur-2), box-shadow var(--dur-2), opacity var(--dur-2);
}
#flow .fl-col:hover { background: var(--glass-1); }
#flow .fl-col[data-state="now"] { background: var(--wash-accent); border-color: color-mix(in srgb, var(--accent) 55%, transparent); box-shadow: var(--glow-accent-sm); }
#flow .fl-col[data-hit="false"] > .fl-cell, #flow .fl-col[data-hit="false"] > .fl-gate { opacity: 0.72; filter: saturate(0.35); }
#flow .fl-col[data-hit="false"] .fl-phase { color: var(--text-muted); }
#flow .fl-col[data-hit="true"] { border-color: color-mix(in srgb, var(--ok) 60%, transparent); box-shadow: 0 0 18px color-mix(in srgb, var(--ok) 26%, transparent); }

#flow .fl-phase {
  display: grid; gap: 2px; text-align: left; margin: 0 0 4px; padding: 10px 10px 9px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); cursor: pointer;
  transition: border-color var(--dur-2), box-shadow var(--dur-2);
}
#flow .fl-phase:hover { border-color: var(--accent); }
#flow .fl-phase:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#flow .fl-phase[aria-pressed="true"] { border-color: var(--accent); box-shadow: var(--glow-accent-sm); }
#flow .fl-no { font-family: var(--font-mono); font-size: var(--text-label); color: var(--accent); }
#flow .fl-title { font-family: var(--font-display); font-size: 0.98rem; font-weight: 600; }
#flow .fl-meta { font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.04em; color: var(--text-muted); }
#flow .fl-day-inline { display: none; font-family: var(--font-mono); font-size: var(--text-label); color: var(--text-muted); }
#flow .fl-col[data-kind="gate"] .fl-phase { border-color: color-mix(in srgb, var(--wait) 55%, transparent); }
#flow .fl-col[data-kind="gate"] .fl-no { color: var(--wait); }

#flow .fl-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px 6px; border-top: 1px dashed var(--border); min-width: 0; }
#flow .fl-cell[data-empty]::before { content: ""; align-self: stretch; margin: auto 6px; border-top: 1px dotted var(--border-strong); }
#flow .fl-chips { display: flex; flex-wrap: wrap; gap: 5px; }
#flow .fl-svc { cursor: pointer; background: var(--glass-1); font-size: 0.62rem; padding: 3px 8px; }
#flow .fl-svc:hover { border-color: var(--accent); color: var(--text); }
#flow .fl-svc:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#flow .fl-svc[data-state="now"] { box-shadow: var(--glow-accent-sm); }

/* Gate: a signature marker across all five lanes */
#flow .fl-gate {
  grid-row: 2 / span 5; position: relative; margin: 10px 2px 0;
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  padding: 18px 8px; border-radius: var(--radius);
  background: var(--wash-wait); border: 1px dashed color-mix(in srgb, var(--wait) 60%, transparent);
}
#flow .fl-gate::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; transform: translateX(-50%); z-index: -1;
  background: linear-gradient(var(--wait), color-mix(in srgb, var(--wait) 15%, transparent));
}
#flow .fl-seal {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--wait); box-shadow: 0 0 18px color-mix(in srgb, var(--wait) 40%, transparent);
  --k: var(--wait);
}
#flow .fl-seal .fl-ico { width: 22px; height: 22px; }
#flow .fl-col[data-state="now"] .fl-seal { animation: fl-seal 2.4s var(--ease-in-out) infinite alternate; }
#flow .fl-gate-title { font-family: var(--font-display); font-size: 0.9rem; color: var(--wait); background: var(--surface); padding: 2px 8px; border-radius: var(--radius-sm); }
#flow .fl-gate-who { font-size: 0.8rem; background: var(--surface); padding: 2px 6px; border-radius: var(--radius-sm); }
#flow .fl-gate-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 0.74rem; color: var(--text-muted); background: var(--surface); padding: 6px; border-radius: var(--radius-sm); }
#flow .fl-gate .fl-chips { justify-content: center; }
#flow .fl-gate .fl-out { margin-top: auto; text-align: left; overflow-wrap: normal; background: linear-gradient(var(--wash-ok), var(--wash-ok)), var(--surface); }
#flow .fl-gate .fl-chips .fl-svc { background: var(--surface); }
#flow .fl-token.fl-tool { overflow-wrap: normal; }
@keyframes fl-seal { from { box-shadow: 0 0 8px color-mix(in srgb, var(--wait) 25%, transparent); } to { box-shadow: 0 0 26px color-mix(in srgb, var(--wait) 60%, transparent); } }

/* OS services and kernel facts */
#flow .fl-services { display: grid; gap: 12px; }
#flow .fl-services-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 18px; }
#flow .fl-services-head .label { margin: 0; }
#flow .fl-service-row { display: flex; flex-wrap: wrap; gap: 8px; }
#flow .fl-service-row .fl-svc { display: inline-flex; align-items: center; gap: 8px; font-size: var(--text-label); padding: 6px 12px; }
#flow .fl-svc-n { font-family: var(--font-mono); color: var(--accent); }
#flow .fl-kernel {
  list-style: none; margin: 0; padding: 16px 20px; display: grid; grid-template-columns: auto repeat(3, minmax(0, 1fr)); gap: 14px 22px; align-items: start;
  background: var(--glass-2); border: 1px solid color-mix(in srgb, var(--ok) 45%, transparent); border-radius: var(--radius); font-size: 0.88rem;
}
#flow .fl-kernel li { border-left: 2px solid var(--border-strong); padding-left: 12px; }
#flow .fl-kernel .fl-kernel-head { display: inline-flex; align-items: center; gap: 8px; border: 0; padding: 0; --k: var(--ok); }
#flow .fl-kernel .fl-kernel-head .fl-ico { width: 20px; height: 20px; }

/* Details panel */
#flow .fl-detail { display: grid; gap: 20px; padding: 28px 30px; }
#flow .fl-detail-title { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
#flow .fl-detail-title h3 { margin: 0; font-size: var(--text-h3); }
#flow .fl-detail-no { font-family: var(--font-mono); font-size: 0.95rem; color: var(--accent); }
#flow .fl-detail-text { margin: 12px 0 0; font-size: var(--text-lead); max-width: 52em; }
#flow .fl-detail-who > div { display: flex; flex-wrap: wrap; gap: 8px; }
#flow .fl-pipe { display: grid; grid-template-columns: minmax(0, 1.2fr) 28px minmax(0, 1fr) 28px minmax(0, 1.2fr) 28px minmax(0, 1fr); align-items: start; }
#flow .fl-pipe-box { padding: 14px; border-radius: var(--radius-sm); background: var(--glass-1); border: 1px solid var(--border); min-height: 100%; }
#flow .fl-pipe-link { align-self: center; margin: 0 4px; }
#flow .fl-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
#flow .fl-list .fl-token { width: 100%; flex-wrap: wrap; }
#flow .fl-list .fl-token-text { flex: 1 1 0; }
#flow .fl-list [data-kind="tool"] { font-family: var(--font-mono); font-size: 0.76rem; }
#flow .fl-none { font-size: 0.85rem; color: var(--text-muted); }
#flow .fl-stepper { flex-wrap: wrap; margin-top: 0; }
#flow .fl-play-note { margin: 0; }
#flow #fl-play[data-state="wait"] { border-color: var(--wait); }

/* Outputs and timing */
#flow .fl-outputs { display: grid; gap: 12px; }
#flow .fl-outputs-head { display: flex; align-items: baseline; gap: 14px; }
#flow .fl-outputs-head .label { margin: 0; }
#flow .fl-outputs-count { font-family: var(--font-mono); font-size: var(--text-label); color: var(--ok); letter-spacing: var(--track-label); text-transform: uppercase; }
#flow .fl-out-strip { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
#flow .fl-out-strip .fl-token { width: 100%; height: 100%; font-size: 0.88rem; padding: 12px; }
#flow .fl-timing { gap: 16px; }
#flow .fl-time p { margin: 12px 0 0; }
#flow .fl-source { margin: 0; max-width: 60em; }

/* Motion: the seal pulse pauses with the page and is off with reduced motion. */
html[data-motion="off"] #flow .fl-seal { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) {
  #flow .fl-seal, #flow .fl-col[data-state="now"] .fl-seal { animation: none; }
  #flow .fl-col, #flow .fl-phase { transition: none; }
}

/* Timeline at 761px and up: the page navigation takes 252px from 1080px on, so the columns stay
   near 100px. Icons sit above the text, and words wrap whole or with a hyphen. */
@media (min-width: 761px) {
  #flow .fl-grid { grid-template-columns: 76px var(--fl-cols, repeat(9, minmax(0, 1fr))); column-gap: 5px; padding-left: 8px; padding-right: 8px; }
  #flow .fl-lane-name { padding-right: 6px; line-height: 1.5; }
  #flow .fl-cell { padding: 10px 3px; }
  #flow .fl-grid .fl-token, #flow .fl-grid .fl-token[data-first] { flex-direction: column; flex-wrap: nowrap; gap: 4px; padding: 6px 7px; font-size: 0.76rem; overflow-wrap: break-word; hyphens: manual; }
  #flow .fl-grid .fl-token.fl-tool { flex-direction: row; }
  #flow .fl-grid .fl-first, #flow .fl-grid .fl-type { flex-basis: auto; padding-left: 0; }
  #flow .fl-gate { padding: 16px 5px; }
  #flow .fl-gate-who, #flow .fl-gate-list { hyphens: manual; overflow-wrap: break-word; }
  #flow .fl-grid .fl-token.fl-tool { overflow-wrap: normal; word-break: normal; }
}

/* Medium screens: the case header stacks, the timeline scrolls inside its own box. */
@media (max-width: 1080px) {
  #flow .fl-case { grid-template-columns: 1fr; }
  #flow .fl-out-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #flow .fl-kernel { grid-template-columns: 1fr; }
  #flow .fl-pipe { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  #flow .fl-pipe-link { display: none; }
}

/* Narrow screens: one card per phase with its lanes stacked, the details below the selected one. */
@media (max-width: 760px) {
  #flow .fl-wide { width: calc(100% - 2 * var(--gutter)); }
  #flow .fl-case { padding: 20px; }
  #flow .fl-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #flow .fl-docs { grid-template-columns: 1fr; }
  #flow .fl-scroll { overflow: visible; }
  #flow .fl-grid { display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; gap: 10px; padding: 10px; }
  #flow .fl-day, #flow .fl-lane-name, #flow .fl-track { display: none; }
  #flow .fl-col { grid-row: auto; grid-column: 1 !important; display: grid; grid-template-rows: none; padding: 6px; border-color: var(--border); background: var(--glass-1); }
  #flow .fl-day-inline { display: block; }
  #flow .fl-cell { flex-direction: row; flex-wrap: wrap; padding: 10px 6px; }
  #flow .fl-cell::before { content: attr(data-lane-name); flex-basis: 100%; font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: var(--track-label); text-transform: uppercase; color: var(--text-muted); }
  #flow .fl-cell[data-empty] { display: none; }
  #flow .fl-col:not([data-state="now"]) { padding: 0; border-color: transparent; background: none; }
  #flow .fl-col:not([data-state="now"]) > :not(.fl-phase) { display: none; }
  #flow .fl-col:not([data-state="now"]) .fl-phase { width: 100%; margin: 0; grid-template-columns: 2.2em minmax(0, 1fr) auto; align-items: baseline; column-gap: 10px; }
  #flow .fl-col:not([data-state="now"]) .fl-meta { display: none; }
  #flow .fl-detail .fl-detail-who, #flow .fl-detail .fl-pipe, #flow .fl-detail .fl-detail-os { display: none; }
  #flow .fl-token-text { flex: 1 1 0; }
  #flow .fl-gate { grid-row: auto; margin: 6px 0 0; }
  #flow .fl-detail { padding: 20px; }
  #flow .fl-pipe { grid-template-columns: 1fr; }
  #flow .fl-out-strip { grid-template-columns: 1fr; }
}

/* German compounds are long: let them break at a syllable in the narrow cells. */
:lang(de) #flow .fl-grid .fl-token, :lang(de) #flow .fl-gate-who, :lang(de) #flow .fl-gate-list, :lang(de) #flow .fl-lane-name, :lang(de) #flow .fl-stat { -webkit-hyphens: auto; hyphens: auto; }
