/* Estate Motion: base styles for estate-motion.js.
   Themes tune it with --em-ease, --em-duration, --em-distance and --em-curtain-bg on :root (the defaults below sit on
   html, so a theme's :root value always wins). The page never waits for motion: a reveal lasts at most 0.5 s, the
   curtain fades out within 0.22 s of the first paint, and content held back for the engine shows anyway after 0.45 s
   (a CSS safety net) when the script is late or missing. Reduced motion and print show everything at once, and the
   normal mouse pointer always shows. */
html {
    --em-ease: cubic-bezier(.16, 1, .3, 1);
    --em-duration: 1.1s;
    --em-distance: 48px;
    --em-curtain-bg: #0b0b0c;
}

/* ---------- reveal ---------- */
/* --em-dur / --em-delay: the engine sets them per element (first screen 0.22 s, later at most 0.5 s). */
:where([data-em-reveal]) { --em-dur: min(var(--em-duration, .5s), .5s); --em-delay: 0ms; }
html.em-js:not(.em-reduce) [data-em-reveal] {
    transition-property: opacity, transform, clip-path, filter;
    transition-duration: var(--em-dur, .5s);
    transition-timing-function: var(--em-ease);
    transition-delay: var(--em-delay, 0ms);
}
/* Hidden until revealed; never the site header or navigation. */
@media (prefers-reduced-motion: no-preference) {
    html.em-js:not(.em-reduce) [data-em-reveal="up"]:not(.em-in):where(:not([data-em-header] *, nav *, body > header *)) { opacity: 0; transform: translate3d(0, var(--em-distance), 0); }
    html.em-js:not(.em-reduce) [data-em-reveal="down"]:not(.em-in):where(:not([data-em-header] *, nav *, body > header *)) { opacity: 0; transform: translate3d(0, calc(var(--em-distance) * -1), 0); }
    html.em-js:not(.em-reduce) [data-em-reveal="left"]:not(.em-in):where(:not([data-em-header] *, nav *, body > header *)) { opacity: 0; transform: translate3d(var(--em-distance), 0, 0); }
    html.em-js:not(.em-reduce) [data-em-reveal="right"]:not(.em-in):where(:not([data-em-header] *, nav *, body > header *)) { opacity: 0; transform: translate3d(calc(var(--em-distance) * -1), 0, 0); }
    html.em-js:not(.em-reduce) [data-em-reveal="fade"]:not(.em-in):where(:not([data-em-header] *, nav *, body > header *)) { opacity: 0; }
    html.em-js:not(.em-reduce) [data-em-reveal="scale"]:not(.em-in):where(:not([data-em-header] *, nav *, body > header *)) { opacity: 0; transform: scale(.92); }
    html.em-js:not(.em-reduce) [data-em-reveal="blur"]:not(.em-in):where(:not([data-em-header] *, nav *, body > header *)) { opacity: 0; filter: blur(14px); transform: scale(1.04); }
    html.em-js:not(.em-reduce) [data-em-reveal="clip-up"]:not(.em-in):where(:not([data-em-header] *, nav *, body > header *)) { clip-path: inset(100% 0 0 0); }
    html.em-js:not(.em-reduce) [data-em-reveal="clip-left"]:not(.em-in):where(:not([data-em-header] *, nav *, body > header *)) { clip-path: inset(0 100% 0 0); }
    html.em-js:not(.em-reduce) [data-em-reveal="mask"]:not(.em-in):where(:not([data-em-header] *, nav *, body > header *)) { clip-path: inset(0 0 100% 0); }
}
[data-em-reveal="clip-up"], [data-em-reveal="clip-left"] { clip-path: inset(0 0 0 0); }

/* mask: the frame wipes open while the image inside settles from a slight zoom */
[data-em-reveal="mask"] { overflow: hidden; clip-path: inset(0 0 0 0); }
html.em-js:not(.em-reduce) [data-em-reveal="mask"] > img,
html.em-js:not(.em-reduce) [data-em-reveal="mask"] > video,
html.em-js:not(.em-reduce) [data-em-reveal="mask"] > picture > img {
    transition: transform var(--em-dur, .5s) var(--em-ease);
    transition-delay: var(--em-delay, 0ms);
}
@media (prefers-reduced-motion: no-preference) {
    html.em-js:not(.em-reduce) [data-em-reveal="mask"]:not(.em-in) > img,
    html.em-js:not(.em-reduce) [data-em-reveal="mask"]:not(.em-in) > video,
    html.em-js:not(.em-reduce) [data-em-reveal="mask"]:not(.em-in) > picture > img { transform: scale(1.25); }
}

/* ---------- split text ---------- */
/* Before the engine splits a headline it waits unseen (at most 0.45 s); then its words rise, readable within ~0.7 s. */
@media (prefers-reduced-motion: no-preference) {
    html.em-js:not(.em-ready) [data-em-split]:where(:not([data-em-header] *, nav *, body > header *)) { opacity: 0; }
}
:where(.em-split) { --em-sdur: min(var(--em-duration, .5s), .5s); }
.em-split .em-w { display: inline-block; white-space: nowrap; }
.em-split .em-c { display: inline-block; }
html.em-js:not(.em-reduce) .em-split .em-w,
html.em-js:not(.em-reduce) .em-split .em-c { overflow: hidden; vertical-align: top; padding-bottom: .08em; margin-bottom: -.08em; }
html.em-js:not(.em-reduce) .em-split .em-i {
    display: inline-block;
    transition: transform var(--em-sdur, .5s) var(--em-ease), opacity calc(var(--em-sdur, .5s) * .6) var(--em-ease);
}
@media (prefers-reduced-motion: no-preference) {
    html.em-js:not(.em-reduce) .em-split:not(.em-in) .em-i { transform: translate3d(0, 110%, 0); opacity: 0; }
    html.em-js:not(.em-reduce) .em-split[data-em-split-style="rotate"]:not(.em-in) .em-i { transform: translate3d(0, 110%, 0) rotate(8deg); }
}
/* Split letters outside a heading, link or button: an empty span speaks the text (generated content: never in innerText). */
.em-sr { position: absolute !important; width: 1px !important; height: 1px !important; margin: -1px !important; padding: 0 !important; border: 0 !important; overflow: hidden !important; clip: rect(0 0 0 0) !important; clip-path: inset(50%) !important; white-space: nowrap !important; -webkit-user-select: none; user-select: none; }
.em-sr::before { content: attr(data-em-text); }

