/* Puck Luck: the page is a sheet of ice. Blue line = the schedule handed you wins, goal red = it took them. */

:root {
  color-scheme: light;
  --ice: #eef3f6;
  --sheet: #f8fafb;
  --ink: #14232e;
  --ink-2: #3d4d58;
  --muted: #5d6c77;
  --hair: #d5dee4;
  --trace: #b9c5cd;
  --lucky: #1f5fae;
  --unlucky: #c3313a;
  --lucky-tint: #c9daf0;
  --unlucky-tint: #f2cbcd;
  --even: #e2e8ec;
  --on-strong: #ffffff;

  --display: "Big Shoulders Display", "Arial Narrow", sans-serif;
  --text: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ice: #0d171e;
    --sheet: #15222c;
    --ink: #e6edf1;
    --ink-2: #c0ccd4;
    --muted: #8e9ea9;
    --hair: #273743;
    --trace: #3a4b57;
    --lucky: #5b93e0;
    --unlucky: #e2615f;
    --lucky-tint: #24497a;
    --unlucky-tint: #5a2a2f;
    --even: #24333e;
    --on-strong: #0b141a;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ice: #0d171e;
  --sheet: #15222c;
  --ink: #e6edf1;
  --ink-2: #c0ccd4;
  --muted: #8e9ea9;
  --hair: #273743;
  --trace: #3a4b57;
  --lucky: #5b93e0;
  --unlucky: #e2615f;
  --lucky-tint: #24497a;
  --unlucky-tint: #5a2a2f;
  --even: #24333e;
  --on-strong: #0b141a;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--ice);
  color: var(--ink);
  font: 400 1.0625rem/1.55 var(--text);
  -webkit-text-size-adjust: 100%;
}

a {
  color: inherit;
  text-decoration-color: var(--trace);
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-color: currentColor;
}

:focus-visible {
  outline: 2px solid var(--lucky);
  outline-offset: 2px;
  border-radius: 2px;
}

.page {
  max-width: 46rem;
  margin: 0 auto;
  padding: 0 16px 4rem;
}

.loading,
.problem {
  padding-top: 4rem;
  color: var(--muted);
}

.problem strong {
  color: var(--ink);
}

/* Masthead */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  padding: 1.25rem 0 0.75rem;
  border-bottom: 1px solid var(--hair);
}

.wordmark {
  font: 800 1.5rem/1 var(--display);
  text-decoration: none;
  letter-spacing: 0.01em;
}

.meta {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
}

/* Headline */

.hero {
  padding: 2.75rem 0 1.5rem;
}

.hero h1 {
  margin: 0;
  font: 800 clamp(2.5rem, 9.5vw, 4.5rem)/0.95 var(--display);
  letter-spacing: 0.005em;
  text-wrap: balance;
}

.hero h1 .claim {
  display: block;
  padding-left: 0.3em;
  border-left: 0.12em solid var(--trace);
}

.hero h1 .claim + .claim {
  margin-top: 0.2em;
}

.hero h1 .claim.lucky {
  border-left-color: var(--lucky);
}

.hero h1 .claim.unlucky {
  border-left-color: var(--unlucky);
}

.lede {
  max-width: 36rem;
  margin: 1.25rem 0 0;
  color: var(--ink-2);
}

/* Sections */

.block {
  padding-top: 2.75rem;
}

.block h2 {
  margin: 0 0 0.25rem;
  font: 700 2rem/1.05 var(--display);
  letter-spacing: 0.01em;
}

.note {
  max-width: 36rem;
  margin: 0 0 1rem;
  font-size: 0.9375rem;
  color: var(--muted);
}

/* Standings: diverging bars either side of center ice */

.board-axis,
.board-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(6.5rem, 1.15fr) 3.25rem;
  column-gap: 0.75rem;
  align-items: center;
}

.board-axis {
  font-size: 0.8125rem;
  color: var(--muted);
}

.board-axis span:nth-child(2) {
  display: flex;
  justify-content: space-between;
}

.board {
  margin: 0.25rem 0 0;
  padding: 0;
  list-style: none;
}

.board-row {
  padding: 0.75rem 0;
  border-top: 1px solid var(--hair);
}

