/* lineup.css — team lineup page */

.lineup-state {
  max-width: 36em;
  margin: 4em auto;
  padding: 2em 1.5em;
  text-align: center;
}
.lineup-state-icon { font-size: 2.5rem; margin-bottom: 0.5em; }
.lineup-state-title {
  font-family: 'Oswald', sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.5em;
}
.lineup-state-body { font-size: var(--text-md); color: var(--text-mute); line-height: 1.6; }

.lineup-wrap {
  max-width: 52em;
  margin: 0 auto;
  padding: 1.2em 1em 4em;
}
.lineup-team-header {
  display: flex;
  align-items: baseline;
  gap: 0.75em;
  margin-bottom: 1.4em;
  padding-bottom: 0.75em;
  border-bottom: 0.07em solid var(--border);
}
.lineup-team-label {
  font-family: 'Oswald', sans-serif;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.lineup-team-name {
  font-family: 'Oswald', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--gold-lt);
  letter-spacing: 0.05em;
}

/* ── Tool bar (Import / Reorder) ── */
.lineup-tools {
  display: flex;
  justify-content: space-between;
  gap: 0.6em;
  margin-bottom: 0.75em;
}
.lineup-tool-btn {
  font-family: 'Oswald', sans-serif;
  font-size: var(--btn-font-size);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: var(--btn-pad-v) var(--btn-pad-h);
  border-radius: var(--radius-xs);
  border: 0.07em solid var(--border);
  background: var(--surface2);
  color: var(--text-dim);
  cursor: pointer;
}
.lineup-tool-btn:hover { opacity: 0.8; }
.lineup-tool-btn--right { margin-left: auto; }
.lineup-tool-btn--import { border-color: var(--blue-lt); color: var(--blue-lt); }
.lineup-tool-btn--reorder { border-color: var(--lose-color); color: var(--lose-color); }
.lineup-tool-btn--done { border-color: var(--win-color); color: var(--win-color); }
.lineup-tool-btn--cancel { color: var(--lose-color); border-color: var(--lose-color); }
.lineup-tool-btn--cancel:hover { opacity: 0.8; }

/* ── Reorder drag-and-drop ── */
.lineup-drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-mute);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
  min-width: 1.4em;
  padding: 0 0.15em;
}
.lineup-drag-handle::before { content: '⠿'; font-size: 1.1rem; line-height: 1; }
.lineup-drag-handle:hover { color: var(--text-dim); }
.lineup-row.drop-before { box-shadow: 0 -3px 0 0 var(--blue-lt); }
.lineup-row.drop-after  { box-shadow: 0  3px 0 0 var(--blue-lt); }

/* ── Import modal ── */
.lineup-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
}
.lineup-modal {
  background: var(--surface);
  border: 0.07em solid var(--border);
  border-radius: 0.5em;
  padding: 1.5em 1.4em 1.2em;
  width: min(90vw, 22em);
  display: flex;
  flex-direction: column;
  gap: 1em;
}
.lineup-modal-title {
  font-family: 'Oswald', sans-serif;
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--blue-lt);
}
.lineup-modal-body { display: flex; flex-direction: column; gap: 0.4em; }
.lineup-modal-label {
  font-size: var(--text-sm);
  color: var(--text-mute);
  font-family: 'Barlow', sans-serif;
}
.lineup-modal-sel {
  width: 100%;
  font-family: 'Barlow', sans-serif;
  font-size: max(1rem, 16px);
  font-weight: 500;
  padding: 0.5em 0.5em;
  border-radius: 0.25em;
  border: 0.07em solid var(--border);
  background: var(--surface2);
  color: var(--text);
}
.lineup-modal-footer {
  display: flex;
  gap: 0.6em;
  justify-content: flex-end;
}

.lineup-form-wrap { overflow-x: auto; }

.lineup-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Barlow', sans-serif;
  /* Deterministic column widths instead of the browser's own auto-layout
     heuristic, which sizes columns from CONTENT and can legitimately
     differ between rendering engines for two tables that don't share the
     same column set (owner, 2026-08-02: "make roster more visually
     similar to lineup... this has limited visual continuity") — order/
     num/pos already carry explicit widths, so table-layout:fixed just
     means Name (the one column with none) reliably gets "the rest",
     rather than a value that can drift with what's actually typed into
     the other cells. */
  table-layout: fixed;
}
.lineup-th {
  font-family: 'Oswald', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0.4em 0.5em 0.6em;
  text-align: left;
  border-bottom: 0.12em solid var(--gold);
}
.lineup-th--order { width: 2rem; text-align: center; }
/* # and Position keep small fixed widths, same as before the 2026-08-02
   resize; Name gets no explicit width so it fills whatever's left — a much
   bigger share than a flat 1/2 (owner, 2026-08-02: "make the player name
   field a little wider... what were those widths?"). Shared by the Lineup
   tab's own header and the roster editor, which reuses these same classes
   on purpose (owner, 2026-08-02: "roster should functionally reuse the
   lineup css"). */
