/* ===========================================================================
   CRYPTOCARDIUM — COUCHE APP MOBILE v1  (03/09/2026)
   Loaded AFTER main(.min).css on every page (public + dashboard).
   Strictly additive: desktop (> 900px) is untouched except for rules scoped
   to (hover: none) and the collapsible-TOC button styling.
   =========================================================================== */

:root {
  --mnav-h: 62px;
  --sab: env(safe-area-inset-bottom, 0px);
  --sat: env(safe-area-inset-top, 0px);
}

/* "On this page" toggle button (inserted by JS next to the title): phones only. */
.guide-toc__toggle { display: none; }
.signin-ico { display: none; }
/* `hidden` must beat `.btn { display: inline-flex }`: the order-card "Top up first"
   CTA was rendered next to the submit button even with enough balance. */
.btn[hidden], .mnav[hidden] { display: none !important; }
.msheet, .mnav, .msheet-backdrop { display: none; }
.msheet-backdrop { position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, 0.62); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: opacity 0.25s ease; }

/* ---------------------------------------------------------------------------
   1. Touch foundations (any touch device, any width)
   --------------------------------------------------------------------------- */
@media (hover: none) {
  a, button, [role="button"], summary, label { -webkit-tap-highlight-color: transparent; }
  a, button, input, select, textarea, summary, label, [role="button"] { touch-action: manipulation; }
  /* Hover lifts stick after a tap on touch screens: neutralise them, keep a press state. */
  .btn:hover, .nav-user:hover, .pillar:hover, .price-card:hover, .use-case:hover, .guide-card:hover,
  .guide-card:hover .guide-card__art img { transform: none; }
  .btn:active { transform: scale(0.97); transition-duration: 80ms; }
  .guide-card:active, .tier:active, .pillar:active, .price-card:active, .use-case:active,
  .tp-coin__tile:active, .card-pick:active, .card-type:active, .tp-preset:active { transform: scale(0.985); transition-duration: 80ms; }
  .faq__item > summary:active, .help-item summary:active { background: rgba(255, 255, 255, 0.03); }
}

/* ---------------------------------------------------------------------------
   2. ≤ 900px — shared chrome: tab bar, sheets, language sheet, fields, rhythm
   --------------------------------------------------------------------------- */
