/* Football Schedule — หน้าเว็บส่วนหน้า
 *
 * หลักการสี: ไม่ฟิกซ์สีเทาตายตัว เพราะไม่รู้ว่าธีมจะพื้นสว่างหรือมืด
 * ข้อความรองใช้ opacity ของสีที่สืบทอดมา เส้นขอบใช้เทาโปร่งใส
 * ทำให้อ่านออกทั้งสองแบบโดยไม่ต้องเขียน prefers-color-scheme
 */

.fsx {
	--fsx-line: rgba(128, 136, 148, .3);
	--fsx-accent: #1a73e8;
	--fsx-radius: 8px;
	font-size: 15px;
	line-height: 1.5;
}

.fsx-title { margin: 0 0 .75em; }

.fsx-empty { opacity: .65; font-style: italic; }

.fsx-sr {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

/* ---------- หัวข้อคั่นกลุ่ม ---------- */

.fsx-grp {
	display: flex;
	align-items: center;
	gap: .5em;
	padding: 1.1em .1em .45em;
	font-size: .88em;
	font-weight: 700;
}

.fsx-grp:first-child { padding-top: .2em; }

.fsx-grp__flag {
	width: 15px;
	height: 15px;
	flex: 0 0 15px;
	border-radius: 2px;
	object-fit: cover;
	display: block;
}

.fsx-grp__country {
	font-weight: 400;
	opacity: .6;
	font-size: .92em;
}

.fsx-grp__country::before { content: "· "; }

/* หัวข้อวันที่เป็นชั้นนอก ต้องหนักกว่าหัวข้อลีกชัดเจน */
.fsx-grp--date {
	font-size: 1.02em;
	font-weight: 800;
	padding: 1.9em .1em .35em;
	border-bottom: 2px solid var(--fsx-line);
	margin-bottom: .1em;
}

.fsx-grp--date:first-child { padding-top: .2em; }

/* หัวข้อลีกเป็นชั้นใน ย่อหน้าเข้ามาให้เห็นลำดับชั้น */
.fsx-list--bylg .fsx-grp:not(.fsx-grp--date) {
	padding-left: .9em;
	font-size: .85em;
	opacity: .9;
}

.fsx-list--bylg .fsx-m { padding-left: .9em; }

/* ---------- หนึ่งแมตช์ — จอคอม ---------- */

.fsx-m {
	display: grid;
	/* คอลัมน์ที่ 3 คือป้ายสถานะ auto จึงยุบเหลือศูนย์เมื่อไม่มีแมตช์ที่ Live */
	grid-template-columns: 3.6em 1fr auto 4.6em;
	align-items: center;
	gap: .5em;
	padding: .5em .1em;
	border-top: 1px solid var(--fsx-line);
}

.fsx-m.is-active { background: rgba(26, 115, 232, .1); }

.fsx-m__meta { min-width: 0; }

.fsx-m__time {
	font-variant-numeric: tabular-nums;
	font-weight: 700;
	font-size: .98em;
}

/* ชื่อลีกในแถว จะโผล่เฉพาะตอนจัดกลุ่มตามวันที่ */
.fsx-m__lg {
	display: block;
	font-size: .72em;
	opacity: .6;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.fsx-m__teams {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	gap: .4em;
	min-width: 0;
}

.fsx-m__side {
	display: flex;
	align-items: center;
	gap: .5em;
	min-width: 0;
}

.fsx-m__side--h {
	justify-content: flex-end;
	text-align: right;
}

.fsx-m__nm {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.fsx-m__logo {
	width: 22px;
	height: 22px;
	flex: 0 0 22px;
	object-fit: contain;
	display: block;
}

.fsx-m__logo--blank {
	border-radius: 50%;
	background: var(--fsx-line);
}

.fsx-m__vs {
	font-size: .72em;
	opacity: .55;
	letter-spacing: .04em;
	white-space: nowrap;
}

.fsx-watch {
	justify-self: end;
	cursor: pointer;
	border: 0;
	border-radius: 5px;
	background: var(--fsx-accent);
	color: #fff;
	font: inherit;
	font-size: .85em;
	font-weight: 600;
	padding: .4em .9em;
}

.fsx-watch:hover { filter: brightness(1.12); }

.fsx-watch:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* ---------- ป้าย Live ---------- */

/*
 * ป้ายถูกใส่ไว้ทุกแถวตั้งแต่ฝั่ง PHP แล้วซ่อนไว้
 * JavaScript แค่เติมคลาส is-live ให้แถวที่อยู่ในช่วงเวลาแข่ง
 * ทำแบบนี้เพราะหน้าเว็บอาจถูก cache ไว้ เวลาที่ PHP คำนวณจะค้าง
 */
.fsx-live { display: none; }

.fsx-m.is-live .fsx-live {
	display: inline-flex;
	align-items: center;
	gap: .4em;
	white-space: nowrap;
	font-size: .75em;
	font-weight: 700;
	letter-spacing: .04em;
	line-height: 1;
	color: #ff4d4f;
}

.fsx-live__dot {
	width: 7px;
	height: 7px;
	flex: 0 0 7px;
	border-radius: 50%;
	background: currentColor;
	box-shadow: 0 0 0 0 rgba(255, 77, 79, .7);
	animation: fsx-pulse 1.8s infinite;
}

@keyframes fsx-pulse {
	70%  { box-shadow: 0 0 0 7px rgba(255, 77, 79, 0); }
	100% { box-shadow: 0 0 0 0 rgba(255, 77, 79, 0); }
}

@media (prefers-reduced-motion: reduce) {
	.fsx-live__dot { animation: none; }
}

/* จอคอมใช้ป้ายในช่องก่อนปุ่ม ไม่ใช้ตัวที่อยู่ข้างเวลา */
.fsx-m__meta .fsx-live { display: none !important; }

.fsx-m__slot {
	display: flex;
	justify-content: flex-end;
	min-width: 0;
}

/* แถวที่ JavaScript สั่งซ่อนเพราะเตะไปนานแล้ว */
.fsx-m[hidden],
.fsx-grp[hidden] { display: none !important; }

/* ---------- ผู้เล่น ---------- */

.fsx-player { margin: 0 0 1.2em; }

.fsx-player__bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1em;
	padding: .5em .2em;
}

.fsx-player__title { font-weight: 600; }

.fsx-player__close {
	cursor: pointer;
	border: 1px solid var(--fsx-line);
	background: none;
	border-radius: 4px;
	padding: .25em .7em;
	font: inherit;
	font-size: .85em;
	color: inherit;
	opacity: .75;
}

.fsx-player__close:hover { opacity: 1; }

.fsx-player__box {
	position: relative;
	width: 100%;
	margin-inline: auto;
	aspect-ratio: var(--fsx-ratio, 1000 / 600);
	background: #000;
	border-radius: 6px;
	overflow: hidden;
}

.fsx-player__frame {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
	display: block;
}

/* โหมดครอป — ขยาย iframe ให้ใหญ่กว่ากรอบแล้วเลื่อนด้วย X/Y ติดลบ
   ส่วนที่ล้นออกนอกกรอบถูก overflow:hidden ตัดทิ้ง
   ชั้น __crop คงขนาดตอนออกแบบไว้ แล้วถูกย่อด้วย --fsx-fit ที่ JS คำนวณ
   ผลลัพธ์บนมือถือจึงเหมือนจอคอม ตั้งค่าครั้งเดียวพอ */
.fsx-player__box.is-crop .fsx-player__crop {
	position: absolute;
	top: 0;
	left: 0;
	width: var(--fsx-bw, 1000px);
	height: var(--fsx-bh, 600px);
	transform: scale(var(--fsx-fit, 1));
	transform-origin: 0 0;
}

.fsx-player__box.is-crop .fsx-player__frame {
	inset: auto;
	left: var(--fsx-ox, 0px);
	top: var(--fsx-oy, 0px);
	width: var(--fsx-fw, 1280px);
	height: var(--fsx-fh, 900px);
	transform: scale(var(--fsx-zoom, 1));
	transform-origin: 0 0;
}

/* ---------- มือถือ: แถวกลายเป็นการ์ด 3 บรรทัด ---------- */

@media (max-width: 640px) {

	.fsx-list { display: flex; flex-direction: column; gap: .5em; }

	.fsx-grp { padding: .7em .1em .15em; justify-content: center; }

	.fsx-grp--date { padding: 1.2em .1em .3em; }

	/* มือถือไม่ต้องย่อหน้า พื้นที่น้อยอยู่แล้ว */
	.fsx-list--bylg .fsx-grp:not(.fsx-grp--date),
	.fsx-list--bylg .fsx-m { padding-left: 0; }

	.fsx-list--bylg .fsx-grp:not(.fsx-grp--date) { padding: .7em .1em .15em; }

	.fsx-m {
		display: block;
		padding: 0;
		border: 1px solid var(--fsx-line);
		border-radius: var(--fsx-radius);
		overflow: hidden;
	}

	.fsx-m__meta,
	.fsx-m__teams {
		padding: .45em .7em;
		text-align: center;
	}

	.fsx-m__meta {
		font-size: .78em;
		opacity: .75;
		display: flex;
		align-items: center;
		justify-content: center;
		gap: .6em;
	}

	/* มือถือ: ป้ายไปอยู่ข้างเวลา ช่องของจอคอมไม่ใช้ */
	.fsx-m.is-live .fsx-m__meta .fsx-live { display: inline-flex !important; }
	.fsx-m__slot { display: none; }

	/* ชื่อลีกกับเวลาอยู่บรรทัดเดียวกัน คั่นด้วยสแลช */
	.fsx-m__lg {
		display: inline;
		font-size: 1em;
		opacity: 1;
		white-space: normal;
	}

	.fsx-m__lg::after {
		content: " / ";
		opacity: .6;
	}

	.fsx-m__teams {
		display: block;
		border-top: 1px solid var(--fsx-line);
		/* ชื่อทีมไทยยาว ๆ ตัดลงบรรทัดใหม่แทนที่จะดันกรอบจนล้น */
		overflow-wrap: anywhere;
	}

	.fsx-m__side {
		display: inline;
	}

	.fsx-m__nm {
		display: inline;
		white-space: normal;
		overflow: visible;
	}

	.fsx-m__logo {
		display: inline-block;
		width: 18px;
		height: 18px;
		vertical-align: -4px;
		margin-inline: .22em;
	}

	.fsx-m__vs { margin-inline: .45em; }

	.fsx-watch {
		display: block;
		width: 100%;
		justify-self: auto;
		border-radius: 0;
		border-top: 1px solid var(--fsx-line);
		background: none;
		color: var(--fsx-accent);
		font-size: .95em;
		font-weight: 700;
		padding: .5em;
	}

	.fsx-watch:hover {
		filter: none;
		background: rgba(26, 115, 232, .12);
	}
}
