/* NFL Rooting Guide. Colours are tokens on :root; dark mode redefines them. */
:root {
  color-scheme: light dark;
  --bg: #f3f5fb;
  --surface: #ffffff;
  --surface-2: #f6f7fc;
  --border: #e1e5f0;
  --text: #151a2d;
  --muted: #5d6784;
  --accent: #4f46e5;
  --accent-soft: #e9e8ff;
  --good: #0f9d6b;
  --shadow: 0 1px 2px rgb(16 24 64 / 6%), 0 6px 20px rgb(16 24 64 / 6%);
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1020;
    --surface: #151a2e;
    --surface-2: #1b2138;
    --border: #272e4a;
    --text: #e7eafc;
    --muted: #9aa4c7;
    --accent: #8b8cff;
    --accent-soft: #2a2e5e;
    --good: #34d399;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px rgb(0 0 0 / 30%);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background:
    radial-gradient(900px 420px at 12% -8%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------ top bar */

.topbar {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  max-width: 1480px;
  margin: 0 auto;
  padding: 1.1rem 1.25rem 0;
}

.topbar .brand {
  font-size: 1.15rem;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.topbar .brand b { color: var(--accent); }

.topbar .tag { color: var(--muted); font-size: 0.85rem; }

/* ------------------------------------------------------------ layout */

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "cal" "a" "b" "s";
  gap: 1.25rem;
  max-width: 1480px;
  margin: 0 auto;
  padding: 0.9rem 1.25rem 3rem;
  align-items: start;
}

.calibration {
  grid-area: cal;
  justify-self: start;
  color: var(--muted);
  font-size: 0.82rem;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.changes  { grid-area: a; }
.teams    { grid-area: b; }
.schedule { grid-area: s; }

.changes, .teams, .schedule {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  min-width: 0;
}

h3 {
  margin: 0 0 0.9rem;
  font-size: 1.35rem;
  letter-spacing: -0.015em;
  line-height: 1.2;
}

.changes > h3 { font-size: 1.6rem; }

/* ------------------------------------------------------------ controls */

select {
  appearance: none;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background:
    var(--surface-2)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%238b93b0' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E")
    no-repeat right 0.8rem center;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 2.1rem 0.5rem 0.85rem;
  margin: 0 0.5rem 1rem 0;
  cursor: pointer;
}

select:hover { border-color: var(--accent); }

select:focus-visible, tr.pointer:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ------------------------------------------------------------ tables */

table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  margin: 0 0 1rem;
}

th, td {
  padding: 0.42rem 0.6rem;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  text-align: left;
}

th {
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  background: var(--surface);
}

tr:last-child > td { border-bottom: 0; }

.chance { text-align: right; }
th:not(:first-child) { text-align: right; }
.changes > table:last-of-type th:nth-child(2) { text-align: left; }

.team { font-weight: 600; text-align: left; }
.power { color: var(--muted); text-align: right; }

/* Headline numbers: the first table under the title. */
.changes > table:first-of-type { margin-bottom: 1.1rem; }

.changes > table:first-of-type th {
  background: transparent;
  text-align: left;
  border-bottom: 0;
  padding: 0 0.6rem 0.1rem 0;
}

.changes > table:first-of-type td {
  font-size: 1.9rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  text-align: left;
  border: 0;
  padding: 0 0.6rem 0 0;
}

.changes > table:first-of-type td:nth-child(5) {
  font-size: 1rem;
  font-weight: 500;
  color: var(--muted);
  align-self: end;
}

/* Rooting table: each game is an away row over a home row. */
.changes > table:last-of-type th {
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: normal;
  vertical-align: bottom;
  border-bottom: 2px solid var(--border);
}

tr.away > td { border-bottom: 0; padding-bottom: 0.12rem; }
tr.home > td { padding-top: 0.12rem; }

tr.pointer { cursor: pointer; }

tr.away:hover > td, tr.home:hover > td { background: var(--surface-2); }

/* Hovering either row of a pair lights both. */
tr.away:has(+ tr.home:hover) > td { background: var(--surface-2); }
tr.home:hover { box-shadow: none; }

.mod > td { background: var(--accent-soft); }

.gametime {
  color: var(--muted);
  font-size: 0.72rem;
  text-align: center;
  white-space: nowrap;
}

/* Impact cells carry --heat (0 to 1), how big the swing is. */
td.chance[style*="--heat"] {
  background: color-mix(in srgb, var(--good) calc(var(--heat) * 38%), transparent);
  font-weight: 600;
  border-radius: 6px;
}

/* ------------------------------------------------------------ standings */


.standings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem 1.25rem;
}

.standings > h3 { grid-column: 1 / -1; margin-bottom: 0; }

.standings > div {
  display: grid;
  gap: 0.9rem;
  align-content: start;
  min-width: 0;
}

.standings td:nth-child(2) { white-space: nowrap; color: var(--muted); }

.standings table {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-2);
}

.standings th { background: var(--surface-2); white-space: normal; letter-spacing: 0.02em; padding: 0.4rem 0.4rem; vertical-align: bottom; }
.standings { font-size: 0.86rem; }
/* Two conferences side by side leave no room for the fitted power column. */
.standings th:nth-child(3), .standings td:nth-child(3) { display: none; }
.standings th:first-child {
  color: var(--accent);
  font-size: 0.8rem;
}

.standings td { background: transparent; padding: 0.32rem 0.4rem; }
.standings tr:hover > td { background: color-mix(in srgb, var(--accent) 8%, transparent); }

/* ------------------------------------------------------------ notes */

.footer {
  margin: 0 0 1rem;
  padding: 0.7rem 0.9rem;
  color: var(--muted);
  font-size: 0.84rem;
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
}

.changes > p { margin: 0.4rem 0; }

/* ------------------------------------------------------------ schedule */

.week {
  margin: 1.1rem 0 0.4rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.schedule table { table-layout: fixed; border-spacing: 0.5rem; margin: 0 -0.5rem; width: calc(100% + 1rem); }

.schedule td.game {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  vertical-align: top;
}

.schedule td.game > div:not(.gametime) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* The class names mark the team that lost (win) or won (lose) the game. */
.lose { font-weight: 700; }
.win  { color: var(--muted); }
.tie  { color: var(--muted); }

.schedule .gametime { text-align: left; margin-top: 0.15rem; }

/* ------------------------------------------------------------ narrow screens */

@media (max-width: 1000px) {
  .standings { grid-template-columns: minmax(0, 1fr); }
  .standings th:nth-child(3), .standings td:nth-child(3) { display: table-cell; }
}

@media (max-width: 700px) {
  .topbar, .app { padding-left: 0.75rem; padding-right: 0.75rem; }
  .changes, .teams, .schedule { padding: 0.9rem; border-radius: 12px; }
  .changes > h3 { font-size: 1.3rem; }
  table { display: block; overflow-x: auto; }
  .topbar .tag { display: none; }
  .changes > table:first-of-type { display: table; }
  .changes > table:first-of-type td { font-size: 1.2rem; }
  .changes > table:first-of-type th { font-size: 0.6rem; letter-spacing: 0; white-space: normal; }
  .changes > table:first-of-type th:nth-child(5), .changes > table:first-of-type td:nth-child(5) { display: none; }
  .schedule table { display: block; overflow: visible; margin: 0; width: 100%; }
  .schedule tbody, .schedule tr { display: block; }
  .schedule td.game { display: block; margin-bottom: 0.5rem; }
}

@media (prefers-reduced-motion: no-preference) {
  tr.away > td, tr.home > td, select { transition: background-color 0.12s, border-color 0.12s; }
}
