/*
 * The phone sheet and the floating media card.
 *
 * Loaded last, so it has the final word over the earlier small-screen rules
 * in app.css and panel.css. Above the phone breakpoint nothing in the first
 * section applies and the workspace is the desk layout it has always been.
 */

/* The handle bar ------------------------------------------------------- */

.fh__sheet-bar {
	display: none;
}

.fh__mcard {
	position: absolute;
	z-index: 26;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	background: var(--fh-bg-2);
	border: 1px solid var(--fh-line-2);
	border-radius: var(--fh-radius-lg);
	box-shadow: 0 10px 34px rgba(0, 0, 0, 0.38);
}

.fh__mcard.is-small {
	width: min(46%, 280px);
}

.fh__mcard.is-large {
	width: min(80%, 460px);
}

.fh__mcard-head {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 5px 6px 5px 8px;
	background: var(--fh-bg);
	border-bottom: 1px solid var(--fh-line);
	cursor: grab;
	touch-action: none;
}

.fh__mcard-head:active {
	cursor: grabbing;
}

.fh__mcard-grip {
	flex: 0 0 auto;
	width: 12px;
	height: 3px;
	border-radius: 2px;
	background: var(--fh-line-2);
}

.fh__mcard-title {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: 11px;
	font-weight: 600;
	color: var(--fh-ink-2);
}

.fh__mcard-btn {
	flex: 0 0 auto;
	width: 26px;
	height: 26px;
	padding: 0;
	border: 0;
	border-radius: 6px;
	background: none;
	color: var(--fh-ink-2);
	font-size: 14px;
	line-height: 1;
	cursor: pointer;
}

.fh__mcard-btn:hover {
	background: var(--fh-bg-2);
	color: var(--fh-ink);
}

.fh__mcard-body {
	min-height: 0;
	max-height: 62vh;
	overflow: auto;
	background: #000;
}

.fh__mcard-body .fh__inspect-media,
.fh__mcard-body .fh__clip {
	margin: 0;
}

.fh__mcard-body img,
.fh__mcard-body video,
.fh__mcard-body iframe {
	display: block;
	width: 100%;
	max-height: 52vh;
	object-fit: contain;
}

/* What the panel says while the media is out over the map. */

.fh__inspect-mediahost.is-floating {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 8px 10px;
	border: 1px dashed var(--fh-line-2);
	border-radius: var(--fh-radius);
}

.fh__inspect-mediahost.is-floating p {
	margin: 0;
	font-size: 12px;
}

/* Phones --------------------------------------------------------------- */

@media (max-width: 820px) {

	/*
	 * One custom property carries the drawer's height. The sheets read it, the
	 * handle bar rides on top of it, and a drag writes it once per frame.
	 */
	.fh__stage.is-sheet {
		position: relative;
		padding-bottom: env(safe-area-inset-bottom, 0px);
	}

	/* The map keeps the whole stage; the drawer floats over it. */
	.fh__stage.is-sheet .fh__stage-main {
		flex: 1;
		min-height: 0;
	}

	.fh__stage.is-sheet .fh__sheet-bar {
		position: absolute;
		left: 0;
		right: 0;
		bottom: var(--fh-sheet-h, 0px);
		z-index: 30;
		display: flex;
		gap: 1px;
		background: var(--fh-line);
		border-top: 1px solid var(--fh-line-2);
	}

	.fh__stage.is-sheet.is-sheet-dragging .fh__sheet-bar,
	.fh__stage.is-sheet.is-sheet-dragging .fh__lower-dock,
	.fh__stage.is-sheet.is-sheet-dragging .fh__panel {
		transition: none;
	}

	.fh__sheet-handle {
		flex: 1 1 50%;
		display: flex;
		flex-direction: column;
		align-items: center;
		gap: 2px;
		min-height: 46px;
		padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
		border: 0;
		background: var(--fh-bg-2);
		color: var(--fh-ink-2);
		font: inherit;
		font-size: 10.5px;
		font-weight: 700;
		letter-spacing: 0.08em;
		text-transform: uppercase;
		cursor: pointer;
		touch-action: none;
	}

	/* Once the drawer is up its own foot carries the inset, not the handles. */
	.fh__stage.is-sheet-open .fh__sheet-handle {
		padding-bottom: 6px;
	}

	.fh__sheet-handle.is-up {
		background: var(--fh-bg);
		color: var(--fh-accent);
	}

	.fh__sheet-grip {
		width: 34px;
		height: 4px;
		border-radius: 2px;
		background: var(--fh-line-2);
	}

	.fh__sheet-handle.is-up .fh__sheet-grip {
		background: var(--fh-accent);
	}

	.fh__sheet-word {
		display: block;
	}

	.fh__sheet-chev {
		display: none;
	}

	/* The two workbenches, as one drawer -------------------------------- */

	.fh__stage.is-sheet .fh__lower-dock,
	.fh__stage.is-sheet .fh__panel {
		position: absolute;
		left: 0;
		right: 0;
		bottom: 0;
		top: auto;
		z-index: 29;
		width: auto;
		max-width: none;
		height: var(--fh-sheet-h, 0px);
		max-height: none;
		min-height: 0;
		margin: 0;
		flex: none;
		overflow: hidden;
		background: var(--fh-bg-2);
		border: 0;
		border-top: 1px solid var(--fh-line-2);
		border-radius: 0;
		box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.28);
		transition: height 0.22s ease;
	}

	/* Only the raised one is on screen. */
	.fh__stage.is-sheet .fh__lower-dock,
	.fh__stage.is-sheet .fh__panel {
		display: none;
	}

	.fh__stage.is-sheet-evidence .fh__lower-dock {
		display: flex;
		flex-direction: column;
		overflow: auto;
		-webkit-overflow-scrolling: touch;
	}

	.fh__stage.is-sheet-intelligence .fh__panel {
		display: flex;
		flex-direction: column;
	}

	/* Raised, the panel shows its tabs whatever its desk state was. */
	.fh__stage.is-sheet-intelligence .fh__panel .fh__panel-head {
		display: flex;
	}

	.fh__stage.is-sheet .fh__panel .fh__panel-body {
		flex: 1;
		min-height: 0;
		overflow: auto;
		-webkit-overflow-scrolling: touch;
	}

	/* The drawer is never "collapsed" in the desk sense while it is a sheet. */
	.fh__stage.is-sheet .fh__lower-dock.is-collapsed {
		height: var(--fh-sheet-h, 0px);
	}

	.fh__stage.is-sheet .fh__lower-dock.is-collapsed > .fh__strip {
		display: block;
	}

	.fh__stage.is-sheet .fh__lower-dock.is-collapsed > .fh__time {
		display: flex;
	}

	/* The desk's own tabs have no job here; the handle bar replaced both. */
	.fh__stage.is-sheet .fh__lower-dock-tab,
	.fh__stage.is-sheet .fh__panel-edge-tab,
	.fh__stage.is-sheet .fh__panel-tab-open {
		display: none;
	}

	/* The card sits clear of the handle bar. */
	.fh__stage.is-sheet .fh__mcard {
		z-index: 27;
	}

	.fh__mcard.is-small {
		width: min(52%, 230px);
	}

	.fh__mcard.is-large {
		width: calc(100% - 20px);
	}

	.fh__mcard-body {
		max-height: 44vh;
	}

	.fh__mcard-body img,
	.fh__mcard-body video,
	.fh__mcard-body iframe {
		max-height: 38vh;
	}
}

@media (prefers-reduced-motion: reduce) {
	.fh__stage.is-sheet .fh__lower-dock,
	.fh__stage.is-sheet .fh__panel {
		transition: none;
	}
}
