/*
 * Deals — /free-games/, /free-software/ and the single deal pages.
 *
 * ⛔ No colour literals. Every colour is a token from cryptogames.css
 * Section 2 (dark on :root) and Section 2b (light, redefined on
 * body.cg-layout), so this file follows the theme toggle without a second
 * rule set. `rgba(var(--rgb-…), a)` is the house way to get a translucent
 * token. DealsWiringTest fails the build on a hex or numeric rgb().
 *
 * Everything is scoped under .cg-deals (the content area both templates
 * print), so nothing here reaches a page that is not ours.
 */

/* ------------------------------------------------------------ page shell */

.cg-deals {
	font-family: var(--font-body);
	color: var(--color-on-surface);
}
.cg-deals *,
.cg-deals *::before,
.cg-deals *::after { box-sizing: border-box; }

.cg-deals a { color: var(--color-primary-fixed-dim); text-decoration: none; }
.cg-deals a:hover { text-decoration: underline; text-underline-offset: 3px; }
.cg-deals a:focus-visible,
.cg-deals summary:focus-visible {
	outline: 2px solid var(--color-primary-container);
	outline-offset: 2px;
	border-radius: 4px;
}

.cg-deals-sr,
.cg-deal-sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Breadcrumb */
.cg-deals-crumbs ol {
	margin: 0 0 20px;
	padding: 0;
	list-style: none;
	font-size: 13px;
	line-height: 1.5;
	color: var(--color-on-surface-variant);
}
/* Inline, not flex: a long deal title then wraps as text, with its separator. */
.cg-deals-crumbs li { display: inline; }
.cg-deals-crumbs li + li::before { content: "\203A"; margin: 0 6px; color: var(--color-outline); }
.cg-deals-crumbs [aria-current] {
	color: var(--color-on-surface);
	overflow-wrap: anywhere;
}

/* Hero */
.cg-deals-hero { max-width: 760px; margin-bottom: 28px; }
.cg-deals-title,
.cg-deal-title {
	margin: 0 0 12px;
	font-family: var(--font-headline);
	font-weight: 700;
	letter-spacing: -0.02em;
	line-height: 1.1;
	color: var(--color-on-surface);
}
.cg-deals-title { font-size: clamp(32px, 5vw, 48px); }
.cg-deals-intro {
	margin: 0;
	font-size: 17px;
	line-height: 1.6;
	color: var(--color-on-surface-variant);
}
.cg-deals-live {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin: 16px 0 0;
	padding: 6px 12px;
	border-radius: 999px;
	background: rgba(var(--rgb-tertiary-container), 0.12);
	color: var(--color-tertiary-container);
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.02em;
}
.cg-deals-live-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--color-tertiary-container);
}

/* Sections */
.cg-deals-section { margin-top: 40px; }
.cg-deals-section-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 16px;
	flex-wrap: wrap;
}
.cg-deals-h2 {
	margin: 0 0 16px;
	font-family: var(--font-headline);
	font-size: 24px;
	font-weight: 700;
	line-height: 1.2;
	color: var(--color-on-surface);
}
.cg-deals-note { margin: -8px 0 16px; font-size: 14px; color: var(--color-on-surface-variant); max-width: 70ch; }
.cg-deals-see-all { font-size: 14px; font-weight: 600; }
.cg-deals-empty {
	margin: 0;
	padding: 28px 24px;
	border: 1px dashed var(--color-outline-variant);
	border-radius: 12px;
	background: var(--color-surface-container-low);
	color: var(--color-on-surface-variant);
	font-size: 15px;
	line-height: 1.6;
}
.cg-deals-back { margin-top: 32px; font-weight: 600; }

/* --------------------------------------------------------------- filters */

.cg-deals-filters {
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 16px;
	border: 1px solid rgba(var(--rgb-outline-variant), 0.6);
	border-radius: 12px;
	background: var(--color-surface-container-low);
}
.cg-deals-filter-group { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cg-deals-filter-label {
	flex: 0 0 72px;
	font-family: var(--font-label);
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--color-on-surface-variant);
}
.cg-deals-pills {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
	min-width: 0;
}
.cg-deals .cg-deals-pill {
	display: inline-flex;
	align-items: center;
	min-height: 32px;
	padding: 4px 14px;
	border: 1px solid var(--color-outline-variant);
	border-radius: 999px;
	background: var(--color-surface-container);
	color: var(--color-on-surface);
	font-size: 13px;
	font-weight: 500;
	line-height: 1.2;
	white-space: nowrap;
	transition: border-color .15s ease, background-color .15s ease;
}
.cg-deals .cg-deals-pill:hover {
	text-decoration: none;
	border-color: var(--color-primary-fixed-dim);
	background: var(--color-surface-container-high);
}
.cg-deals .cg-deals-pill[aria-current="page"] {
	border-color: var(--color-primary-container);
	background: var(--color-primary-container);
	color: var(--color-on-primary-container);
	font-weight: 700;
}

/* ------------------------------------------------------------------ grid */

