/* ============================================================
   FlashDex — phone layout

   Loaded last, so it wins. Most members open this on a phone, so
   below 900px the desktop rail is dropped entirely and replaced
   with the pattern people already know from every other app on
   their home screen: a fixed bottom tab bar, a compact sticky
   header carrying the one number they came to see, and a sheet
   for everything secondary.

   Sizing rules held throughout:
     · every tap target is at least 44px tall
     · nothing below 11px, ever
     · safe-area insets respected, so the tab bar clears the
       home indicator on a notched phone
     · content never scrolls sideways
   ============================================================ */

/* The phone chrome is un-hidden by JS on sign-in, so the hidden
   attribute cannot be what keeps it off a desktop. Without an explicit
   default the unstyled header renders its logo at full page width. */
.mtop,.tabbar,.sheet{display:none;}

@media (max-width: 900px) {

  /* ---------- frame ---------- */
  .shell{grid-template-columns:1fr;}
  .rail{display:none!important;}          /* replaced by .tabbar */

  .main{
    padding:12px 14px 96px;               /* bottom clears the tab bar */
    padding-bottom:calc(96px + env(safe-area-inset-bottom, 0px));
  }

  /* ---------- sticky top ---------- */
  /* :not([hidden]), not !important — see the note above .tabbar. */
  .mtop:not([hidden]){display:flex;}
  .mtop{
    align-items:center;gap:12px;
    position:sticky;top:0;z-index:40;
    padding:10px 14px;
    padding-top:calc(10px + env(safe-area-inset-top, 0px));
    background:rgba(7,6,14,.9);backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);
    border-bottom:1px solid var(--outline-variant);
  }
  /* ::after is the last flex child by DOM order, which would drop the
     wordmark to the right of the member code. Order pulls both to the
     left of everything else. */
  .mtop .mark{width:24px;height:24px;color:var(--primary);flex:none;order:-2;}
  .mtop-b{flex:1;min-width:0;display:flex;flex-direction:column;gap:1px;
    opacity:0;transform:translateY(4px);transition:.22s var(--ease);}
  .mtop.showv .mtop-b{opacity:1;transform:none;}
  .mtop-k{font:9.5px var(--mono);letter-spacing:.13em;text-transform:uppercase;color:var(--on-surface-variant);}
  .mtop-v{font:700 17px var(--font);letter-spacing:-.02em;color:var(--tertiary);
    font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
  /* before the hero scrolls away, the bar is just brand + member code */
  .mtop::after{content:"FlashDex";font:700 16px var(--font);letter-spacing:-.01em;
    margin-right:auto;transition:.22s var(--ease);order:-1;}
  .mtop.showv::after{opacity:0;position:absolute;pointer-events:none;}
  .mtop-code{font:11px var(--mono);color:var(--outline);flex:none;}

  /* the page title repeats the code already in the bar */
  .head h1{font-size:22px;}
  .main > .head > div > p{font-size:12.5px;}

  /* ---------- bottom tabs ---------- */
  /* JS un-hides these after sign-in. An !important display here
     outranked [hidden] and left the tab bar drawn across the bottom
     of the sign-in screen; :not([hidden]) still beats the desktop
     display:none without overriding the attribute. */
  .tabbar:not([hidden]){display:grid;}
  .tabbar{
    grid-template-columns:repeat(5,1fr);
    position:fixed;left:0;right:0;bottom:0;z-index:50;
    background:rgba(12,11,22,.95);backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);
    border-top:1px solid var(--outline-variant);
    padding-bottom:env(safe-area-inset-bottom, 0px);
  }
  .tab{
    display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;
    min-height:56px;padding:8px 4px;background:none;border:0;cursor:pointer;
    color:var(--on-surface-variant);transition:color .15s var(--ease);position:relative;
  }
  .tab .ic{width:20px;height:20px;}
  .tab span{font-size:10px;letter-spacing:.01em;}
  .tab.on{color:var(--primary);}
  .tab.on::before{
    content:"";position:absolute;top:0;left:50%;transform:translateX(-50%);
    width:26px;height:2px;border-radius:0 0 3px 3px;background:var(--primary);
  }
  .tab:active{background:rgba(255,255,255,.04);}

  /* ---------- the more sheet ---------- */
  .sheet{display:block;position:fixed;inset:0;z-index:60;}
  .sheet-bg{position:absolute;inset:0;background:rgba(0,0,0,.55);animation:fade .2s ease both;}
  .sheet-card{
    position:absolute;left:0;right:0;bottom:0;
    background:var(--surface-2);border-top:1px solid var(--outline-variant);
    border-radius:18px 18px 0 0;padding:10px 12px;
    padding-bottom:calc(14px + env(safe-area-inset-bottom, 0px));
    animation:slideUp .26s var(--ease) both;
  }
  .sheet-grip{display:block;width:38px;height:4px;border-radius:99px;
    background:var(--outline-variant);margin:4px auto 12px;}
  .sheet-i{
    display:flex;align-items:center;gap:14px;width:100%;min-height:56px;
    padding:12px 14px;border:0;border-radius:var(--r-m);background:none;
    color:var(--on-surface);font-size:15px;text-align:left;cursor:pointer;
    flex-wrap:wrap;
  }
  .sheet-i .ic{width:20px;height:20px;color:var(--primary);flex:none;}
  .sheet-i em{flex-basis:100%;padding-left:34px;font-style:normal;
    font-size:12px;color:var(--outline);margin-top:-6px;}
  .sheet-i:active{background:var(--surface-3);}
  .sheet-i.danger{color:var(--error);margin-top:4px;
    border-top:1px solid var(--outline-variant);border-radius:0;}
  .sheet-i.danger .ic{color:var(--error);}
  @keyframes fade{from{opacity:0}to{opacity:1}}
  @keyframes slideUp{from{transform:translateY(100%)}to{transform:none}}

  /* ---------- headers ---------- */
  .head{margin-bottom:16px;gap:12px;}
  .head h1{font-size:24px;}
  .head p{font-size:13px;}
  .head .row,.head .chain-tabs{width:100%;}
  .head .btn{flex:1;justify-content:center;min-height:44px;}

  /* ---------- grids: two up, not one ---------- */
  .tiles{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin-bottom:14px;}
  .tile{padding:13px 13px;}
  .tile .v{font-size:19px;margin-top:8px;}
  .tile .wm{width:58px;height:58px;right:-8px;bottom:-10px;}
  .tile .k{font-size:9.5px;letter-spacing:.09em;}
  .tile .d{font-size:9.5px;}

  .hero{grid-template-columns:1fr;gap:12px;}
  .panel{padding:15px 14px;margin-bottom:12px;}
  .panel > h2{font-size:15px;margin-bottom:14px;}
  .panel > h2 .chip{width:27px;height:27px;border-radius:8px;}

  .bignum{font-size:36px;}
  .pnl-main .bignum{font-size:34px;}

  /* the cap ring is decorative at this size — shrink, keep the number */
  .ring{gap:14px;margin:14px 0;}
  .ring svg{width:74px;height:74px;}
  .ring .pc{font-size:22px;}
  .ring .of{font-size:10.5px;}

  .spark{height:96px;}
  .bars{height:78px;gap:3px;}
  .bars-x{gap:3px;font-size:8.5px;}

  /* ---------- lists ---------- */
  .legend{grid-template-columns:1fr;gap:9px;}
  .strip{grid-template-columns:repeat(2,minmax(0,1fr));}
  .pkgs,.memgrid,.boosters,.lvlgrid{grid-template-columns:1fr;}
  .tiergrid{grid-template-columns:repeat(2,minmax(0,1fr));gap:9px;}
  .rankgrid{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;}
  .quote-grid{grid-template-columns:repeat(2,minmax(0,1fr));}

  /* feed rows drop the timestamp column and stack the amount */
  .fitem{padding:11px 12px;gap:11px;}
  .fwhen{display:none;}
  .famt{min-width:0;font-size:13px;}
  .ftx b{font-size:13px;}

  /* pyramid: the percentage and pill compete for room, so the pill goes */
  .pyr-q{display:none;}
  .pyr-l{min-width:28px;font-size:11px;}
  .pyr-pc{min-width:38px;font-size:11px;}
  .pyr-bar{height:24px;}

  /* buttons and inputs get real touch targets */
  .btn{min-height:44px;padding:11px 18px;}
  .btn-sm{min-height:36px;padding:8px 13px;}
  input,select{min-height:46px;font-size:16px;}   /* 16px stops iOS zooming on focus */
  .fchip{min-height:38px;padding:9px 14px;}

  /* tables scroll rather than squash */
  .tw{overflow-x:auto;-webkit-overflow-scrolling:touch;}
  .tw table{min-width:520px;}

  /* the sign-in gate */
  .gate{padding:18px;align-items:flex-start;padding-top:8vh;}
  .gate .box{padding:26px 20px;}
}

/* ---------- very small phones ---------- */
@media (max-width: 380px) {
  .tiles,.tiergrid,.rankgrid,.strip{grid-template-columns:1fr;}
  .tab span{font-size:9px;}
  .bignum{font-size:31px;}
  .main{padding-inline:11px;}
  .mtop-code{display:none;}
}

/* ---------- landscape phones: the tab bar would eat the view ---------- */
@media (max-width: 900px) and (max-height: 460px) {
  .tabbar{position:static;}
  .main{padding-bottom:20px;}
  .mtop{position:static;}
}
