/* Media downloader (/ดาวน์โหลดวิดีโอ/) — state layer over the Kadence layout. */

:root {
	--sg-dl-green: #057c1d;
	--sg-dl-ink: #1d1d1f;
	--sg-dl-muted: #6e6e73;
	--sg-dl-glass: rgba(255, 255, 255, 0.72);
	--sg-dl-radius: 4px;
	--sg-dl-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Avoid a flash of the processing column before the script takes over. */
body.page-id-22577:not(.sg-dl-ready) .kadence-column22577_1b301b-3c {
	display: none;
}

.sg-dl-hidden {
	display: none !important;
}

/* Search row: URL field takes the remaining width, button sizes to its content.
   Scoped to the form, not the wrapping column, whose unique class can change when edited in Kadence. */
#kb-adv-form-22581-cpt-id > .wp-block-kadence-column {
	align-self: stretch;
	width: auto;
	max-width: none;
}

#kb-adv-form-22581-cpt-id > .wp-block-kadence-column > .kt-inside-inner-col {
	width: 100%;
}

#kb-adv-form-22581-cpt-id .kb-field22581144487-a1 {
	flex: 1 1 0%;
	width: auto;
	min-width: 0;
}

#kb-adv-form-22581-cpt-id .kb-field22581144487-a1 input {
	width: 100%;
}

#kb-adv-form-22581-cpt-id .kb-field2093d0-03 {
	flex: 0 0 auto;
	width: auto;
}

#kb-adv-form-22581-cpt-id .kb-btn2093d0-03 {
	white-space: nowrap;
}

.sg-dl-fade {
	transition: opacity 0.28s ease, transform 0.28s var(--sg-dl-ease);
}

.sg-dl-out {
	opacity: 0 !important;
	transform: translateY(8px);
}

@keyframes sg-dl-pop-in {
	from { opacity: 0; transform: translateY(10px) scale(0.985); }
	to { opacity: 1; transform: none; }
}

.sg-dl-pop-in {
	animation: sg-dl-pop-in 0.45s var(--sg-dl-ease);
}

/* ---------- search button busy ---------- */

@keyframes sg-dl-spin {
	to { transform: rotate(360deg); }
}

.kb-button.sg-dl-busy {
	cursor: progress;
	opacity: 0.88;
}

.kb-button.sg-dl-busy .kb-svg-icon-wrap svg {
	display: none;
}

.kb-button.sg-dl-busy .kb-svg-icon-wrap::after {
	content: "";
	display: inline-block;
	width: 1em;
	height: 1em;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: sg-dl-spin 0.7s linear infinite;
}

/* ---------- skeleton while fetching info ---------- */

@keyframes sg-dl-shimmer {
	0% { background-position: 100% 0; }
	100% { background-position: 0 0; }
}