.board-row:last-child {
  border-bottom: 1px solid var(--hair);
}

.who {
  min-width: 0;
}

.who .name {
  display: block;
  font: 700 1.5rem/1.05 var(--display);
}

.who .team,
.who .rec {
  display: block;
  font-size: 0.8125rem;
  line-height: 1.35;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.who .rec {
  font-variant-numeric: tabular-nums;
}

.bar {
  position: relative;
  align-self: stretch;
  min-height: 2.5rem;
}

.bar::before {
  content: "";
  position: absolute;
  top: -0.75rem;
  bottom: -0.75rem;
  left: calc(50% - 1px);
  width: 2px;
  background: var(--trace);
}

.bar span {
  position: absolute;
  top: 50%;
  height: 10px;
  margin-top: -5px;
  width: calc(var(--mag) * 50%);
  /* The page's one entrance: bars push out from center ice. `backwards` means no animation still ends drawn. */
  animation: grow 700ms cubic-bezier(0.2, 0.7, 0.2, 1) backwards;
  animation-delay: calc(var(--i) * 40ms);
}

@keyframes grow {
  from {
    transform: scaleX(0);
  }
}

.lucky .bar span {
  left: calc(50% + 2px);
  background: var(--lucky);
  border-radius: 0 4px 4px 0;
  transform-origin: left center;
}

.unlucky .bar span {
  right: calc(50% + 2px);
  background: var(--unlucky);
  border-radius: 4px 0 0 4px;
  transform-origin: right center;
}

.value {
  font: 700 1.5rem/1 var(--display);
  text-align: right;
}

/* Week-by-week grid */

.grid-scroll {
  overflow-x: auto;
  margin: 0 -16px;
  padding: 0 16px;
}

/* Room to scroll one extra column so the grid can line up with the frozen names. */
.grid-scroll:has(.weekly-grid) {
  padding-right: calc(16px + 2.125rem);
}

.grid {
  border-collapse: separate;
  border-spacing: 2px;
  font-size: 0.8125rem;
}

.grid th {
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.grid thead th {
  padding-bottom: 0.25rem;
  font-variant-numeric: tabular-nums;
}

.grid thead th a {
  display: block;
  min-width: 2rem;
  text-decoration: none;
}

.grid tbody th {
  position: sticky;
  left: 0;
  z-index: 1;
  padding-right: 0.5rem;
  text-align: left;
  font-weight: 600;
  color: var(--ink);
  background: var(--ice);
  /* Covers the border-spacing gap so scrolled-under squares don't peek out. */
  box-shadow: 2px 0 0 var(--ice);
}

.grid .corner {
  position: sticky;
  left: 0;
  z-index: 1;
  text-align: left;
  background: var(--ice);
}

.cell {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 4px;
  font-weight: 700;
  text-decoration: none;
}

.tone-l2 { background: var(--lucky); color: var(--on-strong); }
.tone-l1 { background: var(--lucky-tint); color: var(--ink); }
.tone-0 { background: var(--even); color: var(--ink-2); }
.tone-u1 { background: var(--unlucky-tint); color: var(--ink); }
.tone-u2 { background: var(--unlucky); color: var(--on-strong); }

.scale {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.75rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

.scale .swatches {
  display: flex;
  gap: 2px;
}

.scale .swatches span {
  width: 1.25rem;
  height: 0.875rem;
  border-radius: 3px;
}

/* Running luck chart */

.follow {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
  font-size: 0.9375rem;
  color: var(--ink-2);
}

.follow select {
  font: 600 0.9375rem var(--text);
  color: var(--ink);
  background: var(--sheet);
  border: 1px solid var(--hair);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
}

.chart {
  position: relative;
  margin: 0;
  padding: 0.75rem 0.5rem 0.25rem 0;
  background: var(--sheet);
  border-radius: 6px;
}

.chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  touch-action: pan-y;
}

.chart .grid-line { stroke: var(--hair); stroke-width: 1; }
.chart .zero-line { stroke: var(--muted); stroke-width: 1; }
.chart .tick { fill: var(--muted); font: 500 12px var(--text); font-variant-numeric: tabular-nums; }
.chart .trace { fill: none; stroke: var(--trace); stroke-width: 1.5; stroke-linejoin: round; }
.chart .trace.followed { stroke: var(--ink); stroke-width: 2.5; }
.chart .dot { fill: var(--ink); stroke: var(--sheet); stroke-width: 2; }
.chart .end-label { fill: var(--ink); font: 700 15px var(--display); }
.chart .end-value { fill: var(--ink-2); font: 600 12px var(--text); }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; }

.tip {
  position: absolute;
  top: 0.5rem;
  padding: 0.375rem 0.5rem;
  font-size: 0.8125rem;
  line-height: 1.35;
  white-space: nowrap;
  background: var(--ice);
  border: 1px solid var(--hair);
  border-radius: 6px;
  pointer-events: none;
}

.tip[hidden] {
  display: none;
}

.tip strong {
  display: block;
}

details {
  margin-top: 0.75rem;
  font-size: 0.9375rem;
}

summary {
  cursor: pointer;
  color: var(--ink-2);
}

.data-table {
  margin-top: 0.75rem;
  border-collapse: collapse;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.data-table th,
.data-table td {
  padding: 0.25rem 0.5rem;
  text-align: right;
  border-bottom: 1px solid var(--hair);
  white-space: nowrap;
}

.data-table th:first-child {
  text-align: left;
}

/* How it's counted */

.how p {
  max-width: 36rem;
  margin: 0 0 0.75rem;
  color: var(--ink-2);
}

.footer {
  margin-top: 3.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--hair);
  font-size: 0.8125rem;
  color: var(--muted);
}

/* Week page */

.week-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  padding-top: 1rem;
  font-size: 0.9375rem;
}

