/**
 * Template Sell Demo Importer - demo grid refinements.
 *
 * One Click Demo Import shows a centred title and, only on hover, swaps it for
 * two full size buttons. That hides the name exactly when someone is deciding
 * which demo to take. These rules put the name on the left and small buttons on
 * the right, both visible at all times.
 *
 * The paired selectors below are not duplicates: OCDI toggles these elements
 * with `.ocdi__gl-item:hover .x { display: ... }`, which scores higher than a
 * plain class. Matching that shape and landing later in the cascade wins the
 * override without reaching for !important.
 */

.ocdi__gl-item-footer {
	display: -webkit-box;
	display: -ms-flexbox;
	display: flex;
	-webkit-box-align: center;
	-ms-flex-align: center;
	align-items: center;
	-webkit-box-pack: justify;
	-ms-flex-pack: justify;
	justify-content: space-between;
	gap: 10px;
	padding: 9px 12px;
}

.ocdi__gl-item-title,
.ocdi__gl-item:hover .ocdi__gl-item-title {
	display: block;
	-webkit-box-flex: 1;
	-ms-flex: 1 1 auto;
	flex: 1 1 auto;
	min-width: 0;
	margin: 0;
	padding: 0;
	overflow: hidden;
	font-size: 14px;
	line-height: 20px;
	font-weight: 600;
	text-align: left;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.ocdi__gl-item-buttons,
.ocdi__gl-item:hover .ocdi__gl-item-buttons {
	display: -webkit-box;
	display: -ms-flexbox;
	display: flex;
	-webkit-box-flex: 0;
	-ms-flex: 0 0 auto;
	flex: 0 0 auto;
	gap: 6px;
	text-align: right;
}

/* OCDI spaces the pair with a margin; the flex gap already does that. */
.ocdi__gl-item-button + .ocdi__gl-item-button {
	margin-left: 0;
}

.ocdi__gl-item-button.button {
	min-height: 0;
	height: auto;
	padding: 2px 9px;
	font-size: 11px;
	line-height: 18px;
	white-space: nowrap;
}

/*
 * Narrow screens: OCDI makes each button half the row and floats the second.
 * Undo both, and let the name sit above the buttons instead of being squeezed.
 */
@media ( max-width: 782px ) {

	.ocdi__gl-item-footer {
		-webkit-box-orient: vertical;
		-webkit-box-direction: normal;
		-ms-flex-direction: column;
		flex-direction: column;
		-webkit-box-align: start;
		-ms-flex-align: start;
		align-items: flex-start;
		gap: 8px;
	}

	.ocdi__gl-item-title,
	.ocdi__gl-item:hover .ocdi__gl-item-title {
		white-space: normal;
	}

	.ocdi__gl-item-button,
	.ocdi__gl-item-button + .ocdi__gl-item-button {
		float: none;
		width: auto;
		margin-bottom: 0;
	}
}

/**
 * Card shell.
 *
 * OCDI gives each item a square 1px border. Rounding the card alone would leave
 * the preview image poking through the corners, so the radius and the clipping
 * have to live on the same element.
 */
.ocdi__gl-item {
	overflow: hidden;
	border: 1px solid #e2e4e7;
	border-radius: 10px;
	background-color: #ffffff;
	box-shadow: 0 1px 2px rgba( 0, 0, 0, 0.04 );
	transition: box-shadow 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.ocdi__gl-item:hover {
	border-color: #c3c8ce;
	box-shadow: 0 6px 18px rgba( 0, 0, 0, 0.10 );
	transform: translateY( -2px );
}

/* The image sits flush to the card edge; the parent's radius does the clipping. */
.ocdi__gl-item-image-container {
	background-color: #f2f3f5;
	border-bottom: 1px solid #e8eaed;
}

.ocdi__gl-item-footer,
.ocdi__gl-item:hover .ocdi__gl-item-footer {
	background: #ffffff;
	border-top: 0;
}

.ocdi__gl-item-button.button {
	border-radius: 4px;
}

/* Filter bar and search field, squared off by default. */
.ocdi__gl-header {
	border-radius: 10px;
}

.ocdi__gl-search-input {
	border-radius: 4px;
}

/**
 * Four across on wide screens.
 *
 * OCDI stops at three columns from 1120px up, using a 30px gutter created by a
 * -30px pull on the container against a 30px margin on each item. Keeping that
 * same gutter means a quarter width is calc(25% - 30px): four items then span
 * 100% exactly, and the fourth item's trailing margin is absorbed by the pull.
 *
 * Held back to 1400px so the admin column has room; below that OCDI's three
 * across still reads better than four cramped cards.
 */
@media ( min-width: 1400px ) {

	.ocdi__gl-item {
		-webkit-box-flex: 0;
		-ms-flex: 0 0 calc( 25% - 30px );
		flex: 0 0 calc( 25% - 30px );
	}
}

/**
 * Tabs: Demo Import / More Themes.
 *
 * OCDI has no tab system, so the bar and the themes panel are printed from its
 * 'plugin_page_header' hook. That makes the panel a sibling of the demo grid
 * rather than its parent, which is why a class on <body> does the switching.
 */
.ts-tabs {
	margin: 18px 0 22px;
	padding-top: 0;
}

.ts-tab-count {
	display: inline-block;
	margin-left: 6px;
	padding: 0 6px;
	border-radius: 9px;
	background: #dcdcde;
	color: #2c3338;
	font-size: 11px;
	line-height: 18px;
	font-weight: 600;
}

.nav-tab-active .ts-tab-count {
	background: #2271b1;
	color: #ffffff;
}

.ts-themes-panel {
	display: none;
}

body.ts-show-themes .ts-themes-panel {
	display: block;
}

/* OCDI's own views, hidden while the themes tab is open. */
body.ts-show-themes .ocdi__gl,
body.ts-show-themes .ocdi__title,
body.ts-show-themes .ocdi__intro-text {
	display: none;
}

.ts-themes-intro,
.ts-themes-empty {
	margin: 0 0 18px;
	color: #50575e;
	font-size: 13px;
}

.ts-themes-grid {
	display: -webkit-box;
	display: -ms-flexbox;
	display: flex;
	-ms-flex-wrap: wrap;
	flex-wrap: wrap;
}

/* The screenshot needs a positioned parent for the Active flag. */
.ts-theme-item .ocdi__gl-item-image-container {
	position: relative;
}

.ts-theme-active {
	position: absolute;
	top: 8px;
	left: 8px;
	z-index: 2;
	padding: 2px 8px;
	border-radius: 3px;
	background: #2271b1;
	color: #ffffff;
	font-size: 11px;
	line-height: 18px;
	font-weight: 600;
}

/**
 * Two column shell.
 *
 * The markup for this is built in admin.js, because OCDI prints the header,
 * the category nav and the grid as one flat column and offers no filter to
 * change that.
 */
.ts-layout {
	display: -webkit-box;
	display: -ms-flexbox;
	display: flex;
	-ms-flex-align: start;
	align-items: flex-start;
	gap: 24px;
}

.ts-side {
	-ms-flex: 0 0 220px;
	flex: 0 0 220px;
	position: -webkit-sticky;
	position: sticky;
	top: 46px;
}

.ts-main {
	-ms-flex: 1 1 auto;
	flex: 1 1 auto;
	min-width: 0;
}

/* The grid lives inside .ts-main now, so its columns are measured against a
   narrower box: three across, and four only once there is real room. */
.ts-main .ocdi__gl-item-container {
	margin-right: -20px;
}

.ts-main .ocdi__gl-item {
	-ms-flex: 0 0 calc( 50% - 20px );
	flex: 0 0 calc( 50% - 20px );
	margin-right: 20px;
	margin-bottom: 20px;
}

@media ( min-width: 1200px ) {

	.ts-main .ocdi__gl-item {
		-ms-flex: 0 0 calc( 33.333% - 20px );
		flex: 0 0 calc( 33.333% - 20px );
	}
}

@media ( min-width: 1600px ) {

	.ts-main .ocdi__gl-item {
		-ms-flex: 0 0 calc( 25% - 20px );
		flex: 0 0 calc( 25% - 20px );
	}
}

/* Brand, sitting where the category links used to be. */
.ts-brand {
	display: -webkit-box;
	display: -ms-flexbox;
	display: flex;
	-ms-flex-align: center;
	align-items: center;
	gap: 9px;
	float: left;
	padding: 11px 0;
}

.ts-brand-mark {
	display: -webkit-box;
	display: -ms-flexbox;
	display: flex;
	-ms-flex-align: center;
	align-items: center;
	-ms-flex-pack: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	border-radius: 7px;
	background: linear-gradient( 135deg, #2271b1 0%, #135e96 100% );
	color: #ffffff;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.02em;
}

.ts-brand-text {
	display: -webkit-box;
	display: -ms-flexbox;
	display: flex;
	-webkit-box-orient: vertical;
	-ms-flex-direction: column;
	flex-direction: column;
	line-height: 1.2;
}

.ts-brand-text strong {
	font-size: 13px;
	color: #1d2327;
}

.ts-brand-text em {
	font-style: normal;
	font-size: 11px;
	color: #787c82;
}

/* Filter column. */
.ts-filter {
	padding: 14px 16px 12px;
	border: 1px solid #e2e4e7;
	border-radius: 10px;
	background: #ffffff;
	box-shadow: 0 1px 2px rgba( 0, 0, 0, 0.04 );
}

.ts-filter-title {
	margin: 0 0 10px;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: #787c82;
}

.ts-filter-list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.ts-filter-list li {
	margin: 0;
}

.ts-filter-list label {
	display: -webkit-box;
	display: -ms-flexbox;
	display: flex;
	-ms-flex-align: center;
	align-items: center;
	gap: 8px;
	padding: 5px 6px;
	border-radius: 5px;
	cursor: pointer;
	font-size: 13px;
	color: #2c3338;
}

.ts-filter-list label:hover {
	background: #f2f5f8;
}

.ts-filter-list input {
	margin: 0;
}

.ts-filter-name {
	-ms-flex: 1 1 auto;
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.ts-filter-count {
	-ms-flex: 0 0 auto;
	flex: 0 0 auto;
	min-width: 20px;
	padding: 0 5px;
	border-radius: 9px;
	background: #f0f0f1;
	color: #646970;
	font-size: 11px;
	line-height: 18px;
	text-align: center;
}

.ts-filter-reset {
	margin-top: 8px;
	padding: 0 6px;
	color: #2271b1;
	font-size: 12px;
	text-decoration: none;
}

.ts-empty {
	margin: 4px 0 24px;
	padding: 26px;
	border: 1px dashed #d0d4d9;
	border-radius: 10px;
	color: #646970;
	text-align: center;
}

/* Stack on narrow admin screens. */
@media ( max-width: 960px ) {

	.ts-layout {
		-webkit-box-orient: vertical;
		-ms-flex-direction: column;
		flex-direction: column;
	}

	.ts-side {
		-ms-flex: 1 1 auto;
		flex: 1 1 auto;
		position: static;
		width: 100%;
	}
}

/**
 * Header row: brand left, search right.
 *
 * OCDI lays this bar out for a nav that floats beside a fixed width search box.
 * With the nav moved to the sidebar the two remaining children overlap, so the
 * bar becomes a flex row and the search box gives up its hard coded offsets.
 */
.ocdi__gl-header {
	display: -webkit-box;
	display: -ms-flexbox;
	display: flex;
	-ms-flex-align: center;
	align-items: center;
	-ms-flex-pack: justify;
	justify-content: space-between;
	gap: 16px;
	padding: 6px 14px;
}

.ts-brand {
	float: none;
	-ms-flex: 0 0 auto;
	flex: 0 0 auto;
	padding: 5px 0;
}

.ocdi__gl-header .ocdi__gl-search,
.ocdi__gl-header div[clas="ocdi__gl-search"] {
	-ms-flex: 0 1 320px;
	flex: 0 1 320px;
}

.ocdi__gl-search-input {
	width: 100%;
	max-width: 320px;
	height: 32px;
	margin: 0;
	margin-top: 0;
}

@media ( max-width: 640px ) {

	.ocdi__gl-header {
		-webkit-box-orient: vertical;
		-ms-flex-direction: column;
		flex-direction: column;
		-ms-flex-align: stretch;
		align-items: stretch;
		gap: 10px;
	}

	.ocdi__gl-search-input {
		max-width: none;
	}
}

/**
 * Single panel.
 *
 * The header bar and the two columns are wrapped together in admin.js so the
 * whole screen is one surface. The pieces inside therefore drop their own
 * borders, shadows and radii, and separate with hairlines instead.
 */
.ts-wrap {
	overflow: hidden;
	margin-bottom: 24px;
	border: 1px solid #dcdfe3;
	border-radius: 12px;
	background: #ffffff;
	box-shadow: 0 1px 3px rgba( 0, 0, 0, 0.05 );
}

.ts-wrap .ocdi__gl-header {
	width: auto;
	margin: 0;
	border: 0;
	border-bottom: 1px solid #e6e8eb;
	border-radius: 0;
	background: #fbfcfd;
	box-shadow: none;
}

.ts-wrap .ts-layout {
	gap: 0;
}

.ts-wrap .ts-side {
	-ms-flex: 0 0 216px;
	flex: 0 0 216px;
	position: static;
	border-right: 1px solid #e6e8eb;
	background: #fcfcfd;
}

.ts-wrap .ts-filter {
	padding: 16px 14px;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
}

.ts-wrap .ts-main {
	padding: 20px 20px 4px;
}

/* Buttons trimmed so the demo name has room before it truncates. */
.ocdi__gl-item-button.button {
	padding: 1px 7px;
	font-size: 10px;
	line-height: 17px;
}

.ocdi__gl-item-footer {
	gap: 8px;
	padding: 8px 10px;
}

.ocdi__gl-item-buttons,
.ocdi__gl-item:hover .ocdi__gl-item-buttons {
	gap: 4px;
}

.ts-filter-reset {
	display: inline-block;
	margin-top: 10px;
	text-decoration: none;
}

@media ( max-width: 960px ) {

	.ts-wrap .ts-side {
		-ms-flex: 1 1 auto;
		flex: 1 1 auto;
		border-right: 0;
		border-bottom: 1px solid #e6e8eb;
	}
}

/* A <button> keeps native chrome even with .button-link; strip it. */
.ts-filter-reset,
.ts-filter-reset:hover,
.ts-filter-reset:focus {
	border: 0;
	background: none;
	box-shadow: none;
	outline: 0;
	cursor: pointer;
}

.ts-filter-reset:hover {
	color: #135e96;
	text-decoration: underline;
}

/* The themes tab gets the same single-panel surface as the demos tab. */
body.ts-show-themes .ts-themes-panel {
	margin-bottom: 24px;
	padding: 18px 20px 2px;
	border: 1px solid #dcdfe3;
	border-radius: 12px;
	background: #ffffff;
	box-shadow: 0 1px 3px rgba( 0, 0, 0, 0.05 );
}

.ts-themes-intro {
	margin: 0 0 16px;
}

.ts-theme-item .ocdi__gl-item-image-container::after {
	padding-top: 75%;
}

/**
 * Clear filters.
 *
 * The element carries WP's own .button class, and `.wp-core-ui .button` scores
 * 0-2-0 against a plain `.ts-filter-reset` at 0-1-0, so the earlier reset never
 * applied and the native button chrome stayed visible. Matching .wp-core-ui and
 * both classes scores 0-3-0 and actually wins.
 */
.wp-core-ui .button.ts-filter-reset,
.wp-core-ui .button.ts-filter-reset:hover,
.wp-core-ui .button.ts-filter-reset:focus,
.wp-core-ui .button.ts-filter-reset:active {
	display: inline-block;
	height: auto;
	min-height: 0;
	margin: 12px 0 0;
	padding: 0 4px;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	outline: 0;
	color: #2271b1;
	font-size: 12px;
	line-height: 20px;
	text-decoration: none;
	cursor: pointer;
}

.wp-core-ui .button.ts-filter-reset:hover {
	color: #135e96;
	text-decoration: underline;
}

/**
 * Card footer at a readable size.
 *
 * The first pass shrank the buttons to 10px to buy room for the demo name; at
 * three and four columns there is enough width for both, so they go back up to
 * a normal admin size.
 */
.ocdi__gl-item-footer {
	gap: 10px;
	padding: 11px 13px;
}

.ocdi__gl-item-title,
.ocdi__gl-item:hover .ocdi__gl-item-title {
	font-size: 15px;
	line-height: 22px;
}

.ocdi__gl-item-button.button,
.wp-core-ui .ocdi__gl-item-button.button {
	height: auto;
	min-height: 0;
	padding: 4px 12px;
	border-radius: 4px;
	font-size: 12px;
	line-height: 20px;
	font-weight: 500;
}

.ocdi__gl-item-buttons,
.ocdi__gl-item:hover .ocdi__gl-item-buttons {
	gap: 7px;
}

/* Filter rows scale with the rest. */
.ts-filter-title {
	font-size: 12px;
}

.ts-filter-list label {
	padding: 7px 7px;
	font-size: 13.5px;
}

.ts-filter-count {
	font-size: 11.5px;
	line-height: 19px;
}

/**
 * Let the demo name wrap rather than truncate.
 *
 * Full size buttons leave roughly 130px for the title on a three-up card, which
 * cuts "Classic Newspaper" to "Classic News...". Wrapping to a second line keeps
 * the name on the left and the buttons on the right while showing all of it.
 */
.ocdi__gl-item-title,
.ocdi__gl-item:hover .ocdi__gl-item-title {
	overflow: visible;
	font-size: 14px;
	line-height: 18px;
	white-space: normal;
	text-overflow: clip;
	word-break: normal;
	overflow-wrap: break-word;
}

.ocdi__gl-item-footer {
	-ms-flex-align: center;
	align-items: center;
	min-height: 56px;
}

/**
 * Themes grid: gutters from gap, not a negative margin.
 *
 * OCDI builds its gutters by pulling the container -30px against a 30px margin
 * on each card. Inside a padded panel that pull escapes the padding and widens
 * the document, which is what put a horizontal scrollbar on the page. Using a
 * real gap keeps the row inside its box.
 */
.ts-themes-panel .ocdi__gl-item-container {
	margin-right: 0;
	gap: 20px;
}

.ts-themes-panel .ocdi__gl-item {
	margin-right: 0;
	margin-bottom: 0;
	-ms-flex: 0 0 calc( 50% - 10px );
	flex: 0 0 calc( 50% - 10px );
}

@media ( min-width: 1200px ) {

	.ts-themes-panel .ocdi__gl-item {
		-ms-flex: 0 0 calc( 33.333% - 13.34px );
		flex: 0 0 calc( 33.333% - 13.34px );
	}
}

@media ( min-width: 1600px ) {

	.ts-themes-panel .ocdi__gl-item {
		-ms-flex: 0 0 calc( 25% - 15px );
		flex: 0 0 calc( 25% - 15px );
	}
}

/* Same treatment for the demo grid, so neither tab can widen the document. */
.ts-main .ocdi__gl-item-container {
	margin-right: 0;
	gap: 20px;
}

.ts-main .ocdi__gl-item {
	margin-right: 0;
	margin-bottom: 0;
	-ms-flex: 0 0 calc( 50% - 10px );
	flex: 0 0 calc( 50% - 10px );
}

@media ( min-width: 1200px ) {

	.ts-main .ocdi__gl-item {
		-ms-flex: 0 0 calc( 33.333% - 13.34px );
		flex: 0 0 calc( 33.333% - 13.34px );
	}
}

@media ( min-width: 1600px ) {

	.ts-main .ocdi__gl-item {
		-ms-flex: 0 0 calc( 25% - 15px );
		flex: 0 0 calc( 25% - 15px );
	}
}

.ts-wrap .ts-main {
	padding-bottom: 20px;
}
