/*
 * Styles for the output of projects in the frontend and the block editor (Connector for Propstack Pro).
 *
 * All colors, borders and spacings use CSS variables, so they could be changed in the theme or via
 * "Additional CSS" without overwriting these rules, e.g.:
 *
 * .cfprop-projects {
 *     --cfprop-project-card-background: #f5f5f5;
 *     --cfprop-project-button-background: #003366;
 *     --cfprop-project-button-color: #fff;
 * }
 *
 * Without own values the output uses the colors of the theme (text color, link color).
 */

/* the default values of all variables. */
:root {
	--cfprop-project-border-color: rgba(127, 127, 127, .3);
	--cfprop-project-state-background: transparent;
	--cfprop-project-state-color: inherit;
	--cfprop-project-state-border: 1px solid currentColor;
	--cfprop-project-state-radius: 3px;
	--cfprop-project-card-background: transparent;
	--cfprop-project-card-color: inherit;
	--cfprop-project-card-border: 1px solid var(--cfprop-project-border-color);
	--cfprop-project-card-radius: 0;
	/* spacings and sizes like the list of objects in the Light version (".cfprop-objects", ".cfprop-thumbnail"). */
	--cfprop-project-card-padding: 1em 1rem;
	--cfprop-project-cards-gap: 1.2em;
	--cfprop-project-cards-min-width: 300px;
	--cfprop-project-list-max-width: 1200px;
	--cfprop-project-image-height: 300px;
	--cfprop-project-button-background: transparent;
	--cfprop-project-button-color: inherit;
	--cfprop-project-button-border: 1px solid currentColor;
	--cfprop-project-button-radius: 3px;
	--cfprop-project-button-padding: .4em 1em;
	--cfprop-project-button-hover-background: var(--cfprop-project-button-background);
	--cfprop-project-button-hover-color: var(--cfprop-project-button-color);
	--cfprop-project-table-head-background: transparent;
	--cfprop-project-table-target-background: rgba(127, 127, 127, .15);
}

/* the state of a project, with the color from Propstack (if enabled) and a readable text color. */
.cfprop-project-state {
	background-color: var(--cfprop-project-state-background);
	border: var(--cfprop-project-state-border);
	border-radius: var(--cfprop-project-state-radius);
	color: var(--cfprop-project-state-color);
	display: inline-block;
	font-size: .8em;
	line-height: 1.6;
	padding: 0 .6em;
}
.cfprop-project-state[style*="--cfprop-project-state-background"] {
	border-color: transparent;
}

/* the single view. */
:where(.cfprop-project) {
	.cfprop-project-header {
		margin-bottom: 1.5em;
	}
	.cfprop-project-title {
		margin: .3em 0;
	}
	.cfprop-project-subheadline {
		font-size: 1.2em;
		margin: 0 0 .3em;
	}
	.cfprop-project-tagline {
		font-style: italic;
		margin: 0;
	}
	.cfprop-project-thumbnail img {
		display: block;
		height: auto;
		max-width: 100%;
	}
	.cfprop-project-section {
		margin-top: 2em;
	}
}

/* a list of fields. */
:where(.cfprop-project-data) {
	display: grid;
	gap: .4em 2em;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	margin: 1.5em 0;
	.cfprop-project-data-row {
		border-bottom: 1px solid var(--cfprop-project-border-color);
		display: flex;
		gap: 1em;
		justify-content: space-between;
		padding: .3em 0;
	}
	dt {
		font-weight: bold;
	}
	dd {
		margin: 0;
		text-align: right;
	}
}

/* a single field. */
:where(.cfprop-project-field-label) {
	font-weight: bold;
	margin-right: .5em;
}

/* the table of units. */
:where(.cfprop-project-units-table) {
	border-collapse: collapse;
	width: 100%;
	th {
		background-color: var(--cfprop-project-table-head-background);
	}
	th, td {
		border-bottom: 1px solid var(--cfprop-project-border-color);
		padding: .5em;
		text-align: left;
	}
	/* the unit, which has been opened via its link (e.g. units without own page). */
	tr:target {
		background-color: var(--cfprop-project-table-target-background);
	}
	tr {
		scroll-margin-top: 4em;
	}
}