.cg-deals-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	gap: 16px;
}

/* ------------------------------------------------------------------ card */

.cg-deal-card {
	position: relative;
	display: flex;
	flex-direction: column;
	min-width: 0;
	overflow: hidden;
	border: 1px solid rgba(var(--rgb-outline-variant), 0.6);
	border-radius: 12px;
	background: var(--color-surface-container);
	transition: border-color .15s ease, transform .15s ease, background-color .15s ease;
}
.cg-deal-card:hover {
	border-color: rgba(var(--rgb-primary-fixed-dim), 0.5);
	background: var(--color-surface-container-high);
	transform: translateY(-2px);
}

.cg-deal-card-media {
	position: relative;
	aspect-ratio: 460 / 215;
	background: var(--color-surface-container-highest);
	overflow: hidden;
}
.cg-deal-card-img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}
.cg-deal-card-img--blank {
	background:
		radial-gradient(circle at 30% 30%, rgba(var(--rgb-primary-container), 0.18), transparent 60%),
		radial-gradient(circle at 75% 70%, rgba(var(--rgb-secondary-container), 0.16), transparent 60%),
		var(--color-surface-container-highest);
}

.cg-deal-store {
	display: inline-block;
	padding: 3px 8px;
	border-radius: 6px;
	background: rgba(var(--rgb-surface), 0.88);
	color: var(--color-on-surface);
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.04em;
	line-height: 1.4;
}
.cg-deal-card-media .cg-deal-store { position: absolute; top: 10px; left: 10px; }

.cg-deal-card-body {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 8px;
	min-width: 0;
	padding: 14px 16px 16px;
}
.cg-deal-card-title {
	margin: 0;
	font-family: var(--font-headline);
	font-size: 16px;
	font-weight: 700;
	line-height: 1.3;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
.cg-deals .cg-deal-card-link { color: var(--color-on-surface); }
.cg-deals .cg-deal-card-link:hover { text-decoration: none; }
.cg-deal-card:hover .cg-deal-card-link { color: var(--color-primary-fixed-dim); }
/* The title is the card's only link; its ::after makes the whole card the
 * click target, and carries the keyboard focus ring round the whole card. */
.cg-deal-card-link::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
	border-radius: 12px;
}
.cg-deals .cg-deal-card-link:focus-visible { outline: none; }
.cg-deals .cg-deal-card-link:focus-visible::after {
	outline: 2px solid var(--color-primary-container);
	outline-offset: -2px;
}

/* Price: struck worth, then FREE */
.cg-deal-price {
	display: flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 8px;
	margin: 0;
}
.cg-deal-worth {
	color: var(--color-on-surface-variant);
	font-size: 14px;
	text-decoration-thickness: 1.5px;
}
.cg-deal-free {
	font-family: var(--font-headline);
	font-size: 18px;
	font-weight: 800;
	letter-spacing: 0.04em;
	color: var(--color-tertiary-container);
}
.cg-deal-price--lg .cg-deal-worth { font-size: 18px; }
.cg-deal-price--lg .cg-deal-free { font-size: 30px; }
.cg-deal--is-expired .cg-deal-free { color: var(--color-on-surface-variant); }

.cg-deal-ends { margin: 0; font-size: 13px; color: var(--color-on-surface-variant); }
.cg-deal-ends.is-soon { color: var(--color-error); font-weight: 600; }
.cg-deal-ends-date { white-space: nowrap; }

.cg-deal-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	margin: auto 0 0;
	padding: 4px 0 0;
	list-style: none;
}
.cg-deal-chip {
	padding: 2px 8px;
	border: 1px solid var(--color-outline-variant);
	border-radius: 999px;
	color: var(--color-on-surface-variant);
	font-size: 11px;
	font-weight: 500;
	line-height: 1.5;
}

/* Expired: greyed, and no lift — it can no longer be claimed. */
.cg-deal--expired { opacity: .55; filter: grayscale(1); }
.cg-deal--expired:hover { transform: none; opacity: .8; }

@media (prefers-reduced-motion: reduce) {
	.cg-deal-card { transition: none; }
	.cg-deal-card:hover { transform: none; }
}

/* ------------------------------------------------------------ deal page */

.cg-deal { max-width: 1040px; }
.cg-deal-title { font-size: clamp(26px, 4vw, 40px); overflow-wrap: anywhere; }

.cg-deal-banner {
	margin: 0 0 20px;
	padding: 14px 18px;
	border: 1px solid rgba(var(--rgb-error), 0.45);
	border-radius: 12px;
	background: rgba(var(--rgb-error), 0.1);
	color: var(--color-on-surface);
}
.cg-deal-banner p { margin: 0; line-height: 1.5; }
.cg-deal-banner strong { margin-right: 6px; color: var(--color-error); }

.cg-deal-top {
	display: grid;
	grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
	gap: 20px;
	align-items: start;
	margin-top: 8px;
}
.cg-deal-media {
	margin: 0;
	overflow: hidden;
	border-radius: 12px;
	aspect-ratio: 460 / 215;
	background: var(--color-surface-container-highest);
}
.cg-deal-img { display: block; width: 100%; height: 100%; object-fit: cover; }