.week-nav .spacer {
  flex: 1;
}

.verdicts {
  margin: 1.25rem 0 0;
  padding: 0;
  list-style: none;
  max-width: 38rem;
}

.verdicts li {
  padding-left: 0.75rem;
  border-left: 4px solid var(--trace);
  font-size: 1.1875rem;
  line-height: 1.4;
}

.verdicts li + li {
  margin-top: 0.75rem;
}

.verdicts .lucky { border-left-color: var(--lucky); }
.verdicts .unlucky { border-left-color: var(--unlucky); }

.matchups {
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
}

.matchup {
  padding: 0.5rem 0;
  border-top: 1px solid var(--hair);
}

.matchup:last-child {
  border-bottom: 1px solid var(--hair);
}

.side {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 4.5rem;
  column-gap: 0.75rem;
  align-items: center;
  padding: 0.25rem 0;
}

.side .score {
  font: 700 1.75rem/1 var(--display);
  text-align: right;
}

.side.lost .score {
  color: var(--muted);
}

.side .who .name {
  font-size: 1.375rem;
}

.tag {
  display: inline-block;
  padding: 0.125rem 0.4rem;
  border-radius: 4px;
  font-size: 0.8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ladder {
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
  font-variant-numeric: tabular-nums;
}

.ladder li {
  display: grid;
  grid-template-columns: 1.75rem minmax(0, 1fr) 4.25rem 2rem 3.75rem 3.25rem;
  column-gap: 0.5rem;
  align-items: center;
  padding: 0.4rem 0;
  border-top: 1px solid var(--hair);
  font-size: 0.9375rem;
}

.ladder li.head {
  border-top: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.ladder .rank {
  color: var(--muted);
  text-align: right;
}

.ladder .num {
  text-align: right;
  white-space: nowrap;
}

.ladder .ladder-name {
  min-width: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.ladder .ladder-name small {
  font-weight: 400;
  color: var(--muted);
}

.ladder .result {
  justify-self: center;
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
}

@media (max-width: 30rem) {
  .ladder .ladder-name small {
    display: none;
  }
  .ladder li {
    grid-template-columns: 1.25rem minmax(0, 1fr) 3.75rem 1.5rem 3.5rem 2.5rem;
    column-gap: 0.375rem;
    font-size: 0.875rem;
  }
}

@media (max-width: 30rem) {
  .board-axis,
  .board-row {
    grid-template-columns: minmax(0, 1fr) 5.5rem 2.75rem;
    column-gap: 0.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bar span {
    animation: none;
  }
}

