/* ============================================================
   ZOFFER — Tally page motion (optional, one switch per effect)
   Each effect is enabled by a class on <body> in tally/index.html:
     fx-flow       bill-to-ledger diagram (also needs the .tally-flow block)
     fx-connector  one-way connector diagram (.tally-connector block)
     fx-ticks      "What syncs" check marks tick in one by one
     fx-beam       progress beam down the left edge of the text
     fx-reveal     fade-up on text blocks + smooth FAQ open
   Delete a class to turn that effect off. Nothing here is loaded by
   other pages. Only transform/opacity are animated; reduced-motion
   users get the finished state with no movement.
   ============================================================ */

/* blocks stay hidden unless their switch is on */
.tally-flow, .tally-connector { display: none; }
body.fx-flow .tally-flow { display: block; }
body.fx-connector .tally-connector { display: grid; }

/* ── 1. Flow: WhatsApp → AI reads → you approve → Tally ───────── */
.tally-flow { --flow-t: 8s; /* one full loop; lower = faster */ margin: var(--space-7) 0; padding: 0; }
.flow-track {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-8);
}
.flow-step { position: relative; display: flex; flex-direction: column; gap: var(--space-3); }
.zoffer .flow-label {
  font-size: var(--fs-body-sm); font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--zoffer-orange); margin: 0;
}
.flow-card {
  background: var(--bg-surface);
  border: var(--bw-hairline) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  min-height: 132px;
  display: flex; flex-direction: column; justify-content: center; gap: var(--space-2);
  opacity: 0.55;
}
.zoffer .flow-cap { font-size: var(--fs-body-sm); color: var(--zoffer-muted); margin: 0; line-height: 1.4; }

/* connector between steps: a dim track with a bright beam that runs along it
   as one card hands over to the next (same idea as the who-we-are flow) */
.flow-step:not(:last-child)::after {
  content: ""; position: absolute; top: 58%; right: calc(var(--space-8) * -1);
  width: var(--space-8); height: 3px; border-radius: 2px;
  background:
    linear-gradient(90deg, rgba(246,105,34,0) 0%, rgba(246,105,34,.55) 35%, #f66922 70%, #ffb48a 100%) no-repeat -28px 0 / 28px 100%,
    rgba(246, 105, 34, 0.28);
}

.flow-bubble {
  display: flex; align-items: center; gap: 10px;
  background: #dcf8c6; color: #1a1a1a;
  border-radius: 12px 12px 12px 2px;
  padding: 10px 12px; font-size: var(--fs-body-sm);
}
.flow-bubble svg { flex: none; color: var(--zoffer-navy); }
.flow-row {
  display: flex; justify-content: space-between; gap: 12px;
  font-size: var(--fs-body-sm); padding: 4px 0;
  border-bottom: var(--bw-hairline) solid var(--border-subtle);
}
.flow-row:last-child { border-bottom: 0; }
.flow-row span { color: var(--zoffer-muted); }
.flow-row b { color: var(--zoffer-navy); font-weight: 600; }
.flow-approve {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--bg-page); border-radius: var(--radius-md);
  padding: 12px; font-weight: 600; font-size: var(--fs-body-sm); color: var(--zoffer-navy);
}
.flow-tick {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--success); color: #fff;
  display: grid; place-items: center;
}
.flow-ledger {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px;
  font-size: var(--fs-body-sm); background: var(--bg-page);
  border-left: 3px solid var(--zoffer-orange); border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 10px 12px; color: var(--zoffer-navy);
}
.flow-ledger small { grid-column: 1 / -1; color: var(--zoffer-muted); font-size: 12px; }
.flow-ledger b { font-weight: 600; }
.zoffer .flow-note { font-size: 12px; color: var(--zoffer-muted); margin: var(--space-4) 0 0; }

