/*
 * Swipe feed + cards (Workstream A).
 *
 * Tokens only (assets/css/tokens.css) — no hard-coded colours.
 * Without JS the track is a native scroll-snap row; feed.js adds .is-enhanced
 * and positions every slide with transforms (custom gesture engine).
 *
 * Geometry variables live on .tpb-main--feed so siblings (C's player) can
 * align with the cards:
 *   --tpb-feed-pad-x    side gutter of the card area
 *   --tpb-feed-pad-top  space between header/heading and cards
 *   --tpb-feed-dock     height of the strip under the cards (progress + player pill)
 *   --tpb-feed-gap      space between cards            (px only — read by feed.js)
 *   --tpb-feed-max-h    max card height, or none       (px only — read by feed.js)
 */

/* -------------------------------------------------------------------------
 * Page frame: the feed fills the viewport below the header.
 * ---------------------------------------------------------------------- */

.tpb-main--feed {
	--tpb-feed-pad-x: 10px;
	--tpb-feed-pad-top: 8px;
	--tpb-feed-dock: calc(60px + env(safe-area-inset-bottom, 0px));
	--tpb-feed-gap: 14px;
	--tpb-feed-max-h: none;
	--tpb-feed-per-view: 1;
	--tpb-card-pad: 26px 22px 24px;
	--tpb-excerpt-lines: 11;

	position: relative;
	display: flex;
	flex-direction: column;
	height: calc(100vh - var(--tpb-header-h) - var(--wp-admin--admin-bar--height, 0px) - var(--tpb-footer-h, 0px));
	height: calc(100dvh - var(--tpb-header-h) - var(--wp-admin--admin-bar--height, 0px) - var(--tpb-footer-h, 0px));
	min-height: 420px;
}

@media (min-width: 768px) {
	.tpb-main--feed {
		--tpb-feed-pad-x: 64px;
		--tpb-feed-pad-top: 20px;
		--tpb-feed-dock: 68px;
		--tpb-feed-gap: 20px;
		--tpb-feed-max-h: 860px;
		--tpb-feed-per-view: 2;
		--tpb-card-pad: 32px 30px 28px;
		--tpb-excerpt-lines: 10;
	}
}

@media (min-width: 1200px) {
	.tpb-main--feed {
		--tpb-feed-pad-x: 88px;
		--tpb-feed-pad-top: 24px;
		--tpb-feed-dock: 76px;
		--tpb-feed-gap: 24px;
		--tpb-feed-max-h: 820px;
		--tpb-card-pad: 44px 48px 36px;
		--tpb-excerpt-lines: 9;
	}

	.tpb-desktop-cards-4 .tpb-main--feed {
		--tpb-feed-pad-x: 76px;
		--tpb-feed-gap: 18px;
		--tpb-feed-max-h: 680px;
		--tpb-feed-per-view: 4;
		--tpb-card-pad: 28px 26px 26px;
		--tpb-excerpt-lines: 10;
	}
}

/* One card (tablet + desktop): a single centred card at reading width;
 * neighbours peek in the side gutters and the arrows sit close to the card. */
@media (min-width: 768px) {
	.tpb-desktop-cards-1 .tpb-main--feed {
		--tpb-feed-pad-x: max(64px, calc((100% - 760px) / 2));
		--tpb-feed-per-view: 1;
		--tpb-feed-max-h: 720px;
	}

	.tpb-desktop-cards-1 .tpb-feed__arrow--prev {
		left: max(6px, calc(var(--tpb-feed-pad-x) - var(--tpb-arrow-size) - 28px));
	}

	.tpb-desktop-cards-1 .tpb-feed__arrow--next {
		right: max(6px, calc(var(--tpb-feed-pad-x) - var(--tpb-arrow-size) - 28px));
	}
}

/* Short phones: keep everything on one card without scrolling. */
@media (max-width: 767.98px) and (max-height: 700px) {
	.tpb-main--feed {
		--tpb-card-pad: 22px 20px 20px;
		--tpb-excerpt-lines: 7;
	}
}

@media (max-width: 767.98px) and (max-height: 580px) {
	.tpb-main--feed {
		--tpb-excerpt-lines: 5;
	}
}

/* -------------------------------------------------------------------------
 * Archive heading (archive.php)
 * ---------------------------------------------------------------------- */

.tpb-archive-head {
	flex: 0 0 auto;
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 2px var(--tpb-space-3);
	padding: var(--tpb-space-4) calc(var(--tpb-feed-pad-x) + 4px) 0;
}

.tpb-archive-head__kicker {
	margin: 0;
	color: var(--tpb-muted);
	font-size: var(--tpb-fs-eyebrow);
	font-weight: 600;
	letter-spacing: var(--tpb-tracking-eyebrow);
	text-transform: uppercase;
}

.tpb-archive-head__title {
	margin: 0;
	font-family: var(--tpb-font-display);
	font-size: clamp(1.25rem, 1rem + 1vw, 1.75rem);
	font-weight: 700;
	line-height: 1.15;
	letter-spacing: var(--tpb-tracking-title);
}

.tpb-archive-head__all {
	margin-left: auto;
	color: var(--tpb-accent);
	font-size: var(--tpb-fs-meta);
	font-weight: 600;
	text-decoration: none;
}

.tpb-archive-head__all:hover {
	text-decoration: underline;
	text-underline-offset: 3px;
}

/* -------------------------------------------------------------------------
 * Feed frame
 * ---------------------------------------------------------------------- */

.tpb-feed {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
	isolation: isolate;
}

.tpb-feed__viewport {
	position: absolute;
	inset: 0;
	overflow: hidden;
}

