/*! TikTok Products v2 - frontend */

.ttp-section {
	--ttp-accent: var(--primary-color, #446084);
	--ttp-radius: 12px;
	--ttp-gap: 14px;
	--ttp-card-w: 78vw;
	--ttp-embed-w: 325px;
	--ttp-embed-h: 740px;
	--ttp-overlay: rgba(0, 0, 0, .5);
	--ttp-fg: #fff;
	margin: 28px 0;
}

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

.ttp-section__title { font-size: 1.15em; margin: 0 0 14px; }

/* ---------- carousel ---------- */

.ttp-viewport { position: relative; }

.ttp-track {
	display: flex;
	gap: var(--ttp-gap);
	margin: 0;
	padding: 0 0 6px;
	list-style: none;
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
	align-items: flex-start;
}
.ttp-track::-webkit-scrollbar { display: none; }
.ttp-track > li { list-style: none; margin: 0; }

@media (min-width: 480px) { .ttp-section { --ttp-card-w: 56vw; } }
@media (min-width: 768px) { .ttp-section { --ttp-card-w: 240px; } }
@media (min-width: 1024px) { .ttp-section { --ttp-card-w: 260px; } }

/* ---------- card ---------- */

.ttp-card {
	flex: 0 0 var(--ttp-card-w);
	max-width: var(--ttp-card-w);
	scroll-snap-align: center;
}

/* The TikTok embed refuses to lay out below roughly 325px. */
.ttp-card[data-source="tiktok"] {
	flex-basis: min(var(--ttp-embed-w), 92vw);
	max-width: min(var(--ttp-embed-w), 92vw);
}

.ttp-card__media {
	position: relative;
	width: 100%;
	aspect-ratio: 9 / 16;
	border-radius: var(--ttp-radius);
	overflow: hidden;
	background: #111;
}

@supports not (aspect-ratio: 9 / 16) {
	.ttp-card__media { height: 0; padding-bottom: 177.78%; }
}

/* Once the embed is live the card grows to the height TikTok needs. */
.ttp-card[data-source="tiktok"][data-state="live"] .ttp-card__media {
	aspect-ratio: auto;
	height: var(--ttp-embed-h);
	padding-bottom: 0;
	background: transparent;
}

.ttp-card__poster {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	z-index: 1;
}
.ttp-card__poster--empty { background: linear-gradient(160deg, #2a2f36, #14171b); }

.ttp-card__frame {
	position: absolute;
	inset: 0;
	z-index: 2;
	opacity: 0;
	transition: opacity .18s ease;
}
.ttp-card__frame iframe,
.ttp-card__frame video {
	width: 100%;
	height: 100%;
	border: 0;
	display: block;
	background: #000;
}
.ttp-card__frame video { object-fit: cover; }

.ttp-card[data-state="live"] .ttp-card__frame,
.ttp-card[data-state="playing"] .ttp-card__frame,
.ttp-card[data-state="paused"] .ttp-card__frame { opacity: 1; }

.ttp-card[data-state="live"] .ttp-card__poster,
.ttp-card[data-state="playing"] .ttp-card__poster,
.ttp-card[data-state="paused"] .ttp-card__poster { opacity: 0; }

/* ---------- facade ---------- */

.ttp-card__facade {
	position: absolute;
	inset: 0;
	z-index: 3;
	appearance: none;
	border: 0;
	margin: 0;
	padding: 0;
	background: transparent;
	cursor: pointer;
	display: block;
}
.ttp-card[data-state="live"] .ttp-card__facade,
.ttp-card[data-state="playing"] .ttp-card__facade,
.ttp-card[data-state="paused"] .ttp-card__facade { display: none; }

.ttp-card__cue {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 62px;
	height: 62px;
	margin: -31px 0 0 -31px;
	border-radius: 50%;
	background: var(--ttp-overlay);
	backdrop-filter: blur(3px);
	-webkit-backdrop-filter: blur(3px);
	transition: transform .18s ease, background .18s ease;
}
.ttp-card__cue::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 54%;
	transform: translate(-50%, -50%);
	border-style: solid;
	border-width: 12px 0 12px 19px;
	border-color: transparent transparent transparent var(--ttp-fg);
}
.ttp-card__facade:hover .ttp-card__cue { transform: scale(1.06); background: rgba(0, 0, 0, .62); }
.ttp-card__facade:focus-visible { outline: 2px solid var(--ttp-accent); outline-offset: 2px; }

/* ---------- close (embed only) ---------- */

.ttp-card__close {
	position: absolute;
	top: 8px;
	right: 8px;
	z-index: 6;
	width: 34px;
	height: 34px;
	border: 0;
	border-radius: 50%;
	background: var(--ttp-overlay);
	color: var(--ttp-fg);
	cursor: pointer;
	display: none;
	padding: 0;
}
.ttp-card[data-state="live"] .ttp-card__close { display: block; }
.ttp-card__close::before,
.ttp-card__close::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 14px;
	height: 2px;
	background: currentColor;
	transform-origin: center;
}
.ttp-card__close::before { transform: translate(-50%, -50%) rotate(45deg); }
.ttp-card__close::after { transform: translate(-50%, -50%) rotate(-45deg); }
.ttp-card__close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ---------- controls (self hosted only) ---------- */

.ttp-card__controls {
	position: absolute;
	left: 8px;
	right: 8px;
	bottom: 8px;
	z-index: 5;
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 6px;
	border-radius: 999px;
	background: var(--ttp-overlay);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	opacity: 0;
	transform: translateY(6px);
	transition: opacity .18s ease, transform .18s ease;
}
.ttp-card:hover .ttp-card__controls,
.ttp-card:focus-within .ttp-card__controls,
.ttp-card[data-state="playing"] .ttp-card__controls,
.ttp-card[data-state="paused"] .ttp-card__controls { opacity: 1; transform: none; }

.ttp-btn {
	flex: 0 0 auto;
	width: 44px;
	height: 44px;
	min-width: 44px;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--ttp-fg);
	cursor: pointer;
	position: relative;
	padding: 0;
	appearance: none;
}
.ttp-btn:focus-visible,
.ttp-progress:focus-visible,
.ttp-nav__btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.ttp-btn--play::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 53%;
	transform: translate(-50%, -50%);
	border-style: solid;
	border-width: 7px 0 7px 12px;
	border-color: transparent transparent transparent currentColor;
}
.ttp-btn--play[aria-pressed="true"]::before {
	border: 0;
	width: 11px;
	height: 13px;
	left: 50%;
	border-left: 4px solid currentColor;
	border-right: 4px solid currentColor;
}

