/*
Theme Name: Testcard
Description: Editorial theme for Testcard, plain-English IPTV guides. Categories are colour-coded like the bars of a TV test card.
Version: 2.0.1
Requires PHP: 8.1
Text Domain: testcard
*/

:root {
	--paper: #f4f5f7;
	--surface: #ffffff;
	--ink: #161a33;
	--muted: #565c74;
	--rule: #d8dbe3;
	--link: #2a46b8;

	/* The "screen": header, hero bands and footer */
	--screen: #0e1233;
	--screen-raised: #1a1f4d;
	--screen-line: #2c3270;
	--on-screen: #f2f3fb;
	--on-screen-muted: #aab0d6;

	/* Test-card bars, one per category */
	--bar-yellow: #e9c33a;
	--bar-cyan: #2fafc2;
	--bar-green: #3e9e5e;
	--bar-magenta: #c23c7a;
	--bar-red: #d9473c;
	--bar-blue: #2f4fc4;
	--bar-grey: #8a8fa3;

	--font-display: "Archivo", "Arial Narrow", system-ui, sans-serif;
	--font-body: "Source Serif 4", Georgia, "Times New Roman", serif;

	--measure: 40rem;
	--wide: 72rem;
	--gutter: clamp(1rem, 4vw, 2.5rem);
}

@media (prefers-color-scheme: dark) {
	:root {
		--paper: #12152a;
		--surface: #1a1e38;
		--ink: #eceef5;
		--muted: #a9aec4;
		--rule: #2e3354;
		--link: #9bb0ff;
		--screen: #080a20;
		--screen-raised: #141838;
		--screen-line: #262b5c;
	}
}

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

html { -webkit-text-size-adjust: 100%; }

body {
	margin: 0;
	background: var(--paper);
	color: var(--ink);
	font-family: var(--font-body);
	font-size: 1.125rem;
	line-height: 1.65;
	font-optical-sizing: auto;
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--link); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--bar-blue); outline-offset: 3px; border-radius: 2px; }

.screen-reader-text, .skip-link:not(:focus) {
	position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.skip-link:focus { position: absolute; top: .5rem; left: .5rem; z-index: 10; background: var(--surface); color: var(--ink); padding: .5rem 1rem; }

.wrap { width: min(100% - 2 * var(--gutter), var(--wide)); margin-inline: auto; }

h1, h2, h3, h4 {
	font-family: var(--font-display);
	font-stretch: 112%;
	line-height: 1.1;
	letter-spacing: -0.01em;
	font-weight: 750;
}

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

.site-header { background: var(--screen); color: var(--on-screen); }

.site-header__inner {
	display: flex; align-items: center; justify-content: space-between; gap: 1rem;
	padding-block: 1.1rem;
}

.wordmark {
	font-family: var(--font-display);
	font-stretch: 125%;
	font-weight: 800;
	font-size: 1.5rem;
	letter-spacing: -0.02em;
	color: var(--on-screen);
	text-decoration: none;
	display: inline-flex; align-items: center; gap: .6rem;
}

/* Miniature test card next to the name */
.wordmark__card {
	display: grid; grid-template-columns: repeat(7, 4px); height: 22px;
	border-radius: 3px; overflow: hidden;
}
.wordmark__card span:nth-child(1) { background: var(--bar-grey); }
.wordmark__card span:nth-child(2) { background: var(--bar-yellow); }
.wordmark__card span:nth-child(3) { background: var(--bar-cyan); }
.wordmark__card span:nth-child(4) { background: var(--bar-green); }
.wordmark__card span:nth-child(5) { background: var(--bar-magenta); }
.wordmark__card span:nth-child(6) { background: var(--bar-red); }
.wordmark__card span:nth-child(7) { background: var(--bar-blue); }

.site-nav ul { list-style: none; display: flex; flex-wrap: wrap; gap: .25rem 1.4rem; margin: 0; padding: 0; }
.site-nav a {
	font-family: var(--font-display); font-weight: 600; font-size: 1rem;
	color: var(--on-screen); text-decoration: none; padding-block: .3rem;
	border-bottom: 3px solid transparent;
}
.site-nav a:hover, .site-nav .current-menu-item a, .site-nav .current-cat a { border-bottom-color: var(--cat, var(--bar-yellow)); }
.site-header :focus-visible, .band :focus-visible, .onair :focus-visible, .site-footer :focus-visible { outline-color: var(--bar-yellow); }

@media (max-width: 720px) {
	.site-header__inner { flex-direction: column; align-items: flex-start; gap: .5rem; padding-bottom: .6rem; }
	.site-nav { width: 100%; }
	.site-nav ul { gap: .1rem 1rem; }
	.site-nav a { font-size: .95rem; }
}

/* Thin strip of test-card bars */
.bars-strip { display: flex; height: 6px; }
.bars-strip span { flex: 1; }

/* ---------- Home: on air now / up next ---------- */

.onair { background: var(--screen); color: var(--on-screen); padding-block: clamp(2.5rem, 6vw, 4.5rem) clamp(3rem, 7vw, 5rem); }
.onair__inner {
	display: grid; gap: 2rem clamp(1.5rem, 4vw, 3.5rem);
	grid-template-columns: minmax(0, 2fr) minmax(16rem, 1fr);
	align-items: end;
}
.onair__intro { grid-column: 1 / -1; }
.onair__intro h1 {
	font-size: clamp(3rem, 10vw, 7.5rem);
	font-stretch: 72%;
	font-weight: 800;
	line-height: .9;
	letter-spacing: -0.015em;
	margin: 0 0 1.1rem;
}
.onair__intro p { font-size: 1.2rem; color: var(--on-screen-muted); max-width: 34rem; margin: 0; }

/* A TV screen: the picture, a soft scanline texture and a lower-third caption */
.screen {
	position: relative; display: block; overflow: hidden;
	aspect-ratio: 16 / 9;
	border-radius: 14px;
	background: var(--screen-raised);
	box-shadow: 0 0 0 1px var(--screen-line), 0 30px 60px -30px rgb(0 0 0 / .7);
	color: #10132a; text-decoration: none;
}
.screen img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s cubic-bezier(.2, .7, .2, 1); }
.screen::after {
	content: ""; position: absolute; inset: 0; pointer-events: none;
	background: repeating-linear-gradient(to bottom, rgb(255 255 255 / .035) 0 1px, transparent 1px 3px),
		radial-gradient(ellipse at center, transparent 55%, rgb(0 0 0 / .35));
}
.screen:hover img { transform: scale(1.025); }