.tpb-feed__track {
	position: absolute;
	top: var(--tpb-feed-pad-top);
	right: var(--tpb-feed-pad-x);
	bottom: var(--tpb-feed-dock);
	left: var(--tpb-feed-pad-x);
	margin: 0;
	padding: 0;
}

/* Phones: a little air between the card and the music strip below it. */
@media (max-width: 767.98px) {
	.tpb-feed__track {
		bottom: calc(var(--tpb-feed-dock) + 5px);
	}
}

/* -------------------------------------------------------------------------
 * Search bar above search-result feeds (search.php)
 * ---------------------------------------------------------------------- */

.tpb-searchbar {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: var(--tpb-space-3);
	margin: 0;
	padding: var(--tpb-space-3) calc(var(--tpb-feed-pad-x) + 4px) 0;
}

.tpb-searchbar__field {
	position: relative;
	display: flex;
	flex: 1 1 auto;
	align-items: center;
	min-width: 0;
	max-width: 560px;
}

.tpb-searchbar__icon {
	position: absolute;
	left: 14px;
	color: var(--tpb-muted);
	pointer-events: none;
}

.tpb-searchbar__input {
	width: 100%;
	height: 40px;
	padding: 0 40px 0 40px;
	border: 0;
	border-radius: var(--tpb-radius-pill);
	background: var(--tpb-surface);
	box-shadow: inset 0 0 0 1px var(--tpb-hairline), var(--tpb-shadow-sm);
	color: var(--tpb-text);
	font: inherit;
	font-size: 1rem; /* 16px: no iOS zoom on focus */
	-webkit-appearance: none;
	appearance: none;
	transition: box-shadow var(--tpb-dur-fast) var(--tpb-ease-out);
}

.tpb-searchbar__input::-webkit-search-cancel-button {
	-webkit-appearance: none;
	appearance: none;
}

.tpb-searchbar__input::placeholder {
	color: var(--tpb-muted);
}

.tpb-searchbar__input:focus {
	outline: none;
	box-shadow: inset 0 0 0 1.5px var(--tpb-accent), 0 0 0 4px color-mix(in srgb, var(--tpb-accent) 18%, transparent);
}

.tpb-searchbar__clear {
	position: absolute;
	right: 8px;
	display: grid;
	place-items: center;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: var(--tpb-tag-bg);
	color: var(--tpb-muted);
	transition: background-color var(--tpb-dur-fast) var(--tpb-ease-out), color var(--tpb-dur-fast) var(--tpb-ease-out);
}

.tpb-searchbar__clear:hover {
	background: var(--tpb-hairline-strong);
	color: var(--tpb-text);
}

