/* ─── Design Tokens — Light Mode (Default) ────────────────────────────
   Same architecture as every other AFz tool: this widget owns its own
   color tokens rather than inheriting the theme's, and only reacts to the
   host theme's dark-mode class up the DOM tree. Relying on `color: inherit`
   or the visitor's OS `prefers-color-scheme` both turned out to be
   unreliable — a theme's own inherited text color is often a muted/soft
   tone meant for body copy, not a guaranteed-readable foreground, and OS
   preference has nothing to do with which mode the page is actually in. */
.afz-bluesky-embed-wrapper {
	--afz-be-fg: #0f172a;
	--afz-be-border: rgba(120, 120, 120, 0.25);
	--afz-be-hover-bg: rgba(120, 120, 120, 0.1);
	--afz-be-link: #1d9bf0;

	width: 100%;
	max-width: 600px;
	margin: 0 auto;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	color: var(--afz-be-fg);
	box-sizing: border-box;
}

/* ─── Dark Mode — Listener Only (auto mode) ────────────────────────────
   Covers shadcn/Tailwind-style themes (html.dark — the most likely
   convention for a Shadcn FSE block theme), plus common alternates, so
   this keeps working even if the toggle mechanism changes later. Scoped
   to .afz-be-mode-auto specifically so it can never fight with an
   explicit "Always light" / "Always dark" choice below. */
html.dark .afz-be-mode-auto,
.dark .afz-be-mode-auto,
body.dark .afz-be-mode-auto,
.dark-mode .afz-be-mode-auto,
[data-theme="dark"] .afz-be-mode-auto {
	--afz-be-fg: #f8fafc;
	--afz-be-border: rgba(255, 255, 255, 0.16);
	--afz-be-hover-bg: rgba(255, 255, 255, 0.07);
	--afz-be-link: #6cb7f5;
}

/* "Always light" / "Always dark": a self-contained card with its own fixed
   colors, for when the embed should look the same everywhere regardless of
   the page it's placed on. */
.afz-be-mode-light,
.afz-be-mode-dark {
	border-radius: 14px;
	padding: 4px 16px;
}

.afz-be-mode-light {
	background: #ffffff;
	--afz-be-fg: #0f1419;
	--afz-be-border: #e2e8f0;
	--afz-be-hover-bg: rgba(15, 20, 25, 0.04);
	--afz-be-link: #1d9bf0;
}

.afz-be-mode-dark {
	background: #15202b;
	--afz-be-fg: #f1f5f9;
	--afz-be-border: #2f3b47;
	--afz-be-hover-bg: rgba(255, 255, 255, 0.06);
	--afz-be-link: #6cb7f5;
}

.afz-bluesky-embed-wrapper *,
.afz-bluesky-embed-wrapper *::before,
.afz-bluesky-embed-wrapper *::after {
	box-sizing: inherit;
}

.afz-bluesky-embed-wrapper a {
	color: inherit;
	text-decoration: none;
}

.afz-bluesky-embed-wrapper .afz-be-text a {
	color: var(--afz-be-link);
}

.afz-bluesky-embed-wrapper .afz-be-text a:hover {
	text-decoration: underline;
}

.afz-bluesky-embed-wrapper .afz-be-author-link:hover .afz-be-name {
	text-decoration: underline;
}

/* Muted text (handle, timestamp, card host/description) — derived from
   the widget's own guaranteed-readable foreground token via opacity, so
   it's automatically correct in every mode without a second hardcoded
   color that could itself go stale. */
.afz-be-handle,
.afz-be-dot,
.afz-be-date-link,
.afz-be-repost-badge,
.afz-be-card-host,
.afz-be-card-desc,
.afz-be-error,
.afz-be-empty,
.afz-be-noscript {
	opacity: 0.62;
}

/* Skeleton loading state */
.afz-be-skeleton-post {
	display: flex;
	gap: 10px;
	padding: 12px 0;
	border-bottom: 1px solid var(--afz-be-border);
}

.afz-be-skeleton-avatar {
	width: 42px;
	height: 42px;
	border-radius: 50%;
	background: currentColor;
	opacity: 0.15;
	flex-shrink: 0;
	animation: afz-be-pulse 1.4s ease-in-out infinite;
}

.afz-be-skeleton-lines {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding-top: 4px;
}

.afz-be-skeleton-lines span {
	display: block;
	height: 10px;
	border-radius: 4px;
	background: currentColor;
	opacity: 0.15;
	animation: afz-be-pulse 1.4s ease-in-out infinite;
}

.afz-be-skeleton-lines span:nth-child(1) { width: 40%; }
.afz-be-skeleton-lines span:nth-child(2) { width: 90%; }
.afz-be-skeleton-lines span:nth-child(3) { width: 70%; }

@keyframes afz-be-pulse {
	0%, 100% { opacity: 0.08; }
	50% { opacity: 0.22; }
}

/* Posts */
.afz-be-post {
	padding: 12px 0;
	border-bottom: 1px solid var(--afz-be-border);
}

.afz-be-post:last-child {
	border-bottom: 0;
}

.afz-be-repost-badge {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 0 0 4px 52px;
	font-size: 13px;
	font-weight: 600;
}

.afz-be-header {
	display: flex;
	align-items: center;
	gap: 10px;
}