@media (max-width: 900px) {
  html.sheet-lock, html.sheet-lock body { overflow: hidden; }
  body.has-mnav { padding-bottom: calc(var(--mnav-h) + var(--sab) + 12px); }
  .site-header.is-scrolled, .dash-top.is-scrolled { box-shadow: 0 10px 28px -14px rgba(0, 0, 0, 0.75); }

  /* ---- Bottom tab bar ---- */
  .mnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
    display: flex; align-items: stretch;
    height: calc(var(--mnav-h) + var(--sab));
    padding: 0 4px var(--sab);
    background: rgba(10, 10, 15, 0.9);
    -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    transition: transform 0.25s var(--ease);
  }
  html.kb-open .mnav { transform: translateY(110%); }
  .mnav__item {
    flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    padding: 6px 2px 4px; margin: 0; color: var(--text-faint);
    font-family: var(--geist); font-size: 10.5px; font-weight: 500; letter-spacing: 0.01em; line-height: 1.15; text-align: center;
    background: none; border: 0; border-radius: 10px; cursor: pointer; -webkit-tap-highlight-color: transparent;
    transition: color 0.15s ease;
  }
  .mnav__item > svg { width: 23px; height: 23px; flex: none; }
  .mnav__item > span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mnav__item.is-active { color: var(--text); }
  .mnav__item.is-active > svg { color: var(--brand-hover); }
  .mnav__item:active { color: var(--text); }
  .mnav__item--cta { color: var(--text); }
  .mnav__cta {
    width: 50px; height: 50px; margin-top: -24px; border-radius: 50%; display: grid; place-items: center; flex: none;
    background: linear-gradient(135deg, #6366F1 0%, #8B7CF6 60%, #A78BFA 100%); color: #fff;
    box-shadow: 0 10px 28px -8px rgba(99, 102, 241, 0.8), 0 0 0 4px var(--bg);
    transition: transform 0.15s ease;
  }
  .mnav__cta svg { width: 24px; height: 24px; }
  .mnav__item--cta:active .mnav__cta { transform: scale(0.94); }
  .mnav__item--cta.is-active { color: var(--text); }
  /* The raised CTA keeps its full label (2 lines max) — long in ar/ru/de. */
  .mnav__item--cta > span:last-child { white-space: normal; line-height: 1.05; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; padding: 0 2px; }

  /* ---- Bottom sheet (menu) ---- */
  .msheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 95;
    display: flex; flex-direction: column;
    max-height: min(88dvh, 88vh);
    background: #101016; border: 1px solid rgba(255, 255, 255, 0.1); border-bottom: 0;
    border-radius: 22px 22px 0 0; box-shadow: 0 -24px 60px -20px rgba(0, 0, 0, 0.85);
    padding-bottom: var(--sab);
    transform: translateY(102%); transition: transform 0.28s var(--ease);
  }
  .msheet[hidden] { display: none; }
  .msheet.is-open { transform: none; }
  .msheet-backdrop { display: block; }
  .msheet-backdrop.is-on { opacity: 1; pointer-events: auto; }
  .msheet__handle { width: 40px; height: 4px; border-radius: 99px; background: rgba(255, 255, 255, 0.18); margin: 8px auto 0; flex: none; }
  .msheet__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 18px 6px; flex: none; }
  .msheet__title { font-size: 1.0625rem; font-weight: 600; color: var(--text); margin: 0; letter-spacing: -0.01em; }
  .msheet__close {
    width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
    background: rgba(255, 255, 255, 0.06); color: var(--text-soft); border: 1px solid var(--border); cursor: pointer;
  }
  .msheet__close svg { width: 16px; height: 16px; }
  .msheet__body { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 4px 14px 16px; }

  .msheet__account { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
  .msheet__account .btn { width: 100%; justify-content: center; min-height: 46px; white-space: normal; text-align: center; }
  .msheet__account--user { grid-template-columns: 1fr auto; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); }
  .msheet__user { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--text); font-weight: 500; font-size: 0.9375rem; }
  .msheet__user .nav-user__avatar { flex: none; }
  .msheet__user span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .msheet__signout { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-2); color: var(--text-muted); font-size: 0.8125rem; font-weight: 500; }
  .msheet__signout svg { width: 15px; height: 15px; }

  .msheet__lang {
    display: flex; align-items: center; gap: 10px; width: 100%; min-height: 50px; padding: 10px 14px; margin-bottom: 14px;
    border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card);
    color: var(--text); font-family: var(--geist); font-size: 0.9375rem; font-weight: 500; cursor: pointer; text-align: start;
  }
  .msheet__lang .fi { width: 22px; height: 16px; border-radius: 3px; flex: none; }
  .msheet__lang > span:nth-child(2) { flex: 1; min-width: 0; }
  .msheet__lang small { color: var(--text-faint); font-size: 0.75rem; font-weight: 400; }
  .msheet__lang svg { width: 16px; height: 16px; color: var(--text-faint); flex: none; }

  .msheet__groups { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
  .msheet__group h3 { font-family: var(--mono); font-size: 0.625rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.16em; color: var(--text-faint); margin: 10px 0 4px; padding: 0 2px; }
  .msheet__group a { display: flex; align-items: center; min-height: 44px; padding: 8px 2px; color: var(--text-soft); font-size: 0.9375rem; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
  .msheet__group a:last-child { border-bottom: 0; }
  .msheet__group a:active { color: var(--text); }

  /* ---- Language dropdown -> bottom sheet (moved to <body> by app-mobile.js) ---- */
  .lang-menu--sheet {
    position: fixed; inset: auto 0 0 0; z-index: 96;
    width: auto; max-width: none; margin: 0;
    padding: 10px 14px calc(14px + var(--sab));
    border-radius: 22px 22px 0 0; border-bottom: 0; background: #101016;
    box-shadow: 0 -24px 60px -20px rgba(0, 0, 0, 0.85);
    transform: translateY(102%); transition: transform 0.28s var(--ease), opacity 0.2s ease;
  }
  .lang-menu--sheet::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 99px; background: rgba(255, 255, 255, 0.18); margin: 0 auto 12px; }
  .lang-menu--sheet.is-open { transform: none; opacity: 1; }
  .lang-menu--sheet .lang-grid { max-height: min(56vh, 440px); gap: 2px; }
  .lang-menu--sheet .lang-opt { padding: 11px 12px; font-size: 15px; min-height: 46px; }
  .lang-menu--sheet .lang-search { padding: 10px 12px; min-height: 46px; }
  .lang-menu--sheet .lang-search input { font-size: 16px; }
  .lang-btn { min-height: 40px; }

  /* ---- Fields ≥ 16px: no iOS zoom on focus ---- */
  .form-input, .form-select, select.form-input, textarea.form-input, .docs-search__input, #langSearch, #help-search,
  .help-search input, .dash-search input, .support-textarea, .wd-form input, .wd-form select, .auth-form input { font-size: 16px; }

  /* ---- Tap targets ---- */
  .widget__action, .acc-list__link, .form-link, .guide-card__more, .help-item__a a, .tp-assure a { display: inline-block; padding: 6px 0; margin: -6px 0; }
  .footer__legal a { display: inline-block; padding: 8px 0; margin: -8px 0; }
  .crumb a { display: inline-block; padding: 6px 0; margin: -6px 0; }
  .dash-icon-btn, .dash-hamburger { width: 40px; height: 40px; }
  .act-pager__btn { min-height: 40px; }
  .faq__item > summary { padding: 18px 20px; min-height: 60px; }
  .faq__answer { padding: 0 20px 20px; }
  .btn { min-height: 44px; }
  .actions .btn { min-height: 38px; }

  /* ---- Vertical rhythm ---- */
  .section, .showcase, .physical, .devs, .compare, .faq { padding-block: clamp(40px, 7vw, 56px); }
  .section .section__head { margin-bottom: clamp(24px, 6vw, 40px); }
  .guide-hero { padding: 40px 0 32px; }
  .guide-hub-hero { padding: 56px 0 36px; }
  .guide-body { padding-block: 32px 40px; }
  .prose h2 { margin-top: var(--s-7); }
  .prose > * { min-width: 0; }

  /* ---- Home hero: the old .hero__bg mobile rule made the background a flex
         sibling of the copy (two columns on a phone). Pin it back. ---- */
  .hero--v2 { display: block; }
  .hero--v2 .hero__bg { position: absolute; inset: 0; height: auto; width: auto; z-index: -2; }

  /* ---- Home compare: inline labels no longer forced into a 110px column ---- */
  .compare__row [role="cell"]:not(:first-child)::before { width: auto; margin-inline-end: 8px; }

  /* ---- Grids that trapped wide children (min-width: auto) ---- */
  .guide-layout > *, .api-mcp__grid > *, .api-quick__grid > *, .api-hooks__grid > *, .api-auth__grid > *, .api-flow__grid > *, .api-cat__grid > *, .devs__grid > *, .docs-shell > * { min-width: 0; }
  .auth-method pre, .api-auth pre, .api-flow pre, .prose pre { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
  .prose { max-width: 100%; }
  .mcp-config { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
  .mcp-client { min-width: 0; }

  /* ---- Horizontal scrollers: right-edge fade while more is hidden ---- */
  .pricing-table__scroll, .card-compare__scroll, .table-wrap, .terminal__body, pre.docs-code, .mcp-config { position: relative; }
  .has-more { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent); }

  /* ---- Guide TOC: collapsible card ---- */
  .guide-toc.is-collapsible { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); position: static; }
  .is-collapsible > .guide-toc__title, .is-collapsible > .legal-toc__label { display: none; }
  .guide-toc__toggle {
    display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 10px;
    background: none; border: 0; text-align: start; font-family: var(--mono); font-size: 11px;
    text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted);
  }
  .legal-toc.is-collapsible { padding: 0; gap: 0; }
  .legal-toc.is-collapsible nav { display: none; padding: 0 8px 8px; }
  .legal-toc.is-open nav { display: flex; }
  .legal-toc.is-collapsible .legal-toc__link { min-height: 44px; align-items: center; padding: 8px 12px; font-size: 14.5px; }
  .act-filters, .help-cats { position: relative; }
  .guide-toc__toggle { padding: 14px 16px; margin: 0; cursor: pointer; min-height: 48px; }
  .guide-toc__toggle svg { display: block; transition: transform 0.2s ease; color: var(--text-faint); }
  .guide-toc.is-open .guide-toc__toggle svg { transform: rotate(180deg); }
  .guide-toc.is-collapsible nav { display: none; padding: 0 8px 8px; }
  .guide-toc.is-open nav { display: block; }
  .guide-toc.is-collapsible a { display: flex; align-items: center; min-height: 44px; padding: 8px 12px; font-size: 14.5px; }

  /* ---- Docs: code blocks with an always-visible copy button ---- */
  pre.docs-code { padding: 42px 16px 16px; font-size: 12.5px; }
  .docs-code__copy { top: 8px; right: 8px; padding: 6px 10px; min-height: 30px; }
  .docs-sidebar { padding-top: calc(var(--s-5) + var(--sat)); padding-bottom: calc(var(--s-5) + var(--sab)); z-index: 86; }
  .docs-backdrop { z-index: 84; }

  /* ---- Dashboard ---- */
  .dash-body.has-mnav .dash-content { padding-bottom: calc(var(--mnav-h) + var(--sab) + 28px); }
  .dash-side { padding-top: calc(var(--s-5) + var(--sat)); padding-bottom: calc(var(--s-5) + var(--sab)); z-index: 86; }
  .dash-backdrop { z-index: 84; }
  .widget__head { flex-wrap: wrap; gap: 4px 12px; }
  .dash-notif__panel { max-height: min(70vh, 520px); overflow-y: auto; }
}