.tpb-searchbar__count {
	flex: 0 0 auto;
	margin: 0;
	color: var(--tpb-muted);
	font-size: var(--tpb-fs-meta);
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

@media (min-width: 768px) {
	.tpb-searchbar {
		padding-top: var(--tpb-space-4);
	}
}

/* -------------------------------------------------------------------------
 * Category bar (template-parts/category-bar.php): "All · Markets · …"
 * ---------------------------------------------------------------------- */

.tpb-topics {
	flex: 0 0 auto;
	position: relative;
	z-index: var(--tpb-z-controls);
	padding-top: var(--tpb-space-3);
}

.tpb-topics__scroller {
	position: relative; /* offsetParent for feed.js chip centring */
	overflow-x: auto;
	overflow-y: hidden;
	overscroll-behavior-x: contain;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
	/* Soft fade where chips scroll out of view (alpha mask, theme-independent). */
	-webkit-mask-image: linear-gradient(90deg, transparent 0, #000 var(--tpb-space-4), #000 calc(100% - var(--tpb-space-6)), transparent 100%);
	mask-image: linear-gradient(90deg, transparent 0, #000 var(--tpb-space-4), #000 calc(100% - var(--tpb-space-6)), transparent 100%);
}

.tpb-topics__scroller::-webkit-scrollbar {
	display: none;
}

.tpb-topics__list {
	display: flex;
	gap: var(--tpb-space-2);
	width: max-content;
	margin: 0;
	padding: 2px calc(var(--tpb-feed-pad-x) + 4px) 4px;
	list-style: none;
}

.tpb-topics__chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	height: 34px;
	padding: 0 15px;
	border-radius: var(--tpb-radius-pill);
	background: var(--tpb-surface);
	box-shadow: inset 0 0 0 1px var(--tpb-hairline), var(--tpb-shadow-sm);
	color: var(--tpb-text-2);
	font-size: 0.875rem;
	font-weight: 550;
	line-height: 1;
	letter-spacing: -0.005em;
	text-decoration: none;
	white-space: nowrap;
	transition:
		background-color var(--tpb-dur-fast) var(--tpb-ease-out),
		color var(--tpb-dur-fast) var(--tpb-ease-out),
		box-shadow var(--tpb-dur-fast) var(--tpb-ease-out),
		transform var(--tpb-dur-fast) var(--tpb-ease-out);
	-webkit-tap-highlight-color: transparent;
}

.tpb-topics__chip:hover {
	color: var(--tpb-text);
	box-shadow: inset 0 0 0 1px var(--tpb-hairline-strong), var(--tpb-shadow-sm);
}

.tpb-topics__chip:active {
	transform: scale(0.96);
}

.tpb-topics__chip.is-active {
	background: var(--tpb-text);
	box-shadow: none;
	color: var(--tpb-bg);
}

.tpb-topics__chip--filter svg {
	opacity: 0.7;
}

@media (min-width: 768px) {
	.tpb-topics {
		padding-top: var(--tpb-space-4);
	}
}

@media (prefers-reduced-motion: reduce) {
	.tpb-topics__chip:active {
		transform: none;
	}
}

/* No JS (or before feed.js runs): a native, snap-scrolling row. */
.tpb-feed:not(.is-enhanced) .tpb-feed__track {
	display: flex;
	align-items: center;
	gap: var(--tpb-feed-gap);
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
}

.tpb-feed:not(.is-enhanced) .tpb-feed__track::-webkit-scrollbar {
	display: none;
}

.tpb-feed:not(.is-enhanced) .tpb-feed__slide {
	flex: 0 0 calc((100% - (var(--tpb-feed-per-view) - 1) * var(--tpb-feed-gap)) / var(--tpb-feed-per-view));
	height: 100%;
	max-height: var(--tpb-feed-max-h);
	scroll-snap-align: start;
}

.tpb-feed:not(.is-enhanced) .tpb-feed__arrow,
.tpb-feed:not(.is-enhanced) .tpb-feed__progress,
.tpb-feed:not(.is-enhanced) .tpb-feed__status {
	display: none;
}

/* Enhanced: feed.js owns position via transforms. */
.tpb-feed.is-enhanced .tpb-feed__track {
	isolation: isolate;
}

.tpb-feed.is-enhanced .tpb-feed__slide {
	position: absolute;
	top: var(--tpb-slide-top, 0px);
	left: 0;
	width: var(--tpb-slide-w, 100%);
	height: var(--tpb-slide-h, 100%);
	transform-origin: 50% 50%;
	backface-visibility: hidden;
}

.tpb-feed.is-enhanced .tpb-feed__slide:not(.is-near) {
	visibility: hidden;
}

.tpb-feed.is-enhanced .tpb-feed__slide.is-near {
	will-change: transform, opacity;
}

.tpb-feed.is-enhanced .tpb-feed__slide.is-near .tpb-card__content {
	will-change: transform;
}

/* Reels-style stack: the outgoing card recedes toward the top, the incoming
   one rises from behind the dock (the strip that holds the player pill). */
.tpb-feed.is-vertical .tpb-feed__viewport {
	bottom: var(--tpb-feed-dock);
}

.tpb-feed.is-vertical .tpb-feed__track {
	bottom: 0;
}

.tpb-feed.is-vertical .tpb-feed__slide {
	transform-origin: 50% 0%;
}

.tpb-feed.is-horizontal .tpb-feed__viewport {
	cursor: grab;
	touch-action: pan-y pinch-zoom;
}

.tpb-feed.is-vertical .tpb-feed__viewport {
	touch-action: pinch-zoom;
}

.tpb-feed.is-dragging,
.tpb-feed.is-dragging .tpb-feed__viewport {
	cursor: grabbing;
	-webkit-user-select: none;
	user-select: none;
}

.tpb-feed.is-dragging .tpb-feed__slide {
	pointer-events: none;
}

/* First frame after enhancement: no transitions (content is already painted). */
.tpb-feed.is-booting *,
.tpb-feed.is-booting *::before,
.tpb-feed.is-booting *::after {
	transition: none !important;
}

/* -------------------------------------------------------------------------
 * Card
 * ---------------------------------------------------------------------- */

.tpb-card {
	position: relative;
	isolation: isolate;
	margin: 0;
	color: var(--tpb-text);
}

.tpb-card:focus,
.tpb-card:focus-visible {
	outline: none;
}

/* Lift shadow, faded in on hover (opacity only — no shadow repaint per frame). */
.tpb-card::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	border-radius: var(--tpb-radius-card);
	box-shadow: var(--tpb-shadow-lift);
	opacity: 0;
	transition: opacity var(--tpb-dur) var(--tpb-ease-out);
	pointer-events: none;
}

.tpb-card__surface {
	position: relative;
	height: 100%;
	overflow: hidden;
	border-radius: var(--tpb-radius-card);
	background: var(--tpb-surface);
	background:
		radial-gradient(120% 70% at 100% 0%, color-mix(in srgb, var(--tpb-accent) 7%, transparent) 0%, transparent 62%),
		var(--tpb-surface);
	box-shadow: var(--tpb-shadow-card);
	transition: box-shadow var(--tpb-dur-fast) var(--tpb-ease-out);
}

.tpb-card:focus-visible .tpb-card__surface {
	box-shadow: 0 0 0 2px var(--tpb-accent), var(--tpb-shadow-card);
}

@media (hover: hover) and (pointer: fine) {
	.tpb-feed:not(.is-dragging) .tpb-card:hover::before {
		opacity: 1;
	}
}

.tpb-card__content {
	position: relative;
	display: flex;
	flex-direction: column;
	height: 100%;
	padding: var(--tpb-card-pad);
}

/* Meta row: CATEGORY · date */
.tpb-card__meta {
	display: flex;
	flex-wrap: nowrap;
	align-items: center;
	gap: var(--tpb-space-2) var(--tpb-space-3);
	min-height: 1.25rem;
	margin: 0;
	font-size: var(--tpb-fs-eyebrow);
	line-height: 1.2;
}

.tpb-card__eyebrow {
	min-width: 0;
	overflow: hidden;
	color: var(--tpb-accent);
	text-overflow: ellipsis;
	white-space: nowrap;
	font-weight: 650;
	letter-spacing: var(--tpb-tracking-eyebrow);
	text-transform: uppercase;
	text-decoration: none;
}

a.tpb-card__eyebrow:hover {
	text-decoration: underline;
	text-underline-offset: 3px;
}

.tpb-card__eyebrow--ad {
	color: var(--tpb-muted);
}

.tpb-card__date {
	flex: 0 0 auto;
	display: inline-flex;
	white-space: nowrap;
	align-items: center;
	gap: var(--tpb-space-3);
	color: var(--tpb-muted);
	font-size: var(--tpb-fs-meta);
	font-variant-numeric: tabular-nums;
}

.tpb-card__eyebrow + .tpb-card__date::before {
	content: "";
	width: 3px;
	height: 3px;
	border-radius: 50%;
	background: currentColor;
	opacity: 0.7;
}

/* Title sits low on the card, like a magazine cover line. */
.tpb-card__title {
	margin: auto 0 0;
	padding-top: var(--tpb-space-6);
	color: var(--tpb-text);
	font-family: var(--tpb-font-display);
	font-size: var(--tpb-fs-title);
	font-weight: 700;
	line-height: var(--tpb-lh-tight);
	letter-spacing: var(--tpb-tracking-title);
	overflow-wrap: break-word;
	text-wrap: balance;
}

.tpb-card__title a {
	color: inherit;
	text-decoration: none;
	text-decoration-thickness: 2px;
	text-underline-offset: 0.12em;
}

.tpb-card__title a:hover {
	text-decoration-line: underline;
	text-decoration-color: var(--tpb-hairline-strong);
}

.tpb-card__excerpt {
	display: -webkit-box;
	max-width: 40em;
	margin: var(--tpb-space-4) 0 0;
	overflow: hidden;
	color: var(--tpb-text-2);
	font-size: var(--tpb-fs-body);
	line-height: var(--tpb-lh-body);
	text-wrap: pretty;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: var(--tpb-excerpt-lines);
	line-clamp: var(--tpb-excerpt-lines);
}

.tpb-card__excerpt:empty {
	display: none;
}

.tpb-card__foot {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--tpb-space-3) var(--tpb-space-4);
	margin-top: var(--tpb-space-5);
	padding-top: var(--tpb-space-4);
	border-top: 1px solid var(--tpb-hairline);
}

