/**
 * Meridian — AI Features Stylesheet.
 * Enqueued strictly on-demand when AI features are enabled.
 * Keeps single.min.css and base.min.css within strict 80 KB budget.
 */

/* Action Rail: Listen & Ask Buttons */
.btn-listen,
.btn-ask {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 12px;
	border-radius: 999px;
	border: 1px solid var(--line, #e2e8f0);
	background: var(--paper, #ffffff);
	color: var(--ink, #0f172a);
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-listen svg,
.btn-ask svg {
	width: 16px;
	height: 16px;
	flex-shrink: 0;
	color: var(--accent, #dc2626);
}

.btn-listen:hover,
.btn-ask:hover {
	border-color: var(--accent, #dc2626);
	background: var(--tint, #fef2f2);
	color: var(--accent, #dc2626);
}

/* Vertical Action Rail Adaptation */
@media (min-width: 1280px) {
	.share-vert .btn-listen,
	.share-vert .btn-ask {
		width: 40px;
		min-width: 40px;
		height: 40px;
		padding: 0;
		border-radius: 50%;
		justify-content: center;
	}
	.share-vert .btn-listen span,
	.share-vert .btn-ask span {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0 0 0 0);
		white-space: nowrap;
	}
}

/* Audio Reader Floating Toolbar */
.listen-bar {
	position: fixed;
	bottom: 24px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 999;
	background: var(--card, #ffffff);
	border: 1px solid var(--line, #e2e8f0);
	border-radius: 999px;
	box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
	padding: 6px 16px;
	animation: mrdSlideUp 0.25s ease-out;
}

@keyframes mrdSlideUp {
	from {
		opacity: 0;
		transform: translate(-50%, 20px);
	}
	to {
		opacity: 1;
		transform: translate(-50%, 0);
	}
}

.listen-inner {
	display: flex;
	align-items: center;
	gap: 12px;
}

.listen-play {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	border: none;
	background: var(--accent, #dc2626);
	color: #ffffff;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	padding: 0;
	transition: transform 0.15s ease;
}

.listen-play:hover {
	transform: scale(1.06);
}

.listen-play svg {
	width: 16px;
	height: 16px;
}

.listen-info {
	display: flex;
	flex-direction: column;
	font-size: 12px;
	line-height: 1.2;
}

.listen-title {
	font-weight: 600;
	color: var(--ink, #0f172a);
}

.listen-progress {
	color: var(--muted, #64748b);
	font-size: 11px;
}

.listen-speed {
	display: flex;
	gap: 4px;
	background: var(--tint, #f8fafc);
	padding: 2px;
	border-radius: 999px;
	border: 1px solid var(--line, #e2e8f0);
}

.listen-speed button {
	border: none;
	background: transparent;
	font-size: 11px;
	font-weight: 600;
	color: var(--muted, #64748b);
	padding: 3px 8px;
	border-radius: 999px;
	cursor: pointer;
}

.listen-speed button.is-active {
	background: var(--paper, #ffffff);
	color: var(--ink, #0f172a);
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.listen-close {
	border: none;
	background: transparent;
	color: var(--muted, #64748b);
	cursor: pointer;
	padding: 4px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
}

.listen-close svg {
	width: 16px;
	height: 16px;
}

.listen-close:hover {
	color: var(--ink, #0f172a);
}

/* Ask this article Drawer */
.ask-drawer {
	position: fixed;
	inset: 0;
	z-index: 10000;
	display: flex;
	justify-content: flex-end;
}

/* display:flex above beats the UA [hidden] rule, so the closed drawer covered every article. */
.ask-drawer[hidden] {
	display: none;
}

.ask-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.45);
	backdrop-filter: blur(2px);
}

.ask-dialog {
	position: relative;
	width: 100%;
	max-width: 440px;
	height: 100%;
	background: var(--card, #ffffff);
	display: flex;
	flex-direction: column;
	box-shadow: -10px 0 30px rgba(0, 0, 0, 0.15);
	animation: mrdSlideLeft 0.25s ease-out;
}

@keyframes mrdSlideLeft {
	from {
		transform: translateX(100%);
	}
	to {
		transform: translateX(0);
	}
}

.ask-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 20px;
	border-bottom: 1px solid var(--line, #e2e8f0);
}

.ask-header h3 {
	margin: 0;
	font-size: 16px;
	font-weight: 700;
	display: flex;
	align-items: center;
	gap: 8px;
	color: var(--ink, #0f172a);
}

.ask-header h3 svg {
	width: 20px;
	height: 20px;
	color: var(--accent, #dc2626);
}

.ask-close-btn {
	background: transparent;
	border: none;
	color: var(--muted, #64748b);
	cursor: pointer;
	padding: 6px;
	border-radius: 6px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.ask-close-btn svg {
	width: 18px;
	height: 18px;
}

.ask-close-btn:hover {
	color: var(--ink, #0f172a);
}

.ask-body {
	flex: 1;
	overflow-y: auto;
	padding: 20px;
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.ask-intro {
	font-size: 13px;
	line-height: 1.5;
	color: var(--muted, #64748b);
	background: var(--tint, #f8fafc);
	border: 1px solid var(--line, #e2e8f0);
	padding: 12px 14px;
	border-radius: 8px;
}

.ask-messages {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.ask-msg {
	display: flex;
	flex-direction: column;
	max-width: 90%;
}

.ask-msg.is-user {
	align-self: flex-end;
}

.ask-msg.is-user .msg-bubble {
	background: var(--accent, #dc2626);
	color: #ffffff;
	border-radius: 14px 14px 2px 14px;
	padding: 10px 14px;
	font-size: 14px;
}

.ask-msg.is-ai {
	align-self: flex-start;
}

.ask-msg.is-ai .msg-bubble {
	background: var(--tint, #f8fafc);
	color: var(--ink, #0f172a);
	border: 1px solid var(--line, #e2e8f0);
	border-radius: 14px 14px 14px 2px;
	padding: 12px 14px;
	font-size: 14px;
	line-height: 1.55;
}

.ask-msg p {
	margin: 0;
}

.ask-msg p + p {
	margin-top: 8px;
}

.ask-citations-bar {
	margin-top: 8px;
	padding-top: 8px;
	border-top: 1px solid var(--line, #e2e8f0);
	font-size: 12px;
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	align-items: center;
}

.ask-cite-tag {
	display: inline-block;
	padding: 2px 8px;
	border-radius: 4px;
	background: var(--paper, #ffffff);
	border: 1px solid var(--line, #e2e8f0);
	color: var(--accent, #dc2626);
	font-weight: 600;
	text-decoration: none;
	font-size: 11px;
}

.ask-cite-tag:hover {
	border-color: var(--accent, #dc2626);
}

.ask-dots {
	display: inline-flex;
	gap: 4px;
	font-size: 20px;
	line-height: 1;
}

.ask-error {
	color: #ef4444;
	font-size: 13px;
}

.ask-form {
	padding: 16px 20px;
	border-top: 1px solid var(--line, #e2e8f0);
	display: flex;
	gap: 8px;
}

.ask-form input {
	flex: 1;
	padding: 10px 14px;
	border-radius: 8px;
	border: 1px solid var(--line, #e2e8f0);
	background: var(--paper, #ffffff);
	color: var(--ink, #0f172a);
	font-size: 14px;
	outline: none;
}

.ask-form input:focus {
	border-color: var(--accent, #dc2626);
}

.ask-form button {
	padding: 10px 18px;
	border-radius: 8px;
	border: none;
	background: var(--accent, #dc2626);
	color: #ffffff;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
}

.highlight-section {
	animation: mrdHighlight 2s ease-out;
}

@keyframes mrdHighlight {
	0% {
		background-color: rgba(220, 38, 38, 0.15);
	}
	100% {
		background-color: transparent;
	}
}

/* Search Summary Card */
.search-summary-wrap {
	margin: 20px 0 28px;
}

.search-summary-card {
	background: var(--card, #ffffff);
	border: 1px solid var(--line, #e2e8f0);
	border-radius: 12px;
	padding: 20px;
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.search-summary-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 12px;
}

.ss-tag {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 13px;
	font-weight: 700;
	color: var(--accent, #dc2626);
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.ss-tag svg {
	width: 16px;
	height: 16px;
}

.ss-status {
	font-size: 12px;
	color: var(--muted, #64748b);
}

.ss-body {
	font-size: 15px;
	line-height: 1.6;
	color: var(--ink, #0f172a);
	margin: 0 0 16px;
}

.ss-sources {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
	font-size: 12px;
	padding-top: 12px;
	border-top: 1px solid var(--line, #e2e8f0);
}

.ss-sources-label {
	font-weight: 600;
	color: var(--muted, #64748b);
}

.ss-source-chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 10px;
	border-radius: 999px;
	background: var(--tint, #f8fafc);
	border: 1px solid var(--line, #e2e8f0);
	color: var(--ink, #0f172a);
	text-decoration: none;
	font-size: 12px;
	transition: border-color 0.15s ease;
}

.ss-source-chip:hover {
	border-color: var(--accent, #dc2626);
	color: var(--accent, #dc2626);
}

.ss-source-num {
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: var(--paper, #ffffff);
	border: 1px solid var(--line, #e2e8f0);
	font-size: 10px;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
}

.search-summary-skeleton {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.skel-line {
	height: 14px;
	border-radius: 4px;
	background: linear-gradient(90deg, var(--tint, #f1f5f9) 25%, var(--line, #e2e8f0) 50%, var(--tint, #f1f5f9) 75%);
	background-size: 200% 100%;
	animation: mrdShimmer 1.5s infinite;
}

.skel-line.short {
	width: 60%;
}

@keyframes mrdShimmer {
	0% {
		background-position: 200% 0;
	}
	100% {
		background-position: -200% 0;
	}
}