.cg-deal-panel {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 12px;
	padding: 20px;
	border: 1px solid rgba(var(--rgb-outline-variant), 0.6);
	border-radius: 12px;
	background: var(--color-surface-container);
}
.cg-deal-store--inline {
	background: var(--color-surface-container-highest);
}
.cg-deal-panel .cg-deal-chips { margin: 0; padding: 0; }

.cg-deals .cg-deal-cta {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 48px;
	padding: 12px 20px;
	border: 0;
	border-radius: 10px;
	background: var(--color-primary-container);
	color: var(--color-on-primary-container);
	font-family: var(--font-headline);
	font-size: 16px;
	font-weight: 700;
	text-align: center;
	text-decoration: none;
	transition: filter .15s ease, box-shadow .15s ease;
}
.cg-deals a.cg-deal-cta:hover {
	text-decoration: none;
	filter: brightness(1.08);
	box-shadow: 0 6px 20px rgba(var(--rgb-primary-container), 0.3);
}
.cg-deals a.cg-deal-cta:focus-visible {
	outline: 2px solid var(--color-primary-container);
	outline-offset: 3px;
}
.cg-deals .cg-deal-cta.is-disabled {
	background: var(--color-surface-container-highest);
	color: var(--color-on-surface-variant);
	cursor: not-allowed;
}
.cg-deal-cta-note { margin: 0; font-size: 12px; color: var(--color-on-surface-variant); }

.cg-deal-body {
	max-width: 72ch;
	margin-top: 28px;
	font-size: 16px;
	line-height: 1.7;
	color: var(--color-on-surface);
}
.cg-deal-body > :first-child { margin-top: 0; }
.cg-deal-body h2,
.cg-deal-body h3 { font-family: var(--font-headline); line-height: 1.25; }

.cg-deal-steps { max-width: 72ch; margin-top: 32px; }
.cg-deal-steps ol {
	margin: 0;
	padding: 0;
	list-style: none;
	counter-reset: cg-step;
}
.cg-deal-steps li {
	position: relative;
	min-height: 32px;
	margin: 0 0 12px;
	padding: 4px 0 0 44px;
	line-height: 1.6;
	counter-increment: cg-step;
}
.cg-deal-steps li::before {
	content: counter(cg-step);
	position: absolute;
	top: 0;
	left: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	background: rgba(var(--rgb-primary-container), 0.14);
	color: var(--color-primary-fixed-dim);
	font-family: var(--font-headline);
	font-weight: 700;
	font-size: 14px;
}

.cg-deal-related { margin: 24px 0 0; font-weight: 600; }

/* ------------------------------------------------------------------- FAQ */

.cg-deals-faq { max-width: 820px; }
.cg-deals-faq-item {
	border-bottom: 1px solid var(--color-outline-variant);
}
.cg-deals-faq-item summary {
	position: relative;
	padding: 16px 36px 16px 0;
	cursor: pointer;
	list-style: none;
	font-family: var(--font-headline);
	font-size: 17px;
	font-weight: 600;
	line-height: 1.4;
	color: var(--color-on-surface);
}
.cg-deals-faq-item summary::-webkit-details-marker { display: none; }
.cg-deals-faq-item summary::after {
	content: "+";
	position: absolute;
	top: 50%;
	right: 6px;
	transform: translateY(-50%);
	font-size: 22px;
	font-weight: 400;
	color: var(--color-primary-fixed-dim);
}
.cg-deals-faq-item[open] summary::after { content: "\2212"; }
.cg-deals-faq-item p {
	margin: 0 0 18px;
	font-size: 15px;
	line-height: 1.7;
	color: var(--color-on-surface-variant);
}

/* --------------------------------------------------------- the other hub */

.cg-deals-other {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 12px 24px;
	margin-top: 40px;
	padding: 20px 24px;
	border: 1px solid rgba(var(--rgb-outline-variant), 0.6);
	border-radius: 12px;
	background: var(--color-surface-container-low);
}
.cg-deals-other-q { margin: 0; font-family: var(--font-headline); font-size: 18px; font-weight: 600; }
.cg-deals .cg-deals-other-link { font-weight: 700; }

/* ---------------------------------------------------------------- mobile */

@media (max-width: 899px) {
	.cg-deal-top { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 767px) {
	.cg-content-area.cg-deals { padding: 24px 16px 40px; }
	.cg-deals-filter-group { flex-direction: column; align-items: flex-start; gap: 8px; }
	.cg-deals-filter-label { flex-basis: auto; }
	.cg-deals-section { margin-top: 32px; }
}

@media (max-width: 519px) {
	.cg-deals-grid { grid-template-columns: minmax(0, 1fr); }
	.cg-deals-filters { padding: 12px; }
	.cg-deal-panel { padding: 16px; }
	.cg-deals-other { padding: 16px; }
}