.tpb-card__tags {
	display: flex;
	flex-wrap: wrap;
	gap: var(--tpb-space-2);
	min-width: 0;
	margin: 0;
	padding: 0;
	list-style: none;
}

.tpb-tag {
	display: inline-flex;
	align-items: center;
	min-height: 28px;
	padding: 4px 12px;
	border-radius: var(--tpb-radius-pill);
	background: var(--tpb-tag-bg);
	color: var(--tpb-text-2);
	font-size: var(--tpb-fs-meta);
	font-weight: 500;
	line-height: 1.2;
	text-decoration: none;
	white-space: nowrap;
	transition: background-color var(--tpb-dur-fast) var(--tpb-ease-out), color var(--tpb-dur-fast) var(--tpb-ease-out);
}

a.tpb-tag:hover {
	background: var(--tpb-hairline-strong);
	color: var(--tpb-text);
}

.tpb-card__more {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	margin-left: auto;
	color: var(--tpb-accent);
	font-size: 0.9375rem;
	font-weight: 600;
	text-decoration: none;
	white-space: nowrap;
}

.tpb-card__more-icon {
	width: 16px;
	height: 16px;
	transition: transform var(--tpb-dur-fast) var(--tpb-ease-out);
}

.tpb-card__more:hover .tpb-card__more-icon,
.tpb-card__more:focus-visible .tpb-card__more-icon {
	transform: rotate(-14deg) scale(1.06);
}

/* Narrow cards (phones, 4-up desktop): compact title, stacked foot. */
@media (max-width: 767.98px) {
	.tpb-card__excerpt {
		font-size: 1rem;
	}
}

@media (min-width: 768px) and (max-width: 1199.98px) {
	.tpb-card__title {
		font-size: var(--tpb-fs-title-compact);
	}
}

@media (min-width: 1200px) {
	.tpb-desktop-cards-4 .tpb-card__title {
		font-size: var(--tpb-fs-title-compact);
	}

	.tpb-desktop-cards-4 .tpb-card__excerpt {
		font-size: 0.9375rem;
	}

	.tpb-desktop-cards-4 .tpb-card__foot {
		flex-direction: column;
		align-items: flex-start;
	}

	.tpb-desktop-cards-4 .tpb-card__more {
		margin-left: 0;
	}
}

/* Meta row: [category · time] on the left, signal badge pinned top-right. */
.tpb-card__content {
	container: tpb-card / inline-size;
}

.tpb-card__meta-main {
	display: flex;
	flex: 1 1 auto;
	align-items: center;
	gap: var(--tpb-space-2) var(--tpb-space-3);
	min-width: 0;
}

.tpb-card__meta {
	align-items: flex-start;
	gap: var(--tpb-space-3);
}

.tpb-card__meta > .tpb-card__meta-main {
	min-height: 24px; /* = badge height, keeps both vertically centred on one line */
}

/* Narrow card + badge: stack category and time instead of truncating the category. */
@container tpb-card (max-width: 380px) {
	.tpb-card__meta:has(.tpb-signal) .tpb-card__meta-main {
		flex-direction: column;
		align-items: flex-start;
		justify-content: center;
		gap: 2px;
	}

	.tpb-card__meta:has(.tpb-signal) .tpb-card__eyebrow + .tpb-card__date::before {
		display: none;
	}
}

