/* Vertical reels viewer (TikTok-style).
 * Selectors like :is(.cvr-viewer, #cvr-viewer) score like an ID selector, so
 * these resets beat aggressive theme rules such as
 * ".site button:not(:hover):not(:active)" without needing !important.
 * Every control is a <button>/<a>, so theme styles are reset explicitly
 * (min-height, padding, width, transform, text-transform, shadows). */

.cvr-viewer {
	position: fixed;
	inset: 0;
	z-index: 100000;
	background: #000;
	display: none;
}
.cvr-viewer.is-open { display: block; }

.cvr-viewer-feed {
	position: absolute;
	inset: 0;
	overflow-y: scroll;
	scroll-snap-type: y mandatory;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
	scrollbar-width: none;
}
.cvr-viewer-feed::-webkit-scrollbar { display: none; }

:is(.cvr-viewer, #cvr-viewer) .cvr-viewer-close {
	-webkit-appearance: none;
	appearance: none;
	position: fixed;
	top: 14px;
	right: 16px;
	z-index: 10;
	width: 40px;
	height: 40px;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	box-shadow: none;
	background: rgba(255,255,255,.16);
	color: #fff;
	font-size: 24px;
	line-height: 40px;
	text-align: center;
	text-transform: none;
	transform: none;
	cursor: pointer;
}
:is(.cvr-viewer, #cvr-viewer) .cvr-viewer-close:hover { background: rgba(255,255,255,.28); color: #fff; transform: none; }

/* One reel per screen */
.cvr-slide {
	position: relative;
	height: 100%;
	width: 100%;
	container-type: size;
	scroll-snap-align: start;
	scroll-snap-stop: always;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}

/* The stage takes the video's aspect ratio (set from JS); 9:16 until known. */
.cvr-stage {
	position: relative;
	height: 100%;
	max-width: 100%;
	aspect-ratio: 9 / 16;
	background: #000;
}
.cvr-slide-video {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: contain;
	background: #000;
	cursor: pointer;
	display: block;
}

/* Phones: portrait reels fill the screen like TikTok; landscape reels still fit. */
@media (max-width: 739px) {
	.cvr-stage { width: 100%; }
	.cvr-slide.is-portrait .cvr-slide-video { object-fit: cover; }
}
/* Desktop: leave room for the button rail beside the video. */
@media (min-width: 740px) {
	/* Fit the video inside (screen height) x (screen width minus room for the rail). */
	.cvr-stage {
		height: auto;
		max-height: 100%;
		width: min( calc(100% - 180px), calc(100vh * var(--cvr-ar, 0.5625)) );          /* fallback */
		width: min( calc(100cqw - 180px), calc(100cqh * var(--cvr-ar, 0.5625)) );       /* sized to the slide */
		max-width: none;
	}
}

/* ---- Right-hand action rail ---- */
.cvr-rail {
	position: absolute;
	right: 10px;
	bottom: 112px;
	display: flex;
	flex-direction: column;
	gap: 16px;
	z-index: 5;
}
@media (min-width: 740px) {
	.cvr-rail { right: -72px; bottom: 46px; }   /* beside the video, not on it */
}

:is(.cvr-viewer, #cvr-viewer) .cvr-rail .cvr-act {
	-webkit-appearance: none;
	appearance: none;
	background: transparent;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	margin: 0;
	padding: 0;
	width: auto;
	min-width: 0;
	height: auto;
	min-height: 0;
	line-height: 1.2;
	text-transform: none;
	letter-spacing: normal;
	transform: none;
	color: #fff;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	cursor: pointer;
	text-decoration: none;
	font-family: inherit;
	font-size: 12px;
	font-weight: 600;
	text-shadow: 0 1px 2px rgba(0,0,0,.5);
}
:is(.cvr-viewer, #cvr-viewer) .cvr-rail .cvr-act:hover,
:is(.cvr-viewer, #cvr-viewer) .cvr-rail .cvr-act:focus { background: transparent; color: #fff; box-shadow: none; transform: none; text-decoration: none; }

.cvr-act .cvr-ico {
	width: 48px;
	height: 48px;
	border-radius: 50%;
	background: rgba(0,0,0,.35);
	display: grid;
	place-items: center;
	font-size: 22px;
	line-height: 1;
	transition: transform .12s ease, background .12s ease;
}
@media (min-width: 740px) {
	.cvr-act .cvr-ico { background: rgba(255,255,255,.12); }
	:is(.cvr-viewer, #cvr-viewer) .cvr-rail .cvr-act:hover .cvr-ico { background: rgba(255,255,255,.22); }
}
.cvr-act .cvr-ico i { font-size: 21px; line-height: 1; }
.cvr-like.is-liked .cvr-ico { color: #ff2b55; }
.cvr-pop .cvr-ico { transform: scale(1.25); }

/* ---- Caption + handle ---- */
.cvr-caption {
	position: absolute;
	left: 14px;
	right: 78px;
	bottom: 54px;
	color: #fff;
	z-index: 5;
	text-shadow: 0 1px 3px rgba(0,0,0,.6);
	transition: opacity .12s ease;
	pointer-events: none;
}
.cvr-caption a { pointer-events: auto; }
@media (min-width: 740px) { .cvr-caption { right: 14px; } }

:is(.cvr-viewer, #cvr-viewer) .cvr-cap-author {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-weight: 700;
	font-size: 15px;
	margin-bottom: 6px;
	color: #fff;
	text-decoration: none;
}
:is(.cvr-viewer, #cvr-viewer) .cvr-cap-author:hover { color: #fff; text-decoration: underline; }
:is(.cvr-viewer, #cvr-viewer) .cvr-cap-avatar {
	width: 32px;
	height: 32px;
	max-width: none;
	margin: 0;
	border-radius: 50%;
	object-fit: cover;
	border: 1px solid rgba(255,255,255,.6);
	background: #fff;
}
.cvr-cap-title { font-size: 15px; margin-bottom: 4px; }
.cvr-cap-text { font-size: 13px; opacity: .9; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cvr-cap-tags { margin-top: 6px; font-size: 13px; font-weight: 600; }
.cvr-tag { opacity: .95; margin-right: 6px; }

/* ---- "Tap for sound" pill (it unmutes) ---- */
:is(.cvr-viewer, #cvr-viewer) .cvr-sound-hint {
	-webkit-appearance: none;
	appearance: none;
	position: absolute;
	top: 16px;
	left: 50%;
	transform: translateX(-50%);
	margin: 0;
	border: 0;
	box-shadow: none;
	width: auto;
	min-width: 0;
	height: auto;
	min-height: 0;
	background: rgba(0,0,0,.55);
	color: #fff;
	padding: 7px 14px;
	border-radius: 999px;
	font-family: inherit;
	font-size: 13px;
	line-height: 1.2;
	text-transform: none;
	letter-spacing: normal;
	white-space: nowrap;
	z-index: 6;
	cursor: pointer;
}
:is(.cvr-viewer, #cvr-viewer) .cvr-sound-hint:hover { background: rgba(0,0,0,.7); color: #fff; transform: translateX(-50%); }

/* ---- Big play icon while paused ---- */
.cvr-play-ico {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 76px;
	height: 76px;
	transform: translate(-50%, -50%) scale(.85);
	opacity: 0;
	pointer-events: none; /* taps go through to the video */
	transition: opacity .15s ease, transform .15s ease;
	z-index: 4;
}
.cvr-play-ico svg { width: 100%; height: 100%; fill: rgba(255,255,255,.85); filter: drop-shadow(0 2px 8px rgba(0,0,0,.45)); }
.cvr-slide.is-paused .cvr-play-ico { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.cvr-slide.is-scrubbing .cvr-play-ico { opacity: 0; }

/* ---- Draggable progress bar ---- */
.cvr-progress {
	position: absolute;
	left: 12px;
	right: 12px;
	/* Lifted off the screen edge (and above the iPhone home bar). */
	bottom: calc(14px + env(safe-area-inset-bottom, 0px));
	height: 22px;            /* generous hit area, thin visible track */
	z-index: 7;
	cursor: pointer;
	touch-action: none;      /* a horizontal drag here must not scroll the feed */
	-webkit-user-select: none;
	user-select: none;
}
.cvr-track {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	height: 3px;
	background: rgba(255,255,255,.28);
	transition: height .12s ease;
}
.cvr-fill {
	position: absolute;
	inset: 0;
	background: #fff;
	transform-origin: left center;
	transform: scaleX(0);
}
.cvr-thumb {
	position: absolute;
	top: 50%;
	left: 0;
	width: 12px;
	height: 12px;
	margin-left: -6px;
	border-radius: 50%;
	background: #fff;
	transform: translateY(-50%) scale(0);
	transition: transform .12s ease;
	box-shadow: 0 0 4px rgba(0,0,0,.4);
}
.cvr-progress:hover .cvr-track,
.cvr-slide.is-paused .cvr-track,
.cvr-progress.is-dragging .cvr-track { height: 6px; }
.cvr-progress:hover .cvr-thumb,
.cvr-slide.is-paused .cvr-thumb,
.cvr-progress.is-dragging .cvr-thumb { transform: translateY(-50%) scale(1); }

/* Time readout: small at the right while paused/hovered, big and centred while dragging. */
.cvr-scrub-time {
	position: absolute;
	right: 12px;
	bottom: 14px;
	color: #fff;
	font-size: 12px;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	text-shadow: 0 1px 3px rgba(0,0,0,.8);
	white-space: nowrap;
	opacity: 0;
	pointer-events: none;
	transition: opacity .12s ease;
}
.cvr-progress:hover .cvr-scrub-time,
.cvr-slide.is-paused .cvr-scrub-time { opacity: 1; }
.cvr-progress.is-dragging .cvr-scrub-time {
	opacity: 1;
	right: auto;
	left: 50%;
	bottom: 44px;
	transform: translateX(-50%);
	font-size: 26px;
}
/* Hide the caption while scrubbing so the big time readout is clear, as TikTok does. */
.cvr-slide.is-scrubbing .cvr-caption,
.cvr-slide.is-paused .cvr-caption { transition: opacity .12s ease; }
.cvr-slide.is-scrubbing .cvr-caption { opacity: 0; }

/* ---- Comments drawer (appended to <body>, outside the viewer) ---- */
.cvr-drawer {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 100001;
	background: #fff;
	color: #111;
	border-radius: 16px 16px 0 0;
	max-height: 70vh;
	display: flex;
	flex-direction: column;
	transform: translateY(100%);
	transition: transform .25s ease;
	box-shadow: 0 -6px 30px rgba(0,0,0,.3);
}
.cvr-drawer.is-open { transform: translateY(0); }
@media (min-width: 740px) {
	.cvr-drawer {
		left: auto;
		right: 0;
		top: 0;
		bottom: 0;
		width: 380px;
		max-height: none;
		border-radius: 0;
		transform: translateX(100%);
	}
	.cvr-drawer.is-open { transform: translateX(0); }
}
.cvr-drawer-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px;
	border-bottom: 1px solid #eee;
	font-weight: 700;
}
:is(.cvr-drawer, #cvr-drawer) .cvr-drawer-close {
	-webkit-appearance: none;
	appearance: none;
	border: 0;
	background: none;
	box-shadow: none;
	margin: 0;
	padding: 0 4px;
	width: auto;
	min-width: 0;
	min-height: 0;
	height: auto;
	font-size: 26px;
	line-height: 1;
	color: #111;
	text-transform: none;
	transform: none;
	cursor: pointer;
}
.cvr-drawer-list { flex: 1; overflow-y: auto; padding: 12px 16px; }
.cvr-c-item { display: flex; gap: 10px; margin-bottom: 14px; }
:is(.cvr-drawer, #cvr-drawer) .cvr-c-av { width: 34px; height: 34px; max-width: none; margin: 0; border: 0; border-radius: 50%; flex: 0 0 auto; }
.cvr-c-author { font-weight: 600; font-size: 13px; margin-right: 6px; }
.cvr-c-when { color: #999; font-size: 11px; }
.cvr-c-content { font-size: 14px; margin-top: 2px; }
.cvr-c-empty, .cvr-c-loading { color: #999; text-align: center; padding: 24px 0; }

.cvr-drawer-form { border-top: 1px solid #eee; padding: 10px 16px; margin: 0; }
:is(.cvr-drawer, #cvr-drawer) .cvr-c-name { width: 100%; margin: 0 0 6px; padding: 8px 10px; border: 1px solid #ddd; border-radius: 8px; box-sizing: border-box; font-size: 14px; }
.cvr-c-row { display: flex; gap: 8px; }
:is(.cvr-drawer, #cvr-drawer) .cvr-c-text { flex: 1; min-width: 0; margin: 0; padding: 8px 10px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px; }
:is(.cvr-drawer, #cvr-drawer) .cvr-c-post {
	-webkit-appearance: none;
	appearance: none;
	flex: 0 0 auto;
	width: auto;
	min-width: 0;
	min-height: 0;
	height: auto;
	margin: 0;
	border: 0;
	box-shadow: none;
	background: #e23;
	color: #fff;
	border-radius: 8px;
	padding: 0 16px;
	font-size: 14px;
	line-height: 36px;
	text-transform: none;
	letter-spacing: normal;
	transform: none;
	cursor: pointer;
	font-weight: 600;
}
:is(.cvr-drawer, #cvr-drawer) .cvr-c-post:hover { background: #c41c2c; color: #fff; transform: none; }
.cvr-c-msg { display: none; color: #a00; font-size: 12px; margin-top: 6px; }

/* ---- Reel page: the feed sits under the theme header (height set from JS) ---- */
html.cvr-page-lock,
html.cvr-page-lock body { overflow: hidden; }
.cvr-viewer.cvr-viewer--page {
	position: relative;
	inset: auto;
	z-index: 1;
	display: block;
	/* Full-bleed: escape the theme's content container. */
	width: 100vw;
	max-width: 100vw;
	margin: 0 0 0 calc(50% - 50vw);
	padding: 0;
	height: calc(100vh - 120px); /* replaced by the real "below the header" height */
	background: #000;
	overflow: hidden;
}
.cvr-viewer--page .cvr-viewer-feed { position: absolute; inset: 0; }
.cvr-reel-fallback { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff; }
.cvr-reel-fallback video { max-width: 100%; max-height: 90%; }
.cvr-reel-page--empty { padding: 40px 16px; text-align: center; }

/* ---- Comment states ---- */
.cvr-c-item.is-pending { opacity: .62; }
.cvr-c-badge {
	display: inline-block;
	margin-top: 4px;
	padding: 2px 8px;
	border-radius: 999px;
	background: #fff4d6;
	color: #7a5400;
	font-size: 11px;
	font-weight: 600;
}
.cvr-c-msg.is-info { color: #2a6f2a; }
.cvr-c-msg.is-error { color: #b32d2e; }
:is(.cvr-drawer, #cvr-drawer) .cvr-c-post[disabled] { opacity: .6; cursor: default; }

/* ---- Icons + share toast ---- */
:is(.cvr-viewer, #cvr-viewer) .cvr-sound-hint i { margin-right: 4px; }
.cvr-toast {
	position: fixed;
	left: 50%;
	bottom: 90px;
	transform: translate(-50%, 10px);
	z-index: 100002;
	background: rgba(20,20,20,.92);
	color: #fff;
	padding: 9px 16px;
	border-radius: 999px;
	font-size: 14px;
	font-weight: 600;
	opacity: 0;
	pointer-events: none;
	transition: opacity .18s ease, transform .18s ease;
}
.cvr-toast.is-shown { opacity: 1; transform: translate(-50%, 0); }