.sg-dl-skeleton .wp-block-kadence-advancedheading,
.sg-dl-skeleton .kb-button,
.kb-is-ratio-image.sg-dl-img-loading {
	background: linear-gradient(90deg, #ececec 25%, #f7f7f7 37%, #ececec 63%) !important;
	background-size: 400% 100% !important;
	animation: sg-dl-shimmer 1.3s ease infinite;
	border-radius: var(--sg-dl-radius);
}

/* Hidden until the requested image has loaded (see imageLoading() in media-dl.js). */
.kb-is-ratio-image.sg-dl-img-loading img {
	opacity: 0 !important;
}

.sg-dl-skeleton .wp-block-kadence-advancedheading,
.sg-dl-skeleton .wp-block-kadence-advancedheading * {
	color: transparent !important;
	text-shadow: none !important;
}

.sg-dl-skeleton .wp-block-kadence-advancedheading a {
	text-decoration: none !important;
}

/* Kadence paints the button gradient with !important at (0,3,0), so this needs more weight. */
.sg-dl-skeleton .wp-block-kadence-advancedbtn .kb-button.kt-button,
.sg-dl-skeleton .kb-button {
	background: linear-gradient(90deg, #ececec 25%, #f7f7f7 37%, #ececec 63%) !important;
	background-size: 400% 100% !important;
	color: transparent !important;
	border-color: transparent !important;
	box-shadow: none !important;
	filter: none !important;
	pointer-events: none;
}

.sg-dl-skeleton .kb-button::before,
.sg-dl-skeleton .kb-button::after {
	opacity: 0 !important;
}

.sg-dl-skeleton .kb-button > * {
	visibility: hidden;
}

/* Vertical / square videos: the Kadence 16:9 frame becomes 9:16 or 1:1 at full figure width. */
.kb-image-is-ratio-size .kb-is-ratio-image.sg-dl-portrait,
.kb-image-is-ratio-size .kb-is-ratio-image.sg-dl-square {
	position: relative;
	box-sizing: border-box;
	width: 100% !important;
	max-width: 100% !important;
	height: 0 !important;
	padding-bottom: 177.78% !important;
	margin-left: 0 !important;
	margin-right: 0 !important;
	border-radius: 8px;
}

.kb-image-is-ratio-size .kb-is-ratio-image.sg-dl-square {
	padding-bottom: 100% !important;
}

.wp-block-kadence-image.kb-image-is-ratio-size:has(> .sg-dl-portrait),
.wp-block-kadence-image.kb-image-is-ratio-size:has(> .sg-dl-square) {
	align-self: stretch;
	width: 100% !important;
	max-width: 100% !important;
}

.kb-is-ratio-image.sg-dl-portrait img,
.kb-is-ratio-image.sg-dl-square img {
	position: absolute;
	top: 0;
	left: 0;
	width: 100% !important;
	height: 100% !important;
	max-width: none;
	object-fit: cover;
	object-position: center;
}

.kb-is-ratio-image.sg-dl-portrait a.sg-dl-img-link,
.kb-is-ratio-image.sg-dl-square a.sg-dl-img-link {
	position: absolute;
	inset: 0;
}

.kb-is-ratio-image:has(.sg-dl-noimg) {
	background: #f1f1f3;
}

img.sg-dl-noimg {
	opacity: 0;
}

/* Result and ready-card titles: always one line, cut with "…". Taller line box
   so Thai upper/lower vowels are not clipped by overflow: hidden. */
.wp-block-kadence-advancedheading.kt-adv-heading22577_0b7e36-59,
.wp-block-kadence-advancedheading.kt-adv-heading22577_f950e2-4b {
	display: block;
	min-width: 0;
	max-width: 100%;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
	line-height: 1.6 !important;
	contain: inline-size;
}

/* The parent Kadence columns centre these cards (fit-content), so an unwrapped
   title would set their width; pin them to the column instead. */
.kt-inside-inner-col > .kadence-column22577_bee3e3-2b,
.kt-inside-inner-col > .kadence-column22577_8b2519-b7 {
	align-self: stretch;
	box-sizing: border-box;
	width: auto;
	max-width: 100%;
}

.kadence-column22577_e4c417-eb,
.kadence-column22577_e4c417-eb .wp-block-kadence-column,
.kadence-column22577_e4c417-eb .kt-inside-inner-col,
.kadence-column22577_8b2519-b7,
.kadence-column22577_8b2519-b7 .wp-block-kadence-column,
.kadence-column22577_8b2519-b7 .kt-inside-inner-col {
	min-width: 0;
}

.kt-adv-heading22577_0b7e36-59 > span,
.kt-adv-heading22577_f950e2-4b > span {
	white-space: nowrap;
}

/* ---------- options button (Kadence span) ---------- */

.kb-btns22577_21621c-8e .kb-button {
	cursor: pointer;
	transition: box-shadow 0.2s ease, transform 0.15s ease;
}

.kb-btns22577_21621c-8e .kb-button:active {
	transform: scale(0.98);
}

.kb-button.sg-dl-target {
	box-shadow: 0 0 0 3px rgba(5, 124, 29, 0.28), 0 6px 18px -6px rgba(5, 124, 29, 0.45) !important;
}

/* ---------- options popover (Apple-style frosted) ---------- */

.sg-dl-pop {
	position: fixed;
	inset: 0;
	z-index: 100000;
}

.sg-dl-pop[hidden] {
	display: none;
}

.sg-dl-pop__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(15, 23, 42, 0.12);
	opacity: 0;
	transition: opacity 0.22s ease;
}

.sg-dl-pop.is-open .sg-dl-pop__backdrop {
	opacity: 1;
}

.sg-dl-pop__card {
	position: fixed;
	top: 0;
	left: 0;
	box-sizing: border-box;
	width: min(360px, calc(100vw - 16px));
	padding: 14px;
	background: rgba(255, 255, 255, 0.94);
	-webkit-backdrop-filter: saturate(180%) blur(24px);
	backdrop-filter: saturate(180%) blur(24px);
	border: 1px solid rgba(255, 255, 255, 0.8);
	border-radius: 14px;
	box-shadow: 0 24px 60px -18px rgba(0, 0, 0, 0.32), 0 0 0 0.5px rgba(0, 0, 0, 0.1);
	color: #111;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	opacity: 0;
	transform: translateY(-6px) scale(0.97);
	transform-origin: top center;
	transition: opacity 0.2s ease, transform 0.24s var(--sg-dl-ease);
}

.sg-dl-pop__card.is-above {
	transform: translateY(6px) scale(0.97);
	transform-origin: bottom center;
}

.sg-dl-pop.is-open .sg-dl-pop__card {
	opacity: 1;
	transform: none;
}

.sg-dl-pop__arrow {
	position: absolute;
	width: 14px;
	height: 14px;
	background: rgba(255, 255, 255, 0.94);
	-webkit-backdrop-filter: saturate(180%) blur(24px);
	backdrop-filter: saturate(180%) blur(24px);
	border: 1px solid rgba(0, 0, 0, 0.06);
	border-radius: 2px;
	transform: rotate(45deg);
}

.sg-dl-pop__card.is-below .sg-dl-pop__arrow {
	top: -8px;
	border-right: 0;
	border-bottom: 0;
}

.sg-dl-pop__card.is-above .sg-dl-pop__arrow {
	bottom: -8px;
	border-left: 0;
	border-top: 0;
}

.sg-dl-pop__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin: 0 0 10px;
	padding: 0 2px;
}

