/*
 * Bookkeeping-flow animation for the "Boekhouding" showcase spotlight.
 * A receipt gets scanned -> read out by AI -> categorized -> booked, matching
 * the money-flow's visual language for page cohesion. See js/book-flow.js.
 *
 * Prefixed `bk-`; every custom property scoped to `.bk-device` so it can't
 * collide with landing styles (or the sibling money-flow component).
 */
.bk-device {
  /* Light default; [data-theme="dark"] overrides below (matches landing). */
  --bk-surface: #ffffff;
  --bk-surface-2: #f4f2fa;
  --bk-ink: #1e1a2b;
  --bk-ink-soft: #4b4658;
  --bk-ink-faint: #6c6780;
  --bk-line: #ebe7f2;
  --bk-line-strong: #d9d3e6;
  --bk-violet: #7c3aed;
  --bk-violet-soft: rgba(124, 58, 237, 0.12);
  --bk-green: #059669;
  --bk-green-soft: rgba(5, 150, 105, 0.12);
  --bk-amber: #d97706;
  --bk-shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1.5rem 3rem rgba(124, 58, 237, 0.14);
  --bk-num: ui-monospace, "SF Mono", "Geist Mono", Menlo, monospace;
  --bk-ease: cubic-bezier(0.2, 0.75, 0.2, 1);
  --bk-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  width: min(100%, 26rem);
  margin: 0 auto;
  background: var(--bk-surface);
  border: 1px solid var(--bk-line-strong);
  border-radius: 1.4rem;
  box-shadow: var(--bk-shadow);
  overflow: hidden;
  color: var(--bk-ink);
  font-family: inherit;
  -webkit-font-smoothing: antialiased;
}
[data-theme="dark"] .bk-device {
  --bk-surface: #191423;
  --bk-surface-2: #211a30;
  --bk-ink: #f4f1fb;
  --bk-ink-soft: #bab3cd;
  --bk-ink-faint: #8a8399;
  --bk-line: #292337;
  --bk-line-strong: #392f4e;
  --bk-violet: #8b5cf6;
  --bk-violet-soft: rgba(139, 92, 246, 0.16);
  --bk-green: #10b981;
  --bk-green-soft: rgba(16, 185, 129, 0.15);
  --bk-amber: #f59e0b;
  --bk-shadow: 0 2px 4px rgba(0, 0, 0, 0.4), 0 2rem 4rem rgba(88, 28, 135, 0.4);
}
.bk-device *,
.bk-device *::before,
.bk-device *::after { box-sizing: border-box; }