.ttp-btn--sound::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 16px;
	height: 16px;
	margin: -8px 0 0 -8px;
	background: currentColor;
	clip-path: polygon(0 33%, 33% 33%, 66% 5%, 66% 95%, 33% 66%, 0 66%);
}
.ttp-btn--sound::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 62%;
	width: 14px;
	height: 2px;
	margin-top: -1px;
	background: currentColor;
	transform: rotate(-45deg);
	transform-origin: left center;
}
.ttp-btn--sound[aria-pressed="true"]::after { opacity: 0; }

.ttp-progress {
	flex: 1 1 auto;
	height: 20px;
	position: relative;
	cursor: pointer;
	min-width: 24px;
	display: flex;
	align-items: center;
}
.ttp-progress::before {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	height: 3px;
	border-radius: 3px;
	background: rgba(255, 255, 255, .35);
}
.ttp-progress__bar {
	position: relative;
	height: 3px;
	width: 0;
	border-radius: 3px;
	background: var(--ttp-fg);
	transition: width .12s linear;
}

.ttp-time {
	flex: 0 0 auto;
	font-size: 11px;
	line-height: 1;
	color: var(--ttp-fg);
	font-variant-numeric: tabular-nums;
	padding-right: 2px;
}

.ttp-card__index {
	position: absolute;
	top: 8px;
	left: 8px;
	z-index: 5;
	font-size: 11px;
	line-height: 1;
	padding: 4px 8px;
	border-radius: 999px;
	background: var(--ttp-overlay);
	color: var(--ttp-fg);
	pointer-events: none;
}
.ttp-card[data-state="live"] .ttp-card__index { display: none; }

.ttp-card__note {
	margin: 8px 2px 0;
	font-size: .86em;
	line-height: 1.45;
	opacity: .85;
}

/* ---------- nav ---------- */

.ttp-nav {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 14px;
	margin-top: 14px;
}
.ttp-nav__btn {
	width: 44px;
	height: 44px;
	border-radius: 50%;
	border: 1px solid currentColor;
	background: transparent;
	color: var(--ttp-accent);
	cursor: pointer;
	position: relative;
	appearance: none;
	padding: 0;
}
.ttp-nav__btn[disabled] { opacity: .35; cursor: default; }
.ttp-nav__btn::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 9px;
	height: 9px;
	border-top: 2px solid currentColor;
	border-right: 2px solid currentColor;
}
.ttp-nav__btn--prev::before { transform: translate(-40%, -50%) rotate(-135deg); }
.ttp-nav__btn--next::before { transform: translate(-60%, -50%) rotate(45deg); }
.ttp-nav__status { font-size: .85em; opacity: .8; min-width: 8em; text-align: center; }

/* ---------- no JS ---------- */

.ttp-section:not(.is-ready) .ttp-card__controls,
.ttp-section:not(.is-ready) .ttp-card__facade,
.ttp-section:not(.is-ready) .ttp-nav { display: none; }

/* ---------- motion ---------- */

@media (prefers-reduced-motion: reduce) {
	.ttp-track { scroll-behavior: auto; }
	.ttp-card__cue,
	.ttp-card__frame,
	.ttp-card__controls,
	.ttp-progress__bar { transition: none; }
}
