/* ============================================================
   HEAD-TO-HEAD DASHBOARD
   ============================================================ */

/* ── Hero + Selector (combined) ────────────────────────────── */
.h2h-hero {
    background: var(--pl-green);
    background-image: repeating-linear-gradient(
        90deg, transparent, transparent 28px,
        rgba(255,255,255,0.04) 28px, rgba(255,255,255,0.04) 30px
    );
    padding: 32px 24px 44px;
    position: relative;
    overflow: hidden;
}
.h2h-hero::after {
    content: '';
    position: absolute;
    bottom: -30px; left: 0; right: 0;
    height: 60px;
    background: var(--pl-white);
    clip-path: ellipse(55% 100% at 50% 100%);
}
.h2h-hero__inner { position: relative; z-index: 1; }

.h2h-hero__title {
    font-family: var(--pl-font-display);
    font-size: clamp(1.6rem, 4vw, 2.6rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--pl-white);
    margin: 0 0 20px;
}

/* ── Selectors ─────────────────────────────────────────────── */
.h2h-selector-form { width: 100%; }

.h2h-selector-pair {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.h2h-team-select-group {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.h2h-team-select-wrap,
.h2h-year-select-wrap {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.h2h-select-label {
    font-family: var(--pl-font-display);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.5);
}

.h2h-select {
    font-family: var(--pl-font-display);
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--pl-white);
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: var(--pl-radius);
    padding: 9px 32px 9px 12px;
    min-width: 200px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='rgba(255,255,255,0.6)' d='M5 6L0 0h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: border-color 0.15s, background-color 0.15s;
}
.h2h-select:focus {
    outline: none;
    border-color: var(--pl-gold);
    background-color: rgba(255,255,255,0.15);
}
.h2h-select option { background: #1a1a1a; color: #fff; }

.h2h-select--year {
    min-width: 80px;
    padding-right: 28px;
}

.h2h-vs-badge {
    font-family: var(--pl-font-display);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: rgba(255,255,255,0.4);
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    padding: 8px 12px;
    border-radius: 20px;
    margin-bottom: 2px;
}

/* ── Empty state ───────────────────────────────────────────── */
.h2h-empty {
    padding: 80px 24px;
    text-align: center;
    color: var(--pl-ink-light);
    font-size: 1.05rem;
    font-style: italic;
}

/* ── Matchup Header ────────────────────────────────────────── */
.h2h-matchup-header {
    background: var(--pl-white);
    border-bottom: 1px solid var(--pl-border);
    padding: 28px 0;
}
.h2h-matchup-header__inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 20px;
}
.h2h-matchup-team {
    display: flex;
    align-items: center;
    gap: 14px;
}
.h2h-matchup-team--right { justify-content: flex-end; }
.h2h-matchup-team__logo {
    width: 72px;
    height: 72px;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.1));
}
.h2h-matchup-team__info { display: flex; flex-direction: column; }
.h2h-matchup-team__info--right { text-align: right; }
.h2h-matchup-team__name {
    font-family: var(--pl-font-display);
    font-size: clamp(0.9rem, 2vw, 1.35rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--h2h-accent, var(--pl-green));
    text-decoration: none;
    line-height: 1.1;
    transition: opacity 0.15s;
}
.h2h-matchup-team__name:hover { opacity: 0.7; text-decoration: none; }
.h2h-matchup-team__record {
    font-family: var(--pl-font-mono);
    font-size: 1rem;
    font-weight: 600;
    color: var(--pl-ink);
    margin-top: 3px;
}
.h2h-matchup-team__year {
    font-style: normal;
    font-size: 0.72rem;
    color: var(--pl-ink-light);
    font-weight: 400;
    margin-left: 4px;
}

/* Win probability */
.h2h-wp-block { text-align: center; min-width: 180px; }
.h2h-wp-bar {
    display: flex;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 8px;
    background: var(--pl-border);
}
.h2h-wp-bar__fill { transition: width 0.4s ease; }
.h2h-wp-labels {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 4px;
}
.h2h-wp-pct {
    font-family: var(--pl-font-mono);
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1;
}
.h2h-wp-label {
    font-family: var(--pl-font-display);
    font-size: 0.58rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--pl-ink-light);
}
.h2h-elo-line {
    display: flex;
    justify-content: space-between;
    font-family: var(--pl-font-mono);
    font-size: 0.62rem;
    color: var(--pl-ink-light);
    letter-spacing: 0.04em;
}

/* ── Sections ──────────────────────────────────────────────── */
.h2h-section {
    padding: 36px 0;
    background: var(--pl-white);
    border-top: 1px solid var(--pl-border);
}
.h2h-section--alt { background: var(--pl-cream); }

