/*
 * windpay.org — mobile & tablet system (2026-11-23)
 *
 * Loaded LAST and deliberately unlayered, so it wins over the compiled
 * Tailwind utilities (which live in @layer). Everything below 768px is scoped
 * to the media queries; desktop is untouched apart from safe-area padding.
 *
 * Spacing scale: 4 / 8 / 12 / 16 / 24 / 32px.
 * Type: body text 15–16px (clamp), Bengali line-height 1.75, headings fluid.
 * Targets: every button/link ≥ 44×44px; one-line, centered button labels.
 */

:root {
  --m-s1: 4px; --m-s2: 8px; --m-s3: 12px; --m-s4: 16px; --m-s5: 24px; --m-s6: 32px;
  --m-radius-card: 16px;
  --m-radius-btn: 12px;
  --m-btn-h: 48px;
}

/* ── iPhone notch / home indicator (viewport-fit=cover in the page head) ── */
body {
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
footer { padding-bottom: calc(env(safe-area-inset-bottom) + 0px); }
.wp-nav { padding-top: env(safe-area-inset-top); }

/* ── Text never leaves its box ── */
#root :is(p, li, dd, td, th, h1, h2, h3, h4, blockquote) { overflow-wrap: break-word; }
#root :is(.font-mono, code, td.font-mono, [class*="break-"]) { overflow-wrap: anywhere; }

/* ── Language pill: 30px look, 44px hit area ── */
.wp-lang-opt { position: relative; }
.wp-lang-opt::before { content: ""; position: absolute; inset: -7px -2px; }

/* ── Small text links get a full-size hit area ── */
#root a.block.text-center.text-sm,                 /* "View Full Tokenomics →" */
#root a.inline-flex.items-center.gap-2:not([class*="px-"]), /* legal "Back to windpay.org" */
#root .wt-back, #root .ws-more, #root .wt-note a {
  min-height: 44px; display: inline-flex; align-items: center;
}
#root a.block.text-center.text-sm { display: flex; justify-content: center; }