/* rem, not em: table-layout:fixed (below) resolves a column's width from
   its FIRST-ROW (header) cell, and .lineup-th's font-size (0.7rem) is
   smaller than a data row's — an em-based width here would shrink every
   column to fit that smaller header font instead of the body rows these
   sizes were actually chosen for, clipping "1st"/demo/"2nd"/demo/"3rd" in Position's
   own <select>. rem is relative to the root, not whichever row happens to
   be measured. */
.lineup-th--num   { width: 5rem; }
.lineup-th--pos   { width: 5.5rem; }

.lineup-row { border-bottom: 0.07em solid var(--border); }
.lineup-row:last-child { border-bottom: none; }

.lineup-td-order {
  text-align: center;
  padding: 0.4em 0.3em;
  width: 2rem;
}
/* The delete cell holds only .roster-del, which already carries its own
   horizontal padding (0.5rem, a comfortable tap target) — stacking the
   TD's padding on top of that left no room in the 2rem column, so the
   button overflowed its own cell by a few px and widened the whole table
   past its container, forcing a spurious horizontal scrollbar on desktop
   (owner, 2026-08-02: "don't know why the scroll bar exists on the bottom.
   This is the roster tab"). Zero the TD's horizontal padding here instead
   of widening the column — the button was never cramped, just double-padded. */
.lineup-td-order--del { padding-left: 0; padding-right: 0; }
.lineup-order {
  font-family: 'Oswald', sans-serif;
  font-size: var(--text-xs);
  color: var(--text-mute);
  font-weight: 600;
}
.lineup-td-num   { padding: 0.35em 0.4em; width: 5rem; }
.lineup-td-name  { padding: 0.35em 0.4em; }
.lineup-td-pos   { padding: 0.35em 0.4em; width: 5.5rem; }

.lineup-row--sub { background: var(--surface2); }
.lineup-sub-tag {
  font-family: 'Oswald', sans-serif;
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.lineup-inp {
  font-family: 'Barlow', sans-serif;
  font-size: max(1rem, 16px);
  font-weight: 500;
  width: 100%;
  padding: 0.4em 0.5em;
  border-radius: 0.25em;
  border: 0.07em solid var(--border);
  background: var(--surface2);
  color: var(--text);
  box-sizing: border-box;
}
.lineup-inp:focus { outline: 0.13em solid var(--blue-lt); border-color: var(--blue-lt); }
.lineup-inp--num  { text-align: center; font-weight: 700; }
/* Every tap opens the player picker now, filled or blank (owner, 2026-08-02)
   — cursor:pointer says "tap opens something" rather than reading as a
   normal text field. */
.lineup-inp--name { cursor: pointer; }

/* ── Player picker (lineup.js openLineupPlayerPicker) ──────────────────── */
.lineup-picker { width: min(92vw, 24em); max-height: 80vh; }
.lineup-picker-list {
  display: flex;
  flex-direction: column;
  gap: 0.35em;
  overflow-y: auto;
  max-height: 50vh;
}
.lineup-picker-item {
  display: flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.6em 0.7em;
  border: 0.07em solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface2);
  color: var(--text);
  font-family: 'Barlow', sans-serif;
  font-size: var(--text-md);
  cursor: pointer;
  text-align: left;
}
.lineup-picker-item:hover { border-color: var(--blue-lt); }
.lineup-picker-item--current { border-color: var(--gold); }
/* Name flexes to fill whatever's left between the two — jersey # on the
   left, roster position on the far right in the SAME style (owner,
   2026-08-02: "put the players roster position on the far right hand
   side... using the same font style as the jersey number"). */
.lineup-picker-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lineup-picker-num { color: var(--text-mute); font-size: var(--text-sm); flex-shrink: 0; }
.lineup-picker-item--add { color: var(--win-color); border-color: var(--win-color); justify-content: center; }
.lineup-picker-empty { color: var(--text-mute); font-size: var(--text-sm); padding: 0.5em 0; }
@media (pointer: coarse) { .lineup-picker-item { min-height: 44px; } }

