/**
 * Infinite Scroll — Styles.
 *
 * Article separators (3 styles), skeleton loader, entrance animations,
 * continue/retry buttons, and height placeholders for removed DOM nodes.
 * Fully RTL-compatible (inherits from main theme) and respects
 * prefers-reduced-motion.
 *
 * @package SY_News
 * @since   1.1.0
 */

/* ─── Custom Properties ──────────────────────────────────────── */
:root {
	--is-separator-bg: var(--color-surface, #f8f9fa);
	--is-separator-border: var(--color-border, #e0e0e0);
	--is-separator-text: var(--color-text-secondary, #5f6368);
	--is-separator-accent: var(--color-primary, #1a73e8);
	--is-skeleton-base: #e9ecef;
	--is-skeleton-shine: #f8f9fa;
	--is-entrance-duration: 600ms;
	--is-btn-radius: 12px;
}

/* Dark mode overrides. */
[data-theme="dark"] {
	--is-separator-bg: var(--color-surface-dark, #1e1e1e);
	--is-separator-border: var(--color-border-dark, #333);
	--is-separator-text: var(--color-text-secondary-dark, #9aa0a6);
	--is-skeleton-base: #2a2a2a;
	--is-skeleton-shine: #3a3a3a;
}

/* ─── Infinite Scroll Root ───────────────────────────────────── */
#infinite-scroll-root {
	position: relative;
}

/* ─── Article Sentinel (Trigger) ─────────────────────────────── */
#infinite-scroll-sentinel {
	height: 1px;
	pointer-events: none;
}

/* ─── Dynamic Share Popup (toggle via JS) ────────────────────── */
.is-article-loaded .is-share-popup {
	display: none;
}

.is-article-loaded .is-share-popup.is-active {
	display: flex;
}

/* ─── Last Updated Footer ────────────────────────────────────── */
.is-article-updated {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 14px 20px;
	margin-top: 20px;
	font-size: 13px;
	color: var(--is-separator-text, #5f6368);
	background: var(--is-separator-bg, #f8f9fa);
	border-radius: 10px;
	border: 1px solid var(--is-separator-border, #e0e0e0);
}

.is-article-updated svg {
	flex-shrink: 0;
	opacity: 0.6;
}

[data-theme="dark"] .is-article-updated {
	background: var(--color-surface-dark, #1e1e1e);
	border-color: var(--color-border-dark, #333);
}

/* ═══════════════════════════════════════════════════════════════
   SEPARATOR — Base (shared by all styles)
   ═══════════════════════════════════════════════════════════════ */
.is-separator {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	padding: 40px 24px;
	margin: 48px 0 30px;
	position: relative;
	overflow: hidden;
}

/* Top accent bar — gradient line that screams "new article". */
.is-separator::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 4px;
	background: linear-gradient(
		90deg,
		var(--is-separator-accent) 0%,
		color-mix(in srgb, var(--is-separator-accent) 60%, #fff) 50%,
		var(--is-separator-accent) 100%
	);
	border-radius: 0 0 4px 4px;
}

/* "Next article" pill badge. */
.is-separator__badge {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 16px;
	border-radius: 50px;
	background: var(--is-separator-accent);
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.3px;
	margin-bottom: 16px;
	animation: is-badge-pulse 2s ease-in-out infinite;
}

.is-separator__badge svg {
	width: 14px;
	height: 14px;
}

@keyframes is-badge-pulse {
	0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--is-separator-accent) 40%, transparent); }
	50% { box-shadow: 0 0 0 8px transparent; }
}

.is-separator__label {
	font-size: 13px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	color: var(--is-separator-accent);
	margin-bottom: 12px;
	display: flex;
	align-items: center;
	gap: 8px;
}

.is-separator__label::before,
.is-separator__label::after {
	content: '';
	display: inline-block;
	width: 20px;
	height: 2px;
	background: var(--is-separator-accent);
	border-radius: 1px;
}

.is-separator__title {
	font-size: 22px;
	font-weight: 800;
	color: var(--color-text, #202124);
	margin: 0 0 14px;
	line-height: 1.5;
	max-width: 600px;
}

[data-theme="dark"] .is-separator__title {
	color: var(--color-text-dark, #e8eaed);
}

.is-separator__meta {
	display: flex;
	align-items: center;
	gap: 16px;
	font-size: 13px;
	font-weight: 500;
	color: var(--is-separator-text);
}

.is-separator__meta-item {
	display: flex;
	align-items: center;
	gap: 5px;
}

.is-separator__meta svg {
	width: 14px;
	height: 14px;
	opacity: 0.6;
}

/* Divider line after separator. */
.is-separator::after {
	content: '';
	position: absolute;
	bottom: 0;
	left: 5%;
	right: 5%;
	height: 1px;
	background: linear-gradient(
		to left,
		transparent,
		var(--is-separator-border),
		transparent
	);
}

/* ═══════════════════════════════════════════════════════════════
   SEPARATOR — Card (elevated, bordered)
   ═══════════════════════════════════════════════════════════════ */
.is-separator--card {
	background: var(--is-separator-bg);
	border: 1px solid var(--is-separator-border);
	border-radius: 20px;
	padding: 36px 28px;
	box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

.is-separator--card::before {
	border-radius: 20px 20px 0 0;
	height: 5px;
}

.is-separator--card::after {
	display: none;
}

/* ═══════════════════════════════════════════════════════════════
   SEPARATOR — Full Width (edge-to-edge banner)
   ═══════════════════════════════════════════════════════════════ */
.is-separator--full-width {
	background: linear-gradient(
		135deg,
		var(--is-separator-bg) 0%,
		color-mix(in srgb, var(--is-separator-accent) 5%, var(--is-separator-bg)) 100%
	);
	border-top: 3px solid var(--is-separator-accent);
	border-bottom: 1px solid var(--is-separator-border);
	border-radius: 0;
	margin-left: calc(-1 * var(--space-md, 16px));
	margin-right: calc(-1 * var(--space-md, 16px));
	padding: 40px 28px;
}

.is-separator--full-width::before {
	display: none; /* border-top already provides accent */
}

.is-separator--full-width::after {
	display: none;
}

.is-separator--full-width .is-separator__title {
	font-size: 24px;
}

.is-reading-label {
	color: var(--color-primary, #1a73e8);
	font-weight: 500;
}

.is-reading-value {
	color: var(--is-separator-text, #5f6368);
}

/* ═══════════════════════════════════════════════════════════════
   SKELETON LOADER
   ═══════════════════════════════════════════════════════════════ */
.is-skeleton {
	padding: 24px 0;
	animation: is-fade-in 300ms ease;
}

.is-skeleton__image {
	width: 100%;
	height: 0;
	padding-bottom: 52.5%;
	border-radius: 16px;
	background: var(--is-skeleton-base);
	position: relative;
	overflow: hidden;
	margin-bottom: 20px;
}

.is-skeleton__image::after {
	content: '';
	position: absolute;
	inset: 0;
	background: linear-gradient(
		90deg,
		transparent 0%,
		var(--is-skeleton-shine) 50%,
		transparent 100%
	);
	animation: is-shimmer 1.5s infinite;
}

.is-skeleton__title {
	height: 22px;
	width: 75%;
	border-radius: 6px;
	background: var(--is-skeleton-base);
	margin-bottom: 12px;
	position: relative;
	overflow: hidden;
}

.is-skeleton__title::after {
	content: '';
	position: absolute;
	inset: 0;
	background: linear-gradient(
		90deg,
		transparent 0%,
		var(--is-skeleton-shine) 50%,
		transparent 100%
	);
	animation: is-shimmer 1.5s infinite 0.1s;
}

.is-skeleton__line {
	height: 14px;
	border-radius: 4px;
	background: var(--is-skeleton-base);
	margin-bottom: 10px;
	position: relative;
	overflow: hidden;
}

.is-skeleton__line::after {
	content: '';
	position: absolute;
	inset: 0;
	background: linear-gradient(
		90deg,
		transparent 0%,
		var(--is-skeleton-shine) 50%,
		transparent 100%
	);
	animation: is-shimmer 1.5s infinite 0.2s;
}

.is-skeleton__line:nth-child(2) { width: 90%; }
.is-skeleton__line:nth-child(3) { width: 65%; }
.is-skeleton__line:nth-child(4) { width: 80%; }

@keyframes is-shimmer {
	0% {
		transform: translateX(-100%);
	}
	100% {
		transform: translateX(100%);
	}
}

/* ═══════════════════════════════════════════════════════════════
   PREPARING TOAST
   ═══════════════════════════════════════════════════════════════ */
.is-preparing-toast {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 14px 28px;
	margin: 24px auto;
	width: fit-content;
	background: var(--is-separator-bg, #f8f9fa);
	border: 1px solid var(--is-separator-border, #e0e0e0);
	border-radius: 50px;
	font-size: 14px;
	font-weight: 500;
	color: var(--is-separator-text, #5f6368);
	animation: is-fade-in 300ms ease;
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .is-preparing-toast {
	background: var(--color-surface-dark, #1e1e1e);
	border-color: var(--color-border-dark, #333);
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.is-preparing-toast__spinner {
	width: 16px;
	height: 16px;
	border: 2.5px solid var(--is-separator-border, #e0e0e0);
	border-top-color: var(--is-separator-accent, #1a73e8);
	border-radius: 50%;
	animation: is-toast-spin 0.7s linear infinite;
}

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

/* ═══════════════════════════════════════════════════════════════
   ARTICLE ENTRANCE ANIMATION
   ═══════════════════════════════════════════════════════════════ */
.is-article-loaded {
	animation: is-article-enter var(--is-entrance-duration) ease both;
}

@keyframes is-article-enter {
	from {
		opacity: 0;
		transform: translateY(30px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* @starting-style for browsers that support it (Chrome 117+). */
@supports (selector(:has(+ *))) {
	.is-article-loaded {
		animation: none;
		opacity: 1;
		transform: translateY(0);
		transition:
			opacity var(--is-entrance-duration) ease,
			transform var(--is-entrance-duration) ease;
	}

	@starting-style {
		.is-article-loaded {
			opacity: 0;
			transform: translateY(30px);
		}
	}
}

/* ═══════════════════════════════════════════════════════════════
   CONTINUE / RETRY / END BUTTONS
   ═══════════════════════════════════════════════════════════════ */
.is-action-area {
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 32px 20px;
	margin: 24px 0;
}

.is-continue-btn,
.is-retry-btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 14px 32px;
	border: none;
	border-radius: var(--is-btn-radius);
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	transition: all 200ms ease;
	font-family: inherit;
}

.is-continue-btn {
	background: var(--is-separator-accent);
	color: #fff;
	box-shadow: 0 4px 14px rgba(26, 115, 232, 0.3);
}

.is-continue-btn:hover {
	transform: translateY(-2px);
	box-shadow: 0 6px 20px rgba(26, 115, 232, 0.4);
}

.is-continue-btn:active {
	transform: translateY(0);
}

.is-continue-btn svg {
	width: 18px;
	height: 18px;
	transition: transform 200ms ease;
}

.is-continue-btn:hover svg {
	transform: translateY(2px);
}

.is-retry-btn {
	background: #fff3cd;
	color: #856404;
	border: 1px solid #ffc107;
}

[data-theme="dark"] .is-retry-btn {
	background: #332b00;
	color: #ffd54f;
	border-color: #665600;
}

.is-retry-btn:hover {
	background: #fff0b3;
}

.is-retry-btn svg {
	width: 16px;
	height: 16px;
}

/* End message. */
.is-end-message {
	text-align: center;
	padding: 24px;
	margin: 24px 0;
	font-size: 14px;
	color: var(--is-separator-text);
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
}

.is-end-message::before,
.is-end-message::after {
	content: '';
	width: 40px;
	height: 1px;
	background: var(--is-separator-border);
}

/* ═══════════════════════════════════════════════════════════════
   HEIGHT PLACEHOLDER (for removed DOM articles)
   ═══════════════════════════════════════════════════════════════ */
.is-height-placeholder {
	pointer-events: none;
	visibility: hidden;
}

/* ═══════════════════════════════════════════════════════════════
   FADE IN UTILITY
   ═══════════════════════════════════════════════════════════════ */
@keyframes is-fade-in {
	from { opacity: 0; }
	to   { opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════
   REDUCED MOTION
   ═══════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
	.is-article-loaded {
		animation: none;
		transition: none;
		opacity: 1;
		transform: none;
	}

	.is-skeleton__image::after,
	.is-skeleton__title::after,
	.is-skeleton__line::after {
		animation: none;
	}

	.is-continue-btn:hover,
	.is-continue-btn:hover svg {
		transform: none;
	}
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
	.is-separator {
		padding: 28px 16px;
		margin: 36px 0 20px;
	}

	.is-separator__title {
		font-size: 18px;
	}

	.is-separator--full-width .is-separator__title {
		font-size: 20px;
	}

	.is-separator__meta {
		flex-wrap: wrap;
		justify-content: center;
		gap: 8px;
	}

	.is-separator__badge {
		font-size: 11px;
		padding: 5px 12px;
	}

	.is-continue-btn {
		width: 100%;
		justify-content: center;
	}

	.is-separator--full-width {
		margin-left: calc(-1 * var(--space-sm, 12px));
		margin-right: calc(-1 * var(--space-sm, 12px));
	}
}