/* ══════════════════════ Phones and small tablets ══════════════════════ */
@media (max-width: 767.98px) {

  /* ── Fluid type ── */
  #root :is(p, li, dd, blockquote):not([class*="font-mono"]):not(:has(> .font-mono)):not(ul[class*="font-mono"] > li) { font-size: clamp(15px, 14px + 0.3vw, 16px); line-height: 1.6; }
  /* Monospace labels, chips and the transaction inspector keep their compact size. */
  #root :is(.wf-vals-l li, .wf-tx dd, .wf-tx dt, li[class*="font-mono"], li[class*="font-mono"] span, ul[class*="font-mono"] li, ul[class*="font-mono"] li span) { font-size: 13.5px; line-height: 1.5; }
  #root :is(p, li, dd):not([class*="font-mono"]) > :is(span, strong, b, em, a, code):not([class*="text-["]):not(.font-mono) { font-size: inherit; }
  html[lang="bn"] #root :is(p, li, dd, blockquote) { line-height: 1.75; }
  /* Small print stays small, but readable. */
  #root :is(.wf-note, .wt-caption, .wt-tip, .wt-live, .wt-badge) { font-size: 13.5px; line-height: 1.55; }
  #root :is(td, th) { font-size: 14px; line-height: 1.55; }

  #root h1 { font-size: clamp(30px, 7.6vw + 4px, 46px) !important; line-height: 1.1 !important; }
  html[lang="bn"] #root h1 { line-height: 1.3 !important; }
  #root h2:not(.wf-h) { font-size: clamp(25px, 5.6vw + 4px, 34px) !important; line-height: 1.2 !important; }
  html[lang="bn"] #root h2:not(.wf-h) { line-height: 1.35 !important; }
  #root h3 { font-size: clamp(18px, 3.4vw + 6px, 21px); line-height: 1.3; }
  html[lang="bn"] #root h3 { line-height: 1.45; }
  /* FAQ questions and small card headings read as headings, not captions. */
  #root [id^="faq-btn-"] span.text-sm, #root h4.text-sm { font-size: 16px; line-height: 1.4; }
  html[lang="bn"] #root [id^="faq-btn-"] span.text-sm { line-height: 1.55; }
  /* Hero lead paragraph. */
  #root h1 + p, #root h1 ~ p.text-sm { font-size: clamp(16px, 15px + 0.4vw, 17px); }

  /* ── Cards: one spacing + radius system ── */
  #root :is(.ws-card, .wt-card, .wf-story, .wf-tx,
    [class*="rounded-2xl"][class*="border"][class*="p-4"], [class*="rounded-2xl"][class*="border"][class*="p-5"],
    [class*="rounded-2xl"][class*="border"][class*="p-6"], [class*="rounded-3xl"][class*="border"][class*="p-6"],
    [class*="rounded-3xl"][class*="border"][class*="p-8"], [class*="rounded-2xl"][class*="bg-[#131520]"][class*="p-5"]):not(button):not(a) {
    padding: var(--m-s5); border-radius: var(--m-radius-card);
  }
  #root .wf { padding: var(--m-s4); border-radius: var(--m-radius-card); }
  #root :is(.wf-vals) { border-radius: var(--m-s3); }
  /* Stacked grids: equal-width, 16px gaps. */
  #root :is(.ws-grid, .grid):not(.wf-pipe):not(.wf-vals-grid):not([class*="grid-cols-2"]):not([class*="grid-cols-3"]):not(.wp-eco-grid) { row-gap: var(--m-s4); }
  #root :is(.ws-grid, .wt-grid) > * { height: 100%; }

  /* ── Buttons: one height, radius, size; labels on one line, centered ── */
  #root :is(a, button):is(.rounded-xl, .rounded-2xl, .rounded-full, .wp-btn):not(:has(div)):not([id^="portal-cat-btn-"]):not([id^="faq-cat-btn-"]):not(.w-10):not(.wp-burger):not(.wp-nav-cta):not(.wp-lang-opt):not(.wf-node):not(.wf-play):not([id^="faq-btn-"]) {
    min-height: var(--m-btn-h); border-radius: var(--m-radius-btn);
    display: inline-flex; align-items: center; justify-content: center; gap: var(--m-s2);
    font-size: 15px; line-height: 1.2; white-space: nowrap; text-align: center;
    width: 100%; padding-left: var(--m-s4); padding-right: var(--m-s4);
  }
  #root :is(a, button):is(.rounded-xl, .rounded-2xl, .rounded-full, .wp-btn):active { transform: scale(.98); }
  /* Two-line store badges (Android APK) keep their shape, full width. */
  #root a:is(.rounded-2xl, .rounded-xl):has(> div) { width: 100%; justify-content: center; min-height: 56px; }
  /* Portal cards: primary action and "Info" stacked, both full width. */
  #root div:has(> a.flex-1 + button) { flex-wrap: wrap; gap: var(--m-s2); }
  #root div:has(> a.flex-1 + button) > * { flex: 1 1 100%; }
  /* Filter chips: 44px, 14px text. */
  #root :is([id^="portal-cat-btn-"], [id^="faq-cat-btn-"]) { min-height: 44px; font-size: 14px; border-radius: var(--m-radius-btn); }
  /* URL chips: wrap long domains instead of cutting them off. */
  #root button.inline-flex.space-x-1\.5:has(span.truncate) { display: flex; width: 100%; max-width: 100%; min-height: 44px; }
  #root button.inline-flex.space-x-1\.5 span.truncate { flex: 1 1 auto; min-width: 0; text-align: left; }

  /* ── Flowchart: 3 × 2 grid of large steps instead of 6 tiny ones in a row ── */
  #root .wf-pipe { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: var(--m-s4); }
  #root .wf-rail, #root .wf-packet { display: none; }
  #root .wf-node { padding: var(--m-s2) var(--m-s1); border-radius: var(--m-s3); }
  #root .wf-node.is-active { background: rgba(0, 230, 118, .06); }
  #root .wf-hex { width: 52px !important; height: 52px !important; }
  #root .wf-node .wf-ico { width: 22px !important; height: 22px !important; }
  #root .wf-node-l { font-size: 14px !important; white-space: nowrap; letter-spacing: 0 !important; }

  /* Icon + text rows (scam warning card): the icon keeps its size. */
  #root div.flex.space-x-4:has(> div + div > h4) { align-items: flex-start; }
  #root div.flex.space-x-4:has(> div + div > h4) > div:first-child { flex-shrink: 0; }

  /* ── Header ── */
  .wp-nav-inner { gap: var(--m-s2); }

  /* ── Mobile menu: full screen, eased in, page behind does not scroll ── */
  .wp-mobile-menu {
    height: calc(100dvh - 64px - env(safe-area-inset-top)); max-height: none;
    padding-bottom: calc(var(--m-s5) + env(safe-area-inset-bottom));
    overscroll-behavior: contain;
    animation: wp-menu-in .22s cubic-bezier(.2, .7, .2, 1) both;
  }
  html:has(.wp-mobile-menu) { overflow: hidden; }
  .wp-mobile-links button, .wp-mobile-links .wp-mobile-tk { min-height: 52px; font-size: 16px; }
}

@keyframes wp-menu-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* Very small phones (320–359px): drop the "Protocol" tag so logo, EN | BN and menu fit. */
@media (max-width: 359.98px) {
  .wp-brand-badge { display: none !important; }
  #root button.inline-flex.space-x-1\.5:has(span.truncate) { padding-left: 10px; padding-right: 10px; }
  #root button.inline-flex.space-x-1\.5 span.truncate { font-size: 12px; }
  #root button.inline-flex.space-x-1\.5:has(span.truncate) > svg:last-child { display: none; } /* the chip itself copies */
  #root :is(.ws-card, .wt-card, .wf-story, .wf-tx) { padding: var(--m-s4); }
}

@media (prefers-reduced-motion: reduce) {
  .wp-mobile-menu { animation: none; }
  #root :is(a, button):active { transform: none !important; }
}

/* Tablets (768–1023px): three-up card rows become two-up; an odd last card spans the row. */
@media (min-width: 768px) and (max-width: 1023.98px) {
  #root .grid.md\:grid-cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #root .grid.md\:grid-cols-3 > :last-child:nth-child(odd) { grid-column: 1 / -1; }
}
