/* KMS Mobile Slider v1.0.0 — mobile-first, scroll-snap based. */

/* ---------- Base tokens (Elementor controls override these) ---------- */
.kms {
	--kms-gutter: 16px;
	--kms-gap: 12px;
	--kms-radius: 20px;
	--kms-pad: 20px;
	--kms-peek: 28px;
	--kms-ratio: 4/5;
	--kms-card-ratio: 4/3;
	--kms-hv: 78;
	--kms-jc: flex-end;
	--kms-ta: left;
	--kms-ai: flex-start;
	--kms-shade: rgba(0, 0, 0, .74);
	--kms-shade-dir: to top;
	--kms-shade-stop: 62%;
	--kms-text: #fff;
	--kms-card-bg: #fff;
	--kms-glass: rgba(20, 20, 20, .34);
	--kms-eyebrow-bg: rgba(255, 255, 255, .2);
	--kms-btn-h: 48px;
	--kms-btn-r: 999px;
	--kms-btn-bg: #fff;
	--kms-btn-color: #111;
	--kms-pag-on: #111;
	--kms-pag-dim: rgba(17, 17, 17, .18);
	--kms-arrow-bg: rgba(255, 255, 255, .92);
	--kms-arrow-color: #111;
	--kms-lines: 3;
	--kms-title-gap: 8px;
	position: relative;
	width: 100%;
	min-width: 0;
	max-width: 100%;
	-webkit-tap-highlight-color: transparent;
	box-sizing: border-box;
}
.kms *, .kms *::before, .kms *::after { box-sizing: border-box; }
.kms {
	padding-top: calc(var(--kms-space-above, 0px) + var(--kms-header-offset, 0px));
	padding-bottom: var(--kms-space-below, 20px);
}
/* Full width: no gutter, square corners (Peek keeps its radius so the next card reads as a card). */
.kms--full { --kms-gutter: 0px; --kms-radius: 0px; }
.kms--full.kms--t-peek .kms-track { padding-inline: 0 var(--kms-gap); }
.kms--full.kms--t-card .kms-slide { box-shadow: none; margin-bottom: 0; }

/* Break out of parent container padding: true screen width, centred on the viewport. */
.kms--bleed:not(.kms--wide) {
	width: 100vw;
	max-width: 100vw;
	margin-left: calc(50% - 50vw);
	margin-right: calc(50% - 50vw);
}

/* Debug aid: add ?kms-debug to the URL to outline the slider's real layout box. */
.kms--debug { outline: 2px solid #e5484d; outline-offset: -2px; }

/* Template defaults — single-class selectors so Elementor's {{WRAPPER}} .kms always wins. */
.kms--t-card {
	--kms-text: #111;
	--kms-eyebrow-bg: rgba(17, 17, 17, .07);
	--kms-btn-bg: #111;
	--kms-btn-color: #fff;
}
.kms--t-centered {
	--kms-jc: center;
	--kms-ta: center;
	--kms-ai: center;
	--kms-shade: rgba(0, 0, 0, .5);
}
.kms--t-glass { --kms-shade: rgba(0, 0, 0, .28); }
.kms--pag-overlay-top,
.kms--pag-overlay-bottom {
	--kms-pag-on: #fff;
	--kms-pag-dim: rgba(255, 255, 255, .42);
}
.kms--t-card.kms--pag-overlay-bottom {
	--kms-pag-on: #111;
	--kms-pag-dim: rgba(17, 17, 17, .18);
}

/* ---------- Track (native touch scrolling + snap) ---------- */
/* Elementor flexbox containers size children by min-content; without these the
   in-flow Card text (nowrap buttons) would stretch the widget past the screen. */
.elementor-widget-kms_mobile_slider { min-width: 0; max-width: 100%; }
.kms-viewport { position: relative; min-width: 0; width: 100%; }

.kms-track {
	display: flex;
	gap: var(--kms-gap);
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	scroll-padding-inline: var(--kms-gutter);
	padding-inline: var(--kms-gutter);
	overscroll-behavior-x: contain;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
	outline: none;
	margin: 0;
}
.kms-track::-webkit-scrollbar { display: none; }
/* Full-width slides: gap must be 2× gutter or a sliver of the next slide shows at the edge. */
.kms:not(.kms--t-peek) .kms-track { gap: calc(var(--kms-gutter) * 2); }
.kms-track:focus-visible { box-shadow: inset 0 0 0 2px var(--kms-pag-on); border-radius: var(--kms-radius); }
.kms-track.is-dragging { scroll-snap-type: none; cursor: grabbing; user-select: none; }

.kms-slide {
	position: relative;
	flex: 0 0 100%;
	min-width: 0;
	scroll-snap-align: start;
	scroll-snap-stop: always;
	border-radius: var(--kms-radius);
	overflow: hidden;
	isolation: isolate;
	color: var(--kms-text);
	background: #1a1a1a;
	transform: translateZ(0); /* Safari: keeps radius clipping during scroll */
}
.kms--h-ratio .kms-slide { aspect-ratio: var(--kms-ratio); }
.kms--h-vh .kms-slide {
	height: calc(var(--kms-hv) * 1vh);
	height: calc(var(--kms-hv) * 1svh);
	min-height: 360px;
}

/* ---------- Media ---------- */
.kms-media { position: absolute; inset: 0; z-index: 0; overflow: hidden; }
.kms-media picture { display: contents; }
.kms .kms-img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	border: 0;
	border-radius: 0;
	object-fit: cover;
	object-position: var(--kms-pos, center center);
	-webkit-user-drag: none;
	user-select: none;
	pointer-events: none;
}

