html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--dark);
}

/* the site's text on its background: --site-text, for a dark site whose --body has to stay dark for
   the tenant app's labels on --surface (SitePalette), else --body as before */
.site-layout {
    background-color: var(--site-background);
    color: var(--site-text, var(--body));
}

/* the next page is on its way (watchNavigationProgress, common.js): a thin bar in the site's primary
   colour along the top of the window, over the header. It waits a moment before showing, so a page
   that comes at once doesn't flash it. On the root element, which enhanced navigation's patching of
   the page leaves be. */
html.site-navigating::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 2147483000;
    pointer-events: none;
    background: linear-gradient(90deg, transparent, var(--primary) 30%, var(--primary) 70%, transparent) 0 0 / 40% 100% no-repeat;
    opacity: 0;
    animation: site-navigating-show 0.2s ease-out 0.15s forwards, site-navigating-slide 1.2s ease-in-out 0.15s infinite;
}

@keyframes site-navigating-show {
    to {
        opacity: 1;
    }
}

@keyframes site-navigating-slide {
    from {
        background-position: -70% 0;
    }

    to {
        background-position: 170% 0;
    }
}

/* without the motion: the whole bar, steady */
@media (prefers-reduced-motion: reduce) {
    html.site-navigating::after {
        background: var(--primary);
        animation: site-navigating-show 0.2s ease-out 0.15s forwards;
    }
}

main {
    display: flex;
    width: 100%;
    flex-direction: column;
    position: relative;
    flex-grow: 1;
}

/* Gallery Styles
   Nothing in the code renders these. Tenants use them in HTML they write themselves, so they stay. */
.masonry {
    column-count: 1;
    column-gap: 1rem;
}
    .masonry:last-child {
        margin-bottom: 1rem;
    }

.masonry-2 {
    column-count: 2;
}

.masonry-3 {
    column-count: 3;
}

.masonry-4 {
    column-count: 4;
}

.masonry-img {
    width: 100%;
    margin-bottom: 1rem;
    border-radius: 8px;
    display: block;
    break-inside: avoid;
}

@media (max-width: 991.98px) {
    .masonry-4,
    .masonry-3 {
        column-count: 2;
    }
}

@media (max-width: 767.98px) {
    .masonry-4,
    .masonry-3,
    .masonry-2 {
        column-count: 1;
    }
}

/* Scroll-in: an element whose visibility class is "revealed" (a migrated site's entrance animation, a fade
   or slide in) keeps its animation waiting at its first frame until it comes into view and common.js adds
   the class. Only while common.js runs (html.reveal-ready), so without it the animations play as their
   CSS says. !important, as a lifted site's own rules can be. */
html.reveal-ready [data-visibility~="revealed"]:not(.revealed) {
    animation-play-state: paused !important;
}

/* FocusOnNavigate (Routes.razor) focuses the page's h1 after each load so a screen reader announces the
   page. Chrome counts a script's focus before any click as :focus-visible, so a site's own focus ring (a
   lifted Mobirise site's red one) drew round the heading. That focus isn't the visitor's, so it isn't
   shown. A page's CSS is scoped under #cms-content-style (ToScopedCss), so the rule is too, to stay more
   specific than "#cms-content-style .x :focus-visible" whatever order the CSS loads in; the plain one is
   for an h1 outside the page, in a header block. Keyboard focus on links and buttons keeps the site's ring. */
h1[tabindex="-1"]:focus,
#cms-content-style h1[tabindex="-1"]:focus {
    outline: none !important;
}

/* a search on its way (common.js): the results page streams in when ready */
form.is-searching, form.is-searching button { cursor: progress; }

/* Page transitions (PageTransitions, chosen on Site Styling): how one page gives way to the next. common.js
   wraps each page change in a view transition when the html element names one (data-page-transition), and
   these draw it: the page as it was (::view-transition-old(root)) and as it is now (-new). data-page-way is
   "back" for the browser's back and forward buttons, for a slide to go the other way. "site" has none here:
   the site's own styles draw it. Each is over in under a second, and none plays for a visitor who asks for
   less motion (common.js starts none then; this is in case one is under way as they ask). */
html[data-page-transition]::view-transition-old(root),
html[data-page-transition]::view-transition-new(root) {
    mix-blend-mode: normal;
}

html[data-page-transition]::view-transition-image-pair(root) {
    isolation: isolate;
}

