/* Team of the Week — desktop, dark poster theme */

:root {
  --bg-page: #0e1219;
  --bg-elev-1: #161b25;
  --bg-elev-2: #1d2330;
  --border: #2a3142;
  --text-primary: #e8eaef;
  --text-secondary: #9aa3b5;
  --text-tertiary: #6b7385;
  --accent: #4f8cf7;
  --accent-hover: #6da4ff;
  --field-line: #3a6b48;
  --confirmed: #1B8A4F;
  --stylized: #E8833A;
  --max-width: 1440px;

  /* Rating tier palette — aligned with mobile's lightRatingColors. Deeper
     shades so white text on each pill meets WCAG AA on light backgrounds.
     Overridden below for body.dark with the dark-mode palette. */
  --rating-exceptional: #0D7377;  /* 9.0+ teal */
  --rating-excellent:   #1B8A4F;  /* 8.0+ dark green */
  --rating-very-good:   #2E7D32;  /* 7.0+ deeper green */
  --rating-average:     #C99A2E;  /* 6.5+ deeper amber */
  --rating-below-avg:   #D06B20;  /* 6.0+ deeper orange */
  --rating-poor:        #C0392B;  /* 5.0+ deeper red */
  --rating-very-poor:   #B71C1C;  /* <5.0 darker red */
}

body.dark {
  /* Dark-mode palette mirrors mobile's darkRatingColors — lighter shades
     so pills stand out against the dark page. Only the mid/low tiers
     differ from light mode; exceptional + excellent are shared. */
  --rating-very-good:  #4CAF50;
  --rating-average:    #E8B73A;
  --rating-below-avg:  #E8833A;
  --rating-poor:       #E04A38;
  --rating-very-poor:  #DC1F29;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { color: var(--accent-hover); }

/* ─── Header ─────────────────────────────────────────────────────── */

.totw-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  max-width: var(--max-width);
  margin: 0 auto;
}

.totw-brand {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--text-tertiary);
  font-weight: 700;
}
.totw-title {
  font-size: 28px;
  font-weight: 700;
  margin-top: 2px;
}

.totw-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.round-picker {
  display: flex;
  gap: 8px;
}
.round-picker select {
  background: var(--bg-elev-2);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
.round-picker select:hover { border-color: var(--accent); }

.share-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.share-btn:hover { background: var(--accent-hover); }

.methodology-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.methodology-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.methodology-card {
  max-width: 640px;
}
.methodology-header h2 {
  margin: 0;
  font-size: 20px;
}
.methodology-body {
  line-height: 1.5;
}
.methodology-section {
  margin-bottom: 20px;
}
.methodology-section h3 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.4px;
}
.methodology-section p {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--text-secondary);
}
.methodology-section ul {
  margin: 8px 0 0;
  padding-left: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}
.methodology-section ul li { margin-bottom: 6px; }
.methodology-section ul strong { color: var(--text-primary); }
.methodology-formula {
  margin: 8px 0;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Consecutive-TOTW streak pill in the player modal. */
.modal-streak {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  background: rgba(255, 140, 66, 0.15);
  border: 1px solid rgba(255, 140, 66, 0.5);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  color: #ffa765;
  letter-spacing: 0.3px;
}

/* Editor's pick pill — shown when the player was promoted via an admin override. */
.modal-editor {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--accent);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.3px;
}

.diff-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}
.diff-toggle input { cursor: pointer; accent-color: var(--accent); }

/* ─── NEW badge on field nodes ────────────────────────────────── */
.node-new-badge {
  position: absolute;
  top: -6px;
  left: -10px;
  background: #2563eb;
  color: white;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 2px 5px;
  border-radius: 4px;
  z-index: 2;
  border: 1.5px solid var(--bg-page);
}

