/* Head-to-head explorer.
   Scoped to #h2h-root. Every class is prefixed h2h- (plus shared pf-skel for
   skeletons, defined globally). Colors, fonts and shadow come only from global
   CSS custom properties so light and dark mode flip automatically. */

.h2h-wrap { width: 100%; }

/* ---------- picker ---------- */
.h2h-picker {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px 18px;
  align-items: end;
  padding-bottom: 22px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--hair);
}
@media (min-width: 720px) {
  .h2h-picker {
    grid-template-columns: minmax(160px, 1fr) minmax(140px, 1.2fr) auto minmax(140px, 1.2fr) auto;
  }
  .h2h-field-lg { grid-column: 1 / 2; }
}

.h2h-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.h2h-label {
  font-family: var(--body);
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.h2h-select,
.h2h-input {
  font-family: var(--body);
  font-size: 15px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 5px;
  padding: 10px 12px;
  width: 100%;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}
.h2h-select {
  cursor: pointer;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink2) 50%),
    linear-gradient(135deg, var(--ink2) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}
.h2h-select:focus,
.h2h-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.h2h-input:disabled {
  color: var(--muted);
  background: color-mix(in srgb, var(--ink) 4%, var(--surface));
  cursor: not-allowed;
}

.h2h-vs {
  font-family: var(--disp);
  font-weight: 600;
  font-size: 15px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding-bottom: 11px;
  text-align: center;
}
@media (max-width: 719px) { .h2h-vs { padding-bottom: 0; text-align: left; } }

.h2h-btn {
  font-family: var(--disp);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: .03em;
  color: var(--accent-ink);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 5px;
  padding: 10px 22px;
  cursor: pointer;
  transition: background .12s ease, opacity .12s ease;
}
@media (hover: hover) { .h2h-btn:hover { background: var(--accent-deep); border-color: var(--accent-deep); } }
.h2h-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent);
}
.h2h-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- status messages ---------- */
.h2h-status { min-height: 4px; }
.h2h-msg {
  font-family: var(--body);
  font-size: 14px;
  color: var(--ink2);
  margin: 0;
  padding: 4px 0;
}
.h2h-loading { color: var(--muted); }
.h2h-ok { color: var(--ink2); }
.h2h-err { color: var(--ink); }

/* ---------- result ---------- */
.h2h-result { width: 100%; }

.h2h-head { margin: 6px 0 18px; }
.h2h-title {
  font-family: var(--disp);
  font-weight: 700;
  font-size: clamp(26px, 6vw, 44px);
  line-height: 1.02;
  color: var(--ink);
  margin: 0;
  letter-spacing: -.01em;
}
.h2h-title-vs {
  font-weight: 500;
  color: var(--muted);
  font-size: .6em;
  padding: 0 .15em;
}

.h2h-empty {
  font-family: var(--body);
  font-size: 16px;
  color: var(--ink2);
  padding: 26px 0;
  border-top: 1px solid var(--hair);
  border-bottom: 1px solid var(--hair);
}

/* record strip */
.h2h-record {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin: 0 0 22px;
}
.h2h-tally {
  flex: 1 1 auto;
  min-width: 96px;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 5px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.h2h-tally-n {
  font-family: var(--disp);
  font-weight: 700;
  font-size: clamp(30px, 7vw, 42px);
  line-height: .95;
  color: var(--ink);
}
.h2h-tally-l {
  font-family: var(--body);
  font-size: 13px;
  color: var(--muted);
}
.h2h-tally-total .h2h-tally-n { color: var(--accent); }
.h2h-tally-scori .h2h-tally-n { color: var(--cat2); }   /* scorigamis, in the scorigami accent */

/* Scores this matchup has produced — scorigami finals highlighted. */
.h2h-scores { margin: 0 0 26px; }
.h2h-scores-sub {
  display: block; margin-top: 5px;
  font: 400 12.5px/1.4 var(--body); letter-spacing: 0; text-transform: none; color: var(--muted);
}
.h2h-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.h2h-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font: 600 13px var(--mono); color: var(--ink2);
  background: var(--surface); border: 1px solid var(--hair); border-radius: 4px;
  padding: 5px 9px; text-decoration: none; transition: border-color .12s, color .12s, background .12s;
}
@media (hover: hover) { .h2h-chip:hover { border-color: var(--accent); color: var(--accent-deep); } }
.h2h-chip.is-scori { color: var(--paper); background: var(--cat2); border-color: var(--cat2); }
@media (hover: hover) { .h2h-chip.is-scori:hover { color: var(--paper); border-color: var(--ink); } }
.h2h-chip-star { font-size: 10px; line-height: 1; }
.h2h-chip-n { font-size: 10.5px; color: var(--muted); }
.h2h-chip.is-scori .h2h-chip-n { color: color-mix(in srgb, var(--paper) 78%, var(--cat2)); }

