/*
   Popups in general (the panel, its heading, buttons and focus), and this game's
   players list.
   Loaded in order with the others (see index.html): a later rule wins. */

/* SETTINGS */

.settings-background {
	position: absolute;
	inset: 0; /* the whole screen, phone margins included, so what's in it stays centred */
	padding-bottom: var(--bar-short, 0px); /* under iOS's solid status bar, in the middle of the screen rather than the page (theme-early.js) */
	box-sizing: border-box;
	background: rgba(0, 0, 0, 0.8);
	display: flex;
	justify-content: center;
	align-items: center;
	z-index: 100;
}

.settings-section {
	background: var(--panel);
	border: var(--border);
	border-radius: var(--radius);
	padding: calc(2 * var(--m));
	width: 50%;
	max-height: 90%;
	overflow-y: auto;
	box-sizing: border-box;
}

.settings-tbl {
	width: 100%;
	border-spacing: calc(1 * var(--m));
	color: var(--text);
	font-size: calc(3 * var(--m));
}

.settings-tbl td {
	padding: calc(1 * var(--m));
	vertical-align: bottom;
}

.new-game-section .settings-check {
	display: flex;
	align-items: center;
	gap: calc(1 * var(--m));
	margin: 0;
	color: var(--text);
	cursor: pointer;
}

.new-game-section .settings-check input {
	flex: none;
	width: calc(3 * var(--m));
	height: calc(3 * var(--m));
	margin: 0;
	accent-color: var(--checkout);
}

