/* D2 Men's Soccer Ratings. A printed league table: newsprint and ink, condensed type,
   one blue for the ranges, orange only for the team you pin. */

:root {
  color-scheme: light;
  --page: #f4f2ec;
  --surface: #fcfcfb;
  --ink: #141412;
  --ink-2: #52514e;
  --muted: #7d7b75;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --rule: #141412;
  --series: #2a78d6;
  --series-soft: rgba(42, 120, 214, 0.18);
  --pin: #eb6834;
  --win: #2a78d6;
  --draw: #b9b7ae;
  --loss: #e34948;
  --up: #006300;
  --down: #b3261e;
  --bubble: rgba(235, 104, 52, 0.08);
  --hover: rgba(20, 20, 18, 0.04);
  --display: "Big Shoulders Display", "Arial Narrow", system-ui, sans-serif;
  --text: "IBM Plex Sans Condensed", "Arial Narrow", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #f4f3ee;
    --ink-2: #c3c2b7;
    --muted: #8f8d86;
    --grid: #2c2c2a;
    --axis: #45443f;
    --rule: #f4f3ee;
    --series: #3987e5;
    --series-soft: rgba(57, 135, 229, 0.24);
    --pin: #d95926;
    --win: #3987e5;
    --draw: #6b6a64;
    --loss: #e66767;
    --up: #0ca30c;
    --down: #ff8a80;
    --bubble: rgba(217, 89, 38, 0.12);
    --hover: rgba(255, 255, 255, 0.05);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #f4f3ee;
  --ink-2: #c3c2b7;
  --muted: #8f8d86;
  --grid: #2c2c2a;
  --axis: #45443f;
  --rule: #f4f3ee;
  --series: #3987e5;
  --series-soft: rgba(57, 135, 229, 0.24);
  --pin: #d95926;
  --win: #3987e5;
  --draw: #6b6a64;
  --loss: #e66767;
  --up: #0ca30c;
  --down: #ff8a80;
  --bubble: rgba(217, 89, 38, 0.12);
  --hover: rgba(255, 255, 255, 0.05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 16px/1.45 var(--text);
}
a { color: inherit; }
main { max-width: 1080px; margin: 0 auto; padding: 0 16px 48px; }

/* Masthead */
.mast { border-bottom: 3px double var(--rule); background: var(--page); }
.mast-inner {
  max-width: 1080px; margin: 0 auto; padding: 14px 16px 6px;
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 18px;
}
.brand {
  font: 800 1.7rem/1 var(--display); text-transform: uppercase; letter-spacing: 0.01em;
  text-decoration: none;
}
.brand-d2 { background: var(--ink); color: var(--page); padding: 0 6px; margin-right: 2px; }
.brand-r { color: var(--series); }
nav { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; font-weight: 500; }
nav a { text-decoration: none; padding: 4px 0; border-bottom: 2px solid transparent; }
nav a[aria-current="page"] { border-bottom-color: var(--ink); }
nav a:hover { border-bottom-color: var(--axis); }
.theme {
  font: inherit; background: none; border: 1px solid var(--axis); color: var(--ink);
  border-radius: 999px; width: 30px; height: 30px; cursor: pointer;
}
.updated {
  max-width: 1080px; margin: 0 auto; padding: 0 16px 8px; color: var(--ink-2);
  font-size: 0.85rem; font-variant-numeric: tabular-nums;
}

/* Intro */
.intro h1, .team-head h1, .prose h1 {
  font: 800 clamp(2rem, 6vw, 3.2rem)/0.98 var(--display); text-transform: uppercase;
  margin: 22px 0 10px; letter-spacing: 0.005em;
}
.explain { max-width: 68ch; margin: 0 0 16px; color: var(--ink-2); font-size: 1.02rem; }

/* Controls */
.controls {
  display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: end;
  padding: 10px 0 12px; border-top: 1px solid var(--grid);
}
.controls label { display: grid; gap: 2px; font-size: 0.78rem; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.04em; }
select, .seg button, .pin-btn {
  font: 500 0.95rem var(--text); color: var(--ink); background: var(--surface);
  border: 1px solid var(--axis); border-radius: 6px; padding: 6px 8px; min-height: 36px;
}
.seg { display: inline-flex; border: 1px solid var(--axis); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; cursor: pointer; background: var(--surface); }
.seg button + button { border-left: 1px solid var(--axis); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--page); }

