/**
 * livescore.css
 *
 * Mobile-first, container-adaptive styling for the live score widget.
 * Everything customizable lives in CSS custom properties on `.lsw-widget`
 * — override them per-site without touching this file (see README).
 *
 * Layout strategy: rather than viewport media queries (which don't know
 * whether the widget sits in a full-width content area or a 260px
 * sidebar), the match list uses CSS Grid with `auto-fill`/`minmax`, so it
 * reflows based on the width of its actual parent container. A couple of
 * small viewport media queries remain only for header/spacing polish on
 * very narrow screens (down to 320px).
 */

.lsw-widget {
	/* ---- Public theme tokens (override these) ---- */
	--live-primary: #1a8f5e;      /* accent: live badge, links, focus ring */
	--live-background: #ffffff;   /* widget background */
	--live-surface: #f6f8f7;      /* match card background */
	--live-text: #16211c;         /* primary text */
	--live-muted: #6b7a73;        /* secondary text (league, country, time) */
	--live-border: #e2e8e4;       /* hairline borders/dividers */
	--live-danger: #e5484d;       /* error state, LIVE pulse */
	--live-radius: 10px;
	--live-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

	/* ---- Internal tokens derived from the above ---- */
	--lsw-gap: 12px;
	--lsw-gap-sm: 8px;

	display: block;
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	font-family: var(--live-font);
	color: var(--live-text);
	background: var(--live-background);
	border: 1px solid var(--live-border);
	border-radius: var(--live-radius);
	overflow: hidden;
	line-height: 1.35;
	-webkit-text-size-adjust: 100%;
}

.lsw-widget,
.lsw-widget *,
.lsw-widget *::before,
.lsw-widget *::after {
  box-sizing: border-box;
}

/* Dark theme: either explicit data-theme="dark", or "auto" following the OS. */
.lsw-widget[data-theme="dark"] {
	--live-primary: #35c185;
	--live-background: #14181a;
	--live-surface: #1c2225;
	--live-text: #eef2f0;
	--live-muted: #93a29b;
	--live-border: #2a3134;
	--live-danger: #ff5f5f;
}

@media (prefers-color-scheme: dark) {
	.lsw-widget[data-theme="auto"] {
		--live-primary: #35c185;
		--live-background: #14181a;
		--live-surface: #1c2225;
		--live-text: #eef2f0;
		--live-muted: #93a29b;
		--live-border: #2a3134;
		--live-danger: #ff5f5f;
	}
}

.lsw-widget.lsw-widget--error { padding: 5px; font-size: 15px; font-style: italic; color: var(--live-danger); text-align: center; }

/* ---------- Header ---------- */

.lsw-header { display: flex; align-items: center; justify-content: space-between; gap: var(--lsw-gap-sm); padding: 12px 14px; border-bottom: 1px solid var(--live-border); }
.lsw-header__title { font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--live-text); }
.lsw-header__status { width: 8px; height: 8px; border-radius: 50%; background: var(--live-border); flex: 0 0 auto; }
.lsw-header__status.is-loading { background: var(--live-primary); animation: lsw-pulse 1s ease-in-out infinite; }
.lsw-header__status.is-error { background: var(--live-danger); }

/* ---------- Body / states ---------- */

.lsw-body { padding: var(--lsw-gap); }
.lsw-state { display: flex; align-items: center; gap: 8px; padding: 18px 10px; color: var(--live-muted); font-size: 13px; text-align: center; justify-content: center; }
.lsw-state--error { color: var(--live-danger); }
.lsw-state__icon { font-size: 15px; line-height: 1; }

/* ---------- Match list ---------- */

.lsw-matches { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--lsw-gap); list-style: none!important; margin: 0; padding: 0!important; }
.lsw-match { background: var(--live-surface); border: 1px solid var(--live-border); border-radius: calc(var(--live-radius) - 2px); padding: 10px 12px; min-width: 0;     /* allow child text-overflow ellipsis to work inside grid/flex */ }
.lsw-match__league { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; min-width: 0; }
.lsw-match__league-logo { flex: 0 0 auto; width: 16px; height: 16px; border-radius: 3px; object-fit: contain; }
.lsw-match__league-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 600; color: var(--live-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.lsw-match__country { font-weight: 400; text-transform: none; opacity: 0.85; }
.lsw-match__badge { flex: 0 0 auto; font-size: 10px; font-weight: 700; letter-spacing: 0.04em; color: var(--live-muted); padding: 2px 6px; border-radius: 999px; border: 1px solid var(--live-border); white-space: nowrap; }
.lsw-match__badge--live { color: #ffffff; background: var(--live-danger); border-color: var(--live-danger); position: relative; padding-left: 14px; }
.lsw-match__badge--live::before { content: ""; position: absolute; left: 6px; top: 50%; transform: translateY(-50%); width: 5px; height: 5px; border-radius: 50%; background: #ffffff; animation: lsw-pulse 1.2s ease-in-out infinite; }
.lsw-match__teams { display: flex; flex-direction: column; gap: 6px; }
.lsw-team { display: flex; align-items: center; gap: 8px; min-width: 0; }
.lsw-team__logo { flex: 0 0 auto; width: 20px; height: 20px; object-fit: contain; border-radius: 4px; }
.lsw-team__name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 500; }
.lsw-team__score { flex: 0 0 auto; min-width: 22px; text-align: right; font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; padding: 1px 4px; border-radius: 4px; transition: background-color 200ms ease, color 200ms ease; }
.lsw-team__score--changed { background: var(--live-primary); color: #ffffff; animation: lsw-score-pop 900ms ease; }
.lsw-match__minute { margin-top: 8px; font-size: 11px; font-weight: 700; color: var(--live-primary); font-variant-numeric: tabular-nums; }
.lsw-match__events { list-style: none!important; margin: 8px 0 0; padding: 8px 0 0; border-top: 1px dashed var(--live-border); display: flex; flex-direction: column; gap: 4px; }
.lsw-match__event { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--live-muted); min-width: 0; }
.lsw-match__event-icon { flex: 0 0 auto; font-size: 11px; }
.lsw-match__event-minute { flex: 0 0 auto; font-variant-numeric: tabular-nums; font-weight: 600; }
.lsw-match__event-scorer { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Motion ---------- */

@keyframes lsw-pulse {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.35; }
}

@keyframes lsw-score-pop {
	0% { transform: scale(1); }
	30% { transform: scale(1.18); }
	100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  	.lsw-header__status.is-loading, .lsw-match__badge--live::before, .lsw-team__score--changed { animation: none; }

}

/* ---------- Touch targets / very narrow screens (>=320px) ---------- */

@media (max-width: 360px) {
	.lsw-body { padding: var(--lsw-gap-sm); }
	.lsw-matches { grid-template-columns: 1fr;       /* single column once a card can't fit comfortably */ gap: var(--lsw-gap-sm); }
	.lsw-team__name { font-size: 13px; }
	.lsw-header { padding: 10px 12px; }
}

/* Widen internal spacing a touch once there's real room to breathe. */
@media (min-width: 640px) {
	.lsw-body { padding: 16px; }
}
