/* The Mac Observer: live blog feed
 * Newsroom timeline. Time is the structure; the publication is the voice.
 * Targets both the Liveblog React markup (#wpcom-liveblog-container) and the
 * server-rendered fallback (#tmo-liveblog-ssr). Proxima Nova is inherited.
 */

#wpcom-liveblog-container,
#tmo-liveblog-ssr,
.tmo-lb-status {
	--lb-ink: oklch(0.23 0.012 245);
	--lb-ink-2: oklch(0.45 0.02 245);
	--lb-line: oklch(0.9 0.012 245);
	--lb-surface: oklch(0.985 0.004 245);
	--lb-tint: oklch(0.965 0.014 245);
	--lb-blue: oklch(0.42 0.095 240);
	--lb-blue-deep: oklch(0.34 0.09 240);
	--lb-live: oklch(0.62 0.2 25);
	--lb-ease: cubic-bezier(0.22, 1, 0.36, 1);
	--lb-rail: 1.5rem;
	--lb-marker: 0.75rem;
	color: var(--lb-ink);
}

/* ---------- Status line ---------- */

.tmo-lb-status {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	margin: 0 0 1.75rem;
	padding: 0.8125rem 0;
	border-top: 1px solid var(--lb-line);
	border-bottom: 1px solid var(--lb-line);
	font-size: 0.9375rem;
	line-height: 1.3;
	color: var(--lb-ink-2);
}

.tmo-lb-status__dot {
	flex: 0 0 auto;
	width: 0.625rem;
	height: 0.625rem;
	border-radius: 50%;
	background: var(--lb-live);
	animation: tmo-lb-breathe 2.4s var(--lb-ease) infinite;
}

.tmo-lb-status__label {
	flex: 0 0 auto;
	font-size: 0.8125rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--lb-ink);
}

.tmo-lb-status__hint {
	flex: 1 1 auto;
	min-width: 0;
}

.tmo-lb-status__time {
	flex: 0 0 auto;
	font-variant-numeric: tabular-nums;
	font-weight: 600;
	color: var(--lb-ink);
}

.tmo-lb-status.is-archived .tmo-lb-status__dot {
	background: var(--lb-ink-2);
	animation: none;
}

@keyframes tmo-lb-breathe {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.35; }
}

/* ---------- Feed chrome ---------- */

#wpcom-liveblog-container .liveblog-updates-count {
	margin: 0 0 1rem;
	font-size: 0.8125rem;
	color: var(--lb-ink-2);
}

/* "N new entries available": quiet, sticky, one tap. */
#wpcom-liveblog-container .liveblog-update-btn-container {
	position: sticky;
	top: 5.75rem;
	z-index: 5;
	display: flex;
	justify-content: center;
	margin: 0 0 1.25rem;
	pointer-events: none;
}

#wpcom-liveblog-container .liveblog-update-btn {
	pointer-events: auto;
	appearance: none;
	border: 0;
	border-radius: 999px;
	padding: 0.625rem 1.125rem;
	background: var(--lb-blue);
	color: oklch(0.985 0.004 245);
	font: inherit;
	font-size: 0.9375rem;
	font-weight: 700;
	line-height: 1.2;
	cursor: pointer;
	box-shadow: 0 6px 18px -6px oklch(0.34 0.09 240 / 0.55);
	transition: background-color 160ms var(--lb-ease), transform 160ms var(--lb-ease);
}

#wpcom-liveblog-container .liveblog-update-btn:hover,
#wpcom-liveblog-container .liveblog-update-btn:focus-visible {
	background: var(--lb-blue-deep);
	transform: translateY(-1px);
}

#wpcom-liveblog-container .liveblog-update-btn:focus-visible {
	outline: 2px solid var(--lb-blue-deep);
	outline-offset: 3px;
}

/* Pagination: hidden entirely when there is a single page. */
#wpcom-liveblog-container .liveblog-pagination:has(.liveblog-pagination-first.liveblog-btn--hide):has(.liveblog-pagination-last.liveblog-btn--hide) {
	display: none;
}

#wpcom-liveblog-container .liveblog-pagination {
	margin: 0 0 1.5rem;
	padding: 0.5rem 0;
	border-bottom: 1px solid var(--lb-line);
	font-size: 0.875rem;
	color: var(--lb-ink-2);
}