/* the loop (--flow-t): card n lights up in turn, details appear as it plays */
.tally-flow.fx-in .s1 .flow-card { animation: fx-act-1 var(--flow-t) infinite; }
.tally-flow.fx-in .s2 .flow-card { animation: fx-act-2 var(--flow-t) infinite; }
.tally-flow.fx-in .s3 .flow-card { animation: fx-act-3 var(--flow-t) infinite; }
.tally-flow.fx-in .s4 .flow-card { animation: fx-act-4 var(--flow-t) infinite; }
.tally-flow.fx-in .flow-bubble { animation: fx-bubble var(--flow-t) infinite; }
.tally-flow.fx-in .r1 b { animation: fx-f1 var(--flow-t) infinite; }
.tally-flow.fx-in .r2 b { animation: fx-f2 var(--flow-t) infinite; }
.tally-flow.fx-in .r3 b { animation: fx-f3 var(--flow-t) infinite; }
.tally-flow.fx-in .flow-tick { animation: fx-tick var(--flow-t) infinite; }
.tally-flow.fx-in .flow-ledger { animation: fx-row var(--flow-t) infinite; }
.tally-flow.fx-in .s1::after { animation: fx-beam-a var(--flow-t) infinite; }
.tally-flow.fx-in .s2::after { animation: fx-beam-b var(--flow-t) infinite; }
.tally-flow.fx-in .s3::after { animation: fx-beam-c var(--flow-t) infinite; }
html.fx-js .flow-bubble, html.fx-js .r1 b, html.fx-js .r2 b, html.fx-js .r3 b, html.fx-js .flow-ledger { opacity: 0; }
html.fx-js .flow-tick { transform: scale(0); }
.flow-tick { transform: scale(1); }

@keyframes fx-act-1 { 0%{opacity:.55} 3%,21%{opacity:1;border-color:var(--zoffer-orange);box-shadow:0 8px 24px -8px rgba(246,105,34,.35)} 25%,100%{opacity:.55} }
@keyframes fx-act-2 { 0%,23%{opacity:.55} 27%,45%{opacity:1;border-color:var(--zoffer-orange);box-shadow:0 8px 24px -8px rgba(246,105,34,.35)} 49%,100%{opacity:.55} }
@keyframes fx-act-3 { 0%,47%{opacity:.55} 51%,69%{opacity:1;border-color:var(--zoffer-orange);box-shadow:0 8px 24px -8px rgba(246,105,34,.35)} 73%,100%{opacity:.55} }
@keyframes fx-act-4 { 0%,71%{opacity:.55} 75%,94%{opacity:1;border-color:var(--zoffer-orange);box-shadow:0 8px 24px -8px rgba(246,105,34,.35)} 98%,100%{opacity:.55} }
@keyframes fx-bubble { 0%,2%{opacity:0;transform:translateY(6px)} 6%,92%{opacity:1;transform:none} 97%,100%{opacity:0} }
@keyframes fx-f1 { 0%,27%{opacity:0;transform:translateY(4px)} 31%,92%{opacity:1;transform:none} 97%,100%{opacity:0} }
@keyframes fx-f2 { 0%,32%{opacity:0;transform:translateY(4px)} 36%,92%{opacity:1;transform:none} 97%,100%{opacity:0} }
@keyframes fx-f3 { 0%,37%{opacity:0;transform:translateY(4px)} 41%,92%{opacity:1;transform:none} 97%,100%{opacity:0} }
@keyframes fx-tick { 0%,56%{transform:scale(0)} 60%{transform:scale(1.2)} 63%,92%{transform:scale(1)} 97%,100%{transform:scale(0)} }
@keyframes fx-row { 0%,73%{opacity:0;transform:translateX(-12px)} 79%,92%{opacity:1;transform:none} 97%,100%{opacity:0} }
@keyframes fx-beam-a { 0%,19% { background-position: -28px 0, 0 0; } 27%,100% { background-position: 64px 0, 0 0; } }
@keyframes fx-beam-b { 0%,43% { background-position: -28px 0, 0 0; } 51%,100% { background-position: 64px 0, 0 0; } }
@keyframes fx-beam-c { 0%,67% { background-position: -28px 0, 0 0; } 75%,100% { background-position: 64px 0, 0 0; } }

