/*
 * EANGUS Post Cards
 *
 * Only this plugin's own epc-* classes are styled, and layout keys off screen and container width rather than
 * Divi's column classes, so it renders the same under Divi 4, Divi 5, or no builder at all. Colours are custom properties: override them on .epc to restyle a site.
 */

.epc {
	--epc-card-bg: #fff;
	--epc-radius: 6px;
	--epc-shadow: 0 2px 5px 0 rgba(0, 0, 0, .16), 0 2px 10px 0 rgba(0, 0, 0, .12);
	--epc-badge-bg: #16a085;
	--epc-badge-color: #fff;
	--epc-grid-title-bg: #16a085;
	--epc-grid-title-color: #fff;
	--epc-share-color: #3b5996;
	--epc-meta-bg: #f5f5f5;
	--epc-meta-color: #8a8a8a;
	container-type: inline-size;
}

.epc-cards {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 20px;
	align-items: start;
}

/* ---------- card ---------- */

.epc-card {
	position: relative;
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	grid-template-areas: "media" "body" "meta";
	align-items: start;
	background: var(--epc-card-bg);
	border-radius: var(--epc-radius);
	box-shadow: var(--epc-shadow);
	overflow: hidden;
	text-align: left;
}

.epc-media { grid-area: media; }
.epc-body { grid-area: body; padding: 5px 10px 10px; }
.epc-meta { grid-area: meta; }

.epc-media a {
	display: block;
	line-height: 0;
}

.epc-img {
	display: block;
	width: 100%;
	height: auto;
	max-width: none;
	margin: 0;
}

.epc-badge {
	position: absolute;
	top: 0;
	left: 0;
	z-index: 1;
	padding: 5px;
	background: var(--epc-badge-bg);
	color: var(--epc-badge-color) !important;
	font-size: 10px;
	font-weight: bold;
	line-height: 1.4em;
	text-transform: uppercase;
	text-decoration: none;
}

/* With no image to sit on, the badge gets a band of its own instead of covering the title. */
.epc-card--noimg { padding-top: 26px; }

.epc-title {
	margin: 0;
	padding: 10px 0;
	font-size: 16px;
	line-height: 1.2;
}

.epc-title a {
	color: inherit;
	text-decoration: none;
}

.epc-share a {
	display: inline-block;
	padding: 7px 12px;
	color: var(--epc-share-color);
	font-size: 16px;
	line-height: 0;
	transition: all .2s ease-in-out;
}

.epc-share a:hover,
.epc-share a:focus-visible {
	background: var(--epc-share-color);
	color: #fff;
}

.epc-excerpt p {
	margin: 0;
	padding: 10px 0;
	line-height: 1.3em;
}

.epc-meta {
	display: flex;
	background: var(--epc-meta-bg);
}

.epc-meta > span {
	flex: 1 1 0;
	padding: 10px 0;
	color: var(--epc-meta-color);
	font-size: 8px;
	font-weight: 600;
	letter-spacing: 1px;
	line-height: 1.6;
	text-align: center;
	text-transform: uppercase;
}

.epc-meta a { color: inherit; }

.epc-icon {
	display: inline-block;
	vertical-align: -0.125em;
}

.epc-meta .epc-icon { margin-right: 2px; }

/* ---------- list: image beside the text on wider screens ----------
 * Breakpoints follow the screen, as the old module's did (781px and 841px); the container guard keeps a list that
 * lands in a narrow column stacked instead of squeezing the image into a sliver. */

@media (min-width: 781px) {
	@container (min-width: 420px) {
		.epc--list .epc-card {
			grid-template-columns: 49% minmax(0, 1fr);
			grid-template-areas: "media body" "meta meta";
		}

		.epc--list .epc-card--noimg { grid-template-areas: "body body" "meta meta"; }
		.epc--list .epc-body { padding: 0 10px 10px 16px; }

		.epc-img--list {
			aspect-ratio: 5 / 3;
			object-fit: cover;
		}
	}
}

@media (min-width: 841px) {
	@container (min-width: 420px) {
		.epc--list .epc-card { grid-template-columns: 33.5% minmax(0, 1fr); }
		.epc--archive .epc-card { grid-template-columns: 43% minmax(0, 1fr); }
	}
}

/* ---------- grid: 1, 2 or 3 columns ---------- */

.epc--grid .epc-cards { row-gap: 30px; }

@media (min-width: 768px) {
	@container (min-width: 400px) {
		.epc--grid .epc-cards {
			grid-template-columns: repeat(2, minmax(0, 1fr));
			column-gap: 7.5%;
		}

		.epc-img--grid {
			aspect-ratio: 8 / 5;
			object-fit: cover;
		}
	}
}

@media (min-width: 981px) {
	@container (min-width: 600px) {
		.epc--grid .epc-cards {
			grid-template-columns: repeat(3, minmax(0, 1fr));
			column-gap: 5.5%;
		}
	}
}

.epc--grid .epc-body { padding: 0; }

.epc--grid .epc-title {
	padding: 10px;
	background: var(--epc-grid-title-bg);
	color: var(--epc-grid-title-color);
	text-align: center;
}

.epc--grid .epc-share { text-align: center; }
.epc--grid .epc-excerpt p { padding: 10px; }

/* ---------- archives: the theme's own paragraph rhythm ---------- */

.epc--archive .epc-excerpt p { line-height: inherit; }

/* ---------- pagination ---------- */

.epc-pagination {
	display: flex;
	justify-content: space-between;
	gap: 20px;
	margin-top: 20px;
}
