/*
	Sheets: windows in the mobile layout mode (see javascript/sheets.js).
	Everything is scoped under body.layout-mobile; the desktop layout is untouched.
	The game sets --sheet-top and --sheet-bottom for its header and tab bar.
*/

/*
	Desktop panels (minimap, newsbar) reach past a phone screen. Mobile browsers widen the
	layout viewport to fit them, which makes #sheets wider than the screen. Clip them inside
	#bodyDiv (already 100% by 100% of the viewport); overflow on html or body does not stop this.
*/
body.layout-mobile #bodyDiv
{
	position: relative;
	overflow: hidden;
}

body.layout-mobile #sheets
{
	position: fixed;
	inset: var(--sheet-top, 0) 0 var(--sheet-bottom, 0) 0;
	z-index: 1000;
	pointer-events: none;
}

body.layout-mobile #sheets .sheet
{
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	pointer-events: auto;
	background: #1d1a15;
	color: #ddd;
	font-family: Tahoma, Arial, sans-serif;
	font-size: 14px;
}

body.layout-mobile #sheets .sheet-bar
{
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	min-height: 44px;
	background: #2c261d;
	border-bottom: 1px solid #4a4032;
}

/* A root sheet has no Back: keep the title centred by reserving the button's room. */
body.layout-mobile #sheets .sheet-back[style*="display: none"] + .sheet-title
{
	margin-left: 44px;
}

body.layout-mobile #sheets .sheet-back,
body.layout-mobile #sheets .sheet-close
{
	flex: 0 0 auto;
	width: 44px;
	height: 44px;
	border: 0;
	background: transparent;
	color: #fff;
	font-size: 26px;
	line-height: 44px;
	text-align: center;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

body.layout-mobile #sheets .sheet-title
{
	flex: 1 1 auto;
	min-width: 0;
	padding: 0 8px;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
	color: #fff;
	font-weight: bold;
	font-size: 16px;
	text-align: center;
}

body.layout-mobile #sheets .sheet-title-text,
body.layout-mobile #sheets .sheet-subtitle
{
	display: block;
	overflow: hidden;
	text-overflow: ellipsis;
}

body.layout-mobile #sheets .sheet-subtitle
{
	font-weight: normal;
	font-size: 12px;
	line-height: 1.2;
	opacity: 0.8;
}

body.layout-mobile #sheets .sheet-content
{
	flex: 1 1 auto;
	min-height: 0;
	overflow: auto;
	-webkit-overflow-scrolling: touch;
	padding: 8px;
	box-sizing: border-box;
}

/* Modal: centred over a backdrop; the sheet underneath stays visible. Stacking follows DOM order. */
body.layout-mobile #sheets .sheet-backdrop
{
	position: fixed;
	inset: 0;
	pointer-events: auto;
	background: rgba(0, 0, 0, 0.6);
}

body.layout-mobile #sheets .sheet.sheet-modal
{
	position: fixed;
	inset: auto;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: calc(100% - 32px);
	max-width: 400px;
	max-height: calc(100% - 32px);
	border: 1px solid #4a4032;
	border-radius: 6px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

body.layout-mobile #sheets .sheet-modal .sheet-content
{
	padding: 16px;
}

body.layout-mobile #sheets .sheet-message
{
	margin: 0 0 16px 0;
}

body.layout-mobile #sheets .sheet-actions
{
	display: flex;
	gap: 8px;
	justify-content: flex-end;
}

body.layout-mobile #sheets .sheet-actions button
{
	min-width: 88px;
	min-height: 44px;
	padding: 0 16px;
	font-size: 14px;
}
