/*
 * Scorebox header + "Match Score" period card (livescore_v5_51.xsl, event-detail).
 * Works on the old generated markup too: same class names (.header-content, .left-teamlogo, .left-teamScore,
 * .teamsBlock, .leftTeam, .periodBlock, .rightTeam, .right-teamScore, .right-teamlogo), laid out with CSS grid.
 * Loaded after the inline styles in ls5/livescore.jsp, everything is scoped under .scorebox.
 */

.scorebox {
    --sb-text-strong: #ffffff;
    --sb-text-default: rgba(255, 255, 255, 0.82);
    --sb-text-muted: rgba(255, 255, 255, 0.55);
    --sb-text-subtle: rgba(255, 255, 255, 0.45);
    --sb-border: rgba(255, 255, 255, 0.16);
    --sb-card: rgba(6, 22, 16, 0.42);
    --sb-accent: #34d399;
    --sb-live: #f87171;
}

/* ---------- Header: [home] [score / status] [away] ---------- */

.scorebox .header-content {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 8px;
    row-gap: 2px;
    width: auto;
    padding: 12px 10px 14px;
    background: transparent;
    color: var(--sb-text-strong);
    box-sizing: border-box;
}

/* lets the team names and the status badge take part in the grid */
.scorebox .header-content .teamsBlock { display: contents; }
.scorebox .header-content > div[style*="clear"] { display: none; }

/* logos: row 1 at the sides */
.scorebox .header-content .left-teamlogo,
.scorebox .header-content .right-teamlogo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: 40px;
    grid-row: 1;
}
.scorebox .header-content .left-teamlogo { grid-column: 1; }
.scorebox .header-content .right-teamlogo { grid-column: 5; }

.scorebox .header-content .left-teamlogo img,
.scorebox .header-content .right-teamlogo img {
    width: 36px;
    height: 36px;
    max-width: none;
    object-fit: contain;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.35));
}

/* team names: row 2 at the sides */
.scorebox .header-content .leftTeam,
.scorebox .header-content .rightTeam {
    grid-row: 2;
    min-width: 0;
    text-align: center;
    text-shadow: none;
    color: var(--sb-text-strong);
}
.scorebox .header-content .leftTeam { grid-column: 1; }
.scorebox .header-content .rightTeam { grid-column: 5; }

.scorebox .header-content .team-place div {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.35;
}

/* status badge (and old period text): row 1, middle */
.scorebox .header-content .periodBlock {
    grid-column: 2 / 5;
    grid-row: 1;
    align-self: end;
    height: auto;
    padding-top: 2px;
    font-size: 10px;
    line-height: 1.3;
    color: var(--sb-text-default);
    text-align: center;
}

.scorebox .mx-sb-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
    padding: 2px 6px;
    border: 1px solid rgba(52, 211, 153, 0.3);
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.14);
    color: var(--sb-accent);
    font-size: 8px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}

.scorebox .mx-sb-status-live {
    border-color: rgba(248, 113, 113, 0.35);
    background: rgba(239, 68, 68, 0.16);
    color: var(--sb-live);
}

.scorebox .mx-sb-status-pre,
.scorebox .mx-sb-status-off {
    border-color: var(--sb-border);
    background: rgba(255, 255, 255, 0.08);
    color: var(--sb-text-default);
    letter-spacing: 0.04em;
}

.scorebox .mx-sb-time { white-space: nowrap; }

.scorebox .mx-sb-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: mx-sb-pulse 1.4s ease-in-out infinite;
}

@keyframes mx-sb-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.25; }
}

.scorebox .mx-sb-info {
    margin-top: 2px;
    color: var(--sb-text-muted);
    font-size: 10px;
}