.h2h-section-title {
    font-family: var(--pl-font-display);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--pl-ink);
    margin-bottom: 14px;
    padding-bottom: 7px;
    border-bottom: 2px solid var(--pl-green);
    display: inline-block;
}

/* ── Full-width override for h2h page ──────────────────────── */
/* The standard .pl-container has side padding that wastes space
   on this data-dense page. Override to use max available width. */
.pl-page .h2h-section .pl-container,
.pl-page .h2h-section.h2h-section--alt .pl-container,
.h2h-matchup-header .pl-container,
.h2h-hero .pl-container {
    max-width: 100%;
    padding-left: 20px;
    padding-right: 20px;
}

/* ── Side-by-side tables ───────────────────────────────────── */
.h2h-tables-sidebyside {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
}

/* Compact table — tighter cells for the dense hitter/pitcher tables */
.h2h-table-wrap { overflow-x: auto; }
.h2h-table { font-size: 0.78rem; }
.h2h-table--compact td,
.h2h-table--compact th { padding: 6px 7px !important; }
.h2h-table--compact .h2h-table__name { min-width: 120px !important; max-width: 160px; }

.h2h-table__name {
    text-align: left !important;
    min-width: 130px !important;
    max-width: 170px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.h2h-table__pos {
    font-family: var(--pl-font-display) !important;
    font-size: 0.68rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.05em !important;
    text-transform: uppercase !important;
    color: var(--pl-ink-light) !important;
    text-align: center !important;
    width: 32px !important;
    min-width: 32px !important;
    max-width: 36px !important;
    white-space: nowrap;
}
/* In the header the pos th inherits team color from inline style */
thead .h2h-table__pos { color: inherit !important; }

.h2h-thead-year {
    font-size: 0.62rem;
    font-weight: 400;
    opacity: 0.65;
    margin-left: 4px;
}
.h2h-player-link {
    color: var(--pl-ink);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.12s;
}
.h2h-player-link:hover { color: var(--pl-green); text-decoration: underline; }
.h2h-ops-cell  { font-weight: 600; }
.h2h-era-cell  { font-weight: 600; }
.h2h-empty-cell {
    text-align: center !important;
    color: var(--pl-ink-light);
    font-style: italic;
    padding: 20px !important;
}

/* ── OPS+ / ERA+ gradient badges ──────────────────────────── */
/* Colors applied via inline style by h2h_plus_badge() —
   red (≤50) → white (100) → green (≥160), matching Google Sheets gradient */
.h2h-plus-badge {
    display: inline-block;
    font-family: var(--pl-font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    line-height: 1.4;
    min-width: 32px;
    text-align: center;
}

/* ── Compare grid (season summary) ────────────────────────── */
.h2h-compare-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}
.h2h-compare-card {
    border: 1px solid var(--pl-border);
    border-radius: var(--pl-radius-lg);
    overflow: hidden;
    background: var(--pl-white);
    box-shadow: var(--pl-shadow);
}
.h2h-compare-card__title {
    font-family: var(--pl-font-display);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--pl-white);
    background: var(--pl-green);
    padding: 7px 12px;
    margin: 0;
}
.h2h-stat-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 7px 12px;
    border-bottom: 1px solid var(--pl-border);
    gap: 6px;
}
.h2h-stat-row:last-child { border-bottom: none; }
.h2h-stat-row:hover { background: var(--pl-green-muted); }
.h2h-stat-val {
    font-family: var(--pl-font-mono);
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--pl-ink);
    text-align: right;
}
.h2h-stat-val:last-child { text-align: left; }
.h2h-stat-label {
    font-family: var(--pl-font-display);
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--pl-ink-light);
    text-align: center;
    white-space: nowrap;
}
/* Better/worse in compare cards — distinct colors */
.h2h-stat--better {
    color: #1a7a4a !important;
    font-weight: 700 !important;
}
.h2h-stat--worse {
    color: #c9202a !important;
    font-weight: 400 !important;
    opacity: 0.65;
}

/* ── Results grid ──────────────────────────────────────────── */
.h2h-results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 28px;
    align-items: start;
}
.h2h-results-list { display: flex; flex-direction: column; gap: 5px; }
.h2h-empty-msg {
    color: var(--pl-ink-light);
    font-style: italic;
    font-size: 0.9rem;
    padding: 12px 0;
}

