/* PaySoon interactive demo — in-browser replica of the app's key screens */

.demo { padding: clamp(96px, 12vw, 150px) 0; text-align: center; }

.demo-stage { position: relative; display: flex; justify-content: center; margin-top: 8px; }
.demo-stage::before {
  content: ''; position: absolute; inset: -8% -20%;
  background: radial-gradient(ellipse at 50% 45%, rgba(45, 212, 191, 0.1), rgba(79, 140, 255, 0.08) 45%, transparent 70%);
  filter: blur(48px); pointer-events: none;
}

.demo-cta { margin-top: 2.5rem; color: var(--text-secondary); }
.demo-cta a { color: var(--accent); text-decoration: none; font-weight: 600; }
.demo-cta a:hover { text-decoration: underline; }

/* ── Phone frame ── */
.demo .phone {
  position: relative; width: 312px; height: 660px;
  display: flex; flex-direction: column;
  background: #0b0f1d;
  border-radius: 48px; overflow: hidden;
  box-shadow:
    0 0 0 10px #05070d,
    0 0 0 11.5px rgba(255, 255, 255, 0.12),
    0 40px 80px -24px rgba(0, 0, 0, 0.65),
    0 0 90px rgba(79, 140, 255, 0.1);
  text-align: left;
  font-family: -apple-system, BlinkMacSystemFont, 'DM Sans', sans-serif;
  user-select: none; -webkit-user-select: none;
}
/* :where() keeps this reset at zero specificity so component backgrounds win */
.demo .phone :where(button) { font-family: inherit; background: none; border: none; color: inherit; cursor: pointer; }

.demo .phone-status {
  position: relative; z-index: 3; flex: none;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 26px 6px; font-size: 0.8rem; font-weight: 600; color: #fff;
}
.demo .phone-status svg { width: 42px; height: 12px; display: block; }
.demo .phone-notch {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  width: 86px; height: 24px; border-radius: 999px; background: #05070d; z-index: 4;
}

