/* ═══ beat.css — THE BEAT FLOW (shared by KREMLIN and CAPITOL) ═══
   A beat now plays as three swipe-able views, each with the stat chips pinned on top:
     1. BRIEF     — an old telex machine whirrs to life and types the day's brief, letter by letter (streamed, ChatGPT-fast)
     2. ADVISERS  — "your team is convened" (app fills the slot)
     3. DECISION  — the decision screen (app fills the slot)
   Swipe RIGHT = forward (configurable). Mount with BeatFlow.mount(el, { theme: 'kremlin' | 'capitol' }) — see beat.js.
   Theme = [data-theme] on .bf. In KREMLIN the machine/paper/chips read the era vars (--accent --gold --paper --ink) when present.
   Motion: transform/opacity only. prefers-reduced-motion: no whirr, the brief appears instantly, views cross instantly. */

.bf { --bf-body: #2d3a36; --bf-body2: #1b2420; --bf-accent: var(--accent, #b0121f); --bf-gold: var(--gold, #d4a93c); --bf-paper: #efe6cf; --bf-ink: #1b1710; --bf-rule: #b0121f;
  --bf-bg: #0b0a0c; --bf-chip: #17120f; --bf-text: #e9dfc4; --v: 0; --dir: 1; --drag: 0px;
  position: relative; display: flex; flex-direction: column; width: 100%; height: 100%; min-height: 560px; overflow: hidden; background: var(--bf-bg); color: var(--bf-text); font-family: var(--sans, -apple-system, system-ui, sans-serif); user-select: none; -webkit-user-select: none; }
