/* phone-fit-v1 (26 Nov 2026, G: "the site needs to be mobile responsive on every page no matter the device").
   One shared phone layer: spacing, type, tap targets and card grids. Loaded last on each page that opts in.
   Phones: <= 600px. Small phones: <= 374px (one-column list cards where two columns get hard to read).
   Tablet and desktop are untouched except for the scroll-margin helper. */

:root { --xp-gap: 10px; --xp-pad: 14px; --xp-radius: 14px; --xp-tap: 44px; }

[id] { scroll-margin-top: 84px; }

@media (max-width: 600px) {
  /* ---------- spacing + type ---------- */
  main.wrap, .wrap { padding-left: 12px !important; padding-right: 12px !important; }
  .card, .mp-section { padding: var(--xp-pad) !important; margin-bottom: 12px !important; border-radius: var(--xp-radius) !important; }
  .mp-section-head { margin-bottom: 8px !important; gap: 4px !important; }
  .mp-section-head .hint { font-size: 13px !important; }
  main.wrap h1 { font-size: clamp(24px, 7vw, 30px) !important; line-height: 1.15 !important; }
  main.wrap h2 { font-size: clamp(19px, 5.4vw, 22px) !important; line-height: 1.2 !important; }
  body { -webkit-text-size-adjust: 100%; }

  /* ---------- tap targets ---------- */
  .btn, button.btn, a.btn, .explore-tab, .xp-tap { min-height: var(--xp-tap); display: inline-flex; align-items: center; justify-content: center; }
  select, input[type="search"], input[type="text"] { min-height: var(--xp-tap); font-size: 16px !important; } /* 16px stops iOS zooming in */

  /* ---------- one-row scrollers for tabs and chips ---------- */
  .xp-row, .explore-tabs, .explore-discover-chips, .market-tabs, .mk-tabs {
    display: flex !important; flex-wrap: nowrap !important; overflow-x: auto; gap: 8px;
    scrollbar-width: none; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity;
  }
  .xp-row::-webkit-scrollbar, .explore-tabs::-webkit-scrollbar, .explore-discover-chips::-webkit-scrollbar { display: none; }
  .explore-tabs > *, .explore-discover-chips > * { flex: 0 0 auto; scroll-snap-align: start; }

  /* ---------- shared card grid ---------- */
  .xp-grid, .market-grid, #gridCollections.disc-grid, .disc-grid {
    display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: var(--xp-gap) !important;
  }

  /* ---------- Market cards: art, title, artist, price, then the actions ---------- */
  .market-card { padding: 8px !important; display: flex !important; flex-direction: column; gap: 4px; min-width: 0; }
  .market-card > a:first-child { border-radius: 10px; overflow: hidden; }
  .market-card .thumb { width: 100% !important; height: auto !important; aspect-ratio: 1 / 1; display: block; }
  .market-card .title { font-size: 14.5px !important; font-weight: 700; line-height: 1.25 !important; margin-top: 4px !important;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .market-card .meta { font-size: 12.5px !important; line-height: 1.3 !important; margin: 0 !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .market-card .meta a { display: inline; }
  .market-card .price { margin: 2px 0 0 !important; }
  .market-card .marketplace-crypto-price { font-size: 15px !important; }
  .market-card .marketplace-usd-estimate { font-size: 11.5px !important; }
  .market-card .market-fee-hint, .market-card .links { display: none !important; }
  .market-card .marketplace-badge { font-size: 11px !important; padding: 2px 7px !important; align-self: flex-start; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .market-card .marketplace-badge ~ .marketplace-badge { display: none !important; }
  .market-card .actions { display: grid !important; grid-template-columns: 1fr 1fr; gap: 6px !important; margin-top: auto !important; padding-top: 6px; }
  .market-card .actions > * { min-height: 40px !important; padding: 6px 4px !important; font-size: 13px !important; width: 100% !important; margin: 0 !important; white-space: nowrap; }
  .market-card .actions > :nth-child(3) { grid-column: 1 / -1; }

  /* ---------- Explore collection cards ---------- */
  .disc-card.explore-gallery-card { min-width: 0; }
  .disc-card .cov-wrap, .disc-card .cov { aspect-ratio: 1 / 1; height: auto !important; }
  .disc-card.explore-gallery-card { padding: 6px !important; }
  .disc-gallery-meta { padding: 8px 4px 4px !important; gap: 2px !important; min-height: 0 !important; }
  .disc-gallery-meta > .disc-card-link { flex: 0 0 auto !important; min-height: 0 !important; }
  .disc-gallery-meta .t { min-height: 0 !important; }
  .disc-gallery-meta .by-creator { min-height: 0 !important; }
  .disc-card .disc-card-link .cov-wrap { width: 100% !important; border-radius: 10px; overflow: hidden; }
  .disc-gallery-meta .t { font-size: 14.5px !important; line-height: 1.25 !important; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .disc-gallery-label-row, .disc-gallery-category:empty, .disc-gallery-physical-badges:empty, .disc-gallery-search-tag:empty, .disc-gallery-floor:empty { display: none !important; }
  .disc-gallery-meta .by-creator { font-size: 12.5px !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .disc-gallery-floor { font-size: 13px !important; font-weight: 700; }

  /* ---------- floating "Filters" pill (xh-phone.mjs shows it once the filters scroll away) ---------- */
  .xp-filters-pill { position: fixed; left: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 60; min-height: 44px;
    padding: 0 16px; border-radius: 999px; border: 1px solid rgba(255,255,255,.22); background: rgba(14,16,34,.92); color: #fff;
    font: 700 14px/1 Poppins, system-ui, sans-serif; box-shadow: 0 6px 22px rgba(0,0,0,.45); display: none; align-items: center; gap: 8px; }
  .xp-filters-pill.on { display: inline-flex; }

  /* ---------- jump links + folded sections (Beanville, Casino hub, $dOOd) ---------- */
  .xp-jump { position: sticky; top: 64px; z-index: 30; margin: 0 -12px 10px; padding: 8px 12px; background: rgba(10,12,28,.94);
    backdrop-filter: blur(6px); border-bottom: 1px solid rgba(255,255,255,.08); }
  .xp-jump a { flex: 0 0 auto; min-height: 36px; padding: 0 14px; display: inline-flex; align-items: center; border-radius: 999px;
    border: 1px solid rgba(255,255,255,.18); color: inherit; text-decoration: none; font-size: 13.5px; font-weight: 600; white-space: nowrap; }
  details.xp-fold > summary { list-style: none; cursor: pointer; min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 700; font-size: 17px; }
  details.xp-fold > summary::-webkit-details-marker { display: none; }
  details.xp-fold > summary::after { content: "Show"; font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 999px; border: 1px solid rgba(127,127,127,.5); flex: 0 0 auto; }
  details.xp-fold[open] > summary::after { content: "Hide"; }
}

@media (min-width: 601px) {
  .xp-jump, .xp-filters-pill, .xp-phone-only { display: none !important; }
  details.xp-fold > summary { display: none; }
}

/* ---------- small phones: Market goes to one-column list cards (art left, details right) ---------- */
@media (max-width: 374px) {
  .market-grid { grid-template-columns: 1fr !important; }
  .market-card { display: grid !important; grid-template-columns: 118px minmax(0, 1fr); column-gap: 10px; row-gap: 2px; align-items: start; }
  .market-card > * { grid-column: 2; }
  .market-card > a:first-child { grid-column: 1; grid-row: 1 / span 6; }
  .market-card .actions { grid-column: 1 / -1; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .market-card .actions > :nth-child(3) { grid-column: auto; }
  .market-card .actions > * { font-size: 12.5px !important; }
}

/* ======================= Home (index.html) on phones ======================= */
@media (max-width: 600px) {
  /* hero: real art + Browse art on the first screen */
  .xf-hero { padding-top: 16px !important; gap: 12px !important; }
  .xf-eyebrow { font-size: 11px !important; margin-bottom: 4px !important; }
  .xf-title { font-size: clamp(25px, 7.4vw, 30px) !important; margin: 0 0 6px !important; }
  .xf-lede { font-size: 15px !important; line-height: 1.45 !important; margin: 0 0 12px !important; }
  .xf-cta { display: grid !important; grid-template-columns: 1.25fr 1fr; gap: 8px !important; }
  .xf-cta .btn { width: 100% !important; margin: 0 !important; min-height: 48px; }
  .xf-free { font-size: 13px !important; margin-top: 10px !important; }
  .xf-strip-head { margin-bottom: 6px !important; }
  /* signed-in members: their shortcuts in one swipeable row, so the art stays on the first screen */
  #xhBackRow .xb-row { display: flex !important; flex-wrap: nowrap !important; overflow-x: auto; gap: 8px; scrollbar-width: none; }
  #xhBackRow .xb-row::-webkit-scrollbar { display: none; }
  #xhBackRow .xb-row > * { flex: 0 0 auto; }
  #xhBackRow .xb-hi { margin: 10px 0 6px !important; font-size: 14px !important; }

  /* doors: four short tiles, the whole tile is the link */
  .xf-door-grid { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px !important; }
  .xf-door { position: relative; padding: 12px !important; min-height: 0 !important; display: flex !important; flex-direction: column; gap: 4px; }
  .xf-door.xp-door-collect, .xf-door .xf-door-long, .xf-doors .xf-atlas { display: none !important; }
  .xf-door h3 { font-size: 16px !important; margin: 4px 0 0 !important; }
  .xf-door-ico { font-size: 22px !important; }
  .xf-door .xf-door-short { font-size: 13px !important; line-height: 1.35 !important; margin: 0 !important; opacity: .85; }
  .xf-door .xf-door-links { margin: auto 0 0 !important; padding-top: 6px; }
  .xf-door .xf-door-links a { display: none; }
  .xf-door .xf-door-links a:first-child { display: inline-block; font-weight: 700; font-size: 13.5px; }
  .xf-door .xf-door-links a:first-child::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
  .xf-doors .xf-h2 { font-size: 19px !important; margin-bottom: 10px !important; }

  /* The Corner has its own door on phones */
  #homeCornerWidget { display: none !important; }

  /* Dood Atlas: one compact row */
  .xh-atlas .xh-atlas-link { display: grid !important; grid-template-columns: 92px minmax(0, 1fr); gap: 12px; align-items: center; }
  .xh-atlas .xh-atlas-art img { width: 92px !important; height: 92px !important; object-fit: cover; border-radius: 12px; }
  .xh-atlas .xh-atlas-copy, .xh-atlas .xh-atlas-steps, .xh-atlas .xh-atlas-fine, .xh-atlas .xh-atlas-foot, .xh-atlas .xh-atlas-live { display: none !important; }
  .xh-atlas .xh-atlas-title { font-size: 18px !important; margin: 2px 0 !important; }
  .xh-atlas .xh-atlas-tag { font-size: 13.5px !important; display: block; }
  .xh-atlas .xh-atlas-cta { margin-top: 8px !important; }
  .xh-atlas .xh-atlas-cta .btn { min-height: 40px; font-size: 14px; padding: 0 14px; }

  /* Beanville: one compact row, Visit first */
  .xh-beans .xh-beans-grid { display: grid !important; grid-template-columns: 96px minmax(0, 1fr) !important; gap: 12px !important; align-items: start; }
  .xh-beans .xh-beans-art img { width: 96px !important; height: 96px !important; border-radius: 12px; object-fit: cover; }
  .xh-beans .xh-beans-copy, .xh-beans .xh-beans-facts, .xh-beans .xh-beans-links { display: none !important; }
  .xh-beans .xh-beans-title { font-size: 18px !important; margin: 2px 0 4px !important; }
  .xh-beans .xh-beans-tag { font-size: 13.5px !important; margin: 0 0 8px !important; }
  .xh-beans .xh-beans-cta { grid-column: 1 / -1; display: grid !important; grid-template-columns: 1fr 1fr; gap: 8px; }
  .xh-beans .xh-beans-cta .btn { width: 100%; margin: 0 !important; font-size: 14px; }
  .xh-beans .xh-beans-body { display: contents; }
  .xh-beans .xh-beans-top, .xh-beans .xh-beans-title, .xh-beans .xh-beans-tag { grid-column: 2; }
  .xh-beans .xh-beans-art { grid-column: 1; grid-row: 1 / span 3; }

  /* New to the XRP Ledger: three plain links instead of three cards */
  .xf-new-grid { display: flex !important; flex-direction: column; gap: 0 !important; }
  .xf-new-card { padding: 12px 2px !important; background: none !important; border: 0 !important; border-bottom: 1px solid rgba(255,255,255,.09) !important; border-radius: 0 !important; min-height: 44px; }
  .xf-new-card span { display: none !important; }
  .xf-new-card b::after { content: "  →"; opacity: .6; }
}

/* ======================= Market header on phones ======================= */
@media (max-width: 600px) {
  body.xrpl-home-market .mk-h1 { font-size: 26px !important; margin: 0 !important; }
  body.xrpl-home-market .mk-doors { display: flex !important; flex-wrap: nowrap !important; overflow-x: auto; gap: 8px; scrollbar-width: none; margin-top: 8px !important; }
  body.xrpl-home-market .mk-doors::-webkit-scrollbar { display: none; }
  body.xrpl-home-market .mk-doors a { flex: 0 0 auto; min-height: 40px; display: inline-flex; align-items: center; }
  body.xrpl-home-market .mk-more { font-size: 13px !important; margin-top: 8px !important; }
  body.xrpl-home-market .controls { display: flex !important; flex-direction: column; gap: 8px !important; }
  body.xrpl-home-market .controls .controlRow { width: 100%; min-width: 0 !important; flex-wrap: nowrap !important; gap: 8px !important; }
  body.xrpl-home-market .controls .controlRow .mk-filterbtn { flex: 0 0 auto; }
  body.xrpl-home-market .listed-toggle { display: none !important; } /* always on; nothing to change on a phone */
  body.xrpl-home-market #marketSort { flex: 1 1 auto; min-width: 0; }
  body.xrpl-home-market .hr { margin: 10px 0 !important; }
  body.xrpl-home-market .mt-what { flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; margin-top: 8px !important; }
  body.xrpl-home-market .mt-what > * { flex: 0 0 auto; }
}

/* Home: Happening now + collection cards, shorter on phones */
@media (max-width: 600px) {
  #xhNowGrid .xn-card .xn-body > span:not(.xn-k):not(.xn-bar) { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 13.5px; }
  #xhNowGrid .xn-card img, #xhNowGrid .xn-card .xn-ico { width: 56px !important; height: 56px !important; }
  .mp-collection-card .mp-badge-row { gap: 4px !important; }
  .mp-collection-card .mp-badge-row .mp-badge-origin { display: none !important; } /* "Imported": detail for the collection page */
  .mp-collection-card .mp-badge { font-size: 11px !important; padding: 2px 8px !important; }
  .mp-collection-card .mp-collection-media, .mp-collection-card .mp-collection-media img { aspect-ratio: 4 / 3; height: auto !important; }
}

/* ======================= Beanville, Casino hub, $dOOd page on phones ======================= */
@media (max-width: 600px) {
  /* Beanville welcome: the four "go" doors as a 2 x 2 grid */
  .bv-welcome .bw-gos { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px !important; }
  .bv-welcome .bw-go { min-height: 72px; padding: 10px !important; }
  .bv-welcome .bw-p { font-size: 14.5px !important; }
  .bv-welcome .bw-go b, .bv-welcome .bw-go strong { font-size: 15px !important; line-height: 1.2 !important; }
  .bv-welcome .bw-go span, .bv-welcome .bw-go small { font-size: 12.5px !important; line-height: 1.3 !important; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

  /* Casino hub: game tiles two across (Slots, Midway Booths, Arcade) */
  body .tiles.three, body ul.tiles { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px !important; }
  ul.tiles > li > .tile { display: flex !important; flex-direction: column; height: 100%; }
  ul.tiles .tile .art { aspect-ratio: 1 / 1; height: auto !important; max-height: none !important; }
  ul.tiles .tile .txt { padding: 8px !important; gap: 3px !important; display: flex; flex-direction: column; flex: 1 1 auto; }
  ul.tiles .tile .txt b { font-size: 14.5px !important; }
  ul.tiles .tile .txt small { font-size: 12.5px !important; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  ul.tiles .tile .play-btn { margin-top: auto !important; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
  .dw-grid { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px !important; }
  .dw-grid .dw { padding: 10px !important; min-width: 0; }

  /* $dOOd page: the page's own jump row becomes one sticky scrolling row */
  .sw-hero .sw-jump { display: flex !important; flex-wrap: nowrap !important; overflow-x: auto; gap: 8px; scrollbar-width: none;
    position: sticky; top: 64px; z-index: 20; background: rgba(10,12,28,.94); margin: 8px -14px !important; padding: 8px 14px !important; }
  .sw-hero .sw-jump::-webkit-scrollbar { display: none; }
  .sw-hero .sw-jump > * { flex: 0 0 auto; white-space: nowrap; min-height: 38px; display: inline-flex; align-items: center; }

  details.xp-fold { border: 1px solid rgba(127,127,127,.35); border-radius: 14px; padding: 2px 12px; margin: 10px 0; background: rgba(255,255,255,.02); }
  details.xp-fold[open] { padding-bottom: 12px; }
  details.xp-fold > :not(summary) > h2:first-child, details.xp-fold > :not(summary) .block-head h2 { display: none !important; }
  details.xp-fold > :not(summary) { margin-top: 0 !important; border: 0 !important; padding-left: 0 !important; padding-right: 0 !important; background: none !important; box-shadow: none !important; }
  details.xp-fold > summary h2, details.xp-fold > summary h3 { margin: 0 !important; font-size: 17px !important; }
}
