/*
 * Newsletters page only. Enqueued in functions.php whenever the page slug is
 * "newsletters".
 *
 * Layout is a compact two-column list of rows rather than big cards: the
 * archive is expected to grow past 30 issues, so density and quick scanning
 * matter more than large cover art. Each row is a small document thumbnail,
 * the issue title + date, and a "Read" affordance; clicking opens the PDF in
 * the shared viewer modal.
 */

.newsletters {
	padding-block: clamp(3rem, 6vw, 5rem);
}

.newsletters__empty {
	color: var(--muted);
	text-align: center;
}

.newsletter-controls {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 1rem;
	margin-bottom: 1.5rem;
}

.newsletter-search {
	position: relative;
	flex: 1;
	min-width: 220px;
}

.newsletter-search__icon {
	position: absolute;
	top: 50%;
	left: 0.9rem;
	width: 18px;
	height: 18px;
	transform: translateY(-50%);
	color: var(--muted);
	pointer-events: none;
}

.newsletter-search__input {
	width: 100%;
	padding: 0.7rem 1rem 0.7rem 2.6rem;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: var(--bg);
	color: var(--ink);
	font-family: inherit;
	font-size: 0.95rem;
}

.newsletter-search__input:focus {
	outline: none;
	border-color: var(--accent);
	box-shadow: 0 0 0 3px rgb(0 113 176 / 15%);
}

/* Two-option segmented toggle instead of a native <select>: only two states,
   and it dodges the un-stylable native dropdown list. */
.newsletter-sort {
	display: inline-flex;
	flex-shrink: 0;
	padding: 4px;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: white;
}

.newsletter-sort__option {
	padding: 0.5rem 1.1rem;
	border: none;
	border-radius: 999px;
	background: transparent;
	color: var(--muted);
	font-family: inherit;
	font-size: 0.9rem;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}

.newsletter-sort__option:hover {
	color: var(--ink);
}

.newsletter-sort__option.is-active {
	background: rgba(51, 67, 89, 0.12);
	color: var(--accent);
	box-shadow: 0 1px 3px rgb(11 20 32 / 12%);
}

.newsletter-sort__option:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

.newsletter-list__empty {
	color: var(--muted);
	text-align: center;
	padding-block: 2rem;
}

.newsletter-list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
	gap: 0.75rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.newsletter-item[hidden] {
	display: none;
}

.newsletter-item {
	display: flex;
	position: relative;
}

/*
 * The row links through to the issue's own page; the PDF shortcut beside it
 * opens the printed sheet in the viewer modal without leaving the archive.
 * It sits inside the row's padding rather than after it, so the row keeps its
 * full width and the two never disagree about where the row ends.
 */
.newsletter-item__button {
	display: flex;
	align-items: center;
	gap: 1rem;
	width: 100%;
	padding: 0.75rem 4.5rem 0.75rem 0.75rem;
	border: 1px solid var(--line);
	border-radius: var(--radius-sm);
	background: var(--bg);
	font-family: inherit;
	text-align: left;
	text-decoration: none;
	color: inherit;
	cursor: pointer;
	transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.newsletter-item__pdf {
	position: absolute;
	top: 50%;
	right: 0.75rem;
	transform: translateY(-50%);
	padding: 0.3rem 0.6rem;
	font: inherit;
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	color: var(--accent);
	background: var(--sand);
	border: 1px solid var(--line);
	border-radius: 999px;
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.newsletter-item__pdf:hover,
.newsletter-item__pdf:focus-visible {
	background: var(--accent);
	color: #fff;
}

.newsletter-item__button:hover,
.newsletter-item__button:focus-visible {
	border-color: var(--accent);
	box-shadow: 0 8px 20px rgb(11 58 92 / 10%);
	transform: translateY(-1px);
}

.newsletter-item__thumb {
	flex-shrink: 0;
	width: 52px;
	aspect-ratio: 500 / 647;
	overflow: hidden;
	border-radius: 6px;
	background: var(--sand);
	box-shadow: 0 1px 3px rgb(11 20 32 / 12%);
}

.newsletter-item__thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.newsletter-item__body {
	flex: 1;
	min-width: 0;
}

.newsletter-item__title {
	display: block;
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.35;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.newsletter-item__date {
	display: block;
	margin-top: 0.15rem;
	color: var(--muted);
	font-size: 0.82rem;
}

.newsletter-item__cta {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	color: var(--accent);
	font-size: 0.9rem;
	font-weight: 600;
}

.newsletter-item__arrow {
	width: 16px;
	height: 16px;
	transition: transform 0.18s ease;
}

.newsletter-item__button:hover .newsletter-item__arrow,
.newsletter-item__button:focus-visible .newsletter-item__arrow {
	transform: translateX(3px);
}

/* On the narrowest screens the "Read" word crowds the row; the arrow alone
   still signals the action. */
@media (max-width: 380px) {
	.newsletter-item__cta-text {
		display: none;
	}
}
