/* TikTok Mode - ALVETAK
   Self-contained, theme-independent. All selectors namespaced under tiktokmode- to avoid Journal collisions. */

:root {
	--tktk-bg: #0a0a0c;
	--tktk-fg: #ffffff;
	--tktk-accent: #ff2d55;
	--tktk-accent-2: #25f4ee;
	--tktk-muted: rgba(255,255,255,0.72);
	--tktk-glass: rgba(20,20,22,0.55);
}

/* ---------- Launch button ---------- */
.tiktokmode-launch-btn {
	position: fixed;
	z-index: 2147483000; /* max-safe-ish, wins against almost any theme z-index */
	isolation: isolate;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	border: none;
	border-radius: 999px;
	background: linear-gradient(135deg, var(--tktk-accent) 0%, var(--tktk-accent-2) 100%);
	color: #fff;
	font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
	font-weight: 600;
	letter-spacing: .2px;
	cursor: pointer;
	box-shadow: 0 6px 24px rgba(255,45,85,0.35), 0 2px 8px rgba(0,0,0,0.25);
	transition: transform .18s cubic-bezier(.34,1.56,.64,1), box-shadow .18s ease;
	-webkit-tap-highlight-color: transparent;
}
.tiktokmode-launch-btn:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 10px 28px rgba(255,45,85,0.45); }
.tiktokmode-launch-btn:active { transform: scale(.96); }

.tiktokmode-shape-pill    { border-radius: 999px; }
.tiktokmode-shape-rounded { border-radius: 14px; }
.tiktokmode-shape-square  { border-radius: 4px; }

.tiktokmode-pos-bottom-right { right: var(--tktk-offset-x); bottom: var(--tktk-offset-y); }
.tiktokmode-pos-bottom-left  { left:  var(--tktk-offset-x); bottom: var(--tktk-offset-y); }
.tiktokmode-pos-top-right    { right: var(--tktk-offset-x); top:    var(--tktk-offset-y); }
.tiktokmode-pos-top-left     { left:  var(--tktk-offset-x); top:    var(--tktk-offset-y); }
.tiktokmode-pos-bottom-center{ left: 50%; bottom: var(--tktk-offset-y); transform: translateX(-50%); }

.tiktokmode-size-small  { padding: 9px 14px;  font-size: 12.5px; }
.tiktokmode-size-medium { padding: 12px 18px; font-size: 14.5px; }
.tiktokmode-size-large  { padding: 15px 24px; font-size: 16.5px; }

.tiktokmode-launch-icon { display: inline-flex; }
.tiktokmode-launch-icon svg { display: block; }

@keyframes tktk-pulse {
	0%, 100% { box-shadow: 0 6px 24px rgba(255,45,85,0.35), 0 2px 8px rgba(0,0,0,0.25); }
	50% { box-shadow: 0 6px 30px rgba(37,244,238,0.45), 0 2px 8px rgba(0,0,0,0.25); }
}
.tiktokmode-launch-btn { animation: tktk-pulse 3.2s ease-in-out infinite; }

/* ---------- Overlay shell ---------- */
.tiktokmode-overlay {
	position: fixed;
	inset: 0;
	z-index: 2147483200;
	background: var(--tktk-bg);
	color: var(--tktk-fg);
	font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
	display: flex;
	flex-direction: column;
	overscroll-behavior: contain;
}
.tiktokmode-overlay[hidden] { display: none; }
.tiktokmode-overlay * { box-sizing: border-box; }

.tiktokmode-overlay.tiktokmode-open .tiktokmode-feed { animation: tktk-fade-in .22s ease both; }
@keyframes tktk-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Top bar: close + category chips */
.tiktokmode-topbar {
	position: absolute;
	top: 0; left: 0; right: 0;
	z-index: 20;
	display: flex;
	align-items: center;
	gap: 10px;
	padding: max(12px, env(safe-area-inset-top)) 12px 10px 12px;
	background: linear-gradient(to bottom, rgba(0,0,0,0.55), rgba(0,0,0,0));
	pointer-events: none;
}
.tiktokmode-topbar > * { pointer-events: auto; }

.tiktokmode-close-btn {
	flex: 0 0 auto;
	width: 34px; height: 34px;
	border-radius: 50%;
	border: none;
	background: rgba(0,0,0,0.45);
	color: #fff;
	display: flex; align-items: center; justify-content: center;
	cursor: pointer;
	box-shadow: 0 2px 10px rgba(0,0,0,0.35), inset 0 0 0 1px rgba(255,255,255,0.2);
	backdrop-filter: blur(6px);
}
.tiktokmode-close-btn svg { width: 16px; height: 16px; display: block; }

