/* ══════════════════════════════════════════════════════════════════════════
   Case-study flow diagrams  (js/apps/case-study-flow.js)
   A transparent "screen" that sits directly on the case-study card colour
   (--poster-bg / --poster-text, set per project via `palette` in portfolio.json)
   with Win98-bevelled node cards, accent packets and trace connectors. With no
   palette in scope it falls back to the original desktop green. Layout is container-query driven: the
   flow adapts to ITS OWN width (window, maximized window, narrow launcher
   panel, mobile), never the viewport.

   Motion rules: only transform / opacity / stroke-dashoffset animate. Glows
   are static box-shadows. Easing tokens live in tokens.css.
   ══════════════════════════════════════════════════════════════════════════ */

.flow {
  /* palette: the card colours, with the old desktop-green as fallback */
  --flow-bg: var(--poster-bg, #1C4030);
  --flow-accent: var(--poster-text, #8CFFA6);
  --flow-cream: #F4EBD0;                                              /* light ink */
  --flow-deep: color-mix(in srgb, var(--flow-bg) 72%, black);         /* note / band / pill fill */
  --flow-deep-edge: color-mix(in srgb, var(--flow-cream) 22%, var(--flow-deep));
  --flow-hair: color-mix(in srgb, var(--flow-cream) 45%, transparent);
  --flow-accent-glow: color-mix(in srgb, var(--flow-accent) 55%, transparent);
  --flow-accent-soft: color-mix(in srgb, var(--flow-accent) 30%, transparent);
  --flow-accent-hi: color-mix(in srgb, var(--flow-accent) 45%, white);
  /* semantic status colours (never palette-driven) */
  --flow-ok: #8CFFA6;
  --flow-bad: #FF7A93;
  --flow-line: color-mix(in srgb, var(--flow-cream) 82%, transparent);
  container: flow / inline-size;
  margin: 0;
  color: var(--flow-cream);
  font-family: var(--font-sans);
  text-align: left;
}

.flow-screen {
  position: relative;
  padding: 14px 12px 16px;
  background-color: transparent;
  background-image: radial-gradient(color-mix(in srgb, var(--flow-cream) 11%, transparent) 1.2px, transparent 1.4px);
  background-size: 22px 22px;
  border: 1px solid color-mix(in srgb, var(--flow-accent) 18%, transparent);
  overflow: hidden;
}

.flow-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  margin: 0 2px 14px;
}

.flow-kicker {
  font: 600 11px/1.3 var(--font-mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--flow-cream) 72%, transparent);
}

.flow-stat {
  display: inline-flex;
  align-items: baseline;
  padding: 4px 10px 4px;
  font: 600 12px/1.2 var(--font-mono);
  color: var(--flow-cream);
  background: var(--flow-deep);
  border: 1px solid var(--flow-hair);
  border-radius: 999px;
  white-space: pre;
}
.flow-stat b { font-weight: 700; color: var(--flow-accent); font-variant-numeric: tabular-nums; }

/* ─── stage + grid ─── */

.flow-stage {
  position: relative;
  display: grid;
  grid-template-columns: var(--tpl, repeat(var(--cols, 6), minmax(0, 1fr)));
  column-gap: var(--gx, 16px);
  row-gap: var(--gy, 36px);
  padding: var(--pad-top, 6px) 0 var(--pad-bottom, 6px);
}

.flow-svg {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 1;
  overflow: visible;
  pointer-events: none;
}

.flow-node {
  position: relative;
  z-index: 2;
  min-width: 0;
  grid-column: var(--c, 1) / span var(--cs, 1);
  grid-row: var(--r, 1) / span var(--rs, 1);
}
.flow-node--span { align-self: center; }

/* ─── cards (Win98 bevel) ─── */

