/* ==========================================================
   EV PICKS — the pick table shared by the EV cheat sheet
   (/ev-cheat-sheet/:platform) and its hub (/ev-cheat-sheet).

   Desktop: a wide data table. Phones (768px and below): every row
   becomes a card, as on the projections board:

     Name                                     EV
     NBA · OKC vs DEN · 8:30 PM            +9.0%
     ───────────────────────────────────────────
     [OVER] 31.5 Points                     -112
     WIN %   1/4 KELLY                   [Bet ↗]

   Row markup contract (ev-cheat-sheet.js renderRow and the sample rows in
   both views): td-player holds .name and .ev-pick-meta; spread and
   moneyline lines carry .ev-line-team (and .ev-line-none for no line).
   Team, Opp, Date and Sport cells are folded into the meta line on cards.
   ========================================================== */

/* ===== TOKENS ===== */
:root {
  /* Translucent tints for bet-type and side chips, in the app's info blue,
     caution yellow and negative red. They tell chips apart; they aren't states. */
  --ev-tint-green: rgba(78, 235, 76, 0.4);
  --ev-tint-green-subtle: rgba(78, 235, 76, 0.15);
  --ev-tint-info: rgba(53, 133, 253, 0.4);
  --ev-tint-info-subtle: rgba(53, 133, 253, 0.08);
  --ev-tint-amber: rgba(236, 217, 74, 0.4);
  --ev-tint-amber-subtle: rgba(236, 217, 74, 0.08);
  --ev-tint-error: rgba(255, 77, 97, 0.4);
  --ev-tint-error-subtle: rgba(255, 77, 97, 0.08);
  --ev-tint-row-hover: rgba(78, 235, 76, 0.05);
}

@keyframes evShimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ===== CHIPS =====
   Neutral pill by default; spread/total and every side carry hue accents for
   scannability, kept off brand green except Over (up), so they never compete
   with the +EV signal. */
