/**
 * Mobile native-app baseline — all apps using ds_assets_enqueue().
 * Complements shell-responsive.css (768px) and per-app ds-shell.css (767px).
 */

@media (max-width: 767px) {
	html {
		-webkit-text-size-adjust: 100%;
		overflow-x: clip;
	}

	body {
		overflow-x: clip;
		max-width: 100vw;
		-webkit-tap-highlight-color: rgba(55, 155, 215, 0.14);
	}

	/* Full viewport app shells — single scroll surface */
	body.st-ds .main-col.st-app-main,
	body.forge-ds .main-col.st-app-main,
	body.dh-ds .main-col.st-app-main,
	body.mh-ds .main-col.st-app-main,
	body.tp-ds .tp-app-main,
	body.pt-ds .pt-main,
	body.s-ds .s-main,
	body.reach-ds .reach-layout,
	body.cs-ds {
		min-height: 100dvh;
		min-height: -webkit-fill-available;
	}

	body.st-ds .main-col.st-app-main,
	body.forge-ds .main-col.st-app-main,
	body.dh-ds .main-col.st-app-main,
	body.mh-ds .main-col.st-app-main,
	body.tp-ds .tp-app-main {
		display: flex;
		flex-direction: column;
		overflow: hidden;
	}

	body.st-ds .main-col.st-app-main .main-content,
	body.forge-ds .main-content,
	body.dh-ds .main-col.st-app-main .main-content,
	body.mh-ds .main-col.st-app-main .main-content,
	body.tp-ds .tp-main-content {
		flex: 1 1 auto;
		min-height: 0;
	}

	/* Top chrome clears the notch */
	.toolbar.at-topbar,
	.dtb-toolbar,
	body.tp-ds .tp-sticky-header,
	body.pt-ds .pt-mobile-bar {
		padding-top: max(0px, env(safe-area-inset-top));
	}

	body.st-ds .toolbar.at-topbar,
	body.forge-ds .toolbar.at-topbar,
	body.dh-ds .toolbar.at-topbar,
	body.mh-ds .toolbar.at-topbar {
		position: sticky;
		top: 0;
		z-index: 40;
		flex-shrink: 0;
		-webkit-backface-visibility: hidden;
		backface-visibility: hidden;
	}

	/* Primary scroll surfaces — momentum + no rubber-band bleed */
	body.st-ds .main-col.st-app-main .main-content,
	body.forge-ds .main-content,
	body.dh-ds .main-col.st-app-main .main-content,
	body.mh-ds .main-col.st-app-main .main-content,
	body.tp-ds .tp-main-content,
	body.pt-ds .pt-main,
	body.s-ds .s-main,
	body.reach-ds .reach-main__content,
	body.cs-ds .cs-main {
		-webkit-overflow-scrolling: touch;
		overscroll-behavior-y: contain;
	}

	/* Remove 300ms tap delay; keep pinch-zoom on page */
	button,
	.btn,
	.at-btn,
	.tp-toolbar-btn,
	.pt-toolbar-btn,
	.tp-mobile-link,
	.tp-pill,
	.tp-ecs-style-btn,
	a.nav-mobile-drawer-item,
	.nav-mobile-menu-btn,
	.toolbar-menu-btn,
	.pt-mobile-menu-btn,
	.tp-mobile-menu-btn,
	.s-nav-item,
	.pt-nav-item,
	[role="tab"],
	[role="button"]:not(input) {
		touch-action: manipulation;
	}

	/* iOS: prevent focus zoom on inputs */
	input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="range"]):not([type="file"]),
	select,
	textarea {
		font-size: max(16px, 1rem);
	}

	/* Drawer panels respect safe areas */
	.nav-mobile-drawer-panel,
	body.tp-ds .tp-mobile-panel,
	body.pt-ds .pt-mobile-drawer,
	body.s-ds .s-mobile-drawer {
		padding-top: env(safe-area-inset-top, 0px);
		padding-bottom: env(safe-area-inset-bottom, 0px);
		padding-left: env(safe-area-inset-left, 0px);
	}

	.nav-mobile-drawer-footer,
	body.tp-ds .tp-mobile-footer {
		padding-bottom: max(var(--space-4, 1rem), env(safe-area-inset-bottom));
	}

	.at-drawer__panel {
		padding-top: env(safe-area-inset-top, 0px);
		padding-bottom: env(safe-area-inset-bottom, 0px);
	}

	/* Horizontal scroll rows — native swipe, hidden scrollbar */
	.tp-filter-chips,
	.tp-subtabs,
	.tp-ecs-styles,
	.sdn-sel-nav,
	.sdn-sel-coll-filter,
	.tp-insp-phase-nav,
	.pt-filter-chips,
	.tp-trade-collection-chips,
	.tp-sg-vizfilter,
	.at-chip-row,
	.pt-subtabs,
	body.cs-ds .cs-matrix-scroll {
		scrollbar-width: none;
		-webkit-overflow-scrolling: touch;
	}

	.tp-filter-chips::-webkit-scrollbar,
	.tp-subtabs::-webkit-scrollbar,
	.tp-ecs-styles::-webkit-scrollbar,
	.sdn-sel-nav::-webkit-scrollbar,
	.sdn-sel-coll-filter::-webkit-scrollbar,
	.tp-insp-phase-nav::-webkit-scrollbar,
	.pt-filter-chips::-webkit-scrollbar,
	.pt-subtabs::-webkit-scrollbar,
	body.cs-ds .cs-matrix-scroll::-webkit-scrollbar {
		display: none;
	}

	/* Edge-safe popovers */
	.tp-disp-popover,
	.tp-filter-popover,
	.pt-filter-popover,
	.at-popover {
		max-width: min(320px, calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right) - 1.5rem));
	}

	/* FAB / back-to-top above home indicator */
	.at-scroll-fab,
	.tp-back-top,
	.tp-scroll-top {
		bottom: max(1rem, env(safe-area-inset-bottom));
		right: max(1rem, env(safe-area-inset-right));
	}

	/* Card press feedback */
	.tp-card:active,
	.tp-pl-card:active,
	button.sdn-sel-card:active,
	.at-table--cards-md tbody tr:active,
	.st-table-cards-md tbody tr:active {
		opacity: 0.92;
	}

	/* Modals: safe-area insets on full-screen mobile sheets */
	.at-modal__header,
	.at-modal__footer,
	.at-drawer__header,
	.at-drawer__footer {
		padding-left: max(var(--space-4, 1rem), env(safe-area-inset-left));
		padding-right: max(var(--space-4, 1rem), env(safe-area-inset-right));
	}

	.at-modal__footer,
	.at-drawer__footer {
		padding-bottom: max(var(--space-4, 1rem), env(safe-area-inset-bottom));
	}

	/* Lock page scroll when overlays are open (JS also sets overflow on body) */
	body.tp-modal-open,
	body.sdn-sel-modal-open,
	body.at-modal-open {
		overflow: hidden;
		touch-action: none;
	}

	/* Prevent images/maps from causing horizontal overflow */
	img,
	video,
	canvas,
	svg,
	iframe {
		max-width: 100%;
		height: auto;
	}

	/* Native-style full-width primary actions in toolbars */
	.toolbar .btn-primary,
	.tp-toolbar-right .btn-primary,
	.pt-toolbar-right .btn-primary {
		min-height: var(--touch-min, 44px);
	}

	/*
	 * Table / matrix horizontal scroll — flex-collapse must not apply overflow:visible
	 * to scroll surfaces (breaks swipe on wide tables).
	 */
	.dm-table-wrap,
	.dm-grid-scroll,
	.table-wrap,
	.data-table-wrap,
	.phase-items-table-wrap,
	.at-table-wrap .ap-scroll-body,
	.ap-scroll-body,
	.ap-table-wrap,
	.ap-table-scroll,
	.table-responsive,
	.table-container,
	.st-table-scroll,
	.sticky-table-wrap .table-container,
	.sticky-table-wrap .top-scroll,
	.reach-table-wrap,
	.mh-table-wrap,
	.mh-prose .mh-table-wrap,
	.tpl-table-scroller,
	.cs-matrix-table-wrap,
	.cs-matrix-scroll,
	.match-matrix-section .at-table-wrap,
	body.st-ds .dm-table-wrap,
	body.st-ds .dm-grid-scroll,
	body.st-ds .table-container,
	body.st-ds .st-table-scroll,
	body.forge-ds .table-wrap,
	body.forge-ds .data-table-wrap,
	body.forge-ds .phase-items-table-wrap,
	body.pt-ds .ap-scroll-body,
	body.pt-ds .at-table-wrap .ap-scroll-body,
	body.pt-ds .pt-table-head + div,
	body.pt-ds .ap-table-wrap,
	body.pt-ds .ap-table-scroll,
	body.pt-ds .table-responsive,
	body.pt-ds [data-tab-content] .overflow-x-auto,
	body.reach-ds .reach-table-wrap,
	body.cs-ds .cs-matrix-table-wrap,
	body.cs-ds .cs-matrix-scroll {
		overflow-x: auto !important;
		overflow-y: visible;
		-webkit-overflow-scrolling: touch;
		max-width: 100%;
		min-width: 0;
	}

	body.pt-ds .ap-scroll-body,
	body.pt-ds .at-table-wrap .ap-scroll-body,
	body.pt-ds .pt-table-head + div {
		overflow-y: auto;
		overscroll-behavior: contain;
	}
}
