/* FPI page — extends the Volleyball Pipeline stylesheet. Tokens are redeclared so the
   page also renders standalone (e.g. a Cloudflare Pages preview without /styles.css). */

:root {
  --ink: #162029;
  --muted: #61717f;
  --line: #d9e1e8;
  --paper: #f7fafc;
  --white: #ffffff;
  --navy: #14324a;
  --teal: #0f766e;
  --coral: #d85c45;
  --gold: #e3a72f;
  --mint: #dff7ef;
  --fpi-pos: #0f766e;        /* diverging: above average */
  --fpi-pos-soft: rgba(15, 118, 110, 0.16);
  --fpi-neg: #d85c45;        /* diverging: below average */
  --fpi-neg-soft: rgba(216, 92, 69, 0.16);
  --fpi-bar: #14324a;        /* single-hue magnitude */
  --fpi-bar-soft: rgba(20, 50, 74, 0.12);
}

.fpi-page { background: var(--paper); }
.nav-links a.is-current { color: var(--navy); }

.fpi-shell { padding-top: 40px; }
.fpi-hero { padding-bottom: 20px; }
.fpi-hero h1 { color: var(--navy); font-size: clamp(2.4rem, 5.2vw, 4.4rem); line-height: 1; }

.fpi-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 26px;
}
.fpi-stat {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}
.fpi-stat strong { display: block; color: var(--navy); font-size: 1.5rem; line-height: 1.1; }
.fpi-stat span { display: block; margin-top: 4px; color: var(--muted); font-size: 0.8rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; }

.fpi-jump {
  position: sticky;
  top: 68px;
  z-index: 5;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 8px 0 28px;
  padding: 8px 0;
  background: var(--paper);
}
.fpi-jump a {
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  color: var(--navy);
  font-size: 0.86rem;
  font-weight: 800;
  text-decoration: none;
}
.fpi-jump a:hover { border-color: var(--gold); background: rgba(227, 167, 47, 0.14); }

.fpi-section { margin: 0 0 56px; scroll-margin-top: 130px; }
.fpi-status { margin: 0; color: var(--muted); font-weight: 750; }
.fpi-muted { color: var(--muted); margin: 0; }
.fpi-footnote { margin: 12px 0 0; color: var(--muted); font-size: 0.86rem; line-height: 1.5; max-width: 760px; }

/* ------------------------------------------------------------ controls */
.fpi-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 0 0 14px;
}
.fpi-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.fpi-pill {
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  color: var(--muted);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 800;
  cursor: pointer;
}
.fpi-pill.active, .fpi-pill:hover { color: var(--navy); background: var(--mint); border-color: var(--teal); }
.fpi-controls select, .fpi-controls input[type="search"], .fpi-matchup-form input, .fpi-matchup-form select {
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
}
.fpi-controls input[type="search"] { min-width: 180px; }
.fpi-check { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 0.86rem; font-weight: 700; }

