/* =====================================================================
   PersianToxic — Mobile foundation  (mobile-first pass · Phase 1)
   Shared by every player-facing page. Loaded AFTER each page's main CSS so
   it layers on top. Desktop is intentionally untouched: every layout change
   lives inside a mobile media query; the handful of always-on rules below are
   pure hygiene and are no-ops on desktop.
   ===================================================================== */

/* ---------- 1. Global hygiene (safe on every viewport) ---------- */

/* Stop iOS from re-scaling text on orientation change. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* Kill the grey tap-flash; we provide our own :active feedback below. */
a, button, [role="button"], input, select, textarea, label, summary,
.btn, .nav__link, .mobile__link, .kitCell, .rdKit__cell {
  -webkit-tap-highlight-color: transparent;
}

/* Nothing should ever cause sideways scrolling on a phone. */
html, body { max-width: 100%; }
body { overflow-x: hidden; }

/* Media can never overflow its container. */
img, svg, video, canvas { max-width: 100%; }

/* Touch flag (is-touch / no-touch) is added to <html> by mobile.js. */


/* ---------- 2. Phone primitives (≤768px) ---------- */
@media (max-width: 768px) {

  /* iOS zooms the whole page when a focused input has font-size < 16px.
     Force a 16px floor on every text entry to kill that zoom jump. */
  input, select, textarea { font-size: 16px !important; }

  /* Comfortable minimum tap area (~44px, Apple/Google guideline) for the
     interactive controls shared across the site. Applied to controls only,
     never to layout wrappers, so it can't distort grids. */
  .btn,
  .mobile__link,
  .langtoggle,
  .accountmenu__item,
  .userBtn,
  .bottomnav__item,
  .rankModal__tab,
  .rdModal__tab {
    min-height: 44px;
  }

  /* Icon-only square controls need width too. */
  .hamb,
  .mobile__close,
  .topbar__hamb,
  .rankModal__close,
  .rdModal__x {
    min-width: 44px;
    min-height: 44px;
  }
}


/* ---------- 3. Tap feedback (touch can't trigger :hover) ---------- */
html.is-touch .btn:active {
  transform: scale(.97);
  filter: brightness(.94);
}
html.is-touch .mobile__link:active,
html.is-touch .accountmenu__item:active {
  background: rgba(255, 255, 255, .06);
}


/* ---------- 4. Tooltip-on-tap for kit cells ----------
   The kit item-name tooltips are :hover-only, which never fires on touch.
   mobile.js toggles .is-tapped on the tapped cell; the matching .is-tapped
   selectors live next to the original :hover rules (style.css for the main
   site, the dashboard store page's inline <style> for the dashboard) so the
   exact same bubble is reused with zero duplication. Nothing to add here. */


/* =====================================================================
   Phase 2 — Store experience on mobile
   Store rank-detail modals (main + dashboard) become full-screen sheets on
   phones, with safe-area padding; the wallet history table collapses into
   stacked cards. All scoped to small widths so desktop is untouched.
   ===================================================================== */

/* ---- Rank-detail modals: full-screen sheet on small phones ---- */
@media (max-width: 560px) {

  /* Main-site modal (already flex-column with a scrolling body). */
  .rankModal__panel {
    width: 100vw !important;
    height: 100vh !important;        /* fallback for old webviews */
    height: 100dvh !important;       /* real visible height (URL-bar aware) */
    max-width: none !important;
    max-height: none !important;
    border-radius: 0 !important;
  }
  .rankModal__head {
    padding-top: max(14px, calc(env(safe-area-inset-top) + 12px));
  }
  .rankModal__body {
    padding-bottom: max(16px, calc(env(safe-area-inset-bottom) + 12px)) !important;
  }

  /* Dashboard modal (already full-screen at this width) — keep the action
     buttons clear of the home indicator and the title clear of the notch. */
  .rdModal__head {
    padding-top: max(18px, calc(env(safe-area-inset-top) + 14px));
  }
  .rdModal__foot {
    padding-bottom: max(14px, calc(env(safe-area-inset-bottom) + 10px));
  }
}