/* ── Screens ── */
.demo .screens { position: relative; flex: 1; overflow: hidden; }
.demo .screen {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  padding: 8px 14px 14px;
  background: linear-gradient(180deg, #0d1322, #0a0e1a);
  transition: transform 0.45s var(--ease-out), opacity 0.45s var(--ease-out);
}
.demo .screen-balance,
.demo .screen-insights { transform: translateX(105%); background: linear-gradient(180deg, #0e1424, #0a0e1a); }
.demo .phone.show-balance .screen-group,
.demo .phone.show-insights .screen-group { transform: translateX(-26%); opacity: 0.5; }
/* The active mode (house vs trip) decides which balance/insights variant slides in */
.demo .phone.show-balance:not(.show-trip) .screen-balance.for-house,
.demo .phone.show-insights:not(.show-trip) .screen-insights.for-house,
.demo .phone.show-balance.show-trip .screen-balance.for-trip,
.demo .phone.show-insights.show-trip .screen-insights.for-trip { transform: translateX(0); }

/* ── Trips / Groups mode toggle ── */
.demo .mode-seg {
  display: flex; gap: 3px; padding: 3px; margin: 2px auto 6px; width: fit-content;
  background: rgba(255, 255, 255, 0.07); border-radius: 999px;
}
.demo .mode-seg button {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 14px; border-radius: 999px;
  font-size: 0.68rem; font-weight: 600; color: rgba(255, 255, 255, 0.55);
}
.demo .mode-seg svg { width: 13px; height: 13px; }
.demo .mode-seg .active-trips { background: linear-gradient(135deg, #4f8cff, #3b6fe0); color: #fff; }
.demo .mode-seg .active-groups { background: linear-gradient(135deg, #18a999, #0e9488); color: #fff; }

/* Trip screen — crossfade mode switch, not a push */
.demo .screen-trip {
  opacity: 0; pointer-events: none; transform: scale(0.98);
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none;
}
.demo .screen-trip::-webkit-scrollbar { display: none; }
.demo .phone.show-trip .screen-trip { opacity: 1; pointer-events: auto; transform: none; }
.demo .phone.show-trip .screen-group { opacity: 0; pointer-events: none; }
.demo .phone.show-trip.show-balance .screen-trip,
.demo .phone.show-trip.show-insights .screen-trip { transform: translateX(-26%); opacity: 0.5; }

/* ── Group screen ── */
.demo .app-header { text-align: center; padding: 4px 0 2px; }
.demo .app-header h3 { font-size: 1rem; font-weight: 700; color: #fff; }
.demo .app-header p { font-size: 0.7rem; color: rgba(255, 255, 255, 0.55); }

.demo .month-row {
  display: flex; align-items: center; justify-content: center; gap: 6px; margin: 6px 0 10px;
}
.demo .month-row span {
  font-size: 0.75rem; font-weight: 600; color: rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.07); padding: 4px 14px; border-radius: 999px;
}
.demo .month-row button {
  width: 26px; height: 26px; border-radius: 50%; color: rgba(255, 255, 255, 0.6);
  font-size: 0.85rem; line-height: 1;
}
.demo .month-row button:hover { background: rgba(255, 255, 255, 0.08); }

.demo .spend-card {
  position: relative; border-radius: 16px; padding: 12px 14px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.07);
}
.demo .spend-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.demo .spend-label { font-size: 0.68rem; color: rgba(255, 255, 255, 0.55); }
.demo .spend-delta { font-size: 0.65rem; font-weight: 600; color: #2dd4bf; }
.demo .spend-amt { font-size: 1.45rem; font-weight: 700; color: #fff; letter-spacing: -0.01em; }
.demo .spark { position: absolute; right: 14px; bottom: 12px; width: 96px; height: 30px; }
.demo .insights-chip {
  margin-top: 10px; display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.68rem; font-weight: 700; color: #fff;
  background: #0a84ff; padding: 5px 12px 5px 10px; border-radius: 999px;
  box-shadow: 0 2px 12px rgba(10, 132, 255, 0.45);
  transition: transform 0.2s var(--ease-spring);
}
.demo .insights-chip:hover { transform: scale(1.05); }
.demo .insights-chip svg { width: 13px; height: 13px; }

/* Balance row — the main tap target */
.demo .balance-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  margin-top: 10px; padding: 12px 14px; border-radius: 16px;
  background: rgba(45, 212, 191, 0.09);
  border: 1px solid rgba(45, 212, 191, 0.25);
  font-size: 0.8rem; color: rgba(255, 255, 255, 0.8);
  transition: background 0.2s;
}
.demo .balance-row:hover { background: rgba(45, 212, 191, 0.15); }
.demo .balance-row strong { color: #2dd4bf; font-size: 0.95rem; margin-left: auto; }
.demo .balance-row .chev { color: rgba(255, 255, 255, 0.45); }
.demo .phone:not(.touched) .balance-row { animation: demo-pulse 2.4s ease-in-out infinite; }
@keyframes demo-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(45, 212, 191, 0); }
  50% { box-shadow: 0 0 18px 0 rgba(45, 212, 191, 0.35); }
}

/* Transactions */
.demo .tx-day {
  display: flex; justify-content: space-between;
  margin: 14px 2px 6px; font-size: 0.66rem; color: rgba(255, 255, 255, 0.5);
}
.demo .tx {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.045);
  transition: background 0.2s; text-align: left;
}
.demo .tx:hover { background: rgba(255, 255, 255, 0.08); }
.demo .tx-icon {
  flex: none; width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center; font-size: 1rem;
  background: rgba(79, 140, 255, 0.14);
}
.demo .tx-name { font-size: 0.78rem; font-weight: 600; color: #fff; }
.demo .tx-date { font-size: 0.64rem; color: rgba(255, 255, 255, 0.5); }
.demo .tx-right { margin-left: auto; text-align: right; }
.demo .tx-amt { font-size: 0.78rem; font-weight: 600; color: #fff; }
.demo .tx-payer { font-size: 0.62rem; color: rgba(255, 255, 255, 0.5); }

/* Tab bar */
.demo .tab-bar {
  margin: auto 10px 0; flex: none;
  display: flex; gap: 4px; padding: 5px;
  background: rgba(255, 255, 255, 0.06); border-radius: 999px;
  backdrop-filter: blur(8px);
}
.demo .tab-bar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 5px 0; border-radius: 999px;
  font-size: 0.58rem; font-weight: 600; color: rgba(255, 255, 255, 0.5);
}
.demo .tab-bar button svg { width: 15px; height: 15px; }
.demo .tab-bar button.active { color: #6ea8ff; background: rgba(79, 140, 255, 0.14); }

/* ── Balance screen ── */
.demo .bal-header { display: grid; grid-template-columns: 30px 1fr 30px; align-items: center; padding: 4px 0 10px; }
.demo .bal-header h3 { text-align: center; font-size: 0.92rem; font-weight: 700; color: #fff; }
.demo .back-btn {
  width: 30px; height: 30px; border-radius: 50%; font-size: 1rem;
  color: rgba(255, 255, 255, 0.75); background: rgba(255, 255, 255, 0.07);
}

.demo .owed-card {
  text-align: center; padding: 13px 14px; border-radius: 18px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.07);
}
.demo .owed-icon {
  width: 30px; height: 30px; margin: 0 auto 6px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(48, 209, 88, 0.16); color: #30d158; font-size: 0.9rem;
}
.demo .owed-amt { font-size: 1.5rem; font-weight: 700; color: #30d158; letter-spacing: -0.01em; }
.demo .owed-label { font-size: 0.72rem; color: rgba(255, 255, 255, 0.6); }

/* "Why these amounts?" — only exists once debts are simplified, expandable like the app */
.demo .why-section { display: none; }
.demo .screen.simplified .why-section { display: block; animation: payIn 0.4s var(--ease-out) 0.15s both; }
.demo .why-label {
  display: flex; align-items: center; gap: 6px; width: 100%;
  margin: 10px 0 4px; padding: 4px 2px;
  font-size: 0.74rem; font-weight: 600; color: rgba(255, 255, 255, 0.7);
}
.demo .why-check { margin-left: auto; color: #30d158; font-size: 0.7rem; }
.demo .why-chev { color: rgba(255, 255, 255, 0.45); transition: transform 0.3s var(--ease-out); }
.demo .why-label[aria-expanded="false"] .why-chev { transform: rotate(180deg); }
.demo .why-body { display: grid; grid-template-rows: 1fr; transition: grid-template-rows 0.35s var(--ease-out); }
.demo .why-body > div { overflow: hidden; }
.demo .why-label[aria-expanded="false"] + .why-body { grid-template-rows: 0fr; }
.demo .person-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 12px; border-radius: 14px; margin-bottom: 5px;
  background: rgba(255, 255, 255, 0.045); transition: background 0.2s; text-align: left;
}
.demo .person-row:hover { background: rgba(255, 255, 255, 0.09); }
.demo .avatar {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 0.7rem; font-weight: 700; color: #fff;
}
.demo .person-row .name { font-size: 0.8rem; font-weight: 600; color: #fff; }
.demo .person-row .amt { margin-left: auto; font-size: 0.8rem; font-weight: 600; }
.demo .person-row .chev { color: rgba(255, 255, 255, 0.4); font-size: 0.8rem; }
.demo .neg { color: #ff6259; }
.demo .pos { color: #30d158; }
.demo .muted { color: rgba(255, 255, 255, 0.45); }

/* ── Settle up + simplify toggle ── */
.demo .settle-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 12px 2px 2px;
}
.demo .settle-head span { font-size: 0.74rem; font-weight: 600; color: rgba(255, 255, 255, 0.7); }
.demo .switch-wrap { display: flex; align-items: center; gap: 7px; font-size: 0.68rem; color: rgba(255, 255, 255, 0.6); }
.demo .switch {
  position: relative; width: 38px; height: 22px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.16); transition: background 0.25s var(--ease-out);
}
.demo .switch::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  transition: transform 0.25s var(--ease-out);
}
.demo .switch[aria-checked="true"] { background: #30d158; }
.demo .switch[aria-checked="true"]::after { transform: translateX(16px); }
.demo .pay-count { margin: 2px 2px 6px; font-size: 0.64rem; color: rgba(255, 255, 255, 0.45); transition: color 0.25s; }
.demo .pay-count.simplified { color: #30d158; }
.demo .pay-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: 12px; margin-bottom: 4px;
  background: rgba(255, 255, 255, 0.045);
  font-size: 0.72rem; color: rgba(255, 255, 255, 0.8);
  animation: payIn 0.35s var(--ease-out) both;
}
.demo .pay-row .arrow { color: rgba(255, 255, 255, 0.4); }
.demo .pay-row strong { margin-left: auto; font-weight: 600; color: #fff; }
@keyframes payIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Insights screen ── */
.demo .ins-summary { text-align: center; margin-bottom: 10px; }
.demo .period-pill {
  display: inline-block; margin-bottom: 6px; padding: 3px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.07); font-size: 0.66rem; color: rgba(255, 255, 255, 0.7);
}
.demo .ins-total { font-size: 1.6rem; font-weight: 700; color: #fff; letter-spacing: -0.01em; }
.demo .chips { display: flex; gap: 5px; margin-bottom: 10px; }
.demo .chip {
  flex: 1; padding: 5px 0; border-radius: 999px;
  background: rgba(255, 255, 255, 0.07); font-size: 0.64rem; font-weight: 600;
  color: rgba(255, 255, 255, 0.65); transition: background 0.2s, color 0.2s;
}
.demo .chip.active { background: var(--accent); color: #fff; }
.demo .trend-card, .demo .cat-card {
  border-radius: 16px; padding: 12px 14px; margin-bottom: 10px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.07);
}
.demo .trend-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.demo .trend-head h4 { font-size: 0.78rem; font-weight: 700; color: #fff; }
.demo .trend-head span { font-size: 0.62rem; color: rgba(255, 255, 255, 0.55); }
.demo .trend-head em { font-style: normal; }
.demo .trend-card svg { width: 100%; height: auto; display: block; }
.demo .trend-months { display: flex; justify-content: space-between; padding: 2px 4px 0; font-size: 0.58rem; color: rgba(255, 255, 255, 0.4); }
.demo .screen-insights { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; }
.demo .screen-insights::-webkit-scrollbar { display: none; }
.demo .cat-card { margin-bottom: 0; }
.demo .seg {
  display: flex; gap: 4px; padding: 3px; margin-bottom: 12px;
  background: rgba(255, 255, 255, 0.06); border-radius: 999px;
}
.demo .seg button { flex: 1; padding: 4px 0; border-radius: 999px; font-size: 0.64rem; font-weight: 600; color: rgba(255, 255, 255, 0.6); }
.demo .seg button.active { background: rgba(255, 255, 255, 0.16); color: #fff; }
.demo .donut-wrap { position: relative; width: 108px; height: 108px; margin: 0 auto 12px; }
.demo .donut {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(
    #4f8cff 0 37.6%, #151b2c 37.6% 38%,
    #2dd4bf 38% 64.6%, #151b2c 64.6% 65%,
    #c0567a 65% 85.6%, #151b2c 85.6% 86%,
    #8a6cff 86% 99.6%, #151b2c 99.6% 100%);
  -webkit-mask: radial-gradient(closest-side, transparent 62%, #000 63%);
  mask: radial-gradient(closest-side, transparent 62%, #000 63%);
}
.demo .donut-trip {
  background: conic-gradient(
    #4f8cff 0 60.2%, #151b2c 60.2% 60.6%,
    #2dd4bf 60.6% 87.4%, #151b2c 87.4% 87.8%,
    #c0567a 87.8% 95.3%, #151b2c 95.3% 95.7%,
    #8a6cff 95.7% 99.6%, #151b2c 99.6% 100%);
}
.demo .donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.demo .donut-center strong { font-size: 1.15rem; color: #fff; line-height: 1.1; }
.demo .donut-center span { font-size: 0.56rem; color: rgba(255, 255, 255, 0.5); }
.demo .donut-label {
  position: absolute; transform: translate(-50%, -50%);
  font-size: 0.6rem; font-weight: 700; color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.demo .cat-row { border-radius: 12px; padding: 7px 10px; margin-bottom: 5px; }
.demo .cat-top { display: flex; align-items: center; gap: 6px; font-size: 0.7rem; font-weight: 600; color: #fff; }
.demo .cat-top strong { margin-left: auto; font-weight: 600; }
.demo .cat-meta { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.demo .cat-bar { flex: 1; height: 4px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.demo .cat-bar i { display: block; height: 100%; border-radius: 999px; }
.demo .cat-meta > span { font-size: 0.6rem; color: rgba(255, 255, 255, 0.5); }

/* ── Bottom sheet ── */
.demo .scrim {
  position: absolute; inset: 0; z-index: 4; background: rgba(0, 0, 0, 0.55);
  opacity: 0; pointer-events: none; transition: opacity 0.35s var(--ease-out);
}
.demo .phone.sheet-open .scrim { opacity: 1; pointer-events: auto; }
.demo .sheet {
  position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 5;
  padding: 10px 14px 14px; border-radius: 28px;
  background: #181f33; border: 1px solid rgba(255, 255, 255, 0.1);
  transform: translateY(112%); transition: transform 0.45s var(--ease-out);
}
.demo .phone.sheet-open .sheet { transform: translateY(0); }
.demo .sheet-grabber { width: 36px; height: 4px; margin: 0 auto 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.25); }
.demo .sheet h4 { text-align: center; font-size: 0.95rem; font-weight: 700; color: #fff; margin-bottom: 10px; }
.demo .sheet-card { background: rgba(255, 255, 255, 0.05); border-radius: 16px; padding: 14px; }
.demo .sheet-label { font-size: 0.66rem; color: rgba(255, 255, 255, 0.55); }
.demo .sheet-amt { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; }
.demo .sheet-sub { font-size: 0.72rem; color: rgba(255, 255, 255, 0.6); margin-bottom: 10px; }
.demo .sheet-rows { border-top: 1px solid rgba(255, 255, 255, 0.08); padding-top: 8px; }
.demo .sheet-row { display: flex; justify-content: space-between; padding: 3px 0; font-size: 0.74rem; color: rgba(255, 255, 255, 0.75); }
.demo .sheet-row.total { margin-top: 6px; padding-top: 8px; border-top: 1px solid rgba(255, 255, 255, 0.08); font-weight: 700; color: #fff; }
.demo .sheet-more {
  display: flex; justify-content: space-between; align-items: center; width: 100%;
  margin-top: 10px; padding: 11px 14px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.05); font-size: 0.78rem; font-weight: 600; color: #fff;
}
.demo .sheet-more:hover { background: rgba(255, 255, 255, 0.1); }

/* ── Nudge toast ── */
.demo .demo-toast {
  position: absolute; left: 50%; bottom: 78px; z-index: 6;
  transform: translate(-50%, 8px); opacity: 0; pointer-events: none;
  transition: opacity 0.3s var(--ease-out), transform 0.3s var(--ease-out);
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
  padding: 9px 14px; border-radius: 999px;
  background: rgba(13, 18, 32, 0.92); border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(12px);
  font-size: 0.72rem; color: rgba(255, 255, 255, 0.85);
}
.demo .phone.toast-on .demo-toast { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.demo .demo-toast a { color: #6ea8ff; font-weight: 700; text-decoration: none; }

@media (max-width: 360px) {
  .demo .phone { width: 280px; height: 600px; }
}
