/**
 * SWR status indicator — paired with [data-swr-status="<section>"] elements.
 *
 * Shows a muted "Updated Xm ago" timestamp, a spinner while revalidating,
 * and an amber "Showing saved data · Retry" pill when the server falls back
 * to stale cache because Omoi couldn't be reached.
 */

.swr-status {
	display: inline-flex;
	align-items: center;
	gap: 0.625rem;
	font-size: 0.8125rem;
	line-height: 1.2;
	color: var(--color-text-2, #666);
	font-style: italic;
	padding: 0.25rem 0;
}

.swr-status__label {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
}

/* Pulsing dot while a background refresh is in flight. */
.swr-status--checking .swr-status__label::before {
	content: "";
	display: inline-block;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--color-gray-mid, #999);
	animation: kd-swr-pulse 1.1s ease-in-out infinite;
}

@keyframes kd-swr-pulse {
	0%, 100% { opacity: 0.35; transform: scale(0.9); }
	50% { opacity: 1; transform: scale(1.05); }
}

/* Amber pill for stale fallbacks (Omoi unreachable). */
.swr-status--stale {
	color: var(--color-orange, #b45309);
}

.swr-status--stale .swr-status__label {
	background: rgba(180, 83, 9, 0.08);
	border-radius: 999px;
	padding: 0.25rem 0.625rem;
}

.swr-status--stale .swr-status__label::before {
	content: "";
	display: inline-block;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: currentColor;
}

/* Brief positive state after a manual refresh succeeds. */
.swr-status--refreshed .swr-status__label {
	color: var(--color-green, #16a34a);
	transition: color 0.4s ease;
}

.swr-status__button {
	font: inherit;
	font-style: normal;
	color: var(--color-text-2, #666);
	background: transparent;
	border: none;
	padding: 0.125rem 0.25rem;
	cursor: pointer;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.swr-status__button:hover,
.swr-status__button:focus-visible {
	color: var(--color-text, #111);
}

.swr-status__button[disabled] {
	opacity: 0.5;
	cursor: default;
	text-decoration: none;
}

.swr-status--stale .swr-status__button {
	color: currentColor;
	font-family: "Maax Medium";
	font-weight: 400;
}

/* Hide status entirely until we have something meaningful to show. */
.swr-status:empty {
	display: none;
}

/* Section-header layout helpers so the status sits next to the title. */
.library__section-header,
.account__section-heading {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 1rem;
	flex-wrap: wrap;
	margin: 0 0 1.5rem;
	padding-bottom: 0.75rem;
	border-bottom: 2px solid var(--color-black);
}

.library__section-header .library__section-title,
.account__section-heading .account__section-title {
	margin: 0;
	padding-bottom: 0;
	border-bottom: 0;
}

/* Highlight animation for newly-arrived items after a background refresh. */
@keyframes kd-swr-item-enter {
	from { background-color: rgba(22, 163, 74, 0.12); }
	to { background-color: transparent; }
}

.swr-item--new {
	animation: kd-swr-item-enter 1.2s ease-out;
}
