/* ============================================================
   BOYZ IN MOTION — Pages CSS
   Page-specific layout, per DESIGN.md.
   (Trophy cabinet styles live in islands.css.)
   ============================================================ */

/* ─── Shared page toolbar (title left, controls right) ────────── */
.standings-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-16) var(--sp-24);
  margin-bottom: var(--sp-32);
}

.standings-toolbar > div:last-child {
  display: flex;
  align-items: center;
  gap: var(--sp-16) var(--sp-24);
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
}

/* ─── Home ────────────────────────────────────────────────────── */
.home-page .page-inner {
  padding-top: 0;
  padding-bottom: var(--sp-96);
}

/* On the home page the hero carries the page title, so Standings is a section heading */
.home-page h2.section-title {
  font-family: var(--font-heading);
  font-size: 32px !important;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.home-page .standings-toolbar { margin-bottom: var(--sp-20); align-items: center; }

.standings-table .diff-pos { color: var(--win); }
.standings-table .diff-neg { color: var(--text-muted); }
.standings-table .manager-cell a { font-size: 14px; }

@media (max-width: 640px) {
  .home-page .page-inner { padding-bottom: var(--sp-48); }
  .home-page h2.section-title { font-size: 24px !important; }
}

/* ─── Managers list ───────────────────────────────────────────── */
.managers-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--sp-16);
}

@media (max-width: 960px) { .managers-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .managers-grid { grid-template-columns: 1fr; } }

/* ─── Manager profile ─────────────────────────────────────────── */
.manager-profile-header {
  display: flex;
  align-items: center;
  gap: var(--sp-32);
  padding-bottom: var(--sp-40);
  margin-bottom: var(--sp-48);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.manager-profile-info {
  flex: 1;
  min-width: 240px;
}

.manager-name-row {
  display: flex;
  align-items: center;
  gap: var(--sp-16);
  flex-wrap: wrap;
  margin-bottom: var(--sp-12);
}

.manager-profile-name {
  font-family: var(--font-display);
  font-size: 48px;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.015em;
}

.manager-join-year { margin-bottom: var(--sp-16); }

.btn-trophy-case {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-8);
  padding: var(--sp-8) var(--sp-16);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.manager-section { margin-bottom: var(--sp-64); }
.manager-section:last-child { margin-bottom: 0; }

.manager-section-title {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin-bottom: var(--sp-20);
  color: var(--text-primary);
}

/* Career stats: one box score */
.manager-career-stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.manager-career-stats .stat-card { padding: var(--sp-20) var(--sp-20) var(--sp-16); }
.manager-career-stats .stat-card-value { padding-right: var(--sp-48); font-size: 24px !important; }

.trophy-case-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--sp-16);
}

.best-worst-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-16);
}

@media (max-width: 960px) {
  .manager-career-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .manager-profile-header { gap: var(--sp-20); padding-bottom: var(--sp-24); margin-bottom: var(--sp-32); }
  .manager-profile-header .avatar-xl { width: 72px; height: 72px; --avatar-font-size: 22px; }
  .manager-profile-name { font-size: 34px; }
  .manager-career-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .manager-career-stats .stat-card { padding: var(--sp-16); }
  .manager-career-stats .stat-card-value {
    padding-right: 0;
    font-size: 20px !important;
    white-space: nowrap;
    overflow-wrap: normal;
  }
  /* No room beside the figure on a phone: the rank badge drops below it */
  .manager-career-stats .stat-rank { position: static; margin-top: var(--sp-12); }
  .best-worst-grid { grid-template-columns: 1fr; }
  .manager-section { margin-bottom: var(--sp-48); }
  .callout-value { font-size: 20px; }
}

