/**
 * Card share menus — blog & service items
 *
 * @package Dentaura
 */

/* --------------------------------------------------------------------------
   Inline share — footer row next to "Read article" / card CTA
   -------------------------------------------------------------------------- */

.dentaura-post-card__footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	margin-block-start: auto;
}

.dentaura-share--inline {
	position: relative;
	display: inline-flex;
	align-items: center;
	flex-shrink: 0;
	pointer-events: auto;
}

.dentaura-share--inline .dentaura-share__trigger {
	width: 2rem;
	height: 2rem;
	border: 1px solid var(--dentaura-color-border, #e5e0d8);
	border-radius: 999px;
	background: var(--dentaura-color-surface, #fff);
	color: var(--dentaura-color-text-muted, #6b6b6b);
	box-shadow: var(--dentaura-shadow-sm, 0 1px 2px rgba(26, 26, 26, 0.04));
	backdrop-filter: none;
}

.dentaura-share--inline .dentaura-share__trigger:hover,
.dentaura-share--inline .dentaura-share__trigger:focus-visible {
	background: var(--dentaura-color-surface-muted, #efebe4);
	border-color: rgba(181, 154, 109, 0.35);
	color: var(--dentaura-color-text, #1a1a1a);
	transform: none;
}

.dentaura-share--inline .dentaura-share__menu {
	position: absolute;
	right: 0;
	bottom: calc(100% + 0.45rem);
	top: auto;
	flex-direction: column;
	align-items: stretch;
	gap: 0;
	min-width: 11.5rem;
	padding: 0.35rem;
	border-radius: 0.75rem;
	background: var(--dentaura-color-surface, #fff);
	border: 1px solid var(--dentaura-color-border, #e5e0d8);
	box-shadow: var(--dentaura-shadow-lg, 0 16px 48px rgba(26, 26, 26, 0.12));
	opacity: 0;
	visibility: hidden;
	transform: translateY(0.25rem);
	transform-origin: bottom right;
	transition:
		opacity 0.18s ease,
		visibility 0.18s ease,
		transform 0.18s ease;
	overflow: visible;
	max-width: none;
	z-index: 50;
}

.dentaura-share--inline .dentaura-share__item {
	display: flex;
	align-items: center;
	gap: 0.65rem;
	padding: 0.55rem 0.7rem;
	border: 0;
	border-radius: 0.5rem;
	background: transparent;
	color: var(--dentaura-color-text, #1a1a1a) !important;
	font-size: 0.875rem;
	font-weight: 500;
	line-height: 1.2;
	text-decoration: none !important;
	white-space: nowrap;
	transition: background 0.15s ease, color 0.15s ease;
}

.dentaura-share--inline .dentaura-share__item:hover,
.dentaura-share--inline .dentaura-share__item:focus-visible {
	background: var(--dentaura-color-surface-muted, #efebe4);
	color: var(--dentaura-color-text, #1a1a1a) !important;
	outline: none;
}

.dentaura-share--inline .dentaura-share__icon {
	width: 1.5rem;
	height: 1.5rem;
	border-radius: 0.4rem;
	background: var(--dentaura-color-surface-muted, #efebe4);
	color: inherit;
	flex-shrink: 0;
}

.dentaura-share--inline .dentaura-share__icon svg {
	width: 0.85rem;
	height: 0.85rem;
}

@media (hover: hover) and (pointer: fine) {
	.dentaura-share--inline:hover .dentaura-share__menu,
	.dentaura-share--inline.is-open .dentaura-share__menu,
	.dentaura-share--overlay:hover .dentaura-share__menu,
	.dentaura-share--overlay.is-open .dentaura-share__menu {
		opacity: 1;
		visibility: visible;
		transform: translateY(0);
	}

	.dentaura-share--inline.is-open .dentaura-share__trigger,
	.dentaura-share--overlay.is-open .dentaura-share__trigger {
		z-index: 1;
	}
}

/* --------------------------------------------------------------------------
   Overlay share — fallback on media (service cards without footer CTA)
   -------------------------------------------------------------------------- */

.dentaura-share--overlay {
	position: absolute;
	top: 0.75rem;
	right: 0.75rem;
	z-index: 4;
	display: flex;
	align-items: flex-start;
	justify-content: flex-end;
	gap: 0.45rem;
	max-width: calc(100% - 1.5rem);
	pointer-events: none;
}

.dentaura-share--overlay > * {
	pointer-events: auto;
}

.dentaura-share--overlay .dentaura-share__trigger {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.15rem;
	height: 2.15rem;
	padding: 0;
	border: 1px solid rgba(255, 255, 255, 0.22);
	border-radius: 999px;
	background: rgba(20, 20, 20, 0.72);
	color: #f5f5f5;
	cursor: pointer;
	backdrop-filter: blur(8px);
	box-shadow: 0 8px 22px rgba(20, 20, 20, 0.22);
	transition:
		background 0.2s ease,
		border-color 0.2s ease,
		transform 0.2s ease,
		box-shadow 0.2s ease;
}

.dentaura-share--overlay .dentaura-share__trigger svg {
	width: 1rem;
	height: 1rem;
}

.dentaura-share--overlay .dentaura-share__trigger:hover,
.dentaura-share--overlay .dentaura-share__trigger:focus-visible {
	background: rgba(20, 20, 20, 0.9);
	border-color: rgba(255, 255, 255, 0.35);
	transform: translateY(-1px);
	outline: none;
}

.dentaura-share--overlay .dentaura-share__menu {
	position: absolute;
	right: 0;
	top: calc(100% + 0.45rem);
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 0;
	min-width: 11.5rem;
	padding: 0.35rem;
	border-radius: 0.75rem;
	background: var(--dentaura-color-surface, #fff);
	border: 1px solid var(--dentaura-color-border, #e5e0d8);
	box-shadow: var(--dentaura-shadow-lg, 0 16px 48px rgba(26, 26, 26, 0.12));
	opacity: 0;
	visibility: hidden;
	transform: translateY(-0.25rem);
	transform-origin: top right;
	transition:
		opacity 0.18s ease,
		visibility 0.18s ease,
		transform 0.18s ease;
	z-index: 50;
}

.dentaura-share--overlay .dentaura-share__item {
	display: flex;
	align-items: center;
	gap: 0.65rem;
	padding: 0.55rem 0.7rem;
	border-radius: 0.5rem;
	background: transparent;
	color: var(--dentaura-color-text, #1a1a1a) !important;
	font-size: 0.875rem;
	font-weight: 500;
	line-height: 1.2;
	text-decoration: none !important;
	white-space: nowrap;
	transition: background 0.15s ease;
}

.dentaura-share--overlay .dentaura-share__item:hover,
.dentaura-share--overlay .dentaura-share__item:focus-visible {
	background: var(--dentaura-color-surface-muted, #efebe4);
	outline: none;
}

.dentaura-share--overlay .dentaura-share__icon {
	width: 1.5rem;
	height: 1.5rem;
	border-radius: 0.4rem;
	background: var(--dentaura-color-surface-muted, #efebe4);
	color: inherit;
}

.dentaura-share--overlay .dentaura-share__icon svg {
	width: 0.85rem;
	height: 0.85rem;
}

/* Shared trigger icon sizing */
.dentaura-share__trigger {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	cursor: pointer;
}

.dentaura-share__trigger svg {
	width: 1rem;
	height: 1rem;
}

.dentaura-share__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

/* Portaled menu — always on top of cards (escapes overflow + transform ancestors) */
.dentaura-share__menu--portaled {
	position: fixed;
	z-index: 99996;
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 0;
	min-width: 11.5rem;
	padding: 0.35rem;
	border-radius: 0.75rem;
	background: var(--dentaura-color-surface, #fff);
	border: 1px solid var(--dentaura-color-border, #e5e0d8);
	box-shadow: var(--dentaura-shadow-lg, 0 16px 48px rgba(26, 26, 26, 0.12));
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transform: none;
	transition:
		opacity 0.18s ease,
		visibility 0.18s ease;
}

.dentaura-share__menu--portaled.is-visible {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

.dentaura-share__menu--portaled .dentaura-share__item {
	display: flex;
	align-items: center;
	gap: 0.65rem;
	padding: 0.55rem 0.7rem;
	border-radius: 0.5rem;
	background: transparent;
	color: var(--dentaura-color-text, #1a1a1a) !important;
	font-size: 0.875rem;
	font-weight: 500;
	line-height: 1.2;
	text-decoration: none !important;
	white-space: nowrap;
	transition: background 0.15s ease;
}

.dentaura-share__menu--portaled .dentaura-share__item:hover,
.dentaura-share__menu--portaled .dentaura-share__item:focus-visible {
	background: var(--dentaura-color-surface-muted, #efebe4);
	outline: none;
}

.dentaura-share__menu--portaled .dentaura-share__icon {
	width: 1.5rem;
	height: 1.5rem;
	border-radius: 0.4rem;
	background: var(--dentaura-color-surface-muted, #efebe4);
	color: inherit;
	flex-shrink: 0;
}

.dentaura-share__menu--portaled .dentaura-share__icon svg {
	width: 0.85rem;
	height: 0.85rem;
}

/* Touch / coarse pointer — tap to toggle; menu stays anchored to the trigger via JS. */
@media (hover: none), (pointer: coarse) {
	.dentaura-share.is-open .dentaura-share__menu,
	.dentaura-share__menu--portaled.is-visible {
		opacity: 1;
		visibility: visible;
	}

	.dentaura-share__backdrop {
		position: fixed;
		inset: 0;
		z-index: 99994;
		border: 0;
		padding: 0;
		margin: 0;
		background: rgba(10, 10, 10, 0.28);
		cursor: default;
	}
}

/* Ensure media hosts can position overlay share */
.dentaura-post-card--journal .wp-block-post-featured-image,
.dentaura-post-card__media,
.dentaura-service-card .wp-block-post-featured-image,
.dentaura-services-explorer__media,
.dentaura-related-services .wp-block-post-featured-image {
	position: relative;
}

.dentaura-service-card,
.dentaura-home-service-card {
	position: relative;
}

.dentaura-services-explorer__footer .dentaura-post-card__footer {
	margin-block-start: 0;
	width: 100%;
	min-width: 0;
	flex-wrap: wrap;
	align-items: center;
}

.dentaura-services-explorer__footer .dentaura-post-card__footer .dentaura-services-explorer__cta {
	flex: 1 1 auto;
	width: auto;
	min-width: min-content;
	white-space: nowrap;
}

@media (max-width: 380px) {
	.dentaura-services-explorer__footer .dentaura-post-card__footer {
		flex-direction: column;
		align-items: stretch;
	}

	.dentaura-services-explorer__footer .dentaura-post-card__footer .dentaura-services-explorer__cta {
		width: 100%;
		justify-content: center;
	}

	.dentaura-services-explorer__footer .dentaura-share--inline {
		align-self: flex-start;
	}
}

.dentaura-home-service-card__footer {
	margin-block-start: 0.35rem;
}

.dentaura-home-service-card__footer .dentaura-home-service-card__cta {
	margin: 0;
}

/* Keep share menus visible above card overflow clipping */
.dentaura-post-card--journal:has(.dentaura-share:hover),
.dentaura-post-card--journal:has(.dentaura-share:focus-within),
.dentaura-post-card--journal:has(.dentaura-share.is-open),
.dentaura-service-card:has(.dentaura-share:hover),
.dentaura-service-card:has(.dentaura-share:focus-within),
.dentaura-service-card:has(.dentaura-share.is-open),
.dentaura-home-service-card:has(.dentaura-share:hover),
.dentaura-home-service-card:has(.dentaura-share:focus-within),
.dentaura-home-service-card:has(.dentaura-share.is-open),
.dentaura-post-grid > li:has(.dentaura-share:hover),
.dentaura-post-grid > li:has(.dentaura-share:focus-within),
.dentaura-post-grid > li:has(.dentaura-share.is-open) {
	overflow: visible;
	z-index: 4;
}

.dentaura-post-card--journal:has(.dentaura-share:hover),
.dentaura-post-card--journal:has(.dentaura-share:focus-within),
.dentaura-post-card--journal:has(.dentaura-share.is-open) {
	overflow: visible;
}

.dentaura-share.is-open .dentaura-share__menu,
.dentaura-share:focus-within .dentaura-share__menu {
	z-index: 99996;
}

@media (prefers-reduced-motion: reduce) {
	.dentaura-share__menu,
	.dentaura-share__trigger,
	.dentaura-share__item {
		transition: none;
	}
}
