/* ============ Base ============ */
:root {
  --hp: #10b981;
  --hp-dark: #065f46;
  --ink: #111827;
  --ink-2: #1f2937;
  --muted: #475569;
  --line: #cbd5e1;
  --bg: #ecfdf5;
  --card: #ffffff;
  --card-line: #d1fae5;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body{
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background-color: var(--bg);

  /* Use dynamic viewport units so the URL bar doesn't throw off centering */
  min-height: 100vh;   /* fallback */
  min-height: 100svh;  /* iOS/modern */
  min-height: 100dvh;  /* Chrome/Android */

  /* Grid makes perfect centering simple */
  display: grid;
  place-items: center;

  padding: 20px;
  -webkit-tap-highlight-color: transparent;

  /* iOS safe-area padding */
  padding-top: max(20px, env(safe-area-inset-top));
  padding-right: max(20px, env(safe-area-inset-right));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  padding-left: max(20px, env(safe-area-inset-left));
}

/* ============ Card ============ */
.signin-container {
  background-color: var(--card);
  border: 1px solid var(--card-line);
  border-radius: 16px;
  padding: 40px 30px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);

  /* prevent overflow on short viewports / mobile keyboards */
  max-height: calc(100vh - 40px);   /* fallback */
  max-height: calc(100svh - 40px);  /* iOS/modern */
  max-height: calc(100dvh - 40px);  /* Chrome/Android */
  overflow: auto;
}

/* ============ Headings & Text ============ */
h2 {
  color: var(--hp-dark);
  font-size: 26px;
  margin-bottom: 6px;
  text-align: center;
}

.subtitle {
  color: var(--muted);
  font-size: 15px;
  margin-bottom: 30px;
  text-align: center;
}

/* ============ Inputs ============ */
input[type="tel"] {
  display: block;
  width: 100%;
  padding: 14px;
  margin: 0 auto 20px auto;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 15px;
  background-color: #fff;
  color: var(--ink-2);
}

input::placeholder { color: #94a3b8; }

/* Focus ring (keyboard/a11y) */
input[type="tel"],
#codeInputs input.digit,
.signin-button { outline: none; }

input[type="tel"]:focus-visible,
#codeInputs input.digit:focus-visible,
.signin-button:focus-visible {
  box-shadow: 0 0 0 3px rgba(16, 185, 129, .35);
  border-color: var(--hp);
}

/* ============ reCAPTCHA ============ */
#recaptcha-container { margin: 10px 0 20px; }

/* ============ Buttons ============ */
.signin-button {
  width: 100%;
  padding: 14px;
  background-color: var(--hp);
  border: none;
  border-radius: 10px;
  color: white;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 20px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: filter .15s ease;
}

.signin-button:hover { filter: brightness(0.98); }
.signin-button:active { filter: brightness(0.95); }
.signin-button[disabled] { opacity: .6; cursor: not-allowed; }

/* Secondary/outline (Continue as Guest) */
.signin-button.outline {
  background: transparent;
  border: 1px solid var(--line);
  color: #111;
}
.signin-button.outline:hover { background: #f8fafc; }
.signin-button.outline:active { background: #f1f5f9; }
.signin-button.outline[disabled]{ opacity:.6; cursor:not-allowed; }

/* Spinner inside button */
.signin-button .spinner {
  display: none; width: 16px; height: 16px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .8s linear infinite;
}
.signin-button.is-loading .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Links ============ */
.switch-auth {
  font-size: 14px;
  color: var(--muted);
  text-align: center;
}
.switch-auth a {
  color: var(--hp);
  font-weight: 700;
  text-decoration: underline;
  margin-left: 5px;
}

/* ============ Code Step ============ */
#codeSection { display: none; }

#codeInputs {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 30px 0 24px;
  flex-wrap: wrap;
  position: relative;
}

#codeInputs input.digit {
  width: 52px;
  height: 60px;
  font-size: 24px;
  text-align: center;
  border-radius: 8px;
  border: 2px solid #ccc;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  letter-spacing: .05em;
}

#codeInputs input.digit:focus { border-color: var(--hp); }

/* ============ Toast ============ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--hp);
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.2);
  font-size: 14px;
  opacity: 0;
  z-index: 10000;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.toast.show { opacity: 1; }

/* ============ Responsive ============ */
@media (max-width: 1024px) {
  body { padding: 16px; }

  .signin-container {
    padding: 32px 24px;
    border-radius: 14px;
    max-width: 420px;
  }

  h2 { font-size: 24px; }
  .subtitle { font-size: 14px; margin-bottom: 24px; }

  input[type="tel"] {
    padding: 12px;
    font-size: 14px;
    margin-bottom: 18px;
  }

  #recaptcha-container { margin: 8px 0 18px; }

  .signin-button {
    padding: 13px;
    font-size: 15px;
    border-radius: 9px;
  }

  .switch-auth { font-size: 13.5px; }

  #codeInputs input.digit {
    width: 48px;
    height: 56px;
    font-size: 22px;
  }

  .toast { font-size: 13.5px; padding: 10px 18px; }
}

