/*
 * MA-ZAL Group — base: page ground, type, links, containers, section rhythm. Loaded on every page by the theme.
 * Values come from tokens.css only. Components live in components.css; bars and menus in shell.css.
 * Element rules use :where(.mzs) (no added weight): any component class wins over them without extra selectors.
 */
html:has(body.mzs) {
	min-height: 100%;
	background: var(--c-paper);
}

body.mzs {
	margin: 0;
	/* REQ-20261102-28 (owner photos 2/11): in the installed iPhone app the fixed bottom bar sits at the true bottom only
	   on pages that scroll; a short page that does not scroll keeps it higher with an empty strip under it. So every
	   page is at least one pixel taller than the screen (largest screen height where known) and always scrolls. */
	min-height: calc(100vh + 1px);
	min-height: calc(100lvh + 1px);
	background: var(--c-paper);
	color: var(--c-ink);
	font-family: var(--f-text);
	font-size: var(--fs-body);
	line-height: var(--lh-text);
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
	-webkit-tap-highlight-color: transparent;
}

/* owner 3/11 (T172): the theme paints every table with its dark surface; demo tables take the demo's own colours */
body.mzs table,
body.mzs th,
body.mzs td {
	background: transparent;
	color: inherit;
}

body.mzs th {
	letter-spacing: normal;
	text-transform: none;
}

:where(.mzs) h1,
:where(.mzs) h2,
:where(.mzs) h3,
:where(.mzs) h4 {
	margin: 0;
	font-family: var(--f-text);
	font-weight: var(--fw-bold);
	line-height: var(--lh-tight);
	color: inherit;
	text-wrap: balance;
}

:where(.mzs) h1 { font-size: var(--fs-h1); }
:where(.mzs) h2 { font-size: var(--fs-h2); }
:where(.mzs) h3 { font-size: var(--fs-h3); }

:where(.mzs) p {
	margin: 0;
}

:where(.mzs) a {
	color: var(--c-gold-text);
	text-decoration: none;
	transition: color var(--t-fast);
}

:where(.mzs) a:hover {
	color: var(--c-ink);
}

:where(.mzs) :focus-visible {
	outline: 2px solid var(--c-gold);
	outline-offset: 3px;
	border-radius: var(--r-sm);
}

:where(.mzs) img {
	max-width: 100%;
	height: auto;
	display: block;
}

.mzs-main {
	display: block;
}

/* line icons are drawn with strokes: the theme's svg fill must not paint them */
:where(.mzs) svg[fill="none"] {
	fill: none;
}

/* icons that point (arrows) follow the reading direction */
.mzs-arrow {
	transform: scaleX(var(--dir-x));
}

/* width of the page content */
.mzs-container {
	width: 100%;
	max-width: var(--container);
	margin-inline: auto;
	padding-inline: var(--gutter);
	box-sizing: border-box;
}

/* one home section */
.mzs-section {
	padding-block: var(--section-y);
	scroll-margin-top: calc(var(--bar-h) + var(--safe-top));
}

.mzs-section--night {
	background: var(--c-night);
	color: var(--c-on-night);
}

/* inner pages: space under the header and above the dock */
.mzs-inner {
	padding-block: var(--s-6) var(--s-8);
}

/* T1234: a page with «layout: full» in its header runs edge to edge; its sections hold their own width */
.mzs-inner--full { padding-block: 0; }
.mzs-container--full { max-width: none; padding-inline: 0; }

.mzs-muted {
	color: var(--c-ink-2);
}

.mzs-num {
	font-variant-numeric: tabular-nums;
}

.mzs-ltr {
	direction: ltr;
	unicode-bidi: isolate;
}

.mzs-sr {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

@media (prefers-reduced-motion: reduce) {
	.mzs *,
	.mzs *::before,
	.mzs *::after {
		animation-duration: 0.01ms;
		transition-duration: 0.01ms;
		scroll-behavior: auto;
	}
}

/* T1428 (owner 22/11, standing rule): phone tables = cards (one card per row, the column name beside each value; the
   names come from the table head, added by demo.js); floating windows never wider than the screen. A table that must
   stay a table carries data-mzs-keep-table. */
@media (max-width: 700px) {
	table.mzs-cards.mzs-cards, table.mzs-cards.mzs-cards tbody { display: block; width: 100%; min-width: 0; border: 0; background: none; }
	table.mzs-cards.mzs-cards thead { display: none; }
	table.mzs-cards.mzs-cards tr { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; margin: 0 0 10px; padding: 12px 14px; border: 1px solid var(--mzs-line, rgba(0, 0, 0, .08)); border-radius: 16px; background: var(--mzs-card, #fff); }
	table.mzs-cards.mzs-cards td { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; min-width: 0; padding: 5px 0; border: 0; text-align: end; white-space: normal; overflow-wrap: anywhere; }
	table.mzs-cards.mzs-cards td::before { content: attr(data-label); flex: 0 0 auto; max-width: 48%; text-align: start; font-size: .8rem; font-weight: 600; color: var(--mzs-muted, #6b7280); }
	table.mzs-cards.mzs-cards td[data-label=""] { display: block; text-align: start; }
	table.mzs-cards.mzs-cards td[data-label=""]::before { content: none; }
	table.mzs-cards.mzs-cards td:empty { display: none; }
	table.mzs-cards.mzs-cards tr.mzs-cards__sec { padding: 10px 14px; }
	table.mzs-cards.mzs-cards tr.mzs-cards__sec td { font-weight: 700; }
	[role="dialog"], dialog, .modal, .mzs-modal, .mzs-sheet__panel { max-width: 100vw; overflow-x: hidden; }
}

/* T1435 (owner 22/11, standing rule): not zoomable on a phone — no double-tap zoom, and fields at 16px so the phone does
   not zoom when one gets the focus. */
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (max-width: 760px) {
	input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea { font-size: max(16px, 1em); }
}

/* T1437: the thin bar at the top while the next page comes */
html.mzs-going::before { content: ""; position: fixed; inset-inline: 0; top: 0; z-index: 2147483000; height: 3px; background: var(--mzs-accent, var(--c-gold, #b8963e)); transform-origin: 0 50%; animation: mzs-going 1.6s ease-out forwards; pointer-events: none; }
html[dir="rtl"].mzs-going::before { transform-origin: 100% 50%; }
@keyframes mzs-going { from { transform: scaleX(0); } 60% { transform: scaleX(.75); } to { transform: scaleX(.92); } }
@media (prefers-reduced-motion: reduce) { html.mzs-going::before { animation: none; transform: scaleX(.6); } }