/* --------------------------------------------------------------- table */
.fpi-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--white); }
.fpi-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; min-width: 880px; }
.fpi-table th, .fpi-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.fpi-table th { position: sticky; top: 0; background: #f4f8fa; color: var(--muted); font-size: 0.74rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.04em; }
.fpi-table th.num, .fpi-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.fpi-table tbody tr { cursor: pointer; }
.fpi-table tbody tr:hover { background: #f4f8fa; }
.fpi-table tbody tr:last-child td { border-bottom: 0; }
.fpi-table td.rank { color: var(--navy); font-weight: 900; }
.fpi-team { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.fpi-logo { width: 28px; height: 28px; border-radius: 50%; object-fit: contain; background: var(--paper); flex: 0 0 auto; }
.fpi-logo.blank { display: inline-block; background: var(--paper); border: 1px solid var(--line); }
.fpi-team strong { display: block; color: var(--navy); line-height: 1.1; }
.fpi-team small { display: block; margin-top: 2px; color: var(--muted); font-size: 0.76rem; font-weight: 700; }
.fpi-delta { font-weight: 800; }
.fpi-delta.up { color: var(--fpi-pos); }
.fpi-delta.down { color: var(--fpi-neg); }
.fpi-delta.flat { color: var(--muted); }

/* FPI value + diverging bar: bar grows from a center baseline, right for +, left for - */
.fpi-val { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; }
.fpi-val b { min-width: 3.2em; text-align: right; color: var(--navy); }
.fpi-divbar { position: relative; width: 84px; height: 8px; border-radius: 4px; background: var(--fpi-bar-soft); overflow: hidden; }
.fpi-divbar::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--line); }
.fpi-divbar i { position: absolute; top: 0; bottom: 0; }
.fpi-divbar i.pos { left: 50%; background: var(--fpi-pos); border-radius: 0 4px 4px 0; }
.fpi-divbar i.neg { right: 50%; background: var(--fpi-neg); border-radius: 4px 0 0 4px; }

.fpi-prob { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; }
.fpi-probbar { width: 60px; height: 8px; border-radius: 4px; background: var(--fpi-bar-soft); overflow: hidden; }
.fpi-probbar i { display: block; height: 100%; background: var(--fpi-bar); border-radius: 4px; }
.fpi-dim { color: var(--muted); }
.fpi-tag { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--mint); color: var(--navy); font-size: 0.7rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.04em; }
.fpi-tag.warn { background: rgba(227, 167, 47, 0.2); }

/* ------------------------------------------------------------ matchup */
.fpi-matchup { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 20px; align-items: start; }
.fpi-matchup-form { display: grid; gap: 12px; align-content: start; padding: 20px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); }
.fpi-matchup-form label { display: grid; gap: 6px; color: var(--muted); font-size: 0.78rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.04em; }
.fpi-matchup-form input, .fpi-matchup-form select { width: 100%; font-weight: 700; color: var(--ink); text-transform: none; letter-spacing: 0; }
.fpi-matchup-form select { max-width: 100%; }
.fpi-matchup-form .fpi-pill { justify-self: start; }
.fpi-matchup-result { min-height: 180px; padding: 20px; border: 1px solid var(--line); border-left: 5px solid var(--gold); border-radius: 8px; background: var(--white); }
.fpi-vs { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; }
.fpi-vs > div { text-align: center; }
.fpi-vs .fpi-logo.blank { display: none; }
.fpi-vs .big { display: block; color: var(--navy); font-size: 2.2rem; font-weight: 900; line-height: 1; }
.fpi-vs .name { display: block; margin-top: 6px; color: var(--navy); font-weight: 800; }
.fpi-vs .sub { display: block; color: var(--muted); font-size: 0.8rem; font-weight: 700; }
.fpi-vs .mid { color: var(--muted); font-weight: 900; }
.fpi-split { position: relative; height: 12px; margin: 16px 0 6px; border-radius: 6px; overflow: hidden; background: var(--fpi-neg-soft); }
.fpi-split i { display: block; height: 100%; background: var(--fpi-pos); }
.fpi-split::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; background: var(--white); }
.fpi-dist { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-top: 16px; }
.fpi-dist div { text-align: center; font-size: 0.8rem; color: var(--muted); font-weight: 700; }
.fpi-dist b { display: block; color: var(--navy); }
.fpi-dist .bar { height: 46px; display: flex; align-items: flex-end; margin-bottom: 4px; }
.fpi-dist .bar i { display: block; width: 100%; min-height: 2px; border-radius: 4px 4px 0 0; background: var(--fpi-bar); }
.fpi-dist .bar i.best { background: var(--gold); }

