/* Web layout only. The app bundle, authentication and payment logic are unchanged. */
:root {
  --walletii-page-gutter: clamp(16px, 4.8vw, 24px);
}

#root > div,
#root > div > div {
  min-height: 0;
  min-width: 0;
}

#root input,
#root textarea,
#root select {
  min-width: 0;
}

[data-testid="phone-login-screen"] input,
[data-testid="otp-screen"] input {
  font-size: 16px !important;
}

/* Phone/OTP use RN SafeAreaView outside a frame that already owns the insets.
   Keep the frame's insets and remove the duplicate outer inset only here. */
#root[data-walletii-auth="phone-login-screen"] > div,
#root[data-walletii-auth="otp-screen"] > div {
  padding: 0 !important;
}

[data-testid="phone-login-screen"],
[data-testid="otp-screen"],
[data-testid="faceid-screen"],
[data-testid="returning-login"] {
  min-width: 0;
  min-height: 0;
  max-height: 100%;
}

[data-testid="phone-login-screen"] {
  flex: 1 1 0% !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  scroll-padding-block: 16px;
}

/* ScrollView has one content container; its three children are the language
   row, phone form, and actions. No RN generated class names are relied on. */
[data-testid="phone-login-screen"] > div {
  box-sizing: border-box;
  min-height: 100%;
  flex-grow: 1;
  padding-top: clamp(10px, 1.8dvh, 18px) !important;
  padding-bottom: 16px !important;
  gap: clamp(8px, 1.5dvh, 16px);
}

[data-testid="phone-login-screen"] > div > :first-child {
  padding-inline: var(--walletii-page-gutter) !important;
  flex-shrink: 0;
}

[data-testid="phone-login-screen"] > div > :nth-child(2) {
  flex: 1 0 auto !important;
  padding-block: clamp(12px, 2.5dvh, 24px) !important;
  min-width: 0;
}

[data-testid="phone-login-screen"] > div > :nth-child(2) > :nth-child(2) {
  margin-top: 16px !important;
  font-size: clamp(25px, 7vw, 29px) !important;
}

[data-testid="phone-login-screen"] > div > :nth-child(2) > :nth-child(3) {
  margin-top: 20px !important;
  margin-bottom: 12px !important;
}

[data-testid="phone-login-screen"] > div > :nth-child(2) > :last-child {
  margin-inline: var(--walletii-page-gutter) !important;
  gap: 9px;
  min-width: 0;
}

[data-testid="phone-login-screen"] > div > :nth-child(2) > :last-child > :first-child {
  width: clamp(72px, 22vw, 93px) !important;
  flex: 0 0 auto;
  height: 56px !important;
}

[data-testid="phone-login-screen"] input {
  height: 56px !important;
  min-width: 0 !important;
  padding-inline: clamp(12px, 3.6vw, 18px) !important;
}

[data-testid="phone-login-screen"] > div > :last-child {
  flex-shrink: 0;
  margin-inline: var(--walletii-page-gutter) !important;
  gap: 2px !important;
}

[data-testid="phone-login-screen"] > div > :last-child > [role="button"] {
  min-height: 44px !important;
  padding-block: 8px !important;
}

[data-testid="phone-login-screen"] > div > :last-child > :first-child {
  height: 56px !important;
  min-height: 56px !important;
}

/* OTP remains a single scrolling form; all six boxes stay within the width. */
[data-testid="otp-screen"] > :first-child {
  min-height: 0;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior-y: contain;
}

[data-testid="otp-screen"] > :first-child > div > :last-child {
  margin-top: clamp(24px, 6dvh, 64px) !important;
  padding-inline: var(--walletii-page-gutter) !important;
  min-width: 0;
}

[data-testid="otp-boxes"] {
  min-width: 0;
  gap: clamp(4px, 1.8vw, 8px) !important;
}

[data-testid="otp-boxes"] > div {
  min-width: 0;
}

/* The installed-app viewport shrinks above the keyboard; the inner form can
   scroll without moving the document or adding a second safe-area padding. */
html[data-walletii-keyboard="open"] #root[data-walletii-auth="phone-login-screen"] > div > div,
html[data-walletii-keyboard="open"] #root[data-walletii-auth="otp-screen"] > div > div {
  padding-bottom: 0 !important;
}

@media (max-height: 680px) {
  [data-testid="phone-login-screen"] > div > :nth-child(2) {
    padding-block: 12px !important;
  }
  [data-testid="phone-login-screen"] > div > :nth-child(2) > :nth-child(2) {
    margin-top: 12px !important;
  }
  [data-testid="phone-login-screen"] > div > :nth-child(2) > :nth-child(3) {
    margin-top: 14px !important;
  }
}

@supports not (height: 100dvh) {
  [data-testid="phone-login-screen"] > div { padding-top: 12px !important; gap: 10px; }
  [data-testid="phone-login-screen"] > div > :nth-child(2) { padding-block: 16px !important; }
  [data-testid="otp-screen"] > :first-child > div > :last-child { margin-top: 24px !important; }
}