/* Signal badge (inc/signals.php): top-right of the meta row. */
.tpb-signal {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	height: 24px;
	margin-left: auto;
	padding: 0 10px 0 8px;
	border-radius: var(--tpb-radius-pill);
	background: color-mix(in srgb, var(--tpb-signal) 13%, var(--tpb-surface));
	box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tpb-signal) 22%, transparent);
	color: color-mix(in srgb, var(--tpb-signal) 72%, var(--tpb-text));
	font-size: 0.6875rem;
	font-weight: 650;
	line-height: 1;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	white-space: nowrap;
	max-width: 62%;
	overflow: hidden;
	text-overflow: ellipsis;
}

:root[data-theme="dark"] .tpb-signal {
	background: color-mix(in srgb, var(--tpb-signal) 22%, var(--tpb-surface));
	color: color-mix(in srgb, var(--tpb-signal) 55%, var(--tpb-text));
}

.tpb-signal__dot {
	position: relative;
	flex: 0 0 6px;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--tpb-signal);
}

/* High impact: a slow, quiet pulse. */
.tpb-signal--high-impact .tpb-signal__dot::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: 50%;
	background: var(--tpb-signal);
	animation: tpb-signal-pulse 2.4s var(--tpb-ease-out) infinite;
}

@keyframes tpb-signal-pulse {
	0% { transform: scale(1); opacity: 0.6; }
	70%, 100% { transform: scale(2.8); opacity: 0; }
}

/* On photos: frosted glass, white text, coloured dot. */
.tpb-card--image .tpb-signal {
	background: rgb(0 0 0 / 0.32);
	box-shadow: inset 0 0 0 1px var(--tpb-on-media-hairline);
	color: var(--tpb-on-media);
	text-shadow: none;
	-webkit-backdrop-filter: var(--tpb-blur);
	backdrop-filter: var(--tpb-blur);
}

@media (prefers-reduced-motion: reduce) {
	.tpb-signal--high-impact .tpb-signal__dot::after {
		animation: none;
	}
}

/* Coloured corner highlight (setting "Coloured card accents" → body.tpb-card-colors;
 * feed.js gives every article card a random .tpb-hue-N from tokens.css). Same card as
 * the original design — white / dark surface — only the top-right glow changes colour. */
.tpb-card-colors .tpb-card[class*="tpb-hue-"]:not(.tpb-card--image) .tpb-card__surface {
	background:
		radial-gradient(120% 70% at 100% 0%, color-mix(in srgb, var(--tpb-card-hue) var(--tpb-hue-highlight), transparent) 0%, transparent 62%),
		var(--tpb-surface);
}

/* -------------------------------------------------------------------------
 * Image cards: featured image as a full-bleed background (.tpb-card--image).
 * The photo layer is oversized so feed.js can drift it (parallax) without
 * showing edges; the active card zooms very slowly (Ken Burns).
 * ---------------------------------------------------------------------- */

.tpb-card--image .tpb-card__surface {
	background: var(--tpb-media-base);
}

.tpb-card__media {
	position: absolute;
	inset: -6%;
	z-index: 0;
	overflow: hidden;
	pointer-events: none;
}

.tpb-card__img {
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
	transform: scale(1.02);
	transform-origin: 50% 40%;
}

.tpb-card--image.is-current .tpb-card__img {
	animation: tpb-kenburns 26s var(--tpb-ease-out) both;
}

@keyframes tpb-kenburns {
	from { transform: scale(1.02); }
	to { transform: scale(1.1); }
}

/* Readability gradient: strong at the bottom (text), light at the top (eyebrow). */
.tpb-card__media::after {
	content: "";
	position: absolute;
	inset: 0;
	background:
		linear-gradient(
			to top,
			rgb(0 0 0 / calc(var(--tpb-card-scrim) * 1.25)) 0%,
			rgb(0 0 0 / var(--tpb-card-scrim)) 38%,
			rgb(0 0 0 / calc(var(--tpb-card-scrim) * 0.35)) 68%,
			rgb(0 0 0 / calc(var(--tpb-card-scrim) * 0.45)) 100%
		);
}

.tpb-card--image .tpb-card__content {
	z-index: 1;
	color: var(--tpb-on-media);
	text-shadow: 0 1px 12px rgb(0 0 0 / 0.25);
}

.tpb-card--image .tpb-card__eyebrow,
.tpb-card--image .tpb-card__title,
.tpb-card--image .tpb-card__more {
	color: var(--tpb-on-media);
}

.tpb-card--image .tpb-card__date {
	color: var(--tpb-on-media-muted);
}

.tpb-card--image .tpb-card__excerpt {
	color: var(--tpb-on-media-2);
}

.tpb-card--image .tpb-card__title a:hover {
	text-decoration-color: var(--tpb-on-media-hairline);
}

.tpb-card--image .tpb-card__foot {
	border-top-color: var(--tpb-on-media-hairline);
}

.tpb-card--image .tpb-tag {
	background: var(--tpb-on-media-tag);
	color: var(--tpb-on-media);
	text-shadow: none;
	-webkit-backdrop-filter: var(--tpb-blur);
	backdrop-filter: var(--tpb-blur);
}

.tpb-card--image a.tpb-tag:hover {
	background: var(--tpb-on-media-tag-hover);
	color: var(--tpb-on-media);
}

@media (prefers-reduced-motion: reduce) {
	.tpb-card--image.is-current .tpb-card__img {
		animation: none;
	}
}

.tpb-motion-subtle .tpb-card--image.is-current .tpb-card__img {
	animation-duration: 40s;
}

/* -------------------------------------------------------------------------
 * Staggered text reveal (feed.js toggles .is-revealed as a card enters)
 * ---------------------------------------------------------------------- */

.tpb-feed {
	--tpb-reveal-y: 16px;
	--tpb-stagger: 70ms;
}