/* Head-to-head table on a profile: the W column leads, the rest recede */
.h2h-table td:nth-child(n+2),
.h2h-table th:nth-child(n+2) {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.h2h-table .text-win strong { color: var(--text-primary); font-weight: 500; }
.h2h-table tr.self-row td { background: var(--accent-wash); }

/* ─── Rivalries ───────────────────────────────────────────────── */
.matrix-wrap {
  overflow-x: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.matrix-table {
  border-collapse: collapse;
  white-space: nowrap;
  width: 100%;
}

.matrix-table th {
  height: 40px;
  padding: 0 var(--sp-8);
  font-family: var(--font-data);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--bg-surface-2);
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.matrix-table th.row-header {
  text-align: left;
  padding-left: var(--sp-16);
  min-width: 160px;
}

.matrix-table td {
  padding: 0;
  border-bottom: 1px solid var(--bg-surface);
  border-left: 1px solid var(--bg-surface);
}

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

.matrix-table td.row-label {
  padding: 0 var(--sp-16);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-surface);
  border-left: none;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  left: 0;
  z-index: 1;
}

.matrix-table tbody tr:last-child td.row-label { border-bottom: none; }

.matrix-cell-clickable { cursor: pointer; transition: box-shadow var(--transition); }
.matrix-cell-clickable:hover { box-shadow: inset 0 0 0 1px var(--text-primary); }

/* ─── Records ─────────────────────────────────────────────────── */
.records-section { margin-top: var(--section-gap) !important; }

.records-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-16);
}

@media (max-width: 960px) { .records-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .records-grid { grid-template-columns: 1fr; } }

/* Record card flip */
.flip-wrapper {
  perspective: 900px;
  position: relative;
  min-height: 264px;
}

.flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: inherit;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.flip-wrapper.is-flipped .flip-inner { transform: rotateY(180deg); }

.flip-front,
.flip-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.flip-back { transform: rotateY(180deg); }

.flip-front .trophy-card,
.flip-back .trophy-card { height: 100%; }

.flip-front .trophy-card .flip-btn { margin-top: auto; }

/* The headline record is the page's featured card */
.records-grid .flip-wrapper:first-child .trophy-card {
  background: var(--bg-feature);
  border-color: var(--bg-feature) !important;
  border-radius: var(--radius-xl);
}
.records-grid .flip-wrapper:first-child .trophy-card .trophy-label,
.records-grid .flip-wrapper:first-child .trophy-card .flip-back-title { color: var(--text-secondary); }
.records-grid .flip-wrapper:first-child .trophy-holder {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 400;
}
.records-grid .flip-wrapper:first-child .avatar { border-color: var(--bg-feature); outline-color: rgba(12, 10, 9, 0.14); }
.records-grid .flip-wrapper:first-child .flip-btn { background: transparent; border-color: rgba(12, 10, 9, 0.24); }

.flip-back .trophy-card { gap: var(--sp-12); }

.flip-back-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.flip-top5 {
  list-style: none;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.flip-top5-row {
  display: flex;
  align-items: center;
  gap: var(--sp-8);
  font-size: 14px;
  padding: var(--sp-8) 0;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
}

.records-grid .flip-wrapper:first-child .flip-top5-row { border-top-color: rgba(12, 10, 9, 0.12); }

.flip-top5-rank {
  font-family: var(--font-data);
  font-size: 11px;
  color: var(--text-muted);
  width: 14px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.flip-top5-rank.rank-gold,
.flip-top5-rank.rank-silver,
.flip-top5-rank.rank-bronze { color: var(--text-primary); background: none; border: none; }

.flip-top5-name {
  flex: 1;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.flip-top5-val {
  font-family: var(--font-data);
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.flip-btn {
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  line-height: 20px;
  padding: var(--sp-4) var(--sp-12);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  flex-shrink: 0;
}

/* ─── Scores ──────────────────────────────────────────────────── */
.score-highlights {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: var(--sp-16);
}

.score-highlights .stat-card > div:first-child:not(.stat-card-value) {
  font-size: 16px !important;
  line-height: 1;
  margin-bottom: var(--sp-12) !important;
}

@media (max-width: 960px) { .score-highlights { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.scores-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-8);
  margin-top: var(--sp-16);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-8);
  height: 28px;
  padding: 0 var(--sp-12);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  transition: opacity var(--transition), border-color var(--transition);
  user-select: none;
}

.legend-item:hover { border-color: var(--border-mid); }
.legend-item.is-focused { border-color: var(--text-primary); }

.legend-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.scores-legend-hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* ─── Draft ───────────────────────────────────────────────────── */
.draft-controls {
  display: flex;
  align-items: center;
  gap: var(--sp-16);
  margin-bottom: var(--sp-24);
  flex-wrap: wrap;
}

.draft-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-8);
  margin-bottom: var(--sp-8);
}

.draft-legend .pos-chip { outline-offset: 1px; transition: opacity var(--transition); }
.draft-legend + p { font-size: 12px !important; margin-bottom: var(--sp-20) !important; }

.draft-board td.highlighted-pick { background: var(--accent-wash); }

/* ─── Awards ──────────────────────────────────────────────────── */
.awards-season-block { margin-bottom: var(--sp-64); }
.awards-season-block:last-child { margin-bottom: 0; }

.awards-season-title {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin-bottom: var(--sp-20);
  padding-bottom: var(--sp-16);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: var(--sp-12);
}

.awards-season-title .season-year {
  font-family: var(--font-data);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.awards-season-title .season-live-tag {
  font-family: var(--font-data);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 2px var(--sp-8);
  align-self: center;
}

.awards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--sp-16);
}