.sg-dl-pop__title {
	margin: 0 !important;
	font-size: 15px;
	font-weight: 400;
	line-height: 1.3;
	color: #111;
}

.sg-dl-pop .sg-dl-pop__close,
.sg-dl-verify .sg-dl-verify__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 28px;
	height: 28px;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(120, 120, 128, 0.14);
	box-shadow: none;
	color: var(--sg-dl-muted);
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}

.sg-dl-pop .sg-dl-pop__close:hover,
.sg-dl-verify .sg-dl-verify__close:hover {
	background: rgba(120, 120, 128, 0.24);
	color: var(--sg-dl-ink);
}

.sg-dl-pop__close svg,
.sg-dl-verify__close svg {
	width: 14px;
	height: 14px;
}

.sg-dl-pop__empty {
	margin: 0 !important;
	padding: 4px 2px 2px;
	font-size: 14px;
	line-height: 1.7;
	color: #4a4a4f;
}

.sg-dl-pop__empty .sg-dl-inline-btn {
	display: inline-block;
	width: auto;
	height: 1.6em;
	margin: 0 1px;
	vertical-align: -0.3em;
	border-radius: 4px;
}

@media (max-width: 767px) {
	.sg-dl-pop__empty {
		font-size: 12px;
	}
}

.sg-dl-pop .sg-dl-opt {
	display: flex;
	align-items: center;
	gap: 12px;
	width: 100%;
	min-height: 0;
	margin: 0;
	padding: 10px 12px;
	border: 1px solid rgba(0, 0, 0, 0.07);
	border-radius: 10px;
	background: #fff;
	box-shadow: none;
	color: #111;
	font: inherit;
	font-weight: 400;
	line-height: 1.35;
	letter-spacing: normal;
	text-align: left;
	text-transform: none;
	cursor: pointer;
	transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.sg-dl-pop .sg-dl-opt + .sg-dl-opt {
	margin-top: 6px;
}

.sg-dl-pop .sg-dl-opt:hover {
	background: #f6faf7;
	border-color: rgba(5, 124, 29, 0.35);
	color: #111;
}

.sg-dl-pop .sg-dl-opt:active {
	transform: scale(0.99);
}

.sg-dl-pop .sg-dl-opt:focus-visible {
	outline: 2px solid var(--sg-dl-green);
	outline-offset: 1px;
}

.sg-dl-pop .sg-dl-opt.is-selected {
	background: rgba(5, 124, 29, 0.08);
	border-color: var(--sg-dl-green);
}

.sg-dl-opt__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 34px;
	height: 34px;
	border-radius: 8px;
	background: rgba(5, 124, 29, 0.1);
	color: var(--sg-dl-green);
}

.sg-dl-opt__icon--audio {
	background: rgba(13, 131, 3, 0.08);
	color: #0d8303;
}

.sg-dl-opt__icon svg {
	width: 18px;
	height: 18px;
}

.sg-dl-opt__text {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	min-width: 0;
}

.sg-dl-opt__label {
	font-size: 15px;
	font-weight: 400;
	color: #111;
}

.sg-dl-opt__hint {
	margin-top: 2px;
	font-size: 13px;
	font-weight: 400;
	color: #4a4a4f;
}

