/* =============================================
   Freo Now — How It Works (Step Cards)
   Grid, cards, number indicators, animations
   ============================================= */

/* ---- How It Works — Interactive Step Cards ---- */
.steps-section { padding-bottom: 2rem; }

.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: auto auto auto;
  grid-template-areas:
    "c1 c1 c2"
    "c3 c4 c2"
    "c5 c6 c6";
  gap: 1rem;
  max-width: 1100px;
  margin: 2rem auto 0;
}

/* Bento area assignments */
.step-card[data-step="1"] { grid-area: c1; }
.step-card[data-step="2"] { grid-area: c2; }
.step-card[data-step="3"] { grid-area: c3; }
.step-card[data-step="4"] { grid-area: c4; }
.step-card[data-step="5"] { grid-area: c5; }
.step-card[data-step="6"] { grid-area: c6; }

.step-card {
  background: var(--white);
  border-radius: 18px;
  padding: 1.75rem;
  box-shadow: 0 2px 12px rgba(12, 45, 72, 0.07);
  border: 1px solid rgba(12, 45, 72, 0.06);
  cursor: default;
  display: flex;
  flex-direction: column;
  min-height: 220px;
  position: relative;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  overflow: hidden;
}

.step-card:hover,
.step-card:focus-visible {
  transform: translateY(-4px);
  box-shadow: 0 14px 40px rgba(12, 45, 72, 0.14);
  outline: none;
}

/* ── Step Number Indicator (1, 2...) ── */
.step-card::before {
  content: attr(data-step);
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  font-size: 1.5rem;
  font-weight: 800;
  opacity: 0.5;
  pointer-events: none;
}

.step-card[data-step="1"]::before,
.step-card[data-step="6"]::before { color: var(--primary); }
.step-card[data-step="2"]::before,
.step-card[data-step="5"]::before { color: #0a7c6e; }
.step-card[data-step="3"]::before,
.step-card[data-step="4"]::before { color: #1565c0; }

/* ── Card colour by entity ── */
.step-card[data-step="1"],
.step-card[data-step="6"] {
  background: #edf3f9;
  box-shadow: 0 2px 12px rgba(12, 45, 72, 0.10);
  border-color: var(--primary);
}
.step-card[data-step="2"],
.step-card[data-step="5"] {
  background: #eaf5f3;
  box-shadow: 0 2px 12px rgba(10, 124, 110, 0.10);
  border-color: #0a7c6e;
}
.step-card[data-step="3"],
.step-card[data-step="4"] {
  background: #edf1fb;
  box-shadow: 0 2px 12px rgba(21, 101, 192, 0.10);
  border-color: #1565c0;
}

.step-card h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--dark);
  margin: 0 0 0.2rem;
}

.step-amount {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
}

