/* ==========================================================================
   OwnServe — Mobile viewport hardening
   Loaded LAST so it authoritatively wins the cascade.

   Goal: the whole site uses the FULL device viewport. Only the product
   phone/dashboard mockups keep a limited width — never the page itself.
   Verified targets: 320, 375, 390, 412 (esp. 412x924).
   ========================================================================== */

/* --------------------------------------------------------------------------
   1 & 2 & 7: Page-level width is always 100% of the viewport. No fixed or
   min widths anywhere on the document root chain. Never exceed 100vw.
   -------------------------------------------------------------------------- */
html,
body {
	width: 100%;
	max-width: 100%;
	min-width: 0;
	margin: 0;
	padding: 0;
	overflow-x: hidden;
	overscroll-behavior-x: none;
}

/* Belt-and-braces: guarantee no descendant forces the doc past the viewport. */
*,
*::before,
*::after {
	max-width: 100%;
	min-width: 0;
}

/* Media should always scale down, never overflow. (8: oversized images) */
img,
svg,
video,
canvas,
iframe {
	max-width: 100%;
	height: auto;
}

/* --------------------------------------------------------------------------
   Mobile rules (<= 768px). These cover 412x924 and every smaller phone.
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {

	/* 4: main structural elements are full width. */
	main,
	.os-header,
	.os-hero,
	.os-section,
	.os-footer,
	.os-ctaband,
	.os-vision,
	.os-calc {
		width: 100%;
		max-width: 100%;
	}

	/* 5: containers may keep max-width, but on mobile they become
	   width: calc(100% - 32px) — i.e. 16px gutter each side, centered. */
	.os-container,
	.os-container--wide,
	.os-container--narrow {
		width: calc(100% - 32px);
		max-width: calc(100% - 32px);
		margin-inline: auto;
		padding-inline: 0; /* the calc() already provides the 16px gutters */
	}

	/* 10 & 11: hero occupies full width and collapses to one column. */
	.os-hero__grid {
		grid-template-columns: 1fr;
		width: 100%;
	}

	.os-hero__content,
	.os-hero__media {
		width: 100%;
		min-width: 0;
	}

	/* Any 2-up split becomes a single column and full width. */
	.os-split {
		grid-template-columns: 1fr;
		width: 100%;
	}

	/* 12: ONLY the phone/dashboard mockups keep a limited width, centered.
	   The page itself is never constrained by them. */
	.os-hero__media,
	.os-split__media {
		display: flex;
		justify-content: center;
	}

	.os-phone {
		width: min(320px, 100%);
		margin-inline: auto;
	}

	.os-device {
		width: 100%;
		max-width: 520px;
		margin-inline: auto;
	}

	/* Horizontal step flows must wrap and never push width out. */
	.os-flow {
		flex-wrap: wrap;
		width: 100%;
	}

	.os-flow__node {
		min-width: 0;
	}

	/* Prevent long words / flow labels from forcing overflow. */
	.os-flow__label,
	.os-menuitem__desc,
	.os-nav__link,
	.os-heading__title,
	.os-heading__lead {
		overflow-wrap: anywhere;
		word-break: break-word;
	}

	/* ----------------------------------------------------------------------
	   Vertical flow / positioning fixes for the customer ordering UI.
	   Requirements 1-6: normal document flow, natural header height, the
	   restaurant card immediately follows the header, no large gap, no
	   fixed heights that clip, no overlap. Nothing here changes desktop.
	   -------------------------------------------------------------------- */

	/* 9: predictable box model on every element in the hero/mockup chain. */
	.os-hero,
	.os-hero *,
	.os-phone,
	.os-phone * {
		box-sizing: border-box;
	}

	/* 4 & 6: give the hero a natural top offset (just clears the sticky
	   header) instead of the large desktop top padding — removes the big gap. */
	.os-hero {
		padding-top: var(--os-space-5);
		padding-bottom: var(--os-space-7);
	}

	/* 5 & 6: the phone/restaurant card is shown first on mobile and should
	   follow the header immediately with only a small, intentional gap. */
	.os-hero__media {
		order: -1;
		margin-top: 0;
		margin-bottom: var(--os-space-6);
	}

	/* 1 & 3: the mockup uses natural document flow — no fixed/clamped height
	   that would clip the menu, cart, payment and confirmation below it. */
	.os-phone,
	.os-phone__screen {
		height: auto;
		max-height: none;
		overflow: visible;
	}

	/* Keep the rounded screen mask without clipping content height. */
	.os-phone {
		overflow: hidden; /* clip only the rounded corners of the frame */
	}

	/* 3: the app body must not be constrained; it grows with its content. */
	.os-app__body {
		height: auto;
		max-height: none;
	}

	/* 10: media and cards inside the mockup scale responsively. */
	.os-menuitem__thumb,
	.os-app__logo,
	.os-confirm__check {
		flex: none;
	}
}

/* --------------------------------------------------------------------------
   13 & 14 & 15: one-column cards + footer at phone widths.
   Applied at <= 640px to be safe well before 412px.
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {

	.os-grid,
	.os-grid--2,
	.os-grid--3,
	.os-grid--4,
	.os-grid--auto,
	.os-pricing-grid,
	.os-fulfil-grid,
	.os-restaurant-types,
	.os-compare {
		grid-template-columns: 1fr; /* 13, 14 */
		width: 100%;
	}

	.os-footer__grid {
		grid-template-columns: 1fr; /* 15 */
		width: 100%;
	}

	.os-footer__brand {
		grid-column: auto;
	}

	/* Calculator stacks fully. */
	.os-calc {
		grid-template-columns: 1fr;
	}

	/* Cards should never carry an intrinsic min-width that overflows. */
	.os-fcard,
	.os-pcard,
	.os-typecard,
	.os-fulcard,
	.os-tcard,
	.os-compare__card {
		width: 100%;
		min-width: 0;
	}
}

/* --------------------------------------------------------------------------
   9: navbar is a hamburger menu on mobile. (Reinforces responsive.css.)
   The dropdown panel spans the full viewport width, anchored below the navbar.
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
	.os-navtoggle {
		display: flex;
	}

	/* Full-width dropdown — never a constrained side panel. */
	.os-nav {
		width: 100%;
		max-width: 100%;
		left: 0;
		right: 0;
	}
}

/* --------------------------------------------------------------------------
   Very small phones (<= 360px): tighten the gutter so 320px has breathing room
   but the page still fills the viewport.
   -------------------------------------------------------------------------- */
@media (max-width: 360px) {
	.os-container,
	.os-container--wide,
	.os-container--narrow {
		width: calc(100% - 24px);
		max-width: calc(100% - 24px);
	}

	.os-phone {
		width: min(300px, 100%);
	}
}