/* score: row 2, middle  ->  [home score] [-] [away score] */
.scorebox .header-content .left-teamScore,
.scorebox .header-content .right-teamScore {
    grid-row: 2;
    display: block;
    width: auto;
    margin: 0;
    padding: 0;
    overflow: visible;
    font-size: 24px;
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    text-transform: none;
    text-align: center !important;
}
.scorebox .header-content .left-teamScore { grid-column: 2; }
.scorebox .header-content .right-teamScore { grid-column: 4; }

/* the dash between the scores */
.scorebox .header-content::after {
    content: "-";
    grid-column: 3;
    grid-row: 2;
    color: var(--sb-text-subtle);
    font-size: 16px;
    font-weight: 700;
}

.scorebox .header-content .teamfullname {
    background: linear-gradient(135deg, var(--sb-text-strong), var(--sb-text-default));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--sb-text-strong);
}

/* team that is behind (or lost) */
.scorebox .header-content .mx-sb-trail .teamfullname {
    background: none;
    -webkit-text-fill-color: currentColor;
    color: var(--sb-text-muted);
}

@media (min-width: 640px) {
    .scorebox .header-content { column-gap: 16px; padding: 16px 16px 18px; align-items: center; }
    .scorebox .header-content .left-teamlogo,
    .scorebox .header-content .right-teamlogo { height: 64px; }
    .scorebox .header-content .left-teamlogo img,
    .scorebox .header-content .right-teamlogo img { width: 56px; height: 56px; }
    .scorebox .header-content .team-place div { font-size: 16px; }
    .scorebox .mx-sb-status { margin-bottom: 8px; padding: 2px 10px; font-size: 10px; }
    .scorebox .header-content .left-teamScore,
    .scorebox .header-content .right-teamScore { font-size: 48px; }
    .scorebox .header-content::after { font-size: 20px; }
}

/* ---------- "Match Score" card with period-by-period scores ---------- */

.scorebox .mx-period-scores {
    position: relative;
    z-index: 1;
    margin: 0 8px 10px;
    padding: 12px;
    overflow: hidden;
    border: 1px solid var(--sb-border);
    border-radius: 4px;
    background: var(--sb-card);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
    color: var(--sb-text-strong);
    text-align: left;
}

.scorebox .mx-ps-title {
    margin: 0 0 12px;
    color: var(--sb-text-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.scorebox .mrk {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.scorebox .mrts {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.scorebox .mrtm {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    height: 18px;
}

.scorebox .mrl {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    object-fit: contain;
}

.scorebox .mrtn {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
}

.scorebox .mrtn-strong { font-weight: 700; color: var(--sb-text-strong); }
.scorebox .match-muted { color: var(--sb-text-muted); font-weight: 500; }

.scorebox .mrsc {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
}

.scorebox .mrpr {
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0.9;
    font-variant-numeric: tabular-nums;
}

.scorebox .mrpc {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 16px;
}

.scorebox .mrpc span {
    height: 18px;
    font-size: 12px;
    font-weight: 500;
    line-height: 18px;
}

.scorebox .match-card-divider {
    width: 1px;
    height: 24px;
    margin: 0 4px;
    flex: 0 0 1px;
    background: var(--sb-border);
    opacity: 0.8;
}

.scorebox .mrft {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 18px;
    margin-left: 4px;
    font-variant-numeric: tabular-nums;
}

.scorebox .mrft div {
    height: 18px;
    font-size: 13px;
    font-weight: 800;
    line-height: 18px;
    color: var(--sb-text-strong);
}

.scorebox .mrft div.match-muted { color: var(--sb-text-muted); font-weight: 700; }

/* "FT" above the final score column (finished matches only). Absolutely positioned so the score rows stay aligned with the team names. */
.scorebox .mrft { position: relative; }
.scorebox .mrft-label {
    position: absolute;
    bottom: 100%;
    left: 50%;
    margin-bottom: 4px;
    transform: translateX(-50%);
    color: var(--sb-text-muted);
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}

@media (min-width: 640px) {
    .scorebox .mx-period-scores { margin: 0 16px 14px; padding: 16px; }
}
