/* The league picker: the multi-sport design's "בוחר ליגה אחד" board (owner, 19.11.2026), js/league_picker.js.
   A button in place of the native league select; the sheet it opens comes up from the bottom on a phone and sits as a
   panel in the middle of a wide screen. Colours from the site's tokens (design_system.css), both themes. */

html[data-theme] {
  --lp-scrim: rgba(15, 34, 71, .55);
  --lp-mark: #F5D77A;                 /* the matched letters in a search */
  --lp-on: color-mix(in srgb, var(--ds-ink) 6%, var(--ds-card));
}
html[data-theme="dark"] {
  --lp-scrim: rgba(2, 6, 16, .7);
  --lp-mark: rgba(245, 215, 122, .32);
}

/* The native select stays in the page as the list of leagues, out of sight. */
html[data-theme] .lg-select[hidden] { display: none; }

/* ── The button ── */
.lp-trig {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 200px;
  max-width: 100%;
  min-height: 46px;
  padding: 0 12px;
  box-sizing: border-box;
  border: 1.5px solid var(--ds-ink);
  border-radius: 0;
  background: var(--ds-card);
  color: var(--ds-ink);
  font: 800 16px/1.2 var(--ds-font);
  text-align: start;
  cursor: pointer;
}
.lp-trig:focus-visible { outline: 2px solid var(--ds-ink); outline-offset: 2px; }
.lp-trig-sq { flex: none; width: 14px; height: 14px; }
.lp-trig-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp-trig svg { flex: none; margin-inline-start: auto; }
.dn-bar2 .lp-trig { width: 100%; min-width: 0; }

/* ── The sheet ── */
.lp-scrim {
  position: fixed;
  inset: 0;
  z-index: 9600;
  background: var(--lp-scrim);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--ds-t-layer) ease, visibility 0s linear var(--ds-t-layer);
}
.lp-scrim.is-open { opacity: 1; visibility: visible; transition: opacity var(--ds-t-layer) ease; }

.lp-sheet {
  position: fixed;
  z-index: 9601;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--ds-card);
  color: var(--ds-ink);
  border-top: 3px solid var(--ds-ink);
  font-family: var(--ds-font);
  transform: translateY(100%);
  visibility: hidden;
  transition: transform var(--ds-t-layer) ease, visibility 0s linear var(--ds-t-layer);
}
.lp-sheet.is-open { transform: none; visibility: visible; transition: transform var(--ds-t-layer) ease; }

.lp-grab { display: flex; justify-content: center; padding-top: 8px; }
.lp-grab span { width: 40px; height: 4px; background: var(--ds-line); }

.lp-head { display: flex; align-items: center; gap: 8px; padding-block: 6px 8px; padding-inline: 16px 8px; }
.lp-ht { display: flex; flex-direction: column; min-width: 0; }
.lp-ht h2 { margin: 0; font: 900 20px/1.2 var(--ds-font); color: var(--ds-ink); }
.lp-ctx { margin: 0; font: 400 12px/1.4 var(--ds-font); color: var(--ds-ink2); }
.lp-x {
  flex: none;
  width: 44px;
  height: 44px;
  margin-inline-start: auto;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--ds-ink);
  cursor: pointer;
}

.lp-search { padding: 0 12px 10px; }
.lp-search[hidden] { display: none; }
.lp-search label {
  height: 46px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  box-sizing: border-box;
  border: 1.5px solid var(--ds-ink);
  color: var(--ds-ink);
}
.lp-search label:focus-within { outline: 2px solid var(--ds-ink); outline-offset: 2px; }
.lp-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ds-ink);
  font: 600 16px/1.2 var(--ds-font);
}
.lp-search input::placeholder { color: var(--ds-ink2); font-weight: 500; }
.lp-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.lp-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: env(safe-area-inset-bottom); }

.lp-group--rule { border-top: 1px solid var(--ds-line); }
.lp-gh {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 10px 16px 6px;
  font: 900 13px/1.3 var(--ds-font);
  letter-spacing: .02em;
  color: var(--ds-ink);
}
.lp-gn { font: 700 15px/1 var(--ds-font-num); font-variant-numeric: tabular-nums; color: var(--ds-ink2); }

.lp-row {
  width: 100%;
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 16px;
  box-sizing: border-box;
  border: 0;
  border-top: 1px solid var(--ds-line);
  border-radius: 0;
  background: transparent;
  color: var(--ds-ink);
  font: inherit;
  text-align: start;
  cursor: pointer;
}
.lp-row:hover { background: var(--ds-soft); }
.lp-row:focus-visible { outline: 2px solid var(--ds-ink); outline-offset: -2px; }
/* the league on screen: a soft ground and a bar on the reading side */
.lp-row.is-on { background: var(--lp-on); box-shadow: inset -4px 0 0 var(--ds-ink); }
[dir="ltr"] .lp-row.is-on { box-shadow: inset 4px 0 0 var(--ds-ink); }

.lp-mark { flex: none; width: 24px; height: 24px; display: grid; place-items: center; }
.lp-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.lp-name { font: 800 16px/1.25 var(--ds-font); }
.lp-name mark { background: var(--lp-mark); color: inherit; }
.lp-sub { font: 400 12px/1.4 var(--ds-font); color: var(--ds-ink2); }
.lp-sub b { font-weight: 700; color: var(--ds-ink); }
.lp-mine { flex: none; padding: 1px 5px; border: 1px solid var(--ds-ink); font: 800 11px/1.3 var(--ds-font); }
.lp-end { flex: none; margin-inline-start: auto; display: flex; align-items: center; color: var(--ds-ink); }
.lp-chev { color: var(--ds-ink2); }

.lp-back {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ds-ink);
  font: 800 15px/1.2 var(--ds-font);
  text-align: start;
  cursor: pointer;
}
.lp-back:focus-visible { outline: 2px solid var(--ds-ink); outline-offset: -2px; }
.lp-none { margin: 0; padding: 24px 16px; font: 500 15px/1.5 var(--ds-font); color: var(--ds-ink2); }

html.lp-open, html.lp-open body { overflow: hidden; }

/* A wide screen: a panel in the middle instead of a sheet from the bottom. */
@media (min-width: 768px) {
  .lp-sheet {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 12vh;
    width: min(440px, calc(100vw - 32px));
    max-height: 76vh;
    border: 1.5px solid var(--ds-ink);
    border-top-width: 3px;
    box-shadow: 0 24px 60px rgba(12, 22, 48, .3);
    opacity: 0;
    transform: translate(-50%, 12px);
    transition: transform var(--ds-t-layer) ease, opacity var(--ds-t-layer) ease, visibility 0s linear var(--ds-t-layer);
  }
  .lp-sheet.is-open { opacity: 1; transform: translate(-50%, 0); transition: transform var(--ds-t-layer) ease, opacity var(--ds-t-layer) ease; }
  .lp-grab { display: none; }
  .lp-head { padding-top: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .lp-sheet, .lp-sheet.is-open, .lp-scrim, .lp-scrim.is-open { transition: none; }
}