/* The table */
.table { background: var(--surface); border: 1px solid var(--grid); border-radius: 4px; }
.thead, .row {
  display: grid;
  /* Phones: the range bar gets its own full-width line under the name. */
  grid-template-columns: 2.4rem 1fr 3.4rem 2.6rem;
  grid-template-areas: "rank team p mv" ". bar bar bar";
  align-items: center; column-gap: 8px; padding: 2px 8px 4px;
}
.thead {
  position: sticky; top: 0; z-index: 2; background: var(--surface);
  border-bottom: 1px solid var(--axis); padding-top: 6px; padding-bottom: 4px;
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-2);
}
.row {
  min-height: 40px; text-decoration: none; border-bottom: 1px solid var(--grid);
  font-variant-numeric: tabular-nums;
}
.row:last-child { border-bottom: 0; }
.row:hover, .row:focus-visible { background: var(--hover); outline: none; }
.row:focus-visible { box-shadow: inset 3px 0 0 var(--ink); }
.c-rank { grid-area: rank; text-align: right; color: var(--ink-2); white-space: nowrap; }
.c-team { grid-area: team; min-width: 0; line-height: 1.15; padding: 4px 0; }
.c-team .tn { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-team .sub { display: block; font-size: 0.78rem; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-conf, .c-rec { display: none; color: var(--ink-2); font-size: 0.9rem; }
.c-bar { grid-area: bar; position: relative; min-width: 0; }
.c-p { grid-area: p; text-align: right; font-weight: 600; }
.c-mv { grid-area: mv; text-align: right; font-size: 0.85rem; }
.c-mv .up { color: var(--up); }
.c-mv .down { color: var(--down); }
.c-mv .flat { color: var(--muted); }
.pin-mark { display: none; color: var(--pin); }

.thead .c-bar { height: 18px; }
@media (min-width: 760px) { .thead .c-bar { height: 34px; } }
.axis-title { display: none; text-transform: none; letter-spacing: 0; font-size: 0.72rem; color: var(--muted); }
.axis-caption { margin: 0 0 6px; font-size: 0.85rem; color: var(--ink-2); }
.axis-caption b { color: var(--ink); font-weight: 600; }
@media (min-width: 760px) {
  .axis-title { display: block; }
  .axis-caption { display: none; }
}
.axis-labels { position: absolute; left: 0; right: 0; bottom: 0; height: 16px; }
.axis-labels span {
  position: absolute; transform: translateX(-50%); font-size: 0.75rem; color: var(--ink-2);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.axis-labels span.zero { font-weight: 600; color: var(--ink); }

/* Range bars */
svg.rb { display: block; overflow: visible; }
.rb .tick { stroke: var(--grid); stroke-width: 1; }
.rb .zero { stroke: var(--axis); stroke-width: 1.5; }
.rb .w95 { stroke: var(--series); stroke-width: 1.5; stroke-linecap: round; opacity: 0.6; }
.rb .b80 { fill: var(--series); opacity: 0.85; }
.rb .med { fill: var(--surface); stroke: var(--series); stroke-width: 2.5; }
.rb .clip { fill: var(--series); }
.row.is-pinned .clip { fill: var(--pin); }
.rb .cut { stroke: var(--ink); stroke-width: 1.5; }
.rb .cutband { fill: var(--ink); opacity: 0.07; }

/* One view at a time */
[data-view="rating"] .v-rank, [data-view="rank"] .v-rating { display: none !important; }

/* Pinned team */
.row.is-pinned { background: var(--bubble); }
.row.is-pinned .tn { color: var(--ink); }
.row.is-pinned .pin-mark { display: inline; }
.row.is-pinned .w95 { stroke: var(--pin); opacity: 0.8; }
.row.is-pinned .b80 { fill: var(--pin); }
.row.is-pinned .med { stroke: var(--pin); }
.row.is-hidden { display: none; }

@media (min-width: 760px) {
  .thead, .row {
    grid-template-columns: 2.8rem minmax(9rem, 12rem) 5.5rem 4.6rem 1fr 3.6rem 3rem;
    grid-template-areas: "rank team conf rec bar p mv";
    column-gap: 12px; padding: 0 12px;
  }
  .c-conf { grid-area: conf; display: block; }
  .c-rec { grid-area: rec; display: block; }
  .c-team .sub { display: none; }
  .row { min-height: 34px; padding-top: 0; padding-bottom: 0; }
  .thead { padding-top: 6px; padding-bottom: 4px; }
}

/* Conference ranking: same table, fewer columns */
.confs .thead, .confs .row {
  grid-template-columns: 2.4rem 1fr 4.4rem;
  grid-template-areas: "rank team p" ". bar bar";
}
.confs .c-conf { display: none; }
@media (min-width: 760px) {
  .confs .thead, .confs .row {
    grid-template-columns: 2.8rem minmax(9rem, 14rem) 6.5rem 1fr 5rem;
    grid-template-areas: "rank team conf bar p";
  }
  .confs .c-conf { display: block; }
  .confs .c-team .sub { display: block; white-space: normal; }
  .confs .vs-sub { display: none; }
}
table.standings td:nth-child(n+3), table.standings th:nth-child(n+3) { text-align: right; }

/* Bubble view */
.bubble .thead, .bubble .row {
  grid-template-columns: 1.6rem 1fr 3rem 3.4rem;
  grid-template-areas: "rank team npi p" ". bar bar bar";
}
.bubble .c-p { grid-area: p; }
.bubble .c-npi { grid-area: npi; text-align: right; font-variant-numeric: tabular-nums; }
.bubble .c-aq { display: none; }
@media (min-width: 760px) {
  .bubble .thead, .bubble .row {
    grid-template-columns: 1.6rem minmax(9rem, 15rem) 1fr 3.6rem 4.4rem 3.6rem;
    grid-template-areas: "rank team bar npi aq p";
  }
  .bubble .c-aq { grid-area: aq; display: block; text-align: right; }
  .bubble .c-team .sub .aq { display: none; }
}
.bubble .thead .c-bar { height: 32px; }
.region-cards { display: grid; gap: 12px; grid-template-columns: 1fr; margin-top: 8px; }
@media (min-width: 760px) { .region-cards { grid-template-columns: 1fr 1fr; } }
.region-card { display: block; text-decoration: none; background: var(--surface); border: 1px solid var(--grid); border-radius: 4px; padding: 12px 14px; }
.region-card:hover { background: var(--hover); }
.region-card h2 { font: 800 1.4rem/1.05 var(--display); text-transform: uppercase; margin: 0 0 4px; }
.region-card p { margin: 6px 0 0; }
.bubble .row.is-bubble { background: var(--bubble); }
.tag {
  display: inline-block; font-size: 0.68rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; border: 1px solid currentColor; border-radius: 3px; padding: 0 4px;
  color: var(--ink-2); vertical-align: 1px;
}

/* Team page */
.team-head { padding-top: 6px; }
.kicker { margin: 18px 0 0; font-size: 0.85rem; color: var(--ink-2); }
.team-head h1 { margin-top: 6px; }
.meta { margin: 0 0 10px; color: var(--ink-2); }
.pin-btn { cursor: pointer; }
.pin-btn[aria-pressed="true"] { border-color: var(--pin); color: var(--pin); }
.places { margin: 10px 0 0; font-size: 0.92rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tiles { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 16px 0; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { background: var(--surface); border: 1px solid var(--grid); border-radius: 4px; padding: 12px 14px; }
.tile .label { margin: 0; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-2); }
.tile .value { margin: 2px 0; font: 800 2.5rem/1 var(--display); }
.tile .value.small { font-size: 1.9rem; }
.tile .value .of { font: 500 1rem var(--text); color: var(--ink-2); }
.tile .range { margin: 4px 0 0; font-size: 0.92rem; }
.tile .hint { margin: 4px 0 0; font-size: 0.8rem; color: var(--muted); }

.panel { margin: 22px 0; }
.panel h2, .prose h2 {
  font: 800 1.5rem/1.05 var(--display); text-transform: uppercase; margin: 0 0 4px;
  padding-top: 10px; border-top: 2px solid var(--rule);
}
.panel .sub { margin: 0 0 10px; color: var(--ink-2); font-size: 0.92rem; }
.chart-wrap { max-width: 560px; background: var(--surface); border: 1px solid var(--grid); border-radius: 4px; padding: 8px; }
.chart-wrap.narrow { max-width: 360px; }
svg.chart { display: block; width: 100%; height: auto; font-family: var(--text); }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .zero { stroke: var(--axis); stroke-width: 1.5; }
.chart .band { fill: var(--series-soft); }
.chart .line { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .end, .chart .pt { fill: var(--series); stroke: var(--surface); stroke-width: 2; }
.chart .bar { fill: var(--series); }
.chart .diag { stroke: var(--axis); stroke-width: 1; }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: var(--hover); }
.chart .ylab { font-size: 10.5px; fill: var(--ink-2); text-anchor: end; font-variant-numeric: tabular-nums; }
.chart .xlab { font-size: 10.5px; fill: var(--ink-2); text-anchor: middle; }

.list { background: var(--surface); border: 1px solid var(--grid); border-radius: 4px; }
.li {
  display: grid; grid-template-columns: 3.1rem 1fr auto; grid-template-areas: "dt opp score" "dt probs probs";
  column-gap: 10px; row-gap: 2px; padding: 8px 10px; border-bottom: 1px solid var(--grid);
  font-variant-numeric: tabular-nums; align-items: center;
}
.li:last-child { border-bottom: 0; }
.li .dt { grid-area: dt; color: var(--ink-2); font-size: 0.88rem; align-self: start; padding-top: 1px; }
.li .opp { grid-area: opp; min-width: 0; }
.li .opp a { font-weight: 600; text-decoration-color: var(--axis); text-underline-offset: 2px; }
.results .li { grid-template-areas: "dt opp score" "dt moved moved"; }
.li .score { grid-area: score; text-align: right; white-space: nowrap; }
.li .score small { color: var(--ink-2); }
.li .moved { grid-area: moved; display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--ink-2); }
.fixtures .li { grid-template-areas: "dt opp likely" "dt probs probs"; }
.li .likely { grid-area: likely; color: var(--ink-2); }
.li .probs { grid-area: probs; display: flex; align-items: center; gap: 10px; font-size: 0.85rem; color: var(--ink-2); flex-wrap: wrap; }
@media (min-width: 760px) {
  .results .li { grid-template-columns: 3.4rem 1fr 7.5rem 12rem; grid-template-areas: "dt opp score moved"; }
  .fixtures .li { grid-template-columns: 3.4rem 1fr 18rem 3rem; grid-template-areas: "dt opp probs likely"; }
}
.res-W b, .res-T b, .res-L b {
  display: inline-block; width: 1.4em; text-align: center; border-radius: 3px; font-size: 0.8rem; margin-right: 4px;
}
.res-W b { background: var(--win); color: #fff; }
.res-T b { background: var(--draw); color: var(--ink); }
.res-L b { background: var(--loss); color: #fff; }

.wdl { display: inline-flex; width: 9rem; height: 10px; gap: 2px; }
.wdl span { display: block; min-width: 0; }
.wdl .w { background: var(--win); border-radius: 4px 0 0 4px; }
.wdl .d { background: var(--draw); }
.wdl .l { background: var(--loss); border-radius: 0 4px 4px 0; }

.imp { position: relative; display: inline-block; width: 5rem; height: 8px; }
.imp .mid { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--axis); }
.imp .up, .imp .down { position: absolute; top: 0; height: 8px; }
.imp .up { background: var(--win); border-radius: 0 4px 4px 0; }
.imp .down { background: var(--loss); border-radius: 4px 0 0 4px; }
.moved .num { min-width: 3.2em; }

/* Methodology */
.prose { max-width: 70ch; }
.prose h2 { margin-top: 28px; }
.prose h3 { font: 700 1.05rem var(--text); margin: 18px 0 4px; }
.prose li { margin: 4px 0; }
.tbl-wrap { overflow-x: auto; }
table.metrics { border-collapse: collapse; width: 100%; background: var(--surface); font-variant-numeric: tabular-nums; }
table.metrics th, table.metrics td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--grid); font-size: 0.92rem; }
table.metrics th { font-weight: 600; color: var(--ink-2); }

.note { color: var(--muted); font-size: 0.85rem; }
footer { max-width: 1080px; margin: 0 auto; padding: 16px; border-top: 1px solid var(--grid); color: var(--muted); font-size: 0.85rem; }

/* Tooltip */
.tip {
  position: fixed; z-index: 10; max-width: min(320px, calc(100vw - 24px)); pointer-events: none;
  background: var(--ink); color: var(--page); font-size: 0.85rem; line-height: 1.3;
  padding: 6px 9px; border-radius: 4px; font-variant-numeric: tabular-nums;
}

@media (forced-colors: active) {
  .rb .b80, .wdl span, .imp span { forced-color-adjust: none; }
}
@media print {
  .controls, .theme, .pin-btn { display: none; }
  .thead { position: static; }
}
.v-rank-cap { display: none; }
body.view-rank .v-rank-cap { display: block; }
body.view-rank .v-rating-cap { display: none; }

/* Qualifying */
.steps li { margin: 6px 0; }
.routes { margin: 6px 0 12px; padding-left: 1.2rem; }
.routes li { margin: 6px 0; }
.glossary dt { font-weight: 600; margin-top: 10px; }
.glossary dd { margin: 2px 0 0; color: var(--ink-2); }
table.wins-needed td:first-child, table.wins-needed th:first-child { width: 6rem; }
table.wins-needed td:nth-child(2) { white-space: nowrap; }
.wbar { display: inline-block; width: 6rem; height: 8px; background: var(--grid); border-radius: 4px; margin-right: 8px; vertical-align: middle; overflow: hidden; }
.wbar span { display: block; height: 100%; background: var(--series); border-radius: 4px; }
table.wins-needed td:nth-child(3) { white-space: nowrap; }
@media (max-width: 480px) { .wbar { width: 3rem; margin-right: 6px; } }
.winout { margin: 10px 0 4px; padding: 8px 12px; background: var(--surface); border-left: 3px solid var(--series); }

/* Legend above the rankings */
.legend { margin: 0 0 8px; font-size: 0.9rem; color: var(--ink-2); max-width: 75ch; }
.legend p { margin: 0 0 4px; }
.legend b { color: var(--ink); font-weight: 600; }
.lg { white-space: nowrap; margin-right: 6px; }
.lg svg { vertical-align: -1px; margin-right: 3px; }
.lg-med { fill: var(--surface); stroke: var(--series); stroke-width: 2.5; }
.lg-b80 { fill: var(--series); opacity: 0.85; }
.lg-w95 { stroke: var(--series); stroke-width: 1.5; opacity: 0.6; }
.view-note { color: var(--ink); font-weight: 500; }
.seg-wrap { display: grid; gap: 2px; }
.seg-label { font-size: 0.78rem; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.04em; }

/* Table headers in sentence case: short labels stay readable */
.thead { text-transform: none; letter-spacing: 0; font-size: 0.8rem; font-weight: 600; }

/* Place column: only when the list is re-sorted or filtered */
.c-place { display: none; grid-area: place; text-align: right; font-weight: 600; white-space: nowrap; }
#rankings[data-placed="1"] .c-place { display: block; }
#rankings[data-placed="1"] .thead, #rankings[data-placed="1"] .row {
  grid-template-columns: 2.4rem 2.4rem 1fr 3.1rem 2.6rem;
  grid-template-areas: "place rank team p mv" ". . bar bar bar";
}
#rankings[data-placed="1"] .c-rank { font-size: 0.85rem; }
@media (min-width: 760px) {
  #rankings[data-placed="1"] .thead, #rankings[data-placed="1"] .row {
    grid-template-columns: 2.8rem 2.6rem minmax(9rem, 12rem) 5.5rem 4.6rem 1fr 3.6rem 3rem;
    grid-template-areas: "place rank team conf rec bar p mv";
  }
}
/* The axis title stays visible on phones, inside the sticky header */
.thead .c-bar { height: 32px; }
.axis-title { display: block; }
.c-p { white-space: nowrap; }
.xlab.end { text-anchor: end; font-weight: 600; }

.summary { margin: 0 0 6px; font-size: 1.08rem; line-height: 1.4; max-width: 62ch; }
.tile .range b { font-weight: 600; }
.key { white-space: nowrap; margin-right: 6px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.sw.w { background: var(--win); } .sw.d { background: var(--draw); } .sw.l { background: var(--loss); }
.li .likely { font-size: 0.85rem; white-space: nowrap; }