.tiktokmode-chips {
	flex: 1 1 auto;
	display: flex;
	gap: 8px;
	overflow-x: auto;
	scrollbar-width: none;
	-ms-overflow-style: none;
	padding-bottom: 2px;
}
.tiktokmode-chips::-webkit-scrollbar { display: none; }

.tiktokmode-chip {
	flex: 0 0 auto;
	padding: 7px 14px;
	border-radius: 999px;
	background: rgba(0,0,0,0.45);
	color: #fff;
	font-size: 13px;
	font-weight: 500;
	white-space: nowrap;
	cursor: pointer;
	border: 1px solid transparent;
	box-shadow: 0 2px 8px rgba(0,0,0,0.3), inset 0 0 0 1px rgba(255,255,255,0.18);
	backdrop-filter: blur(6px);
	transition: background .15s ease, border-color .15s ease;
}
.tiktokmode-chip.active {
	background: #fff;
	color: #000;
	border-color: #fff;
}
.tiktokmode-chip-parent::after {
	content: '';
	display: inline-block;
	width: 5px;
	height: 5px;
	margin-left: 6px;
	margin-bottom: 1px;
	border-right: 1.5px solid currentColor;
	border-bottom: 1.5px solid currentColor;
	transform: rotate(-45deg);
	opacity: .75;
}
.tiktokmode-chip-back {
	background: rgba(0,0,0,0.5);
	font-weight: 600;
}

/* Vertical feed: one product per viewport, snap scroll */
.tiktokmode-feed {
	position: relative;
	flex: 1 1 auto;
	overflow-y: scroll;
	overflow-x: hidden;
	scroll-snap-type: y mandatory;
	scroll-behavior: smooth;
	-webkit-overflow-scrolling: touch;
	height: 100%;
	will-change: scroll-position;
}

.tiktokmode-slide {
	position: relative;
	width: 100%;
	height: 100%;
	scroll-snap-align: start;
	scroll-snap-stop: always;
	display: flex;
	flex-direction: column;
}

/* Horizontal image rail within a product: same-product pictures, swipe sideways */
.tiktokmode-imgrail {
	position: relative;
	width: 100%;
	height: 100%;
	display: flex;
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
}
.tiktokmode-imgrail::-webkit-scrollbar { display: none; }

.tiktokmode-imgframe {
	flex: 0 0 100%;
	width: 100%;
	height: 100%;
	scroll-snap-align: start;
	position: relative;
	background: #f4f1ee;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}
.tiktokmode-imgframe img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: center;
	user-select: none;
	-webkit-user-drag: none;
	pointer-events: none;
}

/* "Full resim göster" admin setting: show the whole image, letterboxed, instead of cropping it. */
.tiktokmode-fit-contain .tiktokmode-imgframe { background: #000; }
.tiktokmode-fit-contain .tiktokmode-imgframe img { object-fit: contain; }

/* Video frame (YouTube etc.) */
.tiktokmode-videoframe { background: #000; }
.tiktokmode-videoframe iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}
.tiktokmode-video-mute {
	position: absolute;
	top: max(58px, calc(env(safe-area-inset-top) + 46px));
	right: 12px;
	z-index: 16;
	width: 34px; height: 34px;
	border-radius: 50%;
	border: none;
	display: flex; align-items: center; justify-content: center;
	cursor: pointer;
	background: rgba(0,0,0,0.45);
	color: #fff;
	box-shadow: 0 2px 10px rgba(0,0,0,0.35), inset 0 0 0 1px rgba(255,255,255,0.2);
	backdrop-filter: blur(6px);
}
.tiktokmode-video-mute svg { width: 17px; height: 17px; display: block; }

.tiktokmode-imgdots {
	position: absolute;
	top: max(58px, calc(env(safe-area-inset-top) + 46px));
	left: 50%;
	transform: translateX(-50%);
	z-index: 15;
	display: flex;
	gap: 4px;
}
.tiktokmode-imgdots span {
	width: 6px; height: 6px;
	border-radius: 50%;
	background: rgba(255,255,255,0.55);
	box-shadow: 0 0 0 1px rgba(0,0,0,0.35), 0 1px 3px rgba(0,0,0,0.5);
	transition: background .15s ease, transform .15s ease;
}
.tiktokmode-imgdots span.active { background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.45), 0 1px 4px rgba(0,0,0,0.6); transform: scale(1.3); }