/* show the table of units as list on small screens. */
@media (max-width: 700px) {
	:where(.cfprop-project-units-table) {
		thead {
			display: none;
		}
		tr {
			border-bottom: 2px solid var(--cfprop-project-border-color);
			display: block;
			padding: .5em 0;
		}
		td {
			border: 0;
			display: flex;
			justify-content: space-between;
			padding: .2em 0;
		}
		td::before {
			content: attr(data-label);
			font-weight: bold;
			margin-right: 1em;
		}
	}
}

/* the list of projects. */
:where(.cfprop-projects) {
	display: grid;
	gap: var(--cfprop-project-cards-gap);
	/* 3 columns at full width, fewer in narrow containers (depends on the container, not on the viewport),
	   like the list of objects. Uses px as some themes change the root font size. */
	grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--cfprop-project-cards-min-width)), 1fr));
	.cfprop-project-card {
		background-color: var(--cfprop-project-card-background);
		border: var(--cfprop-project-card-border);
		border-radius: var(--cfprop-project-card-radius);
		color: var(--cfprop-project-card-color);
		display: flex;
		flex-direction: column;
		overflow: hidden;
	}
	.cfprop-project-card-image img {
		display: block;
		height: var(--cfprop-project-image-height);
		object-fit: cover;
		width: 100%;
	}
	.cfprop-project-card-content {
		display: flex;
		flex: 1;
		flex-direction: column;
		gap: .5em;
		padding: var(--cfprop-project-card-padding);
	}
	.cfprop-project-card-title {
		font-size: 1.3em;
		margin: 0;
	}
	.cfprop-project-card-title a {
		color: inherit;
	}
	.cfprop-project-card-subheadline,
	.cfprop-project-card-meta {
		margin: 0;
	}
}

/* limit and center the list in every container (also if used as widget, block or shortcode in a page builder),
   like the list of objects in the Light version (".cfprop-objects"). The width could be changed via the variable. */
:where(.cfprop-projects) {
	margin-inline: auto;
}
.cfprop-projects {
	max-width: var(--cfprop-project-list-max-width) !important;
}

/* a fixed number of projects per row (setting "per_row"), with less columns on smaller screens. */
:where(.cfprop-projects-per-row) {
	grid-template-columns: repeat(var(--cfprop-project-cards-per-row, 3), minmax(0, 1fr));
}
:where(.cfprop-projects-per-row-1) { --cfprop-project-cards-per-row: 1; }
:where(.cfprop-projects-per-row-2) { --cfprop-project-cards-per-row: 2; }
:where(.cfprop-projects-per-row-3) { --cfprop-project-cards-per-row: 3; }
:where(.cfprop-projects-per-row-4) { --cfprop-project-cards-per-row: 4; }
:where(.cfprop-projects-per-row-5) { --cfprop-project-cards-per-row: 5; }
:where(.cfprop-projects-per-row-6) { --cfprop-project-cards-per-row: 6; }
@media (max-width: 1024px) {
	:where(.cfprop-projects-per-row-4, .cfprop-projects-per-row-5, .cfprop-projects-per-row-6) { --cfprop-project-cards-per-row: 3; }
}
@media (max-width: 782px) {
	:where(.cfprop-projects-per-row-3, .cfprop-projects-per-row-4, .cfprop-projects-per-row-5, .cfprop-projects-per-row-6) { --cfprop-project-cards-per-row: 2; }
}
@media (max-width: 600px) {
	:where(.cfprop-projects-per-row) { --cfprop-project-cards-per-row: 1; }
}

/*
 * The button of a project in the list (higher specificity than links of themes and the block editor,
 * so the colors of the variables are used).
 */
.cfprop-projects .cfprop-project-card-link,
.cfprop-projects .cfprop-project-card-link:visited {
	align-self: flex-start;
	background-color: var(--cfprop-project-button-background);
	border: var(--cfprop-project-button-border);
	border-radius: var(--cfprop-project-button-radius);
	color: var(--cfprop-project-button-color);
	display: inline-block;
	margin-top: auto;
	padding: var(--cfprop-project-button-padding);
	text-decoration: none;
}
.cfprop-projects .cfprop-project-card-link:hover,
.cfprop-projects .cfprop-project-card-link:focus {
	background-color: var(--cfprop-project-button-hover-background);
	color: var(--cfprop-project-button-hover-color);
	text-decoration: underline;
}

/* the link from a unit to its project. */
:where(.cfprop-project-link) {
	margin: 1em 0;
}
