/*
 * Copyright (C) 2026 Fluxer Contributors
 *
 * This file is part of Fluxer.
 *
 * Fluxer is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Fluxer is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
 */

.embed {
	position: relative;
	display: inline-grid;
	inline-size: fit-content;
	max-inline-size: 100%;
	max-width: 100%;
	box-sizing: border-box;
	border-radius: 8px;
}

.embedFull {
	background: var(--background-primary);
	border: 1px solid var(--background-modifier-accent);
}

.gridContainer {
	width: 100%;
}

.grid {
	overflow: hidden;
	padding: 12px 12px 14px 12px;
	display: grid;
	grid-template-columns: auto;
	grid-template-rows: auto;
}

.grid.hasThumbnail {
	grid-template-columns: auto min-content;
}

.embedContent {
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.embedContent > *:first-child {
	margin-top: 4px;
}

.embedLink {
	text-decoration: var(--link-decoration);
	cursor: pointer;
	color: var(--text-link);
}

.embedLink code {
	color: var(--text-link);
}

.embedLink:hover {
	text-decoration: underline;
}

.embedProvider {
	font-size: 0.75rem;
	line-height: 1rem;
	grid-column: 1 / 1;
	font-weight: 500;
	color: var(--text-tertiary);
}

.embedProvider .embedLink {
	color: inherit;
}

.embedProvider .embedLink:hover {
	color: inherit;
	text-decoration: underline;
}

.embedAuthor {
	display: flex;
	align-items: center;
	grid-column: 1 / 1;
	min-width: 0;
}

.embedAuthorName {
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--text-primary);
}

.embedAuthorNameLink {
	color: var(--text-primary);
	cursor: pointer;
}

.embedAuthorNameLink:hover {
	color: var(--text-primary);
}

.embedAuthorIcon {
	flex-shrink: 0;
	margin-right: 8px;
	width: 24px;
	height: 24px;
	object-fit: cover;
	border-radius: 50%;
}

.embedTitle {
	font-size: 1rem;
	font-weight: 600;
	display: inline-block;
	grid-column: 1 / 1;
	color: var(--text-primary);
}

.embedDescription {
	font-size: 0.875rem;
	line-height: 1.125rem;
	white-space: pre-line;
	grid-column: 1 / 1;
	color: var(--text-primary);
}

.embedFields {
	display: grid;
	grid-column: 1 / 1;
	grid-template-columns: repeat(12, minmax(0, 1fr));
	gap: 8px;
	min-width: 0;
	margin-top: 8px;
}

.embedField {
	font-size: 0.875rem;
	line-height: 1.125rem;
	min-width: 0;
}

.embedFieldName {
	font-size: 0.875rem;
	line-height: 1.125rem;
	font-weight: 600;
	margin-bottom: 2px;
	min-width: 0;
	color: var(--text-primary);
}

.embedFieldValue {
	font-size: 0.875rem;
	line-height: 1.125rem;
	white-space: pre-line;
	min-width: 0;
}

.embedAuthorName,
.embedAuthorNameLink,
.embedDescription,
.embedFieldName,
.embedFieldValue,
.embedFooterText,
.embedLink,
.embedProvider,
.embedTitle {
	text-align: start;
	unicode-bidi: plaintext;
}

.embedMedia {
	grid-column: 1 / 1;
	border-radius: 4px;
	contain: paint;
	margin-top: 4px;
	overflow: hidden;
}

.hasThumbnail .embedMedia {
	grid-column: 1 / 3;
}

.embedThumbnail {
	grid-row: 1 / 8;
	grid-column: 2 / 2;
	margin-left: 16px;
	margin-top: 8px;
	flex-shrink: 0;
	justify-self: end;
	max-width: 80px;
	height: 80px;
	border-radius: 4px;
	overflow: hidden;
}

.embedFooter {
	display: flex;
	align-items: center;
	grid-column: 1 / 1;
}

.hasThumbnail .embedFooter {
	grid-column: 1 / 3;
}

.embedFooterText {
	font-size: 0.75rem;
	line-height: 1rem;
	font-weight: 600;
	color: var(--text-chat);
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
}

.embedFooterIcon {
	flex-shrink: 0;
	margin-right: 8px;
	width: 20px;
	height: 20px;
	object-fit: contain;
	border-radius: 50%;
}

.embedFooterSeparator {
	width: 4px;
	height: 4px;
	border-radius: 50%;
	background-color: var(--text-chat);
	margin: 0 4px;
	display: inline-block;
	vertical-align: middle;
}

