/* 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;
}

/*
 * Size login help to its content instead of a fixed Figma ratio. The safe viewport is only a
 * ceiling for unusually short screens; ordinary phones keep the banking page visible behind it.
 */
body[data-layout="responsive"] .td-sheet {
  top: auto;
  bottom: max(8px, env(safe-area-inset-bottom));
  height: auto;
  max-height: calc(
    100% - max(16px, env(safe-area-inset-top)) - max(8px, env(safe-area-inset-bottom))
  );
}

body[data-layout="responsive"] .td-sheet-content {
  flex: 0 1 auto;
  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));
}

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;
}

body[data-layout="responsive"] .sandbox-drawer {
  position: fixed;
  z-index: 90;
  top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
  max-width: min(420px, calc(100vw - 16px));
  color: #fff;
  font-family: var(--td-font);
}

body[data-layout="responsive"] .sandbox-drawer > summary {
  display: block;
  width: max-content;
  margin-left: auto;
  padding: 7px 11px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(21, 24, 27, 0.9);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

body[data-layout="responsive"] .sandbox-drawer > summary::-webkit-details-marker {
  display: none;
}

body[data-layout="responsive"] .sandbox-drawer[open] > summary {
  border-radius: 8px 8px 0 0;
}

body[data-layout="responsive"] .demo-bar {
  max-height: min(62vh, 440px);
  padding: 12px;
  overflow: auto;
  border-radius: 8px 0 8px 8px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.28);
}

body[data-layout="responsive"] .demo-bar [data-live-status],
body[data-layout="responsive"] .demo-bar-voice {
  margin-left: 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 {
    width: min(44%, 180px);
    margin-top: 12px;
    margin-bottom: 12px;
  }

  body[data-layout="responsive"] .td-sheet-link {
    margin-top: 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: 48%;
    --cpb-tall: 92%;
  }

  /* Two compact columns keep every login-help item visible without a nested landscape scroll. */
  body[data-layout="responsive"] .td-sheet-content {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(112px, 140px) minmax(0, 1fr);
    grid-template-rows: repeat(4, auto);
    gap: 4px 18px;
    padding: 0 16px 4px;
  }

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

  body[data-layout="responsive"] .td-sheet-content p,
  body[data-layout="responsive"] .td-sheet-link {
    font-size: 16px;
    line-height: 20px;
  }

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

  body[data-layout="responsive"] .td-sheet-content > p:nth-of-type(1) {
    grid-column: 1 / -1;
  }

  body[data-layout="responsive"] .td-sheet-content > h3:nth-of-type(1) {
    grid-column: 1;
    grid-row: 2;
  }

  body[data-layout="responsive"] .td-sheet-content > p:nth-of-type(2) {
    grid-column: 1;
    grid-row: 3;
  }

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

  body[data-layout="responsive"] .td-sheet-content > p:nth-of-type(3) {
    grid-column: 2;
    grid-row: 4;
  }

  body[data-layout="responsive"] .td-sheet-content > h3:nth-of-type(2) {
    grid-column: 3;
    grid-row: 2;
  }

  body[data-layout="responsive"] .td-sheet-content > p:nth-of-type(4) {
    grid-column: 3;
    grid-row: 3;
  }

  body[data-layout="responsive"] .td-sheet-link {
    grid-column: 3;
    grid-row: 4;
    align-self: start;
  }
}