.afz-be-avatar {
	width: 42px;
	height: 42px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
}

.afz-be-avatar-sm {
	width: 18px;
	height: 18px;
}

.afz-be-header-text {
	min-width: 0;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
	font-size: 14px;
	line-height: 1.3;
}

.afz-be-name {
	font-weight: 700;
}

.afz-be-date-link:hover {
	text-decoration: underline;
}

.afz-be-text {
	margin: 6px 0 0;
	font-size: 15px;
	line-height: 1.4;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

/* Images */
.afz-be-images {
	display: grid;
	grid-template-columns: 1fr;
	gap: 4px;
	margin-top: 10px;
	border-radius: 12px;
	overflow: hidden;
}

.afz-be-images-grid {
	grid-template-columns: 1fr 1fr;
}

.afz-be-images img {
	width: 100%;
	height: 100%;
	max-height: 420px;
	object-fit: cover;
	display: block;
}

.afz-be-lightbox-trigger {
	display: block;
	padding: 0;
	border: 0;
	background: none;
	cursor: zoom-in;
	line-height: 0;
}

/* Video */
.afz-be-video {
	position: relative;
	display: block;
	margin-top: 10px;
	border-radius: 12px;
	overflow: hidden;
	background: #000;
}

.afz-be-video img {
	width: 100%;
	display: block;
	max-height: 420px;
	object-fit: cover;
	opacity: 0.85;
}

.afz-be-play-badge {
	position: absolute;
	left: 12px;
	bottom: 12px;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 12px;
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.7);
	color: #fff;
	font-size: 13px;
	font-weight: 600;
}

/* External link card */
.afz-be-card {
	display: block;
	margin-top: 10px;
	border: 1px solid var(--afz-be-border);
	border-radius: 12px;
	overflow: hidden;
}

.afz-be-card:hover {
	background: var(--afz-be-hover-bg);
}

.afz-be-card-thumb {
	width: 100%;
	max-height: 220px;
	object-fit: cover;
	display: block;
}

.afz-be-card-body {
	display: block;
	padding: 10px 12px;
}

.afz-be-card-host {
	display: block;
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.02em;
}

.afz-be-card-title {
	display: block;
	font-weight: 700;
	margin-top: 2px;
}

.afz-be-card-desc {
	display: block;
	margin-top: 4px;
	font-size: 13px;
}

/* Quote post */
.afz-be-quote {
	display: block;
	margin-top: 10px;
	padding: 10px 12px;
	border: 1px solid var(--afz-be-border);
	border-radius: 12px;
}

.afz-be-quote:hover {
	background: var(--afz-be-hover-bg);
}

.afz-be-quote-header {
	font-size: 13px;
}

.afz-be-quote .afz-be-text {
	font-size: 14px;
	margin-top: 4px;
}

.afz-be-quote .afz-be-images img {
	max-height: 260px;
}

/* Action bar: reply / repost / like / bookmark / share. Every icon links
   out to the real post on bsky.app — actually liking or reposting needs
   the visitor's own Bluesky login, which this read-only embed doesn't
   attempt. */
.afz-be-actions {
	display: flex;
	align-items: center;
	justify-content: space-between;
	max-width: 320px;
	margin-top: 10px;
}

.afz-be-action {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px;
	margin: -6px;
	border-radius: 999px;
	opacity: 0.62;
	font-size: 13px;
	line-height: 1;
	transition: background-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.afz-be-action-count {
	min-width: 1ch;
}

.afz-be-action:hover {
	opacity: 1;
}

.afz-be-action-reply:hover {
	background: rgba(29, 155, 240, 0.1);
	color: #1d9bf0;
}

.afz-be-action-repost:hover {
	background: rgba(0, 186, 124, 0.1);
	color: #00ba7c;
}

.afz-be-action-like:hover {
	background: rgba(244, 33, 111, 0.1);
	color: #f4216f;
}

.afz-be-action-bookmark:hover,
.afz-be-action-share:hover {
	background: rgba(29, 155, 240, 0.1);
	color: #1d9bf0;
}

/* Load more / error / empty states */
.afz-be-load-more {
	display: block;
	width: 100%;
	margin-top: 14px;
	padding: 10px 16px;
	border: 1px solid var(--afz-be-border);
	border-radius: 999px;
	background: transparent;
	color: inherit;
	font-weight: 600;
	cursor: pointer;
}

.afz-be-load-more:hover {
	background: var(--afz-be-hover-bg);
}

.afz-be-load-more:disabled {
	opacity: 0.5;
	cursor: default;
}

.afz-be-error,
.afz-be-empty,
.afz-be-noscript {
	padding: 12px 0;
	font-size: 14px;
}

/* Lightbox */
.afz-be-lightbox {
	border: 0;
	padding: 0;
	background: transparent;
	max-width: 92vw;
	max-height: 92vh;
}

.afz-be-lightbox::backdrop {
	background: rgba(0, 0, 0, 0.85);
}

.afz-be-lightbox-img {
	display: block;
	max-width: 92vw;
	max-height: 92vh;
	margin: 0 auto;
}

.afz-be-lightbox-close-form {
	position: fixed;
	top: 16px;
	right: 16px;
}

.afz-be-lightbox-close {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	border: 0;
	background: rgba(0, 0, 0, 0.7);
	color: #fff;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
}
