/**
 * WPMediaVerse Pro — Instagram Feed Layout
 *
 * Mobile-first CSS with custom properties for theming.
 * Dark mode via prefers-color-scheme.
 *
 * @package WPMediaVersePro
 * @since   1.0.0
 */

/* ==========================================================================
   1. Custom Properties (Light Mode)
   ========================================================================== */

:root {
	--mvs-ig-max-width: 614px;
	--mvs-ig-bg: var(--mvs-surface-2);
	--mvs-ig-card-bg: var(--mvs-surface);
	--mvs-ig-bg-secondary: var(--mvs-surface-2); /* skeleton/placeholder fill */
	--mvs-ig-border: var(--mvs-border);
	--mvs-ig-text: var(--mvs-text);
	--mvs-ig-text-secondary: var(--mvs-text-muted);
	--mvs-ig-text-link: #00376b;
	--mvs-ig-heart: var(--mvs-danger);
	--mvs-ig-blue: var(--mvs-primary);
	--mvs-ig-stories-ring: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
	--mvs-ig-separator: var(--mvs-border-light);
	--mvs-ig-input-bg: var(--mvs-surface-2);
	--mvs-ig-card-radius: 8px;
	--mvs-ig-card-gap: 12px;
}

/* ==========================================================================
   2. Dark Mode
   ========================================================================== */

/* Dark mode — fire on every Wbcom dark signal (Reign/BuddyX use
   [data-bx-mode="dark"] or .dark-mode, BuddyNext [data-bn-theme="dark"]).
   The pre-1.8.0 selector only matched [data-theme="dark"], so this block was
   dead on buddyx/reign and the layout-mode IG feed kept light tokens in dark
   mode. DO NOT use prefers-color-scheme (OS-level) — the theme owns dark mode. */
[data-theme="dark"],
[data-bn-theme="dark"],
[data-bx-mode="dark"],
html.dark-mode,
body.dark-mode {
	--mvs-ig-bg: #000;
	--mvs-ig-card-bg: #121212;
	--mvs-ig-bg-secondary: #262626;
	--mvs-ig-border: #363636;
	/* Was var(--mvs-surface-2) — a dark surface token used as text color. */
	--mvs-ig-text: #f5f5f5;
	--mvs-ig-text-secondary: #a8a8a8;
	--mvs-ig-text-link: #e0f1ff;
	--mvs-ig-separator: var(--mvs-text);
	--mvs-ig-input-bg: #121212;
}

/* ==========================================================================
   3. Feed Container
   ========================================================================== */