/* Settings never scrolls as a whole; only the player list does. */
.settings-main {
	/* Half the screen, but wide enough for the game settings row on 4:3. Full
	   height, the room left over going to the player list. */
	width: max(50%, calc(78 * var(--m)));
	height: 95%;
	max-height: 95%;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.new-game-section .settings-check:has(input:disabled) {
	opacity: 0.4;
}

.settings-version {
	margin: 0;
	font-size: calc(2.6 * var(--m));
	font-weight: normal;
	color: var(--text-muted);
}

/* Dialogs take the focus when they open (for the keyboard), without a ring. */
.settings-background:focus {
	outline: none;
}

.settings-heading {
	margin: calc(1 * var(--m)) calc(1 * var(--m)) 0;
	padding-bottom: calc(0.6 * var(--m));
	border-bottom: 1px solid var(--text-muted);
	font-family: var(--font-condensed);
	font-size: calc(5 * var(--m)); /* the size of every popup's title (.confirm-title) */
	font-weight: 500;
	color: var(--text);
}

@property --fade-top {
	syntax: "<length>";
	inherits: false;
	initial-value: 0px;
}

@property --fade-bottom {
	syntax: "<length>";
	inherits: false;
	initial-value: 0px;
}

.players-scroll {
	flex: 1 1 auto;
	min-height: calc(12 * var(--m));
	/* In line with the fields and buttons in the tables around it. The few px
	   of padding keep the fields' side borders off the clipped edge, where
	   they lost a sliver at fractional screen scaling. */
	margin: calc(1 * var(--m)) calc(calc(2 * var(--m)) - 3px) 0;
	padding: 0 3px;
	overscroll-behavior: contain;
}

/* Names scrolled out of view fade out at that edge. */
.players-scroll,
.draft-list {
	overflow-y: auto;
	scrollbar-width: none;
	mask-image: linear-gradient(transparent, black var(--fade-top), black calc(100% - var(--fade-bottom)), transparent);
	transition: --fade-top var(--medium), --fade-bottom var(--medium);
}

.players-scroll::-webkit-scrollbar,
.draft-list::-webkit-scrollbar {
	display: none;
}

.players-scroll.fade-top,
.draft-list.fade-top {
	--fade-top: calc(5 * var(--m));
}

.players-scroll.fade-bottom,
.draft-list.fade-bottom {
	--fade-bottom: calc(5 * var(--m));
}

.players-list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.player-item {
	padding: calc(0.5 * var(--m)) 0;
}

/* While a player is dragged the others slide aside to make room (JS sets
   their transforms); on release the player settles into its slot. */
:is(.players-list, .draft-list).sorting .player-item {
	transition: transform var(--medium) var(--ease-out);
}

.player-item:is(.dragging, .dropping, .moving) {
	position: relative;
	z-index: 1;
}

:is(.players-list, .draft-list).sorting .player-item.dragging {
	transition: none;
	opacity: 0.9;
}

:is(.players-list, .draft-list).sorting .player-item.dropping {
	transition: transform var(--fast) var(--ease-out);
}

.player-item:is(.dragging, .dropping, .moving) .player-field {
	border-color: var(--text);
	box-shadow: 0 calc(1 * var(--m)) calc(2 * var(--m)) rgba(0, 0, 0, 0.6);
}

/* Name with its controls inside the field: grip, name, remove. */
.player-field {
	display: flex;
	align-items: center;
	height: calc(5 * var(--m));
	background: var(--field);
	border: 1px solid var(--text-muted);
	border-radius: var(--radius);
	color: var(--text);
}

.settings-section .player-field input {
	flex: 1;
	min-width: 0;
	height: 100%;
	padding: 0 calc(0.5 * var(--m));
	font-family: var(--font);
	font-size: calc(2.6 * var(--m));
	color: var(--text);
	background: none;
	border: none;
	outline: none;
}

/* The handle to drag a player by, three lines (see pressPlayer). */
.grip {
	align-self: stretch;
	touch-action: none; /* a drag here moves the player, not the list */
	cursor: grab;
	width: calc(2.2 * var(--m));
	padding: 0 calc(1.2 * var(--m));
	color: var(--text-muted);
	--bar: linear-gradient(currentColor 0 0);
	background:
		var(--bar) center calc(50% - calc(0.7 * var(--m))) / calc(2.2 * var(--m)) calc(0.3 * var(--m)) no-repeat content-box,
		var(--bar) center / calc(2.2 * var(--m)) calc(0.3 * var(--m)) no-repeat content-box,
		var(--bar) center calc(50% + calc(0.7 * var(--m))) / calc(2.2 * var(--m)) calc(0.3 * var(--m)) no-repeat content-box;
}

.dragging .player-field,
.dragging .player-field * {
	cursor: grabbing;
}

.field-btn {
	width: calc(5 * var(--m));
	height: 100%;
	padding: 0;
	font-size: calc(2.2 * var(--m));
	color: var(--text);
	background: none;
	border: none;
	border-left: 1px solid #323232;
	cursor: pointer;
}

.field-btn:active {
	transform: scale(0.85);
}

.field-btn:disabled {
	color: #484848;
	cursor: default;
}

.delete-player {
	color: var(--bust);
}

/* Drawn, not a character: iOS shows that one as an emoji, which ignores the colour. */
.cross-icon {
	width: 1.2em;
	height: 1.2em;
	margin: auto;
	stroke-width: 3.5;
	filter: none;
}

.players-add {
	width: 100%;
	height: calc(5 * var(--m));
	margin: calc(0.5 * var(--m)) 0;
	font-family: inherit;
	font-size: calc(3.6 * var(--m));
	line-height: 1;
	color: var(--text);
	border: var(--border);
	border-radius: var(--radius);
	background: var(--panel);
	cursor: pointer;
}

/* Settings, at the top: the game being played in a line, and New game beside it. */
.current-game {
	display: flex;
	align-items: center;
	gap: calc(2 * var(--m));
	margin: calc(2 * var(--m)) calc(2 * var(--m)) calc(1 * var(--m));
}

.settings-summary {
	flex: 1;
	min-width: 0;
	margin: 0;
	font-family: var(--font-condensed);
	font-size: calc(2.8 * var(--m));
	color: var(--text);
}

.settings-summary b {
	font-size: calc(3.2 * var(--m));
	font-weight: 600;
}

.current-game .settings-btn-action {
	flex: none;
	width: auto;
	padding: calc(1 * var(--m)) calc(3 * var(--m));
	font-size: calc(3 * var(--m));
}
