/**
 * YouTube Tutorials Gallery — front-end styles.
 * All colours flow through CSS variables so Elementor style controls can override them.
 */

.ytg {
	--ytg-accent: #EC3B24;
	--ytg-surface: #ffffff;
	--ytg-surface-2: #f3efe9;
	--ytg-ink: #1c1815;
	--ytg-ink-2: #5e564e;
	--ytg-ink-3: #928a80;
	--ytg-line: #e7e0d6;
	--ytg-radius: 18px;
	--ytg-shadow: 0 26px 46px -30px rgba(30, 20, 12, .4);

	direction: rtl;
	color: var(--ytg-ink);
	font-family: inherit;
}

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

/* ---------- Header ---------- */
.ytg-header {
	margin-bottom: 22px;
}

.ytg-eyebrow {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-size: .78rem;
	font-weight: 700;
	letter-spacing: .06em;
	color: var(--ytg-accent);
	background: color-mix(in srgb, var(--ytg-accent) 12%, transparent);
	padding: 6px 13px;
	border-radius: 999px;
}

.ytg-eyebrow--sm {
	background: none;
	padding: 0;
}

.ytg-heading {
	font-size: clamp(1.7rem, 4vw, 2.7rem);
	line-height: 1.1;
	letter-spacing: -.02em;
	margin: 14px 0 10px;
	font-weight: 800;
	text-wrap: balance;
}

.ytg-sub {
	font-size: clamp(1rem, 1.6vw, 1.15rem);
	color: var(--ytg-ink-2);
	max-width: 56ch;
	margin: 0;
}

/* ---------- Search ---------- */
.ytg-search {
	display: flex;
	align-items: center;
	gap: 10px;
	background: var(--ytg-surface);
	border: 1px solid var(--ytg-line);
	border-radius: 14px;
	padding: 4px 16px;
	max-width: 460px;
	margin-bottom: 20px;
	box-shadow: var(--ytg-shadow);
}

.ytg-search svg {
	flex: none;
	color: var(--ytg-ink-3);
}

/*
 * Strip every native / theme-injected chrome from the input so only the outer
 * pill is visible — themes commonly add a border, box-shadow or rounded corners
 * to inputs, which showed as an ugly rectangle inside the pill.
 */
.ytg-search__input {
	flex: 1;
	min-width: 0;
	border: none !important;
	outline: none !important;
	box-shadow: none !important;
	background: transparent !important;
	border-radius: 0 !important;
	-webkit-appearance: none;
	appearance: none;
	color: var(--ytg-ink);
	font: inherit;
	font-size: 1rem;
	padding: 11px 0;
}

.ytg-search__input:focus,
.ytg-search__input:focus-visible {
	outline: none !important;
	box-shadow: none !important;
}

.ytg-search__input::placeholder {
	color: var(--ytg-ink-3);
}

/* Remove WebKit's native search field decorations (magnifier / clear X). */
.ytg-search__input::-webkit-search-decoration,
.ytg-search__input::-webkit-search-cancel-button,
.ytg-search__input::-webkit-search-results-button {
	-webkit-appearance: none;
	appearance: none;
}

/* ---------- Chips ---------- */
.ytg-chips {
	display: flex;
	gap: 9px;
	overflow-x: auto;
	padding-bottom: 4px;
	margin-bottom: 24px;
	scrollbar-width: none;
}

.ytg-chips::-webkit-scrollbar {
	display: none;
}

.ytg-chip {
	flex: none;
	border: 1px solid var(--ytg-line);
	background: var(--ytg-surface);
	color: var(--ytg-ink-2);
	font: inherit;
	font-weight: 600;
	font-size: .9rem;
	padding: 8px 16px;
	border-radius: 999px;
	cursor: pointer;
	white-space: nowrap;
	transition: color .15s, border-color .15s, background .15s;
}

.ytg-chip:hover {
	border-color: var(--ytg-accent);
	color: var(--ytg-ink);
}

.ytg-chip.is-active {
	background: var(--ytg-ink);
	color: var(--ytg-surface);
	border-color: var(--ytg-ink);
}

/* ---------- Grid ---------- */
.ytg-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 22px;
}

/* ---------- Card ---------- */
.ytg-card {
	background: var(--ytg-surface);
	border: 1px solid var(--ytg-line);
	border-radius: var(--ytg-radius);
	overflow: hidden;
	cursor: pointer;
	display: flex;
	flex-direction: column;
	transition: transform .2s, box-shadow .2s, border-color .2s;
}