.lineup-sel {
  font-family: 'Barlow', sans-serif;
  font-size: max(1rem, 16px);
  font-weight: 500;
  width: 100%;
  padding: 0.4em 0.3em;
  border-radius: 0.25em;
  border: 0.07em solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  box-sizing: border-box;
}
.lineup-sel:focus { outline: 0.13em solid var(--blue-lt); }

.lineup-actions {
  display: flex;
  align-items: center;
  gap: 0.8em;
  margin-top: 1.4em;
  padding-top: 1em;
  border-top: 0.07em solid var(--border);
}
/* lineup-submit-btn: base styles from base.css primary-button rule */
.lineup-submit-btn { padding: var(--btn-pad-v) 1.6em; }

.lineup-sub-add-btn,
.lineup-sub-del-btn {
  font-family: 'Oswald', sans-serif;
  font-size: var(--btn-font-size);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: var(--btn-pad-v) 1.2em;
  border-radius: var(--radius-xs);
  background: transparent;
  cursor: pointer;
}
.lineup-sub-add-btn {
  border: 0.07em solid var(--win-color);
  color: var(--win-color);
}
.lineup-sub-add-btn:hover { opacity: 0.8; }
.lineup-sub-del-btn {
  border: 0.07em solid var(--lose-color);
  color: var(--lose-color);
}
.lineup-sub-del-btn:hover { opacity: 0.8; }
.lineup-sub-del-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.lineup-status {
  font-size: 0.82rem;
  font-weight: 600;
}

@media (max-width: 720px) {
  /* Both th and td: table-layout:fixed reads column width from the header
     row, so overriding only the td here would have no visible effect. */
  .lineup-th--num, .lineup-td-num { width: 3.5rem; }
  .lineup-inp--num { padding: 0.4em 0.2em; }
}

/* ── Selector row: team + game side by side ── */
.lineup-selectors-row {
  display: flex;
  gap: 0.75em;
  margin-bottom: 0.75em;
}
.lineup-sel-half {
  flex: 1;
  min-width: 0;
}

/* ── Game info / selector box ── */
.lineup-game-info {
  display: flex;
  align-items: center;
  padding: 0.55em 0.75em;
  background: var(--surface2);
  border-radius: var(--radius-xs);
  border: 0.07em solid var(--border);
  min-height: 2.4em;
}

/* Select filling the info box — explicit bg needed; native selects ignore 'transparent' in dark mode */
.lineup-game-sel {
  width: 100%;
  background: var(--surface2);
  border: none;
  color: var(--text);
  font-family: 'Oswald', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  -webkit-appearance: auto;
  appearance: auto;
}
.lineup-game-sel:focus { outline: 0.13em solid var(--blue-lt); }

.lineup-game-sel-placeholder {
  font-family: 'Barlow', sans-serif;
  font-size: 0.82rem;
  color: var(--text-mute);
  font-style: italic;
}

@media (max-width: 720px) {
  .lineup-selectors-row { flex-direction: column; gap: 0.5em; }
}

/* ── Read-only badge ── */
.lineup-readonly-badge {
  font-family: 'Oswald', sans-serif;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-mute);
  background: var(--surface2);
  border: 0.07em solid var(--border);
  border-radius: 0.25em;
  padding: 0.35em 0.7em;
  margin-bottom: 0.75em;
  display: inline-block;
}

