/* YT Podcast Importer — frontend grid + modal player */

/* ---------- Grid ---------- */

/* The grid simply fills the container it is placed in (theme content column,
   a full-width block, a page-builder column, etc.). No viewport breakout, so
   it stays aligned wherever it is dropped and just adapts to that width. */
.ytpi-container { width: 100%; }

/* The columns attribute sets the number of columns on desktop; the grid fills
   the container and drops to fewer columns on tablet and phone. minmax(0, 1fr)
   keeps a long title from stretching a column wider than its share. */
.ytpi-grid {
	--ytpi-gap: clamp(16px, 2vw, 26px);
	display: grid;
	gap: var(--ytpi-gap);
	margin: 0 0 24px;
	grid-template-columns: repeat(var(--ytpi-cols, 3), minmax(0, 1fr));
}

.ytpi-cols-1 { --ytpi-cols: 1; }
.ytpi-cols-2 { --ytpi-cols: 2; }
.ytpi-cols-3 { --ytpi-cols: 3; }
.ytpi-cols-4 { --ytpi-cols: 4; }
.ytpi-cols-5 { --ytpi-cols: 5; }
.ytpi-cols-6 { --ytpi-cols: 6; }

/* Tablet: at most 2 columns. Phone: single column. */
@media (max-width: 900px) {
	.ytpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
	.ytpi-grid { grid-template-columns: 1fr; }
}

.ytpi-card {
	display: flex;
	flex-direction: column;
}

/* ---------- Sort pills (YouTube-style filter chips) ---------- */

.ytpi-toolbar {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-start;
	align-items: center;
	gap: 10px;
	margin: 0 0 18px;
}

.ytpi-sort-pills {
	display: inline-flex;
	flex-wrap: wrap;
	gap: 8px;
}

.ytpi-pill {
	padding: 7px 14px;
	border: 0;
	border-radius: 8px;
	background: rgba(0, 0, 0, 0.06);
	color: inherit;
	font: inherit;
	font-size: 0.9em;
	font-weight: 500;
	line-height: 1.3;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}

.ytpi-pill:hover:not(.is-active):not(:disabled) {
	background: rgba(0, 0, 0, 0.13);
}

.ytpi-pill.is-active {
	background: #0f0f0f;
	color: #fff;
	cursor: default;
}

.ytpi-pill:disabled {
	opacity: 0.6;
	cursor: default;
}

.ytpi-pill:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

.ytpi-sort-error {
	flex-basis: 100%;
	margin: 0;
	color: #a10000;
	font-size: 0.88em;
}

/* Dim the grid while a new sort is loading. */
.ytpi-grid-busy {
	opacity: 0.45;
	pointer-events: none;
	transition: opacity 0.15s ease;
}

/* The thumbnail is the play trigger (popup); the title is the link to the
   episode page. Keeping them separate is what gives a real, crawlable page
   link while the thumbnail still opens the on-site player. */
.ytpi-thumb-link {
	display: block;
	border-radius: 12px;
	text-decoration: none;
	color: inherit;
	cursor: pointer;
}

.ytpi-thumb-link:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 3px;
}

