/* gamingbroject.com s148 release calendar: base (lab only, /testqq/s145/cal-base.css, manifest 55-calendar.json, body
 * token gbcal). Loaded with every calendar version, before cal-a/b/c.css.
 *
 * WHAT. The shared --gbcal-* tokens (dark default, Day values under :root[data-gb-theme="light"]), the server-rendered
 * list .gbcal-ssr (works without JS and for search; each design hides it once its own UI mounted), the "More games we
 * cover" list .gbcal-more (our games outside the calendar data), the credit line and the lab version switcher (fixed
 * bottom left, so Panos can compare A, B and C).
 *
 * FIRST PAINT. With scripting on, the server list is kept invisible (space reserved) until a design marks #gbcal as
 * mounted: the shared class is-gbcal-mounted, or today's per design marks is-mounted-a, gbcal-b-on and is-c-mounted.
 * If no design mounts, the list shows after 2.5 s anyway; without scripting it shows at once.
 *
 * CASCADE. Everything sits in @layer s145 (index.php declares "@layer s145, gbl, gbu;" before every stylesheet). Two kinds
 * of live rules reach these elements: unlayered page rules (.gb-game-library h2 sets size and colour, .gb-game-library a
 * sets colour) and the Day catch-all of gbl (every text ink, every border one line, no shadows, all !important). Both only
 * lose to an s145 !important, so colours, borders, shadows and the type values the live h2 rule also sets carry
 * !important here; layout values do not need it. Tokens read the shared s145 ones with fallbacks, so the Halloween
 * pumpkin and the Day palette follow without extra rules. */

