/* Writings: topic filter, search, a featured latest piece and a card grid.
   Used on the home page, on the Videos page and on topic / tag / date archives.
   Loaded after components.css. Classes: tts-toolbar, tts-topics, tts-grid, tts-card. */

/* ---------- Toolbar: topics on the left, search on the right ---------- */
.tts-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 1rem 2rem;
	margin: 0 0 var(--wp--preset--spacing--40);
	padding-bottom: 1.25rem;
	border-bottom: 1px solid var(--wp--preset--color--mist);
}
.tts-toolbar > * { margin: 0 !important; }
.tts-toolbar:not(:has(.tts-topics)) { display: none; }
.tts-toolbar .wp-block-search { flex: 0 1 23rem; min-width: 15rem; }
.tts-toolbar .wp-block-search__inside-wrapper { align-items: center; }
.tts-toolbar .wp-block-search__input { min-width: 0; padding: .6em 1.15em; font-size: .95rem; }
.tts-toolbar .wp-block-search__button { margin-left: .4rem; padding: .6em .85em; }

/* ---------- Topic pills ---------- */
.tts-topics { min-width: 0; max-width: 100%; }
.tts-topics ul { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.tts-topics li { margin: 0; }
.tts-topics a {
	display: inline-flex;
	align-items: center;
	gap: .6em;
	padding: .6em 1.15em;
	border: 1px solid var(--wp--preset--color--mist);
	border-radius: 999px;
	font-size: .78rem;
	font-weight: 450;
	letter-spacing: .16em;
	line-height: 1.2;
	text-transform: uppercase;
	text-decoration: none;
	transition: color var(--wp--custom--transition), border-color var(--wp--custom--transition), background-color var(--wp--custom--transition);
}
.tts-topics__count { font-size: .72rem; letter-spacing: 0; color: var(--wp--preset--color--muted); font-variant-numeric: tabular-nums; }
.tts-topics a:hover, .tts-topics a:focus-visible { color: var(--wp--preset--color--accent); border-color: var(--wp--preset--color--accent); }
.tts-topics a[aria-current="page"] { background: var(--wp--preset--color--contrast); border-color: var(--wp--preset--color--contrast); color: var(--wp--preset--color--base); }
.tts-topics a[aria-current="page"] .tts-topics__count { color: inherit; opacity: .7; }

/* ---------- Grid: 1 column on phones, 2 and 3 as the space allows ---------- */
.tts-grid { container-type: inline-size; }
.tts-grid .wp-block-post-template {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 1.75rem;
	margin: 0;
	padding: 0;
	list-style: none;
}
.tts-grid .wp-block-post-template > li { margin: 0; min-width: 0; }
@container (min-width: 40rem) {
	.tts-grid .wp-block-post-template { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2rem; }
}
@container (min-width: 64rem) {
	.tts-grid .wp-block-post-template { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- Card ---------- */
.tts-card.tts-card {
	position: relative;
	display: flex;
	flex-direction: column;
	height: 100%;
	padding: 0;
	overflow: hidden;
	background: color-mix(in srgb, var(--wp--preset--color--surface) 38%, var(--wp--preset--color--base));
	border: 1px solid var(--wp--preset--color--mist);
	border-radius: 2px;
	transition: border-color var(--wp--custom--transition), box-shadow var(--wp--custom--transition);
}
.tts-card > * { margin: 0 !important; }
.tts-card:hover { border-color: var(--wp--preset--color--accent); box-shadow: 0 12px 30px rgba(43, 36, 32, .08); }
.tts-card:has(.wp-block-post-title a:focus-visible) { outline: 1px solid var(--wp--preset--color--accent); outline-offset: 4px; }

.tts-card .wp-block-post-featured-image { overflow: hidden; border-radius: 0; }
.tts-card .wp-block-post-featured-image img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 16 / 9;
	object-fit: cover;
	border-radius: 0;
	transition: transform .8s cubic-bezier(.22, .61, .36, 1);
}
.tts-card:hover .wp-block-post-featured-image img { transform: scale(1.035); }

.tts-card .tts-card__body { display: flex; flex-direction: column; flex: 1 1 auto; gap: .7rem; padding: 1.15rem 1.35rem 1.45rem; }
.tts-card__body > * { margin: 0 !important; }

/* Topic and date, side by side while they fit, otherwise one under the other */
.tts-card__meta { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem 1rem; }
.tts-card__meta .wp-block-post-terms,
.tts-card__meta .wp-block-post-date { margin: 0; font-size: .68rem; letter-spacing: .2em; text-transform: uppercase; }
.tts-card__meta .wp-block-post-terms a { position: relative; z-index: 2; text-decoration: none; }
.tts-card__meta .wp-block-post-terms a:hover { text-decoration: underline; text-underline-offset: .25em; }

/* The whole card is one link: the title's link stretches over it. */
.tts-card .wp-block-post-title {
	margin: 0;
	font-size: clamp(1.25rem, 1.1rem + .5vw, 1.45rem);
	line-height: 1.2;
	overflow-wrap: break-word;
	display: -webkit-box;
	overflow: hidden;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 4;
}
.tts-card .wp-block-post-title a { text-decoration: none; }
.tts-card .wp-block-post-title a::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.tts-card .wp-block-post-title a:focus-visible { outline: none; }
.tts-card:hover .wp-block-post-title a { color: var(--wp--preset--color--accent); }

.tts-card .wp-block-post-excerpt { margin: 0; font-size: .95rem; line-height: 1.6; }
.tts-card .wp-block-post-excerpt__excerpt {
	display: -webkit-box;
	margin: 0;
	overflow: hidden;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
}

/* ---------- The latest piece, larger, on the first page ----------
   Home page and archives only: on a static page (the Videos page) every page of
   the list is a plain grid, because "paged" is not set there. */
body:not(.paged):not(.page) .tts-grid .wp-block-post-template > li:first-child { grid-column: 1 / -1; }
body:not(.paged):not(.page) .tts-grid .wp-block-post-template > li:first-child .tts-card__body::before {
	content: "Latest";
	font-size: .68rem;
	letter-spacing: .3em;
	text-transform: uppercase;
	color: var(--wp--preset--color--accent);
}
body:not(.paged):not(.page) .tts-grid .wp-block-post-template > li:first-child .wp-block-post-title {
	font-size: clamp(1.5rem, 1.2rem + 1vw, 2.15rem);
	-webkit-line-clamp: 5;
}
/* Picture beside the text only when there is room for both; otherwise stacked. */
@container (min-width: 50rem) {
	body:not(.paged):not(.page) .tts-grid .wp-block-post-template > li:first-child .tts-card:has(> .wp-block-post-featured-image) {
		display: grid;
		grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
	}
	body:not(.paged):not(.page) .tts-grid .wp-block-post-template > li:first-child .tts-card .tts-card__body {
		justify-content: center;
		gap: .9rem;
		padding: clamp(1.5rem, 3vw, 2.5rem);
	}
	body:not(.paged):not(.page) .tts-grid .wp-block-post-template > li:first-child .wp-block-post-excerpt { font-size: 1rem; }
	body:not(.paged):not(.page) .tts-grid .wp-block-post-template > li:first-child .wp-block-post-excerpt__excerpt { -webkit-line-clamp: 5; }
}
@container (min-width: 40rem) and (max-width: 49.99rem) {
	body:not(.paged):not(.page) .tts-grid .wp-block-post-template > li:first-child .tts-card .tts-card__body { padding: 1.5rem 1.75rem 1.75rem; }
}

/* ---------- Page navigation: Newer ... 1 2 3 ... Older ---------- */
.tts-grid .wp-block-query-pagination {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
	align-items: center;
	gap: .75rem 1rem;
	margin-top: var(--wp--preset--spacing--40);
	padding-top: 1.5rem;
	border-top: 1px solid var(--wp--preset--color--mist);
	font-size: .78rem;
	letter-spacing: .18em;
	text-transform: uppercase;
}
.tts-grid .wp-block-query-pagination > * { margin: 0; }
.tts-grid .wp-block-query-pagination-previous { grid-column: 1; justify-self: start; }
.tts-grid .wp-block-query-pagination-numbers { grid-column: 2; display: flex; flex-wrap: wrap; justify-content: center; gap: .35rem; }
.tts-grid .wp-block-query-pagination-next { grid-column: 3; justify-self: end; }
.tts-grid .wp-block-query-pagination a { text-decoration: none; }
.tts-grid .wp-block-query-pagination a:hover { color: var(--wp--preset--color--accent); }
.tts-grid .wp-block-query-pagination-numbers .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 2.5rem;
	height: 2.5rem;
	padding: 0 .4rem;
	border: 1px solid transparent;
	border-radius: 999px;
	letter-spacing: 0;
	font-size: .9rem;
}
.tts-grid .wp-block-query-pagination-numbers a.page-numbers:hover { border-color: var(--wp--preset--color--mist); }
.tts-grid .wp-block-query-pagination-numbers .page-numbers.current { border-color: var(--wp--preset--color--contrast); }
.tts-grid .wp-block-query-pagination-numbers .page-numbers.dots { border-color: transparent; }
.tts-grid .wp-block-query-no-results { padding-block: var(--wp--preset--spacing--40); }

/* ---------- Phones ---------- */
@media (max-width: 40em) {
	/* Topics stay on one swipeable row instead of stacking up. */
	.tts-toolbar .tts-topics { flex: 1 1 100%; }
	.tts-topics ul { flex-wrap: nowrap; overflow-x: auto; padding-bottom: .35rem; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
	.tts-topics ul::-webkit-scrollbar { display: none; }
	.tts-topics li { flex: 0 0 auto; }
	.tts-topics a { white-space: nowrap; padding: .55em 1em; }
	.tts-toolbar .wp-block-search { flex: 1 1 100%; }
	.tts-card .tts-card__body { padding: 1rem 1.15rem 1.3rem; }
	.tts-grid .wp-block-query-pagination { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
	.tts-grid .wp-block-query-pagination-numbers { grid-column: 1 / -1; grid-row: 1; }
	.tts-grid .wp-block-query-pagination-previous { grid-column: 1; grid-row: 2; }
	.tts-grid .wp-block-query-pagination-next { grid-column: 2; grid-row: 2; }
}

@media (prefers-reduced-motion: reduce) {
	.tts-card, .tts-card .wp-block-post-featured-image img { transition: none; }
	.tts-card:hover .wp-block-post-featured-image img { transform: none; }
}
