@import url('https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');

:root {
	--light-grey-green: #CDD0CE;
	--off-white: #e9edea;
	--dark-grey-green: #525553;
	--accent-green: #3d4e3d;
	--text-font-size: 1em;
	--small-font-size: 0.9em;
}

/* ---- Page scaffold ---- */

body.page-template-page-library {
	font-family: "Montserrat", sans-serif;
	margin: 0;
}

body.page-template-page-library #main {
	display: none !important;
}

/* ---- Header ---- */

.library-header {
	background-color: var(--light-grey-green);
	padding: clamp(1.25rem, 5vw, 4em);
}

.library-header h1 {
	font-size: 36px;
	margin-top: 0;
	margin-bottom: 10px;
	padding-bottom: 10px;
}

.library-intro {
	font-size: var(--text-font-size);
	line-height: 1.6;
	max-width: 860px;
}

.library-intro p:last-child {
	margin-bottom: 0;
}

/* ---- Page content area ---- */

.library-content {
	padding: 2.5em clamp(1rem, 5vw, 4em);
	background-color: #F8F8F8;
}

/* ---- Page description ---- */

.library-description {
	font-size: var(--text-font-size);
	line-height: 1.6;
	color: #2d2d2d;
	max-width: 860px;
	margin-bottom: 1.75em;
}

.library-description p:last-child {
	margin-bottom: 0;
}

/* ---- Search / controls ---- */

.library-controls {
	display: flex;
	align-items: center;
	gap: 1em;
	margin-bottom: 1.5em;
	font-family: "Inter", sans-serif;
}

.library-sort-mobile {
	display: flex;
	align-items: center;
	gap: 0.5em;
}

.library-sort-label {
	font-size: var(--small-font-size);
	font-weight: 600;
	color: var(--dark-grey-green);
	white-space: nowrap;
}

.library-sort-select {
	flex: 1 1 auto;
	padding: 10px 14px;
	border: 1px solid var(--light-grey-green);
	border-radius: 6px;
	background-color: white;
	color: var(--dark-grey-green);
	font-family: "Inter", sans-serif;
	font-size: var(--small-font-size);
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
	appearance: none;
	-webkit-appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='%23525553' d='M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.929l-4.243-4.243-1.414 1.414L9.293 12.95z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 10px center;
	background-size: 15px;
}

.library-search {
	flex: 0 1 360px;
	padding: 10px 14px;
	border: 1px solid var(--light-grey-green);
	border-radius: 6px;
	background-color: white;
	color: var(--dark-grey-green);
	font-family: "Inter", sans-serif;
	font-size: var(--small-font-size);
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
	appearance: none;
}

.library-search:focus {
	outline: 2px solid var(--accent-green);
	outline-offset: 1px;
}

.library-count {
	font-size: var(--small-font-size);
	color: var(--dark-grey-green);
	white-space: nowrap;
}

/* ---- Table wrapper ---- */

