/* =============================================================================
   MLB mobile props toolbar (<=1000px)
   Markup: static/js/mlb/mlb-workbench-section/mlbPropsToolbar.js
   Replaces the six-tab "By X" row with [Game][Market][Sort] + chips.
   Prop-card styling is deliberately untouched.

   SIZING NOTE — READ BEFORE TWEAKING ANY FONT SIZE HERE.
   templates/index.html ships NO <meta name="viewport">, so phones lay this page
   out at a ~980px virtual width and the browser scales it down (~0.44x on a
   430px device). Every px below is therefore a LAYOUT px worth well under half
   a device px. The prop cards next door run ~30px body text for that reason;
   anything sized "normally" (14-20px) renders as unreadable, untappable specks.
   Match the cards, not your instincts.
   ============================================================================= */

/* ── STICKY ENABLERS ─────────────────────────────────────────────────────────
   position:sticky fails silently if ANY ancestor is a scroll container. Two
   ancestors disqualify it here:

     1. core/style.css sets `html,body{overflow-x:hidden}`. When one axis is
        hidden the other computes to `auto`, making the root a scroll container.
        `clip` suppresses overflow identically WITHOUT creating one. Same fix,
        same reasoning, as mlb-pickem.css:16-27. Scoped to the workbench via the
        html class the toolbar module sets, so no other page changes.
     2. `.glass-panel{overflow:hidden}` (workbench.css:874) is a direct ancestor
        of #props-filter-section. It carries no id (it WRAPS
        #suggested-legs-column), and mixing `overflow-x:clip` with
        `overflow-y:hidden` still leaves a scrollport — both axes must be clip.
        `clip` paints identically to `hidden`, it just isn't scrollable.        */
html.is-mlb-wb,
html.is-mlb-wb body {
  overflow-x: clip;
}

@media (max-width: 1000px) {
  html.is-mlb-wb .glass-panel {
    overflow: clip;
  }
}

/* Body scroll lock while a sheet is open (position:fixed form — a plain
   overflow:hidden on body is a no-op because html owns the scroll here). */
body.mpt-locked {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
}

/* ── Legacy tab row: hidden, not removed (shared code still queries it) ────── */
@media (max-width: 1000px) {
  .mpt-host .filter-mode-toggle,
  .mpt-host #props-game-filter,
  .mpt-host #props-market-filter,
  .mpt-host #props-position-filter,
  .mpt-host #props-defense-filter,
  .mpt-host #props-hitrate-filter,
  .mpt-host #props-grade-filter,
  .mpt-host #props-rate-filter,
  .mpt-host #props-form-filter {
    display: none !important;
  }
}

/* ── Separator + section heading (non-sticky sibling of the bar) ─────────── */
.mpt-sep { display: none; }

@media (max-width: 1000px) {
  .mpt-sep {
    display: block;
    margin-top: 4px;
    padding-top: 24px;
    /* 2px, not 1px: at the page's ~0.44x scale a 1px layout border lands on
       ~0.44 device px and antialiases away to almost nothing. */
    border-top: 2px solid rgba(255, 255, 255, 0.16);
  }
  /* .pf-section-title is 20px at mobile (buildLogic.css:1315); nudged up so it
     doesn't read as undersized beside the 36px toolbar directly below it. */
  .mpt-sep .mpt-title {
    font-size: 24px;
    margin-bottom: 6px;
  }
}

/* ── Toolbar ─────────────────────────────────────────────────────────────── */
.mpt { display: none; }

@media (max-width: 1000px) {
  .mpt {
    display: block;
    position: sticky;
    top: 0;
    z-index: 30;
    /* Bleed the sticky background to the panel edges with negative margins,
       NOT box-shadow. A spread shadow paints above the bar too and covered the
       "Available Props" heading sitting directly over it. 12px matches
       #suggested-legs-column's mobile padding (workbench.css:1556-1562). */
    margin: 0 -12px 14px;
    padding: 14px 12px 12px;
    background: var(--theme-bg-base, #0a0e14);
  }

  /* Centered, and wrapping rather than scrolling — a horizontally scrollable
     row cannot be centered without hiding the first item off the left edge. */
  .mpt-bar {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 16px;
  }

  .mpt-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    /* +50% over the first pass. 102px of layout height is ~45 device px once
       the page's ~0.44x scale is applied — i.e. an actual 44px touch target.
       Sized against the prop card's STATS box (min-height:79px, 1.5rem). */
    /* Settled after three passes: 30px read as a speck on device, 45px was
       overbearing, 38px still a touch heavy, 34px a shade light. 82px tall is
       ~36 device px once the page's ~0.44x scale applies. Horizontal padding
       stays tight so the three labels hold ONE centred line at 980px —
       wrapping costs more height than the bar saves. */
    min-height: 82px;
    padding: 17px 27px;
    min-width: 0;
    border-radius: 17px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.035);
    color: #cdd5df;
    font-family: inherit;
    font-size: 36px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
  }
  .mpt-btn.is-set {
    border-color: rgba(2, 210, 167, 0.5);
    background: rgba(2, 210, 167, 0.12);
    color: #7ee0c0;
  }
  .mpt-caret { font-size: 26px; opacity: 0.7; }
  .mpt-badge {
    min-width: 42px;
    padding: 6px 13px;
    border-radius: 999px;
    background: #02d2a7;
    color: #04120e;
    font-size: 28px;
    font-weight: 800;
    text-align: center;
  }

  /* ── Active-selection chips ── */
  .mpt-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 18px;
  }
  .mpt-chip {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-height: 54px;
    padding: 12px 20px;
    border-radius: 999px;
    border: 1px solid rgba(2, 210, 167, 0.38);
    background: rgba(2, 210, 167, 0.12);
    color: #7ee0c0;
    font-family: inherit;
    font-size: 26px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
  }
  .mpt-chip i { font-size: 23px; opacity: 0.8; }
  .mpt-clear {
    display: inline-flex;
    align-items: center;
    min-height: 54px;
    padding: 12px 18px;
    border: 0;
    background: none;
    color: #d98c8c;
    font-family: inherit;
    font-size: 26px;
    font-weight: 600;
    cursor: pointer;
  }
}