@media (max-width: 900px) {
  .flow-track { grid-template-columns: 1fr; gap: var(--space-5); }
  .flow-step:not(:last-child)::after { display: none; }
  .flow-card { min-height: 0; }
}

/* ── 2. Connector: entries go in, books don't come out ────────── */
.tally-connector {
  grid-template-columns: 1fr minmax(120px, 1.2fr) 1fr;
  align-items: center; gap: var(--space-5);
  margin: var(--space-6) 0 var(--space-5);
}
.conn-node {
  background: var(--bg-surface); border: var(--bw-hairline) solid var(--border-subtle);
  border-radius: var(--radius-lg); padding: var(--space-4) var(--space-5);
  display: flex; flex-direction: column; gap: 4px;
}
.conn-node-pc { border-color: rgba(246, 105, 34, 0.45); }
.zoffer .conn-title { font-weight: 700; color: var(--zoffer-navy); font-size: var(--fs-body); }
.zoffer .conn-sub { color: var(--zoffer-muted); font-size: var(--fs-body-sm); }
.conn-mid { display: flex; flex-direction: column; gap: var(--space-5); }
.conn-line {
  position: relative; height: 2px;
  background: repeating-linear-gradient(90deg, var(--zoffer-orange) 0 8px, transparent 8px 16px);
  background-size: 16px 2px;
}
.conn-line::after {            /* arrow head */
  content: ""; position: absolute; right: -2px; top: -5px;
  border-left: 9px solid var(--zoffer-orange);
  border-top: 6px solid transparent; border-bottom: 6px solid transparent;
}
.conn-line span {
  position: absolute; left: 0; right: 0; top: -24px; text-align: center;
  font-size: 12px; color: var(--zoffer-navy); font-weight: 600;
}
.conn-line-blocked {
  background: repeating-linear-gradient(90deg, rgba(107,101,96,.45) 0 8px, transparent 8px 16px);
  background-size: 16px 2px; animation: none;
}
.conn-line-blocked::after { display: none; }
.conn-line-blocked::before {   /* the cross: nothing flows this way */
  content: "\00d7"; position: absolute; left: 50%; top: -13px; transform: translateX(-50%);
  width: 24px; height: 24px; display: grid; place-items: center;
  background: var(--bg-page); color: var(--zoffer-muted); font-size: 20px; line-height: 1;
}
.conn-line-blocked span { color: var(--zoffer-muted); font-weight: 500; top: 12px; }
.tally-connector.fx-in .conn-line:not(.conn-line-blocked) { animation: fx-dash16 0.9s linear infinite; }
@keyframes fx-dash16 { to { background-position: 16px 0; } }
@media (max-width: 720px) {
  .tally-connector { grid-template-columns: 1fr; }
  .conn-mid { flex-direction: row; justify-content: center; gap: var(--space-6); }
  .conn-line { display: none; }
}