@media (max-width: 960px) { .awards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .awards-grid { grid-template-columns: 1fr; }
  .award-card.award-featured { padding: var(--sp-20); }
  .award-card.award-featured .award-winner { font-size: 24px; }
  .award-card.award-featured .avatar-sm { width: 40px; height: 40px; --avatar-font-size: 13px; }
}

/* ─── Championship box score modal ───────────────────────────── */
.bs-modal { width: min(760px, 100%) !important; }

.bs-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-32);
  padding: var(--sp-24);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  text-align: center;
  flex-shrink: 0;
}

.bs-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-4);
  min-width: 120px;
}

.bs-mgr-name {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: var(--sp-8);
}

.bs-espn-name { font-size: 12px; color: var(--text-muted); }

.bs-final-score {
  font-family: var(--font-data);
  font-size: 28px;
  font-weight: 500;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  margin-top: var(--sp-8);
}

.bs-win  { color: var(--text-primary); font-weight: 600; }
.bs-loss { color: var(--text-muted); font-weight: 400; }

.bs-champ-badge {
  display: inline-flex;
  margin-top: var(--sp-8);
  padding: 2px var(--sp-8);
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #fff !important;
}

.bs-lineups {
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
}

.bs-col { overflow-x: auto; }
.bs-col-right { border-left: 1px solid var(--border); }

.bs-lineup-table { min-width: 100%; }

.bs-slot {
  font-family: var(--font-data);
  font-size: 11px !important;
  color: var(--text-muted) !important;
  white-space: nowrap;
  width: 40px;
}

.bs-pts {
  text-align: right !important;
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
  width: 64px;
  white-space: nowrap;
}

.bs-player { font-size: 14px; color: var(--text-primary) !important; }

.bs-bench-row td { color: var(--text-muted) !important; }

.bs-bench-divider {
  background: var(--bg-surface-2) !important;
  height: 28px !important;
}

@media (max-width: 640px) {
  .bs-lineups { grid-template-columns: 1fr; }
  .bs-col-right { border-left: none; border-top: 1px solid var(--border); }
}

/* ─── Constitution page ────────────────────────────────────────── */
.constitution-page .section-header { max-width: 680px; margin-left: auto; margin-right: auto; }

/* ─── Bonus page ──────────────────────────────────────────────── */
.bonus-page .coming-soon {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-height: 56vh;
  max-width: 720px;
  gap: var(--sp-16);
}

.coming-soon-icon { font-size: 32px; line-height: 1; }

.coming-soon h1 {
  font-family: var(--font-display);
  font-size: 48px;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.015em;
}

.coming-soon p {
  max-width: 480px;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-muted);
}

.coming-soon > div { justify-content: flex-start !important; gap: var(--sp-8) !important; margin-top: var(--sp-8) !important; }
.coming-soon .pill { white-space: normal; }
.coming-soon .btn { margin-top: var(--sp-16) !important; }

@media (max-width: 640px) { .coming-soon h1 { font-size: 34px; } }

/* ═══════════════════════════════════════════════════════════════
   POWER RANKINGS
   ═══════════════════════════════════════════════════════════════ */

.pr-stamp {
  display: inline-block;
  margin-left: var(--sp-8);
  font-family: var(--font-data);
  font-size: 12px;
  color: var(--text-muted);
}

.pr-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-16) var(--sp-40);
  margin-bottom: var(--sp-24);
}

.pr-control { display: flex; align-items: center; gap: var(--sp-12); min-width: 0; }

.pr-explainer {
  margin-bottom: var(--sp-48);
  max-width: 72ch;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-secondary);
}

.pr-section { margin-bottom: var(--sp-64); }

.pr-section-head { margin-bottom: var(--sp-16); }

.pr-section-title {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: var(--sp-4);
}

