/* Global mobile compatibility layer for Eggwallet pages.
   Keeps desktop design intact and applies only responsive safeguards. */

:root {
  --mobile-gap: 12px;
  --mobile-page-padding: clamp(16px, 4.5vw, 20px);
  --mobile-header-height: 58px;
  --mobile-nav-height: 68px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

.background-layer,
.bg-image {
  pointer-events: none;
}

.sidebar,
.sidebar-nav,
.nav-item,
.sidebar-item,
.sidebar__item {
  z-index: 3;
}

img,
video,
canvas,
svg,
iframe {
  max-width: 100%;
  height: auto;
}

input,
select,
textarea,
button {
  max-width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
}

.mobile-app-header,
.mobile-app-nav,
.mobile-more-backdrop {
  display: none;
}

/* Keep wide table layouts usable on phones without breaking desktop table design. */
.table-wrap,
.table-responsive,
.assets-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 1024px) {
  .dashboard-container,
  .page-container,
  .content-wrapper,
  .content-area,
  .main-content,
  main {
    max-width: 100%;
    min-width: 0;
  }

  .dashboard-container {
    min-height: 100vh;
    min-height: 100dvh;
  }
}

@media (max-width: 768px) {
  body {
    font-size: 15px;
  }

  .dashboard-container,
  .page-container,
  .content-wrapper,
  .content-area,
  .main-content,
  .page,
  main {
    min-width: 0;
    max-width: 100%;
  }

  .sidebar,
  .left-sidebar,
  .right-sidebar,
  .panel,
  .card,
  .modal-box {
    max-width: 100%;
  }

  .tabs,
  .content-header,
  .summary-section,
  .balance-actions,
  .info-grid,
  .decision-grid,
  .nft-grid,
  .mint-layout,
  .egg-row {
    width: 100%;
  }

  .content-header,
  .summary-section,
  .decision-grid,
  .mint-layout,
  .egg-row {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .balance-actions,
  .nft-cta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .info-grid,
  .nft-grid {
    grid-template-columns: 1fr;
    gap: var(--mobile-gap);
  }

  .nft-card {
    height: auto;
    min-height: 300px;
  }

  .balance-amount,
  .wallet-info-title,
  .assets-title,
  .egg-title,
  .nft-name {
    word-break: break-word;
  }
}

@media (max-width: 480px) {
  :root {
    --mobile-gap: 10px;
  }

  body {
    font-size: 14px;
  }

  .tabs {
    grid-template-columns: 1fr;
  }

  .balance-actions:not(.fab-actions),
  .nft-cta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .balance-actions.fab-actions {
    display: flex;
    flex-wrap: wrap;
  }

  .btn,
  button,
  [role="button"] {
    min-height: 44px;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

  body.h-screen.w-screen {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    padding-top: max(16px, env(safe-area-inset-top, 0px));
    padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    align-items: flex-start;
  }
}

/* Shared phone shell and touch sizing. Desktop rules remain owned by each page. */
@media (max-width: 767px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
    scroll-padding-top: calc(64px + env(safe-area-inset-top, 0px));
    scroll-padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }

  body.mobile-app-shell {
    min-height: 100vh;
    min-height: 100dvh;
    padding-top: calc(58px + env(safe-area-inset-top, 0px)) !important;
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
  }

  body.mobile-app-shell > main,
  body.mobile-app-shell > .page,
  body.mobile-app-shell > .shell,
  body.mobile-app-shell > .dashboard-container,
  body.mobile-app-shell > .page-container {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .mobile-app-header {
    position: fixed;
    inset: 0 0 auto;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: calc(58px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 16px 0;
    border-bottom: 1px solid rgba(255, 255, 255, .09);
    color: #f7f8fa;
    background: rgba(14, 17, 21, .94);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .mobile-app-brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
    color: inherit;
    font-size: 15px;
    font-weight: 800;
    text-decoration: none;
  }

  .mobile-app-brand img {
    width: 30px;
    height: 30px;
    object-fit: contain;
  }

  .mobile-menu-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-width: 72px;
    min-height: 44px;
    padding: 0 10px;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 11px;
    color: #f5f7f9;
    background: rgba(255, 255, 255, .06);
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
  }

  .mobile-menu-trigger svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
  }

  .mobile-app-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 5000;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: stretch;
    min-height: calc(68px + env(safe-area-inset-bottom, 0px));
    padding: 5px 6px env(safe-area-inset-bottom, 0px);
    border-top: 1px solid rgba(255, 255, 255, .1);
    background: rgba(14, 17, 21, .97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .mobile-app-nav-link {
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 4px;
    min-width: 0;
    min-height: 54px;
    border-radius: 11px;
    color: rgba(235, 240, 244, .62);
    font-size: 10px;
    font-weight: 650;
    line-height: 1;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-app-nav-link svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .mobile-app-nav-link.is-active {
    color: #b8ff50;
    background: rgba(184, 255, 80, .09);
  }

  .mobile-app-nav-link:active,
  .mobile-menu-trigger:active,
  .mobile-more-links > a:active {
    transform: scale(.97);
  }

  .mobile-more-backdrop {
    position: fixed;
    inset: 0;
    z-index: 6000;
    display: flex;
    align-items: flex-end;
    padding: 0;
    background: rgba(3, 5, 8, .66);
    opacity: 0;
    transition: opacity 160ms ease;
  }

  .mobile-more-backdrop[hidden] {
    display: none;
  }

  .mobile-more-backdrop.is-open {
    opacity: 1;
  }

  .mobile-more-sheet {
    width: 100%;
    max-height: min(90dvh, 760px);
    padding: 12px 16px calc(18px + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid rgba(255, 255, 255, .12);
    border-bottom: 0;
    border-radius: 20px 20px 0 0;
    color: #f3f5f7;
    background: #14181d;
    box-shadow: 0 -20px 64px rgba(0, 0, 0, .36);
  }

  .mobile-more-heading {
    position: sticky;
    top: -12px;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 54px;
    margin: -12px -2px 10px;
    padding: 10px 2px;
    background: #14181d;
  }

  .mobile-more-heading h2 {
    margin: 0;
    font-size: 18px;
    line-height: 1.2;
  }

  .mobile-more-close {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 10px;
    color: inherit;
    background: rgba(255, 255, 255, .06);
    font-size: 25px;
    cursor: pointer;
  }

  .mobile-more-links {
    display: grid;
    gap: 7px;
  }

  .mobile-more-links > a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 50px;
    padding: 8px 11px;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 12px;
    color: inherit;
    background: rgba(255, 255, 255, .035);
    font-size: 14px;
    line-height: 1.35;
    text-decoration: none;
    overflow-wrap: anywhere;
  }

  .mobile-more-links img {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    object-fit: contain;
  }

  body.mobile-app-shell aside.sidebar.mobile-shell-source-nav,
  body.app-menu-page.mobile-app-shell .app-menu.sidebar.mobile-shell-source-nav,
  body.mobile-app-shell .mobile-shell-source-nav {
    display: none !important;
  }

  body.mobile-app-shell .menu-offset {
    width: 100% !important;
    margin-left: 0 !important;
  }

  body.mobile-app-shell .dashboard-container {
    position: relative !important;
    width: 100% !important;
    min-height: 100dvh;
    height: auto !important;
    overflow: visible !important;
  }

  body.mobile-app-shell .content,
  body.mobile-app-shell .main-content,
  body.mobile-app-shell .content-wrapper,
  body.mobile-app-shell .content-area,
  body.mobile-app-shell .profile-container,
  body.mobile-app-shell .marketplace-container,
  body.mobile-app-shell .product-container {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  body.mobile-app-shell .row,
  body.mobile-app-shell [class*="-grid"],
  body.mobile-app-shell [class*="-layout"] {
    min-width: 0;
  }

  body.mobile-app-shell .main-content.menu-offset,
  body.mobile-app-shell .content-wrapper.menu-offset,
  body.mobile-app-shell .content-area.menu-offset {
    width: 100% !important;
    margin-left: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  .table-wrap,
  .table-responsive,
  .assets-table-wrapper {
    max-width: 100%;
    overscroll-behavior-x: contain;
  }

  .wallet-address,
  .address,
  .public-address,
  .transaction-hash,
  .txid,
  .public-key,
  .satoshi-id,
  code {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  button,
  [role="button"],
  input,
  select,
  textarea {
    max-width: 100%;
  }

  button,
  [role="button"] {
    min-height: 44px;
  }

  input,
  select,
  textarea {
    min-height: 46px;
    font-size: max(16px, 1em);
  }

  dialog {
    width: min(100% - 24px, 560px);
    max-width: calc(100vw - 24px);
    max-height: 90dvh;
    overflow: auto;
  }

  /* Turn the common custom-dialog patterns into thumb-friendly sheets. */
  body.mobile-app-shell [role="dialog"]:not(.mobile-more-sheet),
  body.mobile-app-shell .modal-box,
  body.mobile-app-shell .modal-dialog,
  body.mobile-app-shell .growth-access-dialog {
    max-width: calc(100vw - 24px) !important;
    max-height: 90dvh !important;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  body.mobile-app-shell :is(h1, .page-title) {
    font-size: clamp(22px, 7vw, 26px);
    line-height: 1.15;
    overflow-wrap: anywhere;
  }

  body.mobile-app-shell :is(h2, .section-title) {
    font-size: clamp(17px, 5vw, 20px);
    line-height: 1.25;
  }

  body.mobile-app-shell :is(pre, code, output, .hash, .address, .wallet-address) {
    min-width: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }

  body.mobile-app-shell .toast,
  body.mobile-app-shell [role="status"] {
    max-width: calc(100vw - 32px);
  }

  :focus-visible {
    outline: 2px solid #b8ff50;
    outline-offset: 2px;
  }
}

@media (max-width: 380px) {
  .mobile-app-header {
    padding-right: 12px;
    padding-left: 12px;
  }

  .mobile-app-nav {
    padding-right: 3px;
    padding-left: 3px;
  }

  .mobile-app-nav-link {
    font-size: 9px;
  }

  .mobile-app-nav-link svg {
    width: 19px;
    height: 19px;
  }
}

@media (max-width: 767px) {
  .nft-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nft-grid > *,
  .nft-card {
    min-width: 0;
  }

  body.mobile-app-shell .modal.active {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
  }

  body.mobile-app-shell .modal.active .modal-content {
    width: 100%;
    max-width: 100%;
    max-height: 90dvh;
    margin: 0;
    padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    overscroll-behavior: contain;
    border-radius: 20px 20px 0 0;
  }

  body.mobile-more-open {
    overflow: hidden;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }

  .mobile-more-backdrop,
  .mobile-app-nav-link {
    scroll-behavior: auto;
    transition: none;
  }
}

/* Retired duplicated app chrome: pages keep their own navigation. */
.mobile-app-header,
.mobile-app-nav,
.mobile-more-backdrop {
  display: none !important;
}