html[data-page-transition="fade"]::view-transition-old(root) {
    animation: page-fade-out 0.45s ease both;
}

html[data-page-transition="fade"]::view-transition-new(root) {
    animation: page-fade-in 0.45s ease both;
}

html[data-page-transition="slide"]::view-transition-old(root) {
    animation: page-out-left 0.6s cubic-bezier(0.76, 0, 0.24, 1) both;
}

html[data-page-transition="slide"]::view-transition-new(root) {
    animation: page-in-right 0.6s cubic-bezier(0.76, 0, 0.24, 1) both;
}

html[data-page-transition="slide"][data-page-way="back"]::view-transition-old(root) {
    animation-name: page-out-right;
}

html[data-page-transition="slide"][data-page-way="back"]::view-transition-new(root) {
    animation-name: page-in-left;
}

html[data-page-transition="rise"]::view-transition-old(root) {
    animation: page-fade-out 0.5s ease both;
}

html[data-page-transition="rise"]::view-transition-new(root) {
    animation: page-rise-in 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* the next page in five bands across the window, from the left and the right in turn, each a little after
   the one above; the last page stays as it was beneath them */
@property --page-band-0 { syntax: '<percentage>'; inherits: false; initial-value: 0%; }
@property --page-band-1 { syntax: '<percentage>'; inherits: false; initial-value: 0%; }
@property --page-band-2 { syntax: '<percentage>'; inherits: false; initial-value: 0%; }
@property --page-band-3 { syntax: '<percentage>'; inherits: false; initial-value: 0%; }
@property --page-band-4 { syntax: '<percentage>'; inherits: false; initial-value: 0%; }

html[data-page-transition="bands"]::view-transition-old(root),
html[data-page-transition="wipe"]::view-transition-old(root) {
    animation: none;
}

html[data-page-transition="bands"]::view-transition-new(root) {
    mask-image: linear-gradient(#000 0 0), linear-gradient(#000 0 0), linear-gradient(#000 0 0), linear-gradient(#000 0 0), linear-gradient(#000 0 0);
    mask-size: var(--page-band-0) calc(20vh + 1px), var(--page-band-1) calc(20vh + 1px), var(--page-band-2) calc(20vh + 1px),
               var(--page-band-3) calc(20vh + 1px), var(--page-band-4) calc(20vh + 1px);
    mask-position: 0 0, 100% 20vh, 0 40vh, 100% 60vh, 0 80vh;
    mask-repeat: no-repeat;
    animation: page-band-0 0.74s cubic-bezier(0.76, 0, 0.24, 1) 0s both,
               page-band-1 0.74s cubic-bezier(0.76, 0, 0.24, 1) 0.065s both,
               page-band-2 0.74s cubic-bezier(0.76, 0, 0.24, 1) 0.13s both,
               page-band-3 0.74s cubic-bezier(0.76, 0, 0.24, 1) 0.195s both,
               page-band-4 0.74s cubic-bezier(0.76, 0, 0.24, 1) 0.26s both;
}

html[data-page-transition="wipe"]::view-transition-new(root) {
    animation: page-wipe-in 0.7s cubic-bezier(0.76, 0, 0.24, 1) both;
}

@keyframes page-fade-out { to { opacity: 0; } }
@keyframes page-fade-in { from { opacity: 0; } }
@keyframes page-out-left { to { transform: translateX(-100%); } }
@keyframes page-in-right { from { transform: translateX(100%); } }
@keyframes page-out-right { to { transform: translateX(100%); } }
@keyframes page-in-left { from { transform: translateX(-100%); } }
@keyframes page-rise-in { from { transform: translateY(48px); opacity: 0; } }
@keyframes page-band-0 { to { --page-band-0: 100%; } }
@keyframes page-band-1 { to { --page-band-1: 100%; } }
@keyframes page-band-2 { to { --page-band-2: 100%; } }
@keyframes page-band-3 { to { --page-band-3: 100%; } }
@keyframes page-band-4 { to { --page-band-4: 100%; } }
@keyframes page-wipe-in { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0); } }

@media (prefers-reduced-motion: reduce) {
    html[data-page-transition]::view-transition-group(*),
    html[data-page-transition]::view-transition-old(*),
    html[data-page-transition]::view-transition-new(*) {
        animation: none !important;
    }
}
