/**
 * News blocks: thumbnails, the featured photo's caption, the previous/next cards,
 * and the share buttons with the card a post makes when shared.
 *
 * Colors, sizes and the card shadow come from the theme's presets, with
 * fallbacks for other themes. How the thumbnail sits beside a list item is up
 * to the theme.
 */

/* Thumbnail: a 3:2 tile the image fills, cropped. */
.ivosea-news-thumb {
	display: block;
	aspect-ratio: 3 / 2;
	overflow: hidden;
	border-radius: 6px;
	background-color: var(--wp--preset--color--surface, #f1f5f9);
}

.ivosea-news-thumb__img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* No image: whatever the theme puts on the tile (its logo), centered. */
.ivosea-news-thumb.is-placeholder {
	display: grid;
	place-items: center;
}

.wp-block-ivosea-news-thumbnail a {
	display: block;
}

/* Featured photo: caption, then the date taken on its own line. */
.ivosea-featured-photo .wp-block-image {
	margin-block: 0;
}

.ivosea-featured-photo .wp-block-image img {
	width: 100%;
}

.ivosea-featured-photo__caption,
.ivosea-featured-photo__date {
	display: block;
}

.ivosea-featured-photo__caption + .ivosea-featured-photo__date {
	margin-top: 0.25em;
}

.ivosea-featured-photo__date {
	color: var(--wp--preset--color--muted, #475569);
	font-style: italic;
}

/* Previous and next posts: two cards side by side, one above the other on phones. */
.ivosea-post-nav {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--wp--preset--spacing--40, 1.5rem);
}

/* The next post stays on the right when there's no previous one. */
.ivosea-post-nav__card.is-next {
	grid-column: 2;
}

@media (max-width: 599px) {
	.ivosea-post-nav {
		grid-template-columns: minmax(0, 1fr);
	}

	.ivosea-post-nav__card.is-next {
		grid-column: auto;
	}
}

.ivosea-post-nav__card {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	padding: var(--wp--preset--spacing--30, 1rem);
	border: 1px solid var(--wp--preset--color--border, #cbd5e1);
	border-radius: 8px;
	background-color: var(--wp--preset--color--base, #fff);
	box-shadow: var(--wp--preset--shadow--card, none);
	font-family: var(--wp--preset--font-family--body, inherit);
	font-size: var(--wp--preset--font-size--small, 0.875rem);
	transition: border-color 0.15s ease;
}

.ivosea-post-nav__card:hover {
	border-color: var(--wp--preset--color--primary, #1d4ed8);
}

.ivosea-post-nav__card p {
	margin: 0;
}

.ivosea-post-nav__label {
	color: var(--wp--preset--color--muted, #475569);
	font-size: var(--wp--preset--font-size--x-small, 0.75rem);
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.ivosea-post-nav__title {
	font-family: var(--wp--preset--font-family--heading, inherit);
	font-size: var(--wp--preset--font-size--medium, 1.125rem);
	font-weight: 700;
	line-height: 1.3;
}

.ivosea-post-nav__title a {
	color: var(--wp--preset--color--primary-dark, #1e3a8a);
	text-decoration: none;
}

/* The title link covers the whole card. */
.ivosea-post-nav__title a::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
}

.ivosea-post-nav__card:hover .ivosea-post-nav__title a {
	text-decoration: underline;
}

/* The keyboard focus ring goes around the card, not just the title. */
.ivosea-post-nav__title a:focus-visible {
	outline: none;
	box-shadow: none;
}

.ivosea-post-nav__card:has(.ivosea-post-nav__title a:focus-visible) {
	outline: 3px solid var(--wp--preset--color--highlight, #f59e0b);
	outline-offset: 2px;
	box-shadow: 0 0 0 5px var(--wp--preset--color--primary-dark, #1e3a8a);
}

.ivosea-post-nav__meta {
	color: var(--wp--preset--color--muted, #475569);
}

.ivosea-post-nav__writers::before {
	content: "·";
	margin-inline: 0.4em;
}

.ivosea-post-nav__excerpt {
	color: var(--wp--preset--color--contrast, #1e293b);
}

/*
 * Share buttons (blocks/share, #172): round icon buttons in a row under the
 * byline. Once the reader scrolls past them (assets/share.js adds
 * .is-floating) they float: in a column beside the text on wide screens, in a
 * bar along the bottom on narrower ones.
 */
.ivosea-share {
	--ivosea-share-size: 2.5rem;
	font-family: var(--wp--preset--font-family--body, inherit);
}

.ivosea-share__bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 0.75rem;
}

.ivosea-share__label {
	margin: 0;
	color: var(--wp--preset--color--muted, #475569);
	font-size: var(--wp--preset--font-size--x-small, 0.75rem);
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.ivosea-share__list {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.ivosea-share__item {
	position: relative;
	margin: 0;
}

.ivosea-share__item[hidden] {
	display: none !important;
}

/* Messenger and Viber open their apps: on touch screens only. */
@media (hover: hover) and (pointer: fine) {
	.ivosea-share__item.is-app {
		display: none;
	}
}

.ivosea-share__button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	box-sizing: border-box;
	min-width: var(--ivosea-share-size);
	height: var(--ivosea-share-size);
	margin: 0;
	padding: 0;
	border: 1px solid var(--wp--preset--color--border, #cbd5e1);
	border-radius: 999px;
	background-color: var(--wp--preset--color--base, #fff);
	color: var(--wp--preset--color--primary-dark, #1e3a8a);
	font: inherit;
	font-size: var(--wp--preset--font-size--small, 0.875rem);
	font-weight: 600;
	line-height: 1;
	text-decoration: none;
	cursor: pointer;
	transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.ivosea-share__button:hover {
	border-color: var(--wp--preset--color--primary, #1d4ed8);
	background-color: var(--wp--preset--color--primary, #1d4ed8);
	color: var(--wp--preset--color--base, #fff);
}

.ivosea-share__button:focus-visible,
.ivosea-share__close:focus-visible {
	outline: 3px solid var(--wp--preset--color--highlight, #f59e0b);
	outline-offset: 2px;
	box-shadow: 0 0 0 5px var(--wp--preset--color--primary-dark, #1e3a8a);
}

.ivosea-share__icon {
	flex: none;
	width: 1.25rem;
	height: 1.25rem;
	fill: currentColor;
}

/*
 * The button's name: for screen readers only, shown as a tooltip above the
 * button on hover and keyboard focus.
 */
.ivosea-share__text {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

.ivosea-share__bar .ivosea-share__button:focus-visible .ivosea-share__text,
.ivosea-share__bar .ivosea-share__button:hover .ivosea-share__text {
	bottom: calc(100% + 0.5rem);
	left: 50%;
	z-index: 2;
	width: auto;
	height: auto;
	padding: 0.35rem 0.6rem;
	border-radius: 4px;
	background-color: var(--wp--preset--color--night, #0f172a);
	color: var(--wp--preset--color--base, #fff);
	font-size: var(--wp--preset--font-size--x-small, 0.75rem);
	font-weight: 600;
	clip-path: none;
	transform: translateX(-50%);
	pointer-events: none;
}

/* "Link copied": a short message near the bottom of the screen. */
.ivosea-share__status {
	position: fixed;
	bottom: calc(5rem + env(safe-area-inset-bottom, 0px));
	left: 50%;
	z-index: 1001;
	margin: 0;
	padding: 0.6rem 1rem;
	border-radius: 6px;
	background-color: var(--wp--preset--color--night, #0f172a);
	color: var(--wp--preset--color--base, #fff);
	font-size: var(--wp--preset--font-size--small, 0.875rem);
	transform: translateX(-50%);
	opacity: 0;
	pointer-events: none;
}

.ivosea-share__status.is-shown {
	opacity: 1;
}

/* Floating: the bar leaves the post (its place is kept) and stays in view. */
.ivosea-share.is-floating .ivosea-share__bar {
	position: fixed;
	z-index: 1000;
	box-sizing: border-box;
	border: 1px solid var(--wp--preset--color--border, #cbd5e1);
	background-color: var(--wp--preset--color--base, #fff);
	box-shadow: 0 4px 16px rgb(15 23 42 / 12%);
}

/* The label still names the bar for screen readers (aria-labelledby). */
.ivosea-share.is-floating .ivosea-share__label {
	display: none;
}

/* Wide screens: a column in the margin left of the 800px text. */
@media (min-width: 1024px) {
	.ivosea-share.is-floating .ivosea-share__bar {
		top: 50%;
		left: max(0.75rem, calc(50vw - 400px - var(--ivosea-share-size) - 2.5rem));
		padding: 0.5rem;
		border-radius: 999px;
		transform: translateY(-50%);
	}

	.ivosea-share.is-floating .ivosea-share__bar .ivosea-share__list {
		flex-direction: column;
	}

	/* In the column, the tooltip goes to the right of the button. */
	.ivosea-share.is-floating .ivosea-share__bar .ivosea-share__button:focus-visible .ivosea-share__text,
	.ivosea-share.is-floating .ivosea-share__bar .ivosea-share__button:hover .ivosea-share__text {
		top: 50%;
		bottom: auto;
		left: calc(100% + 0.6rem);
		transform: translateY(-50%);
	}
}

/* Narrower screens: a bar along the bottom, with the buttons that fit. */
@media (max-width: 1023px) {
	.ivosea-share.is-floating .ivosea-share__bar {
		right: 0;
		bottom: 0;
		left: 0;
		justify-content: center;
		padding: 0.5rem 1rem calc(0.5rem + env(safe-area-inset-bottom, 0px));
		border-width: 1px 0 0;
	}

	.ivosea-share.is-floating .ivosea-share__bar .ivosea-share__list {
		flex-wrap: nowrap;
		justify-content: center;
	}

	/* X and email are still in the row under the byline, and under More ways to share. */
	.ivosea-share.is-floating .ivosea-share__bar .ivosea-share__item:is(.is-x, .is-email) {
		display: none;
	}
}

@media (prefers-reduced-motion: no-preference) {
	.ivosea-share.is-floating .ivosea-share__bar {
		animation: ivosea-share-in 0.2s ease-out;
	}

	.ivosea-share__status {
		transition: opacity 0.2s ease;
	}
}

@keyframes ivosea-share-in {
	from {
		opacity: 0;
	}
}

/* Preview dialog. */
.ivosea-share__dialog {
	box-sizing: border-box;
	width: calc(100% - 2rem);
	max-width: 34rem;
	max-height: calc(100% - 2rem);
	padding: var(--wp--preset--spacing--40, 1.5rem);
	border: 0;
	border-radius: 12px;
	background-color: var(--wp--preset--color--base, #fff);
	color: var(--wp--preset--color--contrast, #1e293b);
	font-family: var(--wp--preset--font-family--body, inherit);
	box-shadow: 0 16px 48px rgb(15 23 42 / 30%);
}

.ivosea-share__dialog::backdrop {
	background-color: rgb(15 23 42 / 60%);
}

.ivosea-share__dialog-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 1rem;
	margin-bottom: 1rem;
}

.ivosea-share__dialog-title {
	margin: 0;
	font-family: var(--wp--preset--font-family--heading, inherit);
	font-size: var(--wp--preset--font-size--medium, 1.125rem);
	line-height: 1.3;
}

.ivosea-share__close {
	flex: none;
	width: 2.25rem;
	height: 2.25rem;
	margin: -0.25rem -0.25rem 0 0;
	padding: 0;
	border: 0;
	border-radius: 999px;
	background: none;
	color: var(--wp--preset--color--muted, #475569);
	font-size: 1.75rem;
	line-height: 1;
	cursor: pointer;
}

.ivosea-share__close:hover {
	background-color: var(--wp--preset--color--surface, #f1f5f9);
	color: var(--wp--preset--color--contrast, #1e293b);
}

.ivosea-share__note {
	margin: 0.75rem 0 1rem;
	color: var(--wp--preset--color--muted, #475569);
	font-size: var(--wp--preset--font-size--small, 0.875rem);
}

/* In the dialog the buttons show their names. */
.ivosea-share__list.is-dialog .ivosea-share__button {
	padding-inline: 0.9rem;
}

.ivosea-share__list.is-dialog .ivosea-share__text {
	position: static;
	width: auto;
	height: auto;
	overflow: visible;
	clip-path: none;
}

.ivosea-share__dialog .ivosea-share__status {
	position: static;
	margin-top: 0.75rem;
	padding: 0;
	background: none;
	color: var(--wp--preset--color--muted, #475569);
	transform: none;
}

/*
 * The card a post makes on Facebook and Messenger, in the dialog and in the
 * editor's Share preview panel: the photo, wide, then the domain, title and
 * summary. With the default image instead of a photo, a small square beside the text.
 */
.ivosea-share-card {
	overflow: hidden;
	border: 1px solid var(--wp--preset--color--border, #cbd5e1);
	border-radius: 8px;
	background-color: var(--wp--preset--color--surface, #f1f5f9);
}

.ivosea-share-card__image {
	display: block;
	width: 100%;
	aspect-ratio: 1.91 / 1;
	object-fit: cover;
	background-color: var(--wp--preset--color--border, #cbd5e1);
}

.ivosea-share-card.is-small {
	display: flex;
}

.ivosea-share-card.is-small .ivosea-share-card__image {
	flex: none;
	box-sizing: border-box;
	width: 6.5rem;
	padding: 0.5rem;
	aspect-ratio: 1;
	object-fit: contain;
	background-color: var(--wp--preset--color--base, #fff);
}

.ivosea-share-card__body {
	min-width: 0;
	padding: 0.6rem 0.75rem 0.75rem;
}

.ivosea-share-card__body p {
	margin: 0;
}

.ivosea-share-card__domain {
	overflow: hidden;
	color: var(--wp--preset--color--muted, #475569);
	font-size: var(--wp--preset--font-size--x-small, 0.75rem);
	text-overflow: ellipsis;
	text-transform: uppercase;
	white-space: nowrap;
}

.ivosea-share-card__title,
.ivosea-share-card__summary {
	display: -webkit-box;
	overflow: hidden;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
}

.ivosea-share-card__body .ivosea-share-card__title {
	margin-top: 0.15rem;
	color: var(--wp--preset--color--contrast, #1e293b);
	font-size: 1rem;
	font-weight: 700;
	line-height: 1.3;
}

.ivosea-share-card__body .ivosea-share-card__summary {
	margin-top: 0.2rem;
	color: var(--wp--preset--color--muted, #475569);
	font-size: var(--wp--preset--font-size--small, 0.875rem);
	line-height: 1.4;
}