/* Focus result rows (last 10 — from that team's view) */
.h2h-result-row {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 9px;
    border: 1px solid var(--pl-border);
    border-radius: var(--pl-radius);
    background: var(--pl-white);
    font-size: 0.82rem;
    transition: background 0.1s;
}
.h2h-result-row:hover { background: var(--pl-cream); }
.h2h-result-row__badge {
    font-family: var(--pl-font-mono);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    flex-shrink: 0;
    min-width: 18px;
    text-align: center;
}
.h2h-result--win  { background: #d4edda; color: #155724; }
.h2h-result--loss { background: #f8d7da; color: #721c24; }
.h2h-result-row__ha {
    font-family: var(--pl-font-display);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--pl-ink-light);
    flex-shrink: 0;
    min-width: 14px;
}
.h2h-result-row__logo {
    width: 18px;
    height: 18px;
    object-fit: contain;
    flex-shrink: 0;
    display: block;
}
.h2h-result-row__opp {
    flex: 1;
    font-weight: 600;
    color: var(--pl-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.8rem;
}
.h2h-result-row__score {
    font-family: var(--pl-font-mono);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--pl-ink);
    flex-shrink: 0;
}
.h2h-result-row__box {
    font-family: var(--pl-font-display);
    font-size: 0.58rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--pl-green);
    text-decoration: none;
    border: 1px solid var(--pl-green);
    padding: 1px 5px;
    border-radius: 3px;
    flex-shrink: 0;
    transition: background 0.12s, color 0.12s;
}
.h2h-result-row__box:hover { background: var(--pl-green); color: var(--pl-white); text-decoration: none; }

/* Neutral H2H rows */
.h2h-result-row--neutral { justify-content: space-between; padding: 7px 10px; }
.h2h-neutral-team {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.h2h-neutral-team--home { justify-content: flex-end; }
.h2h-neutral-abbr {
    font-family: var(--pl-font-display);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--pl-ink-mid);
}
.h2h-neutral-abbr--win { color: var(--pl-ink); }
.h2h-neutral-score {
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: var(--pl-font-mono);
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--pl-ink);
    text-decoration: none;
    flex-shrink: 0;
    padding: 0 8px;
    transition: color 0.12s;
}
.h2h-neutral-score:hover { color: var(--pl-green); text-decoration: none; }
.h2h-score--win { font-size: 1rem; color: var(--pl-ink); }
.h2h-score-dash { color: var(--pl-border); }

/* H2H record line */
.h2h-h2h-record {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--pl-font-mono);
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 10px;
}
.h2h-h2h-record__sep { color: var(--pl-border); }

/* ── Responsive — Tablet ───────────────────────────────────── */
@media (max-width: 1100px) {
    .h2h-compare-grid   { grid-template-columns: 1fr 1fr; }
    .h2h-compare-grid > .h2h-compare-card:last-child { grid-column: 1 / -1; }
    .h2h-results-grid   { grid-template-columns: 1fr 1fr; }
    .h2h-results-grid > div:last-child { grid-column: 1 / -1; }
}

@media (max-width: 900px) {
    .h2h-tables-sidebyside { grid-template-columns: 1fr; }
}

/* ── Responsive — Mobile ───────────────────────────────────── */
@media (max-width: 768px) {
    .h2h-hero { padding: 24px 16px 40px; }
    .h2h-hero__title { font-size: 1.5rem; margin-bottom: 16px; }

    .h2h-selector-pair  { flex-direction: column; align-items: stretch; gap: 12px; }
    .h2h-team-select-group { flex-direction: row; gap: 8px; }
    .h2h-team-select-wrap { flex: 1; }
    .h2h-year-select-wrap { flex-shrink: 0; }
    .h2h-select { min-width: 0; width: 100%; font-size: 0.82rem; padding: 8px 28px 8px 10px; }
    .h2h-select--year { min-width: 72px; }
    .h2h-vs-badge { text-align: center; margin: 0; padding: 6px; }

    .h2h-matchup-header__inner { grid-template-columns: 1fr; gap: 16px; text-align: center; }
    .h2h-matchup-team, .h2h-matchup-team--right { justify-content: center; }
    .h2h-matchup-team__info--right { text-align: center; }
    .h2h-matchup-team__logo { width: 56px; height: 56px; }

    .h2h-compare-grid   { grid-template-columns: 1fr; }
    .h2h-compare-grid > .h2h-compare-card:last-child { grid-column: auto; }
    .h2h-results-grid   { grid-template-columns: 1fr; }
    .h2h-results-grid > div:last-child { grid-column: auto; }

    .h2h-wp-block { min-width: 0; width: 100%; }
    .h2h-wp-pct   { font-size: 0.9rem; }
}

@media (max-width: 480px) {
    .h2h-table { font-size: 0.72rem; }
    .h2h-table__name { min-width: 110px !important; }
    .h2h-plus-badge { font-size: 0.68rem; padding: 1px 5px; }
    .h2h-result-row { gap: 5px; padding: 5px 7px; }
}