.flow-node--card,
.flow-node--note,
.flow-node--chips {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 10px 6px 9px;
  text-align: center;
  color: var(--win98-text, #111);
  background: var(--win98-face, #C0C0C0);
  border: 2px solid;
  border-color: var(--win98-light, #fff) var(--win98-dark, #000) var(--win98-dark, #000) var(--win98-light, #fff);
  box-shadow:
    inset -1px -1px 0 var(--win98-shadow, #808080),
    inset 1px 1px 0 var(--win98-hilight, #dfdfdf),
    3px 3px 0 rgba(0, 0, 0, 0.32);
}

.flow-tone--cream { background: var(--flow-cream); }
.flow-tone--dark {
  color: var(--flow-cream);
  background: var(--flow-deep);
  border-color: var(--flow-deep-edge) color-mix(in srgb, var(--flow-deep) 55%, black) color-mix(in srgb, var(--flow-deep) 55%, black) var(--flow-deep-edge);
  box-shadow:
    inset -1px -1px 0 color-mix(in srgb, var(--flow-deep) 55%, black),
    inset 1px 1px 0 color-mix(in srgb, var(--flow-cream) 10%, var(--flow-deep)),
    3px 3px 0 rgba(0, 0, 0, 0.32);
}

.flow-title {
  font: 700 15px/1.15 var(--font-sans);
  letter-spacing: -0.005em;
  hyphens: manual;
  overflow-wrap: break-word;
  max-width: 100%;
}

.flow-tag {
  font: 600 11px/1.2 var(--font-mono);
  color: #2e2e2e;
  max-width: 100%;
  overflow-wrap: break-word;
}
.flow-tag--parts { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.flow-tag-part { display: block; max-width: 100%; overflow-wrap: break-word; }
.flow-tone--dark .flow-tag { color: color-mix(in srgb, var(--flow-cream) 75%, transparent); }

.flow-badges { display: flex; justify-content: center; gap: 4px; }
.flow-badge {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
}
.flow-badge svg { width: 13px; height: 13px; display: block; }

/* stacked reviewer / digest chips */
.flow-minis { position: relative; width: 38px; height: 17px; margin-top: 1px; }
.flow-mini {
  position: absolute;
  left: calc(var(--i, 0) * 2px);
  right: calc((2 - var(--i, 0)) * 2px);
  top: calc(var(--i, 0) * 4px);
  height: 7px;
  background: #fff;
  border: 1px solid #6a6a6a;
  border-radius: 2px;
  box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.2);
}

/* status chip (PASS / BLOCKED / REFUSED …) */
.flow-chip {
  display: inline-block;
  min-width: 62px;
  padding: 3px 6px 2px;
  font: 700 10px/1.2 var(--font-mono);
  letter-spacing: 0.07em;
  text-align: center;
  color: var(--flow-ok);
  background: var(--flow-deep);
  border: 1px solid rgba(140, 255, 166, 0.55);
}
.flow-chip[data-tone="ok"] { color: var(--flow-ok); border-color: rgba(140, 255, 166, 0.6); }
.flow-chip[data-tone="bad"] { color: var(--flow-bad); background: #3a0f1b; border-color: rgba(255, 122, 147, 0.7); }
.flow-chip[data-tone="neutral"] { color: #d9d9d9; background: #4a4a4a; border-color: #8c8c8c; }
.flow-chip[data-tone="idle"] { opacity: 0; }

/* glyphs (envelope / check / snapshot) */
.flow-glyph { display: inline-grid; place-items: center; width: 20px; height: 20px; color: #1C4030; }
.flow-glyph-svg { width: 18px; height: 18px; display: block; }
.flow-glyph--snapshot { color: #3a3a3a; }
.flow-tone--dark .flow-glyph { color: rgba(244, 235, 208, 0.85); }

/* pulse ring + lit state (opacity-only; glow is static) */
.flow-ring {
  position: absolute;
  inset: -4px;
  border: 2px solid var(--flow-accent);
  box-shadow: 0 0 10px var(--flow-accent-glow);
  opacity: 0;
  pointer-events: none;
}
.flow-node::after {
  content: '';
  position: absolute;
  inset: -4px;
  border: 2px solid var(--flow-accent);
  box-shadow: 0 0 12px var(--flow-accent-glow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms var(--ease-out-strong, cubic-bezier(0.23, 1, 0.32, 1));
}
.flow-node[data-state="lit"]::after { opacity: 1; }

[data-hidden] { opacity: 0; }
.flow-glyph,
.flow-elabel-sub { transition: opacity 200ms var(--ease-out-strong, cubic-bezier(0.23, 1, 0.32, 1)); }

/* ─── tracks (parallel builds) ─── */

.flow-node--tracks { display: grid; gap: 8px; padding: 2px 0 0; }
.flow-tracks-label {
  justify-self: center;
  padding: 3px 10px;
  font: 600 11px/1.2 var(--font-mono);
  letter-spacing: 0.03em;
  text-align: center;
  color: var(--flow-cream);
  background: var(--flow-deep);
  border: 1px solid var(--flow-hair);
  border-radius: 999px;
}
.flow-track { display: flex; align-items: center; gap: 8px; }
.flow-lock { display: inline-grid; place-items: center; width: 14px; height: 14px; color: color-mix(in srgb, var(--flow-cream) 80%, transparent); flex-shrink: 0; }
.flow-lock .flow-glyph-svg { width: 14px; height: 14px; }
.flow-track-line { flex: 1; height: 0; border-top: 2px dashed color-mix(in srgb, var(--flow-cream) 32%, transparent); }

/* ─── bands / lane groups ─── */

.flow-node--band,
.flow-node--lanes {
  border: 1.5px dashed var(--flow-hair);
  border-radius: 10px;
  background: color-mix(in srgb, var(--flow-deep) 45%, transparent);
}
.flow-node--band { pointer-events: none; z-index: 0; }
.flow-node--lanes { padding: 16px 7px 8px; }
.flow-band-label {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0 6px;
  font: 600 10px/16px var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  color: color-mix(in srgb, var(--flow-cream) 82%, transparent);
  background: var(--flow-bg);
}
.flow-lanes { display: grid; gap: 8px; }
.flow-subcard {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  text-align: center;
  color: var(--win98-text, #111);
  background: var(--win98-face, #C0C0C0);
  border: 2px solid;
  border-color: var(--win98-light, #fff) var(--win98-dark, #000) var(--win98-dark, #000) var(--win98-light, #fff);
  box-shadow: inset -1px -1px 0 var(--win98-shadow, #808080), 2px 2px 0 rgba(0, 0, 0, 0.3);
}

/* ─── chips group + notes ─── */

.flow-node--chips { align-items: stretch; gap: 6px; padding: 8px 6px; }
/* the group itself has no box: its cards float, so a collapsed deck never
   sits in an empty frame */
.flow-node--chips.flow-tone--dark { background: transparent; border-color: transparent; box-shadow: none; }
.flow-node--chips { justify-content: center; }
.flow-subchips { display: flex; flex-direction: column; gap: 6px; }
.flow-node--chips > .flow-title { align-self: center; text-align: center; }
.flow-node--chips > .flow-tag { align-self: center; text-align: center; }
.flow-subchip {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 6px 5px;
  text-align: center;
  /* a small Win98 card, same chrome as the other boxes (opaque, so a stacked
     deck never shows the cards behind through it) */
  color: var(--win98-text, #111);
  background: var(--win98-face, #C0C0C0);
  border: 2px solid;
  border-color: var(--win98-light, #fff) var(--win98-dark, #000) var(--win98-dark, #000) var(--win98-light, #fff);
  box-shadow:
    inset -1px -1px 0 var(--win98-shadow, #808080),
    inset 1px 1px 0 var(--win98-hilight, #dfdfdf),
    3px 3px 0 rgba(0, 0, 0, 0.32);
  transform-origin: 50% 0;
  transition:
    transform 520ms var(--ease-in-out-strong, cubic-bezier(0.77, 0, 0.175, 1)),
    clip-path 520ms var(--ease-in-out-strong, cubic-bezier(0.77, 0, 0.175, 1));
}
.flow-subchip { clip-path: inset(-12px -12px -12px -12px); }
.flow-subchip-label,
.flow-subchip-detail { transition: opacity 200ms var(--ease-out-strong, cubic-bezier(0.23, 1, 0.32, 1)) 160ms; }
/* stacked: chips slide into a small deck, cropped to the front card's label */
.flow-node--chips[data-stacked="1"] .flow-subchip {
  transform: translateY(var(--stack-y, 0px)) scale(var(--stack-s, 1));
  clip-path: inset(-12px -12px var(--stack-clip, 0px) -12px);
  z-index: var(--stack-z, 1);
}
.flow-node--chips[data-stacked="1"] .flow-subchip-detail,
.flow-node--chips[data-stacked="1"] .flow-subchip:not(:first-child) .flow-subchip-label {
  opacity: 0;
  transition-delay: 0ms;
}
/* count of stacked agents/checks on the front card */
.flow-subchip:first-child::after {
  content: attr(data-count);
  position: absolute;
  top: -8px;
  right: -8px;
  padding: 2px 4px;
  font: 700 10px/1 var(--font-mono);
  color: var(--flow-cream);
  background: var(--flow-deep);
  border: 1px solid color-mix(in srgb, var(--flow-cream) 40%, var(--flow-deep));
  z-index: 5;
  opacity: 0;
  transition: opacity 200ms var(--ease-out-strong, cubic-bezier(0.23, 1, 0.32, 1));
}
.flow-node--chips[data-stacked="1"] .flow-subchip:first-child::after { opacity: 1; transition-delay: 260ms; }
.flow-node--chips:focus-visible { outline: 2px solid var(--flow-accent); outline-offset: 3px; }
.flow-subchip-label { font: 700 12.5px/1.15 var(--font-sans); overflow-wrap: break-word; min-width: 0; }
.flow-subchip-detail { font: 500 10.5px/1.3 var(--font-mono); color: rgba(0, 0, 0, 0.66); overflow-wrap: break-word; min-width: 0; max-width: 100%; }
/* sequence highlight: an accent outline whose opacity is animated */
.flow-subchip-lit {
  position: absolute;
  inset: -2px;
  border: 2px solid var(--flow-accent);
  box-shadow: 0 0 8px var(--flow-accent-glow);
  opacity: 0;
  pointer-events: none;
}

/* labelled mini pills (build agent inputs) */
.flow-pills { display: flex; flex-direction: column; align-items: center; gap: 3px; margin-top: 2px; max-width: 100%; }
.flow-pill {
  max-width: 100%;
  padding: 2px 6px 1px;
  font: 600 10px/1.25 var(--font-mono);
  color: #2e2e2e;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid #8a8a8a;
  border-radius: 2px;
  overflow-wrap: break-word;
}

.flow-node--note { align-items: flex-start; text-align: left; gap: 6px; padding: 9px 11px 10px; }
.flow-note-top { display: flex; align-items: center; gap: 7px; }
.flow-note-text { margin: 0; font: 500 12px/1.4 var(--font-mono); color: color-mix(in srgb, var(--flow-cream) 82%, transparent); }

/* ─── connectors ─── */

.flow-edge {
  fill: none;
  stroke: var(--flow-line);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.flow-edge--loop { stroke-opacity: 0.62; stroke-width: 1.75; }
.flow-edge--branch { stroke-opacity: 0.5; stroke-width: 1.5; }
.flow-arrow { fill: var(--flow-line); stroke: none; }
.flow-arrow--loop { fill-opacity: 0.8; }
.flow-arrow--branch { fill-opacity: 0.7; }
.flow-hot {
  fill: none;
  stroke: var(--flow-accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}

.flow-elabel {
  position: absolute;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 9px 3px;
  font: 600 10.5px/1.2 var(--font-mono);
  letter-spacing: 0.03em;
  white-space: nowrap;
  color: var(--flow-cream);
  background: var(--flow-deep);
  border: 1px solid var(--flow-hair);
  border-radius: 999px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.flow-elabel--v { transform: translate(-50%, -50%) rotate(-90deg); }
.flow-elabel--human { color: #1c1c1c; background: var(--flow-cream); border-color: color-mix(in srgb, var(--flow-cream) 60%, black); }
.flow-elabel-sub { padding-left: 7px; border-left: 1px solid color-mix(in srgb, var(--flow-cream) 35%, transparent); }
.flow-count { color: var(--flow-accent); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ─── packets ─── */

.flow-packets { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.flow-packet {
  position: absolute;
  left: 0;
  top: 0;
  width: 9px;
  height: 9px;
  margin: -4.5px 0 0 -4.5px;
  border-radius: 50%;
  background: var(--flow-accent-hi);
  box-shadow: 0 0 0 2px var(--flow-accent-soft), 0 0 10px 3px var(--flow-accent-glow);
  opacity: 0;
  will-change: transform, opacity;
}
.flow-packet.is-sm { width: 6px; height: 6px; margin: -3px 0 0 -3px; }
.flow-packet.is-bad {
  background: #FFC2CE;
  box-shadow: 0 0 0 2px rgba(255, 122, 147, 0.3), 0 0 10px 3px rgba(255, 122, 147, 0.6);
}

.flow-caption { margin: 8px 2px 0; font-size: 0.75rem; letter-spacing: 0.02em; opacity: 0.7; }

/* ─── entry phases (JS drives data-phase) ─── */

.flow[data-phase="pre"] .flow-node,
.flow[data-phase="pre"] .flow-edge,
.flow[data-phase="pre"] .flow-arrow,
.flow[data-phase="pre"] .flow-elabel,
.flow[data-phase="pre"] .flow-stat { opacity: 0; }
.flow[data-phase="entering"] .flow-arrow,
.flow[data-phase="entering"] .flow-elabel { opacity: 0; }

/* dense: crowded single-row diagrams (wide layout only; the narrow stack has room) */
@container flow (min-width: 640px) {
  .flow--dense .flow-title { font-size: 13.5px; }
  .flow--dense .flow-tag { font-size: 10px; line-height: 1.2; }
  .flow--dense .flow-node--card,
  .flow--dense .flow-node--note,
  .flow--dense .flow-node--chips { padding-inline: 5px; }
  .flow--dense .flow-chip { min-width: 52px; padding-inline: 4px; }
  .flow--dense .flow-subchip-label { font-size: 12px; }
  .flow--dense .flow-subchip-detail { font-size: 10px; }
}

/* ─── narrow: vertical stack, loops become return lines on the right edge ─── */

@container flow (max-width: 639.98px) {
  .flow-stage {
    grid-template-columns: repeat(var(--ncols, 2), minmax(0, 1fr));
    column-gap: 12px;
    row-gap: var(--ngy, 32px);
    padding-right: var(--ngutter, 0px);
  }
  .flow-node {
    grid-column: var(--nc, 1) / span var(--ncs, 2);
    grid-row: auto;
  }
  .flow-node--span { align-self: stretch; }
  .flow-node--band,
  .flow-node--narrow-hidden { display: none; }
  .flow-lanes { grid-template-columns: repeat(var(--ncols, 2), minmax(0, 1fr)); }
  .flow-node--card { padding-block: 11px 10px; }
  .flow-title { font-size: 16px; }
  .flow-tag { font-size: 11.5px; }
  .flow-node--note { padding-inline: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .flow *,
  .flow *::after { transition: none !important; }
}

/* ══════════════════════════════════════════════════════════════
   Case-study hero: Win98 page windows pop up one by one and fan out
   (case-study-hero-fan.js). transform / opacity only.
   ══════════════════════════════════════════════════════════════ */

.finder-poster-overlay-hero:has(.hf),
.finder-poster-hero:has(.hf) { background: var(--poster-bg); display: flex; }
.finder-poster-overlay-hero:has(.hf) { overflow: visible; }
/* Phones: a 16:9 strip leaves the cascade ~150px wide. Give the hero a square
   slot and a larger stack so the windows read as windows. */
@media (max-width: 600px) {
  .finder-poster-overlay-hero:has(.hf) { aspect-ratio: 1 / 1; }
  .finder-poster-overlay-hero .hf-stage { width: 58%; }
}

.hf {
  --hf-ease: var(--ease-out-strong, cubic-bezier(0.23, 1, 0.32, 1));
  --hf-move: var(--ease-in-out-strong, cubic-bezier(0.77, 0, 0.175, 1));
  container-type: inline-size;
  position: relative;
  flex: 1;
  overflow: visible;   /* windows may overhang the hero edge (shadows, hover lift) rather than clip */
  min-height: 0;
}
.hf-stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 36%;
  aspect-ratio: 4 / 3;
  translate: -50% -50%;
}

/* a Win98 window, same chrome as the OS */
.hf-win {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--win98-face, #C0C0C0);
  box-shadow:
    inset 1px 1px 0 var(--win98-light, #fff),
    inset -1px -1px 0 var(--win98-dark, #000),
    inset 2px 2px 0 var(--win98-hilight, #DFDFDF),
    inset -2px -2px 0 var(--win98-shadow, #808080),
    0 14px 30px rgba(0, 0, 0, 0.4);
  padding: 3px;
  box-sizing: border-box;
  transform-origin: 50% 100%;
  z-index: var(--hf-z, 1);
  opacity: 0;
  transform: translate(0, 0) rotate(0deg) scale(0.9);
}
.hf-bar {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 18px;
  padding: 0 3px 0 4px;
  flex-shrink: 0;
  background: var(--win98-face, #C0C0C0);
  box-shadow: inset 0 -1px 0 var(--win98-shadow, #808080);
}
.hf-bar-icon {
  width: 10px; height: 10px; flex-shrink: 0;
  background: color-mix(in srgb, var(--poster-bg, #1B2F6B) 70%, white);
  box-shadow: inset -1px -1px 0 var(--win98-shadow, #808080), inset 1px 1px 0 var(--win98-light, #fff);
}
.hf-bar-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font: 700 9.5px/1 var(--font-system, system-ui);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--win98-text, #000);
}
.hf-bar-btns { display: flex; gap: 2px; flex-shrink: 0; }
.hf-btn {
  position: relative;
  width: 12px; height: 11px;
  background: var(--win98-face, #C0C0C0);
  box-shadow:
    inset 1px 1px 0 var(--win98-light, #fff),
    inset -1px -1px 0 var(--win98-dark, #000),
    inset -2px -2px 0 var(--win98-shadow, #808080);
}
.hf-btn::after { content: ''; position: absolute; background: var(--win98-dark, #000); }
.hf-btn--min::after { left: 3px; right: 4px; bottom: 3px; height: 1.5px; }
.hf-btn--max::after { left: 3px; right: 3px; top: 3px; bottom: 3px; background: transparent; box-shadow: inset 0 1.5px 0 #000, inset 0 0 0 1px #000; }
.hf-btn--close::after { left: 3px; right: 3px; top: 50%; height: 1.5px; translate: 0 -50%; rotate: 45deg; box-shadow: 0 0 0 0 #000; }
.hf-btn--close::before { content: ''; position: absolute; left: 3px; right: 3px; top: 50%; height: 1.5px; translate: 0 -50%; rotate: -45deg; background: #000; z-index: 1; }
.hf-body {
  flex: 1;
  min-height: 0;
  margin-top: 2px;
  box-shadow: inset 1px 1px 0 var(--win98-shadow, #808080), inset -1px -1px 0 var(--win98-light, #fff);
  padding: 2px;
  box-sizing: border-box;
  display: flex;
}

/* pop up (scale + fade, at the centre) → fan out (move + rotate) */
/* each window pops open at its own place in the cascade, one after another */
@keyframes hf-pop {
  0%   { opacity: 0; transform: translate(var(--hf-x), var(--hf-y)) scale(0.94); }
  100% { opacity: 1; transform: translate(var(--hf-x), var(--hf-y)) scale(1); }
}
.hf[data-state="playing"] .hf-win {
  animation: hf-pop 240ms var(--hf-ease) both;
  animation-delay: calc(var(--hf-i) * 130ms);
}
.hf[data-state="settled"] .hf-win {
  opacity: 1;
  transform: translate(var(--hf-x), var(--hf-y)) scale(1);
  transition: transform 200ms var(--hf-ease);
}
@media (hover: hover) and (pointer: fine) {
  .hf[data-state="settled"] .hf-win:hover {
    transform: translate(var(--hf-x), calc(var(--hf-y) - 4%)) scale(1);
  }
}

/* the page inside each window */
.hf-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6%;
  padding: 0 0 6%;
  box-sizing: border-box;
  background: #F5EEDC;
  overflow: hidden;
}
.hf-nav { display: flex; align-items: center; justify-content: space-between; padding: 5% 7% 0; }
.hf-logo { width: 16%; height: 5px; border-radius: 3px; background: var(--hf-accent); }
.hf-navlinks { width: 34%; height: 4px; border-radius: 3px; background: rgba(0, 0, 0, 0.16); }
.hf-hero { display: flex; gap: 6%; padding: 0 7%; min-height: 0; }
.hf-copy { flex: 1.2; display: flex; flex-direction: column; gap: 5px; justify-content: center; }
.hf-h { display: block; height: 7px; width: 100%; border-radius: 3px; background: rgba(0, 0, 0, 0.75); }
.hf-h--short { width: 70%; }
.hf-p { display: block; height: 4px; width: 90%; border-radius: 3px; background: rgba(0, 0, 0, 0.18); }
.hf-cta { display: block; margin-top: 3px; width: 42%; height: 10px; border-radius: 3px; background: var(--hf-accent); }
.hf-media { flex: 1; aspect-ratio: 4 / 3; border-radius: 3px; background: color-mix(in srgb, var(--hf-accent) 30%, #F5EEDC); }
.hf-rows { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 0 7%; margin-top: auto; }
.hf-tile { display: block; height: 18px; border-radius: 3px; background: rgba(0, 0, 0, 0.08); }

/* layout variety */
.hf-page--centered .hf-hero { flex-direction: column; }
.hf-page--centered .hf-copy { align-items: center; }
.hf-page--centered .hf-media { display: none; }
.hf-page--image .hf-hero { flex-direction: column-reverse; padding: 0; }
.hf-page--image .hf-media { aspect-ratio: 16 / 6; border-radius: 0; }
.hf-page--image .hf-copy { padding: 0 7%; }
.hf-page--form .hf-media { background: transparent; border: 1.5px dashed color-mix(in srgb, var(--hf-accent) 70%, transparent); }
.hf-page--event { background: #1E1B2E; }
.hf-page--event .hf-h { background: #F5EEDC; }
.hf-page--event .hf-p, .hf-page--event .hf-navlinks, .hf-page--event .hf-tile { background: rgba(245, 238, 220, 0.2); }
.hf-page--event .hf-media { background: color-mix(in srgb, var(--hf-accent) 55%, #1E1B2E); }
.hf-page--long .hf-rows { grid-template-columns: 1fr; }
.hf-page--long .hf-tile { height: 6px; }
.hf-page--minimal .hf-media { display: none; }

/* ══════════════════════════════════════════════════════════════
   Client Dashboard hero "Converge" (case-study-hero-brain.js):
   source windows fly into one dashboard window. The stage is a fixed
   design size scaled to the hero; 1em inside a page = 1px × its window scale.
   ══════════════════════════════════════════════════════════════ */

.bh { --bh-mono: var(--font-mono, ui-monospace, 'SF Mono', Menlo, monospace); }
.bh-stage {
  position: absolute;
  left: 50%; top: 50%;
  transform-origin: 50% 50%;
}
.bh-win {
  position: absolute;
  display: flex; flex-direction: column;
  box-sizing: border-box;
  padding: 3px;
  background: var(--win98-face, #C0C0C0);
  box-shadow:
    inset 1px 1px 0 var(--win98-light, #fff),
    inset -1px -1px 0 var(--win98-dark, #000),
    inset 2px 2px 0 var(--win98-hilight, #DFDFDF),
    inset -2px -2px 0 var(--win98-shadow, #808080),
    0 12px 26px rgba(0, 0, 0, 0.4);
  will-change: transform, opacity;
}
/* beat the @container shrink rules of .hf: this hero scales as one unit instead */
.bh .hf-bar { height: 18px; gap: 5px; }
.bh .hf-bar-title { font: 700 8.5px/1 var(--bh-mono); letter-spacing: 0.05em; }
.bh .hf-btn { width: 12px; height: 11px; }
.bh-win--mini .hf-btn--min, .bh-win--mini .hf-btn--max { display: none; }
.bh-win--mini .hf-bar-title { font-size: 7.5px; letter-spacing: 0.01em; }
.bh-ico { display: block; flex-shrink: 0; width: 11px; height: 11px; }
.bh-ico svg { display: block; width: 100%; height: 100%; }
.bh-ico--dot {
  background: var(--c, #888);
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.65), inset -1px -1px 0 rgba(0, 0, 0, 0.35);
}

.bh-page {
  flex: 1; min-width: 0; min-height: 0;
  box-sizing: border-box;
  display: flex; flex-direction: column;
  gap: 3em;
  padding: 4em;
  background: #F5EEDC;
  overflow: hidden;
}
.bh-page--dash { padding: 3px; gap: 0; }
.bh-ph, .bh-line { display: block; flex: none; height: 2.4em; border-radius: 2em; background: rgba(0, 0, 0, 0.2); }
.bh-ph { background: rgba(0, 0, 0, 0.5); height: 2.6em; }
.bh-row, .bh-inv { display: flex; align-items: center; gap: 3em; flex: none; }
.bh-lab { flex: none; width: 18%; height: 2.6em; border-radius: 2em; background: rgba(0, 0, 0, 0.5); }
.bh-track { position: relative; flex: 1; height: 4.6em; border-radius: 1em; background: rgba(0, 0, 0, 0.08); }
.bh-fill { position: absolute; inset: 0 auto 0 0; width: var(--w); border-radius: 1em; transform-origin: 0 50%; }
.bh-tick { position: absolute; top: -1.2em; bottom: -1.2em; left: 83%; width: max(1px, 0.45em); background: rgba(0, 0, 0, 0.55); }
.b-low, .b-over { background: #D9485F; }
.b-under { background: #E2B33C; }
.b-ok { background: #3FA36B; }
.bh-pill { flex: none; width: 9em; height: 3.8em; border-radius: 2em; }
.bh-sig { width: 46%; height: auto; flex: none; fill: none; stroke: #5B3F8C; stroke-width: 1.6; stroke-linecap: round; }
.bh-dots { display: flex; gap: 2.5em; flex: none; }
.bh-dots i { display: block; width: 3.2em; height: 3.2em; border-radius: 50%; background: var(--c); }
.bh-spark { display: block; width: 100%; flex: 1; min-height: 0; overflow: visible; }
.bh-spark path { fill: none; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; stroke-width: max(1.2px, 1.2em); }
.bh-spark .a1 { stroke: #6C5CE7; }
.bh-spark .a2 { stroke: #2E8B6E; }
.bh-kpi { display: flex; align-items: center; gap: 4em; flex: 1; min-height: 0; }
.bh-kpi-r { flex: 1; display: flex; flex-direction: column; gap: 3em; }
.bh-ring { display: block; width: 17em; height: 17em; flex: none; margin: auto; }
.bh-kpi .bh-ring { margin: 0; }
.bh-ring circle { fill: none; stroke-width: 5; }
.bh-ring .r0 { stroke: rgba(0, 0, 0, 0.1); }
.bh-ring .r1 { stroke: #3FA36B; stroke-linecap: round; }

/* the assembled dashboard: one panel per kind of information */
.bh-dash {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 3px;
}
.bh-panel {
  min-width: 0; min-height: 0;
  display: flex; flex-direction: column; gap: 2.6em;
  padding: 3.2em;
  box-sizing: border-box;
  background: #FBF7EA;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 2px;
  overflow: hidden;
  will-change: transform, opacity;
}
.p-hours { grid-area: 1 / 1 / 3 / 2; justify-content: space-between; }
.p-rate  { grid-area: 1 / 2 / 2 / 3; }
.p-kpi   { grid-area: 1 / 3 / 2 / 4; align-items: center; justify-content: center; }
.p-spark { grid-area: 2 / 2 / 3 / 4; }
.p-kpi .bh-ring { width: 20em; height: 20em; }
.bh-pair { flex: 1; min-height: 0; display: flex; align-items: flex-end; justify-content: center; gap: 6em; }
.bh-vbar { display: block; width: 9em; border-radius: 1em 1em 0 0; transform-origin: 50% 100%; }
.v-t { height: 52%; background: #8E7CC3; }
.v-e { height: 82%; background: #3FA36B; }
.bh-grow { will-change: transform; }
.bh-glow {
  position: absolute; inset: -5px; pointer-events: none;
  border: 2px solid #F4B860; border-radius: 3px;
  opacity: 0;
}
.bh-badge {
  position: absolute; right: -10px; top: -10px;
  width: 22px; height: 22px; box-sizing: border-box;
  border-radius: 50%;
  background: #D9485F; color: #fff;
  border: 2px solid #F5EEDC;
  font: 800 13px/18px var(--bh-mono);
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  z-index: 3;
}

@container (max-width: 520px) {
  .hf-stage { width: 44%; }
  .hf-bar { height: 14px; }
  .hf-bar-title { font-size: 7.5px; }
  .hf-btn { width: 9px; height: 8px; }
}

/* the group's title and tag follow the deck in and out */
.flow-node--chips > .flow-title,
.flow-node--chips > .flow-tag {
  transition: transform 520ms var(--ease-in-out-strong, cubic-bezier(0.77, 0, 0.175, 1));
}
.flow-node--chips[data-stacked="1"] > .flow-title { transform: translateY(var(--title-shift, 0px)); }
.flow-node--chips[data-stacked="1"] > .flow-tag { transform: translateY(var(--tag-shift, 0px)); }

/* float: a long stack doesn't stretch its row. The fanned list is laid over the
   node (and its neighbours, while fanned); the node reserves the stacked size. */
.flow[data-layout="wide"] .flow-node--float { min-height: 150px; }
.flow[data-layout="wide"] .flow-node--float .flow-subchips {
  position: absolute;
  left: 5px;
  right: 5px;
  top: calc(50% - var(--grp-h, 0px) / 2);
  z-index: 6;
}
.flow[data-layout="wide"] .flow-node--float[data-stacked="0"] { z-index: 8; }
