/* SearchEV YouTube — front-end styles
 * Theming is driven by CSS custom properties set inline per shortcode instance.
 * Fallbacks below keep the block usable even if no inline vars are present.
 * ------------------------------------------------------------------------- */

.sevyt {
	--sevyt-accent: #15c39a;
	--sevyt-bg: #ffffff;
	--sevyt-card: #ffffff;
	--sevyt-text: #0f1722;
	--sevyt-muted: #5b6b7b;
	--sevyt-border: #e6ebf0;
	--sevyt-radius: 14px;

	/* Carousel controls (arrows + bullets). Defaults match the reference:
	   solid black active, warm grey inactive. */
	--sevyt-control: #000000;
	--sevyt-control-off: #c7c4c2;

	--sevyt-gap: 18px;
	--sevyt-shadow: 0 1px 2px rgba(15, 23, 34, 0.06), 0 8px 24px rgba(15, 23, 34, 0.06);
	--sevyt-shadow-hover: 0 6px 14px rgba(15, 23, 34, 0.10), 0 18px 44px rgba(15, 23, 34, 0.12);

	box-sizing: border-box;
	color: var(--sevyt-text);
	background: var(--sevyt-bg);
	font-family: inherit;
	line-height: 1.45;
	-webkit-font-smoothing: antialiased;
}

.sevyt *,
.sevyt *::before,
.sevyt *::after {
	box-sizing: border-box;
}

.sevyt__heading {
	margin: 0 0 var(--sevyt-gap);
	font-size: clamp(1.15rem, 1rem + 0.8vw, 1.6rem);
	font-weight: 750;
	letter-spacing: -0.015em;
	color: var(--sevyt-text);
}

/* ---------- Card --------------------------------------------------------- */

.sevyt__card {
	display: flex;
	flex-direction: column;
	background: var(--sevyt-card);
	border: 1px solid var(--sevyt-border);
	border-radius: var(--sevyt-radius);
	overflow: hidden;
	transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.sevyt__card:hover {
	transform: translateY(-3px);
	box-shadow: var(--sevyt-shadow-hover);
	border-color: color-mix(in srgb, var(--sevyt-accent) 35%, var(--sevyt-border));
}

.sevyt__thumb {
	position: relative;
	display: block;
	aspect-ratio: 16 / 9;
	background: #0c1116;
	overflow: hidden;
	text-decoration: none;
}

.sevyt__thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.4s ease, opacity 0.3s ease;
}

.sevyt__card:hover .sevyt__thumb img {
	transform: scale(1.045);
}

/* Play overlay — always visible so viewers can see the video is playable.
   (Hover-only meant it never appeared at all on touch devices.) */