/* ── 3. Ticks: "What syncs" ───────────────────────────────────── */
.tally-list { list-style: disc; }
body.fx-ticks .tally-list { list-style: none; margin-left: 0; padding: 0; }
body.fx-ticks .tally-list li { position: relative; padding-left: 38px; }
body.fx-ticks .tally-list li::before {
  content: ""; position: absolute; left: 0; top: 0.3em;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(246, 105, 34, 0.14);
}
body.fx-ticks .tally-list li::after {
  content: ""; position: absolute; left: 8px; top: calc(0.3em + 4px);
  width: 6px; height: 11px;
  border: solid var(--zoffer-orange); border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
html.fx-js body.fx-ticks .tally-list li { opacity: 0; transform: translateX(-8px); }
html.fx-js body.fx-ticks .tally-list li::before,
html.fx-js body.fx-ticks .tally-list li::after { transform-origin: center; scale: 0; }
html.fx-js body.fx-ticks .tally-list li::after { transform: rotate(45deg); }
html.fx-js body.fx-ticks .tally-list.fx-in li {
  opacity: 1; transform: none;
  transition: opacity .5s var(--ease-out), transform .5s var(--ease-out);
  transition-delay: calc(var(--i, 0) * 0.35s);
}
html.fx-js body.fx-ticks .tally-list.fx-in li::before,
html.fx-js body.fx-ticks .tally-list.fx-in li::after {
  scale: 1; transition: scale .35s cubic-bezier(.34, 1.56, .64, 1);
  transition-delay: calc(var(--i, 0) * 0.35s + 0.25s);
}

/* ── 4. Beam: progress line down the left edge ────────────────── */
.tally-beam { display: none; }
body.fx-beam .tally-beam {
  display: block; position: absolute; left: 4px; top: 0; bottom: 0; width: 2px;
  background: rgba(16, 51, 92, 0.1); border-radius: 2px; pointer-events: none;
}
.tally-beam i {
  position: absolute; left: 0; top: 0; width: 2px; height: calc(var(--p, 0) * 100%);
  background: linear-gradient(to bottom, rgba(246,105,34,.15), var(--zoffer-orange));
  border-radius: 2px;
}
.tally-beam i::after {
  content: ""; position: absolute; left: 50%; bottom: -5px; width: 10px; height: 10px;
  transform: translateX(-50%); border-radius: 50%;
  background: var(--zoffer-orange); box-shadow: 0 0 0 4px rgba(246, 105, 34, 0.18), 0 0 14px rgba(246,105,34,.55);
}
.tally-prose { position: relative; }
@media (max-width: 999px) { body.fx-beam .tally-beam { display: none; } }

/* ── 5. Reveal: fade-up + smooth FAQ open ─────────────────────── */
html.fx-js body.fx-reveal .fx-r { opacity: 0; transform: translateY(16px); transition: opacity .6s var(--ease-out), transform .6s var(--ease-out); }
html.fx-js body.fx-reveal .fx-r.fx-in { opacity: 1; transform: none; }

body.fx-reveal .tally-prose .faq-a {
  /* !important: script.js sets an inline max-height from scrollHeight on click,
     which would measure 0 here and hide the answer */
  display: grid; grid-template-rows: 0fr; max-height: none !important; overflow: hidden;
  transition: grid-template-rows var(--dur-slower) var(--ease-out);
}
body.fx-reveal .tally-prose .faq-item.open .faq-a { grid-template-rows: 1fr; }
body.fx-reveal .tally-prose .faq-a > p {
  min-height: 0; overflow: hidden; padding-bottom: 0;
  transition: padding var(--dur-slower) var(--ease-out);
}
body.fx-reveal .tally-prose .faq-item.open .faq-a > p { padding-bottom: var(--space-5); }

/* ── reduced motion: show the finished state, no movement ─────── */
@media (prefers-reduced-motion: reduce) {
  .tally-flow .flow-card, .tally-flow .flow-bubble, .tally-flow .flow-row b,
  .tally-flow .flow-ledger { animation: none !important; opacity: 1 !important; transform: none !important; }
  .tally-flow .flow-tick { animation: none !important; transform: scale(1) !important; }
  .flow-step:not(:last-child)::after, .conn-line { animation: none !important; }
  html.fx-js body.fx-ticks .tally-list li,
  html.fx-js body.fx-reveal .fx-r { opacity: 1; transform: none; transition: none; }
  html.fx-js body.fx-ticks .tally-list li::before,
  html.fx-js body.fx-ticks .tally-list li::after { scale: 1; transition: none; }
  body.fx-reveal .tally-prose .faq-a, body.fx-reveal .tally-prose .faq-a > p { transition: none; }
  body.fx-beam .tally-beam { display: none; }
}