/* ── Bottom sheet ────────────────────────────────────────────────────────── */
/* z-index must clear the parlay pill (10050) which owns the same bottom edge;
   2147483645/6 is the tier the repo's other modals already use. */
.mpt-sheet-wrap {
  position: fixed;
  inset: 0;
  z-index: 2147483645;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.mpt-sheet-bd {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.mpt-sheet-wrap.open .mpt-sheet-bd { opacity: 1; }

/* Edge to edge — no side gutters. */
.mpt-sheet {
  position: relative;
  z-index: 2147483646;
  width: 100%;
  max-width: none;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: #0d1014;
  border-top: 1px solid #202730;
  border-radius: 34px 34px 0 0;
  transform: translateY(100%);
  transition: transform 0.26s cubic-bezier(0.32, 0.72, 0, 1);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  overflow: hidden;
}
.mpt-sheet-wrap.open .mpt-sheet { transform: translateY(0); }

.mpt-sheet-head {
  flex: 0 0 auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 26px 18px;
}
.mpt-grip {
  position: absolute;
  top: 14px; left: 50%;
  transform: translateX(-50%);
  width: 66px; height: 7px;
  border-radius: 999px;
  background: #2b333d;
}
.mpt-sheet-title {
  margin: 24px 0 0;
  font-size: 34px;
  font-weight: 700;
  color: #e7ebf0;
}
.mpt-sheet-x {
  margin-top: 24px;
  min-width: 56px; min-height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  background: none;
  border: 0;
  color: #8b95a1;
  font-size: 36px;
  line-height: 1;
  cursor: pointer;
}

.mpt-sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0 26px 10px;
}

/* ── Option rows ── */
.mpt-opts { display: flex; flex-direction: column; }
.mpt-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  min-height: 96px;
  padding: 20px 4px;
  border: 0;
  border-bottom: 1px solid #1a2029;
  background: none;
  color: #cdd5df;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.mpt-opt:last-child { border-bottom: 0; }
.mpt-opt-txt { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.mpt-opt-lbl { font-size: 30px; font-weight: 600; }
.mpt-opt-sub { font-size: 23px; color: #7e8894; }
.mpt-opt.on .mpt-opt-lbl { color: #7ee0c0; }

.mpt-tick {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  border-radius: 11px;
  border: 2px solid #2b333d;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  font-size: 22px;
}
.mpt-opt.on .mpt-tick {
  background: #02d2a7;
  border-color: #02d2a7;
  color: #04120e;
}

/* ── Game rows: [logo] Nickname @ Nickname [logo], all on one line ── */
.mpt-opt--game { align-items: center; }
.mpt-game {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
}
.mpt-team-logo {
  width: 48px; height: 48px;
  flex: 0 0 auto;
  object-fit: contain;
}
.mpt-team-name {
  font-size: 30px;
  font-weight: 600;
  color: #e7ebf0;
  white-space: nowrap;
}
.mpt-opt--game.on .mpt-team-name { color: #7ee0c0; }
.mpt-at {
  font-size: 24px;
  font-weight: 700;
  color: #5f6874;
  padding: 0 2px;
}
.mpt-game-right {
  display: flex;
  align-items: center;
  gap: 20px;
  flex: 0 0 auto;
}
.mpt-game-time {
  font-size: 24px;
  color: #7e8894;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ── Sort direction ── */
.mpt-dir { padding: 24px 4px 8px; }
.mpt-dir.is-disabled { opacity: 0.4; pointer-events: none; }
.mpt-dir-lbl {
  font-size: 22px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #7e8894;
  margin-bottom: 14px;
}
.mpt-seg { display: flex; gap: 12px; }
.mpt-seg-btn {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 78px;
  padding: 18px 14px;
  border-radius: 16px;
  border: 1px solid #2b333d;
  background: rgba(255, 255, 255, 0.02);
  color: #98a2b3;
  font-family: inherit;
  font-size: 25px;
  font-weight: 600;
  cursor: pointer;
}
.mpt-seg-btn.on {
  border-color: #02d2a7;
  background: rgba(2, 210, 167, 0.12);
  color: #7ee0c0;
}

.mpt-note {
  margin: 20px 4px 0;
  font-size: 23px;
  line-height: 1.45;
  color: #6b7480;
}
.mpt-empty { padding: 40px 4px; color: #6b7480; font-size: 28px; }

/* ── Sheet footer ── */
.mpt-sheet-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 26px 26px;
  border-top: 1px solid #1a2029;
}
.mpt-sheet-clear {
  min-height: 68px;
  padding: 0 8px;
  background: none;
  border: 0;
  color: #d98c8c;
  font-family: inherit;
  font-size: 28px;
  font-weight: 600;
  cursor: pointer;
}
.mpt-sheet-done {
  min-height: 68px;
  padding: 0 48px;
  border-radius: 16px;
  border: 0;
  background: #02d2a7;
  color: #04120e;
  font-family: inherit;
  font-size: 28px;
  font-weight: 800;
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