.sg-dl-opt__check {
	display: inline-flex;
	flex: 0 0 auto;
	width: 20px;
	height: 20px;
	color: var(--sg-dl-green);
	opacity: 0;
	transform: scale(0.6);
	transition: opacity 0.15s ease, transform 0.2s var(--sg-dl-ease);
}

.sg-dl-opt:hover .sg-dl-opt__check {
	opacity: 0.35;
	transform: scale(0.9);
}

.sg-dl-opt.is-selected .sg-dl-opt__check {
	opacity: 1;
	transform: none;
}

@media (max-width: 599px) {
	.sg-dl-pop .sg-dl-opt {
		padding: 12px;
	}
}

/* ---------- title / thumbnail links ---------- */

a.sg-dl-link {
	color: inherit !important;
	text-decoration: inherit;
	transition: color 0.15s ease;
}

a.sg-dl-link:hover,
a.sg-dl-link:focus-visible {
	color: var(--sg-dl-green) !important;
	text-decoration: underline;
}

a.sg-dl-img-link {
	display: block;
	cursor: pointer;
}

a.sg-dl-img-link:hover img {
	filter: brightness(0.92);
}

/* ---------- coach mark on the download button ---------- */

.sg-dl-coach-target {
	position: relative;
	z-index: 10050;
	box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--sg-dl-green), 0 0 0 12px rgba(5, 124, 29, 0.22) !important;
	animation: sg-dl-coach-pulse 1.5s ease-in-out infinite;
}

@keyframes sg-dl-coach-pulse {
	0%, 100% {
		box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--sg-dl-green), 0 0 0 10px rgba(5, 124, 29, 0.24);
	}
	50% {
		box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--sg-dl-green), 0 0 0 18px rgba(5, 124, 29, 0.08);
	}
}

.sg-dl-coach {
	position: fixed;
	top: 0;
	left: 0;
	z-index: 10051;
	display: flex;
	align-items: center;
	gap: 6px;
	box-sizing: border-box;
	width: max-content;
	padding: 10px 6px 10px 14px;
	background: rgba(255, 255, 255, 0.94);
	-webkit-backdrop-filter: saturate(180%) blur(24px);
	backdrop-filter: saturate(180%) blur(24px);
	border: 1px solid rgba(0, 0, 0, 0.06);
	border-radius: 14px;
	box-shadow: 0 16px 40px -14px rgba(0, 0, 0, 0.3), 0 0 0 0.5px rgba(0, 0, 0, 0.08);
	color: #111;
	-webkit-font-smoothing: antialiased;
	opacity: 0;
	transform: translateY(4px);
	transition: opacity 0.2s ease, transform 0.24s var(--sg-dl-ease);
}

.sg-dl-coach[hidden] {
	display: none;
}

.sg-dl-coach.is-below {
	transform: translateY(-4px);
}

.sg-dl-coach.is-open {
	opacity: 1;
	transform: none;
}

.sg-dl-coach__arrow {
	position: absolute;
	width: 14px;
	height: 14px;
	background: rgba(255, 255, 255, 0.94);
	border: 1px solid rgba(0, 0, 0, 0.06);
	border-radius: 2px;
	transform: rotate(45deg);
}

.sg-dl-coach.is-above .sg-dl-coach__arrow {
	bottom: -8px;
	border-left: 0;
	border-top: 0;
}

.sg-dl-coach.is-below .sg-dl-coach__arrow {
	top: -8px;
	border-right: 0;
	border-bottom: 0;
}

.sg-dl-coach__text {
	position: relative;
	margin: 0 !important;
	font-size: 14px;
	font-weight: 400;
	line-height: 1.45;
	color: #111;
}

.sg-dl-coach .sg-dl-coach__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 26px;
	height: 26px;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	box-shadow: none;
	color: var(--sg-dl-muted);
	cursor: pointer;
}

.sg-dl-coach .sg-dl-coach__close:hover {
	background: rgba(120, 120, 128, 0.14);
	color: #111;
}

.sg-dl-coach__close svg {
	width: 13px;
	height: 13px;
}

@media (max-width: 767px) {
	.sg-dl-coach__text {
		font-size: 12px;
	}
}

/* ---------- Turnstile modal ---------- */

.sg-dl-verify {
	position: fixed;
	inset: 0;
	z-index: 100001;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
}

.sg-dl-verify[hidden] {
	display: none;
}

.sg-dl-verify__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(15, 23, 42, 0.18);
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
}