.kms-shade {
	position: absolute;
	inset: 0;
	z-index: 1;
	pointer-events: none;
	background: linear-gradient(var(--kms-shade-dir), var(--kms-shade) 0%, rgba(0, 0, 0, 0) var(--kms-shade-stop));
}
.kms--t-centered .kms-shade { background: var(--kms-shade); }

.kms-cover { position: absolute; inset: 0; z-index: 2; }

/* ---------- Content ---------- */
.kms-content {
	position: absolute;
	inset: 0;
	z-index: 3;
	display: flex;
	flex-direction: column;
	justify-content: var(--kms-jc);
	padding: var(--kms-pad);
	pointer-events: none;
}
.kms-panel {
	display: flex;
	flex-direction: column;
	align-items: var(--kms-ai);
	text-align: var(--kms-ta);
	max-width: 100%;
}
.kms-panel a, .kms-panel button { pointer-events: auto; }

.kms:not(.kms--t-card) .kms-panel { text-shadow: 0 1px 14px rgba(0, 0, 0, .28); }

.kms .kms-eyebrow {
	display: inline-block;
	margin: 0 0 10px;
	font-size: 12px;
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: .09em;
	text-transform: uppercase;
	color: var(--kms-eyebrow-color, var(--kms-text));
	text-shadow: none;
}
.kms--eb-pill .kms-eyebrow {
	padding: 6px 11px;
	border-radius: 999px;
	background: var(--kms-eyebrow-bg);
	-webkit-backdrop-filter: blur(8px);
	backdrop-filter: blur(8px);
}

