/* Responsive mobile sandbox. The framed Figma reference remains in index.html and td.css. */

body[data-layout="responsive"] {
  display: block;
  min-height: 100vh;
  min-height: 100dvh;
  background: #edf2ee;
  overflow: hidden;
}

body[data-layout="responsive"] .stage {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

body[data-layout="responsive"] .device {
  position: relative;
  inset: auto;
  width: min(100%, 480px);
  height: 100vh;
  height: 100dvh;
  padding: 0;
  border-radius: 0;
  transform: none;
  background: #fff;
  box-shadow: 0 0 42px rgba(0, 30, 10, 0.16);
}

body[data-layout="responsive"] .device-screen {
  width: 100%;
  height: 100%;
  border-radius: 0;
}

/* Keep the reviewed bottom-sheet proportion while respecting native safe areas. */
body[data-layout="responsive"] .td-sheet {
  top: auto;
  bottom: max(8px, env(safe-area-inset-bottom));
  height: 79%;
  max-height: calc(
    100% - max(16px, env(safe-area-inset-top)) - max(8px, env(safe-area-inset-bottom))
  );
}

body[data-layout="responsive"] .td-sheet--password,
body[data-layout="responsive"] .td-sheet--username,
body[data-layout="responsive"] .td-sheet--credentials {
  height: 77%;
}

body[data-layout="responsive"] .td-sheet-content {
  overscroll-behavior: contain;
}

body[data-layout="responsive"] .app-status {
  padding-top: env(safe-area-inset-top);
  height: calc(47px + env(safe-area-inset-top));
}

body[data-layout="responsive"] .device-screen[data-sheet="true"] .app-status {
  height: calc(66px + env(safe-area-inset-top));
}

body[data-layout="responsive"] .td-sticky {
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}

/* Keep every form screen and its actions in one scrollable flow when the native keyboard or a
   short viewport reduces the available height. Footer actions never overlay screen content. */
body[data-layout="responsive"] .td-screen-flow {
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scroll-padding-bottom: max(20px, env(safe-area-inset-bottom));
}

body[data-layout="responsive"] .td-screen-flow > .td-content {
  flex: 0 0 auto;
  min-height: calc(100% - 83px);
}

body[data-layout="responsive"] .td-screen-flow:has(> .td-sticky > .td-btn + .td-btn) > .td-content {
  min-height: calc(100% - 145px);
}

body[data-layout="responsive"] .td-screen-flow > .td-sticky {
  margin-top: 0;
}

body[data-layout="responsive"] .cpb-panel {
  padding-bottom: env(safe-area-inset-bottom);
}

body[data-layout="responsive"] .cpb-keyboard {
  display: none !important;
}

/* The responsive page uses the phone's keyboard; these simulated-keyboard states are unreachable. */
body[data-layout="responsive"] .cpb[data-keyboard="open"] .cpb-panel {
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--cpb-dock);
  max-height: none;
  border-radius: 18px 18px 0 0;
}

@media (min-width: 601px) {
  body[data-layout="responsive"] .stage {
    padding: 18px;
  }

  body[data-layout="responsive"] .device {
    height: calc(100vh - 36px);
    height: calc(100dvh - 36px);
    border-radius: 24px;
    overflow: hidden;
  }

  body[data-layout="responsive"] .device-screen {
    border-radius: 24px;
  }
}

/* Preserve the reference composition while tightening its measured gaps on shorter phones. */
@media (max-height: 760px) and (orientation: portrait) {
  body[data-layout="responsive"] .td-signin-body {
    min-height: 100%;
    padding-top: 12px;
  }

  body[data-layout="responsive"] .td-signin-greeting {
    margin-top: 12px;
  }

  body[data-layout="responsive"] .td-signin-form {
    margin-top: 22px;
  }

  body[data-layout="responsive"] .td-screen-signin .td-field + .td-field {
    margin-top: 14px;
  }

  body[data-layout="responsive"] .td-signin-forgot,
  body[data-layout="responsive"] .td-signin-remember,
  body[data-layout="responsive"] .td-screen-signin .td-btn-primary,
  body[data-layout="responsive"] .td-signin-promo {
    margin-top: 18px;
  }

  body[data-layout="responsive"] .td-signin-icons {
    margin-top: 30px;
  }
}

@media (max-height: 760px) {
  body[data-layout="responsive"] .td-sheet-content {
    margin-top: 8px;
    padding-bottom: 16px;
  }

  body[data-layout="responsive"] .td-sheet-content h3 {
    margin-top: 20px;
    margin-bottom: 12px;
  }

  body[data-layout="responsive"] .td-sheet-card {
    margin-top: 12px;
    margin-bottom: 12px;
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  body[data-layout="responsive"] .device {
    width: 100%;
  }

  body[data-layout="responsive"] .app-status {
    display: none;
  }

  body[data-layout="responsive"] .td-content {
    padding-top: 24px;
  }

  body[data-layout="responsive"] .cpb {
    --cpb-dock: 100%;
    --cpb-tall: 100%;
  }

  body[data-layout="responsive"] .td-sheet {
    height: calc(
      100% - max(8px, env(safe-area-inset-top)) - max(8px, env(safe-area-inset-bottom))
    );
  }

  body[data-layout="responsive"] .td-sheet--password,
  body[data-layout="responsive"] .td-sheet--username,
  body[data-layout="responsive"] .td-sheet--credentials {
    height: calc(
      100% - max(8px, env(safe-area-inset-top)) - max(8px, env(safe-area-inset-bottom))
    );
  }

  /* Variant classes keep the different Figma pull-ups stable without positional selectors. */
  body[data-layout="responsive"] .td-sheet-content {
    padding: 0 16px 8px;
  }

  body[data-layout="responsive"] .td-sheet-content--information,
  body[data-layout="responsive"] .td-sheet-content--with-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(112px, 140px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
  }

  body[data-layout="responsive"] .td-sheet--card .td-sheet-content--information {
    grid-template-columns: minmax(0, 1fr) minmax(112px, 140px);
  }

  body[data-layout="responsive"] .td-sheet-content--password {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 32px;
    align-items: start;
  }

  body[data-layout="responsive"] .td-sheet-section--username,
  body[data-layout="responsive"] .td-sheet-section--intro {
    grid-column: 1;
  }

  body[data-layout="responsive"] .td-sheet-card {
    grid-column: 2;
    width: min(100%, 140px);
    align-self: center;
  }

  body[data-layout="responsive"] .td-sheet-reminder {
    grid-column: 2;
  }

  body[data-layout="responsive"] .td-sheet-section--assistant {
    grid-column: 3;
  }

  body[data-layout="responsive"] .td-sheet-content--password .td-sheet-section--assistant {
    grid-column: 2;
    margin-top: 0;
  }

  body[data-layout="responsive"] .td-sheet-content p,
  body[data-layout="responsive"] .td-sheet-card {
    margin: 0;
  }

  body[data-layout="responsive"] .td-sheet-content p {
    font-size: 14px;
    line-height: 18px;
  }

  body[data-layout="responsive"] .td-sheet-content h3 {
    margin: 0;
    font-size: 18px;
    line-height: 22px;
  }

  body[data-layout="responsive"] .td-sheet-content--information .td-sheet-section--username p + p {
    margin-top: 12px;
  }

  body[data-layout="responsive"] .td-assist-mode {
    margin-left: 0;
    margin-right: 0;
  }

  body[data-layout="responsive"] .td-assist-mode legend {
    font-size: 14px;
    line-height: 18px;
  }

  body[data-layout="responsive"] .td-assist-mode-actions {
    gap: 8px;
  }
}