.bf[data-theme="capitol"] { --bf-body: #26324a; --bf-body2: #161d2e; --bf-accent: #1f3a7a; --bf-gold: #d9b95a; --bf-rule: #2f4f9a; --bf-bg: #090b10; --bf-chip: #11151f; --bf-text: #ece6d6; }

/* ── stat chips (on every view) ── */
.bf-chips { position: relative; z-index: 6; display: flex; gap: 6px; padding: 9px 10px 8px; overflow-x: auto; scrollbar-width: none; background: linear-gradient(180deg, rgba(0,0,0,.7), rgba(0,0,0,0)); }
.bf-chips::-webkit-scrollbar { display: none; }
.bf-chip { position: relative; flex: 1 0 auto; display: flex; align-items: center; gap: 7px; padding: 6px 10px 6px 7px; border-radius: 5px; background: var(--bf-chip); border: 1px solid color-mix(in srgb, var(--bf-gold) 38%, transparent); box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 4px 10px -6px #000; }
.bf-chip svg { width: 20px; height: 20px; flex: none; color: var(--bf-gold); }
.bf-chip .t { display: grid; gap: 2px; min-width: 0; }
.bf-chip .lbl { font: 800 8px/1 var(--sans, sans-serif); letter-spacing: .16em; text-transform: uppercase; color: color-mix(in srgb, var(--bf-text) 62%, transparent); white-space: nowrap; }
.bf-chip .val { font: 700 15px/1 var(--serif, Georgia, serif); font-variant-numeric: tabular-nums; color: var(--bf-text); }
.bf-chip .bar { position: absolute; left: 7px; right: 7px; bottom: 2px; height: 2px; background: rgba(255,255,255,.08); overflow: hidden; }
.bf-chip .bar i { display: block; height: 100%; background: var(--bf-gold); transform-origin: left; transform: scaleX(var(--f, .5)); transition: transform .9s cubic-bezier(.3,.7,.2,1); }
.bf-chip .dl { position: absolute; right: 6px; top: -9px; padding: 2px 5px; border-radius: 3px; font: 800 10px/1 var(--sans, sans-serif); opacity: 0; pointer-events: none; color: #fff; }
.bf-chip[data-trend="up"] .dl { background: #2f8a4a; } .bf-chip[data-trend="down"] .dl { background: #b0121f; }
.bf-chip.pulse .dl { animation: bf-dl 1.8s ease-out both; }
.bf-chip.pulse[data-trend="up"] { animation: bf-flash-up .9s ease-out; } .bf-chip.pulse[data-trend="down"] { animation: bf-flash-dn .9s ease-out; }
@keyframes bf-dl { 0% { opacity: 0; transform: translateY(8px); } 15% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-6px); } }
@keyframes bf-flash-up { 0% { transform: scale(1.06); } 100% { transform: scale(1); } } @keyframes bf-flash-dn { 0% { transform: translateX(-3px); } 25% { transform: translateX(3px); } 50% { transform: translateX(-2px); } 100% { transform: none; } }

/* ── the three views: panes slide on a rail; --v = current view, --dir = +1 (swipe right = forward) ── */
.bf-viewport { position: relative; flex: 1; min-height: 0; overflow: hidden; touch-action: pan-y; }
.bf-pane { position: absolute; inset: 0; display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; will-change: transform;
  transform: translateX(calc((var(--v) - var(--i)) * 100% * var(--dir) + var(--drag))); transition: transform .42s cubic-bezier(.2, .8, .2, 1); }
.bf.dragging .bf-pane { transition: none; }
.bf-slot { padding: 6px 14px 90px; }

/* ── pane 1: the telex ── */
.bf-brief { flex-direction: column-reverse; overflow: hidden; background: radial-gradient(120% 60% at 50% 0%, color-mix(in srgb, var(--bf-accent) 22%, transparent), transparent 70%); }
.bf-machine { position: relative; z-index: 3; display: block; width: 100%; max-width: 440px; height: auto; margin: 0 auto 44px; flex: none; filter: drop-shadow(0 12px 14px rgba(0,0,0,.55)); }
.bf-machine .enamel { fill: var(--bf-body); } .bf-machine .enamel2 { fill: var(--bf-body2); } .bf-machine .brass { fill: var(--bf-gold); } .bf-machine .accent { fill: var(--bf-accent); }
.bf-machine .win { fill: #06080a; } .bf-machine .glass { fill: url(#bfShine); }
.bf-machine .key { fill: #d9d2bd; stroke: #14110d; stroke-width: 1; transform-box: fill-box; transform-origin: center; transition: transform .05s; }
.bf-machine .key.dn { transform: translateY(1.8px) scale(.92); fill: #fff3c8; }
.bf-machine .spin { transform-box: fill-box; transform-origin: center; } .bf-machine .dial { transform-box: fill-box; transform-origin: center; }
.bf-machine .lamp { fill: #3a1010; } .bf-machine.on .lamp { fill: #ff5a4a; filter: drop-shadow(0 0 5px #ff5a4a); animation: bf-lamp 1.2s ease-in-out infinite alternate; }
.bf-machine .head { transform: translateX(0); }
.bf-machine.on .head { animation: bf-head .8s linear infinite alternate; }
.bf-machine.on .spin { animation: bf-spin .9s linear infinite; } .bf-machine.on .spin.r { animation-direction: reverse; }
.bf-machine.on .dial { animation: bf-spin 5s linear infinite; }
.bf-machine.on .shake { animation: bf-shake .11s steps(2) infinite; }
.bf-machine.boot .shake { animation: bf-boot .5s steps(2) 3; } .bf-machine.boot .lamp { animation: bf-lamp .12s steps(2) 6; }
@keyframes bf-head { from { transform: translateX(0); } to { transform: translateX(196px); } }
@keyframes bf-spin { to { transform: rotate(360deg); } } @keyframes bf-lamp { from { opacity: .55; } to { opacity: 1; } }
@keyframes bf-shake { 0% { transform: translate(0, 0); } 100% { transform: translate(.5px, .7px); } } @keyframes bf-boot { 0% { transform: translate(-1.4px, 0); } 100% { transform: translate(1.4px, 1px); } }

/* the paper: sprocket-holed teleprinter roll feeding out of the slit; the text is typed at its bottom edge and rolls up */
.bf-paper { position: relative; z-index: 2; flex: 1; min-height: 0; width: min(360px, 92%); margin: 0 auto -26px; padding: 40px 26px 36px; display: flex; flex-direction: column; overflow-y: auto; scrollbar-width: none; cursor: pointer;
  background: repeating-linear-gradient(0deg, transparent 0 21px, color-mix(in srgb, var(--bf-rule) 8%, transparent) 21px 22px), linear-gradient(90deg, rgba(0,0,0,.1), transparent 6%, transparent 94%, rgba(0,0,0,.12)), var(--bf-paper);
  color: var(--bf-ink); box-shadow: 0 0 0 1px rgba(0,0,0,.25), 0 16px 30px -12px #000; }
.bf-paper::-webkit-scrollbar { display: none; }
.bf-paper::before, .bf-paper::after { content: ""; position: sticky; top: 0; display: block; }
.bf-sprockets { position: absolute; top: 0; bottom: 0; width: 14px; pointer-events: none; opacity: .55;
  background: radial-gradient(circle, rgba(0,0,0,.65) 0 2.4px, transparent 2.8px) 50% 0 / 14px 16px repeat-y; }
.bf-sprockets.l { left: 4px; } .bf-sprockets.r { right: 4px; }
.bf-text { margin-top: auto; position: relative; z-index: 1; font: 500 13px/1.7 'Courier New', ui-monospace, 'SFMono-Regular', monospace; letter-spacing: .035em; white-space: pre-wrap; word-break: break-word; color: var(--bf-ink); text-transform: uppercase; }
.bf[data-caps="false"] .bf-text { text-transform: none; }
.bf-text .ln { display: block; min-height: 1.7em; } .bf-text .ln.h { font-weight: 800; letter-spacing: .12em; color: var(--bf-rule); border-bottom: 1.5px solid var(--bf-rule); margin: 2px 0 6px; padding-bottom: 3px; }
.bf-caret { display: inline-block; width: .62em; height: 1.05em; margin-left: 1px; vertical-align: -.16em; background: var(--bf-ink); animation: bf-caret .9s steps(2) infinite; }
.bf.typing .bf-caret { animation: none; }
@keyframes bf-caret { 50% { opacity: 0; } }
.bf-paper .bf-fill { min-height: 8px; }

/* ── nav: where you are + the swipe cue ── */
.bf-nav { position: absolute; left: 0; right: 0; bottom: 0; z-index: 7; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px)); background: linear-gradient(0deg, rgba(0,0,0,.9), rgba(0,0,0,0)); pointer-events: none; }
.bf-dot { all: unset; box-sizing: border-box; pointer-events: auto; cursor: pointer; padding: 6px 10px; border-radius: 3px; font: 800 9px/1 var(--sans, sans-serif); letter-spacing: .18em; text-transform: uppercase; color: color-mix(in srgb, var(--bf-text) 50%, transparent); border: 1px solid transparent; transition: color .25s, border-color .25s; }
.bf-dot[aria-current="true"] { color: var(--bf-gold); border-color: color-mix(in srgb, var(--bf-gold) 55%, transparent); background: rgba(0,0,0,.4); }
.bf-dot:focus-visible { outline: 2px solid var(--bf-gold); }
.bf-cue { position: absolute; z-index: 8; top: 62px; left: 50%; display: flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 20px; font: 800 10px/1 var(--sans, sans-serif); letter-spacing: .22em; color: #1a1208; background: var(--bf-gold); box-shadow: 0 6px 16px -6px #000; opacity: 0; transform: translateX(-50%) translateY(-10px); pointer-events: none; transition: opacity .4s, transform .4s; }
.bf-cue .arr { display: inline-block; animation: bf-arr 1s ease-in-out infinite alternate; }
.bf[data-cue="true"] .bf-cue { opacity: 1; transform: translateX(-50%); }
@keyframes bf-arr { from { transform: translateX(0); } to { transform: translateX(calc(5px * var(--dir))); } }

@media (prefers-reduced-motion: reduce) {
  .bf-pane { transition: none; } .bf-machine.on .head, .bf-machine.on .spin, .bf-machine.on .dial, .bf-machine.on .shake, .bf-machine.boot .shake, .bf-machine.boot .lamp, .bf-machine.on .lamp { animation: none; }
  .bf-cue .arr, .bf-chip.pulse, .bf-caret { animation: none; } .bf-chip .bar i { transition: none; }
}

/* effect chips for adviser cards / decision options: BeatFlow.fx({popularity:+4, influence:-2}) */
.bf-fxs { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.bf-fx { display: inline-flex; align-items: center; gap: 4px; padding: 3px 7px 3px 5px; border-radius: 3px; font: 800 10px/1 var(--sans, sans-serif); letter-spacing: .08em; background: rgba(0,0,0,.45); border: 1px solid currentColor; }
.bf-fx svg { width: 12px; height: 12px; } .bf-fx.up { color: #5fc27a; } .bf-fx.down { color: #ff6a6f; }

/* the staff view */
.bf-h { margin: 8px 0 14px; font: 800 10px/1 var(--sans, sans-serif); letter-spacing: .24em; color: var(--bf-gold); }
.bf-adv { display: grid; grid-template-columns: 72px 1fr; gap: 14px; align-items: start; padding: 14px; margin: 0 0 12px; border-radius: 4px; background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02)); border: 1px solid color-mix(in srgb, var(--bf-gold) 30%, transparent); box-shadow: 0 8px 18px -12px #000; animation: bf-adv .5s cubic-bezier(.2,.8,.2,1) both; }
.bf-adv:nth-of-type(2) { animation-delay: .1s; } .bf-adv:nth-of-type(3) { animation-delay: .2s; }
.bf-adv-face svg { width: 72px; height: 72px; display: block; border-radius: 3px; }
.bf-adv-role { font: 800 9px/1 var(--sans, sans-serif); letter-spacing: .2em; text-transform: uppercase; color: var(--bf-gold); margin-bottom: 5px; }
.bf-adv h5 { margin: 0 0 6px; font: 700 16px/1.1 var(--serif, Georgia, serif); color: var(--bf-text); }
.bf-adv p { margin: 0; font: italic 14px/1.45 var(--serif, Georgia, serif); color: color-mix(in srgb, var(--bf-text) 82%, transparent); }
@keyframes bf-adv { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .bf-adv { animation: none; } }