.pr-section-sub {
  font-size: 14px;
  color: var(--text-muted);
}

/* The list is one card; rows are divided by hairlines */
.pr-list {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.pr-row { border-top: 1px solid var(--border); }
.pr-row:first-child { border-top: none; }

.pr-row-main {
  display: flex;
  align-items: center;
  gap: var(--sp-12);
  width: 100%;
  min-height: 56px;
  padding: var(--sp-8) var(--sp-16);
  text-align: left;
  cursor: pointer;
  color: inherit;
  transition: background var(--transition);
}

.pr-row-main:hover,
.pr-row.is-open .pr-row-main { background: var(--bg-surface-2); }

.pr-rank { flex: 0 0 auto; }

.pr-move {
  flex: 0 0 auto;
  width: 32px;
  font-family: var(--font-data);
  font-size: 11px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.pr-move-up   { color: var(--win); }
.pr-move-down { color: var(--loss); }
.pr-move-flat,
.pr-move-none { color: var(--text-faint); }

.pr-identity {
  display: flex;
  align-items: center;
  gap: var(--sp-12);
  flex: 1 1 auto;
  min-width: 0;
}

.pr-names { display: flex; flex-direction: column; min-width: 0; }

.pr-manager {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pr-preview {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pr-callout {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 0 0 auto;
  font-family: var(--font-data);
  font-size: 11px;
  text-align: right;
}

.pr-callout-good { color: var(--win); }
.pr-callout-bad  { color: var(--loss); }
.pr-callout em   { font-style: normal; }

.pr-metrics {
  display: flex;
  align-items: center;
  gap: var(--sp-16);
  flex: 0 0 auto;
}

.pr-vsavg {
  font-family: var(--font-data);
  font-size: 12px;
  min-width: 48px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pr-pos-val { color: var(--win); }
.pr-neg-val { color: var(--loss); }

.pr-rating {
  font-family: var(--font-data);
  font-size: 20px;
  font-weight: 500;
  min-width: 40px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pr-rating-elite { color: var(--text-primary); font-weight: 600; }
.pr-rating-good  { color: var(--text-primary); }
.pr-rating-mid   { color: var(--text-secondary); }
.pr-rating-poor  { color: var(--text-faint); }

.pr-chevron {
  flex: 0 0 auto;
  font-size: 16px;
  color: var(--text-faint);
  transition: transform var(--transition);
}

.pr-row.is-open .pr-chevron { transform: rotate(90deg); }

/* A collapsed row must never show its breakdown, even if markup lingers. */
.pr-row:not(.is-open) .pr-detail { display: none; }

.pr-detail:not(:empty) {
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
}

.pr-detail-table { font-size: 14px; }
.pr-detail-table th { background: var(--bg-surface); }
.pr-weight, .pr-depth-row td { color: var(--text-muted) !important; }
.pr-counted { color: var(--text-primary) !important; font-weight: 500; }
.pr-depth-row .pr-counted { font-weight: 400; color: var(--text-secondary) !important; }

.pr-player-name { display: flex; align-items: center; gap: var(--sp-8); color: var(--text-primary) !important; }

.pr-inj, .pr-bench-tag {
  font-family: var(--font-data);
  font-size: 11px;
  line-height: 1.5;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: transparent;
}

.pr-inj { border-color: var(--tie); color: var(--tie); }
.pr-inj-bad { border-color: var(--text-primary); background: var(--bg-inverse); color: #fff; }

.pr-empty { padding: var(--sp-16); font-size: 14px; color: var(--text-muted); text-align: center; }

.pr-footnote {
  margin-top: var(--sp-32);
  padding-top: var(--sp-20);
  border-top: 1px solid var(--border);
  max-width: 72ch;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-muted);
}

.pr-footnote strong { color: var(--text-secondary); }

@media (max-width: 960px) {
  .pr-callout { display: none; }
}

@media (max-width: 640px) {
  .pr-control { width: 100%; flex-direction: column; align-items: flex-start; gap: var(--sp-8); }
  .pr-row-main { gap: var(--sp-8); padding: var(--sp-8) var(--sp-12); }
  .pr-preview { display: none; }
  .pr-move { width: 24px; }
  .pr-vsavg { min-width: 40px; }
  .pr-rating { font-size: 16px; min-width: 28px; }
  .pr-chevron { display: none; }
}