@media (max-width: 480px) {
  body {
    padding: 12px;
    flex-direction: column;
    align-items: stretch;
  }

  .signin-container {
    padding: 24px 16px;
    border-radius: 12px;
    max-width: 90%;
  }

  h2 { font-size: 20px; margin-bottom: 5px; }
  .subtitle { font-size: 13.5px; margin-bottom: 20px; }

  input[type="tel"] {
    padding: 11px;
    font-size: 13.5px;
    margin-bottom: 16px;
    border-radius: 7px;
  }

  #recaptcha-container { margin: 6px 0 16px; }

  .signin-button {
    padding: 12px;
    font-size: 14px;
    border-radius: 8px;
  }

  .switch-auth { font-size: 13px; }

  #codeInputs {
    gap: 10px;
    margin: 24px 0 20px;
  }

  /* Thumb-friendly code boxes */
  #codeInputs input.digit {
    width: 40px;   /* bigger for touch */
    height: 48px;
    font-size: 20px;
  }

  .toast {
    font-size: 13px;
    padding: 10px 16px;
    bottom: 16px;
  }
}

/* ============ Preferences ============ */
@media (prefers-reduced-motion: reduce) {
  .signin-button .spinner { animation: none; }
  * { scroll-behavior: auto; }
}

/* ============ Dark Mode ============ */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1620;
    --card: #0f1c28;
    --card-line: #12212c;
    --ink-2: #e5e7eb;
    --muted: #94a3b8;
    --line: #334155;
  }

  body { background-color: var(--bg); color: var(--ink-2); }
  .signin-container { background: var(--card); border-color: var(--card-line); box-shadow: none; }
  h2 { color: #d1fae5; }
  .subtitle { color: var(--muted); }

  input[type="tel"] {
    background: #0b1620;
    border-color: var(--line);
    color: var(--ink-2);
  }
  input::placeholder { color: #64748b; }

  .signin-button { background: var(--hp); color: #052e2b; }
  .signin-button.outline { border-color: var(--line); color: var(--ink-2); }

  #codeInputs input.digit {
    background: #0b1620;
    border-color: var(--line);
    color: var(--ink-2);
  }

  .toast { background: var(--hp-dark); }
}


/* ---- IFRAME NO-SCROLL OVERRIDES (keep last) ---- */
html, body {
  height: auto !important;     /* don't force a viewport height */
}

body {
  min-height: auto !important; /* remove 100vh/svh/dvh */
  display: block !important;   /* don't use grid centering here */
  padding: 20px;               /* keep your existing spacing */
  overflow: hidden;            /* never show inner scrollbar */
}

.signin-container {
  max-height: none !important; /* remove the viewport-based cap */
  overflow: visible !important;
  margin: 24px auto !important;
}

@media (max-width: 480px) {
  .signin-container { margin: 16px auto !important; }
}

