/* Phone layout details that differ structurally from the desktop
   prototype (the phone prototype re-orders some blocks). */
@media (max-width: 1023px) {
	/* Forms (quick request, contacts, price request, career) */
	.bts-c form {
		width: auto !important;
		max-width: 100% !important;
		flex-shrink: 1 !important;
	}

	.bts-c form div[style*="grid-template-columns"]:has(> label) {
		grid-template-columns: minmax(0, 1fr) !important;
	}

	/* "Visos paslaugos" goes under the cards as an outline button */
	.bts-c .bts-m-svc-head {
		display: contents !important;
	}

	.bts-c .bts-m-svc-head ~ * {
		order: 2;
	}

	.bts-c .bts-m-svc-more {
		order: 3;
		display: flex !important;
		align-items: center;
		justify-content: center;
		gap: 8px;
		height: 52px;
		border: 2px solid #3B5AA8;
		border-radius: 12px;
		color: #3B5AA8;
		font-size: 16px;
		font-weight: 700;
	}

	.bts-c .bts-m-svc-head > :not(.bts-m-svc-more):not(p) {
		order: 1;
	}

	/* Photo between the heading and the text, as in the phone prototype */
	.bts-c .bts-m-ord-grid {
		display: flex !important;
		flex-direction: column !important;
		align-items: stretch !important;
		gap: 20px !important;
	}

	.bts-c .bts-m-ord-text {
		display: contents !important;
	}

	.bts-c .bts-m-ord-grid > .bts-m-ord-text > * {
		order: 5;
	}

	.bts-c .bts-m-img-after-2 > .bts-m-ord-text > :nth-child(-n+2),
	.bts-c .bts-m-img-after-3 > .bts-m-ord-text > :nth-child(-n+3) {
		order: 1;
	}

	.bts-c .bts-m-ord-grid > :not(.bts-m-ord-text),
	.bts-c .bts-m-ord-grid > figure img {
		order: 3;
	}
}

@media (max-width: 1023px) {
	/* Links and buttons inside re-ordered columns (their wrapper boxes
	   disappear, so the order goes on the link itself). */
	.bts-c .bts-m-ord-grid > .bts-m-ord-text > .bts-dc > a,
	.bts-c .bts-m-ord-grid > .bts-m-ord-text > .wp-block-buttons.bts-dc .wp-block-button__link {
		order: 5;
	}

	/* "Visi ES projektai": after the project cards */
	.bts-c .bts-m-linklast > .bts-m-ord-text > * {
		order: 1 !important;
	}

	.bts-c .bts-m-linklast > :not(.bts-m-ord-text) {
		order: 2 !important;
	}

	.bts-c .bts-m-linklast > .bts-m-ord-text > .bts-dc > a {
		order: 3 !important;
	}
}

@media (max-width: 1023px) {
	/* Apie: "Visos naujienos" goes under the news cards */
	.bts-c .bts-m-linkend-head {
		display: contents !important;
	}

	.bts-c .bts-m-linkend-head ~ * {
		order: 2;
	}

	.bts-c .bts-m-linkend-head > :not(.bts-m-linkend) {
		order: 1;
	}

	.bts-c .bts-m-linkend,
	.bts-c .bts-m-linkend-head > .bts-dc > a,
	.bts-c .bts-m-linkend-head .wp-block-button__link {
		order: 3;
		padding: 0 4px !important;
	}

	/* Apie: "BTS kasdien" photo grid, 2 columns */
	.bts-c .bts-m-gal {
		display: grid !important;
		grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
		grid-auto-rows: 130px !important;
		gap: 10px !important;
	}

	.bts-c .bts-m-gal img {
		border-radius: 12px !important;
	}
}

@media (max-width: 1023px) {
	/* Privacy policy, terms: contents list as an accordion on top,
	   "Turite klausimų?" box after the text. */
	.bts-c .bts-m-legal {
		display: flex !important;
		flex-direction: column !important;
		gap: 28px !important;
	}

	.bts-c .bts-m-legal-aside {
		display: contents !important;
	}

	.bts-c .bts-m-legal-toc {
		order: 1;
	}

	.bts-c .bts-m-legal > :not(.bts-m-legal-aside) {
		order: 2;
	}

	.bts-c .bts-m-legal-box {
		order: 3;
	}
}