.library-table-wrapper {
	overflow-x: auto;
	border-radius: 8px;
	border: 1px solid var(--light-grey-green);
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* ---- Table ---- */

.library-table {
	width: 100%;
	border-collapse: collapse;
	background-color: white;
	font-size: var(--small-font-size);
}

/* ---- Header row ---- */

.library-table thead tr {
	background-color: var(--accent-green);
	color: white;
}

.library-table th {
	padding: 14px 16px;
	text-align: left;
	font-family: "Inter", sans-serif;
	font-weight: 600;
	font-size: 0.8em;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	white-space: nowrap;
	border-bottom: 2px solid rgba(0, 0, 0, 0.15);
	border-right: 1px solid rgba(255, 255, 255, 0.15);
}

.library-table th:last-child {
	border-right: none;
}

/* ---- Sortable column headers ---- */

.library-table th.sortable {
	cursor: pointer;
	user-select: none;
	transition: background-color 0.15s ease;
}

.library-table th.sortable:hover {
	background-color: #2d3d2d;
}

.library-table th.sortable:focus {
	outline: 2px solid rgba(255, 255, 255, 0.6);
	outline-offset: -2px;
}

.library-table th.sort-active {
	background-color: #283528;
}

.sort-icon {
	display: inline-block;
	margin-left: 6px;
	font-size: 1em;
	opacity: 0.6;
	transition: opacity 0.15s ease;
	vertical-align: middle;
}

.library-table th.sort-active .sort-icon {
	opacity: 1;
}

/* ---- Body rows ---- */

.library-table tbody tr {
	border-bottom: 1px solid var(--light-grey-green);
	transition: background-color 0.15s ease;
}

.library-table tbody tr:last-child {
	border-bottom: none;
}

.library-table tbody tr:nth-child(even) {
	background-color: #f4f6f4;
}

.library-table tbody tr:hover {
	background-color: #eaf0ea;
}

.library-table td {
	padding: 12px 16px;
	vertical-align: middle;
	color: #2d2d2d;
	line-height: 1.45;
	border-right: 1px solid var(--light-grey-green);
}

.library-table td:last-child {
	border-right: none;
}

/* ---- Column widths ---- */

.library-table .col-cover {
	width: 80px;
	text-align: center;
	padding: 8px 10px;
}

.library-table .col-title {
	min-width: 200px;
}

.library-table .col-category {
	width: 160px;
}

.library-table .col-source {
	width: 220px;
}

.library-table .col-date {
	width: 70px;
	text-align: center;
}

/* ---- Cover thumbnail ---- */

.doc-cover-thumb {
	display: block;
	width: 60px;
	height: 80px;
	object-fit: cover;
	border-radius: 3px;
	border: 1px solid var(--light-grey-green);
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
	transition: box-shadow 0.15s ease, transform 0.15s ease;
	margin: 0 auto;
}

.doc-cover-thumb:hover {
	box-shadow: 0 3px 10px rgba(0, 0, 0, 0.28);
	transform: scale(1.06);
}

.doc-cover-placeholder {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 60px;
	height: 80px;
	background-color: var(--off-white);
	border: 1px solid var(--light-grey-green);
	border-radius: 3px;
	color: var(--dark-grey-green);
	font-size: 0.75em;
	font-weight: 600;
	text-decoration: none;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	margin: 0 auto;
	transition: background-color 0.15s ease;
}

.doc-cover-placeholder:hover {
	background-color: var(--light-grey-green);
}

/* ---- Title link ---- */

.library-table .col-title a {
	text-decoration: none;
	color: var(--accent-green);
	font-weight: 500;
	transition: color 0.15s ease;
}

.library-table .col-title a:hover {
	color: #1f2b1f;
	text-decoration: underline;
}

/* ---- Document description blurb ---- */

.doc-description {
	margin: 5px 0 0;
	font-size: 0.8em;
	color: #5a5a5a;
	line-height: 1.5;
}

.doc-description.is-clamped {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.doc-desc-toggle {
	display: inline-block;
	margin-top: 3px;
	font-size: 0.75em;
	color: var(--accent-green);
	background: none;
	border: none;
	padding: 0;
	cursor: pointer;
	font-family: inherit;
	text-decoration: underline;
}

/* ---- Empty state ---- */

.library-empty {
	text-align: center;
	padding: 3em 1em;
	color: var(--dark-grey-green);
	font-style: italic;
}

/* ---- Responsive ---- */

/* Tablet: tighten padding, hide source column */
@media (max-width: 900px) {
	.library-content {
		padding: 2em 2em;
	}

	.library-header {
		padding: 3em 2em;
	}

	.library-header h1 {
		font-size: 28px;
	}

	.library-description {
		font-size: 0.95em;
	}

	.library-table .col-source {
		display: none;
	}

	.library-table th,
	.library-table td {
		padding: 10px 12px;
	}
}

/* Mobile: switch from table to card layout */
@media (max-width: 640px) {
	.library-content {
		padding: 1.5em 0.5em;
	}

	.library-header {
		padding: 2em 1em;
	}

	.library-header h1 {
		font-size: 22px;
	}

	.library-description {
		font-size: 0.88em;
		margin-bottom: 1.25em;
	}

	/* Search bar on its own row, count + sort beneath it */
	.library-controls {
		flex-direction: column;
		align-items: stretch;
		gap: 0.5em;
	}


	.library-search {
		width: 100%;
		box-sizing: border-box;
		flex: none;
	}

	.library-count {
		font-size: 0.8em;
	}

	/* Let the wrapper breathe without a border */
	.library-table-wrapper {
		border: none;
		box-shadow: none;
		background: transparent;
		overflow: visible;
	}

	/* Convert table elements to block/flex */
	.library-table,
	.library-table tbody {
		display: block;
	}

	/* Hide the header row — labels come from ::before instead */
	.library-table thead {
		display: none;
	}

	/* Each row becomes a card with cover on the left */
	.library-table tbody tr.library-row {
		display: grid;
		grid-template-columns: 70px minmax(0, 1fr);
		grid-template-areas:
			"cover title"
			"cover category"
			"cover source"
			"cover date";
		align-items: start;
		gap: 4px 10px;
		padding: 10px;
		margin-bottom: 8px;
		border: 1px solid var(--light-grey-green);
		border-radius: 6px;
		background: white;
		box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
		overflow: hidden;
	}

	/* Remove zebra striping — cards have their own style */
	.library-table tbody tr:nth-child(even) {
		background: white;
	}

	.library-table td {
		padding: 0;
		border: none;
	}

	.library-table .col-cover {
		grid-area: cover;
	}

	.doc-cover-thumb,
	.doc-cover-placeholder {
		margin: 0;
	}

	.library-table .col-title {
		grid-area: title;
		align-self: end;
		font-size: 0.82em;
		line-height: 1.35;
		word-break: break-word;
		overflow-wrap: break-word;
	}

	/* Show all metadata columns on mobile cards */
	.library-table .col-category,
	.library-table .col-source {
		display: block !important;
	}

	.library-table .col-category {
		grid-area: category;
		font-size: 0.78em;
		color: var(--dark-grey-green);
	}

	.library-table .col-source {
		grid-area: source;
		font-size: 0.78em;
		color: var(--dark-grey-green);
	}

	.library-table .col-date {
		grid-area: date;
		font-size: 0.78em;
		color: var(--dark-grey-green);
		text-align: left;
	}

	/* Inline labels so fields are self-explanatory without the header row */
	.library-table .col-category::before { content: "Category: "; font-weight: 700; }
	.library-table .col-source::before   { content: "Source: ";   font-weight: 700; }
	.library-table .col-date::before     { content: "Year: ";     font-weight: 700; }

	/* Empty state */
	.library-table tbody tr.library-empty-row {
		display: block;
	}
}
