/* pickle: warm neutrals, one green for actions, a team colour for each side. */

:root {
  --paper: #f5f2ec;
  --surface: #fbf9f5;
  --ink: #26221e;
  --muted: #655c53;
  --rule: #ddd5c8;
  --accent: #2e6a4e;       /* court green: links, buttons, focus */
  --accent-dark: #22513b;
  --team-0: #9b4a26;       /* A & B */
  --team-1: #345c85;       /* C & D */
  --ball: #d6e64a;         /* the rally that's playing */
  --error: #a3302a;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.6rem;
  --step-3: 2.25rem;
  --gap: 1.5rem;
  --radius: 6px;
  color-scheme: light;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: var(--step-0)/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2 {
  font-family: var(--serif);
  font-weight: 500;
  line-height: 1.2;
  margin: 0 0 0.5em;
  text-wrap: balance;
}
h1 { font-size: var(--step-3); letter-spacing: -0.01em; }
h2 { font-size: var(--step-2); }
p { margin: 0 0 1em; max-width: 65ch; }

a { color: var(--accent); text-underline-offset: 0.18em; }
a:hover { color: var(--accent-dark); }

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

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: 1rem; top: -3rem;
  background: var(--ink); color: var(--paper);
  padding: 0.5rem 1rem;
  z-index: 10;
}
.skip:focus { top: 1rem; }

/* Header */

header.site {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--gap);
  padding: 1.25rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--rule);
}
.wordmark {
  font-family: var(--serif);
  font-size: var(--step-2);
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.02em;
}
.wordmark:hover { color: var(--ink); }
header.site nav { display: flex; align-items: baseline; gap: 1.5rem; }
header.site nav a { color: var(--muted); text-decoration: none; }
header.site nav a:hover, header.site nav a[aria-current="page"] { color: var(--ink); }
header.site nav a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-decoration-color: var(--accent);
}
header.site form { margin: 0; }

/* Page frames */

main.page {
  max-width: 60rem;
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 4rem) clamp(1rem, 4vw, 3rem) 5rem;
}
main.narrow { max-width: 34rem; }

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--gap);
  margin-bottom: 2rem;
}
.page-head h1 { margin: 0; }

.lede { font-size: var(--step-1); color: var(--muted); margin-bottom: 2rem; }
.hint { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--error); }
.error:empty { display: none; }

/* Controls */

button { font: inherit; color: inherit; }

