/**
 * CT Tables — stili frontend.
 *
 * Volutamente neutri: ereditano font/colori dal tema (The7/Ohio). Le regole
 * strutturali (ordinamento, responsive) sono le uniche opinionate.
 */

.ctt-table-wrap {
	width: 100%;
	overflow-x: auto;
}

.ctt-table {
	width: 100%;
	border-collapse: collapse;
	margin: 0 0 1.5em;
}

.ctt-table caption {
	caption-side: top;
	text-align: left;
	font-weight: 600;
	padding: 0.5em 0;
}

.ctt-table th,
.ctt-table td {
	padding: 0.6em 0.8em;
	border: 1px solid rgba( 0, 0, 0, 0.12 );
	text-align: left;
	vertical-align: top;
}

.ctt-table thead th {
	background: rgba( 0, 0, 0, 0.04 );
	font-weight: 600;
}

.ctt-table img {
	max-width: 100%;
	height: auto;
}

/* -------------------------------------------------------------------------- */
/* Ordinamento                                                                */
/* -------------------------------------------------------------------------- */

.ctt-sortable thead th {
	padding: 0;
}

.ctt-sort {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.4em;
	width: 100%;
	padding: 0.6em 0.8em;
	background: none;
	border: 0;
	font: inherit;
	font-weight: 600;
	color: inherit;
	text-align: left;
	cursor: pointer;
}

.ctt-sort:hover,
.ctt-sort:focus-visible {
	background: rgba( 0, 0, 0, 0.06 );
	outline: 2px solid currentColor;
	outline-offset: -2px;
}

.ctt-sort__icon {
	flex: 0 0 auto;
	width: 0.7em;
	height: 0.7em;
	opacity: 0.35;
	background-image:
		linear-gradient( 45deg, transparent 40%, currentColor 40%, currentColor 60%, transparent 60% ),
		linear-gradient( -45deg, transparent 40%, currentColor 40%, currentColor 60%, transparent 60% );
	background-size: 100% 45%;
	background-position: top, bottom;
	background-repeat: no-repeat;
}

.ctt-sortable th[aria-sort="ascending"] .ctt-sort__icon {
	opacity: 1;
	background-image: linear-gradient( 45deg, transparent 40%, currentColor 40%, currentColor 60%, transparent 60% ), linear-gradient( -45deg, transparent 40%, currentColor 40%, currentColor 60%, transparent 60% );
	background-size: 100% 60%, 100% 0;
	background-position: top, bottom;
}

.ctt-sortable th[aria-sort="descending"] .ctt-sort__icon {
	opacity: 1;
	background-size: 100% 0, 100% 60%;
}

/* -------------------------------------------------------------------------- */
/* Responsive: stacking su mobile                                             */
/* -------------------------------------------------------------------------- */

@media screen and (max-width: 640px) {
	.ctt-responsive {
		border: 0;
	}

	/* Intestazione visivamente nascosta ma presente per gli screen reader. */
	.ctt-responsive thead {
		position: absolute;
		width: 1px;
		height: 1px;
		margin: -1px;
		padding: 0;
		overflow: hidden;
		clip: rect( 0 0 0 0 );
		clip-path: inset( 50% );
		white-space: nowrap;
		border: 0;
	}

	.ctt-responsive tr {
		display: block;
		margin-bottom: 1em;
		border: 1px solid rgba( 0, 0, 0, 0.15 );
	}

	.ctt-responsive td,
	.ctt-responsive th[scope="row"] {
		display: block;
		border: 0;
		border-bottom: 1px solid rgba( 0, 0, 0, 0.08 );
		padding: 0.5em 0.8em;
	}

	.ctt-responsive tr td:last-child,
	.ctt-responsive tr th:last-child {
		border-bottom: 0;
	}

	.ctt-responsive td[data-label]::before,
	.ctt-responsive th[data-label]::before {
		content: attr( data-label );
		display: block;
		font-weight: 600;
		font-size: 0.85em;
		opacity: 0.7;
		margin-bottom: 0.15em;
	}
}