/* ─── Out-this-week panel ─────────────────────────────────────── */
.panel-out { border-color: rgba(232, 131, 58, 0.3); }
.out-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.out-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}
.out-row:last-child { border-bottom: none; }
.out-name { color: var(--text-secondary); text-decoration: line-through; }
.out-team { color: var(--text-tertiary); font-size: 11px; }
.out-rating {
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}

/* ─── Coverage banner ─────────────────────────────────────────────── */

.coverage-banner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 10px 32px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.banner-badge {
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
}
.banner-confirmed { background: rgba(27, 138, 79, 0.18); color: #4ade80; }
.banner-stylized { background: rgba(232, 131, 58, 0.18); color: #fbbf77; }
.banner-detail { color: var(--text-secondary); }

/* ─── Layout ─────────────────────────────────────────────────────── */

.totw-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  padding: 24px 32px;
  max-width: var(--max-width);
  margin: 0 auto;
}

@media (max-width: 1100px) {
  .totw-layout { grid-template-columns: 1fr; }
}

/* ─── Field ──────────────────────────────────────────────────────── */

.totw-field {
  background: var(--bg-elev-1);
  border-radius: 12px;
  padding: 24px;
  border: 1px solid var(--border);
}

.field-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  margin: 0 auto;
}

.field-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.field-node {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  z-index: 2;
  transition: transform 0.15s;
}
.field-node:hover { transform: translate(-50%, -50%) scale(1.08); z-index: 3; }
.field-node:focus-visible {
  outline: none;
  transform: translate(-50%, -50%) scale(1.08);
  z-index: 3;
}
.field-node:focus-visible .node-photo-ring {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 247, 0.4);
}
.bench-node:focus-visible {
  outline: none;
}
.bench-node:focus-visible .node-photo-ring {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 247, 0.4);
}
.totw-table th:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.node-photo-ring {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--bg-elev-2);
  overflow: hidden;
  position: relative;
}
.node-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.node-photo-placeholder { background: var(--bg-elev-2); }

.node-rating {
  position: absolute;
  top: -4px;
  right: -8px;
  font-size: 10px;
  font-weight: 700;
  color: white;
  padding: 2px 5px;
  border-radius: 4px;
  z-index: 1;
}

.node-name {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 600;
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  text-align: center;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Bench ──────────────────────────────────────────────────────── */

.bench-wrap {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.bench-label {
  font-size: 11px;
  letter-spacing: 1.5px;
  color: var(--text-tertiary);
  font-weight: 700;
  margin-bottom: 12px;
}
.bench-row {
  display: flex;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
}
.bench-node {
  width: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  position: relative;
}
.bench-node .node-photo-ring {
  width: 40px;
  height: 40px;
}
.bench-node:hover { transform: scale(1.08); }

/* Broad role badge — surfaces DEF/MID/RUC/FWD on bench players so the
   "next best regardless of position" rule is visible at a glance. */
.bench-role-pill {
  margin-top: 3px;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.5px;
  align-self: center;
}

/* ─── Side panels ────────────────────────────────────────────────── */

.side-panels {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}
.panel-title {
  font-size: 11px;
  letter-spacing: 1.5px;
  color: var(--text-tertiary);
  font-weight: 700;
  margin-bottom: 10px;
}
.panel-body {
  font-size: 13px;
  color: var(--text-secondary);
}
.panel-body em.empty {
  color: var(--text-tertiary);
  font-style: italic;
  font-size: 12px;
}

/* ─── Selectors' notes ──────────────────────────────────── */
.notes-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.notes-list li {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-secondary);
  padding-left: 14px;
  position: relative;
}
.notes-list li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 700;
}
.notes-list strong { color: var(--text-primary); font-weight: 600; }
.notes-list .hl { font-weight: 700; }
.notes-list .muted { color: var(--text-tertiary); font-size: 12px; }