.tpb-motion-subtle .tpb-feed {
	--tpb-reveal-y: 6px;
	--tpb-stagger: 35ms;
}

.tpb-feed.is-enhanced .tpb-card__content > * {
	opacity: 0;
	transform: translate3d(0, var(--tpb-reveal-y), 0);
}

.tpb-feed.is-enhanced .tpb-feed__slide.is-revealed .tpb-card__content > * {
	opacity: 1;
	transform: none;
	transition:
		opacity var(--tpb-dur-slow) var(--tpb-ease-out),
		transform var(--tpb-dur-slow) var(--tpb-ease-out);
	transition-delay: calc(var(--tpb-stagger) * var(--tpb-i, 0));
}

.tpb-card__content > :nth-child(2) { --tpb-i: 1; }
.tpb-card__content > :nth-child(3) { --tpb-i: 2; }
.tpb-card__content > :nth-child(4) { --tpb-i: 3; }
.tpb-card__content > :nth-child(5) { --tpb-i: 4; }

/* -------------------------------------------------------------------------
 * Ad slide
 * ---------------------------------------------------------------------- */

.tpb-card--ad .tpb-card__surface {
	background: var(--tpb-surface-2);
}

.tpb-ad {
	display: flex;
	flex: 1 1 auto;
	align-items: center;
	justify-content: center;
	min-height: 0;
	margin-top: var(--tpb-space-4);
	overflow: hidden;
}

.tpb-ad > * {
	max-width: 100%;
}

.tpb-ad ins.adsbygoogle {
	width: 100%;
}

/* -------------------------------------------------------------------------
 * End slide ("You are all caught up.")
 * ---------------------------------------------------------------------- */

.tpb-card--end .tpb-card__content {
	align-items: center;
	justify-content: center;
	text-align: center;
}

.tpb-card__end-mark {
	display: grid;
	place-items: center;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: var(--tpb-tag-bg);
	background: color-mix(in srgb, var(--tpb-accent) 12%, transparent);
	color: var(--tpb-accent);
}

.tpb-card__end-mark svg {
	width: 26px;
	height: 26px;
}

.tpb-card--end .tpb-card__title {
	margin: var(--tpb-space-5) 0 0;
	padding: 0;
	font-size: var(--tpb-fs-title-compact);
}

.tpb-card__end-text {
	max-width: 28em;
	margin: var(--tpb-space-3) 0 0;
	color: var(--tpb-muted);
	font-size: var(--tpb-fs-body);
}

.tpb-card__restart {
	margin-top: var(--tpb-space-6);
	padding: 12px 22px;
	border: 0;
	border-radius: var(--tpb-radius-pill);
	background: var(--tpb-accent);
	color: var(--tpb-accent-contrast);
	font-size: 0.9375rem;
	font-weight: 600;
	cursor: pointer;
	transition: transform var(--tpb-dur-fast) var(--tpb-ease-out), opacity var(--tpb-dur-fast) var(--tpb-ease-out);
}

.tpb-card__restart:hover {
	opacity: 0.9;
}

.tpb-card__restart:active {
	transform: scale(0.97);
}

/* -------------------------------------------------------------------------
 * Arrows
 * ---------------------------------------------------------------------- */

.tpb-feed__arrow {
	--tpb-arrow-size: 48px;
	--tpb-arrow-from: 0px;
	position: absolute;
	top: calc(var(--tpb-feed-pad-top) + (100% - var(--tpb-feed-pad-top) - var(--tpb-feed-dock)) / 2);
	z-index: var(--tpb-z-controls);
	display: grid;
	place-items: center;
	width: var(--tpb-arrow-size);
	height: var(--tpb-arrow-size);
	margin: calc(var(--tpb-arrow-size) / -2) 0 0;
	padding: 0;
	border: 1px solid var(--tpb-hairline);
	border-radius: 50%;
	background: var(--tpb-glass);
	-webkit-backdrop-filter: var(--tpb-blur);
	backdrop-filter: var(--tpb-blur);
	box-shadow: var(--tpb-shadow-sm);
	color: var(--tpb-text);
	cursor: pointer;
	opacity: 0.78;
	transition:
		opacity var(--tpb-dur) var(--tpb-ease-out),
		transform var(--tpb-dur) var(--tpb-ease-spring),
		background-color var(--tpb-dur-fast) var(--tpb-ease-out);
	-webkit-tap-highlight-color: transparent;
}

.tpb-feed__arrow svg {
	width: 20px;
	height: 20px;
	transition: transform var(--tpb-dur-fast) var(--tpb-ease-out);
}

.tpb-feed__arrow--prev {
	--tpb-arrow-from: -14px;
	left: max(6px, calc((var(--tpb-feed-pad-x) - var(--tpb-arrow-size)) / 2));
}

.tpb-feed__arrow--next {
	--tpb-arrow-from: 14px;
	right: max(6px, calc((var(--tpb-feed-pad-x) - var(--tpb-arrow-size)) / 2));
}

/* Glide in once the engine is live. */
@keyframes tpb-arrow-in {
	from {
		opacity: 0;
		transform: translate3d(var(--tpb-arrow-from), 0, 0) scale(0.9);
	}
}

.tpb-feed.is-enhanced.is-horizontal .tpb-feed__arrow {
	animation: tpb-arrow-in var(--tpb-dur-slow) var(--tpb-ease-out) 200ms backwards;
}

.tpb-feed:hover .tpb-feed__arrow,
.tpb-feed__arrow:focus-visible {
	opacity: 1;
}

