/* US #660: Traffic volumes page.
 * Used by the Traffic volumes page and by the four ad format pages (Push, Popunder, In-Page, Video).
 * Filters above the table (Traffic volumes page only); from 1280px the table is the one of the theme (.spreadsheet styles);
 * below 1280px one continuous list of compact cards (one column up to 991px, because the theme keeps the content of all pages
 * below 992px in a 390px column; two columns from 992px). The table of the theme needs about 760px and scrolls sideways in
 * narrower containers. All rows are shown at once, no paging; only vertical scrolling. */

.tv-table-anchor {
	scroll-margin-top: 120px;
}

/* ------------------------------------------------------------------ filters */

.tv-filters {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 16px 20px;
	align-items: flex-end;
	margin: 0 0 24px;
	padding: 0;
	border: 0;
}

.tv-filters__field {
	flex: 0 1 260px;
	max-width: 280px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	min-width: 0;
}

.tv-filters__label {
	font-size: 14px;
	line-height: 20px;
	font-weight: 600;
	color: #000;
}

.tv-filters__select {
	width: 100%;
	box-sizing: border-box;
	min-height: 48px;
	padding: 10px 44px 10px 16px;
	font: inherit;
	font-size: 16px;
	line-height: 24px;
	color: #000;
	background-color: #fff;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' viewBox='0 0 12 7' fill='none'%3E%3Cpath d='M10.1667 1L5.58333 5.58333L1 1' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 16px center;
	border: 1px solid #eaecf5;
	border-radius: 8px;
	box-shadow: 0 4px 24px 0 #4d4e5214;
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
	cursor: pointer;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tv-filters__select option:disabled {
	color: #9a9ba0;
}

.tv-filters__select:hover {
	border-color: #fb5348;
}

.tv-filters__select:focus-visible {
	outline: 2px solid #fb5348;
	outline-offset: 2px;
	border-color: #fb5348;
}

.tv-filters__submit {
	flex: 0 0 auto;
}

.tv-summary {
	margin: 0 0 20px;
	text-align: center;
	font-size: 16px;
	line-height: 26px;
	color: #4c4e53;
}

.tv-summary strong {
	color: #000;
	font-weight: 700;
}

.tv-note {
	margin: 20px 0 0;
	font-size: 14px;
	line-height: 22px;
	color: #4c4e53;
}

.tv-note a {
	color: #fb5348;
}

.tv-empty {
	margin: 0;
	padding: 40px 30px;
	border-radius: 14px;
	box-shadow: 0 8px 70px 0 #4d4e5224;
	text-align: center;
	font-size: 18px;
	line-height: 30px;
	color: #4c4e53;
}

.tv-formats-nav {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 24px;
	margin: 20px 0 56px;
	padding: 0;
	list-style: none;
	font-size: 16px;
	line-height: 26px;
}

.tv-formats-nav a {
	color: #fb5348;
}

/* ------------------------------------------------------------------ table (wide screens) and cards (the rest) */

.tv-mobile {
	display: block;
}

.spreadsheet.tv-desktop {
	display: none;
}

@media (min-width: 1280px) {
	.spreadsheet.tv-desktop {
		display: block;
	}

	.tv-mobile {
		display: none;
	}

	/* a long country name ("Saint Helena, Ascension and Tristan da Cunha") must wrap instead of stretching the column and
	 * pushing the "Action" column out of the card; the table keeps the look of the theme */
	.spreadsheet.tv-desktop tbody td:nth-of-type(2),
	.spreadsheet.tv-desktop tbody td:nth-of-type(2) .spreadsheet__cell {
		white-space: normal;
		overflow-wrap: anywhere;
	}
}

.tv-sort {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin: 0 0 16px;
}

.tv-sort[hidden] {
	display: none;
}

.tv-cards {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 12px;
	margin: 0;
	padding: 0;
}

/* between 992px and 1279px the container is wider than a phone column, but still too narrow for the table: two columns of cards */
@media (min-width: 992px) and (max-width: 1279px) {
	.tv-cards {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 14px;
	}

	.tv-sort {
		max-width: 280px;
	}
}

.tv-card {
	box-sizing: border-box;
	padding: 14px;
	border: 1px solid #eaecf5;
	border-radius: 14px;
	background: #fff;
	box-shadow: 0 6px 30px 0 #4d4e5224;
	/* 230 cards in one list: the browser skips drawing the ones that are far from the screen */
	content-visibility: auto;
	contain-intrinsic-size: auto 240px;
}

.tv-card__head {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
	margin: 0 0 10px;
}

.tv-card__rank {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	min-width: 26px;
	height: 26px;
	padding: 0 7px;
	box-sizing: border-box;
	border-radius: 13px;
	background: rgba(234, 236, 245, 0.8);
	font-size: 12px;
	font-weight: 700;
	line-height: 1;
	color: #4c4e53;
}

.tv-card .spreadsheet__flag {
	flex: 0 0 auto;
	border-radius: 3px;
}

.tv-card__country {
	min-width: 0;
	font-size: 16px;
	font-weight: 700;
	line-height: 22px;
	color: #000;
	overflow-wrap: anywhere;
}

.tv-card__stats {
	margin: 0 0 12px;
}

/* one line per value: the label on the left, the number on the right (a number is never broken into two lines) */
.tv-card__stat {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	min-width: 0;
	margin: 0 0 6px;
	padding: 8px 12px;
	border-radius: 8px;
	background: rgba(234, 236, 245, 0.4);
}

.tv-card__stat:last-child {
	margin-bottom: 0;
}

.tv-card__stat dt {
	margin: 0;
	font-size: 13px;
	line-height: 20px;
	color: #4c4e53;
}

.tv-card__stat dd {
	margin: 0;
	font-size: 16px;
	font-weight: 700;
	line-height: 24px;
	color: #000;
	text-align: right;
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}

.tv-card__cta {
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-height: 44px;
	padding: 8px 16px;
	border: 1px solid #fb5348;
	border-radius: 8px;
	font-size: 15px;
	font-weight: 600;
	line-height: 22px;
	color: #fb5348;
	text-decoration: none;
	transition: background-color 0.2s ease, color 0.2s ease;
}

.tv-card__cta:hover,
.tv-card__cta:focus-visible {
	background: #fb5348;
	color: #fff;
}

/* ------------------------------------------------------------------ dropdowns (custom, replace the native selects when JavaScript works) */

.tv-dd {
	position: relative;
	width: 100%;
}

.tv-dd__native {
	display: none;
}

.tv-dd__button {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	width: 100%;
	box-sizing: border-box;
	min-height: 48px;
	padding: 10px 16px;
	font: inherit;
	font-size: 16px;
	line-height: 24px;
	text-align: left;
	color: #000;
	background: #fff;
	border: 1px solid #eaecf5;
	border-radius: 8px;
	box-shadow: 0 4px 24px 0 #4d4e5214;
	cursor: pointer;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tv-dd__button:hover,
.tv-dd.is-open .tv-dd__button {
	border-color: #fb5348;
}

.tv-dd__button:focus-visible {
	outline: 2px solid #fb5348;
	outline-offset: 2px;
}

.tv-dd__value {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.tv-dd__chevron {
	flex: 0 0 auto;
	width: 8px;
	height: 8px;
	margin: -4px 4px 0 0;
	border-right: 2px solid #000;
	border-bottom: 2px solid #000;
	transform: rotate(45deg);
	transition: transform 0.2s ease, margin 0.2s ease;
}

.tv-dd.is-open .tv-dd__chevron {
	margin-top: 4px;
	transform: rotate(-135deg);
}

.tv-dd__list {
	position: absolute;
	top: calc(100% + 6px);
	left: 0;
	right: 0;
	z-index: 40;
	box-sizing: border-box;
	max-height: 300px;
	margin: 0;
	padding: 6px;
	overflow-y: auto;
	overscroll-behavior: contain;
	list-style: none;
	background: #fff;
	border: 1px solid #eaecf5;
	border-radius: 12px;
	box-shadow: 0 14px 44px 0 #4d4e5238;
}

.tv-dd__list[hidden] {
	display: none;
}

.tv-dd__list:focus {
	outline: none;
}

.tv-dd--up .tv-dd__list {
	top: auto;
	bottom: calc(100% + 6px);
}

.tv-dd__option {
	position: relative;
	display: flex;
	align-items: center;
	min-height: 44px;
	margin: 0;
	padding: 8px 40px 8px 14px;
	box-sizing: border-box;
	font-size: 16px;
	line-height: 24px;
	color: #000;
	border-radius: 8px;
	cursor: pointer;
}

.tv-dd__option.is-active {
	background: rgba(234, 236, 245, 0.7);
}

.tv-dd__option.is-selected {
	font-weight: 700;
}

.tv-dd__option.is-selected::after {
	content: "";
	position: absolute;
	top: 50%;
	right: 16px;
	width: 6px;
	height: 11px;
	margin-top: -7px;
	border-right: 2px solid #fb5348;
	border-bottom: 2px solid #fb5348;
	transform: rotate(45deg);
}

.tv-dd__option.is-disabled {
	color: #9a9ba0;
	cursor: not-allowed;
}

@media (prefers-reduced-motion: reduce) {
	.tv-dd__button,
	.tv-dd__chevron {
		transition: none;
	}
}

/* ------------------------------------------------------------------ small screens */

@media (max-width: 767px) {
	.tv-filters {
		flex-direction: column;
		align-items: stretch;
		gap: 14px;
	}

	.tv-filters__field {
		flex: 1 1 auto;
		max-width: none;
	}

	.tv-summary {
		font-size: 15px;
		line-height: 24px;
	}

	.tv-empty {
		padding: 28px 20px;
		font-size: 16px;
		line-height: 26px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.tv-filters__select,
	.tv-card__cta {
		transition: none;
	}
}
