/* FIN Bilingual – responsive safety layer for the Festivals in Nepal theme.
   Loaded after the theme stylesheet. Rules are deliberately conservative. */

/* 1. Never allow sideways scrolling on phones (clip keeps sticky headers working). */
html, body { max-width: 100%; overflow-x: clip; }
*, *::before, *::after { box-sizing: border-box; }

/* 2. Media always fits its container. */
img, video, svg, canvas, picture { max-width: 100%; height: auto; }
iframe, embed, object { max-width: 100%; }
.wp-caption, figure { max-width: 100% !important; }

/* 3. Long words, URLs and Devanagari compounds wrap instead of overflowing. */
main, article, .site-main, .entry-content, .article-description, footer {
	overflow-wrap: anywhere;
	word-break: normal;
}
pre, code { white-space: pre-wrap; word-break: break-word; }

/* 4. Tables scroll horizontally inside content instead of stretching the page. */
.entry-content table, article table, main table {
	display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
}

/* 5. Tablets */
@media (max-width: 1024px) {
	main, .site-main, .container, [class*="container"]:not([class*="fin-"]) { padding-left: 16px; padding-right: 16px; }
	main [class*="grid"], .site-main [class*="grid"] {
		grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)) !important;
	}
}

/* 6. Phones */
@media (max-width: 680px) {
	body { font-size: 16px; line-height: 1.6; }
	main h1, .site-main h1, article h1 { font-size: clamp(1.6rem, 7vw, 2.4rem); line-height: 1.2; }
	main h2, .site-main h2, article h2 { font-size: clamp(1.3rem, 5.5vw, 1.9rem); line-height: 1.25; }
	main h3, .site-main h3, article h3 { font-size: clamp(1.1rem, 4.8vw, 1.5rem); }

	/* Card grids and side-by-side layouts stack into one column. */
	main [class*="grid"], .site-main [class*="grid"], article [class*="grid"],
	main [class*="cards"], main [class*="columns"] {
		grid-template-columns: 1fr !important;
	}
	main [class*="row"], .site-main [class*="row"] { flex-wrap: wrap; }
	main [class*="col-"], .site-main [class*="col-"] { flex: 1 1 100% !important; max-width: 100% !important; }
	aside, .sidebar, [class*="sidebar"] { width: 100% !important; max-width: 100% !important; float: none !important; }

	/* Countdown, month tabs and button rows wrap neatly. */
	[class*="countdown"]:not([class*="fin-"]), [class*="months"]:not([class*="fin-"]), [class*="tabs"]:not([class*="fin-"]), [class*="filters"]:not([class*="fin-"]), [class*="share"]:not([class*="fin-"]) {
		flex-wrap: wrap !important; gap: 8px;
	}
	[class*="months"]:not([class*="fin-"]) a, [class*="tabs"]:not([class*="fin-"]) a, [class*="tabs"]:not([class*="fin-"]) button { flex: 1 1 calc(33% - 8px); text-align: center; }

	/* Comfortable touch targets. */
	button:not(.fin-hero__tab), .button, input[type="submit"], .fin-pagination a, .fin-pagination span { min-height: 44px; }
	input, select, textarea { font-size: 16px; max-width: 100%; } /* prevents iOS zoom */

	/* Hero sections should not be taller than the screen. */
	[class*="hero"]:not([class*="fin-"]) { min-height: 0 !important; padding-top: 32px !important; padding-bottom: 32px !important; }

	/* Plugin components */
	.fin-toc { padding: 10px 14px; }
	.fin-pagination a, .fin-pagination span { min-width: 40px; padding: 10px; }
	.fin-pagination .prev, .fin-pagination .next { flex-basis: 100%; }
	.wp-caption.aligncenter, figure.aligncenter { margin-left: 0; margin-right: 0; }
	.alignleft, .alignright { float: none !important; display: block; margin: 0 auto 16px !important; }
}

/* 7. Very small phones */
@media (max-width: 360px) {
	main, .site-main, .container, [class*="container"]:not([class*="fin-"]) { padding-left: 12px; padding-right: 12px; }
	[class*="months"]:not([class*="fin-"]) a, [class*="tabs"]:not([class*="fin-"]) a { flex-basis: calc(50% - 8px); }
}