.ytg-card:hover,
.ytg-card:focus-visible {
	transform: translateY(-5px);
	box-shadow: var(--ytg-shadow);
	border-color: color-mix(in srgb, var(--ytg-accent) 40%, var(--ytg-line));
	outline: none;
}

.ytg-card.is-hidden {
	display: none;
}

.ytg-thumb {
	position: relative;
	background: var(--ytg-surface-2);
	overflow: hidden;
}

/*
 * The 16:9 ratio lives on the IMG itself (not the frame). This gives the image a
 * definite height regardless of the parent's height or whether the image has loaded,
 * so object-fit: cover reliably crops YouTube's 4:3 letterbox bars. Putting the ratio
 * on the parent and using height:100% fails when the parent height is itself derived
 * from aspect-ratio (the percentage resolves to 0/auto and the crop never happens).
 */
.ytg-thumb__img {
	display: block;
	width: 100%;
	height: auto;
	max-width: none;
	aspect-ratio: 16 / 9;
	object-fit: cover;
	object-position: center;
}

.ytg-thumb::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(180deg, transparent 55%, rgba(0, 0, 0, .45));
}

.ytg-play {
	position: absolute;
	inset: 0;
	margin: auto;
	width: 58px;
	height: 58px;
	border-radius: 50%;
	background: rgba(20, 15, 12, .55);
	border: 1.5px solid rgba(255, 255, 255, .35);
	display: grid;
	place-items: center;
	z-index: 2;
	transition: transform .2s, background .2s, border-color .2s;
}

.ytg-play::after {
	content: "";
	border-inline-start: 15px solid #fff;
	border-block: 9px solid transparent;
	margin-inline-start: 4px;
}

.ytg-card:hover .ytg-play,
.ytg-featured:hover .ytg-play {
	transform: scale(1.12);
	background: var(--ytg-accent);
	border-color: var(--ytg-accent);
}

.ytg-badge {
	position: absolute;
	bottom: 9px;
	inset-inline-start: 9px;
	z-index: 2;
	background: rgba(15, 12, 10, .82);
	color: #fff;
	font-size: .74rem;
	font-weight: 700;
	padding: 3px 8px;
	border-radius: 6px;
	font-variant-numeric: tabular-nums;
}

.ytg-tag {
	position: absolute;
	top: 10px;
	inset-inline-end: 10px;
	z-index: 2;
	background: color-mix(in srgb, var(--ytg-surface) 92%, transparent);
	color: var(--ytg-accent);
	font-size: .72rem;
	font-weight: 700;
	padding: 4px 10px;
	border-radius: 999px;
	backdrop-filter: blur(4px);
}

.ytg-card__body {
	padding: 15px 16px 17px;
	display: flex;
	flex-direction: column;
	gap: 9px;
	flex: 1;
}

.ytg-card__title {
	margin: 0;
	font-size: 1.02rem;
	line-height: 1.35;
	font-weight: 700;
	letter-spacing: -.01em;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.ytg-meta {
	margin-top: auto;
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: .8rem;
	color: var(--ytg-ink-3);
}

.ytg-dot {
	width: 3px;
	height: 3px;
	border-radius: 50%;
	background: var(--ytg-ink-3);
	display: inline-block;
}

/* ---------- Featured ---------- */
.ytg-featured {
	display: grid;
	grid-template-columns: 1.35fr 1fr;
	margin-bottom: 34px;
	background: var(--ytg-surface);
	border: 1px solid var(--ytg-line);
	border-radius: var(--ytg-radius);
	overflow: hidden;
	box-shadow: var(--ytg-shadow);
	cursor: pointer;
}

/*
 * The hero uses the same reliable 16:9 image rule as the cards (defined above), so no
 * height overrides here — that avoids the letterbox bug entirely. On desktop the wide
 * hero image is the taller column and sets the row height; on mobile it stacks on top.
 */

.ytg-featured .ytg-play {
	width: 74px;
	height: 74px;
}

.ytg-featured .ytg-play::after {
	border-inline-start: 19px solid #fff;
	border-block: 12px solid transparent;
}

.ytg-featured__body {
	padding: clamp(22px, 3vw, 38px);
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 13px;
}

.ytg-featured__title {
	font-size: clamp(1.4rem, 2.6vw, 2rem);
	line-height: 1.15;
	margin: 0;
	letter-spacing: -.02em;
	font-weight: 800;
	text-wrap: balance;
}

.ytg-featured__desc {
	margin: 0;
	color: var(--ytg-ink-2);
	font-size: 1rem;
}

/* ---------- Modal ---------- */
.ytg-modal {
	position: fixed;
	inset: 0;
	z-index: 9999;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 20px;
	background: rgba(12, 8, 5, .62);
	backdrop-filter: blur(6px);
}

.ytg-modal.is-open {
	display: flex;
	animation: ytg-fade .25s ease;
}

@keyframes ytg-fade {
	from { opacity: 0; }
	to   { opacity: 1; }
}

.ytg-modal__card {
	background: var(--ytg-surface);
	border: 1px solid var(--ytg-line);
	border-radius: 20px;
	max-width: 720px;
	width: 100%;
	overflow: hidden;
	box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .6);
	animation: ytg-pop .28s cubic-bezier(.2, .8, .3, 1);
}