.ytpi-thumb-wrap {
	position: relative;
	display: block;
	border-radius: 12px;
	overflow: hidden;
	aspect-ratio: 16 / 9;
	background: #e8e8e8;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ytpi-thumb-link:hover .ytpi-thumb-wrap,
.ytpi-thumb-link:focus-visible .ytpi-thumb-wrap {
	transform: translateY(-3px);
	box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

.ytpi-thumb {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Play badge */
.ytpi-play {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

.ytpi-play::before {
	content: "";
	width: 60px;
	height: 44px;
	background: rgba(0, 0, 0, 0.72);
	border-radius: 12px;
	transition: background 0.2s ease, transform 0.2s ease;
}

.ytpi-play::after {
	content: "";
	position: absolute;
	border-style: solid;
	border-width: 11px 0 11px 18px;
	border-color: transparent transparent transparent #fff;
	margin-left: 4px;
	transition: transform 0.2s ease;
}

.ytpi-thumb-link:hover .ytpi-play::before,
.ytpi-thumb-link:focus-visible .ytpi-play::before {
	background: rgba(204, 0, 0, 0.92);
	transform: scale(1.06);
}

.ytpi-title {
	display: -webkit-box;
	margin-top: 12px;
	font-weight: 600;
	line-height: 1.35;
	color: inherit;
	text-decoration: none;
	overflow: hidden;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}

.ytpi-title:hover,
.ytpi-title:focus-visible {
	text-decoration: underline;
	text-underline-offset: 2px;
}

.ytpi-meta {
	display: flex;
	align-items: baseline;
	gap: 12px;
	margin-top: 5px;
}

/* "1.8K views · 2 weeks ago", like YouTube's card meta line. */
.ytpi-stats {
	font-size: 0.85em;
	opacity: 0.65;
}

.ytpi-page-link {
	margin-left: auto;
	font-size: 0.82em;
	font-weight: 600;
	white-space: nowrap;
	text-decoration: none;
	color: #cc0000;
}

.ytpi-page-link:hover,
.ytpi-page-link:focus-visible {
	text-decoration: underline;
}

.ytpi-empty {
	padding: 14px 16px;
	border-left: 4px solid #2271b1;
	background: #f6f7f7;
}

/* ---------- Modal player ---------- */

.ytpi-modal {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

.ytpi-modal[hidden] { display: none; }

.ytpi-modal-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.82);
}

.ytpi-modal-inner {
	position: relative;
	width: min(960px, 100%);
	z-index: 1;
}

.ytpi-modal-frame {
	position: relative;
	aspect-ratio: 16 / 9;
	background: #000;
	border-radius: 10px;
	overflow: hidden;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

.ytpi-modal-frame iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

.ytpi-modal-error {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	padding: 20px;
	text-align: center;
}

.ytpi-modal-close {
	position: absolute;
	top: -44px;
	right: 0;
	width: 36px;
	height: 36px;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.15);
	color: #fff;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	transition: background 0.15s ease;
}

.ytpi-modal-close:hover,
.ytpi-modal-close:focus-visible {
	background: rgba(255, 255, 255, 0.32);
	outline: none;
}

@media (max-width: 560px) {
	.ytpi-modal { padding: 10px; }
	.ytpi-modal-close { top: -42px; right: 2px; }
}

/* ---------- Duration badge ---------- */

.ytpi-duration {
	position: absolute;
	right: 8px;
	bottom: 8px;
	padding: 2px 6px;
	border-radius: 4px;
	background: rgba(0, 0, 0, 0.8);
	color: #fff;
	font-size: 0.78em;
	line-height: 1.4;
	font-variant-numeric: tabular-nums;
}

/* ---------- Load more ---------- */

.ytpi-more-wrap {
	margin: 8px 0 28px;
	text-align: center;
}

.ytpi-load-more {
	display: inline-block;
	padding: 12px 28px;
	border: 1px solid currentColor;
	border-radius: 999px;
	background: transparent;
	color: inherit;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}

.ytpi-load-more:hover:not(:disabled),
.ytpi-load-more:focus-visible:not(:disabled) {
	background: #cc0000;
	border-color: #cc0000;
	color: #fff;
}

.ytpi-load-more:disabled {
	opacity: 0.6;
	cursor: default;
}

.ytpi-more-error {
	margin: 12px 0 0;
	color: #a10000;
}

.ytpi-card[tabindex="-1"]:focus {
	outline: none;
}

/* ---------- Single episode page ---------- */

.ytpi-single-player {
	position: relative;
	aspect-ratio: 16 / 9;
	margin: 0 0 18px;
	background: #000;
	border-radius: 10px;
	overflow: hidden;
}

.ytpi-single-player iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

.ytpi-single-meta {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 18px;
	align-items: center;
	margin: 0 0 22px;
	font-size: 0.92em;
	opacity: 0.85;
}

.ytpi-single-meta .ytpi-single-yt {
	margin-left: auto;
	font-weight: 600;
}

.ytpi-tags {
	margin-top: 28px;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
}

.ytpi-tags-label {
	font-weight: 600;
}

.ytpi-tag {
	display: inline-block;
	padding: 3px 10px;
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.07);
	font-size: 0.85em;
	text-decoration: none;
	color: inherit;
}

.ytpi-tag:hover,
.ytpi-tag:focus-visible {
	background: rgba(204, 0, 0, 0.12);
}

@media (max-width: 560px) {
	.ytpi-single-meta .ytpi-single-yt { margin-left: 0; }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
	.ytpi-thumb-wrap,
	.ytpi-thumb-link:hover .ytpi-thumb-wrap { transition: none; transform: none; }
	.ytpi-load-more { transition: none; }
}