.ev-bet-type-chip,
.ev-side-chip {
  display: inline-block;
  max-width: 100%;
  padding: 3px 9px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid var(--surface-border-strong);
  background: var(--surface-hover);
  color: var(--surface-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.ev-bet-type-chip.ev-bet-type-moneyline { color: var(--surface-text); }
.ev-bet-type-chip.ev-bet-type-spread { color: var(--color-info-dark); border-color: var(--ev-tint-info); background: var(--ev-tint-info-subtle); }
.ev-bet-type-chip.ev-bet-type-total { color: var(--color-warning-dark); border-color: var(--ev-tint-amber); background: var(--ev-tint-amber-subtle); }

.ev-side-chip.ev-side-over { color: var(--color-primary); border-color: var(--ev-tint-green); background: var(--ev-tint-green-subtle); }
.ev-side-chip.ev-side-under { color: var(--color-error-dark); border-color: var(--ev-tint-error); background: var(--ev-tint-error-subtle); }
.ev-side-chip.ev-side-home { color: var(--color-info-dark); border-color: var(--ev-tint-info); background: var(--ev-tint-info-subtle); }
.ev-side-chip.ev-side-away { color: var(--color-warning-dark); border-color: var(--ev-tint-amber); background: var(--ev-tint-amber-subtle); }

/* ===== TABLE CONTAINER ===== */
.ev-table-scroll {
  overflow-x: auto;
  border-radius: 16px;
  border: 1px solid var(--surface-border);
  background: var(--surface-card);
  overscroll-behavior-x: contain;
}

.ev-table-scroll::-webkit-scrollbar { height: 8px; }
.ev-table-scroll::-webkit-scrollbar-track { background: var(--surface-card); }
.ev-table-scroll::-webkit-scrollbar-thumb { background: var(--surface-strong); border-radius: 4px; }
.ev-table-scroll::-webkit-scrollbar-thumb:hover { background: var(--surface-text-muted); }

/* ===== DATA TABLE (desktop) ===== */
.ev-table {
  width: 100%;
  min-width: 1280px;
  border-collapse: collapse;
  table-layout: fixed;
}

.ev-table thead {
  background: var(--surface-raised);
}

.ev-table thead th {
  padding: 14px 12px;
  text-align: left;
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--surface-text-tertiary);
  border-bottom: 1px solid var(--surface-border);
  white-space: nowrap;
}

/* The column the sheet is sorted by goes white, as on the projections board */
.ev-table thead th.sorted {
  color: var(--color-white);
  box-shadow: inset 0 -2px 0 var(--color-white);
}

.ev-table .th-player { width: 220px; }
.ev-table .th-ou { width: 95px; }
.ev-table .th-prop-type { width: 200px; }
.ev-table .th-line { width: 72px; }
.ev-table .th-odds { width: 76px; }
.ev-table .th-start { width: 125px; }
.ev-table .th-sport { width: 60px; }
.ev-table .th-win { width: 90px; }
.ev-table .th-ev { width: 90px; }
.ev-table .th-units { width: 90px; }
.ev-table .th-bet { width: 76px; }

.ev-table .th-team,
.ev-table .td-team,
.ev-table .th-opp,
.ev-table .td-opp {
  width: 64px;
  max-width: 64px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ev-table tbody tr {
  transition: background 0.15s ease, border-color 0.15s ease;
}

.ev-table tbody tr:hover {
  background: var(--ev-tint-row-hover);
}

.ev-table tbody td {
  padding: 14px 12px;
  font-family: var(--font-display);
  font-size: 0.9rem;
  color: var(--surface-text-secondary);
  border-bottom: 1px solid var(--surface-border);
  vertical-align: middle;
  white-space: nowrap;
}

.ev-table tbody tr:last-child td {
  border-bottom: none;
}

/* Matchup / player */
.ev-table .td-player .name {
  font-weight: 600;
  color: var(--surface-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.2s ease;
}

.ev-table tbody tr:hover .td-player .name {
  color: var(--color-primary);
}

.ev-table .td-player .name.linkable {
  color: var(--color-primary);
  text-decoration: underline;
  text-decoration-color: rgba(78, 235, 76, 0.3);
  text-underline-offset: 2px;
}

.ev-table .player-link {
  display: block;
  color: inherit;
  text-decoration: none;
  border-radius: 6px;
  padding: 2px 4px;
  margin: -2px -4px;
  transition: background 0.2s ease, transform 0.2s ease;
}

.ev-table .player-link:hover {
  background: rgba(78, 235, 76, 0.1);
  transform: translateX(2px);
}

.ev-table .player-link:hover .name.linkable {
  text-decoration-color: var(--color-primary);
}

.ev-table .player-link:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Only the cards show the meta line and the team on a spread / moneyline line */
.ev-pick-meta,
.ev-line-team {
  display: none;
}

/* Numbers */
.ev-table .num {
  text-align: right;
  font-family: var(--font-body);
  font-variant-numeric: tabular-nums;
}

.ev-table .td-prop-type {
  overflow: hidden;
  text-overflow: ellipsis;
}

.win-pct.win-high { color: var(--color-primary); font-weight: 800; }
.win-pct.win-med { color: var(--color-warning-dark); }
.win-pct.win-low { color: var(--color-error); }

.ev-pct.ev-high { color: var(--color-primary); font-weight: 800; }
.ev-pct.ev-med { color: var(--color-warning-dark); }
.ev-pct.ev-low { color: var(--color-error); }

.ev-table .units-high { color: var(--color-primary); font-weight: 800; }
.ev-table .units-low { color: var(--color-error); }

/* Bet deeplink: a green pill with ink type */
.ev-table .td-bet {
  text-align: center;
}

.ev-bet-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-full, 999px);
  background: var(--color-primary);
  color: var(--color-ink);
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.2s ease, transform 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.ev-bet-link:hover { background: var(--color-primary-400); }
.ev-bet-link:active { transform: scale(0.98); }

/* The button wears the row's EV colour (ev-cheat-sheet.js evClassFor), so a
   pick that has slipped below +EV doesn't keep a green Bet. */
.ev-bet-link.ev-med { background: var(--color-caution); }
.ev-bet-link.ev-low { background: var(--color-error); }
.ev-bet-link.ev-med:hover,
.ev-bet-link.ev-low:hover { filter: brightness(1.08); }

.ev-bet-link:focus-visible {
  outline: 2px solid var(--color-white);
  outline-offset: 2px;
}

/* ===== SAMPLE DATA ===== */
.ev-demo-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 10px 16px;
  background: rgba(78, 235, 76, 0.08);
  border: 1px solid rgba(78, 235, 76, 0.2);
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--color-primary);
  letter-spacing: 0.02em;
}

.ev-demo-badge svg {
  flex-shrink: 0;
}

.ev-table--blur {
  filter: blur(5px);
  user-select: none;
  pointer-events: none;
}

