/**
 * ZiGoats Football — front-end styles.
 *
 * Follows the zigoats FSE theme design tokens (theme.json presets):
 *   primary   #176d21 (green)   --wp--preset--color--primary
 *   secondary #fbf418 (yellow)  --wp--preset--color--secondary
 *   contrast  #1e1e1e           --wp--preset--color--contrast
 *   base      #ffffff           --wp--preset--color--base
 *   font      Nunito Sans       --wp--preset--font-family--nunito-sans
 * Fallback values are provided for non-FSE contexts.
 *
 * Layout safety: every fixed width in here is small (status column, logos);
 * team names truncate with ellipsis and containers cap at 100%, so these
 * components can never cause horizontal page scrolling.
 */

.zgf-matches,
.zgf-search {
	--zgf-primary: var(--wp--preset--color--primary, #176d21);
	--zgf-secondary: var(--wp--preset--color--secondary, #fbf418);
	--zgf-contrast: var(--wp--preset--color--contrast, #1e1e1e);
	--zgf-base: var(--wp--preset--color--base, #ffffff);
	--zgf-line: rgba(30, 30, 30, 0.1);
	--zgf-muted: rgba(30, 30, 30, 0.55);
	--zgf-radius: 8px;

	font-family: var(--wp--preset--font-family--nunito-sans, 'Nunito Sans', -apple-system, BlinkMacSystemFont, sans-serif);
	color: var(--zgf-contrast);

	/* Follow the theme's layout system: cap at theme.json contentSize and
	   center, exactly like blocks inside a constrained layout. WordPress
	   emits --wp--style--global--content-size / --wide-size site-wide, so
	   this also holds when the block sits at the root of an FSE template
	   (where no parent applies the constraint). min() preserves the
	   no-horizontal-scroll guarantee in narrow parents. */
	max-width: min(100%, var(--wp--style--global--content-size, 1100px));
	margin-left: auto;
	margin-right: auto;
	margin-bottom: 1.5rem;
}

.zgf-matches.alignwide,
.zgf-search.alignwide {
	max-width: min(100%, var(--wp--style--global--wide-size, 1400px));
}

.zgf-matches.alignfull,
.zgf-search.alignfull {
	max-width: 100%;
}

.zgf-matches *,
.zgf-search * {
	box-sizing: border-box;
	min-width: 0; /* lets flex children shrink instead of overflowing */
}

.zgf-matches img,
.zgf-search img {
	max-width: 100%;
	height: auto;
}

.zgf-matches__title {
	font-size: var(--wp--preset--font-size--large, 1.75rem);
	line-height: 1.2;
	margin: 0 0 1rem;
	padding-bottom: 0.4rem;
	border-bottom: 4px solid var(--zgf-primary);
	display: inline-block;
	overflow-wrap: anywhere;
}

/* ------------------------------------------------------------------ *
 * League cards
 * ------------------------------------------------------------------ */

.zgf-league-group {
	border: 1px solid var(--zgf-line);
	border-radius: var(--zgf-radius);
	background: var(--zgf-base);
	box-shadow: 0 1px 3px rgba(30, 30, 30, 0.06);
	overflow: hidden;
	margin: 0 0 1rem;
}

.zgf-league-header {
	display: flex;
	align-items: center;
	gap: 0.55rem;
	padding: 0.55rem 0.9rem;
	background: var(--zgf-primary);
	color: #fff;
}

.zgf-league-header__logo {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	flex: 0 0 26px;
	border-radius: 50%;
	background: #fff;
	overflow: hidden;
}

.zgf-league-header__logo img {
	width: 18px;
	height: 18px;
	object-fit: contain;
}

.zgf-league-header__name {
	font-size: 0.82rem;
	font-weight: 800;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.zgf-league-header__country {
	font-size: 0.75rem;
	font-weight: 600;
	opacity: 0.75;
	margin-left: auto;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	flex-shrink: 1;
}

/* ------------------------------------------------------------------ *
 * Fixture rows
 * ------------------------------------------------------------------ */

.zgf-fixture-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.zgf-fixture {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.6rem 0.9rem;
	border-top: 1px solid var(--zgf-line);
	transition: background-color 0.15s ease;
}

.zgf-league-header + .zgf-fixture-list .zgf-fixture:first-child,
.zgf-fixture-list:first-child .zgf-fixture:first-child {
	border-top: none;
}

.zgf-fixture:hover {
	background: rgba(23, 109, 33, 0.045);
}

.zgf-fixture--live {
	box-shadow: inset 3px 0 0 var(--zgf-primary);
	background: rgba(23, 109, 33, 0.04);
}

/* Status column */

.zgf-fixture__status {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.2rem;
	flex: 0 0 56px;
	width: 56px;
	text-align: center;
}

.zgf-fixture__time {
	font-size: 0.85rem;
	font-weight: 800;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.zgf-fixture__date {
	font-size: 0.68rem;
	font-weight: 600;
	color: var(--zgf-muted);
	white-space: nowrap;
}

.zgf-badge {
	display: inline-flex;
	align-items: center;
	gap: 0.3em;
	font-size: 0.68rem;
	font-weight: 800;
	line-height: 1;
	letter-spacing: 0.03em;
	padding: 0.35em 0.55em;
	border-radius: 999px;
	background: rgba(30, 30, 30, 0.08);
	color: var(--zgf-contrast);
	white-space: nowrap;
}

.zgf-badge--live {
	background: var(--zgf-primary);
	color: #fff;
}

.zgf-badge--live::before {
	content: '';
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--zgf-secondary);
	animation: zgf-pulse 1.6s ease-in-out infinite;
}

.zgf-badge--ft {
	background: var(--zgf-secondary);
	color: var(--zgf-contrast);
}

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

@media (prefers-reduced-motion: reduce) {
	.zgf-badge--live::before {
		animation: none;
	}
}

/* Team lines */

.zgf-fixture__teams {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
	padding-left: 0.75rem;
	border-left: 1px solid var(--zgf-line);
}

.zgf-team {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.zgf-team__logo {
	width: 20px;
	height: 20px;
	flex: 0 0 20px;
	object-fit: contain;
}

.zgf-team__logo--empty {
	display: inline-block;
	border-radius: 50%;
	background: rgba(30, 30, 30, 0.08);
}

.zgf-team__name {
	flex: 1 1 auto;
	font-size: 0.95rem;
	font-weight: 600;
	line-height: 1.3;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.zgf-team__goals {
	flex: 0 0 auto;
	font-size: 0.95rem;
	font-weight: 800;
	font-variant-numeric: tabular-nums;
	min-width: 1.2em;
	text-align: right;
}

.zgf-fixture--live .zgf-team__goals {
	color: var(--zgf-primary);
}

.zgf-team--winner .zgf-team__name,
.zgf-team--winner .zgf-team__goals {
	font-weight: 800;
}

.zgf-fixture--finished .zgf-team:not(.zgf-team--winner) .zgf-team__name {
	color: var(--zgf-muted);
}

/* Empty state */

.zgf-empty {
	padding: 1.5rem 1rem;
	margin: 0;
	font-size: 0.95rem;
	color: var(--zgf-muted);
	border: 1px dashed rgba(30, 30, 30, 0.25);
	border-radius: var(--zgf-radius);
	text-align: center;
	background: var(--zgf-base);
}

/* ------------------------------------------------------------------ *
 * Search block
 * ------------------------------------------------------------------ */

.zgf-search__form {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-bottom: 1rem;
}

.zgf-search__input {
	flex: 1 1 220px;
	padding: 0.65rem 1rem;
	font-family: inherit;
	font-size: 1rem;
	border: 2px solid rgba(30, 30, 30, 0.2);
	border-radius: var(--zgf-radius);
	background: var(--zgf-base);
	color: var(--zgf-contrast);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.zgf-search__input:focus {
	outline: none;
	border-color: var(--zgf-primary);
	box-shadow: 0 0 0 3px rgba(23, 109, 33, 0.15);
}

/* Matches the theme.json button element (green bg, yellow hover border). */
.zgf-search__button {
	flex: 0 1 auto;
	cursor: pointer;
	padding: 0.55rem 1.4rem;
	font-family: inherit;
	font-size: 1rem;
	font-weight: 700;
	background: var(--zgf-primary);
	color: #fff;
	border: 3px solid transparent;
	border-radius: var(--zgf-radius);
	transition: border-color 0.15s ease;
}

.zgf-search__button:hover,
.zgf-search__button:focus-visible {
	border-color: var(--zgf-secondary);
}

.zgf-search__status {
	font-size: 0.9rem;
	color: var(--zgf-muted);
	margin: 0 0 0.75rem;
}

/* ------------------------------------------------------------------ *
 * Small screens
 * ------------------------------------------------------------------ */

@media (max-width: 480px) {
	.zgf-fixture {
		gap: 0.6rem;
		padding: 0.55rem 0.65rem;
	}

	.zgf-fixture__status {
		flex-basis: 48px;
		width: 48px;
	}

	.zgf-fixture__teams {
		padding-left: 0.6rem;
	}

	.zgf-team__name {
		font-size: 0.88rem;
	}

	.zgf-league-header {
		padding: 0.5rem 0.65rem;
	}

	.zgf-league-header__country {
		display: none; /* keep the header to one clean line on phones */
	}

	.zgf-search__button {
		flex: 1 1 100%;
	}
}