/* ---------- SVG line drawing ---------- */
@media (prefers-reduced-motion: no-preference) {
    html.em-js:not(.em-reduce) [data-em-draw] :is(path, line, polyline, polygon, circle, rect, ellipse) {
        stroke-dasharray: var(--em-len, 1000);
        stroke-dashoffset: var(--em-len, 1000);
        transition: stroke-dashoffset min(calc(var(--em-duration, .5s) * 2.2), 1.2s) var(--em-ease);
        transition-delay: var(--em-delay, 0ms);
    }
    html.em-js:not(.em-reduce) [data-em-draw].em-drawn :is(path, line, polyline, polygon, circle, rect, ellipse) { stroke-dashoffset: 0; }
}
:where([data-em-draw]) { --em-delay: 0ms; }

/* ---------- shown at once (no transition): set briefly by the engine ---------- */
.em-now, .em-now .em-i, .em-now > img, .em-now > video, .em-now > picture > img,
.em-now :is(path, line, polyline, polygon, circle, rect, ellipse) { transition: none !important; }

/* ---------- safety net: if the engine has not started 0.45 s after content appears, show it anyway ---------- */
@media (prefers-reduced-motion: no-preference) {
    :where(html.em-js:not(.em-ready)) :where([data-em-reveal]:not(.em-in), [data-em-split]) { animation: em-failsafe .25s ease .45s forwards; }
    :where(html.em-js:not(.em-ready)) :where([data-em-draw]) :where(path, line, polyline, polygon, circle, rect, ellipse) { animation: em-failsafe-draw .25s ease .45s forwards; }
}
@keyframes em-failsafe { to { opacity: 1; transform: none; clip-path: none; filter: none; } }
@keyframes em-failsafe-draw { to { stroke-dashoffset: 0; } }

/* ---------- marquee ---------- */
.em-marquee { display: flex; overflow: hidden; width: 100%; }
.em-marquee-track { display: flex; flex: none; min-width: 100%; justify-content: space-around; animation: em-marquee var(--em-marquee, 40s) linear infinite; }
.em-marquee-reverse .em-marquee-track { animation-direction: reverse; }
.em-marquee:hover .em-marquee-track { animation-play-state: paused; }
@keyframes em-marquee { to { transform: translate3d(-100%, 0, 0); } }

/* ---------- pinned horizontal scroll ---------- */
.em-hscroll-on { position: relative; }
.em-hscroll-on .em-sticky { position: sticky; top: 0; height: 100vh; overflow: hidden; display: flex; align-items: center; }
.em-hscroll-on [data-em-track] { will-change: transform; }
.em-hscroll-off [data-em-track] { overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }

/* ---------- header and progress (the header is never hidden: it only gets .em-scrolled) ---------- */
[data-em-header] { transition: transform .45s var(--em-ease), background-color .3s ease, box-shadow .3s ease, padding .3s ease; }
[data-em-progress] { transform-origin: 0 50%; transform: scaleX(0); }

/* ---------- video: the poster shows at once; the film takes over when it plays ---------- */
video[data-em-video] { object-fit: cover; }

/* ---------- whole photos on a blurred fill (img[data-em-fit]) ---------- */
.em-fit-host { overflow: hidden; isolation: isolate; background-color: #0b0b0c; }
.em-fit-host::before { content: ''; position: absolute; inset: -32px; z-index: -1; background: var(--em-fit-src) center / cover no-repeat; filter: blur(24px) saturate(1.1) brightness(.72); transform: scale(1.1); }
img[data-em-fit] { object-fit: contain !important; }

/* ---------- curtain: fades out within 0.22 s of the first paint, in CSS alone (it never holds the page) ---------- */
:where([data-em-curtain]) { background: var(--em-curtain-bg); }
[data-em-curtain] { position: fixed; inset: 0; z-index: 2147483500; pointer-events: none; animation: em-curtain-out .22s cubic-bezier(.33, 1, .68, 1) forwards; }
@keyframes em-curtain-out { from { opacity: 1; } to { opacity: 0; visibility: hidden; } }
/* html.em-seen: a later page of the same visit (set in <head> from sessionStorage 'em-seen'): no curtain at all. */
html:not(.em-js) [data-em-curtain], html.em-reduce [data-em-curtain], html.em-seen [data-em-curtain] { display: none; }

@media (prefers-reduced-motion: reduce) {
    .em-marquee-track { animation: none; }
    [data-em-curtain] { display: none !important; }
}

/* ---------- print: everything shows, nothing moves ---------- */
@media print {
    [data-em-reveal], [data-em-split], .em-split .em-i, [data-em-reveal="mask"] > img, [data-em-reveal="mask"] > video, [data-em-reveal="mask"] > picture > img {
        opacity: 1 !important; transform: none !important; clip-path: none !important; filter: none !important; transition: none !important; animation: none !important;
    }
    [data-em-draw] :is(path, line, polyline, polygon, circle, rect, ellipse) { stroke-dashoffset: 0 !important; transition: none !important; animation: none !important; }
    [data-em-curtain] { display: none !important; }
}