/* --------------------------------------------------------------- week */
.fpi-week { display: grid; gap: 16px; }
.fpi-day h3 { margin: 0 0 8px; color: var(--navy); font-size: 1rem; }
.fpi-day-list { display: grid; gap: 6px; }
.fpi-game {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px minmax(0, 1fr) 84px;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  font-size: 0.92rem;
}
.fpi-game .side { display: flex; align-items: center; gap: 8px; min-width: 0; }
.fpi-game .side > div { display: grid; min-width: 0; }
.fpi-game .side a { color: inherit; text-decoration: none; }
.fpi-game .side a:hover { text-decoration: underline; }
.fpi-day-more { margin-top: 6px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--white); color: var(--navy); font: inherit; font-size: 0.84rem; font-weight: 800; cursor: pointer; }
.fpi-day-more:hover { border-color: var(--gold); background: rgba(227, 167, 47, 0.14); }
.fpi-game .side.away { justify-content: flex-end; text-align: right; }
.fpi-game .side strong { color: var(--navy); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fpi-game .side.fav strong a { text-decoration: underline; text-decoration-color: var(--gold); text-decoration-thickness: 3px; text-underline-offset: 3px; }
.fpi-game .side small { color: var(--muted); font-weight: 800; font-size: 0.76rem; white-space: nowrap; }
.fpi-game .center { text-align: center; }
.fpi-game .center .pct { display: flex; justify-content: space-between; font-size: 0.8rem; font-weight: 900; color: var(--navy); font-variant-numeric: tabular-nums; }
.fpi-game .center .split { position: relative; height: 8px; margin: 4px 0; border-radius: 4px; overflow: hidden; background: var(--fpi-neg-soft); }
.fpi-game .center .split i { display: block; height: 100%; background: var(--fpi-pos); }
.fpi-game .center .meta { color: var(--muted); font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; }
.fpi-game .link { text-align: right; }
.fpi-game .link a { color: var(--coral); font-weight: 900; text-decoration: none; font-size: 0.84rem; }
.fpi-game.done { background: #fbfdfe; }
.fpi-game .score { color: var(--navy); font-weight: 900; font-size: 1.05rem; }

/* ------------------------------------------------------------ regions */
.fpi-region-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.fpi-region { border: 1px solid var(--line); border-radius: 8px; background: var(--white); overflow: hidden; }
.fpi-region h3 { margin: 0; padding: 12px 14px; border-bottom: 1px solid var(--line); background: #f4f8fa; color: var(--navy); font-size: 0.95rem; }
.fpi-region table { width: 100%; border-collapse: collapse; font-size: 0.82rem; table-layout: fixed; }
.fpi-region th, .fpi-region td { padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fpi-region col.c-team { width: auto; }
.fpi-region col.c-num { width: 50px; }
.fpi-region col.c-proj { width: 84px; }
.fpi-region th { color: var(--muted); font-size: 0.68rem; font-weight: 900; text-transform: uppercase; text-align: right; }
.fpi-region th:first-child, .fpi-region td:first-child { text-align: left; }
.fpi-region td { text-align: right; font-variant-numeric: tabular-nums; }
.fpi-region td:first-child { font-weight: 800; color: var(--navy); cursor: pointer; }
.fpi-region tr:last-child td { border-bottom: 0; }

/* ------------------------------------------------------------- method */
.fpi-method-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.fpi-method-grid article { padding: 20px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); }
.fpi-method-grid h3 { margin: 0 0 8px; color: var(--navy); font-size: 1.05rem; }
.fpi-method-grid p { margin: 0; color: var(--muted); line-height: 1.55; font-size: 0.94rem; }
.fpi-attribution { max-width: 800px; margin: 18px 0 0; padding: 12px 14px; border-left: 4px solid var(--gold); border-radius: 6px; background: var(--white); color: var(--muted); font-size: 0.9rem; line-height: 1.5; }
.fpi-attribution a { color: var(--teal); font-weight: 800; }

/* ------------------------------------------------------------- drawer */
.fpi-drawer-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(12, 27, 39, 0.45); }
.fpi-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 41;
  width: min(560px, 100vw);
  overflow-y: auto;
  padding: 24px 24px 40px;
  background: var(--white);
  box-shadow: -18px 0 42px rgba(22, 32, 41, 0.18);
}
.fpi-drawer-close { position: absolute; top: 12px; right: 14px; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; background: var(--white); color: var(--navy); font-size: 1.3rem; line-height: 1; cursor: pointer; }
.fpi-drawer-head { display: flex; gap: 14px; align-items: center; padding-right: 40px; }
.fpi-drawer-head .fpi-logo { width: 56px; height: 56px; }
.fpi-drawer-head h2 { margin: 0; color: var(--navy); font-size: 1.6rem; line-height: 1.05; }
.fpi-drawer-head p { margin: 4px 0 0; color: var(--muted); font-weight: 800; font-size: 0.86rem; }
.fpi-drawer-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 18px 0; }
.fpi-drawer-stats div { padding: 10px; border: 1px solid var(--line); border-radius: 8px; text-align: center; }
.fpi-drawer-stats b { display: block; color: var(--navy); font-size: 1.15rem; }
.fpi-drawer-stats span { color: var(--muted); font-size: 0.7rem; font-weight: 900; text-transform: uppercase; }
.fpi-drawer h3 { margin: 18px 0 8px; color: var(--navy); font-size: 1rem; }
.fpi-results { display: grid; gap: 4px; }
.fpi-result {
  display: grid; grid-template-columns: 58px 22px minmax(0, 1fr) auto auto; gap: 8px; align-items: center;
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 0.86rem;
}
.fpi-result .d { color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.fpi-result .wl { font-weight: 900; text-align: center; }
.fpi-result .wl.W { color: var(--fpi-pos); }
.fpi-result .wl.L { color: var(--fpi-neg); }
.fpi-result .opp { color: var(--navy); font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.fpi-result .opp small { color: var(--muted); font-weight: 700; }
.fpi-result .sc { color: var(--ink); font-weight: 800; font-variant-numeric: tabular-nums; }
.fpi-result .sets { color: var(--muted); font-size: 0.76rem; font-variant-numeric: tabular-nums; }
.fpi-result .p { color: var(--navy); font-weight: 900; font-variant-numeric: tabular-nums; }
.fpi-result a { color: var(--coral); font-size: 0.78rem; font-weight: 900; text-decoration: none; }
.fpi-drawer .fpi-attribution { font-size: 0.82rem; }

@media (max-width: 920px) {
  .fpi-stats { grid-template-columns: repeat(2, 1fr); }
  .fpi-matchup { grid-template-columns: 1fr; }
  .fpi-method-grid { grid-template-columns: 1fr; }
  .fpi-jump { top: 68px; }
  .fpi-game { grid-template-columns: minmax(0, 1fr) 120px minmax(0, 1fr); }
  .fpi-game .link { display: none; }
  .fpi-drawer-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .fpi-table { min-width: 0; font-size: 0.86rem; }
  .fpi-table th, .fpi-table td { padding: 8px 6px; }
  .fpi-table th:nth-child(6), .fpi-table td:nth-child(6),
  .fpi-table th:nth-child(7), .fpi-table td:nth-child(7),
  .fpi-table th:nth-child(8), .fpi-table td:nth-child(8),
  .fpi-table th:nth-child(9), .fpi-table td:nth-child(9) { display: none; }
  .fpi-team { min-width: 0; }
  .fpi-divbar { display: none; }
}
@media (max-width: 560px) {
  .fpi-game { grid-template-columns: 1fr; gap: 6px; }
  .fpi-game .side.away { justify-content: flex-start; text-align: left; }
  .fpi-dist { grid-template-columns: repeat(3, 1fr); }
  .fpi-result { grid-template-columns: 52px 20px minmax(0, 1fr) auto; }
  .fpi-result .sets { display: none; }
}
