/* Responsive overrides for the tower/item rows on towers.php and items.php
   (youtd_tower_list / youtd_item_list). Wide screens keep the original fixed layout. */

/* Narrower than the fixed 1120px row: let the abilities column shrink */
@media (max-width: 1200px) {
	li.youtd table.youtd_tower,
	li.youtd table.youtd_tower > tbody {
		display: block;
		width: 100%;
	}

	li.youtd .content_row {
		display: grid;
		width: 100%;
		grid-template-areas: none;
		grid-template-columns: 210px 220px minmax(0, 1fr);
		box-sizing: border-box;
	}

	li.youtd .tower_col {
		display: block;
		min-width: 0;
	}

	li.youtd .title_container,
	li.youtd .details_container {
		margin-right: 0;
	}

	li.youtd div.tower_abilities {
		column-count: auto;
		column-width: 300px;
		column-gap: 8px;
	}

	li.youtd div.tower_ability {
		display: block;
		width: auto;
		max-width: none;
		padding-right: 8px;
		break-inside: avoid;
		box-sizing: border-box;
	}

	li.youtd .tower_ability_desc {
		width: auto;
		text-align: left;
		overflow-wrap: anywhere;
	}

	li.youtd div.tower_ability_header {
		display: inline-flex;
		align-items: center;
		gap: 6px;
		max-width: 100%;
		height: auto;
		min-height: 32px;
	}

	li.youtd div.tower_ability_header img {
		flex: none;
	}
}

/* Tablet: abilities drop below the picture and stats */
@media (max-width: 900px) {
	li.youtd .content_row {
		grid-template-columns: 210px minmax(0, 1fr);
	}

	li.youtd td.tower_right_col {
		grid-column: 1 / -1;
	}
}

/* Phone: everything stacks in one column */
@media (max-width: 560px) {
	li.youtd {
		padding: 5px 0;
	}

	li.youtd .content_row {
		grid-template-columns: minmax(0, 1fr);
	}

	li.youtd .tower_icon {
		margin-top: 8px;
	}

	li.youtd .tower_pic {
		max-width: 100%;
		height: auto;
	}

	li.youtd .details_field,
	li.youtd .details_value,
	li.youtd .tower_desc,
	li.youtd .tower_ability_desc {
		font-size: 12px;
	}

	li.youtd .details_field {
		width: 110px;
	}

	li.youtd .details_value {
		white-space: normal;
		overflow-wrap: anywhere;
	}

	li.youtd div.tower_abilities {
		column-width: auto;
		column-count: 1;
	}
}

/* Filter panel above the list (youtd_filter_panel): stack element and rarity buttons on phones */
@media (max-width: 560px) {
	div.ytd-filter-box {
		width: auto;
		max-width: 100%;
		padding: 8px;
		box-sizing: border-box;
	}

	table.ytd-filter {
		width: 100%;
	}

	table.ytd-filter input#name {
		width: 120px;
	}

	table.ytd-filter > tbody > tr > td {
		display: block;
		text-align: center;
	}

	table.ytd-filter table {
		margin: 0 auto;
	}

	table.ytd-filter input.ytd-filter__submit {
		margin-left: 8px !important;
	}
}