.mvs-ig-feed {
	max-width: var(--mvs-ig-max-width) !important;
	margin: 0 auto !important;
	padding: 30px 0 0;
	background: var(--mvs-ig-bg);
	min-height: 100vh;
	color: var(--mvs-ig-text);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 14px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   4. Stories Bar
   ========================================================================== */

.mvs-ig-stories {
	background: var(--mvs-ig-card-bg);
	border: 1px solid var(--mvs-ig-border);
	border-radius: var(--mvs-ig-card-radius);
	margin-bottom: var(--mvs-ig-card-gap);
	padding: 16px 0;
	overflow: hidden;
}

.mvs-ig-stories-scroll {
	display: flex;
	gap: 16px;
	padding: 0 16px;
	overflow-x: auto;
	scrollbar-width: none;
	-ms-overflow-style: none;
}

.mvs-ig-stories-scroll::-webkit-scrollbar {
	display: none;
}

.mvs-ig-story-item {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	text-decoration: none;
	color: var(--mvs-ig-text);
	flex-shrink: 0;
	width: 66px;
}

.mvs-ig-story-ring {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 62px;
	height: 62px;
	border-radius: 50%;
	background: var(--mvs-ig-stories-ring);
	padding: 2px;
}

.mvs-ig-story-avatar {
	width: 56px;
	height: 56px;
	border-radius: 50%;
	border: 3px solid var(--mvs-ig-card-bg);
	object-fit: cover;
}

.mvs-ig-story-name {
	font-size: 12px;
	color: var(--mvs-ig-text);
	text-align: center;
	max-width: 66px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* ==========================================================================
   5. Card Container
   ========================================================================== */

.mvs-ig-card {
	background: var(--mvs-ig-card-bg);
	border: 1px solid var(--mvs-ig-border);
	border-radius: var(--mvs-ig-card-radius);
	margin-bottom: var(--mvs-ig-card-gap);
	margin-left: auto;
	margin-right: auto;
	max-width: var(--mvs-ig-max-width);
	overflow: hidden;
}

/* ==========================================================================
   6. Card Header
   ========================================================================== */

.mvs-ig-card-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px;
}

.mvs-ig-card-author {
	display: flex;
	align-items: center;
	gap: 10px;
	text-decoration: none;
	color: var(--mvs-ig-text);
	min-width: 0;
}

.mvs-ig-card-avatar {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
}

.mvs-ig-card-username {
	font-size: 14px;
	font-weight: 600;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.mvs-ig-follow-btn {
	background: none;
	border: none;
	color: var(--mvs-ig-blue);
	font-weight: 600;
	font-size: 14px;
	cursor: pointer;
	padding: 0;
	flex-shrink: 0;
}

.mvs-ig-follow-btn:hover {
	color: var(--mvs-ig-text-link);
}

.mvs-ig-follow-btn.mvs-ig-following {
	color: var(--mvs-ig-text);
}

.mvs-ig-edit-profile-btn {
	display: inline-block;
	padding: 6px 16px;
	background: var(--mvs-ig-bg-secondary, #efefef);
	color: var(--mvs-ig-text, #262626);
	border: none;
	border-radius: 8px;
	font-size: 14px;
	font-weight: 600;
	text-decoration: none;
	cursor: pointer;
}

.mvs-ig-edit-profile-btn:hover {
	background: var(--mvs-ig-border, #dbdbdb);
	color: var(--mvs-ig-text, #262626);
	text-decoration: none;
}


/* Message button on profile page */
.mvs-ig-message-btn {
	display: inline-block;
	padding: 6px 16px;
	background: var(--mvs-ig-bg-secondary, #efefef);
	color: var(--mvs-ig-text, #262626);
	border: none;
	border-radius: 8px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
}

.mvs-ig-message-btn:hover {
	background: var(--mvs-ig-border, #dbdbdb);
}

/* Shared Follow + Message buttons (profile-actions.php partial) in Instagram layout */
.mvs-ig-profile-name-row .mvs-follow-toggle {
	background: none;
	border: none;
	color: var(--mvs-ig-blue);
	font-weight: 600;
	font-size: 14px;
	cursor: pointer;
	padding: 0;
	flex-shrink: 0;
}

.mvs-ig-profile-name-row .mvs-follow-toggle:hover {
	color: var(--mvs-ig-text-link);
}

.mvs-ig-profile-name-row .mvs-follow-toggle.mvs-follow-toggle--following {
	color: var(--mvs-ig-text);
	background: none;
	border: none;
}

.mvs-ig-profile-name-row .mvs-follow-toggle.mvs-follow-toggle--following:hover {
	color: var(--mvs-danger);
	background: none;
	border: none;
}

.mvs-ig-profile-name-row .mvs-message-btn {
	display: inline-block;
	padding: 6px 16px;
	background: var(--mvs-ig-bg-secondary, #efefef);
	color: var(--mvs-ig-text, #262626);
	border: none;
	border-radius: 8px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
}

.mvs-ig-profile-name-row .mvs-message-btn:hover {
	background: var(--mvs-ig-border, #dbdbdb);
}

/* ==========================================================================
   7. Media Area
   ========================================================================== */

.mvs-ig-card-media {
	position: relative;
	width: 100%;
	background: #000;
	cursor: pointer;
	user-select: none;
	-webkit-user-select: none;
}

.mvs-ig-card-img {
	display: block;
	width: 100%;
	height: auto;
	object-fit: contain;
	max-height: 614px;
}

.mvs-ig-video {
	display: block;
	width: 100%;
	height: auto;
	max-height: 614px;
	object-fit: contain;
}

/* Gallery Carousel */
.mvs-ig-carousel {
	position: relative;
	width: 100%;
}

.mvs-ig-carousel .mvs-ig-card-img[hidden] {
	display: none !important;
}

.mvs-ig-carousel-prev,
.mvs-ig-carousel-next {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	background: rgba(255, 255, 255, 0.85);
	border: none;
	border-radius: 50%;
	width: 32px;
	height: 32px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	z-index: 3;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
	transition: opacity 0.15s;
	opacity: 0.7;
}

.mvs-ig-carousel-prev:hover,
.mvs-ig-carousel-next:hover {
	opacity: 1;
}

.mvs-ig-carousel-prev {
	left: 8px;
}

.mvs-ig-carousel-next {
	right: 8px;
}

.mvs-ig-carousel-prev svg,
.mvs-ig-carousel-next svg {
	width: 16px;
	height: 16px;
	pointer-events: none;
}

/* Expand / Lightbox button */
.mvs-ig-expand-btn {
	position: absolute;
	bottom: 12px;
	right: 12px;
	z-index: 3;
}

.mvs-ig-expand-trigger {
	background: rgba(0, 0, 0, 0.5);
	border: none;
	color: var(--mvs-surface);
	border-radius: 50%;
	width: 36px;
	height: 36px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: background 0.15s;
	opacity: 0;
}

.mvs-ig-card-media:hover .mvs-ig-expand-trigger {
	opacity: 1;
}

.mvs-ig-expand-trigger:hover {
	background: rgba(0, 0, 0, 0.8);
}

.mvs-ig-expand-trigger svg {
	pointer-events: none;
}

.mvs-ig-carousel-counter {
	position: absolute;
	top: 12px;
	right: 12px;
	background: rgba(0, 0, 0, 0.6);
	color: var(--mvs-surface);
	padding: 4px 10px;
	border-radius: 12px;
	font-size: 12px;
	font-weight: 600;
	z-index: 3;
}

/* Audio */
.mvs-ig-audio-wrap {
	position: relative;
	width: 100%;
	aspect-ratio: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.mvs-ig-audio-art {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.mvs-ig-audio-placeholder {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	aspect-ratio: 1;
	color: var(--mvs-surface);
}

.mvs-ig-audio {
	position: absolute;
	bottom: 0;
	left: 0;
	width: 100%;
	height: 54px;
	background: rgba(0, 0, 0, 0.5);
}

/* Mute button */
.mvs-ig-mute-btn {
	position: absolute;
	bottom: 16px;
	/* Bottom-LEFT so it never collides with the expand button (bottom-right) on
	   video cards - mirrors native video-player mute placement. (#10028071183) */
	left: 16px;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: rgba(38, 38, 38, 0.6);
	border: none;
	color: var(--mvs-surface);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 3px;
	transition: background 0.2s;
}

.mvs-ig-mute-btn:hover {
	background: rgba(38, 38, 38, 0.8);
}

/* ==========================================================================
   8. Heart Overlay (Double-Tap Animation)
   ========================================================================== */

.mvs-ig-heart-overlay {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%) scale(0);
	pointer-events: none;
	opacity: 0;
	z-index: 10;
	filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
}

.mvs-ig-heart-overlay.mvs-ig-heart-active {
	animation: mvs-ig-heart-pop 1s ease-out forwards;
}

@keyframes mvs-ig-heart-pop {
	0% {
		transform: translate(-50%, -50%) scale(0);
		opacity: 1;
	}
	15% {
		transform: translate(-50%, -50%) scale(1.2);
	}
	30% {
		transform: translate(-50%, -50%) scale(0.95);
	}
	45%,
	80% {
		transform: translate(-50%, -50%) scale(1);
		opacity: 1;
	}
	100% {
		transform: translate(-50%, -50%) scale(1);
		opacity: 0;
	}
}

/* ==========================================================================
   9. Action Bar
   ========================================================================== */

.mvs-ig-actions {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 8px 16px 0;
}

.mvs-ig-actions-left {
	display: flex;
	align-items: center;
	gap: 16px;
}

.mvs-ig-actions-right {
	display: flex;
	align-items: center;
}

.mvs-ig-action-btn {
	background: none;
	border: none;
	cursor: pointer;
	padding: 8px 0;
	color: var(--mvs-ig-text);
	display: flex;
	align-items: center;
	text-decoration: none;
	transition: opacity 0.2s;
}

.mvs-ig-action-btn:hover {
	opacity: 0.6;
}

.mvs-ig-action-btn.mvs-ig-liked {
	color: var(--mvs-ig-heart);
}

.mvs-ig-action-btn.mvs-ig-liked:hover {
	opacity: 0.8;
}

.mvs-ig-action-btn.mvs-ig-bookmarked {
	color: var(--mvs-ig-text);
}

/* ==========================================================================
   10. Like Count
   ========================================================================== */

.mvs-ig-likes {
	padding: 0 16px 4px;
	font-size: 14px;
}

/* ==========================================================================
   11. Caption
   ========================================================================== */

.mvs-ig-caption {
	padding: 0 16px 4px;
	font-size: 14px;
	word-wrap: break-word;
	overflow-wrap: break-word;
}

.mvs-ig-caption-author {
	margin-right: 4px;
}

.mvs-ig-caption-text {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.mvs-ig-caption-text.mvs-ig-caption-expanded {
	display: inline;
	-webkit-line-clamp: unset;
}

.mvs-ig-caption-more {
	background: none;
	border: none;
	color: var(--mvs-ig-text-secondary);
	cursor: pointer;
	padding: 0;
	font-size: 14px;
}

/* ==========================================================================
   12. Comments
   ========================================================================== */

.mvs-ig-view-comments {
	display: block;
	padding: 0 16px 4px;
	color: var(--mvs-ig-text-secondary);
	text-decoration: none;
	font-size: 14px;
}

.mvs-ig-comments-preview {
	padding: 0 16px 4px;
}

.mvs-ig-comment-row {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 14px;
	margin-bottom: 4px;
}

.mvs-ig-comment-author-link {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	text-decoration: none;
	color: inherit;
	flex-shrink: 0;
}
.mvs-ig-comment-author-link:hover strong { text-decoration: underline; }

.mvs-ig-comment-avatar {
	width: 20px;
	height: 20px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
}

.mvs-ig-comment-row strong {
	margin-right: 2px;
}

/* ==========================================================================
   13. Add Comment
   ========================================================================== */

.mvs-ig-add-comment {
	display: flex;
	align-items: center;
	padding: 12px 16px;
	border-top: 1px solid var(--mvs-ig-separator);
	gap: 12px;
}

.mvs-ig-comment-input {
	flex: 1;
	border: none;
	background: transparent;
	font-size: 14px;
	color: var(--mvs-ig-text);
	outline: none;
	padding: 0;
	font-family: inherit;
}

.mvs-ig-comment-input::placeholder {
	color: var(--mvs-ig-text-secondary);
}

.mvs-ig-post-btn {
	background: none;
	border: none;
	color: var(--mvs-ig-blue);
	font-weight: 600;
	font-size: 14px;
	cursor: pointer;
	padding: 0;
	opacity: 1;
	transition: opacity 0.2s;
}

.mvs-ig-post-btn:disabled {
	opacity: 0.3;
	cursor: default;
}

/* ==========================================================================
   14. Timestamp
   ========================================================================== */

.mvs-ig-timestamp {
	display: block;
	padding: 0 16px 16px;
	color: var(--mvs-ig-text-secondary);
	font-size: 10px;
	text-transform: uppercase;
	letter-spacing: 0.2px;
	text-decoration: none;
}

.mvs-ig-empty {
	text-align: center;
	padding: 48px 16px;
	color: var(--mvs-ig-text-secondary);
	font-size: 16px;
}

.mvs-ig-follow-btn[hidden],
.mvs-ig-profile-name-row .mvs-follow-toggle[hidden],
.mvs-ig-caption-more[hidden],
.mvs-ig-likes[hidden] {
	display: none !important;
}

/* ==========================================================================
   16. Mobile — Full Bleed
   ========================================================================== */

@media (max-width: 614px) {
	.mvs-ig-feed {
		padding: 0;
	}

	.mvs-ig-card {
		border-left: none;
		border-right: none;
		border-radius: 0;
	}

	.mvs-ig-stories {
		border-left: none;
		border-right: none;
		border-radius: 0;
	}
}

/* ==========================================================================
   17. Dynamically Appended Cards (event delegation targets)
   ========================================================================== */

.mvs-ig-card--dynamic .mvs-ig-action-btn[data-action="like"].mvs-ig-liked {
	color: var(--mvs-ig-heart);
}

.mvs-ig-card--dynamic .mvs-ig-action-btn[data-action="favorite"].mvs-ig-bookmarked {
	color: var(--mvs-ig-text);
}

/* ==========================================================================
   18. Accessibility
   ========================================================================== */

.mvs-ig-action-btn:focus-visible,
.mvs-ig-follow-btn:focus-visible,
.mvs-ig-profile-name-row .mvs-follow-toggle:focus-visible,
.mvs-ig-profile-name-row .mvs-message-btn:focus-visible,
.mvs-ig-post-btn:focus-visible,
.mvs-ig-caption-more:focus-visible,
.mvs-ig-mute-btn:focus-visible {
	outline: 2px solid var(--mvs-ig-blue);
	outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
	.mvs-ig-heart-overlay.mvs-ig-heart-active {
		animation: none;
		transform: translate(-50%, -50%) scale(1);
		opacity: 1;
	}

	.mvs-ig-spinner {
		animation-duration: 1.5s;
	}
}

/* ==========================================================================
   19. User Profile Header
   ========================================================================== */

.mvs-ig-profile-header {
	display: flex;
	gap: 30px;
	padding: 30px 16px;
	align-items: flex-start;
}

.mvs-ig-profile-avatar img {
	width: 150px;
	height: 150px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
}

.mvs-ig-profile-info {
	flex: 1;
	min-width: 0;
}

.mvs-ig-profile-name-row {
	display: flex;
	align-items: center;
	gap: 20px;
	margin-bottom: 16px;
}

.mvs-ig-profile-username {
	font-size: 20px;
	font-weight: 300;
	color: var(--mvs-ig-text);
	margin: 0;
}

.mvs-ig-profile-stats {
	display: flex;
	gap: 40px;
	margin-bottom: 12px;
}

.mvs-ig-profile-stat {
	font-size: 14px;
	color: var(--mvs-ig-text);
}

.mvs-ig-profile-stat strong {
	font-weight: 600;
}

.mvs-ig-profile-display-name {
	font-size: 14px;
	font-weight: 600;
	color: var(--mvs-ig-text);
	margin-bottom: 4px;
}

.mvs-ig-profile-bio {
	font-size: 14px;
	color: var(--mvs-ig-text);
	line-height: 1.4;
	white-space: pre-line;
}

/* Mobile profile layout */
@media (max-width: 614px) {
	.mvs-ig-profile-header {
		gap: 16px;
		padding: 16px;
	}

	.mvs-ig-profile-avatar img {
		width: 77px;
		height: 77px;
	}

	.mvs-ig-profile-username {
		font-size: 18px;
	}

	.mvs-ig-profile-stats {
		gap: 0;
		justify-content: space-around;
		text-align: center;
		border-top: 1px solid var(--mvs-ig-border);
		border-bottom: 1px solid var(--mvs-ig-border);
		padding: 12px 0;
		margin: 0 -16px 0;
	}
}