.button {
  display: inline-block;
  padding: 0.65rem 1.25rem;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { background: var(--accent-dark); color: #fff; }
.button:disabled { background: var(--muted); cursor: progress; }

button.quiet {
  background: none;
  border: 0;
  padding: 0;
  color: var(--muted);
  cursor: pointer;
}
button.quiet:hover { color: var(--ink); }

progress {
  width: 100%;
  max-width: 28rem;
  height: 0.5rem;
  accent-color: var(--accent);
}

/* Games list */

table.games { width: 100%; border-collapse: collapse; }
table.games th {
  text-align: left;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
  padding: 0 1rem 0.6rem 0;
  border-bottom: 1px solid var(--ink);
}
table.games td {
  padding: 1rem 1rem 1rem 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: baseline;
}
table.games td:first-child { font-family: var(--serif); font-size: var(--step-1); }
table.games td:first-child a { color: var(--ink); text-decoration-color: var(--rule); }
table.games td:first-child a:hover { text-decoration-color: var(--accent); }
table.games td:nth-child(2) { color: var(--muted); white-space: nowrap; }
@media (max-width: 40rem) {
  /* Room for the title on phones; the date is the least needed. */
  table.games :is(th, td):nth-child(2) { display: none; }
}

.state { white-space: nowrap; font-variant-numeric: tabular-nums; }
.state::before {
  content: "";
  display: inline-block;
  width: 0.55rem; height: 0.55rem;
  margin-right: 0.5rem;
  border-radius: 50%;
  background: var(--rule);
}
.state-done::before { background: var(--accent); }
.state-running::before, .state-queued::before { background: var(--ball); box-shadow: 0 0 0 1px #8f9a2a; }
.state-failed { color: var(--error); }
.state-failed::before { background: var(--error); }

.empty {
  padding: 3rem 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

/* Upload */

.upload { max-width: 32rem; margin-bottom: 4rem; }
.field { margin-bottom: 1.5rem; }
.field label { display: block; font-weight: 600; margin-bottom: 0.35rem; }
.field .hint { margin: 0.35rem 0 0; }
.field input {
  width: 100%;
  font: inherit;
  padding: 0.6rem 0.75rem;
  border: 1px solid #8a8073;  /* 3:1 against the paper */
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}
.field input[type="file"] { padding: 1.25rem 0.75rem; border-style: dashed; cursor: pointer; }
.field input[type="file"]::file-selector-button {
  font: inherit;
  margin-right: 1rem;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
}
.upload-progress { margin-top: 1.5rem; }
.upload-progress p { margin-top: 0.5rem; font-variant-numeric: tabular-nums; }
.upload .error { margin-top: 1rem; }

.tips { border-top: 1px solid var(--rule); padding-top: 2rem; max-width: 40rem; }
.tips h2 { font-size: var(--step-1); }
.tips ul { margin: 0; padding-left: 1.2rem; color: var(--muted); }
.tips li { margin-bottom: 0.4rem; }

/* Game page: the video and its title on the left, the rallies beside it. */

main.game {
  display: grid;
  gap: 2rem clamp(1.5rem, 3vw, 3rem);
  padding: clamp(1rem, 3vw, 2rem) clamp(1rem, 4vw, 3rem) 5rem;
  max-width: 100rem;
  margin: 0 auto;
}
@media (min-width: 64rem) {
  main.game { grid-template-columns: minmax(0, 1fr) minmax(20rem, 26rem); align-items: start; }
  .game-main { position: sticky; top: 1.5rem; }
  .rallies { max-height: calc(100vh - 3rem); overflow-y: auto; padding-right: 0.5rem; }
}
@media (max-width: 63.99rem) {
  /* Keep the video in view while scrolling through shots. Without its wrapper's
     box, the player sticks within the whole page rather than the wrapper. */
  .game-main { display: contents; }
  main.game .game-head { padding-top: 0; }
  .player { position: sticky; top: 0; z-index: 1; background: var(--paper); padding-bottom: 0.5rem; }
}

.player video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #1d1a17;
  border-radius: var(--radius);
}
.game-head { padding-top: 1.25rem; }
.game-head h1 { font-size: var(--step-2); margin-bottom: 0.25rem; }
.meta { color: var(--muted); }
.status { margin: 1rem 0; }
.status-line { margin-bottom: 0.5rem; font-variant-numeric: tabular-nums; }

.teams { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem 2rem; color: var(--muted); font-size: 0.9rem; }
.teams .chip:first-child { margin-right: 0.2rem; }
.teams .chip:nth-child(2) { margin-right: 0.5rem; }

.chip {
  display: inline-grid;
  place-items: center;
  width: 1.6rem; height: 1.6rem;
  border-radius: 50%;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--muted);
}
.chip.team-0 { background: var(--team-0); }
.chip.team-1 { background: var(--team-1); }

.rallies h2 { margin-bottom: 0.25rem; }
.rallies > .hint { margin-bottom: 1.25rem; }

.rally-list, .shots { list-style: none; margin: 0; padding: 0; }
.rally { border-top: 1px solid var(--rule); position: relative; padding-left: 0.75rem; }
.rally:last-child { border-bottom: 1px solid var(--rule); }
.rally.playing::before {
  content: "";
  position: absolute;
  left: 0; top: 0.5rem; bottom: 0.5rem;
  width: 4px;
  border-radius: 2px;
  background: var(--ball);
  box-shadow: 0 0 0 1px #8f9a2a;
}

.rally summary {
  display: grid;
  grid-template-columns: 5.5rem 1fr auto;
  align-items: baseline;
  gap: 0 1rem;
  padding: 0.85rem 0.25rem;
  cursor: pointer;
  list-style: none;
}
.rally summary::-webkit-details-marker { display: none; }
.rally summary:hover, .rally details[open] > summary { background: var(--surface); }

/* The called score, set like a scorebook. */
.score {
  font-family: var(--serif);
  font-size: var(--step-1);
  font-variant-numeric: lining-nums tabular-nums;
  white-space: nowrap;
}
.rally-facts { color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.tag {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0 0.5rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--ink);
}
.winner { font-size: 0.9rem; font-weight: 600; white-space: nowrap; }
.winner.team-0 { color: var(--team-0); }
.winner.team-1 { color: var(--team-1); }

.shots { padding: 0 0 0.75rem 5.5rem; }
.shots button {
  display: grid;
  grid-template-columns: 2.75rem auto 1fr;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.3rem 0.5rem;
  border: 0;
  border-radius: var(--radius);
  background: none;
  text-align: left;
  cursor: pointer;
}
.shots button:hover { background: var(--surface); }
.shots .time { color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.shots .chip { width: 1.4rem; height: 1.4rem; font-size: 0.75rem; }

@media (max-width: 30rem) {
  .rally summary { grid-template-columns: 4.5rem 1fr; }
  .winner { grid-column: 2; }
  .shots { padding-left: 1rem; }
}

@media (forced-colors: active) {
  .chip, .rally.playing::before, .state::before { forced-color-adjust: none; }
}