/* ---------------------------------------------------------------------------
   3. ≤ 640px — tables become label / value cards (data-th set by app-mobile.js)
   --------------------------------------------------------------------------- */
@media (max-width: 640px) {
  table.tb-cards { display: block; width: 100%; min-width: 0; border-collapse: separate; border-spacing: 0; font-size: 14px; }
  table.tb-cards thead { display: none; }
  table.tb-cards tbody { display: block; }
  table.tb-cards tr { display: block; padding: 12px 14px; border-bottom: 1px solid var(--border); background: none; }
  table.tb-cards tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.015); }
  table.tb-cards tr:last-child { border-bottom: 0; }
  table.tb-cards td, table.tb-cards th { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 5px 0; border: 0; text-align: start; background: none !important; width: auto; min-width: 0; white-space: normal; }
  table.tb-cards [data-first] { display: block; font-weight: 600; color: #fff; font-size: 15px; padding: 0 0 8px; }
  table.tb-cards [data-first] .mono, table.tb-cards [data-first] span { font-weight: 400; }
  table.tb-cards td[data-th]::before { content: attr(data-th); flex: 0 0 44%; font-family: var(--mono); font-size: 10.5px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); line-height: 1.4; }
  table.tb-cards td[data-th] > * { text-align: end; }
  table.tb-cards td[data-th] { text-align: end; }
  table.tb-cards td[data-th] > span:only-child { margin-inline-start: auto; }
  table.tb-cards td.is-long { flex-direction: column; align-items: flex-start; gap: 3px; text-align: start; }
  table.tb-cards td.is-long::before { flex: none; }
  table.tb-cards td.is-long > * { text-align: start; }
  .table-wrap:has(> .tb-cards), .pricing-table__scroll:has(> .tb-cards), .card-compare__scroll:has(> .tb-cards) { overflow: visible; -webkit-mask-image: none; mask-image: none; }
  .cmp-table.tb-cards, .card-compare__table.tb-cards { min-width: 0; }
}

