/* ============================================================
   Live Game Expanded View — css/liveGame.css
   Scoped to .lg-* selectors. All values from variables.css tokens.
   ============================================================ */

/* ── Full-page wrapper (showMLBLiveGame) ──────────────────── */

.lg-live-page {
    max-width: 680px;
    margin: 0 auto;
    padding: 0 var(--space-3) var(--space-6);
}

.lg-live-page .lg-panel {
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
    border-left: 3px solid var(--lg-team-color, var(--accent));
}

/* ── Panel container ──────────────────────────────────────── */

.lg-panel {
    border-left: 3px solid var(--lg-team-color, var(--accent));
    background: var(--bg-surface);
    border-top: 1px solid var(--border-default);
    border-bottom: 1px solid var(--border-default);
    padding: var(--space-4);
    animation: lgPanelOpen 180ms ease-out forwards;
    outline: none;
}

@keyframes lgPanelOpen {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .lg-panel { animation: none; }
}

/* ── Header ───────────────────────────────────────────────── */

.lg-header {
    position: relative;
    margin-bottom: var(--space-3);
}

.lg-close-btn {
    position: absolute;
    top: 0;
    right: 0;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    color: var(--text-subtle);
    padding: 0 0.25rem;
    transition: color var(--transition-fast);
}
.lg-close-btn:hover { color: var(--text-secondary); }

.lg-scoreline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.lg-abbr {
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--text-muted);
    min-width: 2.5rem;
    text-align: center;
}
.lg-abbr.lg-winner { color: var(--text-primary); }

.lg-score {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: 800;
    color: var(--text-primary);
    min-width: 2rem;
    text-align: center;
    transition: background var(--transition-fast);
}
.lg-score--win  { color: var(--color-win); }
.lg-score--loss { color: var(--text-subtle); }

.lg-sep {
    font-size: var(--text-lg);
    color: var(--text-subtle);
}

.lg-meta-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.lg-inning {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--text-secondary);
}

.lg-count-pill {
    background: var(--bg-raised);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-full);
    padding: 0.15rem 0.6rem;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-secondary);
}

.lg-status-badge {
    font-size: var(--text-xs);
}

.lg-scorecard-link {
    font-size: var(--text-xs);
    color: var(--accent);
    text-decoration: none;
}
.lg-scorecard-link:hover { text-decoration: underline; }

/* ── Freshness timestamp ──────────────────────────────────── */

.lg-poll-ts {
    text-align: right;
    font-size: 0.7rem;
    color: var(--text-subtle);
    min-height: 1em;
    margin-top: calc(var(--space-3) * -1);
    margin-bottom: var(--space-2);
}

/* ── Linescore ────────────────────────────────────────────── */

.lg-linescore-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin: var(--space-3) 0;
}
.lg-linescore-wrap::-webkit-scrollbar { display: none; }

.lg-linescore {
    display: grid;
    grid-template-columns: 48px repeat(var(--lg-innings, 9), minmax(28px, 1fr)) 24px 24px 24px;
    min-width: max-content;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: var(--text-xs);
}

.lg-linescore-cell {
    text-align: center;
    padding: 0.25rem 0.15rem;
    color: var(--text-secondary);
}

.lg-linescore-cell--header {
    color: var(--text-subtle);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 1px solid var(--border-default);
}

.lg-linescore-cell--active {
    background: var(--accent-subtle);
    color: var(--accent);
    border-radius: var(--radius-xs);
}

.lg-linescore-cell--rhe {
    font-weight: 800;
    color: var(--text-primary);
    border-left: 1px solid var(--border-default);
}

.lg-linescore-team {
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--text-muted);
    text-align: left;
    padding-left: 0.25rem;
}

/* ── Tab content area ─────────────────────────────────────── */

.lg-tabs { margin: var(--space-3) 0 var(--space-2); }

.lg-tab-content { min-height: 80px; }

/* ── Play-by-Play ─────────────────────────────────────────── */

.lg-pbp {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
}

.lg-pbp-inning {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 0.3rem 0.5rem 0.2rem;
    background: var(--bg-raised);
    border-bottom: 1px solid var(--border-default);
    position: sticky;
    top: 0;
    z-index: 1;
}

