/* Content-sized mobile layouts for migrated exchange sections.
   Keep this stylesheet after page-specific layout styles in the final bundle. */

/* Store artwork must remain complete when the desktop tracks become narrower. */
#zdBQW_ :is(#zf6wMV, #zK3930) .image__image { object-fit: contain; }

@media (max-width: 1024px) {
  /* Registration and copying shared a Builder grid row in review heroes.
     A content-sized column gives each control its own row in every language. */
  :is(#ai-Q84kas, #z2agGR, #zlayw3, #zengiW, #zBxWdS) > .block-layout {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: min(100%, 640px);
    max-width: 640px;
    height: auto;
    min-height: 0;
    padding: 28px 20px 32px;
  }

  :is(#ai-Q84kas, #z2agGR, #zlayw3, #zengiW, #zBxWdS) > .block-layout > .layout-element {
    grid-area: auto;
    align-self: stretch;
    width: 100%;
    min-width: 0;
    height: auto;
    min-height: 0;
    margin: 0;
  }

  :is(#ai-Q84kas, #z2agGR, #zlayw3, #zengiW, #zBxWdS) > .block-layout > :nth-child(1) { order: 1; }
  :is(#ai-Q84kas, #z2agGR, #zlayw3, #zengiW, #zBxWdS) > .block-layout > :nth-child(2) { order: 2; }
  :is(#ai-Q84kas, #z2agGR, #zlayw3, #zengiW, #zBxWdS) > .block-layout > :nth-child(3) {
    order: 3;
    align-self: center;
    width: min(100%, 360px);
  }
  :is(#ai-Q84kas, #z2agGR, #zlayw3, #zengiW, #zBxWdS) > .block-layout > :nth-child(4) { order: 5; }
  :is(#ai-Q84kas, #z2agGR, #zlayw3, #zengiW, #zBxWdS) > .block-layout > :nth-child(5) { order: 6; }
  :is(#ai-Q84kas, #z2agGR, #zlayw3, #zengiW, #zBxWdS) > .block-layout > :nth-child(6) { order: 4; }

  :is(#ai-Q84kas, #z2agGR, #zlayw3, #zengiW, #zBxWdS) > .block-layout > .layout-element > a.grid-button {
    box-sizing: border-box;
    width: 100%;
    height: auto;
    min-height: 48px;
    padding: 12px 18px;
    line-height: 1.35;
    white-space: normal;
    overflow-wrap: break-word;
    text-align: center;
  }

  /* Imported layouts assign each image an increasing z-index. Use local layers
     so every card background stays behind its text and actions. */
  :is(#zqUAco, #z4L5YW, #zFW6QJ, #zNqZyl, #zKD44p, #zMPvH8) > .block-layout {
    isolation: isolate;
  }

  :is(#zqUAco, #z4L5YW, #zFW6QJ, #zNqZyl, #zKD44p, #zMPvH8) > .block-layout > .layout-element {
    z-index: 1;
  }

  :is(#zqUAco, #z4L5YW, #zFW6QJ, #zNqZyl, #zKD44p, #zMPvH8) > .block-layout > .layout-element:has(> .image-wrapper) {
    z-index: 0;
  }

  /* Binance app links form a separate row after the illustration. */
  #ai-HOSlxQ > .block-layout {
    box-sizing: border-box;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows:
      [app-title] auto [app-lead] auto [app-image] auto
      [app-stores] auto [app-code] auto [app-note] auto;
    gap: 20px 12px;
    width: min(100%, 640px);
    max-width: 640px;
    height: auto;
    min-height: 0;
    padding: 28px 16px 32px;
  }

  #ai-HOSlxQ > .block-layout > .layout-element {
    grid-area: auto / 1 / auto / -1;
    width: 100%;
    min-width: 0;
    height: auto;
    min-height: 0;
    margin: 0;
  }

  #ai-HOSlxQ > .block-layout > :has(> #ai-K8BqLK) { grid-row: app-title; }
  #ai-HOSlxQ > .block-layout > :has(> #ai-nohuMB) { grid-row: app-lead; }
  #ai-HOSlxQ > .block-layout > :has(> #ai-i9HEpj) { grid-row: app-image; }
  #ai-HOSlxQ > .block-layout > :has(> #zHb-fr) { grid-area: app-stores / 1; }
  #ai-HOSlxQ > .block-layout > :has(> #zpFeaY) { grid-area: app-stores / 2; }
  #ai-HOSlxQ > .block-layout > :has(> #zIirgA) { grid-row: app-code; }
  #ai-HOSlxQ > .block-layout > :has(> #zTH_Ws) { grid-row: app-note; }

  #ai-HOSlxQ .image-wrapper,
  #ai-HOSlxQ .image-wrapper .image {
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 0;
    max-height: none;
  }

  #ai-HOSlxQ .image-wrapper .image__image {
    position: static;
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
  }

  #ai-HOSlxQ .image-wrapper--desktop { display: none; }
  #ai-HOSlxQ .image-wrapper--mobile { display: block; }
  #ai-HOSlxQ #ai-i9HEpj { max-width: 480px; justify-self: center; }
  #ai-HOSlxQ > .block-layout > :has(> :is(#zHb-fr, #zpFeaY)) {
    align-self: center;
    justify-self: center;
    max-width: 220px;
  }
  #ai-HOSlxQ :is(#zHb-fr, #zpFeaY) a.image { min-height: 44px; }
  #ai-HOSlxQ :is(#zHb-fr, #zpFeaY) .image__image { border-radius: 0; }

  /* Bybit's app illustration and store badges need distinct intrinsic rows.
     The old auto-placement still inherited image height limits and crop rules. */
  #zdBQW_ > .block-layout {
    box-sizing: border-box;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows:
      [bybit-app-title] auto [bybit-app-lead] auto [bybit-app-image] auto
      [bybit-app-stores] auto [bybit-app-code] auto [bybit-app-note] auto;
    gap: 20px 12px;
    width: min(100%, 640px);
    max-width: 640px;
    height: auto;
    min-height: 0;
    padding: 28px 16px 32px;
  }

  #zdBQW_ > .block-layout > .layout-element {
    grid-area: auto / 1 / auto / -1;
    width: 100%;
    min-width: 0;
    height: auto;
    min-height: 0;
    margin: 0;
  }

  #zdBQW_ > .block-layout > :has(> #zwkSez) { grid-row: bybit-app-title; }
  #zdBQW_ > .block-layout > :has(> #zkTUXV) { grid-row: bybit-app-lead; }
  #zdBQW_ > .block-layout > :has(> #ztTvt_) { grid-row: bybit-app-image; }
  #zdBQW_ > .block-layout > :has(> #zf6wMV) { grid-area: bybit-app-stores / 1; }
  #zdBQW_ > .block-layout > :has(> #zK3930) { grid-area: bybit-app-stores / 2; }
  #zdBQW_ > .block-layout > :has(> #zinqV5) { grid-row: bybit-app-code; }
  #zdBQW_ > .block-layout > :has(> #zhUglI) { grid-row: bybit-app-note; }

  #zdBQW_ .image-wrapper,
  #zdBQW_ .image-wrapper .image {
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 0;
    max-height: none;
  }

  #zdBQW_ .image-wrapper .image__image {
    position: static;
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
  }

  #zdBQW_ .image-wrapper--desktop { display: none; }
  #zdBQW_ .image-wrapper--mobile { display: block; }
  #zdBQW_ #ztTvt_ { max-width: 480px; justify-self: center; }

  #zdBQW_ > .block-layout > :has(> :is(#zf6wMV, #zK3930)) {
    align-self: center;
    justify-self: center;
    max-width: 220px;
  }

  #zdBQW_ :is(#zf6wMV, #zK3930) {
    overflow: visible;
    border-radius: 0;
  }

  #zdBQW_ :is(#zf6wMV, #zK3930) a.image-wrapper--mobile {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
  }

  #zdBQW_ :is(#zf6wMV, #zK3930) a.zh-app-store {
    flex-direction: column;
    min-height: 48px;
  }

  #zdBQW_ :is(#zf6wMV, #zK3930) .image__image {
    width: auto;
    max-width: 100%;
    height: clamp(40px, 12vw, 56px);
    border-radius: 0;
  }

  /* Each homepage logo background spans its complete, intrinsic-height action
     area. The reserved last track supplies bottom padding even when labels wrap. */
  #zqUAco > .block-layout {
    box-sizing: border-box;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows:
      [section-title] auto [section-lead] auto
      repeat(5,
        [exchange-title] auto
        [exchange-visual] minmax(clamp(132px, 32vw, 220px), auto)
        [exchange-action] auto [exchange-review] auto
        [exchange-padding] 16px [exchange-details] auto);
    gap: 12px;
    width: min(100%, 640px);
    max-width: 640px;
    height: auto;
    min-height: 0;
    padding: 28px 16px;
  }

  #zqUAco > .block-layout > .layout-element {
    grid-area: auto / 1 / auto / -1;
    width: 100%;
    min-width: 0;
    height: auto;
    min-height: 0;
    margin: 0;
  }

  #zqUAco > .block-layout > :has(> #zJlyWb) { grid-row: section-title; }
  #zqUAco > .block-layout > :has(> #zPWA1V) { grid-row: section-lead; margin-bottom: 8px; }
  #zqUAco > .block-layout > :has(> :is(#zRnOMs, #zFSN0w, #zJObQ7, #zXoNBM, #zzx3N3)) { --exchange-number: 1; --exchange-background: #13171c; }
  #zqUAco > .block-layout > :has(> :is(#zyJele, #zgQ5BF, #ziqOLj, #zXClDD, #z8z-rC)) { --exchange-number: 2; --exchange-background: #1f1f1f; }
  #zqUAco > .block-layout > :has(> :is(#zPEoXC, #zaX_Ai, #zfe3Qi, #zUUT9J, #zrGzSh)) { --exchange-number: 3; --exchange-background: #2954fe; }
  #zqUAco > .block-layout > :has(> :is(#zphyf2, #zXf8ah, #zrCC5Z, #zFqyyA, #zhfF4F)) { --exchange-number: 4; --exchange-background: #000; }
  #zqUAco > .block-layout > :has(> :is(#zeobSg, #zME360, #zGDBbK, #zt3tGm, #zHjMPx)) { --exchange-number: 5; --exchange-background: #fc712c; }

  #zqUAco > .block-layout > .layout-element:has(> .text-box h3) {
    grid-row: exchange-title var(--exchange-number);
    text-align: center;
  }
  #zqUAco > .block-layout > .layout-element:has(> .text-box ul) {
    grid-row: exchange-details var(--exchange-number);
    margin-bottom: 24px;
  }
  #zqUAco > .block-layout > .layout-element:has(> .image-wrapper) {
    grid-row: exchange-visual var(--exchange-number) / exchange-details var(--exchange-number);
    align-self: stretch;
  }
  #zqUAco .image-wrapper {
    height: 100%;
    min-height: 0;
    max-height: none;
    border-radius: 20px;
    background: var(--exchange-background);
  }
  #zqUAco .image-wrapper .image {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: none;
  }
  #zqUAco .image-wrapper .image__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
  }
  #zqUAco .image-wrapper--desktop { display: none; }
  #zqUAco .image-wrapper--mobile { display: block; }

  #zqUAco > .block-layout > .layout-element:has(> a.grid-button) {
    grid-column: 1 / -1;
    width: auto;
    margin-inline: 16px;
    align-self: stretch;
    z-index: 2;
  }
  #zqUAco > .block-layout > .layout-element:has(> a.grid-button[rel~="sponsored"]) {
    grid-row: exchange-action var(--exchange-number);
  }
  #zqUAco > .block-layout > .layout-element:has(> a.grid-button:not([rel~="sponsored"])) {
    grid-row: exchange-review var(--exchange-number);
  }
  #zqUAco > .block-layout > .layout-element:has(> .grid-embed:empty) { display: none; }

  /* The four-card alternatives sections share the same source structure in
     every locale. Keep each background behind title, copy and both buttons. */
  :is(#z4L5YW, #zFW6QJ, #zNqZyl, #zKD44p, #zMPvH8) > .block-layout {
    box-sizing: border-box;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows:
      [alternatives-kicker] auto [alternatives-title] auto
      repeat(4,
        [alternative-start] 16px [alternative-title] auto
        [alternative-copy] auto [alternative-action] auto
        [alternative-review] auto [alternative-padding] 16px
        [alternative-end] 16px)
      [alternatives-code] auto [alternatives-sources] auto;
    gap: 12px;
    width: min(100%, 640px);
    max-width: 640px;
    height: auto;
    min-height: 0;
    padding: 28px 16px;
  }

  :is(#z4L5YW, #zFW6QJ, #zNqZyl, #zKD44p, #zMPvH8) > .block-layout > .layout-element {
    grid-area: auto / 1 / auto / -1;
    width: 100%;
    min-width: 0;
    height: auto;
    min-height: 0;
    margin: 0;
  }
  :is(#z4L5YW, #zFW6QJ, #zNqZyl, #zKD44p, #zMPvH8) > .block-layout > :nth-child(1) { grid-row: alternatives-title; }
  :is(#z4L5YW, #zFW6QJ, #zNqZyl, #zKD44p, #zMPvH8) > .block-layout > :nth-child(5) { grid-row: alternatives-kicker; }
  :is(#z4L5YW, #zFW6QJ, #zNqZyl, #zKD44p, #zMPvH8) > .block-layout > :is(:nth-child(2), :nth-child(3), :nth-child(4), :nth-child(6), :nth-child(7)) { --alternative-number: 1; }
  :is(#z4L5YW, #zFW6QJ, #zNqZyl, #zKD44p, #zMPvH8) > .block-layout > :nth-child(n+8):nth-child(-n+12) { --alternative-number: 2; }
  :is(#z4L5YW, #zFW6QJ, #zNqZyl, #zKD44p, #zMPvH8) > .block-layout > :nth-child(n+13):nth-child(-n+17) { --alternative-number: 3; }
  :is(#z4L5YW, #zFW6QJ, #zNqZyl, #zKD44p, #zMPvH8) > .block-layout > :nth-child(n+18):nth-child(-n+22) { --alternative-number: 4; }

  :is(#z4L5YW, #zFW6QJ, #zNqZyl, #zKD44p, #zMPvH8) > .block-layout > :has(> .image-wrapper) {
    grid-row: alternative-start var(--alternative-number) / alternative-end var(--alternative-number);
    align-self: stretch;
  }
  :is(#z4L5YW, #zFW6QJ, #zNqZyl, #zKD44p, #zMPvH8) .image-wrapper {
    height: 100%;
    min-height: 0;
    max-height: none;
  }
  :is(#z4L5YW, #zFW6QJ, #zNqZyl, #zKD44p, #zMPvH8) .image-wrapper .image {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: none;
  }
  :is(#z4L5YW, #zFW6QJ, #zNqZyl, #zKD44p, #zMPvH8) .image-wrapper .image__image { width: 100%; height: 100%; object-fit: cover; }
  :is(#z4L5YW, #zFW6QJ, #zNqZyl, #zKD44p, #zMPvH8) .image-wrapper--desktop { display: none; }
  :is(#z4L5YW, #zFW6QJ, #zNqZyl, #zKD44p, #zMPvH8) .image-wrapper--mobile { display: block; }

  :is(#z4L5YW, #zFW6QJ, #zNqZyl, #zKD44p, #zMPvH8) > .block-layout > :is(:nth-child(3), :nth-child(9), :nth-child(14), :nth-child(19)) {
    grid-row: alternative-title var(--alternative-number);
    margin-inline: 16px;
    width: auto;
    text-align: center;
  }
  :is(#z4L5YW, #zFW6QJ, #zNqZyl, #zKD44p, #zMPvH8) > .block-layout > :is(:nth-child(4), :nth-child(10), :nth-child(15), :nth-child(20)) {
    grid-row: alternative-copy var(--alternative-number);
    margin-inline: 16px;
    width: auto;
    text-align: center;
  }
  :is(#z4L5YW, #zFW6QJ, #zNqZyl, #zKD44p, #zMPvH8) > .block-layout > :has(> a.grid-button) {
    grid-column: 1 / -1;
    grid-row: alternative-action var(--alternative-number);
    margin-inline: 16px;
    width: auto;
    z-index: 2;
  }
  /* Keep the full-width review below the offer on narrow phones. This must
     outrank the shared :has(> a.grid-button) action placement above. */
  :is(#z4L5YW, #zFW6QJ, #zNqZyl, #zKD44p, #zMPvH8) > .block-layout > .layout-element:has(> a.grid-button:not([rel~="sponsored"])) { grid-row: alternative-review var(--alternative-number); }
  :is(#z4L5YW, #zFW6QJ, #zNqZyl, #zKD44p, #zMPvH8) > .block-layout > .alternatives-referral-row { grid-area: alternatives-code / 1 / auto / -1; margin: 0; }
  :is(#z4L5YW, #zFW6QJ, #zNqZyl, #zKD44p, #zMPvH8) > .block-layout > :nth-child(24) { grid-row: alternatives-sources; }

  :is(#zqUAco, #z4L5YW, #zFW6QJ, #zNqZyl, #zKD44p, #zMPvH8) > .block-layout > .layout-element > a.grid-button {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    height: auto;
    min-height: 48px;
    align-self: stretch;
    justify-self: stretch;
    padding: 10px 12px;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: auto;
    line-height: 1.35;
  }
}

@media (360px <= width <= 1024px) {
  #zqUAco > .block-layout > .layout-element:has(> a.grid-button[rel~="sponsored"]) {
    grid-column: 1;
    margin-right: 0;
  }
  #zqUAco > .block-layout > .layout-element:has(> a.grid-button:not([rel~="sponsored"])) {
    grid-row: exchange-action var(--exchange-number);
    grid-column: 2;
    margin-left: 0;
  }
  :is(#z4L5YW, #zFW6QJ, #zNqZyl, #zKD44p, #zMPvH8) > .block-layout > .layout-element:has(> a.grid-button[rel~="sponsored"]) {
    grid-column: 1;
    margin-right: 0;
  }
  :is(#z4L5YW, #zFW6QJ, #zNqZyl, #zKD44p, #zMPvH8) > .block-layout > .layout-element:has(> a.grid-button:not([rel~="sponsored"])) {
    grid-row: alternative-action var(--alternative-number);
    grid-column: 2;
    margin-left: 0;
  }
}

@media (max-width: 359px) {
  #zqUAco .image-wrapper .image__image { object-fit: contain; }
}

@media (max-width: 600px) {
  /* Preserve the localized field label already present in every AI-tools cell.
     The header remains available to assistive technology without a narrow column. */
  .exchange-comparison table {
    display: block;
    border: 0;
    background: transparent;
    font-size: 1rem;
  }
  .exchange-comparison thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .exchange-comparison tbody { display: grid; gap: 16px; }
  .exchange-comparison tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    border: 1px solid #dadce0;
    border-radius: 12px;
    padding: 18px;
  }
  .exchange-comparison table tbody th,
  .exchange-comparison table tbody td {
    display: block;
    width: auto;
    min-width: 0;
    padding: 0;
    overflow-wrap: break-word;
    word-break: normal;
  }
  .exchange-comparison table tbody th[scope="row"],
  .exchange-comparison tbody td:first-child {
    width: auto;
    min-width: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #dadce0;
    font-size: 1.1rem;
    font-weight: 600;
  }
  .exchange-comparison .comparison-label {
    display: block;
    margin-bottom: 3px;
    color: #5e6268;
    font-size: .875rem;
    font-weight: 500;
  }
}