.embedGifvContainer {
	/* width/max-width handled by inline styles to avoid fit-content circularity */
}

.container {
	display: inline-flex;
	align-items: flex-start;
	max-width: 100%;
}

.mediaFrame {
	position: relative;
	display: inline-block;
	inline-size: fit-content;
	max-inline-size: min(100%, var(--message-media-max-width, 550px));
	max-width: 100%;
}

.suppressButton {
	order: 2;
	display: flex;
	height: 1.5rem;
	width: 1.5rem;
	align-items: center;
	justify-content: center;
	align-self: flex-start;
	margin-top: 0.25rem;
	margin-left: 0.375rem;
	color: var(--text-tertiary);
	transition: color 150ms ease;
	border: none;
	background: transparent;
	cursor: pointer;
	padding: 0;
	flex-shrink: 0;
}

.mediaSuppressButton {
	position: absolute;
	top: 0.25rem;
	left: 100%;
	margin-left: 0.375rem;
	margin-top: 0;
	z-index: 12;
}

.container > :not(.suppressButton) {
	order: 1;
}

.suppressButton:hover {
	color: var(--status-danger);
}

.blueskyMediaEngagement {
	display: inline-flex;
	flex-direction: column;
	align-items: flex-start;
	align-self: flex-start;
	width: fit-content;
	max-width: 100%;
}

.blueskyMediaEngagement .embedMedia {
	width: 100%;
	max-width: 100%;
}

.blueskyGalleryMedia {
	width: 100%;
}

.blueskyGalleryMedia .embedMedia {
	width: 100%;
}

.blueskyMediaEngagement .blueskyEngagement {
	width: 100%;
	box-sizing: border-box;
}

.blueskyNestedEmbedContainer {
	width: 100%;
	margin-top: 8px;
}

.blueskyNestedEmbed {
	--bluesky-nested-scale: 0.9;
	--bluesky-nested-avatar-size: calc(24px * var(--bluesky-nested-scale));
	--bluesky-nested-avatar-gap: calc(8px * var(--bluesky-nested-scale));
	width: 100%;
	border: 1px solid var(--background-modifier-accent);
	border-radius: 6px;
	background: transparent;
	box-shadow: none;
}

.blueskyNestedEmbed .grid {
	padding: calc(12px * var(--bluesky-nested-scale)) calc(12px * var(--bluesky-nested-scale))
		calc(14px * var(--bluesky-nested-scale)) calc(12px * var(--bluesky-nested-scale));
}

.blueskyNestedEmbed .embedContent {
	gap: calc(8px * var(--bluesky-nested-scale));
}

.blueskyNestedEmbed .embedContent > *:first-child {
	margin-top: calc(4px * var(--bluesky-nested-scale));
}

.blueskyNestedEmbed .embedProvider {
	font-size: calc(0.75rem * var(--bluesky-nested-scale));
	line-height: calc(1rem * var(--bluesky-nested-scale));
}

.blueskyNestedEmbed .embedAuthorName,
.blueskyNestedEmbed .embedAuthorNameLink {
	font-size: calc(0.875rem * var(--bluesky-nested-scale));
	line-height: calc(1.125rem * var(--bluesky-nested-scale));
}

.blueskyNestedEmbed .embedAuthorIcon {
	width: var(--bluesky-nested-avatar-size);
	height: var(--bluesky-nested-avatar-size);
	margin-right: var(--bluesky-nested-avatar-gap);
}

.blueskyNestedEmbed .embedDescription {
	font-size: calc(0.875rem * var(--bluesky-nested-scale));
	line-height: calc(1.125rem * var(--bluesky-nested-scale));
}

.blueskyNestedEmbed .embedMedia {
	margin-top: calc(4px * var(--bluesky-nested-scale));
}

.blueskyNestedMediaEngagement {
	width: 100%;
	max-width: 100%;
	align-items: stretch;
}

.blueskyNestedMediaEngagement .embedMedia {
	width: 100%;
}

.blueskyEngagement {
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
	gap: 8px 16px;
	border-top: 1px solid var(--background-modifier-hover);
	padding-top: 12px;
}

.blueskyEngagementItem {
	display: flex;
	align-items: center;
	gap: 4px;
	font-size: 0.875rem;
	line-height: 1.125rem;
	color: var(--text-tertiary);
}

.blueskyEngagementItem strong {
	color: var(--text-primary);
	font-weight: 600;
}
