/* From paper offer to paid - test prototype
   Values mirror the Billogram token system (see ../DESIGN.md).
   Custom property names follow the Figma semantic token paths. */

:root {
  /* Billogram semantics */
  --text-primary: #292d32;
  --text-secondary: #636d79;
  --text-link: #0067e5;
  --background-page: #ffffff;
  --background-sunken: #f4f5f6;
  --border-default: #e0e0e1;
  --brand-interactive-primary-surface-default: #0067e5;
  --brand-interactive-primary-surface-active: #003270;
  --brand-interactive-primary-on-color: #f5fbff;
  --feedback-success-background-subtle: #e7f5ec;
  --feedback-success-icon: #17724a;
  --feedback-success-text: #135c3c;
  --radius-card: 24px;
  --radius-button: 999px;
  --radius-input: 10px;
  --shadow-card: 0 4px 30px rgba(0, 0, 0, 0.08);

  /* Offer campaign colors (from the design sketch, not system tokens) */
  --offer-heading: #12403a;
  --offer-amount: #003270;

  /* Swish + BankID look-alike palettes (prototype only) */
  --swish-ink: #222222;
  --bankid-ink: #193e4f;
  --bankid-blue: #479cbe;

  --app-font: "Inter", -apple-system, "Helvetica Neue", Arial, sans-serif;

  /* Real device safe areas; overridden with fake values inside the desktop frame */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overscroll-behavior: none;
}

/* White canvas so a stale first-paint viewport (iOS Safari after QR-scan
   open) shows page-colored space instead of a black rectangle */
html { background: #ffffff; }

body {
  font-family: var(--app-font);
  color: var(--text-primary);
  background: #000;
  height: 100dvh; /* live unit: tracks iOS toolbar state, unlike 100% */
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  position: fixed;
  inset: 0;
  overflow: hidden;
}

/* ---------- desktop iPhone frame ---------- */
/* On phones the frame is a transparent full-viewport wrapper; from 520px
   wide it becomes an iPhone 17 mockup so the design keeps its phone
   proportions without resizing the browser window. */

.iphone-17 {
  position: absolute;
  inset: 0;
}

.device-screen {
  position: absolute;
  inset: 0;
  background: #000;
  overflow: hidden;
}

.dynamic-island { display: none; }

@media (min-width: 520px) and (hover: hover) {
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #26282c;
  }

  /* Fake the phone's safe areas (real iPhone values) so content clears the island */
  :root {
    --safe-top: 59px;
    --safe-bottom: 34px;
  }

  .iphone-17 {
    position: relative;
    inset: auto;
    flex: 0 0 auto;
    width: 390px;
    height: 844px;
    background: #1a1a1a;
    border-radius: 56px;
    padding: 12px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3), inset 0 0 0 3px #444;
  }

  .device-screen {
    position: relative;
    inset: auto;
    width: 100%;
    height: 100%;
    border-radius: 44px;
  }

  .dynamic-island {
    display: block;
    position: absolute;
    top: 23px;
    left: 50%;
    transform: translateX(-50%);
    width: 122px;
    height: 34px;
    background: #000;
    border-radius: 20px;
    z-index: 50;
    pointer-events: none;
  }

  .device-screen::after {
    content: "";
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 140px;
    height: 5px;
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.28);
    z-index: 50;
    pointer-events: none;
  }
}

/* Shrink the frame on short windows so it never clips (868px tall at full size) */
@media (min-width: 520px) and (hover: hover) and (max-height: 920px) {
  .iphone-17 { transform: scale(0.9); }
}

@media (min-width: 520px) and (hover: hover) and (max-height: 830px) {
  .iphone-17 { transform: scale(0.8); }
}

@media (min-width: 520px) and (hover: hover) and (max-height: 730px) {
  .iphone-17 { transform: scale(0.7); }
}

@media (min-width: 520px) and (hover: hover) and (max-height: 640px) {
  .iphone-17 { transform: scale(0.6); }
}

/* ---------- screens + app-switch transition ---------- */

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  background: var(--background-page);
  overflow: hidden;
}

/* z-index keeps the settled screen above .switch-backdrop while it fades out */
.screen.is-active { display: flex; z-index: 10; }

.switch-backdrop {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.42s ease;
  z-index: 5;
}

body.is-switching .switch-backdrop { opacity: 1; }

.screen.leave, .screen.enter { display: flex; z-index: 10; }

.screen.leave {
  animation: app-leave 0.42s cubic-bezier(0.32, 0, 0.67, 0) forwards;
}