/* Bottom gradient + caption (name/description, TikTok style) */
.tiktokmode-caption {
	position: absolute;
	left: 0; right: 78px; bottom: 0;
	z-index: 15;
	padding: 70px 16px max(20px, env(safe-area-inset-bottom)) 16px;
	background: linear-gradient(to top, rgba(0,0,0,0.78) 0%, rgba(0,0,0,0.5) 45%, rgba(0,0,0,0) 100%);
	pointer-events: none;
}
.tiktokmode-caption > * { pointer-events: auto; }

.tiktokmode-cap-name {
	font-size: 17px;
	font-weight: 700;
	margin: 0 0 6px 0;
	text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.tiktokmode-cap-price {
	display: inline-flex;
	align-items: baseline;
	gap: 8px;
	font-size: 15px;
	font-weight: 700;
	color: var(--tktk-accent-2);
	margin-bottom: 8px;
}
.tiktokmode-cap-price .tiktokmode-was {
	font-size: 12.5px;
	font-weight: 500;
	color: var(--tktk-muted);
	text-decoration: line-through;
}

.tiktokmode-cap-desc {
	font-size: 13.5px;
	line-height: 1.42;
	color: var(--tktk-muted);
	max-height: 3.1em;
	overflow: hidden;
	transition: max-height .25s ease;
}
.tiktokmode-cap-desc.expanded {
	max-height: 38vh;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
	touch-action: pan-y;
	padding-right: 4px;
}

.tiktokmode-cap-more {
	display: inline-block;
	margin-top: 4px;
	font-size: 12.5px;
	font-weight: 600;
	color: #fff;
	cursor: pointer;
	opacity: .85;
}

.tiktokmode-cap-stock {
	display: inline-block;
	margin-top: 8px;
	font-size: 11.5px;
	font-weight: 700;
	letter-spacing: .3px;
	color: #ff6161;
	text-transform: uppercase;
}

/* Right-side stacked action rail */
.tiktokmode-actions {
	position: absolute;
	right: 10px;
	bottom: max(24px, env(safe-area-inset-bottom));
	z-index: 16;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 18px;
}

.tiktokmode-action {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	background: none;
	border: none;
	cursor: pointer;
	color: #fff;
	-webkit-tap-highlight-color: transparent;
}

.tiktokmode-action-icon {
	width: 46px; height: 46px;
	border-radius: 50%;
	background: rgba(0,0,0,0.45);
	box-shadow: 0 2px 10px rgba(0,0,0,0.3), inset 0 0 0 1px rgba(255,255,255,0.2);
	backdrop-filter: blur(8px);
	display: flex; align-items: center; justify-content: center;
	transition: transform .12s cubic-bezier(.34,1.56,.64,1), background .12s ease;
}
.tiktokmode-action-icon svg { width: 22px; height: 22px; display: block; }
.tiktokmode-action:active .tiktokmode-action-icon { transform: scale(.88); }
.tiktokmode-action.tiktokmode-added .tiktokmode-action-icon { background: #21d07a; }

.tiktokmode-action-label {
	font-size: 10.5px;
	font-weight: 600;
	text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* End of feed marker */
.tiktokmode-endcard {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 10px;
	height: 100%;
	color: var(--tktk-muted);
	font-size: 14px;
	text-align: center;
	padding: 0 30px;
}

/* Loading spinner */
.tiktokmode-spinner {
	position: absolute;
	left: 50%; top: 50%;
	transform: translate(-50%,-50%);
	width: 34px; height: 34px;
	border-radius: 50%;
	border: 3px solid rgba(255,255,255,0.2);
	border-top-color: #fff;
	animation: tktk-spin .7s linear infinite;
	z-index: 5;
}
@keyframes tktk-spin { to { transform: translate(-50%,-50%) rotate(360deg); } }

/* Toast */
.tiktokmode-toast {
	position: absolute;
	left: 50%;
	bottom: 90px;
	transform: translateX(-50%) translateY(10px);
	background: rgba(20,20,22,0.92);
	color: #fff;
	padding: 10px 18px;
	border-radius: 999px;
	font-size: 13px;
	font-weight: 600;
	z-index: 40;
	opacity: 0;
	pointer-events: none;
	transition: opacity .2s ease, transform .2s ease;
}
.tiktokmode-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Body lock while overlay open */
body.tiktokmode-lock { overflow: hidden !important; height: 100% !important; }

/* Required-options bottom sheet */
.tiktokmode-sheet-backdrop {
	position: fixed;
	inset: 0;
	z-index: 2147483400;
	background: rgba(0,0,0,0);
	transition: background .22s ease;
}
.tiktokmode-sheet-backdrop.open { background: rgba(0,0,0,0.55); }

.tiktokmode-sheet {
	position: fixed;
	left: 0; right: 0; bottom: 0;
	z-index: 2147483401;
	max-height: 80vh;
	display: flex;
	flex-direction: column;
	background: #17171a;
	color: #fff;
	border-radius: 18px 18px 0 0;
	box-shadow: 0 -8px 30px rgba(0,0,0,0.4);
	transform: translateY(100%);
	transition: transform .28s cubic-bezier(.32,.72,0,1);
	padding-bottom: env(safe-area-inset-bottom);
}
.tiktokmode-sheet.open { transform: translateY(0); }

.tiktokmode-sheet-handle {
	width: 36px; height: 4px;
	border-radius: 999px;
	background: rgba(255,255,255,0.25);
	margin: 10px auto 4px;
	flex: 0 0 auto;
}

.tiktokmode-sheet-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 8px 18px 12px;
	flex: 0 0 auto;
	border-bottom: 1px solid rgba(255,255,255,0.08);
}
.tiktokmode-sheet-header h4 { margin: 0; font-size: 16px; font-weight: 700; }
.tiktokmode-sheet-close {
	width: 30px; height: 30px;
	display: flex; align-items: center; justify-content: center;
	border: none; border-radius: 50%;
	background: rgba(255,255,255,0.12);
	box-shadow: inset 0 0 0 1px rgba(255,255,255,0.14);
	color: #fff;
	cursor: pointer;
}
.tiktokmode-sheet-close svg { display: block; width: 15px; height: 15px; }

.tiktokmode-sheet-body {
	flex: 1 1 auto;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
	padding: 14px 18px 6px;
}

.tiktokmode-sheet-field { margin-bottom: 18px; }
.tiktokmode-sheet-label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 8px; }
.tiktokmode-req { color: var(--tktk-accent, #ff2d55); }

.tiktokmode-sheet-input {
	width: 100%;
	background: rgba(255,255,255,0.06);
	border: 1px solid rgba(255,255,255,0.14);
	border-radius: 10px;
	color: #fff;
	font-size: 14px;
	font-family: inherit;
	padding: 11px 12px;
	box-sizing: border-box;
}
select.tiktokmode-sheet-input { appearance: none; -webkit-appearance: none; }
.tiktokmode-sheet-input:focus { outline: none; border-color: var(--tktk-accent, #ff2d55); }

.tiktokmode-sheet-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.tiktokmode-sheet-choice {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 9px 14px;
	border-radius: 999px;
	border: 1px solid rgba(255,255,255,0.16);
	background: rgba(255,255,255,0.05);
	font-size: 13.5px;
	cursor: pointer;
}
.tiktokmode-sheet-choice input { accent-color: var(--tktk-accent, #ff2d55); margin: 0; }
.tiktokmode-sheet-choice:has(input:checked),
.tiktokmode-sheet-choice.checked {
	border-color: var(--tktk-accent, #ff2d55);
	background: rgba(255,45,85,0.15);
}
.tiktokmode-sheet-choice em { font-style: normal; opacity: .7; font-size: 12px; }

.tiktokmode-sheet-field-error .tiktokmode-sheet-label { color: #ff6161; }
.tiktokmode-sheet-field-error .tiktokmode-sheet-input,
.tiktokmode-sheet-field-error .tiktokmode-sheet-choice { border-color: #ff6161; }

.tiktokmode-sheet-footer {
	flex: 0 0 auto;
	padding: 12px 18px calc(14px + env(safe-area-inset-bottom));
	border-top: 1px solid rgba(255,255,255,0.08);
}
.tiktokmode-sheet-submit {
	width: 100%;
	border: none;
	border-radius: 999px;
	padding: 14px;
	background: linear-gradient(135deg, var(--tktk-accent, #ff2d55) 0%, var(--tktk-accent-2, #25f4ee) 100%);
	color: #fff;
	font-size: 15px;
	font-weight: 700;
	font-family: inherit;
	cursor: pointer;
}

/* Small screens: slightly larger caption text is easier to read on tiny phones already; scale actions down a touch */
@media (max-width: 340px) {
	.tiktokmode-action-icon { width: 40px; height: 40px; }
	.tiktokmode-caption { right: 70px; }
}