/* ---- Wallet: 3-col transaction table -> stacked cards ----
   Markup column order is fixed (1=Date, 2=Item, 3=Amount) so cells are placed
   by nth-child without needing data-labels. Scoped to .table--cards so the
   orders / dashboard tables (handled in a later phase) stay untouched. */
@media (max-width: 600px) {
  .table--cards thead { display: none; }
  .table--cards,
  .table--cards tbody { display: block; }

  .table--cards tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "item amount" "date amount";
    align-items: center;
    column-gap: 10px;
    row-gap: 2px;
    padding: 12px 14px;
    border: 1px solid var(--line-1);
    border-radius: var(--radius);
    background: var(--bg-2);
    margin-bottom: 8px;
  }
  .table--cards tbody tr:last-child { margin-bottom: 0; }
  .table--cards tbody td { padding: 0; border: 0; }

  .table--cards td:nth-child(1) {          /* Date */
    grid-area: date; font-size: 12px; color: var(--text-3);
  }
  .table--cards td:nth-child(2) {          /* Item */
    grid-area: item; font-weight: 600; font-size: 14px; color: var(--text-1);
  }
  .table--cards td:nth-child(3) {          /* Amount */
    grid-area: amount; justify-self: end; text-align: end;
    font-weight: 700; font-size: 15px;
    font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate;
  }
}


/* =====================================================================
   Phase 3 — Engagement pages (home + leaderboard)
   Both pages already carry extensive responsive CSS from earlier work; these
   are targeted refinements for the rough edges that remain on small phones.
   ===================================================================== */

/* ---- Home: hero call-to-action buttons go full-width on small phones ----
   They currently flex-wrap, which leaves them unevenly sized once stacked.
   A clean full-width stack reads far better on a narrow screen. */
@media (max-width: 560px) {
  .cta { flex-direction: column; align-items: stretch; }
  .cta .btn { width: 100%; }
}

/* ---- Home: fluid hero title so it never overflows on the narrowest
   phones or with the longer Persian wording. ---- */
@media (max-width: 600px) {
  .title { font-size: clamp(30px, 11vw, 48px); }
}

/* ---- Home: guarantee the 6-card row collapses to a single column on
   phones (the base layout has no single-column fallback of its own). ---- */
@media (max-width: 600px) {
  .cards3 { display: grid; grid-template-columns: 1fr; gap: 14px; }
}

/* ---- Leaderboard: on the narrowest phones, ease the stat label/value so a
   long name (e.g. "Rockets Fired") doesn't crowd its number. The carefully
   tuned absolute icon is left exactly as-is. ---- */
@media (max-width: 440px) {
  .lbName  { font-size: 18px; line-height: 1.1; }
  .lbValue { font-size: 15px; }
}


/* =====================================================================
   Phase 4 — Dashboard pages
   The multi-column order tables become labeled cards on phones. Each cell's
   label is copied from the table header by dashboard.js, so this one ruleset
   serves both the 5-column overview table and the 7-column orders table.
   (The 3-column wallet table keeps its own compact .table--cards layout.)
   ===================================================================== */
@media (max-width: 600px) {
  .table--stack thead { display: none; }
  .table--stack,
  .table--stack tbody { display: block; }

  .table--stack tbody tr {
    display: block;
    border: 1px solid var(--line-1);
    border-radius: var(--radius);
    background: var(--bg-2);
    padding: 4px 14px;
    margin-bottom: 8px;
  }
  .table--stack tbody tr:last-child { margin-bottom: 0; }

  .table--stack tbody td { display: block; padding: 7px 0; border: 0; }
  .table--stack tbody td[data-label] {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; text-align: end;
    border-bottom: 1px solid var(--line-1);
  }
  .table--stack tbody tr td[data-label]:last-child { border-bottom: 0; }
  .table--stack tbody td[data-label]::before {
    content: attr(data-label);
    color: var(--text-3); font-size: 12px; font-weight: 600;
    text-align: start; flex-shrink: 0; white-space: nowrap;
  }
}
