/* Shared mobile and touch polish; loaded after each page's own styles. */

/* Fallback fonts sized to match the web fonts, so text doesn't reflow (jump) when they finish loading.
   Values measured against Cormorant Garamond / Inter in Chromium. */
@font-face{font-family:"Cormorant Fallback";src:local("Times New Roman"),local("TimesNewRomanPSMT"),local("Times"),local("Noto Serif"),local("DejaVu Serif");size-adjust:93%;ascent-override:99%;descent-override:29%;line-gap-override:0%}
@font-face{font-family:"Inter Fallback";src:local("Arial"),local("ArialMT"),local("Helvetica"),local("Roboto");size-adjust:106.3%;ascent-override:91%;descent-override:22.8%;line-gap-override:0%}

/* Touch screens: every control at least 44px tall/wide (Apple/Google guidance). Mouse users see no change. */
@media(pointer:coarse){
  a.nav-brand,a.brand,.mhdr-logo{min-width:44px;min-height:44px;display:inline-flex;align-items:center;justify-content:center}
  .btn,.btn-gold,.btn-ghost,.btn-join,.apply-btn,.cta-btn{min-height:44px;display:inline-flex;align-items:center;justify-content:center}
  footer a{display:inline-flex;align-items:center;min-height:44px}
  .foot-col a{display:flex;margin-bottom:0}
  footer .links a{padding-left:4px;padding-right:4px}
  .tabs button{min-height:44px}
  .toggle-pw,#togglePw{min-width:44px;min-height:44px}
  #forgotLink,.swap button{display:inline-flex;align-items:center;min-height:44px}
  a[href^="mailto:"]:not(p a),a[href^="tel:"]:not(p a){display:inline-flex;align-items:center;min-height:44px}
  #menuToggle,.icon-btn,#exportBtn,#refreshBtn,#sidebarClose{min-width:44px;min-height:44px}
  /* trading terminal */
  .mhdr-avatar,.mhdr-ham{width:44px;height:44px}
  .tr-x{width:44px;height:44px}
  .tr-ok{min-height:48px}
  .tf-btn{min-width:34px;min-height:28px;position:relative}
  .cs-btn{min-width:40px;min-height:28px;position:relative}
  .mhdr-tog button{position:relative;padding:6px 12px}
  /* invisible hit area: keeps the compact look, but the finger target is 44px+ tall */
  .tf-btn::after,.cs-btn::after{content:"";position:absolute;left:0;right:0;top:-10px;bottom:-10px}
  .mhdr-tog{overflow:visible}
  .mhdr-tog button:first-child{border-radius:5px 0 0 5px}
  .mhdr-tog button:last-child{border-radius:0 5px 5px 0}
  .mhdr-tog button::after{content:"";position:absolute;left:0;right:0;top:-11px;bottom:-11px}
}

/* Phones in landscape: fixed bars must not eat the short screen */
@media(max-width:940px) and (max-height:500px) and (orientation:landscape){
  .mobile-bar{flex-direction:row!important;align-items:stretch;gap:8px;padding:6px 10px calc(6px + env(safe-area-inset-bottom))}
  .mobile-bar .mb-ctls,.mobile-bar .mb-btns{flex:1;min-width:0}
  .mobile-bar .mb-btn{padding:8px 10px;border-radius:12px}
  .mobile-bar .mb-ctl{padding:2px 4px}
  body:has(.mobile-bar){padding-bottom:76px!important}
}