.sg-dl-verify__card {
	position: relative;
	box-sizing: border-box;
	width: min(380px, 100%);
	padding: 22px 20px 18px;
	background: var(--sg-dl-glass);
	-webkit-backdrop-filter: saturate(180%) blur(20px);
	backdrop-filter: saturate(180%) blur(20px);
	border: 1px solid rgba(255, 255, 255, 0.65);
	border-radius: var(--sg-dl-radius);
	box-shadow: 0 24px 60px -18px rgba(0, 0, 0, 0.32);
	text-align: center;
	animation: sg-dl-pop-in 0.3s var(--sg-dl-ease);
}

.sg-dl-verify .sg-dl-verify__close {
	position: absolute;
	top: 10px;
	right: 10px;
}

.sg-dl-verify__title {
	margin: 0 0 4px !important;
	font-size: 16px;
	font-weight: 700;
	color: var(--sg-dl-ink);
}

.sg-dl-verify__desc {
	margin: 0 0 14px !important;
	font-size: 13.5px;
	color: var(--sg-dl-muted);
}

.sg-dl-verify__widget {
	min-height: 65px;
}

/* ---------- inline alert ---------- */

.sg-dl-alert {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	box-sizing: border-box;
	width: 100%;
	margin-top: 12px;
	padding: 11px 12px;
	border: 1px solid rgba(220, 38, 38, 0.22);
	border-radius: var(--sg-dl-radius);
	background: rgba(254, 242, 242, 0.92);
	color: #991b1b;
}

.sg-dl-alert__icon {
	display: inline-flex;
	flex: 0 0 auto;
	width: 18px;
	height: 18px;
	margin-top: 2px;
}

.sg-dl-alert__text {
	flex: 1 1 auto;
	margin: 0 !important;
	font-size: 14px;
	line-height: 1.55;
}

.sg-dl-alert .sg-dl-alert__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 22px;
	height: 22px;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	box-shadow: none;
	color: inherit;
	cursor: pointer;
	opacity: 0.7;
}

.sg-dl-alert .sg-dl-alert__close:hover {
	opacity: 1;
	background: rgba(153, 27, 27, 0.08);
	color: inherit;
}

.sg-dl-alert__close svg {
	width: 12px;
	height: 12px;
}

/* ---------- live progress bar (replaces Kadence's SVG tween) ---------- */

.sg-dl-progress {
	overflow: hidden;
	transition: max-height 0.35s var(--sg-dl-ease), opacity 0.3s ease, margin 0.35s ease;
}

.sg-dl-progress .kb-progress-bar > svg {
	display: none !important;
}

.sg-dl-progress.sg-dl-collapsed {
	max-height: 0 !important;
	margin: 0 !important;
	opacity: 0;
}

.sg-dl-bar {
	position: relative;
	overflow: hidden;
	width: 100%;
	height: 10px;
	border-radius: 10px;
	background: var(--sg-dl-track, #e5e5e5);
}

.sg-dl-bar__fill {
	position: absolute;
	top: 0;
	left: 0;
	bottom: 0;
	width: 0;
	border-radius: inherit;
	background: var(--sg-dl-fill, var(--sg-dl-green));
	transition: width 0.6s var(--sg-dl-ease);
}

@keyframes sg-dl-sweep {
	from { transform: translateX(-100%); }
	to { transform: translateX(340%); }
}

.sg-dl-bar.is-indeterminate::after {
	content: "";
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	width: 30%;
	background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
	animation: sg-dl-sweep 1.2s ease-in-out infinite;
}

.sg-dl-pct {
	font-variant-numeric: tabular-nums;
}

/* ---------- ready state ---------- */

a.kb-button[aria-disabled="true"] {
	pointer-events: none;
	opacity: 0.6;
}

.sg-dl-expiry {
	width: 100%;
	margin: 8px 0 0 !important;
	font-size: 12.5px;
	line-height: 1.5;
	text-align: center;
	color: var(--sg-dl-muted);
}

@media (prefers-reduced-motion: reduce) {
	.sg-dl-fade,
	.sg-dl-pop__card,
	.sg-dl-pop__backdrop,
	.sg-dl-bar__fill,
	.sg-dl-progress,
	.sg-dl-coach {
		transition: none !important;
	}

	.sg-dl-coach-target,
	.sg-dl-pop-in,
	.sg-dl-verify__card,
	.sg-dl-bar.is-indeterminate::after,
	.sg-dl-skeleton .wp-block-kadence-advancedheading,
	.sg-dl-skeleton .kb-button,
	.kb-is-ratio-image.sg-dl-img-loading {
		animation: none !important;
	}
}