@layer s145 {

	/* ---------------------------------------------------------------- tokens */
	/* The body carries the class gbcal too (it loads these files): root rules name .gbcal:where(div), the #gbcal box
	 * only, with the same specificity as .gbcal. */
	.gbcal:where(div),
	.gbcal-more,
	.gbcal-more-library,
	.gbcal-credit,
	.gbcal-switch {
		--gbcal-bg: #0c0712;
		--gbcal-surface: #130b1b;
		--gbcal-surface-2: #1b1226;
		--gbcal-line: rgba(255, 255, 255, .1);
		--gbcal-line-2: rgba(255, 255, 255, .18);
		--gbcal-ink: var(--s145-ink, #f7f5fb);
		--gbcal-ink-2: var(--s145-ink-2, #c9c3d1);
		--gbcal-ink-3: #a49dae;
		--gbcal-red: var(--s145-red, #ff2948);
		--gbcal-red-text: var(--s145-red-text, #ff5c78);
		--gbcal-red-fill: var(--s145-red-fill, #df1a3e);
		--gbcal-on-red: #ffffff;
		--gbcal-gold: #ffd35a;
		--gbcal-gold-bg: rgba(255, 211, 90, .08);
		--gbcal-gold-line: rgba(255, 211, 90, .4);
		--gbcal-green: #43f5a0;
		--gbcal-focus: var(--s145-focus, #21eaff);
		--gbcal-switch-bg: #0c0712;
		--gbcal-switch-press: #241832;
		--gbcal-shadow: 0 12px 32px -12px rgba(0, 0, 0, .7);
		--gbcal-r: var(--s145-r-l, 14px);
		--gbcal-r-s: var(--s145-r-s, 6px);
		--gbcal-font: var(--font-sans, "Inter", "Inter Fallback", system-ui, sans-serif);
		--gbcal-press: var(--s145-press, .97);
		--gbcal-t-press: var(--s145-t-press, 140ms);
		--gbcal-ease: var(--s145-ease, cubic-bezier(.23, 1, .32, 1));
	}

	:root[data-gb-theme="light"] :is(.gbcal:where(div), .gbcal-more, .gbcal-more-library, .gbcal-credit, .gbcal-switch) {
		--gbcal-bg: #ffffff;
		--gbcal-surface: #ffffff;
		--gbcal-surface-2: #f4f2f7;
		--gbcal-line: rgba(21, 18, 27, .1);
		--gbcal-line-2: rgba(21, 18, 27, .18);
		--gbcal-ink: var(--s145-ink, #15121b);
		--gbcal-ink-2: var(--s145-ink-2, #4f4958);
		--gbcal-ink-3: #6a6474;
		--gbcal-red: var(--s145-red, #d1123a);
		--gbcal-red-text: var(--s145-red-text, #b80d32);
		--gbcal-red-fill: var(--s145-red-fill, #d1123a);
		--gbcal-gold: #9a6400;
		--gbcal-gold-bg: #fff6df;
		--gbcal-gold-line: #e7c77a;
		--gbcal-green: #0a7a4c;
		--gbcal-focus: var(--s145-focus, #007385);
		--gbcal-switch-bg: #ffffff;
		--gbcal-switch-press: #e9e5ef;
		--gbcal-shadow: 0 1px 2px rgba(21, 18, 27, .06), 0 14px 36px -10px rgba(21, 18, 27, .22);
	}

	/* ---------------------------------------------------------------- calendar root */
	.gbcal:where(div) {
		margin: 28px 0 0;
		font-family: var(--gbcal-font);
		color: var(--gbcal-ink) !important;
		-webkit-text-size-adjust: 100%;
	}
	.gbcal:where(div) *,
	.gbcal:where(div) *::before,
	.gbcal:where(div) *::after {
		box-sizing: border-box;
	}

	/* ---------------------------------------------------------------- server-rendered list (no JS) */
	.gbcal-ssr {
		max-width: 860px;
	}
	/* no flash of the long server list before the design mounts (and no big layout shift under the H1) */
	@media (scripting: enabled) {
		.gbcal:where(div):not(.is-gbcal-mounted):not(.is-mounted-a):not(.gbcal-b-on):not(.is-c-mounted) {
			min-height: 70svh;
		}
		.gbcal:where(div):not(.is-gbcal-mounted):not(.is-mounted-a):not(.gbcal-b-on):not(.is-c-mounted) > .gbcal-ssr {
			visibility: hidden;
			animation: gbcal-ssr-show 0s 2.5s forwards;
		}
	}
	.gbcal .gbcal-ssr-day {
		margin: 30px 0 10px !important;
		font: 800 14px/1.3 var(--gbcal-font) !important;
		letter-spacing: .08em !important;
		text-transform: uppercase !important;
		color: var(--gbcal-ink-2) !important;
	}
	.gbcal .gbcal-ssr-day:first-child {
		margin-top: 0 !important;
	}
	.gbcal-ssr-day time {
		color: inherit !important;
	}
	.gbcal-ssr-list {
		list-style: none;
		margin: 0;
		padding: 0;
		display: grid;
		gap: 8px;
	}
	.gbcal-ssr-item {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		gap: 4px 12px;
		min-height: 48px;
		margin: 0;
		padding: 11px 16px;
		border: 1px solid var(--gbcal-line) !important;
		border-radius: var(--gbcal-r);
		background: var(--gbcal-surface) !important;
		color: var(--gbcal-ink) !important;
		overflow-wrap: anywhere;
	}
	.gbcal-ssr-item.is-ours {
		position: relative;
		border-color: var(--gbcal-gold-line) !important;
		background: var(--gbcal-gold-bg) !important;
		box-shadow: inset 3px 0 0 var(--gbcal-gold) !important;
	}
	/* the whole gold row is the link's tap target (48 px tall at least), not only the title text */
	.gbcal .gbcal-ssr-item.is-ours > a::after {
		content: "";
		position: absolute;
		inset: 0;
		border-radius: inherit;
	}
	.gbcal-ssr-title {
		font-size: 16px;
		font-weight: 750;
		line-height: 1.35;
		color: var(--gbcal-ink) !important;
	}
	.gbcal .gbcal-ssr-item > a {
		font-size: 16px;
		font-weight: 800;
		line-height: 1.35;
		color: var(--gbcal-gold) !important;
		text-decoration: underline !important;
		text-decoration-thickness: 1px !important;
		text-underline-offset: 3px;
		-webkit-tap-highlight-color: transparent;
	}
	.gbcal .gbcal-ssr-item > a:focus-visible {
		outline: 2px solid var(--gbcal-focus) !important;
		outline-offset: 3px;
		border-radius: 2px;
	}
	.gbcal-ssr-meta {
		font-size: 14px;
		line-height: 1.4;
		color: var(--gbcal-ink-2) !important;
	}
	.gbcal-ssr-badge {
		margin-left: auto;
		padding: 5px 9px;
		border: 1px solid var(--gbcal-gold-line) !important;
		border-radius: 999px;
		font: 800 11px/1 var(--gbcal-font);
		letter-spacing: .08em;
		text-transform: uppercase;
		white-space: nowrap;
		color: var(--gbcal-gold) !important;
	}
	.gbcal-ssr-empty {
		margin: 0;
		padding: 16px;
		border: 1px dashed var(--gbcal-line-2) !important;
		border-radius: var(--gbcal-r);
		color: var(--gbcal-ink-2) !important;
	}

	/* ---------------------------------------------------------------- more games we cover (outside #gbcal) */
	.gbcal-more {
		max-width: 860px;
		margin: 40px 0 0;
		font-family: var(--gbcal-font);
		color: var(--gbcal-ink) !important;
	}
	.gbcal-main .gbcal-more .gbcal-more-group {
		margin: 26px 0 10px !important;
		font: 800 14px/1.3 var(--gbcal-font) !important;
		letter-spacing: .08em !important;
		text-transform: uppercase !important;
		color: var(--gbcal-ink-2) !important;
	}
	.gbcal-more-list {
		list-style: none;
		margin: 0;
		padding: 0;
		display: grid;
		gap: 8px;
	}
	.gbcal-more-item {
		position: relative;
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		gap: 4px 12px;
		min-height: 48px;
		margin: 0;
		padding: 11px 16px;
		border: 1px solid var(--gbcal-gold-line) !important;
		border-radius: var(--gbcal-r);
		background: var(--gbcal-gold-bg) !important;
		box-shadow: inset 3px 0 0 var(--gbcal-gold) !important;
		color: var(--gbcal-ink) !important;
		overflow-wrap: anywhere;
	}
	.gbcal-main .gbcal-more-item > a {
		font-size: 16px;
		font-weight: 800;
		line-height: 1.35;
		color: var(--gbcal-gold) !important;
		text-decoration: underline !important;
		text-decoration-thickness: 1px !important;
		text-underline-offset: 3px;
		-webkit-tap-highlight-color: transparent;
	}
	.gbcal-main .gbcal-more-item > a::after {
		content: "";
		position: absolute;
		inset: 0;
		border-radius: inherit;
	}
	.gbcal-main .gbcal-more-item > a:focus-visible {
		outline: 2px solid var(--gbcal-focus) !important;
		outline-offset: 3px;
		border-radius: 2px;
	}
	.gbcal-more-meta {
		font-size: 14px;
		line-height: 1.4;
		color: var(--gbcal-ink-2) !important;
	}
	.gbcal-more-library {
		max-width: 760px;
		margin: 24px 0 0 !important;
		font: 400 15px/1.55 var(--gbcal-font) !important;
		color: var(--gbcal-ink-2) !important;
	}
	.gbcal-main .gbcal-more-library a {
		display: inline-block;
		padding-block: 11px;
		margin-block: -11px;
		font-weight: 700;
		color: var(--gbcal-ink) !important;
		text-decoration: underline !important;
		text-underline-offset: 3px;
		-webkit-tap-highlight-color: transparent;
	}
	.gbcal-main .gbcal-more-library a:focus-visible {
		outline: 2px solid var(--gbcal-focus) !important;
		outline-offset: 2px;
	}

	/* ---------------------------------------------------------------- version B: the lists wear B's raised key */
	/* Restyle s148: on the B page (body.gbcal-b) the lists under the calendar drop the old gold outline, gold wash, left
	 * bar, underline and tracked capitals. Each row is B's resting key (E1, lit from above); the only gold left is a
	 * small star before the title. A and C keep the shared look above. */
	.gbcal-b .gbcal-main .gbcal-more .gbcal-more-group,
	.gbcal-b .gbcal .gbcal-ssr-day {
		margin: 28px 0 10px !important;
		font: 700 20px/1.2 "GB Barlow Condensed", "Barlow Condensed", var(--gbcal-font) !important;
		letter-spacing: 0 !important;
		text-transform: none !important;
		color: var(--gbcal-ink) !important;
	}
	.gbcal-b .gbcal .gbcal-ssr-day:first-child { margin-top: 0 !important; }
	.gbcal-b .gbcal-more-item,
	.gbcal-b .gbcal-ssr-item,
	.gbcal-b .gbcal-ssr-item.is-ours {
		border: 1px solid transparent !important;
		border-radius: 8px !important;
		background: #171020 !important;
		box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), 0 1px 1px rgba(0, 0, 0, .55), 0 3px 8px -2px rgba(0, 0, 0, .5) !important;
		transition: box-shadow .16s var(--gbcal-ease), background-color .16s ease;
	}
	:root[data-gb-theme="light"] .gbcal-b :is(.gbcal-more-item, .gbcal-ssr-item, .gbcal-ssr-item.is-ours) {
		background: #ffffff !important;
		box-shadow: 0 0 0 1px rgba(21, 18, 27, .08), 0 1px 2px rgba(21, 18, 27, .07), 0 3px 8px -3px rgba(21, 18, 27, .12) !important;
	}
	.gbcal-b .gbcal-main .gbcal-more-item > a,
	.gbcal-b .gbcal .gbcal-ssr-item > a {
		color: var(--gbcal-ink) !important;
		font-weight: 700;
		text-decoration: none !important;
	}
	/* the one gold mark: a 12 px star before the title */
	.gbcal-b .gbcal-main .gbcal-more-item > a::before,
	.gbcal-b .gbcal .gbcal-ssr-item.is-ours > a::before {
		content: "";
		display: inline-block;
		width: 12px;
		height: 12px;
		margin-right: 8px;
		vertical-align: -1px;
		background: var(--gbcal-gold) !important;
		clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
	}
	.gbcal-b .gbcal-ssr-badge {
		padding: 0;
		border: 0 !important;
		border-radius: 0;
		font: 600 13px/1.2 var(--gbcal-font) !important;
		letter-spacing: 0 !important;
		text-transform: none !important;
		color: var(--gbcal-gold) !important;
	}
	/* press: the row settles into the page (a tone and an inner shadow, no travel) */
	.gbcal-b .gbcal-more-item:active {
		box-shadow: inset 0 1px 2px rgba(0, 0, 0, .5) !important;
		transition-duration: .1s;
	}
	:root[data-gb-theme="light"] .gbcal-b .gbcal-more-item:active {
		box-shadow: inset 0 1px 2px rgba(21, 18, 27, .14), 0 0 0 1px rgba(21, 18, 27, .1) !important;
	}
	@media (hover: hover) and (pointer: fine) {
		.gbcal-b .gbcal-more-item:hover:not(:active) {
			background: #261d31 !important;
			box-shadow: inset 0 1px 0 rgba(255, 255, 255, .09), 0 2px 3px rgba(0, 0, 0, .5), 0 10px 18px -6px rgba(0, 0, 0, .7) !important;
		}
		:root[data-gb-theme="light"] .gbcal-b .gbcal-more-item:hover:not(:active) {
			background: #ffffff !important;
			box-shadow: 0 0 0 1px rgba(21, 18, 27, .08), 0 2px 4px rgba(21, 18, 27, .08), 0 12px 22px -10px rgba(21, 18, 27, .24) !important;
		}
		.gbcal-b .gbcal-main .gbcal-more-item > a:hover {
			text-decoration: underline !important;
			text-decoration-thickness: 1px !important;
			text-underline-offset: 3px;
		}
	}

	/* ---------------------------------------------------------------- credit line */
	.gbcal-credit {
		max-width: 760px;
		margin: 32px 0 0 !important;
		font: 400 13px/1.55 var(--gbcal-font) !important;
		color: var(--gbcal-ink-3) !important;
	}
	.gbcal-main .gbcal-credit a {
		color: var(--gbcal-ink-2) !important;
		text-decoration: underline !important;
		text-underline-offset: 2px;
	}
	.gbcal-main .gbcal-credit a:focus-visible {
		outline: 2px solid var(--gbcal-focus) !important;
		outline-offset: 2px;
	}

	/* ---------------------------------------------------------------- lab version switcher */
	.gbcal-switch {
		position: fixed;
		left: max(12px, env(safe-area-inset-left, 0px));
		bottom: calc(12px + env(safe-area-inset-bottom, 0px));
		z-index: 900;
		display: flex;
		align-items: center;
		gap: 2px;
		padding: 4px;
		border: 1px solid var(--gbcal-line-2) !important;
		border-radius: 999px;
		background: var(--gbcal-switch-bg) !important;
		box-shadow: var(--gbcal-shadow) !important;
		font-family: var(--gbcal-font);
	}
	.gbcal-switch-label {
		padding: 0 6px 0 10px;
		font: 800 11px/1 var(--gbcal-font);
		letter-spacing: .1em;
		text-transform: uppercase;
		color: var(--gbcal-ink-3) !important;
	}
	body .gbcal-switch a {
		display: inline-grid;
		place-items: center;
		min-width: 44px;
		height: 44px;
		padding: 0 6px;
		border-radius: 999px;
		font: 800 15px/1 var(--gbcal-font);
		color: var(--gbcal-ink-2) !important;
		text-decoration: none !important;
		touch-action: manipulation;
		-webkit-tap-highlight-color: transparent;
		user-select: none;
		-webkit-user-select: none;
	}
	body .gbcal-switch a[aria-current="page"] {
		background: var(--gbcal-red-fill) !important;
		color: var(--gbcal-on-red) !important;
	}
	body .gbcal-switch a:focus-visible {
		outline: 2px solid var(--gbcal-focus) !important;
		outline-offset: 2px;
	}
	/* press feedback that does not move, so it also holds under reduced motion */
	body .gbcal-switch a:not([aria-current="page"]):active {
		background: var(--gbcal-switch-press) !important;
		color: var(--gbcal-ink) !important;
	}
	@media (hover: hover) and (pointer: fine) {
		.gbcal .gbcal-ssr-item > a:hover {
			text-decoration-thickness: 2px !important;
		}
		.gbcal-main .gbcal-credit a:hover {
			color: var(--gbcal-ink) !important;
		}
		.gbcal-main .gbcal-more-item > a:hover,
		.gbcal-main .gbcal-more-library a:hover {
			text-decoration-thickness: 2px !important;
		}
		body .gbcal-switch a:not([aria-current="page"]):hover {
			background: var(--gbcal-surface-2) !important;
			color: var(--gbcal-ink) !important;
		}
	}
	@media (prefers-reduced-motion: no-preference) {
		body .gbcal-switch a {
			transition: transform var(--gbcal-t-press) var(--gbcal-ease), background-color 160ms var(--gbcal-ease);
		}
		body .gbcal-switch a:active {
			transform: scale(var(--gbcal-press));
		}
	}
	@media (max-width: 420px) {
		.gbcal-switch-label {
			display: none;
		}
		.gbcal-ssr-badge {
			margin-left: 0;
		}
	}
	@media print {
		.gbcal-switch {
			display: none !important;
		}
	}
	@keyframes gbcal-ssr-show {
		to {
			visibility: visible;
		}
	}
}
