/* HDFC Smart Widgets — Medium Widget Prototype
   Tokens come from the Figma file's "Colour Styles" (Light mode) + widget spec. */

:root {
  --primary-500: #1c3fca;
  --primary-50: #f3f6fd;
  --neutral-100: #f5f6fb;
  --neutral-200: #ecedf3;
  --neutral-400: #9ca3af;
  --neutral-500: #6b7280;
  --neutral-600: #4b5563;
  --neutral-900: #111827;
  --success-500: #00875f;
  --faceid-green: #87fa89;
  --navy-a: #090c34;
  --navy-b: #0f3167;
  --pay-a: #080326;
  --pay-b: #0e346b;
  --phone-w: 402px;
  --phone-h: 874px;
  --ios-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", system-ui, sans-serif;
  --app-font: "Inter", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --t-dissolve: 300ms;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: #0b0d1a;
  color: #fff;
  font-family: var(--app-font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible { outline: 2px solid #4d71ff; outline-offset: 2px; }
img { display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Stage + phone ---------- */
.stage {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background:
    radial-gradient(60% 50% at 50% 0%, rgba(28, 63, 202, 0.18), transparent 70%),
    #0b0d1a;
}
.phone-wrap {
  width: calc(var(--phone-w) * var(--scale, 1));
  height: calc(var(--phone-h) * var(--scale, 1));
}
.phone {
  position: relative;
  width: var(--phone-w); height: var(--phone-h);
  border-radius: 54px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 0 10px #101216, 0 0 0 12px #2a2d36, 0 40px 80px rgba(0, 0, 0, 0.6);
  transform: scale(var(--scale, 1));
  transform-origin: top left;
  isolation: isolate;
}
.phone.bare { border-radius: 0; box-shadow: none; }
.home-indicator {
  position: absolute; left: 50%; bottom: 8px; width: 140px; height: 5px;
  transform: translateX(-50%); border-radius: 3px; background: rgba(255, 255, 255, 0.9);
  z-index: 50; pointer-events: none; mix-blend-mode: difference;
}
.hint {
  position: fixed; left: 0; right: 0; bottom: 14px; margin: 0; text-align: center;
  font-size: 13px; color: rgba(255, 255, 255, 0.55);
}
.hint kbd { font: inherit; padding: 1px 6px; border: 1px solid rgba(255,255,255,.25); border-radius: 5px; }
.stage.bare .hint { display: none; }

/* Embed mode: transparent page, phone frame only (used by /embed and ?embed) */
body.is-embed { background: transparent; }
body.is-embed .stage { background: transparent; }
body.is-embed .hint { display: none; }
body.is-embed .phone { box-shadow: 0 0 0 10px #101216, 0 0 0 12px #2a2d36, 0 24px 48px rgba(0, 0, 0, 0.45); }

/* ---------- Screens ---------- */
.screen {
  position: absolute; inset: 0;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity var(--t-dissolve) ease, visibility 0s linear var(--t-dissolve);
}
.screen.is-active { opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 0s; }
.screen .bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-drag: none; }
.hit { position: absolute; background: transparent; }

/* ---------- 1 · Home + widget ---------- */
.widget {
  position: absolute; left: 27px; top: 88px;
  width: 349px; height: 164px;
  border-radius: 28px; overflow: hidden;
  background: linear-gradient(98deg, var(--navy-a) 0%, var(--navy-b) 100%);
  font-family: var(--ios-font);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}
.widget-header { height: 40px; padding: 10px 10px 10px 30px; color: #fff; }
.widget-body {
  position: absolute; left: 0; right: 0; top: 40px; height: 124px;
  border-radius: 28px; background: #fff;
  display: flex; justify-content: center; align-items: center; gap: 16px;
}
/* Top gradient rule: red(0) → purple → blue → purple → red(0), drawn outside like Figma */
.widget-body::before {
  content: ""; position: absolute; left: 0; right: 0; top: -1px; height: 1.5px;
  background: linear-gradient(90deg, rgba(255,0,15,0) 0%, rgba(111,78,183,.73) 35%, #3a6bf5 50%, rgba(100,84,196,.79) 65%, rgba(255,0,15,0) 100%);
  border-radius: 2px;
}
.widget-action {
  width: 70px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  color: var(--neutral-900); -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.icon-box {
  width: 48px; height: 48px; border-radius: 16px;
  border: 1px solid var(--neutral-200);
  display: grid; place-items: center; color: var(--primary-500);
  transition: background-color 120ms ease, transform 120ms ease;
}
.icon { width: 24px; height: 24px; --icon-bg: #fff; }
.widget-action .label { font-size: 12px; line-height: 16px; text-align: center; }
.widget-action.is-pressed .icon-box, .widget-action:active .icon-box { background: var(--neutral-200); transform: scale(0.97); }
.widget-name {
  position: absolute; left: 0; right: 0; top: 257px; margin: 0; text-align: center;
  font: 500 12px/14px var(--ios-font); color: #fff;
}

/* ---------- 2/3 · Face ID ---------- */
.faceid-tile {
  position: absolute; left: 126px; top: 352px; width: 151px; height: 151px;
  border-radius: 40px; background: #000;
  box-shadow: 0 12px 74px rgba(0, 0, 0, 0.22);
  display: grid; place-items: center;
}
.faceid-tile .glyph { grid-area: 1 / 1; width: 151px; height: 151px; transition: opacity 740ms ease, transform 740ms ease; }
.faceid-tile .glyph-check { opacity: 0; transform: scale(0.85); }
.faceid-tile.is-check .glyph-scan { opacity: 0; transform: scale(0.85); }
.faceid-tile.is-check .glyph-check { opacity: 1; transform: none; }
.faceid-tile .glyph-scan { animation: faceid-pulse 1.2s ease-in-out infinite; }
.faceid-tile.is-check .glyph-scan { animation: none; }
@keyframes faceid-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* ---------- 4–6 · QR scan ---------- */
.scan-line {
  position: absolute; left: 78px; width: 256px; height: 2px; top: 272px;
  background: #fff; border-radius: 2px;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.9), 0 0 18px rgba(77, 113, 255, 0.6);
  opacity: 0.95;
}
/* Figma: hold 0.4s → smart-animate 1.02s to y=489 → hold 0.4s → 1.02s back to y=270 → hold 0.4s → dissolve.
   Total ≈ 3.24s, then the Payment screen dissolves in. */
.screen-qr.is-active .scan-line { animation: scan 3.24s cubic-bezier(0.45, 0, 0.55, 1) forwards; }
@keyframes scan {
  0%      { top: 272px; }
  12.35%  { top: 272px; }  /* 0.40s */
  43.83%  { top: 489px; }  /* 1.42s */
  56.17%  { top: 489px; }  /* 1.82s */
  87.65%  { top: 270px; }  /* 2.84s */
  100%    { top: 270px; }  /* 3.24s */
}
.close-hit { left: 8px; top: 62px; width: 44px; height: 44px; border-radius: 22px; }

/* ---------- 7 · Payment ---------- */
.screen-pay { background: #fff; font-family: var(--app-font); color: var(--neutral-900); }
.pay-hero {
  position: absolute; left: 0; top: 0; width: 100%; height: 472px;
  background: linear-gradient(180deg, var(--pay-a) 0%, var(--pay-b) 100%);
  color: #fff;
}
.status-bar {
  position: absolute; left: 0; right: 0; top: 0; height: 62px;
  display: flex; align-items: center; justify-content: space-between; padding: 21px 24px 0;
  font-family: var(--ios-font); font-weight: 600; font-size: 17px;
}
.status-bar .time { width: 100px; padding-left: 32px; }
.status-bar .levels { width: 100px; display: flex; justify-content: flex-end; align-items: center; gap: 7px; }
.pay-nav { position: absolute; left: 20px; right: 20px; top: 74px; height: 32px; display: flex; justify-content: space-between; align-items: center; }
.nav-btn { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 16px; color: #fff; }
.nav-btn:last-child { border: 1px solid rgba(255, 255, 255, 0.45); }
.payee { position: absolute; left: 20px; right: 20px; top: 166px; text-align: center; }
.avatar {
  width: 48px; height: 48px; margin: 0 auto; border-radius: 24px;
  background: #7c5cff; color: #fff; font-weight: 600; font-size: 16px;
  display: grid; place-items: center;
}
.payee-name { margin-top: 12px; font-size: 14px; line-height: 20px; font-weight: 600; }
.amount { margin-top: 12px; font-size: 32px; line-height: 40px; font-weight: 600; letter-spacing: -0.2px; display: flex; justify-content: center; align-items: baseline; gap: 2px; }
.amount .rupee { font-weight: 600; }
.amount .paise { font-size: 16px; line-height: 20px; }
.amount .note-icon { margin-left: 8px; align-self: center; opacity: 0.9; }
.amount-words { margin: 8px auto 0; max-width: 340px; font-size: 16px; line-height: 24px; color: rgba(255, 255, 255, 0.72); }
.chip {
  margin-top: 20px; height: 36px; padding: 0 12px 0 9px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.10); color: #fff; font-size: 14px; line-height: 20px; font-weight: 500;
}
.pay-sheet {
  position: absolute; left: 0; right: 0; top: 440px; height: 294px;
  background: #fff; border-radius: 24px 24px 0 0; padding: 24px 20px 0;
}
.note-field input {
  width: 320px; height: 48px; padding: 14px 16px; border-radius: 8px;
  border: 1px solid var(--neutral-400); background: #fff;
  font: 400 14px/20px var(--app-font); color: var(--neutral-900);
}
.note-field input::placeholder { color: var(--neutral-500); }
.note-field input:focus { outline: none; border-color: var(--primary-500); box-shadow: 0 0 0 3px rgba(28, 63, 202, 0.12); }
.paying-from { margin: 24px 0 12px; font-size: 16px; line-height: 24px; font-weight: 400; color: var(--neutral-600); }
.account-card {
  width: 320px; height: 102px; padding: 16px; border-radius: 12px;
  border: 1px solid var(--neutral-200); background: #fff;
  display: grid; grid-template-columns: 20px 1fr 20px; gap: 12px; align-items: start; text-align: left;
}
.account-card .chev { color: var(--neutral-900); }
.account-info { display: flex; flex-direction: column; gap: 4px; }
.account-info .bank { font-size: 16px; line-height: 24px; font-weight: 600; color: var(--neutral-900); }
.account-info .meta { font-size: 12px; line-height: 16px; color: var(--neutral-600); }
.account-info .meta b { font-weight: 600; color: var(--neutral-900); }
.powered {
  position: absolute; left: 0; right: 0; top: 250px; margin: 0;
  display: flex; justify-content: center; align-items: center; gap: 8px;
  font-size: 12px; line-height: 20px; color: var(--neutral-600);
}
.pay-cta {
  position: absolute; left: 0; right: 0; top: 734px; height: 140px;
  padding: 20px 20px 0; background: #fff; border-top: 1px solid var(--neutral-100);
}
.swipe {
  position: relative; width: 362px; height: 44px; border-radius: 8px;
  background: var(--primary-500); color: #fff; overflow: hidden;
  display: grid; place-items: center; user-select: none; touch-action: pan-y;
  font-family: "Archivo", var(--app-font); font-weight: 600; font-size: 16px;
}
.swipe:focus-visible { outline: 2px solid #4d71ff; outline-offset: 3px; }
.swipe-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(255, 255, 255, 0.16); }
.swipe-knob {
  position: absolute; left: 3px; top: 3px; width: 55px; height: 38px; border-radius: 6px;
  background: #fff; color: var(--primary-500); display: grid; place-items: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18); cursor: grab; will-change: transform;
}
.swipe.is-dragging .swipe-knob { cursor: grabbing; }
.swipe.is-resetting .swipe-knob, .swipe.is-resetting .swipe-fill { transition: transform 260ms ease, width 260ms ease; }
.swipe-label { position: relative; padding-left: 40px; transition: opacity 150ms; }
.swipe.is-done { background: var(--success-500); }
.swipe.is-done .swipe-knob { color: var(--success-500); }
.tertiary { display: block; width: 362px; height: 48px; margin-top: 12px; color: var(--primary-500); font-weight: 600; font-size: 16px; }

.paid-overlay {
  position: absolute; inset: 0; background: rgba(8, 3, 38, 0.72);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  opacity: 0; visibility: hidden; transition: opacity 370ms ease, visibility 0s linear 370ms; color: #fff;
}
.paid-overlay .faceid-tile { position: static; }
.paid-overlay .faceid-tile .glyph-check { opacity: 1; transform: none; }
.paid-title { margin: 28px 0 0; font-size: 20px; line-height: 28px; font-weight: 600; }
.paid-sub { margin: 4px 0 0; font-size: 14px; line-height: 20px; color: rgba(255, 255, 255, 0.72); }
.screen-pay.is-paid .paid-overlay { opacity: 1; visibility: visible; transition-delay: 0s; }

/* ---------- App screens (Send Money / Amount / Transactions) ---------- */
.screen-app { background: #fff; color: var(--neutral-900); font-family: var(--app-font); }
.status-bar.dark { color: var(--neutral-900); }
.app-header {
  position: absolute; left: 0; right: 0; top: 62px; height: 56px;
  display: flex; align-items: center; gap: 12px; padding: 0 20px;
}
.app-header h1 { flex: 1; margin: 0; font-size: 16px; line-height: 24px; font-weight: 600; }
.icon-btn { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 16px; color: var(--neutral-900); margin: 0 -4px; }
.app-content { position: absolute; left: 0; right: 0; top: 118px; bottom: 0; padding: 12px 20px 24px; overflow-y: auto; overscroll-behavior: contain; }
.search-field {
  display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 14px;
  border: 1px solid var(--neutral-400); border-radius: 8px; color: var(--neutral-500); background: #fff;
}
.search-field input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: 400 14px/20px var(--app-font); color: var(--neutral-900); }
.search-field input::placeholder { color: var(--neutral-500); }
.search-field:focus-within { border-color: var(--primary-500); box-shadow: 0 0 0 3px rgba(28, 63, 202, 0.12); }
.chip-row { display: flex; gap: 8px; margin-top: 20px; }
.chip-row.center { justify-content: center; }
.mode-chip {
  height: 32px; padding: 0 14px; border-radius: 16px; border: 1px solid var(--neutral-300);
  font-size: 14px; line-height: 20px; font-weight: 500; color: var(--neutral-900); background: #fff;
  transition: background-color 120ms, color 120ms, border-color 120ms;
}
.mode-chip.is-on { background: var(--primary-500); border-color: var(--primary-500); color: #fff; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; }
.section-head h2, .list-title { margin: 0; font-size: 16px; line-height: 24px; font-weight: 600; }
.list-title { margin-top: 20px; }
.link { color: var(--primary-500); font-size: 14px; font-weight: 500; }
.recent-row { display: flex; gap: 22px; margin-top: 12px; }
.contact { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 60px; font-size: 13px; color: var(--neutral-900); }
.av {
  --av: var(--primary-500);
  flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--av); color: #fff;
  display: grid; place-items: center; font-weight: 600; font-size: 14px;
}
.av-lg { width: 54px; height: 54px; font-size: 18px; }
.list { list-style: none; margin: 0; padding: 0; }
.list-row {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 0; text-align: left;
  border-bottom: 1px solid var(--neutral-200);
}
.list-row:active { background: var(--neutral-100); }
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-text b { font-size: 14px; line-height: 20px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-text small { font-size: 12px; line-height: 16px; color: var(--neutral-500); }
.row-amt { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.row-amt b { font-size: 14px; line-height: 20px; font-weight: 600; }
.row-amt b.credit { color: var(--success-500); }
.row-amt small { font-size: 12px; line-height: 16px; color: var(--neutral-500); }
.row-amt small.pending { color: #f99f35; }
.chev { color: var(--neutral-400); flex: none; }

/* Amount screen */
.amount-screen { display: flex; flex-direction: column; align-items: stretch; gap: 20px; padding-top: 8px; overflow: hidden; }
.payee-card { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border: 1px solid var(--neutral-200); border-radius: 12px; }
.amount-display { text-align: center; padding-top: 4px; }
.amount-big { font-size: 40px; line-height: 48px; font-weight: 600; letter-spacing: -0.5px; }
.amount-big .rupee { font-weight: 600; }
.amount-display small { display: block; margin-top: 6px; font-size: 12px; line-height: 16px; color: var(--neutral-500); }
.amount-screen .chip-row { margin-top: 0; }
.note-field.small input { width: 100%; height: 44px; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad button { height: 46px; border-radius: 8px; background: var(--neutral-100); font-size: 22px; font-weight: 500; color: var(--neutral-900); display: grid; place-items: center; }
.keypad button:active { background: var(--neutral-200); }
.primary-btn { width: 100%; height: 44px; border-radius: 8px; background: var(--primary-500); color: #fff; font-size: 16px; font-weight: 600; }
.primary-btn:active { filter: brightness(0.92); }
.secondary-btn { flex: 1; height: 44px; border-radius: 8px; border: 1px solid var(--neutral-300); color: var(--primary-500); font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }

/* Transactions */
.account-pill { width: 100%; display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 14px; border: 1px solid var(--neutral-200); border-radius: 8px; font-size: 14px; font-weight: 500; text-align: left; }
.account-pill span { flex: 1; }
.month-label { margin: 16px 0 0; font-size: 12px; line-height: 16px; font-weight: 600; color: var(--neutral-500); letter-spacing: 0.4px; }
.txn-list .list-row { gap: 12px; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(8, 3, 38, 0.55); opacity: 0; transition: opacity 250ms; }
.sheet-scrim.is-open { opacity: 1; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; background: #fff; border-radius: 24px 24px 0 0;
  padding: 12px 20px 28px; display: flex; flex-direction: column; gap: 16px; align-items: center;
  transform: translateY(100%); transition: transform 300ms cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.18);
}
.sheet.is-open { transform: none; }
.sheet[hidden], .sheet-scrim[hidden] { display: none; }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--neutral-300); padding: 0; position: relative; }
.sheet-handle::before { content: ""; position: absolute; inset: -14px -40px; }
.sheet-summary { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.sheet-sub { margin: 0; font-size: 14px; color: var(--neutral-600); }
.sheet-amount { margin: 0; font-size: 28px; line-height: 34px; font-weight: 600; }
.status-pill { padding: 4px 10px; border-radius: 12px; background: #c7f9d6; color: var(--success-500); font-size: 12px; font-weight: 600; }
.status-pill.pending { background: #fef8e6; color: #b35f1a; }
.details { width: 100%; margin: 0; border: 1px solid var(--neutral-200); border-radius: 12px; }
.details > div { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--neutral-200); }
.details > div:last-child { border-bottom: 0; }
.details dt { margin: 0; font-size: 12px; color: var(--neutral-500); }
.details dd { margin: 0; font-size: 12px; font-weight: 600; text-align: right; }
.sheet-actions { width: 100%; display: flex; gap: 8px; }
.sheet .primary-btn { width: 100%; }

/* Dashboard / balance */
.screen-dash { background: #0b1a4d; font-family: var(--app-font); color: #fff; }
.balance-block { position: absolute; left: 0; right: 0; top: 206px; text-align: center; }
.balance-value {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 40px;
  font-size: 27px; line-height: 36px; font-weight: 600; color: #fff; padding: 2px 6px; border-radius: 8px;
}
.balance-value:focus-visible { outline: 2px solid rgba(255,255,255,.6); outline-offset: 2px; }
.balance-value .eye { color: #fff; }
.balance-value .eye-on { display: none; }
.balance-value.is-revealed .eye-on { display: block; }
.balance-value.is-revealed .eye-off { display: none; }
.balance-value #balanceText { font-variant-numeric: tabular-nums; }
.balance-caption { margin: 36px 0 0; font-size: 12px; line-height: 16px; color: rgba(255,255,255,.75); opacity: 0; transition: opacity 300ms; }
.balance-caption.is-visible { opacity: 1; }

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  .faceid-tile .glyph-scan { animation: none; }
  .screen { transition-duration: 1ms; }
}