#wpcom-liveblog-container .liveblog-pagination-btn {
	appearance: none;
	border: 1px solid var(--lb-line);
	border-radius: 999px;
	background: transparent;
	color: var(--lb-blue);
	font: inherit;
	font-size: 0.8125rem;
	font-weight: 600;
	padding: 0.375rem 0.875rem;
	cursor: pointer;
}

#wpcom-liveblog-container .liveblog-pagination-btn.liveblog-btn--hide {
	display: none;
}

#wpcom-liveblog-container .liveblog-pagination-pages {
	font-variant-numeric: tabular-nums;
	line-height: 1.6;
}

#wpcom-liveblog-container .liveblog-empty-message {
	padding: 1.5rem 0;
	color: var(--lb-ink-2);
}

/* ---------- Timeline ---------- */

#wpcom-liveblog-container .liveblog-feed,
#tmo-liveblog-ssr .liveblog-feed {
	position: relative;
	min-height: 0;
	padding-left: var(--lb-rail);
}

#wpcom-liveblog-container .liveblog-feed::before,
#tmo-liveblog-ssr .liveblog-feed::before {
	content: "";
	position: absolute;
	top: 0.75rem;
	bottom: 0.75rem;
	left: calc(var(--lb-marker) / 2 - 1px);
	width: 2px;
	background: var(--lb-line);
	border-radius: 1px;
}

#wpcom-liveblog-container .liveblog-feed.is-loading::after {
	background: oklch(0.985 0.004 245 / 0.6);
}

.liveblog-entry {
	position: relative;
	margin: 0 0 1.875rem;
	animation: tmo-lb-in 420ms var(--lb-ease) both;
}

.liveblog-entry:last-child {
	margin-bottom: 0;
}

/* Rail marker */
.liveblog-entry::before {
	content: "";
	position: absolute;
	top: 0.3125rem;
	left: calc(-1 * var(--lb-rail));
	width: var(--lb-marker);
	height: var(--lb-marker);
	box-sizing: border-box;
	border-radius: 50%;
	border: 2px solid var(--lb-blue);
	background: var(--lb-surface);
}

.liveblog-entry.is-key-event::before {
	background: var(--lb-blue);
	box-shadow: 0 0 0 4px var(--lb-tint);
}

/* Time: the only metadata. */
.liveblog-entry-aside {
	margin: 0 0 0.375rem;
	line-height: 1.4;
}

.liveblog-meta-time {
	display: inline-block;
	font-size: 0.9375rem;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	letter-spacing: 0.01em;
	color: var(--lb-blue);
	text-decoration: none;
}

.liveblog-meta-time:hover,
.liveblog-meta-time:focus-visible {
	color: var(--lb-blue-deep);
	text-decoration: underline;
	text-underline-offset: 0.2em;
}

/* React renders [relative time][date]; the site shows clock time only. */
.liveblog-meta-time span {
	display: inline;
}

.liveblog-meta-time span:first-child {
	display: none;
}

/* No bylines in the feed. */
.liveblog-meta-authors,
.liveblog-meta-author,
.liveblog-meta-author-avatar,
.liveblog-meta-author-name {
	display: none !important;
}

/* Body */
.liveblog-entry-main {
	min-width: 0;
}

.liveblog-entry-content,
.liveblog-entry-text {
	max-width: 68ch;
	font-size: 1.0625rem;
	line-height: 1.6;
	color: var(--lb-ink);
	overflow-wrap: anywhere;
}

.liveblog-entry-content > :first-child,
.liveblog-entry-text > :first-child {
	margin-top: 0;
}

.liveblog-entry-content p,
.liveblog-entry-text p {
	margin: 0 0 0.75em;
}

.liveblog-entry-content > :last-child,
.liveblog-entry-text > :last-child {
	margin-bottom: 0;
}

.liveblog-entry-content a,
.liveblog-entry-text a {
	color: var(--lb-blue);
	font-weight: 600;
	text-decoration: underline;
	text-decoration-color: oklch(0.42 0.095 240 / 0.35);
	text-underline-offset: 0.18em;
	transition: text-decoration-color 160ms var(--lb-ease);
}

