/* Playoff machine. Everything is scoped under .pm and prefixed pm- so it can't collide with
   Bootstrap (.row, .col) or the site-wide h1/h3/a rules in styles.less. Colours are the site's slate palette. */
.pm {
  --pm-surface: #1e293b; /* slate-800 */
  --pm-card: #0f172a; /* slate-900 */
  --pm-ink: #f1f5f9; /* slate-100 */
  --pm-muted: #94a3b8; /* slate-400 */
  --pm-line: #334155; /* slate-700 */
  --pm-edge: #64748b; /* slate-500. The outline of a control, 3:1 or better on the page, card and surface */
  --pm-accent: #15803d; /* a shade darker than the site's green, so white text on it is 5:1 */
  --pm-accent-ink: #ffffff;
  --pm-gold: #eab308;
  --pm-in: #4ade80;
  --pm-out: #f87171;
  --pm-flash: #4a2a08; /* dark enough that the Out pill and muted text stay 4.5:1 on it */

  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 16px 64px;
  display: grid;
  gap: 20px;
  color: var(--pm-ink);
  font-size: 15px;
  line-height: 1.4;
  color-scheme: dark;
}
/* The site header holds the h1, so the page title is the h2, sections are h3 and groups inside them h4. */
.pm h2, .pm h3, .pm h4 { margin: 0; line-height: 1.1; text-wrap: balance; }
.pm h2, .pm h3 { font-family: "Graduate", Helvetica, sans-serif; color: var(--pm-ink); }
.pm h2 { font-size: 34px; }
.pm h3 { font-size: 26px; }
.pm h4 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--pm-muted); }
.pm p { margin: 0; }
.pm button { font: inherit; color: inherit; cursor: pointer; }
.pm button:focus-visible, .pm input:focus-visible { outline: 2px solid var(--pm-in); outline-offset: 2px; }
.pm-sub { color: var(--pm-muted); margin-top: 6px !important; }
.pm-num { font-variant-numeric: tabular-nums; }