.kms .kms-title {
	margin: 0 0 var(--kms-title-gap);
	padding: 0;
	font-size: clamp(26px, 7.2vw, 34px);
	font-weight: 700;
	line-height: 1.1;
	letter-spacing: -.02em;
	color: var(--kms-title-color, var(--kms-text));
	text-wrap: balance;
	overflow-wrap: anywhere;
	display: -webkit-box;
	-webkit-line-clamp: 4;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
.kms--t-centered .kms-title { font-size: clamp(30px, 8.6vw, 40px); }

.kms .kms-desc {
	margin: 0;
	padding: 0;
	font-size: 15px;
	font-weight: 400;
	line-height: 1.5;
	color: var(--kms-desc-color, var(--kms-text));
	opacity: .92;
	max-width: 36ch;
	display: -webkit-box;
	-webkit-line-clamp: var(--kms-lines);
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* ---------- Buttons (48px tap targets) ---------- */
.kms-btns {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 18px;
	width: 100%;
	justify-content: var(--kms-ai);
}
.kms--btn-full .kms-btns {
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: minmax(0, 1fr);
}
.kms--btn-stack .kms-btns { display: grid; grid-template-columns: 1fr; }

.kms .kms-btn,
.kms .kms-btn:hover,
.kms .kms-btn:focus,
.kms .kms-btn:visited {
	text-decoration: none;
}
.kms .kms-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: var(--kms-btn-h);
	padding: 0 22px;
	border-radius: var(--kms-btn-r);
	font-size: 15px;
	font-weight: 600;
	line-height: 1.1;
	letter-spacing: .005em;
	text-align: center;
	text-shadow: none;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	border: 1.5px solid transparent;
	transition: transform .15s ease, opacity .15s ease, background-color .2s ease;
	touch-action: manipulation;
}
.kms .kms-btn:active { transform: scale(.97); }
.kms .kms-btn:focus-visible { outline: 2px solid var(--kms-btn-bg); outline-offset: 3px; }
.kms .kms-btn--1,
.kms .kms-btn--1:hover,
.kms .kms-btn--1:visited {
	background: var(--kms-btn-bg);
	color: var(--kms-btn-color);
}
.kms .kms-btn--2,
.kms .kms-btn--2:hover,
.kms .kms-btn--2:visited {
	background: transparent;
	color: var(--kms-btn2-color, var(--kms-text));
	border-color: var(--kms-btn2-color, var(--kms-text));
}
.kms:not(.kms--t-card) .kms-btn--2 {
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
	background: rgba(255, 255, 255, .08);
}

/* ---------- Template: Card ---------- */
.kms--t-card .kms-track { align-items: flex-start; }
/* Track hugs the active card so a slide without a description has no empty gap. */
.kms--t-card.kms--ready .kms-track { transition: height .35s cubic-bezier(.2, .7, .2, 1); }
.kms--t-card .kms-slide {
	display: flex;
	flex-direction: column;
	background: var(--kms-card-bg);
	box-shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 8px 24px rgba(0, 0, 0, .07);
	margin-bottom: 6px; /* room for the shadow inside overflow */
}
.kms--t-card .kms-media { position: relative; inset: auto; aspect-ratio: var(--kms-card-ratio); flex: 0 0 auto; }
.kms--t-card .kms-content { position: relative; inset: auto; flex: 1 1 auto; justify-content: flex-start; }
.kms--t-card .kms-panel { flex: 1 1 auto; }
.kms--t-card .kms-btns { margin-top: 18px; }
.kms--t-card .kms .kms-title, .kms--t-card .kms-title { font-size: clamp(22px, 6vw, 27px); }
.kms--t-card .kms-desc { opacity: .72; }

/* ---------- Template: Glass ---------- */
.kms--t-glass .kms-content { padding: calc(var(--kms-pad) * .6); }
.kms--t-glass .kms-panel {
	width: 100%;
	padding: var(--kms-pad);
	border-radius: max(8px, calc(var(--kms-radius) - 6px));
	background: var(--kms-glass);
	border: 1px solid rgba(255, 255, 255, .22);
	-webkit-backdrop-filter: blur(18px) saturate(150%);
	backdrop-filter: blur(18px) saturate(150%);
	text-shadow: none;
}
.kms--t-glass .kms-desc { max-width: none; }

/* ---------- Template: Peek ---------- */
.kms--t-peek .kms-slide { flex-basis: calc(100% - var(--kms-peek) - var(--kms-gap)); }
.kms--t-peek.kms--ready .kms-slide { transition: transform .45s cubic-bezier(.2, .7, .2, 1), opacity .45s ease; }
.kms--t-peek.kms--ready .kms-slide:not(.is-active) { transform: scale(.94); opacity: .62; }
.kms--t-peek .kms .kms-title, .kms--t-peek .kms-title { font-size: clamp(24px, 6.6vw, 31px); }

/* ---------- Pagination ---------- */
.kms { background: var(--kms-bg, transparent); }
.kms-pag {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 2px;
	padding: var(--kms-pag-pad, 10px) var(--kms-gutter);
	margin-top: var(--kms-pag-offset, 2px);
	background: var(--kms-pag-bg, transparent);
}
.kms--pag-overlay-top .kms-pag,
.kms--pag-overlay-bottom .kms-pag {
	position: absolute;
	left: calc(var(--kms-gutter) + 12px);
	right: calc(var(--kms-gutter) + 12px);
	z-index: 4;
	margin: 0;
	background: none;
	padding: 0;
	pointer-events: none;
}
.kms--pag-overlay-top .kms-pag { top: 10px; }
.kms--pag-overlay-bottom .kms-pag { bottom: 10px; }
.kms--t-peek.kms--pag-overlay-top .kms-pag,
.kms--t-peek.kms--pag-overlay-bottom .kms-pag { right: calc(var(--kms-gutter) + var(--kms-peek) + var(--kms-gap) + 12px); }
.kms--pag-overlay-top .kms-content { padding-top: calc(var(--kms-pad) + 22px); }
.kms--pag-overlay-bottom .kms-content { padding-bottom: calc(var(--kms-pad) + 26px); }
.kms-pag button { pointer-events: auto; }

.kms .kms-dot,
.kms .kms-bar {
	appearance: none;
	-webkit-appearance: none;
	background: none;
	border: 0;
	margin: 0;
	padding: 0;
	min-width: 0;
	box-shadow: none;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	touch-action: manipulation;
}
.kms .kms-dot { width: 24px; height: 24px; } /* 24px hit area, 8px visual */
.kms .kms-dot span {
	display: block;
	width: 8px;
	height: 8px;
	border-radius: 999px;
	background: var(--kms-pag-dim);
	transition: width .3s ease, background-color .3s ease;
}
.kms .kms-dot.is-active { width: 34px; }
.kms .kms-dot.is-active span { width: 24px; background: var(--kms-pag-on); }

.kms-pag--bars { gap: 5px; }
.kms .kms-bar { flex: 1 1 0; height: 20px; max-width: 120px; }
.kms .kms-bar span {
	display: block;
	position: relative;
	width: 100%;
	height: 3px;
	border-radius: 3px;
	overflow: hidden;
	background: var(--kms-pag-dim);
}
.kms .kms-bar i {
	position: absolute;
	inset: 0;
	background: var(--kms-pag-on);
	transform-origin: left center;
	transform: scaleX(0);
}
.kms .kms-bar.is-done i { transform: scaleX(1); }
.kms .kms-bar.is-active i { animation: kms-fill var(--kms-dur) linear forwards; }
.kms--noauto .kms-bar.is-active i { animation: none; transform: scaleX(1); }
.kms--paused .kms-bar.is-active i { animation-play-state: paused; }
@keyframes kms-fill { to { transform: scaleX(1); } }

.kms-frac {
	display: inline-flex;
	gap: 4px;
	padding: 5px 11px;
	border-radius: 999px;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.2;
	font-variant-numeric: tabular-nums;
	color: var(--kms-pag-on);
	background: var(--kms-pag-dim);
}
.kms--pag-overlay-top .kms-pag--fraction,
.kms--pag-overlay-bottom .kms-pag--fraction { justify-content: flex-end; }
.kms--pag-overlay-top .kms-frac,
.kms--pag-overlay-bottom .kms-frac { background: rgba(0, 0, 0, .35); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.kms-frac-sep { opacity: .55; }

/* ---------- Arrows ---------- */
.kms .kms-arrow {
	appearance: none;
	-webkit-appearance: none;
	position: absolute;
	top: var(--kms-arrow-top, 50%);
	z-index: 5;
	width: var(--kms-arrow-size, 40px);
	height: var(--kms-arrow-size, 40px);
	margin: calc(var(--kms-arrow-size, 40px) / -2) 0 0;
	padding: 0;
	border: 0;
	border-radius: 999px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--kms-arrow-bg);
	color: var(--kms-arrow-color);
	box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
	cursor: pointer;
	touch-action: manipulation;
}
.kms .kms-arrow svg { width: 50%; height: 50%; }
.kms .kms-arrow:focus-visible { outline: 2px solid var(--kms-arrow-color); outline-offset: 2px; }
.kms .kms-arrow--prev { left: calc(var(--kms-gutter) + 10px); }
.kms .kms-arrow--next { right: calc(var(--kms-gutter) + 10px); }
.kms--t-peek .kms-arrow--next { right: calc(var(--kms-gutter) + var(--kms-peek) + var(--kms-gap) + 10px); }
.kms .kms-arrow:active { transform: scale(.94); }
.kms .kms-arrow[disabled] { opacity: .35; }

/* ---------- Motion (only once JS is running, so no-JS stays fully visible) ---------- */
.kms--anim.kms--ready .kms-panel > * {
	opacity: 0;
	transform: translateY(14px);
	transition: opacity .5s ease, transform .6s cubic-bezier(.2, .7, .2, 1);
}
.kms--anim.kms--ready .kms-slide.is-active .kms-panel > * { opacity: 1; transform: none; }
.kms--anim.kms--ready .kms-slide.is-active .kms-panel > :nth-child(2) { transition-delay: .07s; }
.kms--anim.kms--ready .kms-slide.is-active .kms-panel > :nth-child(3) { transition-delay: .14s; }
.kms--anim.kms--ready .kms-slide.is-active .kms-panel > :nth-child(4) { transition-delay: .21s; }
.kms--anim.kms--ready:not(.kms--t-card) .kms-img { transform: scale(1.07); transition: transform 7s ease-out; }
.kms--anim.kms--ready:not(.kms--t-card) .kms-slide.is-active .kms-img { transform: scale(1); }
.kms--t-peek.kms--anim.kms--ready .kms-panel > * { opacity: 1; transform: none; }

.kms-track.kms--nudge { animation: kms-nudge 1.1s cubic-bezier(.3, .7, .3, 1) 1; }
@keyframes kms-nudge {
	0%, 100% { transform: translateX(0); }
	35% { transform: translateX(-34px); }
	65% { transform: translateX(4px); }
}

@media (prefers-reduced-motion: reduce) {
	.kms *, .kms-track { animation: none !important; transition: none !important; }
	.kms--anim.kms--ready .kms-panel > * { opacity: 1; transform: none; }
	.kms .kms-img { transform: none !important; }
}

/* ---------- Editor helper: preview as a phone on wide canvases ---------- */
.kms--editor.kms--wide {
	max-width: 414px;
	margin-inline: auto;
	padding-top: 30px;
	outline: 2px dashed rgba(111, 66, 193, .5);
	outline-offset: 6px;
	border-radius: 6px;
}
.kms--editor.kms--wide::before {
	content: attr(data-kms-label);
	position: absolute;
	top: 4px;
	left: 0;
	right: 0;
	text-align: center;
	font: 600 10px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	letter-spacing: .08em;
	color: #6f42c1;
}