.sevyt__play {
	position: absolute;
	inset: 0;
	margin: auto;
	width: 58px;
	height: 58px;
	display: grid;
	place-items: center;
	border-radius: 50%;
	color: #fff;
	background: color-mix(in srgb, var(--sevyt-accent) 88%, #000 4%);
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
	opacity: 1;
	transform: translateY(0) scale(1);
	transition: opacity 0.22s ease, transform 0.22s ease, background 0.22s ease;
	pointer-events: none;
}

.sevyt__play svg {
	margin-left: 3px; /* optically centre the triangle */
}

/* Hover simply emphasises the button rather than revealing it. */
.sevyt__thumb:hover .sevyt__play,
.sevyt__thumb:focus-visible .sevyt__play {
	transform: scale(1.1);
	box-shadow: 0 6px 22px rgba(0, 0, 0, 0.45);
}

/* Smaller play button on the narrower Shorts cards. */
.sevyt--shorts .sevyt__play {
	width: 48px;
	height: 48px;
}

/* Duration + short badges */
.sevyt__badge {
	position: absolute;
	right: 8px;
	bottom: 8px;
	padding: 2px 7px;
	font-size: 0.72rem;
	font-weight: 650;
	font-variant-numeric: tabular-nums;
	color: #fff;
	background: rgba(0, 0, 0, 0.82);
	border-radius: 6px;
	letter-spacing: 0.01em;
}

.sevyt__short-tag {
	position: absolute;
	left: 8px;
	top: 8px;
	padding: 3px 8px;
	font-size: 0.66rem;
	font-weight: 750;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: #fff;
	background: var(--sevyt-accent);
	border-radius: 6px;
}

/* Meta */
.sevyt__meta {
	padding: 12px 14px 14px;
	display: flex;
	flex-direction: column;
	gap: 5px;
}

.sevyt__title {
	margin: 0;
	font-size: 0.95rem;
	font-weight: 650;
	line-height: 1.3;
	color: var(--sevyt-text);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.sevyt__sub {
	margin: 0;
	font-size: 0.8rem;
	color: var(--sevyt-muted);
	font-variant-numeric: tabular-nums;
}

.sevyt__dot {
	opacity: 0.55;
	margin: 0 1px;
}

/* ---------- Library (grid) ---------------------------------------------- */

.sevyt__grid {
	display: grid;
	grid-template-columns: repeat(var(--sevyt-cols, 3), minmax(0, 1fr));
	gap: var(--sevyt-gap);
}

/* ---------- Carousel ----------------------------------------------------- */

.sevyt__carousel {
	position: relative;
	/* Reserve gutters on each side so the arrows sit outside the cards. */
	padding: 0 52px;
}

.sevyt__track {
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: minmax(260px, calc((100% - 2 * var(--sevyt-gap)) / 3));
	gap: var(--sevyt-gap);
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	padding: 6px 2px 14px;
	scrollbar-width: thin;
	scrollbar-color: var(--sevyt-border) transparent;
	-webkit-overflow-scrolling: touch;
	/* Ask the browser for horizontal panning. Some themes set `pan-y` on a
	   parent, which blocks this for the whole subtree — the JS detects that
	   and drives the scroll manually, so swiping works either way. */
	touch-action: pan-x pan-y;
	overscroll-behavior-x: contain;
}

/* While the JS is driving a manual swipe, smooth-scroll must be off or every
   frame would animate and the drag would feel laggy/stuck. */
.sevyt__track.is-dragging {
	scroll-behavior: auto;
	scroll-snap-type: none;
}

.sevyt__track::-webkit-scrollbar {
	height: 8px;
}
.sevyt__track::-webkit-scrollbar-thumb {
	background: var(--sevyt-border);
	border-radius: 8px;
}

.sevyt__track > .sevyt__card {
	scroll-snap-align: start;
}

.sevyt__nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 3;
	width: 44px;
	height: 44px;
	display: grid;
	place-items: center;
	padding: 0;
	border: 0;
	border-radius: 50%;
	/* Active direction: flat solid-black circle, white chevron (no shadow). */
	background: var(--sevyt-control);
	color: #ffffff;
	cursor: pointer;
	box-shadow: none;
	transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease, opacity 0.2s ease;
}

.sevyt__nav:not(:disabled):hover {
	background: var(--sevyt-control);
	transform: translateY(-50%) scale(1.07);
}

.sevyt__nav:disabled {
	/* Disabled direction stays visible as a soft grey circle (per design). */
	background: var(--sevyt-control-off);
	color: #ffffff;
	box-shadow: none;
	cursor: default;
}

.sevyt__nav svg {
	display: block;
	width: 20px;
	height: 20px;
}

.sevyt__nav svg path {
	stroke-width: 2;
}

.sevyt__nav--prev { left: 4px; }
.sevyt__nav--next { right: 4px; }

/* Hide controls entirely when everything already fits (set by JS). */
.sevyt__nav[hidden] { display: none; }

/* ---------- Bullet pagination ------------------------------------------- */

.sevyt__dots {
	display: flex;
	justify-content: flex-end;
	align-items: center;
	gap: 18px;
	margin-top: 14px;
	padding-right: 52px; /* line the dots up with the right edge of the cards */
}

.sevyt__dot {
	/* Visual size stays 9px, but the tappable area is padded out to ~30px
	   so the dots are usable as a real control on touch screens. */
	width: 9px;
	height: 9px;
	box-sizing: content-box;
	padding: 10px 6px;
	margin: -10px -6px;
	border: 0;
	background: var(--sevyt-control-off);
	background-clip: content-box;
	border-radius: 50%;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	transition: background 0.2s ease, transform 0.2s ease;
}

.sevyt__dot:hover {
	transform: scale(1.15);
}

.sevyt__dot.is-active {
	/* Same size as the others — just solid black (no pill). */
	background: var(--sevyt-control);
	background-clip: content-box;
}

/* ---------- Shorts (vertical) ------------------------------------------- */

.sevyt--shorts .sevyt__thumb {
	aspect-ratio: 9 / 16;
}

.sevyt--shorts.sevyt--carousel .sevyt__track {
	grid-auto-columns: minmax(170px, calc((100% - 4 * var(--sevyt-gap)) / 5));
}

.sevyt--shorts.sevyt--library .sevyt__grid {
	grid-template-columns: repeat(var(--sevyt-cols, 5), minmax(0, 1fr));
}

.sevyt--shorts .sevyt__title {
	font-size: 0.88rem;
}

/* ---------- Inline player ------------------------------------------------ */

.sevyt__thumb.is-playing img,
.sevyt__thumb.is-playing .sevyt__play,
.sevyt__thumb.is-playing .sevyt__badge,
.sevyt__thumb.is-playing .sevyt__short-tag {
	display: none;
}

.sevyt__iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

/* ---------- Lightbox ----------------------------------------------------- */

.sevyt-lightbox {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 4vmin;
	background: rgba(8, 12, 17, 0.86);
	backdrop-filter: blur(4px);
	opacity: 0;
	/* When closed, the overlay must not sit on top of the page and swallow
	   clicks/hover. visibility + pointer-events make it inert until opened. */
	visibility: hidden;
	pointer-events: none;
	transition: opacity 0.2s ease, visibility 0.2s ease;
}

.sevyt-lightbox.is-open {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

/* Wrapper that holds the video and the close button. It is NOT clipped,
   so the close button can sit just outside the rounded video corner. */
.sevyt-lightbox__dialog {
	position: relative;
	transform: scale(0.96);
	transition: transform 0.22s ease;
}

.sevyt-lightbox.is-open .sevyt-lightbox__dialog {
	transform: scale(1);
}

.sevyt-lightbox__inner {
	position: relative;
	width: min(960px, 92vw);
	aspect-ratio: 16 / 9;
	background: #000;
	border-radius: 12px;
	overflow: hidden;
	box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}

.sevyt-lightbox--vertical .sevyt-lightbox__inner {
	width: auto;
	height: min(82vh, 860px);
	max-width: 92vw;
	aspect-ratio: 9 / 16;
}

.sevyt-lightbox iframe {
	width: 100%;
	height: 100%;
	border: 0;
	display: block;
}

.sevyt-lightbox__close {
	position: absolute;
	top: -16px;
	right: -16px;
	z-index: 2;
	width: 40px;
	height: 40px;
	padding: 0;
	border-radius: 50%;
	border: 0;
	background: #fff;
	color: #0f1722;
	font-size: 26px;
	font-weight: 400;
	line-height: 1;
	cursor: pointer;
	display: grid;
	place-items: center;
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
	transition: transform 0.15s ease, background 0.15s ease;
}

.sevyt-lightbox__close:hover {
	transform: scale(1.08);
	background: #f3f4f6;
}

/* On small screens, tuck the button inside the top-right corner so the
   negative offset can't push it off-screen. */
@media (max-width: 600px) {
	.sevyt-lightbox__close {
		top: 8px;
		right: 8px;
		background: rgba(255, 255, 255, 0.92);
	}
}

/* ---------- Admin diagnostic notice ------------------------------------- */

.sevyt__notice {
	padding: 14px 16px;
	border: 1px dashed #d6a200;
	background: #fff8e5;
	border-radius: 10px;
	color: #5a4500;
	font-size: 0.9rem;
}
.sevyt__notice a { color: inherit; font-weight: 700; }

/* ---------- Focus + responsive + reduced motion ------------------------- */

.sevyt a:focus-visible,
.sevyt button:focus-visible,
.sevyt-lightbox__close:focus-visible {
	outline: 3px solid var(--sevyt-accent);
	outline-offset: 2px;
	border-radius: 8px;
}

@media (max-width: 1024px) {
	.sevyt__grid { grid-template-columns: repeat(min(var(--sevyt-cols, 3), 3), minmax(0, 1fr)); }
	.sevyt__track { grid-auto-columns: minmax(240px, calc((100% - var(--sevyt-gap)) / 2)); }
	.sevyt--shorts.sevyt--carousel .sevyt__track { grid-auto-columns: minmax(150px, calc((100% - 3 * var(--sevyt-gap)) / 4)); }
}

@media (max-width: 680px) {
	.sevyt__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.sevyt--shorts.sevyt--library .sevyt__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
	.sevyt__track { grid-auto-columns: minmax(78%, 78%); }
	.sevyt--shorts.sevyt--carousel .sevyt__track { grid-auto-columns: minmax(45%, 45%); }
	/* No room for gutter arrows on phones — rely on swipe + dots. */
	.sevyt__carousel { padding: 0; }
	.sevyt__nav { display: none; }
	.sevyt__dots { padding-right: 4px; }
}

@media (max-width: 420px) {
	.sevyt__grid { grid-template-columns: minmax(0, 1fr); }
	.sevyt--shorts.sevyt--library .sevyt__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
	.sevyt *,
	.sevyt-lightbox,
	.sevyt-lightbox__inner {
		transition: none !important;
	}
	.sevyt__track { scroll-behavior: auto; }
}