/* ---------------------------------------------------------------------------
   4. ≤ 600px — phones
   --------------------------------------------------------------------------- */
@media (max-width: 600px) {
  /* Hero / page actions: one full-width button per row */
  .page-hero__actions, .cards-hero__actions, .card-final__actions, .page-final__actions, .physical__actions, .cta__actions,
  .card-show__actions, .wallets-bin__actions, .prose__cta, .hub-404__actions, .docs-hero__actions, .docs-finish, .guide-hero__actions { flex-direction: column; align-items: stretch; }
  .page-hero__actions .btn, .cards-hero__actions .btn, .card-final__actions .btn, .page-final__actions .btn, .physical__actions .btn,
  .cta__actions .btn, .card-show__actions .btn, .wallets-bin__actions .btn, .prose__cta .btn, .docs-finish .btn { width: 100%; justify-content: center; white-space: normal; text-align: center; min-height: 50px; }
  .btn--lg { min-height: 50px; }
  .page-hero__strip, .cards-hero__strip { gap: 10px 18px; }

  /* Home: darker scrim over the card photo so the copy stays readable */
  .hero--v2 .hero__bg::after {
    background:
      radial-gradient(ellipse 70% 38% at 50% 28%, rgba(138,124,255,0.16) 0%, transparent 65%),
      linear-gradient(180deg, rgba(8,8,12,0.9) 0%, rgba(8,8,12,0.74) 40%, rgba(8,8,12,0.78) 70%, rgba(8,8,12,0.97) 100%);
  }
  .hero--v2 .hero__pill { max-width: 100%; justify-content: center; }
  .tier__limits { font-size: 0.75rem; }
  .terminal__body { font-size: 0.75rem; }

  /* Dashboard top bar: the bar's tabs replace the "Back to overview" ghost link */
  .dash-top__right .btn--ghost { display: none; }
  .dash-top { padding: 10px var(--s-4) 10px var(--s-3); }
  .dash-top__title { font-size: 1.0625rem; }
  .widget--balance__primary .widget__eyebrow { line-height: 1.5; }

  /* Footer: compact, every link a real row */
  .site-footer { padding: 36px 0 20px; }
  /* Two link columns down to 320px (main.css dropped to one below 400px): the
     Menu sheet already lists everything, so the footer stays short. */
  .footer__top { grid-template-columns: 1fr 1fr; gap: 20px 16px; padding-bottom: 20px; }
  .footer__brand-block { grid-column: 1 / -1; }
  .footer__col h4 { margin-bottom: 6px; }
  .footer__col ul { gap: 0; }
  .footer__col a { display: block; padding: 9px 0; margin: 0; font-size: 0.9375rem; }
  .footer__bottom { gap: 10px; padding-top: 18px; }
  .footer__disclaimer { font-size: 0.72rem; margin-top: 20px; padding-top: 16px; }

  /* Guides hub cards + article */
  .guide-grid { gap: var(--s-4); }
  .guide-card__body { padding: var(--s-4); }
  .prose { font-size: 1rem; line-height: 1.7; }
  .prose h2 { font-size: 1.375rem; }
  .prose h3 { font-size: 1.125rem; }
  .takeaways { padding: var(--s-4); }
  .callout { padding: var(--s-4); }
  .code-block pre { padding: var(--s-4); }

  /* Header: the raised tab-bar CTA already says "Get a card"; the header slot
     goes to sign-in (user icon), the one entry phones were missing. */
  .actions .btn--brand { display: none; }
  .signin-ico { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 11px; border: 1px solid var(--border-2); background: var(--bg-glass); color: var(--text); }
  .signin-ico svg { width: 19px; height: 19px; }

  /* Auth card */
  .auth-card { padding-inline: 18px; }

  /* Dashboard forms */
  .form-section--split { grid-template-columns: 1fr; }
  .tp-preset { min-height: 44px; }
}

/* ---------------------------------------------------------------------------
   5. ≤ 380px — small phones
   --------------------------------------------------------------------------- */
@media (max-width: 380px) {
  .mnav__item { font-size: 10px; }
  .mnav__item > svg { width: 22px; height: 22px; }
  .msheet__groups { grid-template-columns: 1fr; }
  .actions .btn { padding: 7px 10px; }
  .actions .lang-btn { padding-inline: 8px; }
}

/* ---------------------------------------------------------------------------
   6. Installed as a home-screen app: respect the status-bar notch
   --------------------------------------------------------------------------- */
@media (display-mode: standalone) {
  .site-header, .dash-top { padding-top: var(--sat); }
}
