dvSsrFirstHead function
The style and script an SSR-first shell carries in its head.
With accessibilityControls (dartvel.accessibility.defaultControls) it also
reads the visitor's accessibility settings before the first paint.
background and darkBackground are the app's page colours (the
splash's, which come from dartvel.splash or dartvel.pwa); accent is
the link colour when it reads on them, the loading bar's by default.
Implementation
String dvSsrFirstHead({
required String background,
required String darkBackground,
required String accent,
bool accessibilityControls = false,
}) {
const String on = 'html:not([data-dv-app]) .dv-fallback';
final String css = '@media screen{'
// Its own scroller above where Flutter paints, below the loading bar.
// The engine fixes the body and turns off selection and touch scrolling
// on it; none of that reaches a fixed scroll container that sets its own.
'$on{position:fixed;top:0;right:0;bottom:0;left:0;z-index:2147483645;'
'width:auto;height:auto;max-width:none;margin:0;box-sizing:border-box;'
'padding:2.5rem max(1.25rem,calc((100% - 44rem)/2)) 3rem;'
'overflow:auto;overscroll-behavior:contain;clip-path:none;'
'pointer-events:auto;touch-action:auto;'
'user-select:text;-webkit-user-select:text}'
// Every section on screen, though each keeps hidden="until-found" for
// after the handover.
'$on [data-dv-anchor]{display:block;content-visibility:visible}'
// A run of plain links (a navigation bar, a pair of buttons) reads as
// a row rather than a column of one-word lines.
'$on [data-dv-anchor]:has(>a:only-child){display:inline-block;'
'margin:0 1.25rem .75rem 0}'
'$on a{text-underline-offset:.15em}'
// A button pressed before the app is there says it is on its way.
'$on [aria-busy=true]{cursor:progress;opacity:.6}'
'${_colours(background, accent)}'
// Behind a document the splash would only be covered; hidden, it is not
// painted at all. A page with no document keeps it.
'.dv-fallback~#dartvel-splash{display:none}'
'}'
'@media screen and (prefers-color-scheme:dark){'
'${_colours(darkBackground, accent)}}'
'@media screen and (prefers-reduced-motion:no-preference){'
'html[data-dv-handover] .dv-fallback{transition:opacity .2s ease-out}}'
// Still taking presses while it fades: it lies exactly over the app,
// and a press there is a link's, a queued button's or one made again
// on the app (see the handover script).
'html[data-dv-handover] .dv-fallback{opacity:0}';
return '<script>$_firstScreenScript</script>\n'
'${accessibilityControls ? '<script>$_accessibilityScript</script>\n' : ''}'
'<style $dvSsrFirstMarker>$css${accessibilityControls ? _accessibilityStyle : ''}</style>\n'
'<script>$_handoverScript</script>\n';
}