@media (hover: hover) {
	.tpb-feed__arrow:hover {
		transform: scale(1.07);
		background: var(--tpb-surface);
	}

	.tpb-feed__arrow--prev:hover svg {
		transform: translateX(-2px);
	}

	.tpb-feed__arrow--next:hover svg {
		transform: translateX(2px);
	}
}

.tpb-feed__arrow:active {
	transform: scale(0.93);
	transition-duration: var(--tpb-dur-fast);
}

.tpb-feed__arrow[aria-disabled="true"],
.tpb-feed:hover .tpb-feed__arrow[aria-disabled="true"] {
	opacity: 0.28;
	transform: none;
	cursor: default;
}

/* Click feedback: the chevron nudges in its direction. */
@keyframes tpb-nudge-prev {
	40% { transform: translateX(-4px); }
}

@keyframes tpb-nudge-next {
	40% { transform: translateX(4px); }
}

.tpb-feed__arrow--prev.is-nudge svg {
	animation: tpb-nudge-prev var(--tpb-dur) var(--tpb-ease-out);
}

.tpb-feed__arrow--next.is-nudge svg {
	animation: tpb-nudge-next var(--tpb-dur) var(--tpb-ease-out);
}

/* Phones (vertical reels): swipe is the control. Arrows stay in the tab order
   and appear only when focused with a keyboard / switch device. */
.tpb-feed.is-vertical .tpb-feed__arrow {
	--tpb-arrow-size: 40px;
	right: 18px;
	left: auto;
	opacity: 0;
	pointer-events: none;
}

.tpb-feed.is-vertical .tpb-feed__arrow--prev {
	top: calc(50% - 26px);
}

.tpb-feed.is-vertical .tpb-feed__arrow--next {
	top: calc(50% + 26px);
}

.tpb-feed.is-vertical .tpb-feed__arrow svg {
	transform: rotate(90deg);
}

.tpb-feed.is-vertical .tpb-feed__arrow:focus-visible {
	opacity: 1;
	pointer-events: auto;
}

/* -------------------------------------------------------------------------
 * Progress + loading status
 * ---------------------------------------------------------------------- */

.tpb-feed__progress {
	position: absolute;
	bottom: calc((var(--tpb-feed-dock) - 20px) / 2);
	left: 50%;
	z-index: var(--tpb-z-controls);
	display: flex;
	align-items: center;
	gap: var(--tpb-space-3);
	height: 20px;
	transform: translateX(-50%);
	pointer-events: none;
}

.tpb-feed__progress-track {
	position: relative;
	width: 120px;
	height: 2px;
	overflow: hidden;
	border-radius: 2px;
	background: var(--tpb-hairline-strong);
}

.tpb-feed__progress-fill {
	position: absolute;
	inset: 0;
	border-radius: inherit;
	background: var(--tpb-text);
	transform: scaleX(0);
	transform-origin: 0 50%;
}

.tpb-feed__count {
	color: var(--tpb-muted);
	font-family: var(--tpb-font-mono);
	font-size: 0.75rem;
	font-variant-numeric: tabular-nums;
	letter-spacing: 0.02em;
}

.tpb-feed__count-sep {
	margin: 0 0.4em;
	opacity: 0.5;
}

/* Phones: a hairline rail in the right gutter, like a reel scrubber. */
.tpb-feed.is-vertical .tpb-feed__progress {
	top: calc(var(--tpb-feed-pad-top) + (100% - var(--tpb-feed-pad-top) - var(--tpb-feed-dock)) / 2);
	right: 3px;
	bottom: auto;
	left: auto;
	height: auto;
	transform: translateY(-50%);
}

.tpb-feed.is-vertical .tpb-feed__progress-track {
	width: 2px;
	height: 64px;
}

.tpb-feed.is-vertical .tpb-feed__progress-fill {
	transform: scaleY(0);
	transform-origin: 50% 0;
}

.tpb-feed.is-vertical .tpb-feed__count {
	display: none;
}

.tpb-feed__status {
	position: absolute;
	right: var(--tpb-feed-pad-x);
	bottom: calc((var(--tpb-feed-dock) - 30px) / 2);
	z-index: var(--tpb-z-controls);
	display: inline-flex;
	align-items: center;
	gap: var(--tpb-space-2);
	height: 30px;
	margin: 0;
	padding: 0 12px;
	border-radius: var(--tpb-radius-pill);
	background: var(--tpb-glass);
	-webkit-backdrop-filter: var(--tpb-blur);
	backdrop-filter: var(--tpb-blur);
	box-shadow: var(--tpb-shadow-sm);
	color: var(--tpb-muted);
	font-size: var(--tpb-fs-meta);
	opacity: 0;
	transform: translateY(6px);
	transition: opacity var(--tpb-dur) var(--tpb-ease-out), transform var(--tpb-dur) var(--tpb-ease-out);
	pointer-events: none;
}

.tpb-feed.is-loading.is-near-end .tpb-feed__status {
	opacity: 1;
	transform: none;
}

.tpb-feed.is-vertical .tpb-feed__status {
	top: calc(var(--tpb-feed-pad-top) + 12px);
	right: auto;
	bottom: auto;
	left: 50%;
	transform: translate(-50%, -6px);
}

.tpb-feed.is-vertical.is-loading.is-near-end .tpb-feed__status {
	transform: translate(-50%, 0);
}

.tpb-feed__spinner {
	width: 12px;
	height: 12px;
	border: 1.5px solid var(--tpb-hairline-strong);
	border-top-color: var(--tpb-text);
	border-radius: 50%;
	animation: tpb-spin 0.8s linear infinite;
}