/* ── Sign-out button ── */
.lineup-signout-btn {
  font-family: 'Oswald', sans-serif;
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.5em 1.1em;
  border-radius: var(--radius-xs);
  border: 0.07em solid var(--border);
  background: transparent;
  color: var(--text-mute);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.lineup-signout-btn:hover { color: var(--lose-color); border-color: var(--lose-color); }

/* ── No-game message ── */
.lineup-no-game {
  font-family: 'Barlow', sans-serif;
  font-size: var(--text-md);
  color: var(--text-mute);
  padding: 1.5em 0;
}

/* ── Navigation tab bar (injected by JS, shown after session check) ── */
.lineup-nav {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.lineup-nav-tab {
  flex: 1;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  text-align: center;
  padding: 0.85em 0.3em;
  font-family: 'Oswald', sans-serif;
  font-size: clamp(0.78rem, 1.5vw, 0.95rem);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 0.18em solid transparent;
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.lineup-nav-tab:hover { color: var(--text); }
.lineup-nav-tab.active { color: var(--blue-lt); border-bottom-color: var(--blue-lt); }
.lineup-nav-tab .tab-icon { display: none; }

/* ════════════════════════════════════════════════════════════
   MOBILE — locked flex column, nav at bottom
   ════════════════════════════════════════════════════════════ */
@media (max-width: 1023px) {
  html { height: 100svh; height: var(--app-h, 100svh); }
  body { height: 100svh; height: var(--app-h, 100svh); overflow: hidden; display: flex; flex-direction: column; }
  .site-header { flex-shrink: 0; }

  /* Scrollable content fills remaining space between header and nav */
  #lineupLoading,
  #lineupInvalid { flex: 1; overflow-y: auto; }
  #lineupContent {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    scrollbar-width: none;
  }
  #lineupContent::-webkit-scrollbar { display: none; }

  /* Prevent iOS Safari zoom on input focus */
  .lineup-inp,
  .lineup-sel,
  .lineup-game-sel {
    font-size: var(--text-lg);
  }
}

/* ── Touch target sizing (coarse pointer = touchscreen) ── */
@media (pointer: coarse) {
  .lineup-tool-btn    { min-height: 2.75rem; }
  .lineup-submit-btn  { min-height: 2.75rem; }
  .lineup-sub-add-btn { min-height: 2.75rem; }
  .lineup-sub-del-btn { min-height: 2.75rem; }
  /* reorder drag handle cell — widen the grab area */
  .lineup-td-order--reorder { min-width: 2.75rem; }
}

/* ── Roster: number column ─────────────────────────────────────────────
   One number per player now — a per-game exception is handled in the
   lineup tab instead of a comma list here (owner, 2026-08-02: "only accept
   one number [in the roster] (they can change for one jersey in the
   lineup tab)"). No roster-only width/alignment override anymore — the
   roster's # header uses .lineup-th--num directly (not a mirrored
   .lineup-th--nums) and the input carries no extra rule beyond
   .lineup-inp--num, so it's the SAME css as lineup, not a copy of it
   (owner, 2026-08-02: "Roster should use the same css as lineup"). */

/* Two PLAYERS sharing a number is allowed and saves fine; it only means a
   lineup cannot autofill from that number. So this is a hint, not an error
   state — amber rather than red, and never blocking. */
.roster-jerseys--dup {
  border-color: var(--warn, #b8860b);
  background: var(--warn-bg, rgba(184, 134, 11, 0.1));
}
.roster-dup-note {
  color: var(--text-dim);
  font-size: var(--text-sm);
  line-height: 1.4;
  margin: 0.6rem 0 0;
}

/* ── Roster row remove button ──────────────────────────────────────────
   Sits in the order column, which the roster has no other use for (a squad
   list has no batting order). Deliberately quiet until hovered: it deletes a
   player, and on a phone it sits under the thumb that is trying to type. */
.roster-del {
  background: none;
  border: 1px solid transparent;
  border-radius: 0.35rem;
  color: var(--text-dim);
  cursor: pointer;
  font-size: var(--text-base);
  line-height: 1;
  padding: 0.35rem 0.5rem;
}
.roster-del:hover,
.roster-del:focus-visible {
  background: var(--danger-bg, rgba(220, 60, 60, 0.12));
  border-color: var(--danger, #c33);
  color: var(--danger, #c33);
}

@media (pointer: coarse) {
  /* Touch (phone web + PWA) uses swipe-to-delete instead — the ✕ is an easy
     mis-tap next to the row it's about to remove, right where a thumb rests
     while typing (owner, 2026-08-02: "remove the x ... on mobile and pwa").
     Desktop (mouse/trackpad, pointer:fine) keeps the ✕, now confirmed too. */
  .roster-del { display: none; }
  /* The cell the ✕ sits in collapses too, not just the button — otherwise
     it's a dead reserved column and Name/Position stay narrower on touch
     than the Lineup tab's own columns for no reason anyone can see there
     (owner, 2026-08-02: "it's like you're still leaving room for the
     delete button... the look should be identical from one tab to the
     next" — Lineup never had this trailing column to begin with). */
  .lineup-td-order--del, .lineup-th--order--del { display: none; }
}

/* Swipe-armed feedback (coach.js wireRosterRowSwipe): past the delete
   threshold, the row tints red so lifting the finger reads as "about to
   remove" rather than an unexplained shift. */
.roster-row--armed { background: var(--danger-bg, rgba(220, 60, 60, 0.12)); }
