/* Welcome carousel, set-up and unlock (welcome.js, security.js).
   Apple Human Interface Guidelines patterns on FinTraka's brand tokens (styles.css :root): large titles,
   readable body text, 50 pt full-width primary buttons, a passcode keypad with targets of at least 44 pt,
   safe-area insets (notch, Dynamic Island, home indicator), dynamic viewport units, dark mode and
   reduced motion. Sizes are in rem so they follow the user's text size. */

.ob-screen {
  --ob-bg: var(--color-bg, #F4FAF7);
  --ob-surface: var(--color-surface, #FFFFFF);
  --ob-text: var(--color-dark, #111C18);
  --ob-muted: var(--color-grey, #5A7A6E);
  --ob-line: var(--color-line, #DCE7E1);
  --ob-brand: var(--color-brand, #0B3F32);
  --ob-on-brand: var(--color-on-brand, #FFFFFF);
  --ob-accent: var(--color-mint, #22C97A);
  --ob-accent-soft: var(--color-mint-soft, #E2F6EC);
  --ob-danger: var(--color-danger, #B42318);
  --ob-key: #FFFFFF;
  --ob-key-pressed: #E3ECE7;
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(12px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  background: var(--ob-bg);
  color: var(--ob-text);
  font-family: var(--font-body);
  overflow-y: auto;
  -webkit-text-size-adjust: 100%;
}
#welcome.ob-screen { z-index: 10001; }
.ob-screen[hidden] { display: none; }
@media (prefers-color-scheme: dark) {
  .ob-screen {
    --ob-bg: #0B1612;
    --ob-surface: #13221C;
    --ob-text: #EAF3EE;
    --ob-muted: #9DB5AA;
    --ob-line: #22362D;
    --ob-brand: #22C97A;
    --ob-on-brand: #06231A;
    --ob-accent-soft: #123A2A;
    --ob-danger: #FF8A80;
    --ob-key: #1B2E26;
    --ob-key-pressed: #274036;
  }
}

/* Layout: content centred in a readable column, actions pinned to the bottom (thumb reach). */
.ob-screen > *, .ob-form > * { width: 100%; max-width: 30rem; margin-inline: auto; }
.ob-form { display: flex; flex-direction: column; flex: 1; }
.ob-top { flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.ob-content { flex: 1; display: flex; flex-direction: column; justify-content: center; padding-block: 1.5rem; }
.ob-content-pin { align-items: center; text-align: center; }
/* Text fields sit high, so the on-screen keyboard never covers them. */
.ob-form .ob-content { justify-content: flex-start; padding-top: clamp(1.5rem, 8vh, 4rem); }
.ob-bottom { display: flex; flex-direction: column; gap: 0.75rem; padding-top: 0.5rem; }
.ob-bottom-pad { align-items: center; }

/* Typography: Large Title / Body / Footnote. */
.ob-title { font-family: var(--font-display); font-weight: 800; font-size: clamp(1.75rem, 1.4rem + 1.6vw, 2.125rem); line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 0.6rem; }
.ob-body { font-size: 1.0625rem; line-height: 1.45; color: var(--ob-muted); margin: 0 0 1.5rem; }
.ob-step, .ob-help, .ob-fine { font-size: 0.8125rem; line-height: 1.4; color: var(--ob-muted); }
.ob-fine { text-align: center; margin: 0.5rem 0 0; max-width: 24rem; }
.ob-message { min-height: 1.4em; margin: 0.75rem 0 0; color: var(--ob-danger); font-size: 0.9375rem; text-align: inherit; }
.ob-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Buttons. */
.ob-primary {
  min-height: 50px; width: 100%; border: 0; border-radius: 14px;
  background: var(--ob-brand); color: var(--ob-on-brand);
  font: 600 1.0625rem/1.2 var(--font-body); cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease;
}
.ob-primary:active { transform: scale(0.98); opacity: 0.9; }
.ob-primary:disabled { opacity: 0.45; }
.ob-text-button { min-height: 44px; min-width: 44px; padding: 0 4px; border: 0; background: none; color: var(--ob-brand); font: 600 1.0625rem var(--font-body); cursor: pointer; }
.ob-back { display: inline-flex; align-items: center; gap: 2px; margin-left: -4px; }
.ob-back span { font-size: 1.75rem; line-height: 1; margin-top: -3px; }
.ob-primary:focus-visible, .ob-text-button:focus-visible, .ob-key:focus-visible, .ob-dot:focus-visible, .ob-input:focus-visible {
  outline: 3px solid var(--ob-accent); outline-offset: 3px;
}

/* Progress (set-up). */
.ob-progress { flex-shrink: 0; height: 4px; border-radius: 2px; background: var(--ob-line); overflow: hidden; margin-top: 0.25rem; }
.ob-progress span { display: block; height: 100%; background: var(--ob-brand); border-radius: 2px; transition: width 300ms ease; }

/* Fields: grouped, 50 pt tall, large text. */
.ob-label { font-weight: 600; font-size: 0.9375rem; margin: 0 0 0.4rem; }
.ob-input {
  width: 100%; min-height: 52px; padding: 0 1rem; border: 1.5px solid var(--ob-line); border-radius: 14px;
  background: var(--ob-surface); color: var(--ob-text); font: 400 1.1875rem var(--font-body);
}
.ob-input::placeholder { color: var(--ob-muted); opacity: 0.7; }
.ob-input:focus { border-color: var(--ob-brand); outline: none; }
.ob-phone { display: flex; align-items: stretch; gap: 0.5rem; }
.ob-country {
  display: inline-flex; align-items: center; padding: 0 0.9rem; border-radius: 14px; white-space: nowrap;
  background: var(--ob-accent-soft); color: var(--ob-text); font: 600 1.0625rem var(--font-body);
}
.ob-phone .ob-input { flex: 1; min-width: 0; letter-spacing: 0.02em; }
.ob-help { margin: 0.5rem 0 0; }

/* Passcode: dots and keypad (iPhone passcode screen proportions). */
.ob-avatar {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 1rem;
  background: var(--ob-brand); color: var(--ob-on-brand); font: 800 1.6rem var(--font-display);
}
.ob-pin-dots { display: flex; gap: 18px; justify-content: center; margin: 0.5rem 0 0; }
.ob-pin-dot { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--ob-brand); transition: background-color 120ms ease, transform 120ms ease; }
.ob-pin-dot.is-filled { background: var(--ob-brand); transform: scale(1.05); }
.ob-keypad { display: grid; grid-template-columns: repeat(3, minmax(64px, 78px)); gap: 14px 26px; justify-content: center; margin-top: 0.5rem; }
.ob-key {
  aspect-ratio: 1; width: 100%; min-width: 64px; border-radius: 50%; border: 0;
  background: var(--ob-key); color: var(--ob-text); box-shadow: 0 1px 2px rgba(11, 63, 50, 0.12);
  font: 500 1.75rem var(--font-display); cursor: pointer; transition: background-color 80ms ease;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.ob-key:active { background: var(--ob-key-pressed); }
.ob-key-quiet { background: transparent; box-shadow: none; color: var(--ob-text); }
.ob-key-icon { width: 28px; height: 28px; }
.ob-key-spacer { display: block; }
.ob-shake { animation: ob-shake 420ms ease; }
@keyframes ob-shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }

/* Welcome carousel. */
.ob-track {
  flex: 1; display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory;
  scrollbar-width: none; overscroll-behavior-x: contain; outline: none;
  /* Edge to edge: the slides swipe under the screen's side padding. */
  width: auto; max-width: none; margin-inline: calc(-1 * max(20px, env(safe-area-inset-left))) calc(-1 * max(20px, env(safe-area-inset-right)));
}
.ob-screen:focus { outline: none; }
.ob-track::-webkit-scrollbar { display: none; }
.ob-slide {
  flex: 0 0 100%; scroll-snap-align: center; scroll-snap-stop: always;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 1rem max(20px, env(safe-area-inset-left));
}
.ob-slide .ob-title, .ob-slide .ob-body { max-width: 22rem; }
.ob-art-wrap { width: min(78vw, 320px); aspect-ratio: 14 / 11; margin-bottom: 2rem; border-radius: 28px; background: var(--ob-accent-soft); display: grid; place-items: center; }
.ob-art { width: 88%; height: auto; overflow: visible; }
.ob-dots { display: flex; justify-content: center; gap: 2px; }
.ob-dot { width: 44px; height: 28px; border: 0; background: none; cursor: pointer; display: grid; place-items: center; }
.ob-dot::after { content: ''; width: 8px; height: 8px; border-radius: 4px; background: var(--ob-line); transition: width 200ms ease, background-color 200ms ease; }
.ob-dot[aria-current="true"]::after { width: 22px; background: var(--ob-brand); }

/* Illustration colours. */
.ob-art-device { fill: var(--ob-surface); stroke: var(--ob-line); stroke-width: 2; }
.ob-art-card { fill: var(--ob-surface); stroke: var(--ob-line); stroke-width: 1.5; }
.ob-art-bubble { fill: var(--ob-surface); stroke: var(--ob-line); stroke-width: 1.5; }
.ob-art-chip { fill: var(--ob-surface); stroke: var(--ob-brand); stroke-width: 1.5; }
.ob-art-brand { fill: var(--ob-brand); }
.ob-art-accent { fill: var(--ob-accent); }
.ob-art-tap { fill: var(--ob-accent); opacity: 0.25; }
.ob-art-tap-dot { fill: var(--ob-accent); stroke: var(--ob-surface); stroke-width: 3; }
.ob-art-line { fill: var(--ob-line); }
.ob-art-line-strong { fill: var(--ob-muted); opacity: 0.6; }
.ob-art-arrow { fill: none; stroke: var(--ob-accent); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.ob-art-sign { fill: none; stroke: var(--ob-text); stroke-width: 2.5; stroke-linecap: round; }
.ob-art-check { fill: none; stroke: var(--ob-on-brand); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.ob-art-text { fill: var(--ob-text); font: 600 13px var(--font-body); }
.ob-art-small { fill: var(--ob-muted); font: 500 11px var(--font-body); }
.ob-art-money { fill: var(--ob-text); font: 700 13px var(--font-body); font-variant-numeric: tabular-nums; }
.ob-art-on-brand { fill: var(--ob-on-brand); font: 600 14px var(--font-body); }
.ob-art-moni { fill: var(--ob-on-brand); font: 700 16px var(--font-body); }

/* Short screens (iPhone SE, landscape phones, iPad split view): tighten so the PIN step fits
   without scrolling. Keys stay at least 58 pt, above the 44 pt minimum. */
@media (max-height: 720px) {
  .ob-keypad { gap: 8px 22px; grid-template-columns: repeat(3, 62px); margin-top: 0; }
  .ob-key { min-width: 62px; font-size: 1.5rem; }
  .ob-content { padding-block: 0.5rem; }
  .ob-content-pin .ob-title { font-size: 1.5rem; }
  .ob-content-pin .ob-body { font-size: 0.9375rem; margin-bottom: 0.75rem; }
  .ob-content-pin .ob-message { margin-top: 0.4rem; }
  .ob-avatar { width: 52px; height: 52px; margin-bottom: 0.5rem; font-size: 1.3rem; }
  .ob-fine { font-size: 0.75rem; margin-top: 0.25rem; }
  .ob-art-wrap { margin-bottom: 1.25rem; }
}
@media (max-height: 600px) {
  .ob-keypad { gap: 6px 18px; grid-template-columns: repeat(3, 58px); }
  .ob-key { min-width: 58px; }
  .ob-art-wrap { width: min(50vw, 220px); margin-bottom: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .ob-shake { animation: none; }
  .ob-primary, .ob-pin-dot, .ob-dot::after, .ob-progress span { transition: none; }
  .ob-track { scroll-behavior: auto; }
}