@keyframes ytg-pop {
	from { opacity: 0; transform: translateY(14px) scale(.97); }
	to   { opacity: 1; transform: none; }
}

.ytg-modal__media {
	position: relative;
}

.ytg-modal__close {
	position: absolute;
	top: 16px;
	inset-inline-start: 16px;
	z-index: 3;
	width: 38px;
	height: 38px;
	border-radius: 50%;
	border: none;
	cursor: pointer;
	background: rgba(15, 12, 10, .6);
	color: #fff;
	font-size: 1.1rem;
	display: grid;
	place-items: center;
}

.ytg-modal__body {
	padding: 22px 24px 26px;
}

.ytg-modal__cat {
	color: var(--ytg-accent);
	font-weight: 700;
	font-size: .8rem;
	letter-spacing: .05em;
}

.ytg-modal__title {
	margin: 8px 0 10px;
	font-size: 1.4rem;
	line-height: 1.25;
	letter-spacing: -.02em;
}

.ytg-modal__desc {
	margin: 0 0 20px;
	color: var(--ytg-ink-2);
}

.ytg-modal__actions {
	display: flex;
	gap: 12px;
	flex-wrap: wrap;
}

.ytg-btn {
	display: inline-flex;
	align-items: center;
	gap: 9px;
	font: inherit;
	font-weight: 700;
	font-size: .98rem;
	padding: 13px 22px;
	border-radius: 12px;
	cursor: pointer;
	text-decoration: none;
	border: none;
}

.ytg-btn--yt {
	background: var(--ytg-accent);
	box-shadow: 0 10px 24px -10px var(--ytg-accent);
	transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}

/*
 * The button is an <a>, so a theme's `a:hover { color: ... }` was turning the label
 * blue on hover. Pin the text to white across every link state — the two-class
 * selector outbeats the theme's `a:hover` without needing !important.
 */
.ytg .ytg-btn--yt,
.ytg .ytg-btn--yt:link,
.ytg .ytg-btn--yt:visited,
.ytg .ytg-btn--yt:hover,
.ytg .ytg-btn--yt:focus,
.ytg .ytg-btn--yt:active {
	color: #fff;
}

.ytg-btn--yt:hover {
	transform: translateY(-2px);
	filter: brightness(1.05);
	box-shadow: 0 16px 32px -8px var(--ytg-accent);
}

.ytg-btn--yt:active {
	transform: translateY(0);
	box-shadow: 0 8px 18px -10px var(--ytg-accent);
}

.ytg-modal__note {
	margin-top: 16px;
	font-size: .8rem;
	color: var(--ytg-ink-3);
}

/* ---------- Empty state ---------- */
.ytg-empty {
	padding: 40px 20px;
	text-align: center;
	color: var(--ytg-ink-3);
	font-size: 1rem;
	display: none;
}

.ytg-empty.is-visible {
	display: block;
}

/* ---------- Editor notice ---------- */
.ytg-notice {
	padding: 16px 20px;
	border: 1px dashed #d9a400;
	background: #fff8e5;
	color: #7a5c00;
	border-radius: 10px;
	font-size: .95rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 767px) {
	.ytg-featured {
		grid-template-columns: 1fr;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ytg * {
		animation: none !important;
		transition: none !important;
	}
}
