/* ==========================================================================
   UGS Link — general-purpose link card. Two layouts (Full Image,
   Condensed / Bar) sharing the same standard widget width, frame
   color/glass treatment, and share popup.
   ========================================================================== */

.ugs-link-card {
	position: relative;
	max-width: var(--ugs-widget-max-width, 420px);
	margin: 0 auto;
	font-family: inherit;

	--ugs-link-frame-color: #111111;
	--ugs-link-frame-alpha: 0.45;
	--ugs-link-frame-thickness: 10px;
	--ugs-link-bar-height: 76px;
	--ugs-link-radius: 18px;
}

.ugs-link-card * {
	box-sizing: border-box;
}

.ugs-link-hit {
	display: block;
	position: relative;
	color: inherit;
	text-decoration: none;
	border-radius: var(--ugs-link-radius);
	overflow: hidden;
}

.ugs-link-image {
	display: block;
	width: 100%;
	background-color: #1a1a1a;
}

.ugs-link-image-empty {
	aspect-ratio: 4 / 5;
	background: linear-gradient(135deg, #2a2a2a, #141414);
}

/* Frame: a ring-shaped mat sitting on top of the image — thin on the
   top/left/right, thicker on the bottom for the title/link text. Its
   middle is masked out (content-box cut from border-box) so the window
   it leaves over the image picks up the SAME rounded curvature as the
   card's own outer corners, instead of a sharp inner corner. Color and
   glass/blur come from the same two custom properties the "Frame Style"
   control writes (solid = alpha 1, glass = alpha 0.45), reusing the exact
   alpha-driven blur formula from the Music Link popup: at alpha 1 the
   blur amount is 0 (solid), at 0.45 it's ~11px (frosted). */
.ugs-link-frame {
	position: absolute;
	inset: 0;
	box-sizing: border-box;
	padding: var(--ugs-link-frame-thickness) var(--ugs-link-frame-thickness) var(--ugs-link-bar-height) var(--ugs-link-frame-thickness);
	border-radius: var(--ugs-link-radius);
	background-color: color-mix(in srgb, var(--ugs-link-frame-color) calc(var(--ugs-link-frame-alpha) * 100%), transparent);
	background-image: var(--ugs-glass-noise);
	background-blend-mode: overlay;
	backdrop-filter: blur(calc((1 - var(--ugs-link-frame-alpha)) * 20px));
	-webkit-backdrop-filter: blur(calc((1 - var(--ugs-link-frame-alpha)) * 20px));
	/* The bevel and mask both need to render on this same ring, and mask
	   only clips the element's own painted content (background/box-shadow
	   included) — so the inset bevel shows up correctly confined to the
	   ring shape, not just the rectangular box. */
	box-shadow: var(--ugs-glass-bevel);
	-webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
	-webkit-mask-composite: xor;
	mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
	mask-composite: exclude;
	pointer-events: none;
}

.ugs-link-bar {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	height: var(--ugs-link-bar-height);
	display: flex;
	align-items: center;
	padding: 0 60px 0 18px;
	box-sizing: border-box;
	pointer-events: none;
}

.ugs-link-text {
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 0;
}

.ugs-link-title {
	font-weight: 600;
	font-size: 18px;
	letter-spacing: 0.01em;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.ugs-link-subtitle {
	font-size: 12px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* ---------- Full Image layout ---------- */

.ugs-link-layout-full.ugs-link-height-auto .ugs-link-image {
	height: auto;
}

.ugs-link-layout-full.ugs-link-height-fixed .ugs-link-hit {
	height: 460px; /* overridden per-instance by the Fixed Height control */
}

.ugs-link-layout-full.ugs-link-height-fixed .ugs-link-image {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.ugs-link-layout-full .ugs-link-image-empty {
	width: 100%;
	height: 100%;
	min-height: 240px;
}

/* ---------- Condensed / Bar layout ---------- */

.ugs-link-layout-condensed .ugs-link-hit {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 8px 54px 8px 8px;
	background-color: color-mix(in srgb, var(--ugs-link-frame-color) calc(var(--ugs-link-frame-alpha) * 100%), transparent);
	background-image: var(--ugs-glass-noise);
	background-blend-mode: overlay;
	backdrop-filter: blur(calc((1 - var(--ugs-link-frame-alpha)) * 20px));
	-webkit-backdrop-filter: blur(calc((1 - var(--ugs-link-frame-alpha)) * 20px));
	box-shadow: var(--ugs-glass-bevel);
	border: var(--ugs-glass-rim);
}

.ugs-link-layout-condensed .ugs-link-image {
	width: 64px;
	height: 64px;
	flex-shrink: 0;
	border-radius: calc(var(--ugs-link-radius) * 0.55);
	object-fit: cover;
}

.ugs-link-layout-condensed .ugs-link-image-empty {
	aspect-ratio: auto;
}

.ugs-link-layout-condensed .ugs-link-frame {
	display: none;
}

.ugs-link-layout-condensed .ugs-link-bar {
	position: static;
	height: auto;
	flex: 1 1 auto;
	padding: 0;
}

.ugs-link-layout-condensed .ugs-link-title {
	font-size: 16px;
}

.ugs-link-layout-condensed .ugs-link-subtitle {
	font-size: 11.5px;
}

/* ---------- Share button ---------- */

.ugs-link-share-btn {
	position: absolute;
	z-index: 3;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: rgba(255,255,255,0.14);
	border: 1px solid rgba(255,255,255,0.22);
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	cursor: pointer;
	padding: 0;
}

.ugs-link-layout-full .ugs-link-share-btn {
	right: 18px;
	bottom: calc((var(--ugs-link-bar-height) - 40px) / 2);
}

.ugs-link-layout-condensed .ugs-link-share-btn {
	right: 10px;
	top: 50%;
	transform: translateY(-50%);
	width: 34px;
	height: 34px;
}

/* ---------- Share popup ---------- */
/* Same open/close mechanics and containing-block handling as Music Link's
   popup (see link-widget.js) — a separate class namespace so the two
   widgets' popups never collide if both are on the same page. */

.ugs-link-popup {
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,0);
	display: none;
	align-items: center;
	justify-content: center;
	z-index: 99999;
	padding: 20px;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.32s ease, background-color 0.32s ease;
}

.ugs-link-popup.ugs-link-popup-open {
	background: rgba(0,0,0,0.6);
	opacity: 1;
	pointer-events: auto;
}

.ugs-link-popup-inner {
	--ugs-link-popup-bg: #111111;
	--ugs-link-popup-alpha: 1;
	position: relative;
	background-color: color-mix(in srgb, var(--ugs-link-popup-bg) calc(var(--ugs-link-popup-alpha) * 100%), transparent);
	background-image: var(--ugs-glass-noise);
	background-blend-mode: overlay;
	backdrop-filter: blur(calc((1 - var(--ugs-link-popup-alpha)) * 20px));
	-webkit-backdrop-filter: blur(calc((1 - var(--ugs-link-popup-alpha)) * 20px));
	border: var(--ugs-glass-rim);
	color: #fff;
	max-width: min(92vw, clamp(320px, 40vw, 420px));
	width: 100%;
	max-height: 85vh;
	overflow-y: auto;
	border-radius: 16px;
	padding: 24px 20px 20px;
	text-align: center;
	box-shadow: 0 24px 60px rgba(0,0,0,0.45), var(--ugs-glass-bevel);
	transform: translateY(20px) scale(0.96);
	opacity: 0;
	transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.28s ease;
}

.ugs-link-popup.ugs-link-popup-open .ugs-link-popup-inner {
	transform: translateY(0) scale(1);
	opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
	.ugs-link-popup,
	.ugs-link-popup-inner {
		transition-duration: 0.01ms !important;
	}
}

.ugs-link-popup-close {
	position: absolute;
	top: 12px;
	right: 12px;
	background-color: color-mix(in srgb, color-mix(in srgb, var(--ugs-link-popup-bg) 80%, white 20%) calc(var(--ugs-link-popup-alpha) * 100%), transparent);
	background-image: var(--ugs-glass-noise);
	background-blend-mode: overlay;
	border: var(--ugs-glass-rim);
	box-shadow: var(--ugs-glass-bevel);
	color: #fff;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
}

.ugs-link-share-preview {
	display: flex;
	align-items: center;
	gap: 12px;
	text-align: left;
	background-color: color-mix(in srgb, color-mix(in srgb, var(--ugs-link-popup-bg) 80%, white 20%) calc(var(--ugs-link-popup-alpha) * 100%), transparent);
	background-image: var(--ugs-glass-noise);
	background-blend-mode: overlay;
	border: var(--ugs-glass-rim);
	box-shadow: var(--ugs-glass-bevel);
	border-radius: 12px;
	padding: 10px;
	margin: 8px 0 18px;
}

.ugs-link-share-preview-art {
	width: 48px;
	height: 48px;
	border-radius: 8px;
	object-fit: cover;
	flex-shrink: 0;
}

.ugs-link-share-preview-text {
	min-width: 0;
}

.ugs-link-share-preview-title {
	font-weight: 600;
	font-size: 14px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.ugs-link-share-preview-url {
	font-size: 12px;
	opacity: 0.6;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.ugs-link-share-grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 18px 8px;
}

.ugs-link-share-opt {
	background: none;
	border: none;
	color: inherit;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	cursor: pointer;
	font-family: inherit;
}

.ugs-link-share-icon {
	width: 44px;
	height: 44px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
}

.ugs-link-share-icon-custom img,
.ugs-link-share-icon-custom svg {
	width: 24px;
	height: 24px;
}

/* Most uploaded/Icon-Library SVGs ship with no fill attribute at all and
   are meant to inherit color from context — without this, the SVG spec's
   black fill default wins regardless of the Icon Glyph Color control. Only
   affects paths that don't already hardcode their own fill, so a genuinely
   multi-color uploaded logo keeps its own colors. */
.ugs-link-share-icon-custom svg {
	fill: currentColor;
}

.ugs-link-share-label {
	font-size: 11px;
	opacity: 0.85;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 100%;
}

@media (max-width: 480px), (orientation: portrait) and (max-width: 600px) {
	.ugs-link-popup-inner {
		max-width: min(90vw, 400px);
		padding: 22px 16px 18px;
	}

	.ugs-link-share-grid {
		gap: 14px 4px;
	}

	.ugs-link-share-icon {
		width: 40px;
		height: 40px;
	}
}