.pm-cols { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 24px; align-items: start; }
.pm-main { display: grid; gap: 24px; min-width: 0; }
.pm-stack { display: grid; gap: 12px; min-width: 0; }
/* A flex column, not a grid, so the pinned bar can stick across the whole section. */
.pm-picks { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.pm-strip { display: none; }
@media (min-width: 821px) {
  .pm-picks.pm-fits { position: sticky; top: 16px; } /* pm-fits is set in fit() */
}
@media (max-width: 820px) {
  .pm-cols { grid-template-columns: minmax(0, 1fr); }
  .pm-main { display: contents; }
  .pm-board { order: -1; }
  /* The playoff picture is above the games here, so a short copy of it and the change line stay
     pinned to the bottom of the screen while the games are in view. */
  .pm-pin { order: 1; position: sticky; bottom: 0; z-index: 1; margin: 0 -16px;
    padding: 8px max(16px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    background: var(--pm-surface); border-top: 1px solid var(--pm-edge); box-shadow: 0 -8px 16px rgb(0 0 0 / 0.45); }
  .pm-strip { display: block; columns: 2; column-gap: 16px; font-size: 13px; }
  .pm-strip > span { display: flex; gap: 6px; align-items: baseline; break-inside: avoid; padding: 1px 4px; border-radius: 4px; }
  .pm-strip b { min-width: 1ch; color: var(--pm-muted); }
  .pm-strip b + span { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 700; }
  .pm-strip .pm-out b + span { font-weight: 400; color: var(--pm-muted); }
  .pm-strip small { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--pm-out); }
  .pm-strip .pm-flash { animation: pm-flash 1.4s ease-out; }
  .pm-pin .pm-change { min-height: 0; }
  .pm-pin .pm-change:not(:empty) { margin-top: 6px !important; }
  /* Keeps a focused game clear of the pinned bar. */
  .pm-game button { scroll-margin-bottom: 160px; }
}

.pm-bar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; }
.pm-seg { display: inline-flex; border: 1px solid var(--pm-edge); border-radius: 6px; overflow: hidden; background: var(--pm-surface); }
.pm-seg button { border: 0; background: none; padding: 6px 12px; font-weight: 700; }
.pm-seg button + button { border-left: 1px solid var(--pm-line); }
.pm-seg button[aria-pressed="true"] { background: var(--pm-ink); color: var(--pm-card); }
.pm-link { border: 0; background: none; padding: 4px 0; color: var(--pm-in) !important; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.pm-hint { color: var(--pm-muted); font-size: 13px; }
.pm-tools { order: 2; display: flex; justify-content: flex-end; } /* Reset, under the games and the change line */
/* In the picks column the week tabs and the autofill choice each fill a row, with the count and Reset on their own row between. */
.pm-picks .pm-seg { display: flex; flex: 1 1 100%; }
.pm-picks .pm-seg button { flex: 1 1 0; }
.pm-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* A week tab with picks of the visitor's in it. */
.pm-dot { display: inline-block; width: 6px; height: 6px; margin-left: 6px; border-radius: 50%; background: currentColor; vertical-align: middle; }
/* What the last change did. Two lines are held open so the games don't jump when it fills in. */
.pm-change { font-size: 13px; text-wrap: pretty; }

.pm-games { display: grid; gap: 8px; }
.pm-game { position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
/* A small pill over the gap ties the two sides of a game together. */
.pm-vs { position: absolute; left: 50%; top: 50%; translate: -50% -50%; z-index: 1; pointer-events: none; padding: 1px 6px; border: 1px solid var(--pm-edge); border-radius: 99px;
  background: var(--pm-card); color: var(--pm-muted); font-size: 10px; font-weight: 700; line-height: 1.4; }
/* Owner headshots, used the way a team logo would be. */
.pm-head { flex: none; width: 32px; height: 32px; object-fit: contain; }
.pm-game button { display: flex; align-items: center; gap: 8px; border: 1px solid var(--pm-edge); background: var(--pm-surface); border-radius: 6px; padding: 8px 10px; text-align: left; min-width: 0; }
.pm-game .pm-who { flex: 1; min-width: 0; }
.pm-game .pm-name { display: block; font-weight: 700; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* playoff_machine.js shrinks it to fit */
.pm-game .pm-pct { display: flex; flex-wrap: wrap; gap: 0 8px; justify-content: space-between; font-size: 12px; color: var(--pm-muted); margin-top: 2px; }
.pm-game .pm-tag { font-weight: 700; }
.pm-game button:hover { border-color: var(--pm-muted); }
/* The autofill's guess is a green outline; the visitor's own pick is filled in. */
.pm-game button[data-state="projected"] { border-color: var(--pm-in); background: color-mix(in srgb, var(--pm-accent) 12%, var(--pm-surface)); }
.pm-game button[data-state="projected"] .pm-tag { color: var(--pm-in); }
.pm-game button[data-state="mine"] { background: var(--pm-accent); border-color: var(--pm-accent); color: var(--pm-accent-ink); }
.pm-game button[data-state="mine"] .pm-pct { color: inherit; }

.pm-board { background: var(--pm-surface); border: 1px solid var(--pm-line); border-radius: 8px; padding: 18px; display: grid; gap: 14px; container-type: inline-size; }
/* As many cards across as fit at 280px or wider, so a reason line rarely needs a third line.
   Once there are two across, every row in a group is the same height. */
.pm-slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 10px; }
@container (min-width: 570px) { .pm-slots { grid-auto-rows: 1fr; } }
.pm-slot { background: var(--pm-card); border: 1px solid var(--pm-line); border-radius: 8px; padding: 10px 12px; min-width: 0;
  display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 10px; align-items: center; }
.pm-slot .pm-head { width: 40px; height: 40px; }
.pm-slot.pm-out { background: none; border-style: dashed; }
.pm-slot .pm-seed { font-family: "Graduate", Helvetica, sans-serif; font-size: 24px; line-height: 1; min-width: 1.2em; }
.pm-slot.pm-bye .pm-seed { color: var(--pm-gold); }
.pm-slot .pm-name { font-weight: 700; overflow-wrap: anywhere; line-height: 1.2; }
.pm-slot .pm-meta { display: block; font-size: 12px; font-weight: 400; color: var(--pm-muted); margin-top: 2px; }
/* A seed number with its i button pushed to the far side, so the buttons line up down a column. */
.pm-seedcell { display: flex; align-items: center; justify-content: space-between; gap: 6px; }

/* The i beside a seed opens a popover saying why a tied team landed there. */
.pm button.pm-info { position: relative; display: inline-grid; place-items: center; width: 16px; height: 16px; padding: 0; flex: none;
  border: 1px solid currentColor; border-radius: 50%; background: none; color: var(--pm-muted); font: 700 10px/1 "Lato", Helvetica, sans-serif; }
.pm button.pm-info:hover { color: var(--pm-ink); }
/* playoff_machine.js places it under its button. */
.pm-pop { position: fixed; inset: auto; margin: 0; width: max-content; max-width: min(280px, calc(100vw - 16px)); padding: 10px 36px 10px 12px;
  background: var(--pm-surface); color: var(--pm-ink); border: 1px solid var(--pm-edge); border-radius: 8px; box-shadow: 0 8px 24px rgb(0 0 0 / 0.5); font-size: 13px; }
.pm .pm-pop p { margin-top: 4px; text-wrap: pretty; }
.pm .pm-pop-close { position: absolute; top: 2px; right: 2px; width: 30px; height: 30px; padding: 0; border: 0; background: none; color: var(--pm-muted); font-size: 18px; line-height: 1; }
.pm .pm-pop-close:hover { color: var(--pm-ink); }

.pm-tables { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr)); gap: 20px 24px; }
.pm-tables.pm-one { grid-template-columns: minmax(0, 1fr); }
.pm-tbl { min-width: 0; display: grid; gap: 6px; container-type: inline-size; }
.pm-scroll { overflow-x: auto; }
.pm table { border-collapse: collapse; width: 100%; }
.pm th, .pm td { padding: 7px 8px; text-align: left; border-bottom: 1px solid var(--pm-line); white-space: nowrap; }
.pm th { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--pm-muted); }
.pm td.pm-team { white-space: normal; min-width: 150px; font-weight: 700; }
.pm-own { display: flex; align-items: center; gap: 8px; }
.pm-own .pm-head { width: 28px; height: 28px; }
.pm td.pm-team small { display: block; font-weight: 400; color: var(--pm-muted); font-size: 12px; }
/* League view: the line between the last playoff seed and the first team out. */
.pm tr.pm-cut td { padding: 3px 8px; border-top: 2px solid var(--pm-muted); border-bottom: 0; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--pm-muted); }
.pm .pm-r { text-align: right; }
.pm-pill { display: inline-block; min-width: 38px; text-align: center; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 99px; border: 1px solid currentColor; }
.pm-pill.pm-Bye { color: var(--pm-gold); }
.pm-pill.pm-In { color: var(--pm-in); }
.pm-pill.pm-Out { color: var(--pm-out); border-color: transparent; }