.bk-top {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--bk-line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
}
.bk-brandmark {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 0.45rem;
  flex: none;
  background: linear-gradient(135deg, var(--bk-violet), var(--bk-green));
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 0.8rem;
}
.bk-brandname { font-weight: 700; font-size: 0.85rem; letter-spacing: -0.01em; flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bk-live { margin-left: auto; display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.66rem; font-weight: 600; color: var(--bk-ink-faint); text-transform: lowercase; }
.bk-live i { width: 0.42rem; height: 0.42rem; border-radius: 50%; background: var(--bk-green); animation: bk-pulse 2s var(--bk-ease) infinite; }

/* ---- rail ---- */
.bk-rail { display: flex; padding: 1rem 1.1rem 0.4rem; }
.bk-node { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0.4rem; position: relative; }
.bk-node + .bk-node::before { content: ""; position: absolute; top: 0.72rem; right: 50%; width: 100%; height: 2px; background: var(--bk-line-strong); z-index: 0; }
.bk-node + .bk-node::after { content: ""; position: absolute; top: 0.72rem; right: 50%; width: 0%; height: 2px; background: var(--bk-green); z-index: 1; transition: width 0.5s var(--bk-ease); }
.bk-node.bk-done + .bk-node::after, .bk-node.bk-active + .bk-node::after { width: 100%; }
.bk-dot { width: 1.5rem; height: 1.5rem; border-radius: 50%; position: relative; z-index: 2; background: var(--bk-surface-2); border: 2px solid var(--bk-line-strong); display: grid; place-items: center; transition: all 0.35s var(--bk-spring); color: var(--bk-ink-faint); }
.bk-dot svg { width: 0.8rem; height: 0.8rem; opacity: 0; transform: scale(0.4); transition: all 0.3s var(--bk-spring); }
.bk-node.bk-active .bk-dot { border-color: var(--bk-violet); background: var(--bk-violet-soft); color: var(--bk-violet); transform: scale(1.12); box-shadow: 0 0 0 5px var(--bk-violet-soft); }
.bk-node.bk-done .bk-dot { border-color: var(--bk-green); background: var(--bk-green); color: #fff; }
.bk-node.bk-done .bk-dot svg { opacity: 1; transform: scale(1); }
.bk-num { font-size: 0.72rem; font-weight: 700; font-family: var(--bk-num); }
.bk-node.bk-done .bk-num { display: none; }
.bk-label { font-size: 0.6rem; font-weight: 600; letter-spacing: 0.02em; color: var(--bk-ink-faint); text-transform: uppercase; transition: color 0.35s var(--bk-ease); }
.bk-node.bk-active .bk-label { color: var(--bk-ink); }
.bk-node.bk-done .bk-label { color: var(--bk-green); }

/* ---- stage ---- */
.bk-stage { position: relative; height: 21rem; margin: 0.3rem 0.4rem 0; }
.bk-panel { position: absolute; inset: 0; padding: 0.7rem 1.1rem 1rem; opacity: 0; transform: translateY(14px) scale(0.985); pointer-events: none; transition: opacity 0.45s var(--bk-ease), transform 0.45s var(--bk-ease); }
.bk-panel.bk-is-active { opacity: 1; transform: none; }
.bk-panel.bk-is-leaving { opacity: 0; transform: translateY(-14px) scale(0.985); transition-duration: 0.32s; }

.bk-caption { display: flex; align-items: center; gap: 0.4rem; margin-top: 0.9rem; font-size: 0.72rem; color: var(--bk-ink-faint); }
.bk-caption svg { color: var(--bk-violet); flex: none; }

.bk-panel.bk-is-active .bk-st { animation: bk-rise 0.5s var(--bk-ease) both; }
.bk-panel.bk-is-active .bk-st:nth-child(2) { animation-delay: 0.08s; }
.bk-panel.bk-is-active .bk-st:nth-child(3) { animation-delay: 0.16s; }
.bk-panel.bk-is-active .bk-st:nth-child(4) { animation-delay: 0.24s; }

/* ---- receipt (step 1) ---- */
.bk-receipt-wrap { display: flex; justify-content: center; padding-top: 0.3rem; }
.bk-receipt {
  position: relative;
  width: 11rem;
  background: #f6f4ee;
  color: #2a2530;
  border-radius: 0.4rem 0.4rem 0.5rem 0.5rem;
  padding: 0.7rem 0.8rem 0.9rem;
  transform: rotate(-2deg);
  box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.45);
  overflow: hidden;
  /* torn bottom edge */
  -webkit-mask: linear-gradient(#000 0 0) top/100% calc(100% - 6px) no-repeat,
    radial-gradient(5px at 5px, transparent 98%, #000) bottom left/10px 6px repeat-x;
  mask: linear-gradient(#000 0 0) top/100% calc(100% - 6px) no-repeat,
    radial-gradient(5px at 5px, transparent 98%, #000) bottom left/10px 6px repeat-x;
}
.bk-receipt-logo { font-weight: 800; font-size: 0.9rem; letter-spacing: 0.02em; }
.bk-receipt-sub { font-size: 0.58rem; color: #8a8290; margin-bottom: 0.5rem; }
.bk-rline { height: 0.42rem; border-radius: 2px; background: #d9d4cc; margin: 0.3rem 0; }
.bk-rline.s1 { width: 85%; } .bk-rline.s2 { width: 60%; } .bk-rline.s3 { width: 72%; }
.bk-receipt-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: 0.55rem; padding-top: 0.45rem; border-top: 1.5px dashed #cbc5bc; font-weight: 800; }
.bk-receipt-total span:first-child { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.04em; color: #8a8290; }
.bk-receipt-total span:last-child { font-family: var(--bk-num); font-size: 0.95rem; }
.bk-scan { position: absolute; left: 0; right: 0; top: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--bk-green), transparent); box-shadow: 0 0 12px 3px rgba(16, 185, 129, 0.6); opacity: 0; }
.bk-scan::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2.5rem; background: linear-gradient(180deg, rgba(16, 185, 129, 0.18), transparent); }
.bk-panel.bk-is-active .bk-scan { animation: bk-sweep 1.5s var(--bk-ease) 0.5s 1 both; }

/* ---- extracted fields (step 2) ---- */
.bk-doc { background: var(--bk-surface-2); border: 1px solid var(--bk-line); border-radius: 0.8rem; padding: 0.35rem 0.85rem; }
.bk-field { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; font-size: 0.78rem; padding: 0.4rem 0; border-bottom: 1px dashed var(--bk-line-strong); }
.bk-field:last-child { border-bottom: none; }
.bk-field .bk-flabel { color: var(--bk-ink-faint); display: inline-flex; align-items: center; gap: 0.35rem; }
.bk-field .bk-fval { font-family: var(--bk-num); font-variant-numeric: tabular-nums; color: var(--bk-ink); font-weight: 600; }
.bk-field .bk-fval.pos { color: var(--bk-green); }
.bk-tick { color: var(--bk-green); flex: none; opacity: 0; transform: scale(0.4); }
.bk-panel.bk-is-active .bk-field .bk-tick { animation: bk-pop 0.35s var(--bk-spring) both; }
.bk-panel.bk-is-active .bk-field:nth-child(1) .bk-tick { animation-delay: 0.5s; }
.bk-panel.bk-is-active .bk-field:nth-child(2) .bk-tick { animation-delay: 0.7s; }
.bk-panel.bk-is-active .bk-field:nth-child(3) .bk-tick { animation-delay: 0.9s; }
.bk-panel.bk-is-active .bk-field:nth-child(4) .bk-tick { animation-delay: 1.1s; }

/* ---- category (step 3) ---- */
.bk-catrow { display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 0.8rem; border-radius: 0.7rem; background: var(--bk-surface-2); border: 1px solid var(--bk-line); }
.bk-catlogo { width: 2rem; height: 2rem; border-radius: 0.5rem; flex: none; display: grid; place-items: center; font-weight: 800; font-size: 0.7rem; color: #fff; background: #ff6a00; }
.bk-catmeta { min-width: 0; flex: 1; }
.bk-catname { font-weight: 700; font-size: 0.82rem; }
.bk-catamt { font-size: 0.72rem; color: var(--bk-ink-faint); font-family: var(--bk-num); }
.bk-catchip { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.7rem; font-weight: 700; color: var(--bk-violet); background: var(--bk-violet-soft); border: 1px solid color-mix(in srgb, var(--bk-violet) 30%, transparent); padding: 0.2rem 0.5rem; border-radius: 999px; flex: none; transform: scale(0); }
.bk-panel.bk-is-active .bk-catchip { animation: bk-thunk 0.5s var(--bk-spring) 1s both; }
.bk-ai { display: inline-flex; align-items: center; gap: 0.3rem; margin-top: 0.9rem; font-size: 0.7rem; font-weight: 600; color: var(--bk-violet); }
.bk-ai .bk-aibadge { font-size: 0.58rem; font-weight: 800; letter-spacing: 0.04em; color: #fff; background: linear-gradient(135deg, var(--bk-violet), #6d28d9); padding: 0.08rem 0.34rem; border-radius: 0.3rem; }

/* ---- booked (step 4) ---- */
.bk-booked { display: flex; flex-direction: column; align-items: center; text-align: center; }
.bk-check { width: 3.4rem; height: 3.4rem; margin: 0.5rem 0 0.6rem; }
.bk-check circle.bg { fill: var(--bk-green-soft); }
.bk-check circle.ring { fill: none; stroke: var(--bk-green); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 151; stroke-dashoffset: 151; transform: rotate(-90deg); transform-origin: center; }
.bk-check path { fill: none; stroke: var(--bk-green); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 30; stroke-dashoffset: 30; }
.bk-panel.bk-is-active .bk-check circle.ring { animation: bk-draw 0.55s var(--bk-ease) 0.15s forwards; }
.bk-panel.bk-is-active .bk-check path { animation: bk-draw 0.4s var(--bk-ease) 0.55s forwards; }
.bk-booked-title { font-weight: 700; font-size: 0.9rem; }
.bk-booked-sub { font-size: 0.75rem; color: var(--bk-ink-soft); margin-top: 0.15rem; }
.bk-vat { margin-top: 0.75rem; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; width: 100%; padding: 0.55rem 0.75rem; border-radius: 0.6rem; background: var(--bk-green-soft); border: 1px solid color-mix(in srgb, var(--bk-green) 28%, transparent); }
.bk-vat .lbl { font-size: 0.72rem; color: var(--bk-ink-soft); font-weight: 600; }
.bk-vat .val { font-family: var(--bk-num); font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1rem; color: var(--bk-green); }

@keyframes bk-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes bk-pulse { 0% { box-shadow: 0 0 0 0 var(--bk-green-soft); } 70% { box-shadow: 0 0 0 0.4rem transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes bk-sweep { 0% { opacity: 0; top: 0; } 12% { opacity: 1; } 88% { opacity: 1; } 100% { opacity: 0; top: calc(100% - 2px); } }
@keyframes bk-pop { to { opacity: 1; transform: scale(1); } }
@keyframes bk-thunk { 0% { transform: scale(1.8); opacity: 0; } 60% { transform: scale(0.92); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
@keyframes bk-draw { to { stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: reduce) {
  .bk-device *,
  .bk-device *::before,
  .bk-device *::after { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
}