@keyframes tpb-spin {
	to { transform: rotate(360deg); }
}

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

.tpb-feed__empty {
	position: absolute;
	top: var(--tpb-feed-pad-top);
	right: var(--tpb-feed-pad-x);
	bottom: var(--tpb-feed-dock);
	left: var(--tpb-feed-pad-x);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: var(--tpb-space-6);
	border-radius: var(--tpb-radius-card);
	background: var(--tpb-surface);
	box-shadow: var(--tpb-shadow-card);
	text-align: center;
}

.tpb-feed:not(.is-empty) .tpb-feed__empty {
	display: none;
}

.tpb-feed.is-empty .tpb-feed__arrow,
.tpb-feed.is-empty .tpb-feed__progress {
	display: none;
}

.tpb-feed__empty-kicker {
	margin: 0;
	color: var(--tpb-accent);
	font-size: var(--tpb-fs-eyebrow);
	font-weight: 650;
	letter-spacing: var(--tpb-tracking-eyebrow);
	text-transform: uppercase;
}

.tpb-feed__empty-title {
	margin: var(--tpb-space-4) 0 0;
	font-family: var(--tpb-font-display);
	font-size: var(--tpb-fs-title-compact);
	font-weight: 700;
	line-height: var(--tpb-lh-tight);
	letter-spacing: var(--tpb-tracking-title);
}

.tpb-feed__empty-text {
	max-width: 30em;
	margin: var(--tpb-space-3) 0 0;
	color: var(--tpb-muted);
}

.tpb-feed__empty-link {
	margin-top: var(--tpb-space-5);
	color: var(--tpb-accent);
	font-weight: 600;
	text-decoration: none;
}

/* -------------------------------------------------------------------------
 * Reduced motion: no travel, no stagger, no decorative animation.
 * (feed.js also swaps the spring for a short crossfade.)
 * ---------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.tpb-feed.is-enhanced .tpb-card__content > * {
		transform: none;
	}

	.tpb-feed.is-enhanced .tpb-feed__slide.is-revealed .tpb-card__content > * {
		transition: opacity 160ms linear;
		transition-delay: 0ms;
	}

	.tpb-feed__arrow,
	.tpb-feed__arrow svg,
	.tpb-feed.is-enhanced.is-horizontal .tpb-feed__arrow {
		animation: none !important;
		transition: opacity 160ms linear;
	}

	.tpb-feed__arrow:hover,
	.tpb-feed__arrow:active {
		transform: none;
	}

	.tpb-feed__spinner {
		animation-duration: 2.4s;
	}
}

/* -------------------------------------------------------------------------
 * Single article as one large card (single.php) + "More stories"
 * Reuses the card surface, meta row, signal badge, corner glow and tags.
 * ---------------------------------------------------------------------- */

.tpb-main--article-card {
	padding: var(--tpb-space-4) var(--tpb-gutter) var(--tpb-space-8);
}

.tpb-article-wrap {
	max-width: 760px;
	margin: 0 auto;
}

.tpb-article-wrap > .tpb-back {
	margin-bottom: var(--tpb-space-4);
}

.tpb-article-card {
	--tpb-card-pad: 26px 22px 24px;
	margin: 0;
}

.tpb-article-card::before {
	display: none; /* no hover lift on a reading surface */
}

.tpb-article-card__body {
	container: tpb-card / inline-size;
	padding: var(--tpb-card-pad);
}

.tpb-article-card .tpb-card__meta {
	margin-bottom: var(--tpb-space-5);
}

.tpb-article-card__media {
	margin: 0 0 var(--tpb-space-5);
}

.tpb-article-card__media img {
	width: 100%;
	aspect-ratio: 16 / 9;
	border-radius: var(--tpb-radius);
	object-fit: cover;
	background: var(--tpb-tag-bg);
}

.tpb-article-card__media figcaption {
	margin-top: var(--tpb-space-2);
	color: var(--tpb-muted);
	font-size: var(--tpb-fs-meta);
}

.tpb-article-card__title {
	margin: 0 0 var(--tpb-space-5);
	color: var(--tpb-text);
	font-family: var(--tpb-font-display);
	font-size: var(--tpb-fs-title);
	font-weight: 700;
	line-height: var(--tpb-lh-tight);
	letter-spacing: var(--tpb-tracking-title);
	overflow-wrap: break-word;
	text-wrap: balance;
}

.tpb-article-card__content {
	max-width: none;
	margin: 0;
}

.tpb-article-card__foot {
	margin-top: var(--tpb-space-6);
}

.tpb-article-card__foot .tpb-pill {
	margin-left: auto;
}

@media (min-width: 768px) {
	.tpb-main--article-card {
		padding-top: var(--tpb-space-6);
	}

	.tpb-article-card {
		--tpb-card-pad: 40px 48px 36px;
	}
}

/* More stories */
.tpb-related {
	margin-top: var(--tpb-space-7);
}

.tpb-related__title {
	margin: 0 0 var(--tpb-space-4);
	color: var(--tpb-muted);
	font-size: var(--tpb-fs-eyebrow);
	font-weight: 650;
	letter-spacing: var(--tpb-tracking-eyebrow);
	text-transform: uppercase;
}

.tpb-related__grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: var(--tpb-space-4);
}

.tpb-related .tpb-card {
	--tpb-card-pad: 24px 22px 22px;
	--tpb-excerpt-lines: 4;
	height: 360px;
}

.tpb-related .tpb-card__title {
	font-size: var(--tpb-fs-title-compact);
}

@media (min-width: 640px) {
	.tpb-related__grid {
		grid-template-columns: 1fr 1fr;
	}
}