.step-card[data-step="1"] .step-amount,
.step-card[data-step="6"] .step-amount { color: var(--primary); }
.step-card[data-step="2"] .step-amount,
.step-card[data-step="5"] .step-amount { color: #0a7c6e; }
.step-card[data-step="3"] .step-amount,
.step-card[data-step="4"] .step-amount { color: #1565c0; }

.step-card p { font-size: 0.82rem; color: #555; line-height: 1.5; margin: 0; }

/* ── Animation stage ── */
.step-anim {
  margin-top: auto;
  padding-top: 1.2rem;
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  overflow: hidden;
  transition: opacity 0.3s ease;
  min-height: 100px;
}

/* Fade to invisible on mouse-leave while animations reset */
.step-card.is-leaving .step-anim { opacity: 0; }


/* ══════════════════════════════════════════
   STEP 1 — 💰 Coins fly into vault
══════════════════════════════════════════ */
.step-card[data-step="1"] .coin {
  position: absolute;
  width: 22px;
  height: 22px;
  color: var(--primary);
  left: 10%;
  animation: s1CoinFly 1.8s ease-in-out infinite;
  animation-play-state: paused;
}
.step-card[data-step="1"] .c1 { top: 15%; animation-delay: 0s; }
.step-card[data-step="1"] .c2 { top: 42%; animation-delay: 0.5s; }
.step-card[data-step="1"] .c3 { top: 68%; animation-delay: 1.0s; }

.step-card[data-step="1"] .anim-vault {
  position: absolute;
  width: 44px;
  height: 44px;
  color: var(--primary);
  right: 8%;
  animation: s1VaultPulse 1.8s ease-in-out infinite;
  animation-play-state: paused;
  animation-delay: 0.9s;
}

.step-card[data-step="1"].is-hovered .coin,
.step-card[data-step="1"].is-hovered .anim-vault { animation-play-state: running; }

.step-card[data-step="1"].is-reversing .coin,
.step-card[data-step="1"].is-reversing .anim-vault { animation-play-state: running; animation-direction: reverse; }

@keyframes s1CoinFly {
  0%   { transform: translateX(0) scale(1);    opacity: 0; }
  12%  { opacity: 1; }
  72%  { transform: translateX(130px) scale(0.6); opacity: 1; }
  85%  { transform: translateX(150px) scale(0.3); opacity: 0; }
  100% { transform: translateX(0) scale(1);    opacity: 0; }
}

@keyframes s1VaultPulse {
  0%, 58% { transform: scale(1);    filter: none; }
  68%     { transform: scale(1.18); filter: drop-shadow(0 0 10px #ffd700); }
  88%     { transform: scale(1);    filter: none; }
  100%    { transform: scale(1);    filter: none; }
}

/* ══════════════════════════════════════════
   STEP 2 — 📊 Bar chart grows
══════════════════════════════════════════ */
.step-card[data-step="2"] .bars-wrap {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 68px;
}

.step-card[data-step="2"] .bar {
  width: 18px;
  border-radius: 4px 4px 0 0;
  background: #0a7c6e;
  height: 3px;
  animation: s2BarGrow 2s ease-in-out infinite;
  animation-play-state: paused;
}
.step-card[data-step="2"] .b1 { --h: 38px; animation-delay: 0.0s; }
.step-card[data-step="2"] .b2 { --h: 56px; animation-delay: 0.2s; }
.step-card[data-step="2"] .b3 { --h: 32px; animation-delay: 0.4s; }
.step-card[data-step="2"] .b4 { --h: 64px; animation-delay: 0.6s; }

.step-card[data-step="2"] .revenue-badge {
  position: absolute;
  right: 12px;
  top: 10px;
  font-size: 1rem;
  font-weight: 800;
  color: #0a7c6e;
  opacity: 0;
  animation: s2RevFade 2s ease-in-out infinite;
  animation-play-state: paused;
}

.step-card[data-step="2"].is-hovered .bar,
.step-card[data-step="2"].is-hovered .revenue-badge { animation-play-state: running; }

.step-card[data-step="2"].is-reversing .bar,
.step-card[data-step="2"].is-reversing .revenue-badge { animation-play-state: running; animation-direction: reverse; }

@keyframes s2BarGrow {
  0%       { height: 3px; }
  50%, 88% { height: var(--h); }
  100%     { height: 3px; }
}

@keyframes s2RevFade {
  0%, 35%  { opacity: 0; transform: translateY(-6px); }
  55%, 88% { opacity: 1; transform: translateY(0); }
  100%     { opacity: 0; transform: translateY(-6px); }
}

/* ══════════════════════════════════════════
   STEP 3 — ⭐ Stars burst into wallet
══════════════════════════════════════════ */
.step-card[data-step="3"] .anim-tap {
  position: absolute;
  width: 32px;
  height: 32px;
  color: #1565c0;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  animation: s3Tap 2s ease infinite;
  animation-play-state: paused;
}

.step-card[data-step="3"] .star {
  position: absolute;
  width: 18px;
  height: 18px;
  color: #1565c0;
  left: 50%;
  top: 50%;
  opacity: 0;
  animation: s3StarBurst 2s ease infinite;
  animation-play-state: paused;
}
.step-card[data-step="3"] .s1 { --sx: -52px; --sy: -18px; animation-delay: 0.15s; }
.step-card[data-step="3"] .s2 { --sx: 0px;   --sy: -46px; animation-delay: 0.25s; }
.step-card[data-step="3"] .s3 { --sx: 52px;  --sy: -18px; animation-delay: 0.35s; }

.step-card[data-step="3"] .anim-wallet {
  position: absolute;
  width: 32px;
  height: 32px;
  color: #1565c0;
  bottom: 6px;
  right: 14%;
  animation: s3WalletJiggle 2s ease infinite;
  animation-play-state: paused;
  animation-delay: 0.6s;
}

.step-card[data-step="3"].is-hovered .anim-tap,
.step-card[data-step="3"].is-hovered .star,
.step-card[data-step="3"].is-hovered .anim-wallet { animation-play-state: running; }

.step-card[data-step="3"].is-reversing .anim-tap,
.step-card[data-step="3"].is-reversing .star,
.step-card[data-step="3"].is-reversing .anim-wallet { animation-play-state: running; animation-direction: reverse; }

@keyframes s3Tap {
  0%, 75%, 100% { transform: translate(-50%, -50%) scale(1); }
  10%           { transform: translate(-50%, -50%) scale(0.82); }
  22%           { transform: translate(-50%, -50%) scale(1.05); }
  30%           { transform: translate(-50%, -50%) scale(1); }
}

@keyframes s3StarBurst {
  0%        { transform: translate(-50%, -50%) scale(0); opacity: 0; }
  12%       { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
  58%       { transform: translate(calc(-50% + var(--sx)), calc(-50% + var(--sy))) scale(1); opacity: 0.85; }
  78%, 100% { transform: translate(calc(-50% + var(--sx)), calc(-50% + var(--sy))) scale(0);  opacity: 0; }
}

@keyframes s3WalletJiggle {
  0%, 58%, 100% { transform: rotate(0); }
  65%           { transform: rotate(-12deg) scale(1.12); }
  72%           { transform: rotate(10deg); }
  80%           { transform: rotate(-5deg); }
  90%           { transform: rotate(0); }
}

/* ══════════════════════════════════════════
   STEP 4 — 🎫 Points convert to voucher
══════════════════════════════════════════ */
.step-card[data-step="4"] .anim-pts {
  position: absolute;
  left: 8%;
  font-size: 1rem;
  font-weight: 700;
  color: #1565c0;
  animation: s4PtsDrain 2s ease infinite;
  animation-play-state: paused;
}

.step-card[data-step="4"] .anim-arrow-r {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: #bbb;
  animation: s4ArrowPulse 2s ease infinite;
  animation-play-state: paused;
}

.step-card[data-step="4"] .anim-voucher {
  position: absolute;
  right: 8%;
  width: 36px;
  height: 36px;
  color: #1565c0;
  animation: s4VoucherIn 2s ease infinite;
  animation-play-state: paused;
}

.step-card[data-step="4"].is-hovered .anim-pts,
.step-card[data-step="4"].is-hovered .anim-arrow-r,
.step-card[data-step="4"].is-hovered .anim-voucher { animation-play-state: running; }

.step-card[data-step="4"].is-reversing .anim-pts,
.step-card[data-step="4"].is-reversing .anim-arrow-r,
.step-card[data-step="4"].is-reversing .anim-voucher { animation-play-state: running; animation-direction: reverse; }

@keyframes s4PtsDrain {
  0%, 18%   { opacity: 1; transform: scale(1) translateX(0); }
  58%       { opacity: 0; transform: scale(0.55) translateX(18px); }
  80%, 100% { opacity: 0; transform: scale(1) translateX(0); }
}

@keyframes s4ArrowPulse {
  0%, 100% { transform: translateX(0); opacity: 0.4; }
  40%, 58% { transform: translateX(6px); opacity: 1; }
}

@keyframes s4VoucherIn {
  0%, 32%  { transform: scale(0) rotate(-18deg); opacity: 0; }
  56%      { transform: scale(1.1) rotate(4deg); opacity: 1; }
  66%, 88% { transform: scale(1) rotate(0); opacity: 1; }
  100%     { transform: scale(0) rotate(-18deg); opacity: 0; }
}

/* ══════════════════════════════════════════
   STEP 5 — 🥧 SVG donut pie chart
══════════════════════════════════════════ */
.step-card[data-step="5"] .step-anim { flex-direction: column; gap: 2px; }

.pie-svg {
  width: 72px;
  height: 72px;
  transform: rotate(-90deg);
}

.pie-track {
  fill: none;
  stroke: rgba(12, 45, 72, 0.10);
  stroke-width: 11;
}

.pie-fill {
  fill: none;
  stroke: var(--primary);
  stroke-width: 11;
  stroke-linecap: butt;
  stroke-dasharray: 0 188.5;
  animation: s5PieFill 2.2s ease-in-out infinite;
  animation-play-state: paused;
}

.pie-slice {
  fill: none;
  stroke: #0a7c6e;
  stroke-width: 11;
  stroke-linecap: butt;
  stroke-dasharray: 0 188.5;
  animation: s5SliceIn 2.2s ease-in-out infinite;
  animation-play-state: paused;
}

.pie-label {
  font-size: 0.82rem;
  font-weight: 800;
  color: #0a7c6e;
  opacity: 0;
  animation: s5LabelPop 2.2s ease-in-out infinite;
  animation-play-state: paused;
}

.step-card[data-step="5"].is-hovered .pie-fill,
.step-card[data-step="5"].is-hovered .pie-slice,
.step-card[data-step="5"].is-hovered .pie-label { animation-play-state: running; }

.step-card[data-step="5"].is-reversing .pie-fill,
.step-card[data-step="5"].is-reversing .pie-slice,
.step-card[data-step="5"].is-reversing .pie-label { animation-play-state: running; animation-direction: reverse; }

@keyframes s5PieFill {
  0%        { stroke-dasharray: 0 188.5; }
  45%, 88%  { stroke-dasharray: 141.4 47.1; }
  100%      { stroke-dasharray: 0 188.5; }
}

@keyframes s5SliceIn {
  0%, 38%   { stroke-dasharray: 0 188.5;    stroke-dashoffset: 0; }
  62%, 88%  { stroke-dasharray: 47.1 141.4; stroke-dashoffset: -141.4; }
  100%      { stroke-dasharray: 0 188.5;    stroke-dashoffset: 0; }
}

@keyframes s5LabelPop {
  0%, 52%   { opacity: 0; transform: scale(0.6); }
  68%, 88%  { opacity: 1; transform: scale(1); }
  100%      { opacity: 0; transform: scale(0.6); }
}

/* ══════════════════════════════════════════
   STEP 6 — 💵 Cash arrives at shop + ❤️
══════════════════════════════════════════ */
.step-card[data-step="6"] .anim-cash {
  position: absolute;
  width: 26px;
  height: 26px;
  color: var(--primary);
  animation: s6CashFly 2s ease infinite;
  animation-play-state: paused;
}
.step-card[data-step="6"] .c1 { top: 20%; left: 4%; animation-delay: 0s; }
.step-card[data-step="6"] .c2 { top: 54%; left: 4%; animation-delay: 0.45s; }

.step-card[data-step="6"] .anim-shop {
  width: 44px;
  height: 44px;
  color: var(--primary);
  animation: s6ShopBounce 2s ease infinite;
  animation-play-state: paused;
  animation-delay: 0.7s;
}

.step-card[data-step="6"] .anim-heart {
  position: absolute;
  right: 10%;
  top: 8px;
  width: 22px;
  height: 22px;
  stroke: #e53935;
  fill: #e53935;
  animation: s6HeartPop 2s ease infinite;
  animation-play-state: paused;
  animation-delay: 1.0s;
}

.step-card[data-step="6"].is-hovered .anim-cash,
.step-card[data-step="6"].is-hovered .anim-shop,
.step-card[data-step="6"].is-hovered .anim-heart { animation-play-state: running; }

.step-card[data-step="6"].is-reversing .anim-cash,
.step-card[data-step="6"].is-reversing .anim-shop,
.step-card[data-step="6"].is-reversing .anim-heart { animation-play-state: running; animation-direction: reverse; }

@keyframes s6CashFly {
  0%   { transform: translateX(-8px); opacity: 0; }
  14%  { opacity: 1; }
  62%  { transform: translateX(85px); opacity: 1; }
  76%  { transform: translateX(95px); opacity: 0; }
  100% { transform: translateX(-8px); opacity: 0; }
}

@keyframes s6ShopBounce {
  0%, 58%, 100% { transform: translateY(0) scale(1); }
  70%           { transform: translateY(-8px) scale(1.1); }
  82%           { transform: translateY(0) scale(1); }
}

@keyframes s6HeartPop {
  0%, 56%  { transform: scale(0); opacity: 0; }
  72%      { transform: scale(1.3); opacity: 1; }
  82%, 90% { transform: scale(1); opacity: 1; }
  100%     { transform: scale(0); opacity: 0; }
}

/* ── Touch devices: auto-play all animations slowly ── */
@media (hover: none) {
  .step-card[data-step="1"] .coin,
  .step-card[data-step="1"] .anim-vault,
  .step-card[data-step="2"] .bar,
  .step-card[data-step="2"] .revenue-badge,
  .step-card[data-step="3"] .anim-tap,
  .step-card[data-step="3"] .star,
  .step-card[data-step="3"] .anim-wallet,
  .step-card[data-step="4"] .anim-pts,
  .step-card[data-step="4"] .anim-arrow-r,
  .step-card[data-step="4"] .anim-voucher,
  .step-card[data-step="5"] .pie-fill,
  .step-card[data-step="5"] .pie-slice,
  .step-card[data-step="5"] .pie-label,
  .step-card[data-step="6"] .anim-cash,
  .step-card[data-step="6"] .anim-shop,
  .step-card[data-step="6"] .anim-heart {
    animation-play-state: running;
    animation-duration: 3s;
  }
}

/* ── Wide cards: info + anim side by side ── */
.step-card[data-step="1"],
.step-card[data-step="6"] {
  flex-direction: row;
  align-items: stretch;
  gap: 1.5rem;
}
.step-card[data-step="6"] { flex-direction: row-reverse; }

.step-card[data-step="1"] .step-info,
.step-card[data-step="6"] .step-info {
  flex: 0 0 46%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.step-card[data-step="1"] .step-anim,
.step-card[data-step="6"] .step-anim {
  flex: 1;
  margin-top: 0;
  padding-top: 0;
  min-height: 150px;
}

/* ── Tall card (2): bigger animation area ── */
.step-card[data-step="2"] .step-anim { min-height: 180px; }

/* ── Responsive: collapse bento grid ── */
@media (max-width: 900px) {
  .steps-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "c1 c1"
      "c2 c3"
      "c4 c5"
      "c6 c6";
  }
}

@media (max-width: 600px) {
  .steps-grid {
    grid-template-columns: 1fr;
    grid-template-areas: "c1" "c2" "c3" "c4" "c5" "c6";
  }
  /* Restore column layout for wide cards on mobile */
  .step-card[data-step="1"],
  .step-card[data-step="6"] {
    flex-direction: column;
  }
  .step-card[data-step="1"] .step-anim,
  .step-card[data-step="6"] .step-anim {
    margin-top: auto;
    padding-top: 1.2rem;
    min-height: 120px;
  }
}