input.pm-pf { font: inherit; color: inherit; font-variant-numeric: tabular-nums; text-align: right; width: 8ch; box-sizing: content-box;
  padding: 2px 6px; background: none; border: 1px solid var(--pm-edge); border-radius: 4px; }
input.pm-pf:hover { border-color: var(--pm-muted); }
input.pm-pf.pm-mine { box-shadow: inset 0 -3px 0 var(--pm-gold); }

/* A change that moves a seed, record or status flashes it briefly. */
@keyframes pm-flash { from { background-color: var(--pm-flash); box-shadow: inset 0 -2px 0 var(--pm-gold); } }
@keyframes pm-ring { from { box-shadow: 0 0 0 2px var(--pm-gold); background-color: var(--pm-flash); } }
.pm td.pm-flash { animation: pm-flash 1.4s ease-out; }
.pm-slot.pm-flash { animation: pm-ring 1.4s ease-out; }
@media (prefers-reduced-motion: reduce) { .pm td.pm-flash, .pm-slot.pm-flash, .pm-strip .pm-flash { animation: none; } }

/* A table too narrow for six columns folds the current record into the team cell and tightens up. */
.pm td.pm-team .pm-curr { display: none; }
@container (max-width: 500px) {
  .pm th, .pm td { padding-inline: 4px; }
  .pm .pm-c { display: none; }
  .pm td.pm-team .pm-curr { display: block; }
  /* The owner cell takes whatever width is left, and a name that still doesn't fit is cut with an ellipsis. */
  .pm td.pm-team { min-width: 0; max-width: 0; width: 99%; }
  .pm-own { gap: 6px; }
  .pm-own .pm-head { width: 22px; height: 22px; }
  .pm-own > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pm-pill { min-width: 0; padding-inline: 6px; }
  input.pm-pf { width: 7ch; padding-inline: 4px; }
}
/* Touch sizes: every control at least 44px tall. */
@media (max-width: 820px), (pointer: coarse) {
  .pm-seg button { min-height: 44px; }
  .pm-link { min-width: 44px; min-height: 44px; margin-block: -8px; }
  .pm-pop { padding-right: 46px; }
  .pm .pm-pop-close { width: 44px; height: 44px; }
  .pm button.pm-info::after { content: ""; position: absolute; inset: -14px; } /* a 44px tap area without moving the layout */
  input.pm-pf { font-size: 16px; padding-block: 10px; } /* 16px also stops iOS zooming in on focus */
}
