/**
 * News cards.
 *
 * One stylesheet for both the Elementor News widget and the news archive /
 * single templates in the child theme, so the two cannot drift apart. Every
 * value the widget exposes as a control is read here as a custom property with
 * a sensible fallback, which is also what the templates get.
 */

.tpx-news {
	--tpx-news-columns: 2;
	--tpx-news-column-gap: 48px;
	--tpx-news-row-gap: 40px;

	--tpx-news-date-color: #6b7280;
	--tpx-news-marker-color: #9ca3af;

	--tpx-news-title-color: #820606;
	--tpx-news-title-hover-color: #5c0404;
	--tpx-news-title-gap: 10px;

	--tpx-news-excerpt-color: #4b5563;
	--tpx-news-excerpt-gap: 10px;
	--tpx-news-excerpt-lines: 2;

	--tpx-news-rule-color: #820606;
	--tpx-news-rule-width: 28px;
	--tpx-news-rule-hover-width: 56px;
	--tpx-news-rule-height: 3px;
	--tpx-news-rule-gap: 18px;

	--tpx-news-item-bg: transparent;
	--tpx-news-item-hover-bg: transparent;
	--tpx-news-item-padding: 0px;
	--tpx-news-item-radius: 0px;
	--tpx-news-item-lift: 2px;
	--tpx-news-item-shadow: none;
	--tpx-news-item-hover-shadow: none;

	/* Hover / focus feedback band: 160-240ms. */
	--tpx-news-speed: 200ms;
	--tpx-news-ease: cubic-bezier(0.4, 0, 0.2, 1);
}

.tpx-news__list {
	display: grid;
	grid-template-columns: repeat(var(--tpx-news-columns), minmax(0, 1fr));
	column-gap: var(--tpx-news-column-gap);
	row-gap: var(--tpx-news-row-gap);
	margin: 0;
	padding: 0;
	list-style: none;
}

/* === Item === */

.tpx-news__item {
	position: relative;
	display: flex;
	flex-direction: column;
	min-width: 0;
	background-color: var(--tpx-news-item-bg);
	padding: var(--tpx-news-item-padding);
	border-radius: var(--tpx-news-item-radius);
	box-shadow: var(--tpx-news-item-shadow);
	transition:
		transform var(--tpx-news-speed) var(--tpx-news-ease),
		box-shadow var(--tpx-news-speed) var(--tpx-news-ease),
		background-color var(--tpx-news-speed) var(--tpx-news-ease);
}

/* The whole card is one link. Focus is taken by this anchor, and the visual
   response is drawn on the card, so keyboard and pointer get the same state. */
.tpx-news__link {
	position: absolute;
	inset: 0;
	z-index: 1;
	border-radius: inherit;
	text-decoration: none;
}

.tpx-news__link:focus-visible {
	outline: 2px solid var(--tpx-news-rule-color);
	outline-offset: 4px;
}

.tpx-news__item:hover,
.tpx-news__item:has(.tpx-news__link:focus-visible) {
	transform: translateY(calc(-1 * var(--tpx-news-item-lift)));
	background-color: var(--tpx-news-item-hover-bg);
	box-shadow: var(--tpx-news-item-hover-shadow);
}

/* Pressing releases the lift, so the card reads as accepting the click. */
.tpx-news__item:has(.tpx-news__link:active) {
	transform: translateY(0);
	transition-duration: 90ms;
}

/* :has() is unsupported in a few older engines. Those simply get no lift --
   the card stays fully readable and the link still works. */

/* === Thumbnail (optional) === */

.tpx-news__thumb {
	position: relative;
	display: block;
	overflow: hidden;
	border-radius: var(--tpx-news-item-radius);
	margin-bottom: 16px;
	aspect-ratio: 16 / 10;
	background-color: #e9eaec;
}

.tpx-news__thumb > img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 400ms var(--tpx-news-ease);
}

/* === Date === */

.tpx-news__date {
	display: flex;
	align-items: center;
	gap: 8px;
	color: var(--tpx-news-date-color);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	margin: 0;
}

/* Drawn rather than an icon font, so it needs no webfont and cannot arrive late. */
.tpx-news__marker {
	flex: none;
	width: 0;
	height: 0;
	border-top: 5px solid transparent;
	border-bottom: 5px solid transparent;
	border-left: 7px solid var(--tpx-news-marker-color);
	transition: transform var(--tpx-news-speed) var(--tpx-news-ease);
}

