/**
 * plugins/blocks/scholarCitations/styles/block.css
 *
 * Distributed under the GNU GPL v3. For full terms see the file LICENSE.
 *
 * The Scholar Citations block. The accent colour comes from the theme:
 * a theme variable when there is one, otherwise the colour js/block.js
 * reads from the page (the header or the links).
 */

.block_scholar_citations {
	--gsc-accent: var(--lk-primary, var(--color-primary, var(--primary-color, #1e6292)));
	/* For text and icons: the theme's readable version when it has one (dark mode) */
	--gsc-accent-text: var(--lk-primary-text, var(--gsc-accent));
	--gsc-text: currentColor;
	--gsc-muted: color-mix(in srgb, currentColor 76%, transparent);
	--gsc-line: color-mix(in srgb, currentColor 14%, transparent);
	--gsc-track: color-mix(in srgb, currentColor 6%, transparent);
}

.block_scholar_citations .content {
	font-size: 0.875rem;
	line-height: 1.4;
}

.block_scholar_citations .gsc_name {
	margin: 0 0 0.5rem;
	font-weight: 600;
}

/* Read by screen readers only */
.block_scholar_citations .gsc_sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* Figures */
.block_scholar_citations .gsc_table {
	width: 100%;
	border-collapse: collapse;
	margin: 0 0 0.75rem;
	font-variant-numeric: tabular-nums;
}

.block_scholar_citations .gsc_table th,
.block_scholar_citations .gsc_table td {
	padding: 0.45rem 0.25rem;
	border-bottom: 1px solid var(--gsc-line);
	text-align: end;
	vertical-align: middle;
	white-space: nowrap;
}

.block_scholar_citations .gsc_table thead th {
	padding-top: 0;
	font-size: 0.75rem;
	font-weight: 600;
	color: var(--gsc-muted);
	text-transform: none;
}

.block_scholar_citations .gsc_table tbody th {
	text-align: start;
	font-weight: 500;
	/* "i10-index" must not break at its hyphen */
	white-space: nowrap;
	width: 100%;
}

.block_scholar_citations .gsc_table td {
	font-weight: 700;
	font-size: 0.95rem;
}

.block_scholar_citations .gsc_table tbody tr:last-child > * {
	border-bottom: 0;
}

.block_scholar_citations .gsc_icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 1.5rem;
	height: 1.5rem;
	margin-inline-end: 0.35rem;
	border-radius: 0.4rem;
	color: var(--gsc-accent-text);
	background: color-mix(in srgb, var(--gsc-accent-text) 14%, transparent);
	vertical-align: middle;
}

.block_scholar_citations .gsc_icon svg {
	display: block;
	width: 0.95rem;
	height: 0.95rem;
}

/* Citations per year */
.block_scholar_citations .gsc_chart {
	margin: 0 0 0.75rem;
	padding: 0;
}

.block_scholar_citations .gsc_chart figcaption {
	margin: 0 0 0.5rem;
	font-size: 0.75rem;
	font-weight: 600;
	color: var(--gsc-muted);
}

.block_scholar_citations .gsc_bars {
	display: grid;
	grid-template-columns: repeat(var(--gsc-count, 6), minmax(0, 1fr));
	gap: 0.35rem;
	align-items: end;
	margin: 0;
	padding: 1.4rem 0 0;
	list-style: none;
	border-bottom: 1px solid var(--gsc-line);
}

.block_scholar_citations .gsc_bar {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	margin: 0;
	padding: 0;
}

.block_scholar_citations .gsc_bars:focus {
	outline: none;
}

.block_scholar_citations .gsc_bars:focus-visible {
	outline: 2px solid var(--gsc-accent-text);
	outline-offset: 4px;
	border-radius: 0.3rem;
}

.block_scholar_citations .gsc_bar_track {
	position: relative;
	display: flex;
	align-items: flex-end;
	height: 6.5rem;
	border-radius: 0.45rem 0.45rem 0 0;
	background: var(--gsc-track);
}

.block_scholar_citations .gsc_bar_fill {
	position: relative;
	display: block;
	width: 100%;
	height: var(--h, 0%);
	min-height: 0;
	border-radius: 0.45rem 0.45rem 0 0;
	background: linear-gradient(180deg,
		color-mix(in srgb, var(--gsc-accent) 72%, white) 0%,
		var(--gsc-accent) 100%);
	box-shadow: 0 0 0 0 transparent;
	transform-origin: bottom;
	transition: translate 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
	animation: gsc-grow 0.6s ease-out both;
}

.block_scholar_citations .gsc_bar_value {
	position: absolute;
	bottom: calc(100% + 0.2rem);
	left: 50%;
	transform: translate(-50%, 0.25rem);
	padding: 0.1rem 0.3rem;
	border-radius: 0.3rem;
	font-size: 0.7rem;
	font-weight: 700;
	line-height: 1.2;
	white-space: nowrap;
	color: #fff;
	background: color-mix(in srgb, var(--gsc-accent) 85%, black);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.15s ease, transform 0.15s ease;
	z-index: 1;
}

.block_scholar_citations .gsc_bar:hover .gsc_bar_fill {
	/* translate, not transform: the grow animation keeps transform */
	translate: 0 -3px;
	box-shadow: 0 6px 12px -6px color-mix(in srgb, var(--gsc-accent) 70%, transparent);
	filter: saturate(1.15);
}

.block_scholar_citations .gsc_bar:hover .gsc_bar_value,
.block_scholar_citations .gsc_bars:focus-visible .gsc_bar_value {
	opacity: 1;
	transform: translate(-50%, 0);
}

/* No hover on touch screens: the values are always shown */
@media (hover: none) {
	.block_scholar_citations .gsc_bar_value {
		opacity: 1;
		transform: translate(-50%, 0);
		color: inherit;
		background: none;
		padding: 0;
		font-size: 0.65rem;
	}
}

.block_scholar_citations .gsc_bar_empty .gsc_bar_value {
	color: inherit;
	background: none;
}

.block_scholar_citations .gsc_bar_year {
	margin-top: 0.3rem;
	font-size: 0.7rem;
	text-align: center;
	color: var(--gsc-muted);
	font-variant-numeric: tabular-nums;
}

@keyframes gsc-grow {
	from { transform: scaleY(0); }
	to { transform: scaleY(1); }
}

@media (prefers-reduced-motion: reduce) {
	.block_scholar_citations .gsc_bar_fill,
	.block_scholar_citations .gsc_bar_value {
		animation: none;
		transition: none;
	}
	.block_scholar_citations .gsc_bar:hover .gsc_bar_fill {
		translate: none;
	}
}

/* Footer */
.block_scholar_citations .gsc_footer {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 0.25rem 0.75rem;
	margin: 0;
	font-size: 0.75rem;
}

.block_scholar_citations .gsc_footer a {
	color: var(--gsc-accent-text);
	font-weight: 600;
}

.block_scholar_citations .gsc_updated {
	color: var(--gsc-muted);
}

/* Browsers without color-mix */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
	.block_scholar_citations {
		--gsc-muted: inherit;
		--gsc-line: rgba(128, 128, 128, 0.25);
		--gsc-track: rgba(128, 128, 128, 0.08);
	}
	.block_scholar_citations .gsc_icon {
		background: rgba(128, 128, 128, 0.12);
	}
	.block_scholar_citations .gsc_bar_fill {
		background: var(--gsc-accent);
	}
	.block_scholar_citations .gsc_bar_value {
		background: #333;
	}
}