@media (max-width: 1023px) {
	/* Sections the phone prototype shows in another order */
	main.bts-c:has(> .bts-m-o) {
		display: flex;
		flex-direction: column;
	}

	.bts-c > .bts-m-o-0 {
		order: 0;
	}

	.bts-c > .bts-m-o-1 {
		order: 1;
	}

	.bts-c > .bts-m-o-2 {
		order: 2;
	}

	.bts-c > .bts-m-o-3 {
		order: 3;
	}

	.bts-c > .bts-m-o-4 {
		order: 4;
	}

	.bts-c > .bts-m-o-5 {
		order: 5;
	}

	.bts-c > .bts-m-o-6 {
		order: 6;
	}

	.bts-c > .bts-m-o-7 {
		order: 7;
	}

	.bts-c > .bts-m-o-8 {
		order: 8;
	}

	.bts-c > .bts-m-o-9 {
		order: 9;
	}

	.bts-c > .bts-m-o-10 {
		order: 10;
	}

	.bts-c > .bts-m-o-11 {
		order: 11;
	}

	.bts-c > .bts-m-o-12 {
		order: 12;
	}
}

/* Swipe rows on the phone (home: "Kodėl BTS" values, testimonials).
   In the phone prototype these rows are horizontal scrollers. */
@media (max-width: 1023px) {
	.bts-c .m-bff2354,
	.bts-c .m-7df9265 {
		overflow-x: auto;
		overflow-y: hidden;
		scroll-snap-type: x mandatory;
		-webkit-overflow-scrolling: touch;
		overscroll-behavior-x: contain;
		scrollbar-width: none;
	}

	.bts-c .m-bff2354 {
		scroll-padding-inline: 20px;
	}

	.bts-c .m-7df9265 {
		scroll-padding-inline: 16px;
	}

	.bts-c .m-bff2354::-webkit-scrollbar,
	.bts-c .m-7df9265::-webkit-scrollbar {
		display: none;
	}

	.bts-c .m-bff2354 > *,
	.bts-c .m-7df9265 > * {
		flex-shrink: 0;
		scroll-snap-align: start;
	}

	/* Kontaktai hero: info pills wrap onto two lines (phone prototype). */
	.bts-c .b-617f340 {
		flex-wrap: wrap;
		gap: 8px;
		padding-top: 4px;
	}
}

/* Arrows under the swipe rows (phone prototype). */
@media (max-width: 1023px) {
	.bts-c .bts-m-scroll {
		overflow-x: auto;
		overflow-y: hidden;
		scroll-snap-type: x mandatory;
		-webkit-overflow-scrolling: touch;
		overscroll-behavior-x: contain;
		scrollbar-width: none;
	}

	.bts-c .bts-m-scroll::-webkit-scrollbar {
		display: none;
	}

	.bts-c .bts-m-scroll > * {
		flex-shrink: 0;
		scroll-snap-align: start;
	}

	.bts-c .bts-m-arrows {
		display: flex;
		align-items: center;
		justify-content: flex-end;
		gap: 12px;
	}

	.bts-c .bts-m-arrows .arrowbtn {
		transition: opacity .15s, border-color .15s;
	}
}

/* Arrows under "Kodėl BTS" values and ES projects sit as far from the
   right edge as the testimonial arrows (inside their grey box). */
@media (max-width: 1023px) {
	.bts-c .m-bff2354 + .bts-m-arrows,
	.bts-c #bts-eu + .b-8d4a676 {
		padding-right: 16px;
	}
}

/* Button text always on one line. */
.bts-c :is(a.cta, button.cta, .wp-block-button.cta > .wp-block-button__link, a.btn-ghost, button.btn-ghost, .wp-block-button.btn-ghost > .wp-block-button__link) {
	white-space: nowrap;
}

@media (max-width: 1023px) {
	/* Form send buttons are full width on the phone (phone prototype);
	   "Gauti kainą" goes above the "Atsakome tą pačią darbo dieną" note. */
	.bts-c form [data-bts-submit] {
		align-self: stretch !important;
	}

	.bts-c form div:has(> [data-bts-submit]) {
		flex-direction: column !important;
		align-items: stretch !important;
		gap: 10px !important;
	}

	/* Kontaktai map card: "Maršrutas" + "Kopijuoti adresą" – the second
	   button moves under the first on very narrow phones. */
	.bts-c .b-3fd7e90 {
		flex-wrap: wrap !important;
	}

	.bts-c .b-3fd7e90 > .btn-ghost {
		flex: 1 1 auto !important;
	}
}

/* Very narrow phones: two buttons side by side go one under the other. */
@media (max-width: 360px) {
	.bts-c div[style*="grid-template-columns: repeat(2"]:has(> :is(a, button):is(.cta, .btn-ghost)) {
		grid-template-columns: minmax(0, 1fr) !important;
	}
}
