/*!
 * Signage — shell stylesheet.
 *
 * Two jobs, both about coexistence rather than appearance:
 *
 *   1. Neutralise the active WordPress theme inside the plugin container, so
 *      the application looks the same on every theme.
 *   2. Give the container the full-page surface the original application had,
 *      without restyling anything else on the site.
 *
 * Loaded *before* signage-app.css so that, where specificities tie, the
 * application's own rules win.
 *
 * Note on specificity: the reset below matches #signage-app itself at (1,0,0),
 * so every other rule in this file is also written through the #signage-app ID.
 * A plain `.signage-container {...}` rule would be reverted by its own reset.
 */

/* ------------------------------------------------------------------ *
 * 1. Theme isolation — the container is a style boundary.
 *
 * The root uses `all: initial`, not `all: revert`. That distinction matters:
 * `revert` rolls a property back to the browser's default, but for an
 * *inherited* property the browser has no default, so the value keeps
 * arriving from the theme's <body> — text-transform, font-style,
 * letter-spacing, line-height, white-space and color would all still leak in.
 * `initial` cuts the inheritance chain at the container instead.
 *
 * Inside the container, `revert` is right: it discards the theme's rules while
 * restoring normal browser behaviour for headings, lists, form controls and so
 * on, and lets the application's typography inherit from the container. The
 * net effect reproduces "a blank page with only the app's stylesheet", which
 * is the environment the original index.html ran in.
 *
 * Custom properties are not affected by `all`, so the --u / --t / theme
 * variables the display engine relies on survive untouched.
 *
 * Specificity here is (1,0,0); every rule in signage-app.css is at least
 * (1,1,0), so the application always overrides this reset.
 * ------------------------------------------------------------------ */
#signage-app {
	all: initial;
}

/*
 * SVG subtrees are deliberately excluded. In SVG 2 — and in Chrome today —
 * the geometry presentation attributes are real CSS properties: `d` on a
 * path, `x`/`y`/`width`/`height` on a rect, `cx`/`cy`/`r` on a circle. None of
 * them is inherited and the browser declares no default, so `all: revert`
 * resolves them to `initial`, which for `d` is `none`. The result is that
 * every icon in the application silently disappears while still reporting the
 * right size, colour and attributes. The few properties a theme realistically
 * sets on `svg` are neutralised explicitly below instead.
 */
/*
 * The exclusions are wrapped in :where() so they add no specificity. Written
 * as a plain `*:not(svg):not(svg *)` this rule would score (1,0,2), because
 * each :not() contributes the type selector inside it — enough to beat the
 * application's own `#signage-app *` box-sizing rule (1,0,0) and its bare
 * element rules such as `#signage-app select` (1,0,1). The visible result was
 * every control falling back to content-box, so inputs overflowed their grid
 * cells and overlapped, and selects lost their styling entirely.
 *
 * With :where() the reset scores (1,0,0), below everything in signage-app.css.
 */
#signage-app *:where(:not(svg)):where(:not(svg *)),
#signage-app *:where(:not(svg)):where(:not(svg *))::before,
#signage-app *:where(:not(svg)):where(:not(svg *))::after {
	all: revert;
}

#signage-app svg {
	max-width: none;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	box-shadow: none;
	filter: none;
	transform: none;
	vertical-align: baseline;
	overflow: visible;
}

#signage-app svg * {
	filter: none;
	mask: none;
	clip-path: none;
	opacity: 1;
}

/* `all` deliberately excludes these two, so set them explicitly. */
#signage-app.signage-container {
	direction: ltr;
	unicode-bidi: isolate;
}

/* Themes often bolt decorative pseudo-elements onto links and headings. */
#signage-app a::before,
#signage-app a::after,
#signage-app button::before,
#signage-app button::after,
#signage-app h1::before,
#signage-app h2::before,
#signage-app h3::before,
#signage-app h4::before {
	content: none;
}

/* ------------------------------------------------------------------ *
 * 2. The container itself
 * ------------------------------------------------------------------ */

#signage-app.signage-container {
	/* Re-establish what `all: initial` above cleared. */
	display: block;
	box-sizing: border-box;
	position: relative;
	/*
	 * No transform, filter, perspective, will-change or contain here: any of
	 * those would turn this element into a containing block for
	 * `position: fixed` descendants, and the display player, the modal layer
	 * and the toast all rely on being fixed to the viewport.
	 */
	width: auto;
	max-width: 100%;
	font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
	font-size: 16px;
	font-style: normal;
	font-weight: 400;
	line-height: normal;
	letter-spacing: normal;
	word-spacing: normal;
	text-align: left;
	text-transform: none;
	text-indent: 0;
	text-shadow: none;
	white-space: normal;
	list-style: none;
	cursor: auto;
	visibility: visible;
	color: #2b1a1a;
	-webkit-font-smoothing: antialiased;
}

/* Inline mode (fullpage="0"): sit inside the theme's content flow. */
#signage-app.signage-container:not(.signage-fullpage) {
	height: auto;
	min-height: 60vh;
}

/* An embedded TV display still needs a 16:9 stage to live in. */
#signage-app.signage-container:not(.signage-fullpage).signage-tv {
	min-height: 0;
	aspect-ratio: 16 / 9;
}

/*
 * Full-page mode — the default, and how all three interfaces worked before.
 * The container owns the viewport, so the theme's header, footer and sidebars
 * are not in the way. Nothing outside the container is restyled.
 */
#signage-app.signage-container.signage-fullpage {
	position: fixed;
	inset: 0;
	z-index: 999990;
	overflow-x: hidden;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
	background: #f6efe2;
}

#signage-app.signage-container.signage-fullpage.signage-tv {
	overflow: hidden;
	background: #170c0d;
}

/* Keep the WordPress toolbar reachable on the admin and staff pages. */
body.admin-bar #signage-app.signage-container.signage-fullpage:not(.signage-tv) {
	top: 32px;
}

@media screen and (max-width: 782px) {
	body.admin-bar #signage-app.signage-container.signage-fullpage:not(.signage-tv) {
		top: 46px;
	}
}

/*
 * The one place the plugin touches the page outside its own container: when a
 * full-page interface is showing there is nothing behind it to scroll, and
 * letting the document scroll underneath causes rubber-banding on phones.
 * The class is only ever added on a page that renders a signage shortcode.
 */
html.signage-locked,
html.signage-locked body {
	overflow: hidden;
	overscroll-behavior: none;
}

/* ------------------------------------------------------------------ *
 * 3. States PHP renders before (or instead of) the application
 *    Doubled class names keep these legible on themes with opinionated
 *    content styles, without needing !important.
 * ------------------------------------------------------------------ */

#signage-app .signage-boot,
.signage-boot.signage-boot {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 40vh;
	margin: 0;
	padding: 32px 20px;
	font: 600 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
	color: #7a6656;
	text-align: center;
}

.signage-notice.signage-notice {
	box-sizing: border-box;
	max-width: 640px;
	margin: 24px auto;
	padding: 16px 20px;
	border: 1px solid #ecc3c3;
	border-radius: 12px;
	background: #fbeeee;
	font: 400 15px/1.6 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
	color: #6e2425;
	text-align: left;
}

.signage-notice.signage-notice strong {
	font-weight: 700;
}

.signage-notice.signage-notice code {
	padding: 2px 6px;
	border-radius: 5px;
	background: rgba(110, 36, 37, 0.1);
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: 0.92em;
}

/* ------------------------------------------------------------------ *
 * 4. Print: an in-store display has nothing useful to print.
 * ------------------------------------------------------------------ */

@media print {
	#signage-app.signage-container {
		display: none;
	}
}