/* ─── Snubs ────────────────────────────────────────────── */
.snubs-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.snub-row {
  display: grid;
  grid-template-columns: 36px 1fr auto auto;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.snub-row:last-child { border-bottom: none; }
.snub-pos {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  background: var(--bg-elev-2);
  padding: 2px 6px;
  border-radius: 4px;
  text-align: center;
}
.snub-name { color: var(--text-primary); font-weight: 500; }
.snub-team { color: var(--text-tertiary); font-size: 11px; }
.snub-rating {
  font-weight: 700;
  color: white;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

/* ─── Position races ──────────────────────────────────── */
.races-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.race-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}
.race-group {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  background: var(--bg-elev-2);
  padding: 2px 6px;
  border-radius: 4px;
  text-align: center;
}
.race-pair {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: baseline;
  color: var(--text-secondary);
  font-size: 12px;
}
.race-name.in { color: var(--text-primary); font-weight: 500; }
.race-name.out { color: var(--text-secondary); }
.race-rating { font-weight: 600; font-variant-numeric: tabular-nums; }
.race-vs { color: var(--text-tertiary); font-size: 10px; text-transform: uppercase; }
.race-gap {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

/* ─── Team representation ─────────────────────────────── */
.rep-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rep-row {
  display: grid;
  grid-template-columns: 24px 1fr auto auto;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  padding: 4px 0;
}
.rep-logo {
  width: 22px;
  height: 22px;
  object-fit: contain;
}
.rep-logo-placeholder {
  width: 22px;
  height: 22px;
  background: var(--bg-elev-2);
  border-radius: 4px;
  display: inline-block;
}
.rep-team { color: var(--text-secondary); }
.rep-dots {
  color: var(--accent);
  font-size: 9px;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
}
.rep-count {
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  min-width: 14px;
  text-align: right;
}

/* ─── Full team table ────────────────────────────────────────────── */

.full-team-table {
  max-width: var(--max-width);
  margin: 0 auto 32px;
  padding: 0 32px;
}
.table-title {
  font-size: 11px;
  letter-spacing: 1.5px;
  color: var(--text-tertiary);
  font-weight: 700;
  margin-bottom: 12px;
}

.totw-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elev-1);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.totw-table th, .totw-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.totw-table th {
  background: var(--bg-elev-2);
  color: var(--text-tertiary);
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
}
.totw-table th:hover { color: var(--text-primary); }
.totw-table th.num, .totw-table td.num { text-align: right; }
.totw-table tbody tr:hover { background: var(--bg-elev-2); }
.totw-table tbody tr:last-child td { border-bottom: none; }

/* ─── Footer ─────────────────────────────────────────────────────── */

.totw-footer {
  text-align: center;
  padding: 24px;
  font-size: 12px;
  color: var(--text-tertiary);
  border-top: 1px solid var(--border);
}

/* ─── Loading + error ────────────────────────────────────────────── */

.loading, .error {
  padding: 48px;
  text-align: center;
  color: var(--text-secondary);
}
.error { color: #f87171; }

/* ─── Player modal ───────────────────────────────────────────────── */

.player-modal[hidden] { display: none; }

.player-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}
.modal-card {
  position: relative;
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  z-index: 1;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  width: 32px;
  height: 32px;
}
.modal-close:hover { color: var(--text-primary); }

.modal-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-photo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-elev-2);
  object-fit: cover;
}
.modal-titles { flex: 1; }
.modal-titles h2 { font-size: 18px; font-weight: 700; }
.modal-sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.modal-rating {
  font-size: 18px;
  font-weight: 700;
  color: white;
  padding: 8px 14px;
  border-radius: 8px;
}

.modal-body {
  padding: 18px 24px;
}
.modal-stats {
  width: 100%;
  border-collapse: collapse;
}
.modal-stats th, .modal-stats td {
  padding: 6px 0;
  font-size: 13px;
}
.modal-stats th {
  text-align: left;
  font-weight: 500;
  color: var(--text-secondary);
}
.modal-stats td {
  text-align: right;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.modal-composite {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: ui-monospace, monospace;
}