.screen.enter {
  z-index: 20;
  animation: app-enter 0.46s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes app-leave {
  from { transform: scale(1); border-radius: 0; opacity: 1; }
  to { transform: scale(0.88); border-radius: 40px; opacity: 0; }
}

@keyframes app-enter {
  from { transform: scale(1.1); border-radius: 40px; opacity: 0; }
  to { transform: scale(1); border-radius: 0; opacity: 1; }
}

/* ---------- spinners ---------- */

.spinner {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid rgba(0, 0, 0, 0.12);
  border-top-color: var(--text-secondary);
  animation: spin 0.9s linear infinite;
}

.spinner-swish { border-top-color: #4f45c2; }

.spinner-bankid {
  width: 56px;
  height: 56px;
  border-width: 5px;
  border-color: rgba(71, 156, 190, 0.22);
  border-top-color: var(--bankid-blue);
  animation-duration: 1.05s;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- boot / loading bridge ---------- */

.boot {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Billogram chrome ---------- */

.bg-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(var(--safe-top) + 14px) 20px 14px;
  background: var(--background-page);
  border-bottom: 1px solid var(--border-default);
  flex: 0 0 auto;
}

.bg-cloud { width: 34px; height: 22px; color: var(--text-primary); }

.bg-wordmark {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.bg-page {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px 20px calc(var(--safe-bottom) + 32px);
}

/* ---------- mySafety offer landing (Figma node 23:684) ---------- */

.ms-nav {
  display: flex;
  align-items: center;
  height: calc(var(--safe-top) + 80px);
  padding: var(--safe-top) 16px 0;
  background: var(--background-page);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  flex: 0 0 auto;
  position: relative;
  z-index: 2;
}

.ms-logo {
  display: block;
  height: 48px;
  width: auto;
}

.offer-page {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.offer-hero {
  height: 193px;
  background: #d9d9d9;
  overflow: hidden;
}

.offer-hero img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 25%;
}

.offer-intro {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 40px 24px 0;
}

.offer-heading {
  font-size: 32px;
  line-height: normal;
  font-weight: 700;
  color: var(--offer-heading);
}

.offer-body {
  font-size: 20px;
  line-height: normal;
  color: var(--offer-heading);
}

.offer-pay {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 40px 24px calc(var(--safe-bottom) + 32px);
}

.offer-amount {
  font-size: 32px;
  line-height: normal;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--offer-amount);
  margin-bottom: 7px; /* 23px gap to the Swish card in the design */
}

.swish-card {
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding: 16px;
  background: var(--background-page);
  border-radius: 10px;
  box-shadow: 0 2px 7.5px rgba(50, 67, 88, 0.15);
}

.swish-card-head {
  display: flex;
  align-items: flex-end;
  gap: 16px;
}

.swish-icon {
  display: block;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
}

.swish-card-title {
  font-size: 18px;
  line-height: 1.5;
  font-weight: 500;
  letter-spacing: 0.2px;
  color: #000;
}

.btn-swish-continue {
  width: 100%;
  height: 48px;
  font: inherit;
  font-size: 18px;
  font-weight: 500;
  color: #000;
  background: #00cc66;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}

.btn-swish-continue:active { background: #00b85c; }

.method-row {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 64px;
  padding: 0 16px;
  background: var(--background-page);
  border: 0;
  border-radius: 10px;
  box-shadow: 0 2px 7.5px rgba(50, 67, 88, 0.15);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.method-icon {
  display: block;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
}

.method-icon-card { width: 36px; }

.method-label {
  flex: 1;
  font-size: 16px;
  line-height: 1.5;
  font-weight: 500;
  letter-spacing: 0.2px;
  color: var(--text-link);
}

.method-label-strong { font-weight: 600; }

.method-chevron {
  display: block;
  width: 21px;
  height: 24px;
  flex: 0 0 auto;
}

/* ---------- payment cards (receipt on the success screen) ---------- */

.pay-card {
  background: var(--background-page);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
  overflow: hidden;
}

.btn {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  border: 0;
  border-radius: var(--radius-button);
  padding: 16px;
  cursor: pointer;
}

.bg-footer {
  padding-top: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ---------- redirect overlay ---------- */

.redirect-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.96);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  font-size: 17px;
  font-weight: 500;
  z-index: 3;
}

.redirect-overlay[hidden], .swish-confirm[hidden], .bankid-phase[hidden] { display: none; }

/* ---------- Swish look-alike (payment sheet over dimmed app) ---------- */

.app-swish { background: #b2b2b2; color: var(--swish-ink); }

.swish-dim {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: calc(var(--safe-top) + 12px) 0 10px;
  min-height: 0;
}

.swish-app-logo {
  width: 132px;
  height: 132px;
  object-fit: contain;
}

.swish-sheet {
  flex: 0 0 auto;
  background: #ffffff;
  border-radius: 22px 22px 0 0;
  padding: 26px 24px calc(var(--safe-bottom) + 22px);
}

.swish-sheet-title {
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #1a1a1a;
  margin-bottom: 20px;
}

.swish-label {
  font-size: 13px;
  color: #7d848b;
  margin-bottom: 2px;
}

.swish-value {
  font-size: 24px;
  line-height: 1.25;
  color: #1a1a1a;
  margin-bottom: 18px;
}

.swish-value-sub {
  font-size: 13px;
  color: #7d848b;
  margin: -16px 0 18px;
}

.btn-swish-pay {
  position: relative;
  background: #3674c7;
  color: #fff;
  border-radius: 12px;
  padding: 15px;
  margin-top: 6px;
}

.btn-swish-pay:active { background: #2d63ab; }

.bankid-btn-mark {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 29px;
}

.btn-swish-cancel {
  background: #d0ecfa;
  color: #294c68;
  border-radius: 12px;
  padding: 15px;
  margin-top: 10px;
}

.btn-swish-cancel:active { background: #bce1f4; }

.swish-confirm {
  position: absolute;
  inset: 0;
  background: rgba(254, 254, 254, 0.97);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  font-size: 17px;
  font-weight: 500;
  z-index: 3;
}

/* ---------- BankID look-alike ---------- */

.app-bankid { background: #ffffff; color: var(--bankid-ink); }

.bankid-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(var(--safe-top) + 14px) 20px 12px;
  background: #e8e6e3;
}

.bankid-cancel { font-size: 16px; }

.bankid-topbar-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.bankid-logo { width: 30px; height: auto; display: block; }

.bankid-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 20px calc(var(--safe-bottom) + 24px);
}

.bankid-phase {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

#bankid-ask {
  align-self: stretch;
  align-items: stretch;
  text-align: left;
}

#bankid-ask .btn-bankid { margin-top: auto; }

.bankid-signer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.bankid-name {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 12px;
}

.bankid-signin-label {
  font-size: 15px;
  color: #6b7a83;
  margin-bottom: 2px;
}

.bankid-org {
  font-size: 16px;
  font-weight: 700;
}

.bankid-pen {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #d9ecf3;
  color: var(--bankid-ink);
  display: flex;
  align-items: center;
  justify-content: center;
}

.bankid-pen svg { width: 26px; height: 26px; }

.bankid-infobox {
  background: #d9ecf3;
  border-left: 4px solid #013f51;
  padding: 20px 18px;
}

.bankid-infobox-title {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 16px;
  max-width: 8em;
}

.bankid-info-row {
  display: flex;
  gap: 6px;
  font-size: 14px;
}

.bankid-info-row + .bankid-info-row { margin-top: 4px; }

.bankid-info-row span { color: #4a5f6a; }

.btn-bankid {
  background: var(--bankid-ink);
  color: #fff;
  border-radius: 0;
  font-weight: 400;
}

.faceid-glyph {
  width: 72px;
  height: 72px;
  color: var(--bankid-ink);
  margin-bottom: 18px;
  animation:
    pop-in 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    faceid-wiggle 0.7s ease-in-out 0.35s infinite;
}

@keyframes faceid-wiggle {
  0%, 100% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(-4deg) scale(1.04); }
  75% { transform: rotate(4deg) scale(1.04); }
}

.faceid-glyph svg { width: 100%; height: 100%; }

.bankid-status {
  font-size: 17px;
  font-weight: 500;
  margin-top: 20px;
}

.bankid-check {
  width: 64px;
  height: 64px;
  color: var(--bankid-blue);
  animation: pop-in 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.bankid-check svg { width: 100%; height: 100%; }

@keyframes pop-in {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ---------- success screen ---------- */

.success-page { display: flex; flex-direction: column; }

.success-hero {
  text-align: center;
  padding: 24px 4px 30px;
}

.success-check {
  width: 84px;
  height: 84px;
  margin: 0 auto 22px;
  color: var(--feedback-success-icon);
}

.success-check svg { width: 100%; height: 100%; }

.success-hero .offer-heading { color: var(--offer-heading); }

.success-hero .offer-body { margin-bottom: 0; color: var(--text-secondary); }

.pay-card.receipt { margin-bottom: 0; }

.receipt-head {
  background: var(--feedback-success-background-subtle);
  color: var(--feedback-success-text);
  font-size: 16px;
  font-weight: 700;
  padding: 14px 20px;
}

.receipt-body { padding: 6px 20px; }

.receipt-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 0;
  font-size: 16px;
}

.receipt-row + .receipt-row { border-top: 1px solid var(--border-default); }

.receipt-row span { color: var(--text-secondary); }
