/* The incoming and outgoing layers share a viewport and independent scroll positions. */
:root {
 --wo-safe-top: env(safe-area-inset-top, 0px);
 --wo-safe-right: env(safe-area-inset-right, 0px);
 --wo-safe-bottom: env(safe-area-inset-bottom, 0px);
 --wo-safe-left: env(safe-area-inset-left, 0px);
}

/* The incoming page's reveal edge, as a share of its height from the top.
   Chrome runs clip-path transitions on its compositor and, when one ends,
   can present a single frame with the starting mask: the page being left
   then flashes through the top 70%. A registered property animates on the
   main thread and recomputes the same clip-path every frame, so the reveal
   looks identical and ends without that hand-off. */
@property --wo-page-reveal {
 syntax: '<percentage>';
 inherits: false;
 initial-value: 0%;
}

html,
body {
 overflow: hidden;
 /* Section surfaces supply the colour underneath Safari's glass toolbar. */
 background: transparent;
}

/* Both view URLs serve the Coaching HTML. The synchronous head bootstrap
   selects Guide before that markup is parsed; keep it out of paint even
   while deferred controllers load, including a cold Safari history return. */
html[data-active-view="guide"] #main {
 display: none !important;
}
html[data-active-view="guide"] #swup {
 background: var(--wo-paper);
}

.wo-app {
 display: grid;
 grid-template-areas: "header" "page";
 grid-template-rows: 0 minmax(0, 1fr);
 height: 100dvh;
 /* This wrapper is a mask, not a scroll surface. In particular, an iframe's
    fragment navigation must not scroll it while the Guide enters. */
 overflow: clip;
 background: transparent;
}

.wo-app > .wo-header {
 grid-area: header;
}

#swup {
 grid-area: page;
 position: relative;
 min-width: 0;
 overflow: hidden auto;
 overscroll-behavior: contain;
 scrollbar-width: none;
 z-index: 2;
 clip-path: inset(var(--wo-page-reveal) 0% 0% 0%);
 background: transparent;
 outline: none;
}

#swup[data-view="guide"],
html[data-contact-open] #swup {
 overflow-y: hidden;
}

/* Keep a painted backing under the iframe during compositor handoffs. */
#swup[data-view="guide"] {
 background: var(--wo-paper);
}

#swup.lenis { scroll-behavior: auto !important; }

/* Use the document as the mobile scroll surface. A viewport-sized inner
   scroller leaves Safari's toolbar areas outside the page's painted content. */
html[data-native-scroll][data-entry-choice="selected"],
html[data-native-scroll][data-entry-choice="selected"] body {
 overflow: visible;
 overflow-x: clip;
 overscroll-behavior-x: none;
}
/* At scroll origin Safari has no earlier content to extend behind its top
   controls. Give that document canvas the same grey as the Hero and Guide
   surround, rather than the browser's default white. This is a page backing,
   not a pinned layer; scrolling content can still paint beneath the glass. */
html[data-native-scroll][data-entry-choice="selected"],
html[data-native-scroll][data-entry-choice="selected"] body {
 background-color: var(--wo-paper);
}
html[data-native-scroll][data-entry-choice="selected"] .wo-app {
 display: block;
 width: 100%;
 max-width: 100%;
 min-width: 0;
 height: auto;
 min-height: 100svh;
 overflow: visible;
}
html[data-native-scroll][data-entry-choice="selected"] #swup {
 display: block;
 width: 100%;
 max-width: 100%;
 min-width: 0;
 min-height: 100svh;
 /* Contain decorative/transformed overflow without making an inner scroller.
    Keeping vertical overflow visible preserves Safari's transparent bars. */
 overflow: clip visible;
 touch-action: pan-y pinch-zoom;
 clip-path: none;
}

#swup .entry-choice {
 display: grid;
 position: absolute;
}

/* Only the shared page layer moves on exit; keep the choice's own reveal
   settled when its root state changes from ready to selected. */
#swup.is-previous-container .entry-choice__content {
 opacity: 1;
 transform: none;
 transition: none;
}

#wo-page-stash {
 position: absolute;
 inset: 0;
 overflow: hidden;
 visibility: hidden;
 /* visibility can be overridden by retained Framer descendants. Fade the
    entire stored layer so none can paint over the active Guide. */
 opacity: 0;
 pointer-events: none;
}

/* Retained Framer/video layers must not paint while Guide is active. Keep
   the iframe's warm-up geometry, but fully remove stored Coaching from paint. */
#wo-page-stash > #main { display: none !important; }

/* Applied before Swup clears transition classes and releases compositor
   layers, rather than waiting for ParallelPlugin's later DOM removal. */
