/*
 * pOS polish layer. Loaded after the app's compiled CSS, so it refines tokens
 * and components without touching the bundle. It also styles pOS Connect
 * (QR cards, scanner, stickers and print layouts).
 */

/* ---------------------------------------------------------------- tokens */

:root {
  /* Brand accent, taken from the app icon (indigo to coral) instead of stock blue. */
  --accent: #5b3fd9;
  --accent-press: #4a30c2;
  --accent-tint: #5b3fd91f;
  --brand-a: #1b1f3b;
  --brand-b: #3b2a6b;
  --brand-c: #f0806a;
  --brand-grad: linear-gradient(135deg, var(--brand-a), var(--brand-b) 55%, var(--brand-c));
  --card-shadow: 0 1px 2px #1b1f3b0a, 0 8px 24px #1b1f3b0d;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #7d6bff;
    --accent-press: #9585ff;
    --accent-tint: #7d6bff2e;
  }
}

::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }

/* ------------------------------------------------------------ typography */

.t-title2, .section-head h2, .sheet-head h3, .empty h3 { text-wrap: balance; }
.t-sub, .t-foot, .section-foot, .banner span, .perk span, p { text-wrap: pretty; }

.wordmark i {
  background: linear-gradient(120deg, #3b2a6b, #6d4cff 50%, #f0806a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
@media (prefers-color-scheme: dark) {
  .wordmark i { background-image: linear-gradient(120deg, #a99bff, #8f7bff 45%, #ff9b85); }
}

/* --------------------------------------------------------------- surfaces */

.sk {
  background: linear-gradient(90deg, var(--fill-2) 25%, var(--fill-3) 45%, var(--fill-2) 65%);
  background-size: 300% 100%;
  animation: pos-shimmer 1.3s ease-in-out infinite;
}
@keyframes pos-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* Desktop and tablet: rows and buttons react to the pointer. */
@media (hover: hover) and (pointer: fine) {
  button.row, a.row { transition: background-color .15s; }
  button.row:hover, a.row:hover { background: color-mix(in srgb, var(--label) 4%, transparent); }
  .btn:hover:not(:disabled) { filter: brightness(1.05); }
  .mini-btn:hover { filter: brightness(.97); }
  * { scrollbar-width: thin; scrollbar-color: var(--fill) transparent; }
}

/* ------------------------------------------------------ owner home density */

/* Waiting-payment card: keep "Not received" on one line. */
.await-actions .btn { white-space: nowrap; }
.await-actions .btn.gray:not(.icon-only) { flex: 0 0 auto; width: auto; padding: 0 16px; }

/* On phones, action pills become icon buttons so names and amounts stay readable.
   Each one already carries an aria-label, so screen readers are unaffected. */
@media (max-width: 440px) {
  .row-actions { gap: 6px; }
  .row-actions .mini-btn {
    font-size: 0;
    gap: 0;
    width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
  }
  .row-actions .mini-btn svg { width: 19px; height: 19px; }
}

/* ------------------------------------------------------ motion preferences */

@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================ pOS Connect */

/* QR card: always light, like a printed payment standee, in both themes. */
.qr[data-pos-qr] {
  width: min(320px, 100%);
  padding: 0;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 1px 2px #0000000d, 0 14px 40px #1b1f3b24;
  overflow: hidden;
  position: relative;
}
.qr[data-pos-qr] > :not(.pos-qr-card) { display: none; }
.qr[data-pos-qr]::before {
  content: "";
  display: block;
  height: 6px;
  background: var(--brand-grad);
}

.pos-qr-card {
  color: #0b0b0f;
  text-align: center;
  padding: 16px 18px 16px;
  animation: pos-pop .45s var(--spring) both;
}
.pos-invite-qr .pos-qr-card {
  margin-top: 12px;
  background: #fff;
  border-radius: 26px;
  box-shadow: 0 1px 2px #0000000d, 0 14px 40px #1b1f3b1f;
  border-top: 6px solid transparent;
  border-image: var(--brand-grad) 1 0 0 0;
  max-width: 340px;
  margin-inline: auto;
}
.pos-qr-head {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -.01em;
  color: #2b1d5c;
}
.pos-upi-mark {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  color: #fff;
  background: #2b1d5c;
  border-radius: 6px;
  padding: 3px 6px 2px;
  font-style: italic;
}
.pos-qr-art {
  margin: 10px auto 6px;
  width: min(232px, 100%);
  aspect-ratio: 1;
}
.pos-qr-art svg { width: 100%; height: 100%; display: block; }
.pos-qr-amount {
  font-family: var(--font-round);
  font-size: 28px;
  font-weight: 750;
  letter-spacing: -.01em;
  line-height: 1.1;
}
.pos-qr-to { font-size: 14px; color: #55555f; margin-top: 4px; line-height: 1.35; overflow-wrap: anywhere; }
.pos-qr-to b { color: #0b0b0f; font-weight: 600; }
.pos-qr-note { font-size: 13px; color: #6b6b75; margin-top: 6px; }
.pos-qr-apps {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  margin-top: 12px;
}
.pos-qr-apps span {
  font-size: 11.5px;
  font-weight: 600;
  color: #3c3c43;
  background: #f2f2f7;
  border-radius: 999px;
  padding: 4px 9px;
}
.pos-qr-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.pos-chip-btn {
  flex: 1;
  height: 42px;
  border-radius: 21px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 600;
  color: #4a30c2;
  background: #5b3fd914;
  transition: transform .3s var(--spring), background-color .2s;
}
.pos-chip-btn:active { transform: scale(.96); }
.pos-chip-btn:disabled { opacity: .55; }
.pos-chip-btn svg { width: 18px; height: 18px; }

@keyframes pos-pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }

/* Invite disclosure */
.pos-invite-qr { margin-top: 12px; }
.pos-disclosure {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-radius: 16px;
  background: var(--bg-elevated);
  box-shadow: var(--card-shadow);
  color: var(--accent);
  font-size: 16px;
  font-weight: 600;
  text-align: left;
}
.pos-disclosure span { flex: 1; }
.pos-disclosure svg { width: 22px; height: 22px; flex: none; }
.pos-disclosure svg:last-child { width: 18px; height: 18px; color: var(--label-3); transition: transform .3s var(--spring); }
.pos-disclosure[aria-expanded="true"] svg:last-child { transform: rotate(90deg); }

/* Meter tools under "Scan a meter" */
.pos-meter-tools { display: flex; gap: 8px; margin-top: 10px; }
.pos-meter-tools .btn { flex: 1; min-width: 0; white-space: nowrap; }

/* Sticker picker */
.pos-sticker-intro { color: var(--label-2); font-size: 15px; line-height: 1.4; padding: 0 4px; }
.pos-unit-pick label.row { cursor: pointer; gap: 12px; }
.pos-unit-pick input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; margin: 0; }

/* Our own sheets reuse the app's sheet classes; add a close animation. */
.pos-sheet.closing .sheet { transition: transform .22s ease-in, opacity .22s; transform: translateY(24px); opacity: 0; }
.pos-sheet.closing .scrim { transition: opacity .22s; opacity: 0; }

/* Welcome screen entry */
.pos-welcome-scan {
  margin: 14px auto 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 22px;
  color: var(--label-2);
  font-size: 15px;
  align-self: center;
}
.pos-welcome-scan b { color: var(--accent); font-weight: 600; }
.pos-welcome-scan svg { width: 20px; height: 20px; color: var(--accent); }

/* Toast lifecycle for our messages */
.pos-toast { transition: opacity .3s; }
.pos-toast.out { opacity: 0; }

/* ---------------------------------------------------------------- scanner */

html.pos-scanning, html.pos-scanning body { overflow: hidden; }

.pos-scanner {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
  color: #fff;
  animation: pos-fade .25s ease both;
}
.pos-scanner.closing { transition: opacity .2s; opacity: 0; }
.pos-scanner video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity .4s;
}
.pos-scanner.live video { opacity: 1; }
.pos-scan-shade {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}
.pos-scan-frame {
  --s: min(68vw, 300px);
  width: var(--s);
  height: var(--s);
  border-radius: 34px;
  position: relative;
  box-shadow: 0 0 0 100vmax #000000a6;
  transition: transform .3s var(--spring);
}
.pos-scan-frame i {
  position: absolute;
  width: 54px;
  height: 54px;
  border: 5px solid #fff;
  border-radius: 34px;
}
.pos-scan-frame i:nth-child(1) { top: -2px; left: -2px; border-right: 0; border-bottom: 0; border-radius: 34px 0 0 0; }
.pos-scan-frame i:nth-child(2) { top: -2px; right: -2px; border-left: 0; border-bottom: 0; border-radius: 0 34px 0 0; }
.pos-scan-frame i:nth-child(3) { bottom: -2px; left: -2px; border-right: 0; border-top: 0; border-radius: 0 0 0 34px; }
.pos-scan-frame i:nth-child(4) { bottom: -2px; right: -2px; border-left: 0; border-top: 0; border-radius: 0 0 34px 0; }
.pos-scan-frame b {
  position: absolute;
  left: 12%;
  right: 12%;
  height: 2px;
  top: 50%;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, #a99bff, #ff9b85, transparent);
  box-shadow: 0 0 18px #a99bff;
  animation: pos-sweep 2.2s ease-in-out infinite alternate;
  opacity: 0;
}
.pos-scanner.live .pos-scan-frame b { opacity: 1; }
.pos-scanner.found .pos-scan-frame { transform: scale(.94); }
.pos-scanner.found .pos-scan-frame i { border-color: #30d158; }
@keyframes pos-sweep { from { top: 14%; } to { top: 86%; } }
@keyframes pos-fade { from { opacity: 0; } to { opacity: 1; } }

.pos-scan-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(var(--safe-t) + 12px) 16px 12px;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
}
.pos-scan-top .circle-btn { width: 44px; height: 44px; color: #fff; display: grid; place-items: center; border-radius: 50%; background: #ffffff26; -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.pos-scan-top .circle-btn svg { width: 20px; height: 20px; }
.pos-scan-title { text-align: center; font-size: 17px; font-weight: 600; }
.pos-scan-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 16px 24px calc(var(--safe-b) + 28px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}
.pos-scan-hint { margin: 0; font-size: 16px; line-height: 1.4; max-width: 320px; color: #ffffffe6; }
.pos-scan-photo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 24px;
  background: #ffffff26;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.pos-scan-photo svg { width: 20px; height: 20px; }
.pos-scan-photo:focus-within { outline: 3px solid #a99bff; outline-offset: 2px; }
.pos-scanner.nocam .pos-scan-frame b { display: none; }

/* ------------------------------------------------------------------ print */

.pos-print-root { display: none; }

@media print {
  html.pos-printing body > *:not(.pos-print-root) { display: none !important; }
  html.pos-printing, html.pos-printing body { background: #fff !important; }
  html.pos-printing .pos-print-root {
    display: block;
    color: #0b0b0f;
    font-family: var(--font);
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  @page { margin: 12mm; }
}

.pos-print-bar { height: 8px; border-radius: 8px; background: linear-gradient(90deg, #1b1f3b, #3b2a6b 55%, #f0806a); }

.pos-print-card { max-width: 150mm; margin: 0 auto; text-align: center; }
.pos-print-card h1 { font-size: 30pt; margin: 14mm 0 3mm; letter-spacing: -.02em; }
.pos-print-card .lead { font-size: 13pt; color: #55555f; margin: 0 0 8mm; }
.pos-print-qr { width: 85mm; height: 85mm; margin: 0 auto 8mm; }
.pos-print-qr svg, .pos-sticker-qr svg { width: 100%; height: 100%; display: block; }
.pos-print-card ol { text-align: left; font-size: 13pt; line-height: 1.7; max-width: 110mm; margin: 0 auto 8mm; }
.pos-print-card .link { font-size: 9pt; color: #8a8a94; word-break: break-all; }

.pos-sticker-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6mm; }
.pos-sticker {
  break-inside: avoid;
  border: 1px dashed #c7c7cc;
  border-radius: 5mm;
  padding: 0 4mm 4mm;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  overflow: hidden;
}
.pos-sticker .pos-print-bar { align-self: stretch; margin: 0 -4mm 3mm; border-radius: 0; height: 5px; }
.pos-sticker-qr { width: 42mm; height: 42mm; }
.pos-sticker b { font-size: 13pt; margin-top: 2mm; }
.pos-sticker span { font-size: 9pt; color: #55555f; }
.pos-sticker em { font-style: normal; font-size: 8.5pt; color: #3b2a6b; font-weight: 600; margin-top: 1.5mm; }
