/* CPGCBL EMD R11.6.8 - Embedded Register/Reset actions MUST remain accessible.
   The iframe is height-limited by the parent dialog. Previous overflow:hidden on
   the embedded HTML clipped Confirm Password, Turnstile and Submit entirely.
   This patch changes only presentation: registration/authentication APIs are untouched. */

/* Parent context (index.html): allow more of the form to show without enlarging
   the dialog beyond the viewport. The child still scrolls when necessary. */
#r1051AuthDialog .r1051-auth-frame {
  height: min(540px, calc(100dvh - 193px));
  max-height: calc(100dvh - 193px) !important;
  transition: none !important;
}
@media (max-width: 540px) {
  #r1051AuthDialog .r1051-auth-frame {
    height: min(540px, calc(100dvh - 157px));
    max-height: calc(100dvh - 157px) !important;
  }
}
@media (max-height: 600px) {
  #r1051AuthDialog .r1051-auth-frame {
    height: min(540px, calc(100dvh - 130px));
    max-height: calc(100dvh - 130px) !important;
  }
}

/* Child context (/login?embed=1): unlike direct /login, an embedded page must
   scroll INSIDE the iframe. Keep a scrollbar, stable width and keyboard access. */
html[data-emd-embed="1"] {
  height: 100%;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior-y: contain;
  scrollbar-width: thin;
  scrollbar-gutter: stable;
}
html[data-emd-embed="1"] body {
  height: auto;
  min-height: 100%;
  overflow-y: visible !important;
  overflow-x: hidden !important;
}
html[data-emd-embed="1"] .auth-shell,
html[data-emd-embed="1"] .auth-panel {
  overflow: visible;
}

/* Registration and password-reset flows contain extra form fields. The call to
   action stays visible while the fields, notes and security challenge can scroll.
   The button REMAINS in the native form, so pressing it uses the existing
   validation, anti-bot and API code unchanged. */
html[data-emd-embed="1"][data-auth-view="signup"] .auth-panel,
html[data-emd-embed="1"][data-auth-view="reset"] .auth-panel {
  padding-bottom: 100px !important;
}
html[data-emd-embed="1"][data-auth-view="signup"] #authSubmit,
html[data-emd-embed="1"][data-auth-view="reset"] #authSubmit {
  position: fixed;
  z-index: 20;
  left: 16px;
  right: 16px;
  bottom: max(10px, env(safe-area-inset-bottom));
  width: auto;
  margin: 0;
  min-height: 45px;
  box-shadow: 0 0 0 9px #fff, 0 6px 19px #0f536638;
}
html[data-emd-embed="1"] #authSubmit:focus-visible {
  outline-offset: 3px;
}
@media(max-width:540px) {
  html[data-emd-embed="1"][data-auth-view="signup"] #authSubmit,
  html[data-emd-embed="1"][data-auth-view="reset"] #authSubmit {
    left: 12px;right: 12px;bottom: max(9px,env(safe-area-inset-bottom));
  }
}