.liveblog-entry-content a:hover,
.liveblog-entry-text a:hover {
	text-decoration-color: currentColor;
}

.liveblog-entry-content img,
.liveblog-entry-text img {
	display: block;
	max-width: 100%;
	height: auto;
	border-radius: 0.5rem;
	margin: 0.75rem 0;
}

.liveblog-entry-content blockquote,
.liveblog-entry-text blockquote {
	margin: 0.75rem 0;
	padding: 0 0 0 1rem;
	border-left: 1px solid var(--lb-line);
	color: var(--lb-ink-2);
	font-style: italic;
}

.liveblog-entry-content ul,
.liveblog-entry-content ol,
.liveblog-entry-text ul,
.liveblog-entry-text ol {
	margin: 0 0 0.75em 1.25em;
	padding: 0;
}

/* Key moments: tinted block, labelled, larger lead. */
.liveblog-entry.is-key-event .liveblog-entry-main {
	padding: 1rem 1.125rem 1.125rem;
	border-radius: 0.625rem;
	background: var(--lb-tint);
}

.liveblog-entry.is-key-event .liveblog-entry-main::before {
	content: "Key moment";
	display: block;
	margin: 0 0 0.5rem;
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--lb-blue);
}

.liveblog-entry.is-key-event .liveblog-entry-content,
.liveblog-entry.is-key-event .liveblog-entry-text {
	font-size: 1.125rem;
	line-height: 1.55;
}

.liveblog-entry .type-key {
	display: none;
}

/* The "/key" command is stored as its own paragraph; drop that empty line. */
.liveblog-entry-content p:has(> .type-key:only-child),
.liveblog-entry-text p:has(> .type-key:only-child) {
	display: none;
}

/* Editor tools (logged-in authors only) */
.liveblog-entry-tools {
	margin-top: 0.75rem;
}

/* ---------- Key events index (optional widget/shortcode) ---------- */

.liveblog-key-events .liveblog-event-meta {
	display: none;
}

.liveblog-key-events .liveblog-event {
	display: block;
	padding: 0.5rem 0 0.5rem 1rem;
	border-bottom: 1px solid var(--lb-line);
	font-size: 0.9375rem;
	line-height: 1.45;
}

.liveblog-key-events .liveblog-event::before {
	content: "";
	position: absolute;
	left: 0;
	top: 0.95rem;
	width: 0.375rem;
	height: 0.375rem;
	border-radius: 50%;
	background: var(--lb-blue);
}

.liveblog-key-events .liveblog-event-content {
	color: var(--lb-ink);
}

.liveblog-key-events .liveblog-event-content:hover {
	color: var(--lb-blue);
	text-decoration: none;
}

/* ---------- Wider screens: time moves into the rail ---------- */

@media (min-width: 48em) {
	#wpcom-liveblog-container,
	#tmo-liveblog-ssr {
		--lb-rail: 6.75rem;
	}

	#wpcom-liveblog-container .liveblog-feed::before,
	#tmo-liveblog-ssr .liveblog-feed::before {
		left: calc(var(--lb-rail) - 1.5rem + var(--lb-marker) / 2 - 1px);
	}

	.liveblog-entry {
		margin-bottom: 2.25rem;
	}

	.liveblog-entry::before {
		left: -1.5rem;
		top: 0.375rem;
	}

	.liveblog-entry-aside {
		position: absolute;
		top: 0;
		left: calc(-1 * var(--lb-rail));
		width: calc(var(--lb-rail) - 2.5rem);
		margin: 0;
		text-align: right;
	}

	.liveblog-meta-time {
		font-size: 1rem;
	}

	.liveblog-entry.is-key-event .liveblog-entry-main {
		padding: 1.125rem 1.375rem 1.25rem;
	}
}

/* ---------- Motion ---------- */

@keyframes tmo-lb-in {
	from {
		opacity: 0;
		transform: translateY(6px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.liveblog-entry,
	.tmo-lb-status__dot {
		animation: none;
	}

	#wpcom-liveblog-container .liveblog-update-btn {
		transition: none;
	}
}

/* Server-rendered fallback is replaced once the React app has mounted. */
#wpcom-liveblog-container:not(:empty) ~ #tmo-liveblog-ssr {
	display: none;
}