.tpx-news__item:hover .tpx-news__marker,
.tpx-news__item:has(.tpx-news__link:focus-visible) .tpx-news__marker {
	transform: translateX(3px);
}

/* === Title === */

.tpx-news__title {
	margin: var(--tpx-news-title-gap) 0 0;
	color: var(--tpx-news-title-color);
	font-size: 20px;
	line-height: 1.35;
	font-weight: 700;
	transition: color var(--tpx-news-speed) var(--tpx-news-ease);
}

.tpx-news__item:hover .tpx-news__title,
.tpx-news__item:has(.tpx-news__link:focus-visible) .tpx-news__title {
	color: var(--tpx-news-title-hover-color);
}

/* === Excerpt === */

.tpx-news__excerpt {
	margin: var(--tpx-news-excerpt-gap) 0 0;
	color: var(--tpx-news-excerpt-color);
	font-size: 15px;
	line-height: 1.6;
	display: -webkit-box;
	-webkit-line-clamp: var(--tpx-news-excerpt-lines);
	line-clamp: var(--tpx-news-excerpt-lines);
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* === Accent rule === */

/* Two classes: Elementor ships `.elementor hr { background: transparent }` at
   specificity (0,1,1), which silently wins over a single class and leaves the
   rule invisible. */
.tpx-news .tpx-news__rule {
	margin-top: var(--tpx-news-rule-gap);
	width: var(--tpx-news-rule-width);
	height: var(--tpx-news-rule-height);
	background-color: var(--tpx-news-rule-color);
	border: 0;
	border-radius: calc(var(--tpx-news-rule-height) / 2);
	/* Width is a layout property, but this one is deliberate: the rule is
	   absolutely sized and has no siblings on its line, so growing it reflows
	   nothing around it. */
	transition: width var(--tpx-news-speed) var(--tpx-news-ease);
}

.tpx-news .tpx-news__item:hover .tpx-news__rule,
.tpx-news .tpx-news__item:has(.tpx-news__link:focus-visible) .tpx-news__rule {
	width: var(--tpx-news-rule-hover-width);
}

/* === Entrance ===
   The opt-in class is added by script. Without it every item is visible, so a
   page where the script fails or never runs still shows all its news. */

.tpx-news__list.is-animatable > .tpx-news__item {
	opacity: 0;
	/* `translate`, not `transform`. The entrance and the hover lift are two
	   different motions on the same element; sharing `transform` meant the
	   entrance end state -- at specificity (0,4,0) -- silently pinned the card
	   in place and the hover lift never happened. These two properties compose
	   instead of overriding each other. */
	translate: 0 12px;
	transition:
		opacity 420ms var(--tpx-news-ease),
		translate 420ms var(--tpx-news-ease);
	transition-delay: var(--tpx-news-enter-delay, 0ms);
}

.tpx-news__list.is-animatable > .tpx-news__item.is-in {
	opacity: 1;
	translate: 0 0;
}

/* === Empty and editor states === */

.tpx-news__empty {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 20px;
	border: 1px dashed #c3c4c7;
	border-radius: 4px;
	color: #50575e;
	font-size: 13px;
	line-height: 1.5;
}

/* === Responsive ===
   Columns are a layout decision, so they step at breakpoints; the widget
   overrides these per device through Elementor's own breakpoint controls. */

@media (max-width: 1024px) {
	.tpx-news {
		--tpx-news-column-gap: 32px;
	}
}

@media (max-width: 767px) {
	.tpx-news__list {
		grid-template-columns: minmax(0, 1fr);
	}

	.tpx-news {
		--tpx-news-row-gap: 32px;
	}

	.tpx-news__title {
		font-size: 18px;
	}
}

/* === Reduced motion ===
   Movement goes; every state change stays, and happens at once. */

@media (prefers-reduced-motion: reduce) {
	.tpx-news__item,
	.tpx-news__title,
	.tpx-news .tpx-news__rule,
	.tpx-news__marker,
	.tpx-news__thumb > img,
	.tpx-news__list.is-animatable > .tpx-news__item {
		transition-duration: 1ms !important;
		transition-delay: 0ms !important;
	}

	.tpx-news__item:hover,
	.tpx-news__item:has(.tpx-news__link:focus-visible) {
		transform: none;
	}

	.tpx-news__list.is-animatable > .tpx-news__item {
		opacity: 1;
		translate: 0 0;
	}

	.tpx-news__item:hover .tpx-news__marker,
	.tpx-news__item:has(.tpx-news__link:focus-visible) .tpx-news__marker {
		transform: none;
	}
}

/* ==========================================================================
   Archive and single templates
   ========================================================================== */

.tpx-news-archive {
	padding-block: 8px 48px;
}

.tpx-news-archive__pagination {
	margin-top: 48px;
}

.tpx-news-archive__pagination .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 40px;
	height: 40px;
	padding: 0 12px;
	margin: 0 4px;
	border-radius: 4px;
	color: var(--tpx-news-title-color, #820606);
	background-color: #f3f4f6;
	text-decoration: none;
	font-weight: 600;
	transition: background-color var(--tpx-news-speed, 200ms) ease, color var(--tpx-news-speed, 200ms) ease;
}

.tpx-news-archive__pagination .page-numbers:hover,
.tpx-news-archive__pagination .page-numbers:focus-visible {
	background-color: #e5e7eb;
}

.tpx-news-archive__pagination .page-numbers.current {
	background-color: var(--tpx-news-rule-color, #820606);
	color: #fff;
}

.tpx-news-archive__pagination .page-numbers:focus-visible {
	outline: 2px solid var(--tpx-news-rule-color, #820606);
	outline-offset: 2px;
}

/* --- Single --- */

.tpx-news-single {
	padding-block: 8px 48px;
}

.tpx-news-single__meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	color: var(--tpx-news-date-color, #6b7280);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	margin-bottom: 20px;
}

.tpx-news-single__status {
	padding: 3px 10px;
	border-radius: 999px;
	background-color: #fef3c7;
	color: #92400e;
	letter-spacing: 0.04em;
}

.tpx-news-single__figure {
	margin: 0 0 28px;
	border-radius: 6px;
	overflow: hidden;
	background-color: #e9eaec;
}

.tpx-news-single__figure > img {
	width: 100%;
	height: auto;
	display: block;
}

.tpx-news-single__content {
	color: #374151;
	line-height: 1.75;
	max-width: 68ch;
}

.tpx-news-single__content > * + * {
	margin-top: 1.1em;
}

.tpx-news .tpx-news-single__rule,
.tpx-news-single__rule {
	width: var(--tpx-news-rule-width, 28px);
	height: var(--tpx-news-rule-height, 3px);
	background-color: var(--tpx-news-rule-color, #820606);
	border: 0;
	border-radius: 2px;
	margin: 32px 0;
}

/* --- Prev / next --- */

.tpx-news-nav {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 24px;
	margin-top: 8px;
}

@media (max-width: 767px) {
	.tpx-news-nav {
		grid-template-columns: minmax(0, 1fr);
	}
}

.tpx-news-nav__label {
	display: block;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--tpx-news-date-color, #6b7280);
	margin-bottom: 6px;
}

.tpx-news-nav__item--next {
	text-align: right;
}

/* text-align only moves inline content. The date is a flex row and the rule is
   a fixed-width block, so both need aligning explicitly or the Next card ends
   up with a right-aligned title over a left-aligned date and rule. */
.tpx-news-nav__item--next .tpx-news__date {
	justify-content: flex-end;
}

.tpx-news-nav__item--next .tpx-news .tpx-news__rule,
.tpx-news-nav__item--next .tpx-news__rule {
	margin-left: auto;
}

/* The marker is a triangle pointing right; on the Previous card it should
   point back the way the link goes. */
.tpx-news-nav__item--prev .tpx-news__marker {
	transform: scaleX(-1);
}

.tpx-news-nav__item--prev .tpx-news__item:hover .tpx-news__marker,
.tpx-news-nav__item--prev .tpx-news__item:has(.tpx-news__link:focus-visible) .tpx-news__marker {
	transform: scaleX(-1) translateX(3px);
}

@media (max-width: 767px) {
	.tpx-news-nav__item--next {
		text-align: left;
	}

	.tpx-news-nav__item--next .tpx-news__date {
		justify-content: flex-start;
	}

	.tpx-news-nav__item--next .tpx-news__rule {
		margin-left: 0;
	}
}

.tpx-news-back {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin-top: 40px;
	font-weight: 600;
	color: var(--tpx-news-title-color, #820606);
	text-decoration: none;
	transition: gap var(--tpx-news-speed, 200ms) ease;
}

.tpx-news-back:hover,
.tpx-news-back:focus-visible {
	gap: 14px;
}

.tpx-news-back:focus-visible {
	outline: 2px solid var(--tpx-news-rule-color, #820606);
	outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
	.tpx-news-back {
		transition-duration: 1ms !important;
	}
}
