/*
 * Tier ’Swich. See includes/class-iig-tier.php.
 *
 * Phones first: on a 390 wide phone a row holds five pictures beside its letter. The board is the one everybody
 * knows: S to F in the usual colours, on black, pictures edge to edge. Headings are Anton in capitals, as on the
 * rest of the site.
 *
 * The game and the lobby fill the window under the bar, in maroon, as Which ’Swich does. Jamey, 26 November: "you
 * need to make the tier game immersive like the other games. right now it feels like a square on a screen".
 */
@font-face {
	font-family: "ITR Anton";
	src: url("fonts/anton-latin.woff") format("woff");
	font-weight: 400;
	font-style: normal;
	font-display: swap;
}

.itr-public {
	--itr-maroon: #73182c;
	--itr-deep: #4f0e1f;
	--itr-yellow: #ffdd2c;
	margin: 0;
	background: #fff;
	color: #1a1a1a;
	font: 16px/1.5 Poppins, Arial, sans-serif;
}
.itr-public *,
.itr-public *::before,
.itr-public *::after { box-sizing: border-box; }
.itr-public [hidden] { display: none !important; }
.itr-public a { color: #0a6fb0; }

/* The theme dresses every button. Here each one starts plain. */
.itr button {
	appearance: none;
	-webkit-appearance: none;
	display: inline-block;
	width: auto;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	outline: 0;
	background: none;
	color: inherit;
	font: inherit;
	line-height: inherit;
	text-align: inherit;
	vertical-align: top;
	cursor: pointer;
	touch-action: manipulation;
}
.itr button:focus-visible,
.itr a:focus-visible {
	outline: 3px solid var(--itr-yellow);
	outline-offset: 2px;
}

/* The stage: the whole window under the bar, edge to edge, in maroon, with white words. */
.itr {
	--room: calc(100vh - var(--iig-nav-height, 0px));
	min-height: var(--room);
	margin: 0;
	padding: 0 0 20px;
	background: radial-gradient(120% 80% at 50% 0%, #86233e 0%, var(--itr-maroon) 46%, var(--itr-deep) 100%);
	color: #fff;
	/* The board and the tray size their pictures from this box's width. */
	container-type: inline-size;
}
@supports (height: 100svh) {
	.itr { --room: calc(100svh - var(--iig-nav-height, 0px)); }
}
.itr-public .itr a { color: #fff; }

.itr__head { padding: 14px 16px 12px; }
.itr__kicker {
	margin: 0;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: .08em;
	text-transform: uppercase;
}
.itr-public .itr__kicker a { color: rgba(255, 255, 255, .82); text-decoration: none; }
.itr__title {
	margin: 2px 0 4px;
	color: var(--itr-yellow);
	font: 400 32px/1.08 "ITR Anton", Anton, Impact, sans-serif;
	text-transform: uppercase;
	letter-spacing: .01em;
	text-shadow: 0 3px 0 rgba(0, 0, 0, .25);
}
.itr__lead { margin: 0; font-size: 17px; }
.itr__hint { margin: 0; min-height: 1.5em; font-size: 15px; font-weight: 600; }
/* The tiny guide: S is super, A to F are like old school grades. */
.itr__guide { margin: 0 0 2px; font-size: 15px; line-height: 1.6; }
.itr__chip {
	display: inline-block;
	padding: 0 6px;
	border-radius: 3px;
	color: #1a1a17;
	font: 400 15px/1.45 "ITR Anton", Anton, Impact, sans-serif;
	letter-spacing: .02em;
	vertical-align: 1px;
}
.itr__chip--grades { background: linear-gradient(90deg, #ffbf7f, #ffdf7f, #ffff7f, #bfff7f, #7fff7f); }

/* The board's fun name, and the way to another. On a phone it takes the guide's line once a picture is placed. */
.itr__named {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	column-gap: 8px;
	margin: 0 0 2px;
	font-size: 15px;
	line-height: 1.5;
}
.itr__named[hidden] { display: none !important; }
.itr__named-label { color: rgba(255, 255, 255, .82); font-weight: 600; }
.itr__name {
	color: var(--itr-yellow);
	font: 400 18px/1.3 "ITR Anton", Anton, Impact, sans-serif;
	letter-spacing: .02em;
	text-transform: uppercase;
}
.itr .itr__rename {
	padding: 0 2px;
	min-height: 28px;
	color: #fff;
	font-size: 14px;
	font-weight: 700;
	text-decoration: underline;
	text-underline-offset: 3px;
}
.itr--game.is-named .itr__guide { display: none; }
/* On a phone the name and New name fit one line without "Your list:". */
.itr--game .itr__named-label { display: none; }
@media (min-width: 900px) and (min-aspect-ratio: 1/1) {
	.itr--game.is-named .itr__guide { display: block; }
	.itr--game .itr__named-label { display: inline; }
	.itr__named { font-size: 17px; }
	.itr__name { font-size: 22px; }
}
.itr__lead--link { margin-top: 6px; font-weight: 700; }
.itr-public .itr__lead--link a,
.itr-public .itr__more a { color: var(--itr-yellow); }

/* ---- The game, on a phone: the words, the board, then the pictures to place, docked at the foot of the screen so
 * a picture and a row are both in reach without scrolling. The side column is only a column on a computer. */
.itr--game { display: flex; flex-direction: column; padding-bottom: 0; }
.itr--game .itr__side { display: contents; }
/* Room is tight on a phone: the bar's Tier ’Swich box already leads back to the lobby, so the small line over the
 * name only shows on a computer. */
.itr--game .itr__kicker { display: none; }
.itr--game .itr__head { padding: 10px 16px 8px; }
.itr--game .itr__title { font-size: 28px; }
.itr--game .itr__head { order: 1; }
.itr--game .itr__board { order: 2; }
.itr--game .itr__dock { order: 3; }
.itr--game .itr__end { order: 4; }
.itr--game .itr__again { order: 5; }
.itr--game .itr__join { order: 6; }
.itr__dock {
	position: sticky;
	bottom: 0;
	z-index: 3;
	margin-top: 6px;
	padding-bottom: env(safe-area-inset-bottom, 0px);
	border-radius: 14px 14px 0 0;
	background: var(--itr-deep);
	box-shadow: 0 -8px 22px rgba(0, 0, 0, .35);
	/* The tray sizes its pictures from the dock's width. */
	container-type: inline-size;
}

/* ---- The board. */
.itr__board {
	--label: 56px;
	--tile: 64px;
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: 2px 0;
	background: #000;
	box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
@supports (width: 1cqi) {
	/* Five pictures beside the letter, at any width, up to a size that still looks like a tier list. */
	.itr__board { --tile: min(104px, calc((100cqi - var(--label)) / 5)); }
}
.itr__row {
	display: flex;
	min-height: var(--tile);
	background: #1a1a17;
}
.itr .itr__label {
	flex: 0 0 var(--label);
	display: grid;
	place-items: center;
	min-height: var(--tile);
	color: #1a1a17;
	font: 400 30px/1 "ITR Anton", Anton, Impact, sans-serif;
	text-align: center;
}
.itr__tiles {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-wrap: wrap;
	align-content: flex-start;
}
.itr .itr__tile {
	position: relative;
	display: block;
	flex: 0 0 var(--tile);
	width: var(--tile);
	height: var(--tile);
	background: #000;
	-webkit-user-select: none;
	user-select: none;
	-webkit-touch-callout: none;
}
.itr__tile img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	pointer-events: none;
}
.itr .itr__tile.is-picked {
	z-index: 1;
	outline: 4px solid #ffdd2c;
	outline-offset: -4px;
}
.itr .itr__tile.is-picked img { opacity: .82; }

/* Holding a picture: the rows show they can be tapped. */
.is-holding .itr__label { box-shadow: inset 0 0 0 3px rgba(0, 0, 0, .35); }
.is-holding .itr__tiles,
.is-holding .itr__tray { cursor: copy; }
@media (hover: hover) {
	.is-holding .itr__row:hover .itr__tiles,
	.is-holding .itr__tray:hover { background: #2b2b26; }
}

/* Dragging with a mouse: the picture follows the pointer and the row it will land in is marked. */
.itr .itr__tile { cursor: grab; }
.is-dragging,
.is-dragging * { cursor: grabbing !important; }
.itr .itr__tile.is-dragging {
	z-index: 5;
	pointer-events: none;
	scale: 1.06;
	box-shadow: 0 10px 24px rgba(0, 0, 0, .45);
}
.itr__row.is-target .itr__tiles,
.itr__tray.is-target { background: #34342e; }
.itr .itr__tile.is-target { box-shadow: inset 4px 0 0 #ffdd2c; }

/* ---- The tray of pictures still to place. */
.itr__trayhead {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	min-height: 44px;
	padding: 0 16px;
}
.itr__left {
	margin: 0;
	color: #fff;
	font: 400 19px/1.2 "ITR Anton", Anton, Impact, sans-serif;
	text-transform: uppercase;
}
.itr .itr__share {
	flex: none;
	min-height: 44px;
	margin: 6px 0;
	padding: 0 14px;
	border: 2px solid #1a1a17;
	border-bottom-width: 4px;
	border-radius: 8px;
	background: #12a7ff;
	color: #0d1b24;
	font: 400 17px/1 "ITR Anton", Anton, Impact, sans-serif;
	letter-spacing: .02em;
	text-transform: uppercase;
	white-space: nowrap;
}
.itr .itr__share:hover { background: #5cc4ff; }
.itr .itr__share:active { border-bottom-width: 2px; margin-top: 8px; margin-bottom: 4px; }
.itr .itr__reset {
	min-height: 44px;
	padding: 0 4px;
	color: var(--itr-yellow);
	font-size: 16px;
	font-weight: 700;
	text-decoration: underline;
}
.itr__tray {
	display: flex;
	flex-wrap: wrap;
	align-content: flex-start;
	min-height: 64px;
	padding: 0;
	background: #1a1a17;
	--tile: 64px;
	/* On a phone two rows and a bit of the next show, and the rest scroll inside the dock. */
	max-height: calc(var(--tile) * 2.3);
	overflow-y: auto;
	overscroll-behavior: contain;
}
@supports (width: 1cqi) {
	/* The tray holds six to a row on a phone, the same size as a picture on the board. */
	.itr__tray { --tile: min(104px, calc(100cqi / 6)); }
}
/* In the tray a picture is a share of the tray's own width, so a scrollbar beside it can never push one onto the
 * next row. Square, as on the board. */
.itr .itr__tray > .itr__tile {
	flex: 0 0 calc(100% / 6);
	width: calc(100% / 6);
	max-width: 104px;
	height: auto;
	aspect-ratio: 1 / 1;
}

/*
 * On a computer: the words and the pictures to place on the left, the board on the right, as tall as the window.
 * The left stays in view while the page scrolls, and its pictures scroll inside it, so a picture can be dragged
 * straight across with a mouse. Jamey works on a 27 inch screen.
 */
@media (min-width: 900px) and (min-aspect-ratio: 1/1) {
	.itr--game {
		display: grid;
		grid-template-columns: minmax(360px, .72fr) minmax(0, 1.28fr);
		column-gap: clamp(24px, 3vw, 56px);
		align-items: start;
		padding: 24px max(24px, calc(50vw - 880px));
		background: radial-gradient(75% 95% at 68% 50%, #86233e 0%, var(--itr-maroon) 50%, var(--itr-deep) 100%);
	}
	.itr--game .itr__side {
		position: sticky;
		top: 16px;
		display: flex;
		flex-direction: column;
		min-width: 0;
		max-height: calc(var(--room) - 48px);
	}
	.itr--game .itr__head { padding: 0 0 16px; }
	.itr--game .itr__kicker { display: block; }
	.itr--game .itr__title { font-size: clamp(40px, 3.6vw, 64px); }
	.itr--game .itr__guide,
	.itr--game .itr__hint { font-size: 17px; }
	.itr--game .itr__dock {
		position: static;
		flex: 1 1 auto;
		display: flex;
		flex-direction: column;
		min-height: 0;
		margin: 0;
		border-radius: 12px;
		overflow: hidden;
		box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
	}
	.itr--game .itr__tray { flex: 1 1 auto; max-height: none; min-height: 0; }
	.itr--game .itr__end { padding: 0; }
	.itr--game .itr__again { text-align: left; }
	.itr--game .itr__board {
		grid-column: 2;
		grid-row: 1;
		--label: clamp(72px, 6vw, 112px);
		border: 3px solid #000;
		border-radius: 6px;
	}
	.itr.itr--game .itr__label { font-size: clamp(34px, 3vw, 54px); }
}
@media (min-width: 900px) and (min-aspect-ratio: 1/1) {
	@supports (width: 1cqi) {
		/* Six rows as tall as the window allows, and five pictures across the tray. */
		.itr--game .itr__board { --tile: clamp(64px, calc((var(--room) - 48px - 16px) / 6), 150px); }
		.itr--game .itr__tray { --tile: calc(100cqi / 5); }
		.itr.itr--game .itr__tray > .itr__tile { flex-basis: 20%; width: 20%; max-width: none; }
	}
}

/* ---- Done. */
.itr__end { padding: 16px 16px 0; }
.itr__end-title {
	margin: 0 0 4px;
	color: var(--itr-yellow);
	font: 400 28px/1.2 "ITR Anton", Anton, Impact, sans-serif;
	text-transform: uppercase;
}
.itr__end-title:focus { outline: 0; }
.itr .itr__moves button.iig-share-open-button {
	margin: 10px 0 0;
	min-height: 52px;
	border: 2px solid #1a1a17;
	border-bottom-width: 5px;
	border-radius: 10px;
	background: #12a7ff;
	color: #0d1b24;
	font: 400 21px/1.2 "ITR Anton", Anton, Impact, sans-serif;
	letter-spacing: .02em;
	text-transform: uppercase;
	text-align: center;
}
.itr__more { margin: 14px 0 0; font-size: 15px; font-weight: 600; }
.itr__join { margin: 16px 0 0; }
.itr__again { margin: 8px 0 0; text-align: center; }
.is-done .itr__again { margin-top: 18px; }

.itr-footer {
	padding: 22px 16px;
	font-size: 14px;
	text-align: center;
}

/* ---- The lobby: the same maroon stage, its lists as cards. */
.itr--lobby { padding: 0 max(0px, calc(50vw - 700px)) 32px; }
.itr--lobby .itr__head { padding-top: 20px; }
.itr--lobby .itr__title { font-size: clamp(36px, 9vw, 64px); }
.itr-lobby {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 14px;
	margin: 8px 0 0;
	padding: 0 16px;
	list-style: none;
}
@media (min-width: 640px) {
	.itr-lobby { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1100px) {
	.itr--lobby .itr__head { padding: 32px 16px 18px; }
	.itr-lobby { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
}
.itr-lobby__card {
	display: flex;
	align-items: center;
	gap: 14px;
	height: 100%;
	padding: 14px;
	border-radius: 12px;
	background: #1a1a17;
	color: #fff;
	text-decoration: none;
	box-shadow: 0 10px 26px rgba(0, 0, 0, .3);
}
.itr-public .itr-lobby__card { color: #fff; }
.itr-lobby__words {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 4px;
}
.itr-lobby__name {
	font: 400 21px/1.15 "ITR Anton", Anton, Impact, sans-serif;
	text-transform: uppercase;
}
.itr-lobby__count { font-size: 14px; }
.itr-lobby__go {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	margin-top: 6px;
	padding: 0 16px;
	border-radius: 6px;
	background: #12a7ff;
	color: #0d1b24;
	font: 400 17px/1 "ITR Anton", Anton, Impact, sans-serif;
	text-transform: uppercase;
}
.itr-lobby__card:hover .itr-lobby__go { background: #5cc4ff; }

/* ---- A small tier list, the picture of what the game is. */
.itr-mini {
	--m: 30px;
	flex: none;
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: 2px;
	background: #000;
}
.itr-mini__row { display: flex; }
.itr-mini__label {
	display: grid;
	place-items: center;
	width: var(--m);
	height: var(--m);
	color: #1a1a17;
	font: 400 calc(var(--m) * .55)/1 "ITR Anton", Anton, Impact, sans-serif;
}
.itr-mini__tile,
.itr-mini__gap {
	display: block;
	width: var(--m);
	height: var(--m);
	object-fit: cover;
	background: #1a1a17;
}

/* ---- The gallery: the boards readers have shared, newest first, as their cards. */
.itr--gallery { padding: 0 max(0px, calc(50vw - 700px)) 36px; }
.itr--gallery .itr__head { padding-top: 20px; }
.itr--gallery .itr__title { font-size: clamp(36px, 9vw, 64px); }
.itr-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 4px 0 18px;
	padding: 0 16px;
}
.itr-public .itr-chips a {
	display: inline-flex;
	align-items: center;
	min-height: 40px;
	padding: 0 14px;
	border-radius: 8px;
	background: rgba(255, 255, 255, .14);
	color: #fff;
	font-size: 15px;
	font-weight: 600;
	text-decoration: none;
}
.itr-public .itr-chips a:hover { background: rgba(255, 255, 255, .24); }
.itr-public .itr-chips a[aria-current] { background: var(--itr-yellow); color: #1a1a17; }
.itr-gallery {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 18px;
	margin: 0;
	padding: 0 16px;
	list-style: none;
}
@media (min-width: 700px) { .itr-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .itr-gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; } }
.itr-gallery__figure {
	height: 100%;
	margin: 0;
	overflow: hidden;
	border-radius: 12px;
	background: #1a1a17;
	box-shadow: 0 10px 26px rgba(0, 0, 0, .3);
}
.itr-gallery__card { display: block; width: 100%; height: auto; aspect-ratio: 1200 / 630; }
.itr-gallery__words { padding: 12px 14px 14px; }
.itr-gallery__name {
	margin: 0 0 2px;
	color: var(--itr-yellow);
	font: 400 22px/1.15 "ITR Anton", Anton, Impact, sans-serif;
	text-transform: uppercase;
}
.itr-gallery__meta { margin: 0; font-size: 14px; color: rgba(255, 255, 255, .82); }
.itr-public .itr-gallery__meta a { color: #fff; font-weight: 600; }
.itr-gallery__top { margin: 4px 0 0; font-size: 14px; }
.itr-gallery__empty { padding: 0 16px; }
.itr-gallery__more { margin: 24px 0 0; padding: 0 16px; }
.itr-public .itr-gallery__more a { color: #0d1b24; text-decoration: none; }
.itr-public .itr-gallery__more a:hover { background: #5cc4ff; }

@media (prefers-reduced-motion: reduce) {
	.itr .itr__tile.is-dragging { scale: 1; }
}