/* ===== SKELETON ===== */
.ev-sk {
  display: inline-block;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-raised) 25%, var(--surface-hover) 50%, var(--surface-raised) 75%);
  background-size: 200% 100%;
  animation: evShimmer 1.4s linear infinite;
  vertical-align: middle;
}

.ev-sk-name  { width: 150px; height: 13px; }
.ev-sk-meta  { width: 110px; height: 9px; }
.ev-sk-chip  { width: 52px; height: 20px; border-radius: 999px; }
.ev-sk-num   { width: 40px; }
.ev-sk-short { width: 32px; }
.ev-sk-type  { width: 96px; }
.ev-sk-btn   { width: 52px; height: 30px; border-radius: 999px; }

.ev-table .row-skeleton .ev-sk-meta { display: none; }

/* ===== EMPTY / ERROR ===== */
.ev-table .row-empty td {
  padding: 0;
  border-bottom: none;
  white-space: normal;
}

.ev-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding: 72px 24px;
}

.ev-empty-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--surface-text);
  margin: 0;
}

.ev-empty-body {
  font-family: var(--font-display);
  font-size: 0.9rem;
  color: var(--surface-text-tertiary);
  margin: 0;
}

.ev-empty-action,
.ev-show-more-btn {
  margin-top: 16px;
  min-height: 42px;
  padding: 0 20px;
  background: var(--surface-raised);
  color: var(--surface-text);
  border: 1px solid var(--surface-border-strong);
  border-radius: var(--radius-full, 999px);
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.ev-empty-action:hover,
.ev-show-more-btn:hover {
  border-color: var(--color-primary);
  background: var(--surface-hover);
}

.ev-show-more {
  display: flex;
  justify-content: center;
  padding: 8px 0 0;
}

/* ===== CARDS (phones) ===== */
@media (max-width: 768px) {
  .ev-table-scroll {
    overflow: visible;
    border: none;
    border-radius: 0;
    background: transparent;
  }

  .ev-table {
    display: block;
    width: 100%;
    min-width: 0;
    table-layout: auto;
  }

  .ev-table thead {
    display: none;
  }

  .ev-table tbody {
    display: grid;
    gap: 10px;
  }

  .ev-table tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 8px;
    background: var(--surface-card);
    border: 1px solid var(--surface-border);
    border-radius: 16px;
    padding: 12px 14px;
  }

  .ev-table tbody tr:hover {
    background: var(--surface-card);
    border-color: var(--surface-border-strong);
  }

  /* Divider under the matchup, and a line break before the numbers */
  .ev-table tbody tr::before {
    content: '';
    order: 1;
    flex-basis: 100%;
    height: 1px;
    margin: 10px 0;
    background: var(--surface-border);
  }

  .ev-table tbody tr::after {
    content: '';
    order: 3;
    flex-basis: 100%;
    height: 0;
    margin-bottom: 10px;
  }

  .ev-table tbody td {
    display: block;
    padding: 0;
    border: none;
    font-size: 0.9rem;
    overflow: visible;
  }

  /* Folded into the meta line */
  .ev-table .td-team,
  .ev-table .td-opp,
  .ev-table .td-start,
  .ev-table .td-sport {
    display: none;
  }

  /* --- Row 1: who + EV --- */
  .ev-table .td-player {
    order: 0;
    flex: 1 1 0;
    min-width: 0;
    white-space: normal;
  }

  .ev-table .td-player .name,
  .ev-table .td-player .name.linkable {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    white-space: normal;
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.01em;
    color: var(--surface-text);
    text-decoration: none;
  }

  .ev-table tbody tr:hover .td-player .name {
    color: var(--surface-text);
  }

  .ev-table .player-link {
    padding: 0;
    margin: 0;
    border-radius: 4px;
  }

  .ev-table .player-link:hover {
    background: transparent;
    transform: none;
  }

  .ev-table .player-link:hover .name,
  .ev-table .player-link:active .name {
    color: var(--color-primary);
  }

  .ev-pick-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    min-width: 0;
    overflow: hidden;
    font-family: var(--font-body);
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    line-height: 1.3;
    color: var(--surface-text-tertiary);
    white-space: nowrap;
  }

  .ev-pick-meta > span {
    flex-shrink: 0;
  }

  .ev-pick-meta > span:last-child {
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .ev-pick-meta > span + span::before {
    content: '';
    display: inline-block;
    width: 3px;
    height: 3px;
    margin-right: 6px;
    border-radius: 50%;
    background: var(--surface-text-muted);
    vertical-align: middle;
  }

  .ev-pick-meta .ev-pick-sport {
    font-weight: 700;
    color: var(--surface-text-secondary);
  }

  .ev-table .td-ev {
    order: 0;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    padding-left: 8px;
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.01em;
  }

  /* --- Row 2: the pick, read like a bet slip --- */
  .ev-table .td-ou {
    order: 2;
    flex-shrink: 0;
  }

  /* On cards every side chip is the same neutral gray */
  .ev-side-chip,
  .ev-side-chip.ev-side-over,
  .ev-side-chip.ev-side-under,
  .ev-side-chip.ev-side-home,
  .ev-side-chip.ev-side-away {
    padding: 4px 9px;
    font-size: 0.66rem;
    color: var(--surface-text-secondary);
    border-color: var(--surface-border-strong);
    background: var(--surface-hover);
  }

  .ev-table .td-line {
    order: 2;
    flex-shrink: 0;
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    color: var(--surface-text);
  }

  .ev-table .td-line:empty {
    display: none;
  }

  .ev-line-team {
    display: inline;
    margin-right: 5px;
  }

  .ev-line-none {
    display: none;
  }

  .ev-table .td-prop-type {
    order: 2;
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* The bet type reads as words on a card, not a second chip */
  .ev-table .td-prop-type .ev-bet-type-chip {
    display: inline;
    padding: 0;
    border: none;
    background: none;
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    color: var(--surface-text-secondary);
  }

  .ev-table .td-odds {
    order: 2;
    flex-shrink: 0;
    padding-left: 8px;
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    color: var(--surface-text);
  }

  /* --- Row 3: the numbers + Bet --- */
  .ev-table .td-win,
  .ev-table .td-units {
    order: 4;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 72px;
    padding: 5px 10px;
    margin-left: -2px;
    border-radius: 10px;
    text-align: left;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.2;
  }

  .ev-table .td-units {
    margin-left: 0;
  }

  .ev-table .td-ev::before,
  .ev-table .td-win::before,
  .ev-table .td-units::before {
    font-family: var(--font-body);
    font-size: 0.56rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    line-height: 1;
    color: var(--surface-text-tertiary);
    margin-bottom: 4px;
  }

  .ev-table .td-ev::before { content: 'EV'; }
  .ev-table .td-win::before { content: 'Win %'; }
  .ev-table .td-units::before { content: '1/4 Kelly'; }

  .ev-table .td-bet {
    order: 4;
    margin-left: auto;
  }

  .ev-bet-link {
    min-height: 38px;
    padding: 0 18px;
    font-size: 0.88rem;
  }

  /* --- Skeleton cards --- */
  .ev-table .row-skeleton .ev-sk-meta { display: block; margin-top: 7px; }
  .ev-table .row-skeleton .td-ev::before,
  .ev-table .row-skeleton .td-win::before,
  .ev-table .row-skeleton .td-units::before { content: none; }
  .ev-table .row-skeleton .td-win,
  .ev-table .row-skeleton .td-units { padding: 8px 10px; }
  .ev-sk-name { width: 160px; }
  .ev-sk-btn { width: 64px; height: 38px; }

  /* --- Empty state as a card --- */
  .ev-table tbody tr.row-empty {
    display: block;
    padding: 0;
  }

  .ev-table tbody tr.row-empty::before,
  .ev-table tbody tr.row-empty::after {
    display: none;
  }

  .ev-table .row-empty td {
    display: block;
  }

  .ev-empty {
    padding: 48px 20px;
  }

  /* --- Sample data --- */
  .ev-demo-badge {
    border-bottom: 1px solid rgba(78, 235, 76, 0.2);
    border-radius: 12px;
    margin-bottom: 10px;
  }

  .ev-show-more-btn {
    width: 100%;
  }
}

/* Narrow phones: tighter numbers so Bet keeps its row */
@media (max-width: 360px) {
  .ev-table tbody tr {
    padding: 12px 12px 10px;
  }

  .ev-table .td-win,
  .ev-table .td-units {
    min-width: 64px;
    padding: 5px 8px;
  }

  .ev-bet-link {
    padding: 0 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ev-sk { animation: none; }
  .ev-table .player-link,
  .ev-table .player-link:hover { transition: none; transform: none; }
}