/* Full-screen pages on phones: the main action stays at the bottom, within thumb reach */
@media(max-width:880px){
  .modal-overlay .modal{padding-bottom:0!important}
  .modal-overlay .modal .modal-actions{position:sticky;bottom:0;z-index:2;background:var(--panel,#FFFFFF);margin:16px -18px 0;padding:12px 18px calc(12px + env(safe-area-inset-bottom));border-top:1px solid var(--line-soft,#E2E8F0)}
}
html{-webkit-text-size-adjust:100%;text-size-adjust:100%;touch-action:manipulation}
body{overflow-x:hidden;-webkit-tap-highlight-color:transparent}
img,svg,video,canvas{max-width:100%}
.toast{white-space:normal;max-width:calc(100vw - 24px);background:var(--panel,#FFFFFF);color:var(--text,#0F172A);border-color:var(--line,#E2E8F0)}
button,a,[role=button]{touch-action:manipulation}

@media(max-width:880px){
  /* trading: filled buy/sell on the mobile bar to match desktop */
  .mb-btn{border:none;border-radius:16px;padding:15px 12px;color:#FFFFFF}
  .mb-btn.buy{background:linear-gradient(135deg,#10B981,#0E9F72);color:#FFFFFF;box-shadow:0 8px 20px rgba(16,185,129,.28)}
  .mb-btn.sell{background:linear-gradient(135deg,#EF4444,#DC2F2F);color:#FFFFFF;box-shadow:0 8px 20px rgba(239,68,68,.28)}
  .mobile-bar{box-shadow:0 -8px 24px rgba(15,23,42,.08);padding-bottom:calc(10px + env(safe-area-inset-bottom))}
  .mb-step{width:40px;height:44px}
  .chartwrap{height:52vh;min-height:280px}
  .tf-btn{padding:6px 9px}
}

@media(max-width:640px){
  /* 16px inputs stop iOS Safari from zooming on focus */
  input:not([type=checkbox]):not([type=radio]):not([type=range]),select,textarea{font-size:16px!important}
  input:not([type=checkbox]):not([type=radio]):not([type=range]),select{min-height:46px}
  form button[type=submit],.btn,.btn-primary,.cta{min-height:48px}
  h1{overflow-wrap:anywhere}
  .modal,.modal-card,.card{max-width:100%}
  .tbl-scroll{margin:0 -4px}
  footer{padding-left:16px;padding-right:16px}
}

@media(max-width:380px){
  body{font-size:15px}
}

@supports(padding:max(0px)){
  body{padding-left:env(safe-area-inset-left);padding-right:env(safe-area-inset-right)}
}

/* decorative glows must not widen the page */
.hero,.cta{overflow-x:clip}

@media(max-width:400px){
  .nav{gap:8px;padding-left:14px;padding-right:14px}
  .nav .btn-gold{padding:8px 12px;font-size:12px;white-space:nowrap}
}

@media(max-width:400px){
  .nav-brand{font-size:17px;letter-spacing:1px}
  .btn-join{padding:7px 12px}
}

footer .links{flex-wrap:wrap;justify-content:center}

/* any touch device: 16px form text prevents iOS focus zoom */
@media(pointer:coarse){
  input:not([type=checkbox]):not([type=radio]):not([type=range]),select,textarea{font-size:16px!important}
}

/* logo */
svg[aria-label="PrimeTradeBroker"]{border-radius:26%}

/* logo + name; logo only on small screens */
.nav-brand{display:inline-flex;align-items:center;gap:10px;line-height:1}
.logo-mark{flex-shrink:0;border-radius:26%}

.brand .brand-name{display:inline}
a.brand{display:inline-flex;align-items:center;gap:10px}

/* name shown next to the logo on every page; on narrow phones it shrinks so it fits beside the nav button */
@media(max-width:420px){
  .nav-brand{font-size:16px!important;letter-spacing:1px!important;gap:7px}
  .nav-brand .logo-mark{width:26px;height:26px}
  .nav .btn-gold,.nav .btn-join{padding:0 12px!important;font-size:12px!important;white-space:nowrap}
  nav .brand,a.brand{gap:7px}
  nav .brand .name,a.brand .brand-name,header .brand .name{font-size:16px!important;letter-spacing:1px!important}
  nav .brand svg,a.brand svg{width:28px;height:28px}
}
@media(max-width:340px){
  .nav-brand,nav .brand .name,a.brand .brand-name,header .brand .name{font-size:14px!important;letter-spacing:.5px!important}
}

@media(max-width:400px){
  .foot-brand,.foot-col{min-width:0}
  .foot-brand .brand{gap:8px}
  .foot-brand .brand .name{font-size:17px;letter-spacing:1.5px}
}

/* Accessible headings that are not shown (app pages) */
.sr-only{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}

/* Breadcrumbs on information pages */
.crumbs{font-size:13px;color:var(--muted,#64748B);margin:0 0 18px;line-height:1.4}
.crumbs a{color:var(--muted,#64748B);text-decoration:none}
.crumbs a:hover{color:var(--gold,#2563EB)}
.crumbs span[aria-hidden]{margin:0 8px;opacity:.6}
.crumbs [aria-current]{color:var(--text,#0F172A);font-weight:500}
@media(pointer:coarse){
  .crumbs a,.nav-links a{display:inline-flex;align-items:center;min-height:44px}
  .stake-row input{min-height:40px}
}

/* Compact trade controls (investment / auto-close boxes and SELL/BUY), still 40px+ to tap */
.ctl{padding:1px 5px;border-radius:10px}
.ctl-step{width:28px;height:30px;font-size:18px}
.ctl-val,.ctl-val input{font-size:14px}
.ctl-lbl{font-size:7.5px}
.tbtn{padding:14px 12px!important;border-radius:14px!important}
.tbtn .tlab b{font-size:17px}
.tbtn .tlab small{font-size:11px}
.tbtn .tchev{font-size:15px}
@media(max-width:880px){
  .mobile-bar{gap:6px;padding-top:8px}
  .mb-ctls,.mb-btns{gap:6px}
  .mb-ctl{padding:0 3px;border-radius:10px}
  .mb-step{width:32px;height:32px;font-size:17px;position:relative}
  .mb-step::after{content:"";position:absolute;left:0;right:0;top:-6px;bottom:-6px} /* finger target stays ~44px */
  .mb-val{font-size:13px;line-height:1.15}
  .mb-lbl{font-size:7.5px}
  .mb-btn{padding:10px 12px!important;border-radius:13px!important;min-height:54px}
  .mb-btn .tlab b{font-size:17px;display:inline;margin-right:6px}
  .mb-btn .tlab small{font-size:12px;opacity:.9}
  .mb-btn .tchev{font-size:15px!important}
}

/* Compact top of the trading terminal */
.hdr{padding:8px 20px}
.atab{flex-direction:row;align-items:center;gap:7px;padding:6px 11px}
.asset-bar{padding:6px 18px;min-height:43px!important}
@media(max-width:880px){
  .mhdr{padding:6px 10px;gap:8px}
  .mhdr-logo svg{width:32px;height:32px}
  .mhdr-bal{min-width:0;flex-direction:row;justify-content:space-between;align-items:center;padding:4px 12px 4px 5px;border-radius:10px}
  .mhdr-tog button{padding:5px 10px}
  .mhdr-amt{font-size:14px}
  .mhdr-avatar,.mhdr-ham{width:40px!important;height:40px!important}
  .asset-pill-wrap{padding:5px 10px}
  .asset-pill{padding:6px 12px;gap:8px}
  .ap-logo{width:22px;height:22px;font-size:11px}
  .ap-name{font-size:14px}
}
@media(max-width:385px){
  /* not enough width for balance and DEMO/REAL side by side: stack them, tightly */
  .mhdr-bal{flex-direction:column;justify-content:center;gap:2px;padding:3px 6px}
  .mhdr-tog button{padding:4px 9px}
}

/* install-app buttons stay hidden until install.js shows them */
[data-install-app][hidden]{display:none!important}
[data-install-app] svg{flex-shrink:0;margin-right:6px}