.lower-third {
	position: absolute; left: clamp(.75rem, 3vw, 1.75rem); right: clamp(.75rem, 3vw, 1.75rem); bottom: clamp(.75rem, 3vw, 1.75rem);
	z-index: 1; display: grid; justify-items: start; max-width: 36rem;
}
.lower-third__tab {
	background: var(--cat, var(--bar-yellow)); color: var(--cat-ink, #10132a);
	font-family: var(--font-display); font-weight: 700; font-size: .9rem;
	padding: .3rem .8rem; border-radius: 4px 4px 0 0;
}
.lower-third__title {
	background: #fff; color: #10132a;
	font-family: var(--font-display); font-stretch: 85%; font-weight: 800;
	font-size: clamp(1.35rem, 3.2vw, 2.3rem); line-height: 1.05;
	padding: .55rem .9rem .6rem; border-radius: 0 6px 0 0;
}
.lower-third__meta {
	background: var(--screen); color: var(--on-screen);
	font-family: var(--font-display); font-weight: 600; font-size: .85rem;
	padding: .3rem .9rem; border-radius: 0 0 6px 6px;
}
.screen:hover .lower-third__title { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: .12em; }

.onair__next h2 { font-size: 1.15rem; font-stretch: 100%; margin: 0 0 .75rem; color: var(--on-screen-muted); }
.onair__next ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.onair__next a {
	display: grid; grid-template-columns: 112px 1fr; gap: .9rem; align-items: center;
	padding: .5rem; border-radius: 10px;
	color: var(--on-screen); text-decoration: none;
	background: var(--screen-raised);
	box-shadow: inset 4px 0 0 var(--cat, var(--bar-grey));
	transition: background-color .15s ease;
}
.onair__next a:hover { background: var(--screen-line); }
.onair__next img { width: 112px; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 6px; }
.onair__cat { display: block; font-family: var(--font-display); font-size: .82rem; font-weight: 600; color: var(--on-screen-muted); }
.onair__title { display: block; font-family: var(--font-display); font-weight: 700; font-size: 1.02rem; line-height: 1.2; }

/* The one load moment: the screen switches on like a CRT */
@media (prefers-reduced-motion: no-preference) {
	.onair__now .screen { animation: switch-on .8s cubic-bezier(.2, .7, .2, 1) .1s both; }
	@keyframes switch-on {
		0% { clip-path: inset(49.5% 0 49.5% 0); filter: brightness(3); }
		45% { clip-path: inset(49.5% 0 49.5% 0); filter: brightness(2); }
		100% { clip-path: inset(0 0 0 0); filter: brightness(1); }
	}
}

@media (max-width: 900px) {
	.onair__inner { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
	.screen { aspect-ratio: 4 / 5; }
	.onair__next a { grid-template-columns: 88px 1fr; }
	.onair__next img { width: 88px; }
}

/* ---------- Home: the programme guide ---------- */

.guide { padding-block: clamp(3rem, 7vw, 4.5rem) 1rem; }
.guide__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .25rem 2rem; margin-bottom: 1.25rem; }
.guide__head p { margin: 0; color: var(--muted); font-size: 1rem; }

.epg { display: grid; gap: 6px; }
.epg__row { display: grid; grid-template-columns: 12rem minmax(0, 1fr); gap: 6px; }
.epg__channel {
	background: var(--cat); color: var(--cat-ink, #10132a); text-decoration: none;
	display: flex; flex-direction: column; justify-content: center;
	padding: 1rem 1.1rem; border-radius: 8px 0 0 8px;
}
.epg__channel:hover .epg__name { text-decoration: underline; }
.epg__name { font-family: var(--font-display); font-weight: 800; font-size: 1.2rem; line-height: 1.1; }
.epg__count { font-family: var(--font-display); font-weight: 500; font-size: .88rem; }

.epg__slots {
	list-style: none; margin: 0; padding: 0;
	display: grid; grid-auto-flow: column; grid-auto-columns: minmax(18rem, 1fr); gap: 6px;
	overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: thin;
}
.epg__slots li { scroll-snap-align: start; }
.epg__slots li:last-child > * { border-radius: 0 8px 8px 0; }
.epg__slots a {
	display: grid; grid-template-columns: 96px 1fr; grid-template-rows: 1fr auto; gap: .15rem 1rem;
	height: 100%; padding: .75rem; background: var(--surface);
	border-top: 3px solid var(--cat);
	color: var(--ink); text-decoration: none;
	transition: background-color .15s ease;
}
.epg__slots a:hover { background: color-mix(in srgb, var(--cat) 12%, var(--surface)); }
.epg__slots img { grid-row: 1 / span 2; width: 96px; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 5px; align-self: center; }
.epg__title { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; line-height: 1.2; align-self: end; }
.epg__meta { font-family: var(--font-display); font-size: .85rem; color: var(--muted); }
.epg__empty { display: flex; align-items: center; padding: 1rem; background: var(--surface); color: var(--muted); font-size: 1rem; border-radius: 0 8px 8px 0; }

@media (max-width: 640px) {
	.epg { gap: 1rem; }
	.epg__row { grid-template-columns: minmax(0, 1fr); gap: 0; }
	.epg__channel { flex-direction: row; justify-content: space-between; align-items: baseline; border-radius: 8px 8px 0 0; padding: .75rem 1rem; }
	.epg__slots { grid-auto-columns: minmax(85%, 1fr); }
	.epg__slots li:last-child > * { border-radius: 0 0 8px 8px; }
}

/* ---------- Home: device chooser ---------- */

.devices {
	margin-block: 2.5rem 4rem; padding: clamp(1.25rem, 4vw, 2rem);
	background: var(--screen); color: var(--on-screen); border-radius: 14px;
	display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 2rem;
}
.devices h2 { margin: 0; font-size: clamp(1.4rem, 3vw, 1.9rem); font-stretch: 85%; }
.devices ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.devices a {
	display: inline-block; padding: .55rem 1.1rem; border-radius: 999px;
	font-family: var(--font-display); font-weight: 600; font-size: 1rem;
	color: var(--on-screen); text-decoration: none;
	box-shadow: inset 0 0 0 1.5px var(--screen-line); background: var(--screen-raised);
	transition: background-color .15s ease, color .15s ease;
}
.devices a:hover { background: var(--on-screen); color: var(--screen); }

/* ---------- Post list ---------- */

.section-title { font-size: clamp(1.8rem, 4vw, 2.6rem); font-stretch: 85%; font-weight: 800; margin: 0 0 .5rem; }

.post-list { list-style: none; margin: 0 0 3rem; padding: 0; }
.post-row {
	display: grid; grid-template-columns: 10px 1fr; gap: 0 1.25rem;
	padding-block: 1.5rem; border-bottom: 1px solid var(--rule);
}
.post-row::before { content: ""; background: var(--cat, var(--bar-grey)); border-radius: 2px; }
.post-row h2, .post-row h3 { font-size: clamp(1.3rem, 2.6vw, 1.75rem); margin: .15rem 0 .45rem; }
.post-row h2 a, .post-row h3 a { color: var(--ink); text-decoration: none; }
.post-row h2 a:hover, .post-row h3 a:hover { text-decoration: underline; }
.post-row p { margin: 0; color: var(--muted); max-width: var(--measure); }
.post-row:has(.post-row__thumb) { grid-template-columns: 10px 1fr 240px; }
.post-row__thumb { align-self: center; display: block; border-radius: 6px; overflow: hidden; background: var(--rule); }
.post-row__thumb img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; transition: transform .3s ease; }
.post-row:hover .post-row__thumb img { transform: scale(1.03); }
@media (max-width: 640px) {
	.post-row:has(.post-row__thumb) { grid-template-columns: 10px 1fr; }
	.post-row:has(.post-row__thumb)::before { grid-row: 1 / span 2; }
	.post-row__thumb { grid-column: 2; grid-row: 1; margin-bottom: 1rem; }
}
@media (prefers-reduced-motion: reduce) { .post-row__thumb img { transition: none; } }

.meta {
	font-family: var(--font-display); font-size: .92rem; font-weight: 500; color: var(--muted);
	display: flex; flex-wrap: wrap; gap: .2rem 1rem; margin: 0;
}
.meta a { color: inherit; }
.meta .meta__cat { color: var(--ink); font-weight: 650; text-decoration: none; }

/* ---------- Dark bands: archive and article headers ---------- */

.band { background: var(--screen); color: var(--on-screen); }
.band .meta { color: var(--on-screen-muted); }

.archive-head { padding-block: clamp(2.5rem, 6vw, 4rem); }
.archive-head h1 {
	font-size: clamp(2.6rem, 8vw, 5.5rem); font-stretch: 72%; font-weight: 800; line-height: .95;
	margin: 0 0 .75rem; display: flex; align-items: center; gap: 1rem;
}
.archive-head h1::before { content: ""; width: .35em; height: .85em; background: var(--cat, var(--bar-yellow)); border-radius: 4px; flex: none; }
.archive-head p { color: var(--on-screen-muted); margin: 0; max-width: var(--measure); font-size: 1.15rem; }
.archive-body { padding-top: 1rem; }

/* ---------- Single article ---------- */

.article { padding-bottom: 4rem; }
.article__head { padding-block: clamp(2.5rem, 6vw, 4rem); }
.article__head h1 { max-width: 20ch; }
.article--hero .article__head { padding-bottom: clamp(7rem, 16vw, 12rem); }
.article__head h1 { font-size: clamp(2.4rem, 7vw, 4.75rem); font-stretch: 78%; font-weight: 800; line-height: .95; margin: .8rem 0 1.1rem; }
.article__lede { font-size: 1.3rem; color: var(--on-screen-muted); margin: 0 0 1.25rem; max-width: 42rem; }
.article__cat {
	display: inline-flex; align-items: center;
	background: var(--cat); color: var(--cat-ink, #10132a); border-radius: 4px; padding: .25rem .75rem;
	font-family: var(--font-display); font-weight: 700; font-size: .95rem; text-decoration: none;
}
.article__cat:hover { text-decoration: underline; }

/* The picture sits on a screen that overlaps the band */
.article__hero { margin: calc(-1 * clamp(5.5rem, 13vw, 10rem)) 0 3rem; }
.article__hero img {
	display: block; width: 100%; height: auto; max-height: 32rem; object-fit: cover;
	border-radius: 14px; box-shadow: 0 0 0 1px var(--screen-line), 0 30px 60px -30px rgb(0 0 0 / .6);
}
.article__hero figcaption { font-family: var(--font-display); font-size: .82rem; color: var(--muted); margin-top: .6rem; }
.article__hero figcaption a { color: inherit; }
.article:not(.article--hero) .article__layout { padding-top: 3rem; }

.article__layout { display: grid; gap: 2.5rem; grid-template-columns: minmax(0, var(--measure)) minmax(0, 1fr); align-items: start; }
@media (max-width: 960px) { .article__layout { grid-template-columns: minmax(0, 1fr); } }

.toc {
	position: sticky; top: 1.5rem; order: 2;
	font-family: var(--font-display); font-size: .98rem;
	border-left: 4px solid var(--cat, var(--bar-grey)); padding: .25rem 0 .25rem 1rem;
}
.toc h2 { font-size: 1rem; margin: 0 0 .5rem; }
.toc ol { margin: 0; padding-left: 1.2rem; }
.toc li { margin-bottom: .35rem; }
.toc a { color: var(--ink); text-decoration: none; }
.toc a[aria-current] { box-shadow: inset 0 -3px 0 var(--cat, var(--bar-grey)); }
.toc a:hover { text-decoration: underline; }
@media (max-width: 960px) { .toc { position: static; order: 0; } }

.prose { min-width: 0; line-height: 1.72; }
.prose > * { margin-block: 0 1.15em; }
.prose h2 { font-size: 1.75rem; margin-top: 2.2em; margin-bottom: .6em; scroll-margin-top: 1.5rem; }
.prose h3 { font-size: 1.3rem; margin-top: 1.8em; margin-bottom: .5em; }
.prose ul, .prose ol { padding-left: 1.35em; }
.prose li { margin-bottom: .45em; }
.prose li::marker { font-family: var(--font-display); font-weight: 700; }
.prose strong { font-weight: 650; }
.prose code, .prose kbd {
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86em;
	background: var(--surface); border: 1px solid var(--rule); border-radius: 4px; padding: .05em .35em;
}

/* Steps: real sequences only */
.prose ol.steps { list-style: none; padding: 0; counter-reset: step; }
.prose ol.steps > li { counter-increment: step; position: relative; padding-left: 3rem; margin-bottom: 1.1em; }
.prose ol.steps > li::before {
	content: counter(step); position: absolute; left: 0; top: .05em;
	width: 2rem; height: 2rem; border-radius: 50%;
	display: grid; place-items: center;
	background: var(--ink); color: var(--paper);
	font-family: var(--font-display); font-weight: 700; font-size: .95rem;
}

.prose .note {
	background: var(--surface); border-left: 4px solid var(--cat, var(--bar-yellow));
	padding: 1rem 1.25rem; border-radius: 0 6px 6px 0; font-size: 1.02rem;
}
.prose .note strong:first-child { font-family: var(--font-display); }

.prose table { width: 100%; border-collapse: collapse; font-size: 1rem; display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
.prose th { font-family: var(--font-display); font-weight: 700; border-bottom: 2px solid var(--ink); }

.prose blockquote { margin-inline: 0; padding-left: 1.25rem; border-left: 3px solid var(--rule); font-style: italic; }

.works-on { margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--rule); font-family: var(--font-display); }
.works-on ul { list-style: none; padding: 0; margin: .5rem 0 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.works-on a { display: inline-block; padding: .3rem .8rem; border: 1.5px solid var(--ink); border-radius: 999px; color: var(--ink); text-decoration: none; font-size: .95rem; }
.works-on a:hover { background: var(--ink); color: var(--paper); }

.related { padding-bottom: 4rem; }

/* ---------- Pages, 404, search ---------- */

.page-body { padding-block: 3rem 4rem; max-width: var(--measure); }
.page-body h1 { font-size: clamp(2rem, 5vw, 3.2rem); margin: 0 0 1.5rem; }

.search-form { display: flex; gap: .5rem; max-width: 30rem; }
.search-form input[type="search"] {
	flex: 1; font: inherit; font-size: 1rem; padding: .6rem .9rem;
	border: 1.5px solid var(--ink); border-radius: 6px; background: var(--surface); color: var(--ink);
}
.search-form button {
	font-family: var(--font-display); font-weight: 650; font-size: 1rem;
	padding: .6rem 1.1rem; border: 0; border-radius: 6px; background: var(--ink); color: var(--paper); cursor: pointer;
}

.pagination { display: flex; gap: .75rem; font-family: var(--font-display); margin-bottom: 4rem; }
.pagination .page-numbers { padding: .3rem .7rem; border: 1px solid var(--rule); border-radius: 4px; text-decoration: none; color: var(--ink); }
.pagination .current { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ---------- Footer ---------- */

.site-footer { background: var(--screen); font-size: 1rem; color: var(--on-screen-muted); }
.site-footer__inner { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 1.5rem 3rem; padding-block: 3rem 3.5rem; }
.site-footer .footer-topics { flex: 1; min-width: 12rem; }
.site-footer .footer-topics ul { flex-direction: column; gap: .45rem; }
.site-footer .footer-topics li { display: flex; align-items: center; gap: .6rem; }
.site-footer .footer-topics li::before { content: ""; width: 18px; height: 8px; border-radius: 2px; background: var(--cat); }
.site-footer .footer-topics a { text-decoration: none; }
.site-footer .footer-topics a:hover { text-decoration: underline; }
.site-footer p { margin: 0; max-width: 30rem; }
.site-footer p strong { color: var(--on-screen); font-family: var(--font-display); }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; font-family: var(--font-display); }
.site-footer a { color: var(--on-screen); }

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { transition: none !important; animation: none !important; }
}
