@import "../../common";

.ub-block-post-grid {
	&.is-equal-height {
		.ub-post-grid-items {
			align-items: stretch;
		}
	}
	margin: 0 0 1.2em 0;
	position: relative;
	&.preserve-post-image-aspect-ratio {
		.ub-post-grid-items {
			article {
				.ub-block-post-grid-image {
					img {
						height: auto;
					}
				}
			}
		}
	}
	.ub-post-grid-items {
		align-items: flex-start;
		article {
			overflow: hidden;
			background: var(--ub-post-grid-post-background);
			&:hover {
				background: var(
					--ub-post-grid-post-hover-background,
					var(--ub-post-grid-post-background)
				);
			}
			.ub-block-post-grid-image {
				img {
					border-top-left-radius: var(--ub-post-grid-image-top-left-radius);
					border-top-right-radius: var(--ub-post-grid-image-top-right-radius);
					border-bottom-left-radius: var(
						--ub-post-grid-image-bottom-left-radius
					);
					border-bottom-right-radius: var(
						--ub-post-grid-image-bottom-right-radius
					);
				}
			}
		}
	}
	.is-grid {
		display: grid;
		grid-template-columns: 1fr 1fr;
		grid-template-rows: 1fr;
		@media all and (-ms-high-contrast: none) {
			display: block;
		}
		article {
			min-width: 0;
			@media all and (-ms-high-contrast: none) {
				padding-left: 10px;
				padding-right: 10px;
				display: inline-block;
				vertical-align: top;
			}
		}
		&.columns-1 {
			grid-template-columns: 1fr;
			@media all and (-ms-high-contrast: none) {
				article {
					width: 100%;
				}
			}
		}
		&.columns-2 {
			grid-template-columns: 1fr 1fr;
			@media all and (-ms-high-contrast: none) {
				article {
					width: 48%;
				}
			}
		}
		&.columns-3 {
			grid-template-columns: 1fr 1fr 1fr;
			@media all and (-ms-high-contrast: none) {
				article {
					width: 32%;
				}
			}
		}
	}
	div[class*="columns"].is-grid {
		@media only screen and (max-width: 600px) {
			grid-template-columns: 1fr;
		}
	}
	.ub-block-post-grid-text {
		text-align: left;
	}
	a {
		text-decoration: none;
	}
	.ub-block-post-grid-image {
		margin-bottom: 1.2em;
		img {
			display: block;
			width: 100%;
		}
	}
	header .ub-block-post-grid-title {
		margin-top: 0;
		margin-bottom: 15px;
		line-height: 1.2;
		a {
			color: var(--ub-post-grid-title-color, #292929);
			text-decoration: none;
			&:hover {
				text-decoration: underline;
				color: var(
					--ub-post-grid-title-hover-color,
					var(--ub-post-grid-title-color, inherit)
				);
			}
		}
	}
	.ub-block-post-grid-date {
		color: var(--ub-post-grid-date-color);
		&:hover {
			color: var(
				--ub-post-grid-date-hover-color,
				var(--ub-post-grid-date-color)
			);
		}
	}
	.ub-block-post-grid-author,
	.ub-block-post-grid-date {
		display: inline-block;
		&:not(:last-child):after {
			content: "";
			vertical-align: middle;
			margin: 0 5px;
			line-height: 1;
		}
	}
	.ub-block-post-grid-author a {
		color: var(--ub-post-grid-author-color, inherit);

		text-decoration: none;
		&:hover {
			color: var(
				--ub-post-grid-author-hover-color,
				var(--ub-post-grid-author-color, inherit)
			);
			text-decoration: underline;
		}
	}
	.ub-block-post-grid-more-link {
		display: inline-block;
		box-shadow: none;
		transition: 0.3s ease;
		font-weight: bold;
		text-decoration: none;
		color: var(--ub-post-grid-link-color, #292929);
		background: var(--ub-post-grid-link-background);
		&:hover {
			text-decoration: underline;
			color: var(
				--ub-post-grid-link-hover-color,
				var(--ub-post-grid-link-color, #292929)
			);
			background: var(
				--ub-post-grid-link-hover-background,
				var(--ub-post-grid-link-background)
			);
		}
	}
	.ub-block-post-grid-excerpt {
		.ub-block-post-grid-excerpt-text {
			color: var(--ub-post-grid-excerpt-color);
			&:hover {
				color: var(
					--ub-post-grid-excerpt-hover-color,
					var(--ub-post-grid-excerpt-color)
				);
			}
		}
	}
	.ub-block-post-grid-excerpt > p:last-child {
		margin-top: 15px;
		margin-bottom: 0;
	}
	.is-list {
		display: grid;
		article {
			display: grid;
			grid-template-columns: 30% 1fr;
			grid-template-rows: 1fr;
			grid-gap: 0 2em;
			@media all and (-ms-high-contrast: none) {
				display: block;
			}
			&:before {
				display: none;
			}
			&:not(.has-post-thumbnail) {
				grid-template-columns: 1fr;
			}
			@media only screen and (min-width: 600px) {
				&:not(:last-child) {
					border-bottom: solid 1px #eee;
				}
			}
			@media only screen and (max-width: 600px) {
				grid-template-columns: 1fr;
			}
		}
		.ub-block-post-grid-image {
			margin-bottom: 0;
			@media all and (-ms-high-contrast: none) {
				width: 30%;
				display: inline-block;
				vertical-align: top;
			}
			@media only screen and (max-width: 600px) {
				margin-bottom: 5%;
			}
		}
		@media all and (-ms-high-contrast: none) {
			.ub-block-post-grid-text {
				width: 65%;
				padding-left: 5%;
				display: inline-block;
				vertical-align: top;
			}
			.post:not(.has-post-thumbnail) .ub-block-post-grid-text {
				width: 100%;
				padding-left: 0;
			}
		}
		.no-thumb .ub-block-post-grid-text {
			grid-column: span 2;
		}
	}
}

.ub-block-post-grid-image {
	position: relative;
	&:hover .ub-post-grid-no-image-placeholder {
		opacity: 1;
		z-index: 1;
	}
}

.ub-post-grid-no-image-placeholder {
	padding: 40px;
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	opacity: 0;
	background: #f3f3f4;
	transition: 0.2s ease;
	svg {
		margin-bottom: 10px;
	}
}

.ub-post-grid-no-image-icon {
	position: absolute;
	top: 10px;
	background: #ffe606;
	right: 10px;
	padding: 6px;
	line-height: 1;
	height: 32px;
	transition: 0.2s ease;
	border-radius: 5px;
	z-index: 1;
}