.transition-swup[data-page-retired] {
 visibility: hidden !important;
 opacity: 0 !important;
 clip-path: inset(50%) !important;
 pointer-events: none !important;
 transition: none !important;
}

/* Keep retired pages in place, with an empty paint mask and no document-flow
   height. Preserve viewport geometry so the live 3D scene stays correctly sized. */
.wo-retained-page {
 display: block !important;
 position: absolute;
 inset: 0;
 width: 100%;
 height: 100dvh;
 min-height: 0;
 margin: 0;
 padding: 0;
 overflow: hidden;
 visibility: hidden !important;
 opacity: 0 !important;
 clip-path: inset(50%) !important;
 pointer-events: none !important;
 transition: none !important;
 transform: none !important;
}

.guide-view {
 display: block;
 width: 100%;
 height: 100dvh;
 border: 0;
 background: var(--wo-paper);
 opacity: 0;
 transition: opacity 160ms linear;
}
.guide-view[data-shell-ready="true"] { opacity: 1; }

/* Let the real framed page extend beneath Safari's expanded bottom controls.
   A dvh-sized frame inside two clipped viewport wrappers ends at the toolbar
   edge: transparency then shows an empty browser canvas instead of content.
   Keep the frame in document flow, sized to the unobscured large viewport;
   its catalogue still owns its existing scroll and 3D transitions. */
html[data-native-scroll] .guide-view {
 height: 100lvh;
 min-height: 100dvh;
}

/* The same overlap on native Safari, kept in document paint so its glass
   toolbars continue sampling the page. The outgoing page supplies document
   height until removal; the incoming surface is only one viewport tall. */
html[data-native-page-swap],
html[data-native-page-swap] body {
 overflow: visible;
 overflow-x: clip;
 overscroll-behavior-x: none;
}
html[data-native-page-swap] .wo-app {
 display: block;
 position: relative;
 height: auto;
 min-height: 100svh;
 overflow: visible;
}
html[data-native-page-swap] .wo-app > #swup[data-native-outgoing] {
 display: block;
 overflow: clip visible;
 clip-path: none;
 transform-origin: 50% var(--wo-native-page-origin);
}
/* Safari's glass toolbars show the page beneath them. A surface exactly as
   tall as the visible viewport left the outgoing page showing under both
   bars until the swap ended, so the incoming one bleeds past each edge: its
   own next content continues under the bottom bar, and its page colour sits
   under the top bar. Padding keeps the content where the viewport starts. */
html[data-native-page-swap] .wo-app > #swup[data-native-incoming] {
 --wo-native-bleed-top: 180px;
 --wo-native-bleed-bottom: max(220px, calc(100lvh - var(--wo-native-page-height) + 40px));
 display: block;
 position: absolute;
 top: calc(var(--wo-native-page-top) - var(--wo-native-bleed-top));
 left: 0;
 width: 100%;
 height: calc(var(--wo-native-page-height) + var(--wo-native-bleed-top) + var(--wo-native-bleed-bottom));
 min-height: 0;
 padding-top: var(--wo-native-bleed-top);
 background: var(--wo-paper);
 overflow: clip;
 clip-path: inset(var(--wo-page-reveal) 0 0);
 transform: none;
 pointer-events: none;
}
html[data-native-page-swap] .wo-app > #swup[data-native-incoming].is-next-container {
 transform: translateY(50dvh);
 --wo-page-reveal: 70%;
}

.wo-guide-fallback {
 display: grid;
 height: 100%;
 place-items: center;
 color: white;
}

html.is-changing .transition-swup {
 --transitions-ease: var(--ease-overlap);
 transition:
  transform 1.4s var(--transitions-ease),
  opacity 1.4s var(--transitions-ease),
  --wo-page-reveal 1.4s var(--transitions-ease);
}

html.is-changing .wo-header.transition-swup:not(.is-previous-container) {
 transition:
  opacity 0.4s var(--transitions-ease) 0.9s,
  transform 0.8s var(--transitions-ease) 0.7s;
}

/* A menu opened during a page swap still needs its own coordinated reveal. */
html.is-changing .wo-header:not(:has(.bevel-nav[data-menu-animating])) * {
 transition: none !important;
}

.transition-swup.is-previous-container {
 transform: translateY(-160px) scale(0.95);
 opacity: 0.5;
 pointer-events: none;
}

html.is-changing .wo-header.is-previous-container {
 opacity: 0;
}

#swup.is-previous-container {
 z-index: 1;
}

#swup.is-next-container {
 transform: translateY(50dvh);
 --wo-page-reveal: 70%;
}

html.is-changing .wo-header.is-next-container {
 opacity: 0;
 transform: translateY(10dvh);
}

@media (prefers-reduced-motion: reduce) {
 html.is-changing .transition-swup { transition: none !important; }
}