.lg-pbp-entry {
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid var(--border-default);
    font-size: var(--text-xs);
    color: var(--text-secondary);
    line-height: 1.5;
}
.lg-pbp-entry:last-child { border-bottom: none; }

.lg-pbp-entry--scoring {
    background: var(--color-win-subtle);
    border-left: 2px solid var(--color-win);
    padding-left: calc(0.5rem - 2px);
}

.lg-pbp-entry--hr::before { content: '💥 '; }

.lg-pbp-entry--new {
    animation: lgEntrySlide 200ms ease-out;
}
@keyframes lgEntrySlide {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
    .lg-pbp-entry--new { animation: none; }
}

.lg-pbp-score {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--color-win);
    margin-left: 0.4rem;
}

.lg-pbp-empty {
    padding: 0.75rem 0.5rem;
    color: var(--text-subtle);
    font-size: var(--text-xs);
    text-align: center;
}

/* ── Box Score ────────────────────────────────────────────── */

.lg-box { overflow-x: auto; }

.lg-box-section-title {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 0.5rem 0 0.25rem;
}

.lg-box-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-xs);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    min-width: 360px;
}

.lg-box-table th {
    color: var(--text-subtle);
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 0.2rem 0.4rem;
    border-bottom: 1px solid var(--border-default);
    text-align: right;
    white-space: nowrap;
}
.lg-box-table th:first-child { text-align: left; }

.lg-box-table td {
    padding: 0.18rem 0.4rem;
    color: var(--text-secondary);
    text-align: right;
    border-bottom: 1px solid var(--border-default);
    white-space: nowrap;
}
.lg-box-table td:first-child {
    text-align: left;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--text-xs);
}
.lg-box-table tr:last-child td { border-bottom: none; }

.lg-box-active {
    color: var(--color-live);
    font-size: 0.6rem;
    margin-right: 0.2rem;
}

/* ── Score-change flash ────────────────────────────────────── */
@keyframes lgScoreFlash {
    0%, 100% { background: transparent; }
    40%      { background: var(--color-win-subtle); }
}
.lg-score--flash {
    animation: lgScoreFlash 800ms ease-out 1 forwards;
    border-radius: var(--radius-xs);
}
@media (prefers-reduced-motion: reduce) {
    .lg-score--flash { animation: none; }
}

/* ── Retry button (DATA UNAVAILABLE state) ────────────────── */
.lg-retry-btn {
    background: none;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: var(--text-xs);
    font-family: inherit;
    padding: 0.15rem 0.5rem;
    cursor: pointer;
    transition: border-color var(--transition-fast), color var(--transition-fast);
}
.lg-retry-btn:hover { border-color: var(--accent); color: var(--accent); }
.lg-retry-btn:focus-visible {
    outline: 2px solid var(--accent-border);
    outline-offset: 2px;
    border-radius: var(--radius-xs);
}

/* ── Pitching change entry ─────────────────────────────────── */
.lg-pbp-entry--pitching-change {
    color: var(--text-muted);
    font-style: italic;
    border-left: 2px solid var(--border-mid);
    padding-left: calc(0.5rem - 2px);
}

/* ── Delay / suspension reason note ───────────────────────── */
.lg-delay-note {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    margin: 0.25rem var(--space-4) 0;
    padding: 0;
}

/* ── Phase 2: Two-column body layout ──────────────────────── */
.lg-body {
    display: flex;
    gap: var(--space-3);
    align-items: flex-start;
    margin-top: var(--space-2);
}