/* Compare scorigami grids — two teams' full score maps on one shared axis. */
.h2h-cmp { margin: 0 0 26px; }
.h2h-cmp-legend {
  display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 12px 0 14px;
  font: 500 12px var(--body); color: var(--ink2);
}
.h2h-cmp-key { display: inline-flex; align-items: center; gap: 6px; }
.h2h-cmp-sw { width: 11px; height: 11px; flex: none; border-radius: 2px; border: 1px solid var(--hair); }
.h2h-cmp-sw.is-a { background: var(--accent); border-color: var(--accent); }
.h2h-cmp-sw.is-b { background: var(--cat2); border-color: var(--cat2); }
.h2h-cmp-sw.is-shared { background: var(--base); border-color: var(--base); }
.h2h-cmp-sw.is-scori { background: var(--cat3); border-color: var(--cat3); }
.h2h-cmp-export {
  margin-left: auto;
  padding: 5px 11px;
  border: 1px solid var(--base);
  border-radius: 3px;
  background: var(--paper);
  color: var(--ink);
  font: 500 12px var(--body);
  cursor: pointer;
}
@media (hover: hover) { .h2h-cmp-export:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); } }
.h2h-cmp-teamlink {
  align-self: flex-start;
  font: 500 12.5px var(--body);
  color: var(--accent-deep);
  text-decoration: none;
}
@media (hover: hover) { .h2h-cmp-teamlink:hover { text-decoration: underline; } }
/* 44px touch targets for the export action and the team deep links. */
@media (pointer: coarse) {
  .h2h-cmp-export { min-height: 44px; padding: 8px 14px; }
  .h2h-cmp-teamlink { min-height: 44px; display: inline-flex; align-items: center; }
}
/* Two full ScoreGrid stages, one shared axis. Side by side when there is
   room, stacked on narrow screens; each stage owns its tooltip + zoom. */
.h2h-cmp-fullpair {
  display: grid; grid-template-columns: 1fr; gap: 22px; align-items: start;
}
@media (min-width: 980px) { .h2h-cmp-fullpair { grid-template-columns: 1fr 1fr; gap: 18px; } }
.h2h-cmp-col { margin: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.h2h-cmp-head {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  font: 400 12px var(--body); color: var(--muted);
}
.h2h-cmp-head b {
  font: 700 15px var(--disp); color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.h2h-cmp-meta { margin-left: auto; flex: none; font: 400 12px var(--body); color: var(--muted); }
.h2h-stage {
  position: relative;
  height: clamp(340px, 52vw, 520px);
  border: 1px solid var(--hair);
  border-radius: 5px;
  background: var(--paper);
  overflow: hidden;
  box-shadow: var(--shadow);
}
/* The engine sizes the BITMAP by devicePixelRatio and relies on CSS to size
   the element (same contract as .stage canvas in site.css); without this the
   canvas lays out dpr-times too large and hover picks the wrong cells. */
.h2h-stage canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: pan-y;
}
.h2h-cmp-note { margin: 12px 0 0; font: 400 12px/1.5 var(--body); color: var(--muted); }
@media (max-width: 979px) {
  /* Stacked (not side-by-side) below 980px, so give each compare grid more
     height to explore, and dock the zoom controls in the empty upper-left
     triangle (losing > winning has no cells) instead of over the score cloud. */
  .h2h-stage { height: clamp(360px, 82vw, 460px); }
  .h2h-stage .zoomctl { top: 12px; left: 12px; right: auto; bottom: auto; }
}
@media (max-width: 460px) {
  .h2h-cmp-legend { gap: 6px 12px; }
}

/* summary */
.h2h-summary {
  list-style: none;
  margin: 0 0 26px;
  padding: 0;
  display: grid;
  gap: 0;
  border: 1px solid var(--hair);
  border-radius: 5px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.h2h-sum-item {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--hair);
}
.h2h-sum-item:last-child { border-bottom: none; }
.h2h-sum-lab {
  font-family: var(--body);
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  flex: 0 0 auto;
  min-width: 40%;
}
@media (min-width: 560px) { .h2h-sum-lab { min-width: 220px; } }
.h2h-sum-score {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 18px;
  color: var(--accent);
  text-decoration: none;
}
@media (hover: hover) { .h2h-sum-score:hover { text-decoration: underline; } }
.h2h-sum-meta {
  font-family: var(--body);
  font-size: 14px;
  color: var(--ink2);
}
.h2h-sum-note {
  font-family: var(--body);
  font-size: 14px;
  color: var(--ink2);
}

/* meetings */
.h2h-list-title {
  font-family: var(--disp);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 4px;
}
.h2h-meetings {
  list-style: none;
  margin: 0;
  padding: 0;
}
.h2h-meeting {
  padding: 14px 0;
  border-bottom: 1px solid var(--hair);
}
.h2h-meeting:first-child { border-top: 1px solid var(--hair); }

.h2h-m-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px 16px;
  flex-wrap: wrap;
}
.h2h-m-line {
  font-family: var(--body);
  font-size: 16px;
  color: var(--ink2);
  min-width: 0;
}
.h2h-m-team { color: var(--ink); }
.h2h-m-winner { font-weight: 700; }
.h2h-m-verb { color: var(--muted); }

.h2h-m-score {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 20px;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 1px solid transparent;
}
@media (hover: hover) { .h2h-m-score:hover { color: var(--accent); border-bottom-color: color-mix(in srgb, var(--accent) 50%, transparent); } }

.h2h-m-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  margin-top: 6px;
}
.h2h-m-season {
  font-family: var(--body);
  font-size: 13px;
  color: var(--ink2);
}
.h2h-m-date {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}
.h2h-tag {
  font-family: var(--body);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 3px;
  padding: 2px 7px;
  line-height: 1.5;
}
