/*
 * MMG shared layout safety contract.
 * Loaded after brand, article, WordPress, fallback and media-specific extra CSS.
 * Rules constrain overflow without replacing media-specific presentation.
 */
:where(main, #main, .content, .container, article, aside, figure,
	.hero, .coral-cover, .beauty-cover, .work-front, .family-welcome, .premium-cover,
	.work-feature, .article-hero, .hero-figure, .picture, .media, .shot,
	.article-layout, .reading-layout, .culture-article-layout, .culture-main,
	.portal-layout, .book-portal, .grid, .journal-grid, .coral-grid,
	.beauty-shelves, .family-boards, .premium-pair, .work-rows,
	.module-cards, .article-aside, .article-sidebar, .book-directory,
	.article-tags, .mmg-article-related, .mmg-article-editor-picks,
	.mmg-article-latest, .mmg-ad-slot,
	.article-head, .article-heading, .culture-article-head, .story-card,
	.work-row, .book-list, .feature, .story, .reading, .article-body) {
	min-inline-size: 0;
	max-inline-size: 100%;
}

:where(.article-layout, .reading-layout, .culture-article-layout, .culture-main,
	.portal-layout, .book-portal, .grid, .journal-grid, .coral-grid,
	.beauty-shelves, .family-boards, .premium-pair, .work-rows,
	.module-cards, .article-tags) > * {
	min-inline-size: 0;
}

:where(h1, h2, h3, h4, p, a, li, figcaption, .tag, .meta, .small) {
	max-inline-size: 100%;
	overflow-wrap: anywhere;
}

:where(nav, nav ul, .menu, .footer-links) {
	min-inline-size: 0;
	max-inline-size: 100%;
}

:where(img, video, canvas, iframe, embed, object, svg) {
	max-inline-size: 100%;
}

/* Body images keep their source ratio; card crops remain controlled by each brand. */
:where(.reading, .article-body) img,
:where(.reading, .article-body) video {
	block-size: auto;
}

:where(.reading, .article-body) figure,
:where(.reading, .article-body) .wp-block-image {
	max-inline-size: 100%;
}

:where(.reading, .article-body) table {
	max-inline-size: 100%;
}

:where(.reading, .article-body) iframe,
:where(.reading, .article-body) embed,
:where(.reading, .article-body) object {
	inline-size: auto;
}

/* Optional ad-slot contract only. It does not create or deliver advertisements. */
.mmg-ad-slot:empty,
[data-mmg-ad-slot]:empty,
.mmg-ad-slot[data-mmg-ad-enabled="false"],
[data-mmg-ad-slot][data-mmg-ad-enabled="false"] {
	display: none;
}

.mmg-ad-slot,
[data-mmg-ad-slot] {
	min-inline-size: 0;
	max-inline-size: 100%;
}

@media (max-width: 760px) {
	:where(.reading, .article-body) table {
		display: block;
		overflow-x: auto;
		overscroll-behavior-inline: contain;
	}

	:where(.reading, .article-body) pre,
	:where(.reading, .article-body) code {
		max-inline-size: 100%;
		white-space: pre-wrap;
		word-break: break-word;
	}
}
