/* ============================================================
   MOBILE MARKET PAGES (registrar): My listings and its tabs, the
   list-a-domain wizard, offer threads, purchase receipts, pre-launch
   reservations and auctions.

   Every rule sits inside @media (max-width: 767px) (src/lib/mobile.js
   MOBILE_QUERY), so tablet and desktop render exactly as before. Builds on
   mobile-shell.css (.mobile-sticky-actions, --m-sticky-h, the .modal bottom
   sheet) and mobile-pages.css (table.m-cards with data-label / data-m).
   The dc-* classes are only used by the marketplace pages.
   ============================================================ */

@media (max-width: 767px) {
  /* ---------- Page frame: .page-content already carries the gutters ---------- */
  .dc-page {
    padding: 0;
  }
  .dc-page-head {
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
  }
  .dc-page-head > :first-child {
    min-width: 0;
  }
  .dc-h1 {
    font-size: clamp(1.375rem, 1.1rem + 1.4vw, 1.625rem);
    line-height: 1.2;
  }
  .dc-page-head > .dc-page-actions {
    flex-shrink: 0;
  }
  .dc-page-head > .dc-page-actions .dc-btn {
    white-space: nowrap;
  }
  .dc-back {
    min-height: 44px;
    margin-bottom: var(--space-2);
  }
  .dc-card {
    padding: var(--space-4);
  }
  .dc-page .dc-card + .dc-card,
  .dc-page [data-testid="prelaunch-marketplace"] {
    margin-bottom: var(--space-4);
  }
  .dc-section-title {
    font-size: var(--text-base);
  }

  /* ---------- Touch targets ---------- */
  .dc-btn {
    min-height: 44px;
    justify-content: center;
    padding-inline: var(--space-4);
    font-size: var(--text-sm);
  }
  .dc-btn-sm {
    min-height: 44px;
    padding-inline: var(--space-3);
  }
  .dc-btn:active:not(:disabled) {
    filter: brightness(0.94);
  }
  .dc-input {
    min-height: 44px;
    font-size: 16px !important;
  }
  textarea.dc-input {
    min-height: 88px;
  }
  /* The 40x22 switch keeps its look; its hit area grows to 44px. */
  .dc-toggle::after {
    content: "";
    position: absolute;
    inset: -11px -4px;
  }
  .dc-toggle-row {
    min-height: 56px;
  }

  /* ---------- Stats: compact 2x2 ---------- */
  .dc-grid-4 {
    gap: var(--space-2) !important;
    margin-bottom: var(--space-4) !important;
  }
  .dc-grid-4 > .dc-card {
    padding: var(--space-3);
  }
  .dc-grid-4 .dc-meta {
    font-size: var(--text-xs);
  }
  .dc-grid-4 .dc-stat-value {
    font-size: var(--text-xl);
    margin-top: 2px;
  }

  /* ---------- Tabs: one swipeable row, labels never wrap ---------- */
  .dc-tabs {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    padding: 0 var(--space-1);
  }
  .dc-tabs::-webkit-scrollbar {
    display: none;
  }
  .dc-tab {
    flex-shrink: 0;
    min-height: 48px;
    padding: var(--space-2) var(--space-3);
    white-space: nowrap;
    scroll-snap-align: start;
  }

  /* ---------- Card lists (table.dc-table.m-cards) under the tabs ----------
     The tabs' wrapping card drops its frame so the row cards are not
     nested inside another bordered card. */
  .dc-card:has(> .dc-tabs) {
    padding: 0 !important;
    border: none;
    background: none;
  }
  .dc-card:has(> .dc-tabs) > :is(table.m-cards, .m-cards-scroll) {
    margin-top: var(--space-3);
  }
  .dc-card:has(> .dc-tabs) > .dc-empty {
    padding-block: var(--space-8);
  }
  /* Field labels stay in the body font when the value cell is monospaced. */
  table.m-cards td::before {
    font-family: Inter, system-ui, -apple-system, sans-serif;
  }
  /* Row actions: an even grid of full-width buttons. */
  .dc-page table.m-cards td[data-m="actions"] > div {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }
  .dc-page table.m-cards td[data-m="actions"] > div > .dc-btn {
    width: 100%;
  }
  .dc-page table.m-cards td[data-m="actions"] > div > .dc-btn:only-child {
    grid-column: 1 / -1;
  }
  table.m-cards td[data-m="primary"]:has(> div) {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
  table.m-cards td[data-m="primary"] > div {
    max-width: 100% !important;
    overflow-wrap: anywhere;
  }
  table.m-cards td[data-label] > div:not(:first-child) {
    flex-basis: 100%;
    max-width: none !important;
    text-align: right;
  }
  /* Tappable card rows (purchases, auctions, receipts) */
  table.m-cards tbody tr[role="button"],
  table.m-cards tbody tr[style*="pointer"] {
    -webkit-tap-highlight-color: transparent;
  }
  table.m-cards tbody tr[role="button"]:active,
  table.m-cards tbody tr[style*="pointer"]:active {
    background: var(--bg-hover);
  }

  /* ---------- Offers inbox: list, then the thread in its place ---------- */
  .mkt-offers {
    display: block !important;
    min-height: 0 !important;
    scroll-margin-top: calc(var(--nav-height, 56px) + var(--crumbs-height, 0px) + 56px);
  }
  .mkt-offers-list {
    border-right: none !important;
  }
  .mkt-inbox-row {
    min-height: 64px;
    padding: var(--space-3) var(--space-4) !important;
  }
  .mkt-inbox-row.selected {
    background: none;
  }
  .mkt-inbox-row:active {
    background: var(--bg-hover);
  }
  .mkt-offer-thread {
    padding: var(--space-3) var(--space-4) var(--space-4) !important;
  }
  .mkt-offer-thread .dc-section-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
  }
  .mkt-offer-thread .dc-section-title .dc-badge {
    margin-left: 0 !important;
  }
  .mkt-offer-thread label.dc-meta {
    display: block;
    margin-bottom: var(--space-1);
  }
  /* Decline / Counter share a row; Accept takes the full width above them. */
  .app-container:has(.mkt-offer-actions.mobile-sticky-actions) {
    --m-sticky-h: 129px;
  }
  .mkt-offer-actions.mobile-sticky-actions {
    flex-wrap: wrap !important;
  }
  .dc-page-actions.mkt-offer-actions.mobile-sticky-actions > .dc-btn-primary {
    order: -1;
    flex: 1 1 100%;
  }

  /* ---------- Sticky action bars built from dc-btn ---------- */
  .dc-page-actions.mobile-sticky-actions > .dc-btn {
    flex: 1 1 0;
    min-width: 0;
    min-height: 48px;
    font-size: 16px;
    white-space: normal;
    line-height: 1.2;
    text-align: center;
  }
  .modal-footer > .dc-btn {
    flex: 1 1 0;
    min-height: 48px;
    justify-content: center;
    font-size: 16px;
  }

  /* ---------- List-a-domain wizard ---------- */
  /* The breadcrumb's back chip already leads to My listings. */
  .dc-page > .dc-back:first-child {
    display: none;
  }
  .dc-stepper {
    margin-bottom: var(--space-4);
  }
  .dc-step:not(.active) .dc-step-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .dc-domain-pick {
    min-height: 52px;
  }
  .dc-domain-pick .mono {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  /* Sale types: a compact 2x2 choice instead of four full-width tiles. */
  .dc-grid-2[role="radiogroup"] {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
  }
  .mkt-pricing-tile {
    min-height: 64px;
    padding: var(--space-3);
  }
  .mkt-pricing-tile .dc-meta {
    margin-top: 2px;
    font-size: var(--text-xs);
    line-height: 1.35;
  }
  .dc-kv-row {
    gap: var(--space-3);
    padding-block: var(--space-2);
  }
  .dc-kv-row .dc-btn {
    flex-shrink: 0;
    white-space: nowrap;
  }
  .dc-kv-row > :first-child {
    flex-shrink: 0;
    max-width: 50%;
  }
  .dc-kv-row > :last-child {
    min-width: 0;
    text-align: right;
    overflow-wrap: anywhere;
  }

  /* ---------- Pre-launch section: search, extension chips, results ---------- */
  .mkt-prelaunch-search .form-input {
    min-width: 0;
  }
  .mkt-prelaunch-search .dc-btn {
    flex-shrink: 0;
  }
  /* Eleven extensions in one swipeable row instead of four wrapped rows. */
  .mkt-chips {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    padding-block: 2px;
  }
  .mkt-chips::-webkit-scrollbar {
    display: none;
  }
  .mkt-chips > .btn {
    flex-shrink: 0;
    min-height: 40px;
    border-radius: var(--radius-full);
  }
  .mkt-prelaunch-row {
    padding: var(--space-3) !important;
  }
  .mkt-prelaunch-row > :first-child {
    flex: 1 1 100%;
  }
  .mkt-prelaunch-row > :last-child {
    flex: 1 1 100%;
    justify-content: flex-start !important;
  }
  .mkt-prelaunch-row > :last-child > :last-child {
    margin-left: auto;
  }
  .mkt-prelaunch-row .btn-primary {
    min-height: 44px;
  }
  /* Remove-from-cart: an icon button inline-styled to 24px wide. */
  .mkt-prelaunch-row .btn-ghost {
    min-width: 44px !important;
    min-height: 44px;
    justify-content: center;
  }

  /* ---------- Pre-launch auctions ---------- */
  /* The breadcrumb's back chip already leads to the auction list. */
  .page-content a.btn-ghost[href="#/prelaunch/auctions"] {
    display: none;
  }
  .mkt-auction-stats {
    grid-template-columns: 1fr 1fr !important;
    gap: var(--space-2) !important;
  }
  .mkt-auction-stats .stat-card {
    padding: var(--space-3);
  }
  .mkt-auction-stats .stat-card-value {
    font-size: var(--text-xl) !important;
  }
  .mkt-bid-row .form-input {
    flex: 1 1 auto;
    min-width: 0;
  }
  .mkt-bid-row .btn {
    flex-shrink: 0;
    min-height: 44px;
  }

  /* Receipt rows keep data-label on the title cell; it still reads left. */
  table.m-cards td[data-m="primary"][data-label] {
    justify-content: flex-start;
  }

  /* ---------- Escrow-held deals (Financial wallet) ---------- */
  [data-testid="escrow-held-deals"] li {
    padding: var(--space-2) 0;
    line-height: 1.5;
    overflow-wrap: anywhere;
  }
  [data-testid="escrow-held-deals"] li + li {
    border-top: 1px solid var(--border-subtle);
  }
  /* Links stay inline in the sentence; an absolutely placed ::after grows
     the tap area to ~44px without moving the text. The Receipt button's
     inline accent colour is too light on white for AA, so it takes the
     text accent. */
  [data-testid="escrow-held-deals"] li :is(a, button) {
    position: relative;
    color: var(--accent-text) !important;
    font-weight: 500 !important;
  }
  [data-testid="escrow-held-deals"] li :is(a, button)::after {
    content: "";
    position: absolute;
    inset: -12px -4px;
  }
}