.lg-zone-col {
    flex: 0 0 130px;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.lg-tab-col {
    flex: 1 1 0;
    min-width: 0;
}

.lg-zone-section-label {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

@media (max-width: 768px) {
    .lg-body { flex-direction: column; }
    .lg-zone-col { width: 100%; flex: none; }
}

/* ── Phase 2: Pitch zone SVG ───────────────────────────────── */
.lg-zone-wrap { position: relative; }

.lg-pitch-zone {
    width: 100%;
    aspect-ratio: 5 / 7;
    display: block;
}

.lg-dot-group { cursor: pointer; }

.lg-dot-group circle:not(.lg-dot-focus-ring) {
    transition: r 120ms ease;
}

.lg-dot-group:hover circle:not(.lg-dot-focus-ring),
.lg-dot-group:focus-visible circle:not(.lg-dot-focus-ring) { r: 5px; }

.lg-dot-text {
    opacity: 0;
    pointer-events: none;
    transition: opacity 120ms ease;
}

.lg-dot-group:hover .lg-dot-text,
.lg-dot-group:focus-visible .lg-dot-text { opacity: 1; }

.lg-dot-focus-ring { opacity: 0; pointer-events: none; }
.lg-dot-group:focus-visible .lg-dot-focus-ring { opacity: 1; }
.lg-dot-group:focus-visible { outline: none; }

/* ── Phase 2: Pitch tooltip ────────────────────────────────── */
.lg-pitch-tooltip {
    position: absolute;
    background: var(--bg-raised);
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-sm);
    padding: 0.3rem 0.5rem;
    font-size: var(--text-xs);
    color: var(--text-secondary);
    white-space: nowrap;
    pointer-events: none;
    z-index: 10;
    box-shadow: var(--shadow-sm);
    line-height: 1.6;
}

/* ── Phase 2: Base runner diagram ──────────────────────────── */
.lg-base-diagram { display: block; margin: 0 auto; }

/* ── Phase 2: Matchup tab content ──────────────────────────── */
.lg-matchup-wrap { overflow-y: auto; max-height: 320px; }

.lg-matchup-block { padding: var(--space-2) 0; }

.lg-matchup-block + .lg-matchup-block {
    border-top: 1px solid var(--border-default);
    margin-top: 0;
}

.lg-matchup-empty {
    text-align: center;
    color: var(--text-subtle);
    font-size: var(--text-xs);
    padding: var(--space-3) 0;
    font-style: italic;
}

.lg-matchup-line {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    padding: 0.3rem 0;
    font-family: var(--font-mono);
}

/* ── Phase 2: SVG token classes ────────────────────────────────
   SVG presentation attributes cannot resolve CSS custom properties,
   so all fill/stroke values for zone/diagram elements live here. */

.lg-zone-rect  { fill: none; stroke: var(--border-strong); stroke-width: 1.5; }
.lg-zone-grid  { stroke: var(--border-default); stroke-width: 0.6; }

.lg-zone-legend {
    display: flex;
    gap: 0.4rem;
    justify-content: center;
    margin-top: 0.3rem;
    flex-wrap: wrap;
}

.lg-zone-legend-item {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius-full);
    border: 1px solid transparent;
}

.lg-zone-legend--ball   { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); border-color: var(--accent); }
.lg-zone-legend--strike { background: color-mix(in srgb, var(--color-loss) 18%, transparent); color: var(--color-loss); border-color: var(--color-loss); }
.lg-zone-legend--hit    { background: color-mix(in srgb, var(--color-pts) 18%, transparent); color: var(--color-pts); border-color: var(--color-pts); }

.lg-home-plate { fill: none; stroke: var(--border-mid); stroke-width: 1; }
.lg-home-plate-shape { fill: var(--bg-surface); stroke: var(--border-mid); stroke-width: 1.5; }

.lg-base-line { fill: none; stroke: var(--border-default); stroke-width: 1; }
.lg-base-empty { fill: var(--bg-surface); stroke: var(--border-mid); stroke-width: 1.5; }
.lg-base-occupied { fill: var(--color-pts); stroke: var(--color-pts); stroke-width: 1.5; }

.lg-dot-text { fill: var(--bg-base); }
.lg-dot-focus-ring { fill: none; stroke: var(--accent-border); stroke-width: 1.5; }

.lg-dot--ball      circle:not(.lg-dot-focus-ring) { fill: var(--accent); }
.lg-dot--cstrike   circle:not(.lg-dot-focus-ring) { fill: var(--color-win); }
.lg-dot--kstrike   circle:not(.lg-dot-focus-ring) { fill: var(--color-loss); }
.lg-dot--foul      circle:not(.lg-dot-focus-ring) { fill: var(--text-muted); }
.lg-dot--hit       circle:not(.lg-dot-focus-ring) { fill: var(--color-pts); }
.lg-dot--hr        circle:not(.lg-dot-focus-ring) { fill: var(--color-pts); stroke: var(--text-primary); stroke-width: 2; }
.lg-dot--out       circle:not(.lg-dot-focus-ring) { fill: var(--text-subtle); }
.lg-dot--unknown   circle:not(.lg-dot-focus-ring) { fill: var(--border-mid); }
