/* ── Backdrop ─────────────────────────────────────────────────
   Full-viewport dimmer behind the image. When the image is
   zoomed the backdrop allows scroll so the user can pan through
   overflow content. */
.backdrop {
	position: fixed;
	inset: 0;
	z-index: 16000;
	display: flex;
	/* `safe center` keeps the image centred when it fits the
	   viewport but stops centering once the content overflows —
	   without `safe`, an oversized child gets clipped at the top /
	   left and the user can't scroll back into the hidden region. */
	align-items: safe center;
	justify-content: safe center;
	background-color: rgba(0, 0, 0, 0.85);
	padding: 80px 48px 48px;
	box-sizing: border-box;
	overflow: auto;
	/* Desktop click-outside-to-close affordance — mobile drops
	   this via the media query below since tapping empty space
	   there is more likely to be accidental. */
	cursor: zoom-out;
}

/* Mobile: drop the backdrop padding so the image can use the full
   width of the screen. The mobile header buttons are position: fixed
   so they still float over the image instead of occupying layout. */
@media (max-width: 768px) {
	.backdrop {
		padding: 0;
		cursor: default;
	}
}

/* Image — fits the viewport by default. Toggling `.imageZoomed`
   drops the max constraints so the natural size kicks in; the
   backdrop becomes scrollable to pan through the overflow. */
.image {
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	border-radius: 4px;
	box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
	cursor: zoom-in;
	user-select: none;
	-webkit-user-drag: none;
	transition: transform 0.2s ease;
}

.imageZoomed {
	max-width: none;
	max-height: none;
	/* Force the image to its natural pixel dimensions so the
	   backdrop's overflow:auto actually has something to scroll. */
	width: auto;
	height: auto;
	min-width: max-content;
	min-height: max-content;
	cursor: zoom-out;
}

/* ── Mobile header row ───────────────────────────────────────
   Bare minimum on mobile: an X button pinned top-left and a
   three-dot menu button pinned top-right. Everything else lives
   in the MobileImageActionsSheet the menu button opens.
   Rendered instead of the desktop `.header` on touch viewports. */
.mobileHeader {
	position: fixed;
	top: 14px;
	left: 14px;
	right: 14px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	pointer-events: none;
	z-index: 1;
}

.mobileHeaderButton {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	background: transparent;
	border: none;
	border-radius: 50%;
	color: var(--text-primary, #fff);
	cursor: pointer;
	pointer-events: auto;
	-webkit-tap-highlight-color: transparent;
	transition: background-color 0.12s;
}

.mobileHeaderButton:active {
	background-color: rgba(255, 255, 255, 0.12);
}

/* ── Desktop header row ──────────────────────────────────────
   Sits above the image, pinned to the top of the viewport. Holds
   three independent cards: file info (left), action controls
   (right), close button (far right). */
.header {
	position: fixed;
	top: 16px;
	left: 24px;
	right: 24px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	height: 40px;
	pointer-events: none;
	z-index: 1;
}

/* File info card — filename + dimensions. Spec from Fluxer:
   `--background-textarea` surface with a 1px accent border and
   a soft drop shadow. Constrained max-width so it never shoves
   the action cards off-screen on narrow viewports. */
.fileInfoCard {
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 0.125rem;
	padding: 0.25rem 0.75rem;
	border-radius: var(--radius-lg, 10px);
	background-color: var(--background-textarea, rgba(24, 25, 28, 0.85));
	border: 1px solid var(--background-modifier-accent);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
	pointer-events: auto;
	min-width: 0;
	max-width: calc(100% - 260px);
	height: 100%;
	box-sizing: border-box;
}

.filename {
	font-size: 13px;
	font-weight: 700;
	color: var(--text-primary, #fff);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	line-height: 1.2;
}

.dimensions {
	font-size: 11px;
	color: var(--text-primary-muted, rgba(255, 255, 255, 0.6));
	font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
	line-height: 1.2;
}

/* Right-side cluster: action card + close card, separated so the
   close button can sit visually apart like the Fluxer reference. */
.headerRight {
	display: flex;
	align-items: stretch;
	gap: 8px;
	height: 100%;
	pointer-events: none;
}

/* Action card — zoom / favorite / save / open. Same surface
   treatment as the file info card, tighter padding and gap. */
.actionCard {
	display: flex;
	align-items: center;
	gap: 0.125rem;
	padding: 0.25rem 0.375rem;
	border-radius: var(--radius-lg, 10px);
	background-color: var(--background-textarea, rgba(24, 25, 28, 0.85));
	border: 1px solid var(--background-modifier-accent);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
	pointer-events: auto;
	height: 100%;
	box-sizing: border-box;
}

/* Close card — its own standalone pill. Square-ish so the X
   button reads as a self-contained control. */
.closeCard {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0.25rem;
	border-radius: var(--radius-lg, 10px);
	background-color: var(--background-textarea, rgba(24, 25, 28, 0.85));
	border: 1px solid var(--background-modifier-accent);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
	pointer-events: auto;
	height: 100%;
	box-sizing: border-box;
}

.actionButton {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	padding: 0;
	background: transparent;
	border: none;
	border-radius: 6px;
	color: var(--text-primary, #fff);
	cursor: pointer;
	transition: background-color 0.12s, color 0.12s;
}

.actionButton:hover:not(:disabled) {
	background-color: var(--background-modifier-hover, rgba(255, 255, 255, 0.1));
}

.actionButton:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

/* Favorited state — brand-primary fill + white icon so the
   star reads as "on" even when the button isn't hovered.
   Matches the spec'd `--brand-primary` / `--text-on-brand-primary`
   tokens. */
.actionButtonActive {
	background-color: var(--brand-primary);
	color: var(--text-on-brand-primary);
}

.actionButtonActive:hover:not(:disabled) {
	background-color: var(--brand-primary);
	color: var(--text-on-brand-primary);
	filter: brightness(1.08);
}
