/* LEIT Welcome: the module stylesheet, served at /_leit/welcome/welcome.css.

   THE STYLING CONTRACT (LEIT-CENTRAL-MODULES-PLAN.md 2.5):
   - Every color, face, size, gap, radius and motion value reads a --welcome-*
     token. The value after the comma is the neutral default (system colors,
     so it reads in light and dark); a site sets its own in leit.config.json
     (modules.welcome.tokens), served as /_leit/welcome/site.css.
   - Rules are wrapped in :where(), so they weigh nothing and any site or skin
     rule wins without !important.
   - Skins style [data-part="welcome-..."] and nothing else (parts.json).
   - TWO RULES REACH PAST THE PARTS, on purpose, because they are the module's
     function: the pause freeze (every animation on the page holds) and the
     scroll hold while the dialog is up. Both key on attributes the module
     owns on <html>: data-leit-motion and data-leit-welcome. */

/* ---- The pause freeze ----------------------------------------------------------
   While the visitor has paused motion, every CSS animation on the page holds
   its frame. JS loops park through LeitMotion.subscribe. One-shot entrances are
   played through by welcome.js (motion.releaseEntrances). */
html[data-leit-motion~="paused"] *,
html[data-leit-motion~="paused"] *::before,
html[data-leit-motion~="paused"] *::after {
  animation-play-state: paused !important;
}

/* ---- The scroll hold -------------------------------------------------------------
   The boot stamps data-leit-welcome before the body paints; welcome.js clears
   it when the dialog closes. The gutter stays reserved so the page keeps its
   width and nothing re-lays out when the scrim lifts. */
html[data-leit-welcome] {
  overflow: hidden;
  scrollbar-gutter: stable;
}

/* ---- The scrim and the card ------------------------------------------------------ */

:where(.leit-welcome) {
  position: fixed;
  inset: 0;
  z-index: var(--welcome-z, 10000);
  display: grid;
  justify-items: center;
  /* Pinned from the top, not centred: each step is a different height, and a
     centred card jumps between them. The title stays exactly where it is. */
  align-items: start;
  padding: var(--welcome-top, max(1.5rem, 12vh)) var(--welcome-gutter, 1.5rem) var(--welcome-gutter, 1.5rem);
  background: var(--welcome-scrim-bg, rgb(0 0 0 / 0.35));
  -webkit-backdrop-filter: var(--welcome-scrim-filter, blur(3px));
  backdrop-filter: var(--welcome-scrim-filter, blur(3px));
  font-family: var(--welcome-font, inherit);
  cursor: default;
}
:where(.leit-welcome *, .leit-welcome *::before, .leit-welcome *::after) { box-sizing: border-box; }
:where(.leit-welcome a, .leit-welcome button) { cursor: pointer; }

/* The static frame (server HTML, before welcome.js decides the steps) shows
   only when the boot's stamp asks for it, and only the step it names. */
:where(.leit-welcome--static),
:where(.leit-welcome--static .leit-welcome__step) { display: none; }
:where(html[data-leit-welcome="motion"], html[data-leit-welcome="cookies"]) :where(.leit-welcome--static) { display: grid; }
:where(html[data-leit-welcome="motion"]) :where(.leit-welcome--static .leit-welcome__step[data-step="motion"]),
:where(html[data-leit-welcome="cookies"]) :where(.leit-welcome--static .leit-welcome__step[data-step="cookies"]) { display: block; }

:where(.leit-welcome__card) {
  width: 100%;
  max-width: var(--welcome-card-width, 30rem);
  /* Never taller than the window: the card scrolls rather than clip the
     buttons off the bottom, which would leave no way out. */
  max-height: calc(100dvh - var(--welcome-top, max(1.5rem, 12vh)) - var(--welcome-gutter, 1.5rem));
  overflow: hidden auto;
  padding: var(--welcome-card-padding, clamp(1.5rem, 4vw, 2.25rem));
  background: var(--welcome-card-bg, Canvas);
  color: var(--welcome-text, CanvasText);
  border: var(--welcome-card-border-width, 1px) solid var(--welcome-card-border, color-mix(in srgb, CanvasText 18%, transparent));
  border-radius: var(--welcome-card-radius, 10px);
  box-shadow: var(--welcome-card-shadow, 0 24px 60px rgb(0 0 0 / 0.22));
  text-align: start;
}
/* Holds focus for the dialog, never shows it. */
:where(.leit-welcome__card:focus) { outline: none; }

:where(.leit-welcome__title) {
  margin: 0;
  font-family: var(--welcome-title-font, inherit);
  font-size: var(--welcome-title-size, 1.75rem);
  font-weight: var(--welcome-title-weight, 600);
  line-height: var(--welcome-title-leading, 1.15);
  letter-spacing: var(--welcome-title-tracking, normal);
  text-transform: var(--welcome-title-transform, none);
  text-shadow: var(--welcome-title-shadow, none);
  color: var(--welcome-title-color, inherit);
}

/* The clip is padded out past the content so a button's focus ring is not cut
   off at the edges, then pulled back so the text stays where it was. */
:where(.leit-welcome__viewport) {
  overflow: hidden;
  margin: var(--welcome-space, 1rem) -8px 0;
  padding: 0 8px 8px;
}

:where(.leit-welcome__heading) {
  margin: 0 0 var(--welcome-heading-gap, 0.75rem);
  font-family: var(--welcome-heading-font, inherit);
  font-size: var(--welcome-heading-size, 1.25rem);
  font-weight: var(--welcome-heading-weight, 600);
  line-height: var(--welcome-heading-leading, 1.2);
  letter-spacing: var(--welcome-heading-tracking, normal);
  text-transform: var(--welcome-heading-transform, none);
  color: var(--welcome-heading-color, inherit);
}

:where(.leit-welcome__body) {
  margin: 0;
  font-family: var(--welcome-body-font, inherit);
  font-size: var(--welcome-body-size, 1rem);
  line-height: var(--welcome-leading, 1.6);
  color: var(--welcome-muted, inherit);
}
:where(.leit-welcome__link) {
  color: var(--welcome-link, LinkText);
  text-decoration: underline;
  text-underline-offset: 2px;
}
:where(.leit-welcome__link:hover, .leit-welcome__link:focus-visible) { color: var(--welcome-link-hover, var(--welcome-link, LinkText)); }

:where(.leit-welcome__thanks) {
  margin: 0;
  padding-block: 0.25rem 0.5rem;
  font-family: var(--welcome-body-font, inherit);
  font-size: var(--welcome-thanks-size, 1.25rem);
  line-height: var(--welcome-leading, 1.6);
  color: var(--welcome-muted, inherit);
}

/* ---- The buttons -------------------------------------------------------------------
   go: View motion, the one primary. stay: Keep motion off. choice: BOTH cookie
   buttons, one class and one part with nothing added to either, so neither
   nudges (LEIT-TRACKING-CONSENT-STANDARD section 3). A skin cannot dress one
   cookie choice apart from the other, because there is no selector for it. */

:where(.leit-welcome__actions) {
  display: flex;
  flex-wrap: wrap;
  gap: var(--welcome-button-gap, 0.75rem);
  margin-top: var(--welcome-actions-gap, 1.5rem);
}
:where(.leit-welcome__btn) {
  /* A label never breaks: when the pair cannot sit side by side the row wraps
     and each button takes the card's width. */
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--welcome-icon-gap, 0.6em);
  min-width: var(--welcome-button-min, 10rem);
  min-height: var(--welcome-target, 44px);
  padding: var(--welcome-button-pad, 0.7rem 1.1rem);
  white-space: nowrap;
  font-family: var(--welcome-button-font, inherit);
  font-size: var(--welcome-button-size, 0.875rem);
  font-weight: var(--welcome-button-weight, 500);
  letter-spacing: var(--welcome-button-tracking, 0.04em);
  text-transform: var(--welcome-button-transform, uppercase);
  border-radius: var(--welcome-button-radius, 10px);
  box-shadow: var(--welcome-button-shadow, none);
  transition: var(--welcome-button-transition, background-color 0.2s, border-color 0.2s, color 0.2s);
}
:where(.leit-welcome__btn:focus-visible) {
  outline: var(--welcome-focus-width, 2px) solid var(--welcome-focus, CanvasText);
  outline-offset: var(--welcome-focus-offset, 2px);
}
:where(.leit-welcome__icon) { flex: 0 0 auto; width: 1.15em; height: 1.15em; }

:where(.leit-welcome__go) {
  background: var(--welcome-go-bg, CanvasText);
  color: var(--welcome-go-text, Canvas);
  border: var(--welcome-button-border-width, 1px) solid var(--welcome-go-border, CanvasText);
  box-shadow: var(--welcome-go-shadow, var(--welcome-button-shadow, none));
}
:where(.leit-welcome__go:hover) {
  background: var(--welcome-go-hover-bg, color-mix(in srgb, CanvasText 82%, Canvas));
  color: var(--welcome-go-hover-text, var(--welcome-go-text, Canvas));
  border-color: var(--welcome-go-hover-border, var(--welcome-go-border, CanvasText));
}
:where(.leit-welcome__stay, .leit-welcome__choice) {
  background: var(--welcome-stay-bg, transparent);
  color: var(--welcome-stay-text, inherit);
  border: var(--welcome-button-border-width, 1px) solid var(--welcome-stay-border, color-mix(in srgb, CanvasText 40%, transparent));
}
:where(.leit-welcome__stay:hover, .leit-welcome__choice:hover) {
  background: var(--welcome-stay-hover-bg, var(--welcome-stay-bg, transparent));
  color: var(--welcome-stay-hover-text, var(--welcome-stay-text, inherit));
  border-color: var(--welcome-stay-hover-border, CanvasText);
}

/* ---- The slides ---------------------------------------------------------------------
   Durations come from the timing settings (welcome.js sets the two -ms tokens). */
:where(.leit-welcome__step--out) { animation: leit-welcome-out var(--welcome-slide-ms, 323ms) var(--welcome-ease, cubic-bezier(0.4, 0, 0.2, 1)) forwards; }
:where(.leit-welcome__step--in) { animation: leit-welcome-in var(--welcome-slide-ms, 323ms) var(--welcome-ease-in, cubic-bezier(0.16, 1, 0.3, 1)) both; }
:where(.leit-welcome--fading) { animation: leit-welcome-fade var(--welcome-fade-ms, 550ms) var(--welcome-ease, cubic-bezier(0.4, 0, 0.2, 1)) forwards; }
@keyframes leit-welcome-out { to { transform: translateX(-110%); opacity: 0; } }
@keyframes leit-welcome-in { from { transform: translateX(110%); opacity: 0; } }
@keyframes leit-welcome-fade { to { opacity: 0; } }
/* Motion off (and not forced): the steps swap in place and the scrim just goes. */
@media (prefers-reduced-motion: reduce) {
  :where(html:not([data-leit-motion~="forced"])) :where(.leit-welcome__step--out, .leit-welcome__step--in, .leit-welcome--fading) { animation: none; }
}

@media (max-width: 480px) {
  :where(.leit-welcome__btn) { flex-basis: 100%; }
}

/* ---- The pause control ----------------------------------------------------------------
   Fixed bottom-right, an aside landmark, riding above the site's cookie bar
   (--welcome-pause-lift: the bar's height, which the site publishes). The root
   lets clicks through; only the dock takes the pointer. */

:where(.leit-pause) {
  position: fixed;
  right: var(--welcome-pause-right, clamp(0.9rem, 2vw, 1.6rem));
  bottom: calc(var(--welcome-pause-lift, 0px) + var(--welcome-pause-bottom, clamp(1rem, 2.5vw, 1.75rem)));
  z-index: var(--welcome-pause-z, 60);
  pointer-events: none;
  display: grid;
  justify-items: end;
  font-family: var(--welcome-pause-font, inherit);
  transition: bottom var(--welcome-pause-ms, 0.3s) var(--welcome-pause-ease, cubic-bezier(0.16, 1, 0.3, 1));
}
:where(.leit-pause *, .leit-pause *::before, .leit-pause *::after) { box-sizing: border-box; }

/* The dock holds the button and its stow x, and is what the stow slides. */
:where(.leit-pause__dock) {
  position: relative;
  pointer-events: auto;
  transition: transform var(--welcome-pause-ms, 0.3s) var(--welcome-pause-ease, cubic-bezier(0.16, 1, 0.3, 1));
}

/* The pill (default): label always out, 44px tall. */
:where(.leit-pause__button) {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--welcome-pause-gap, 0.5rem);
  min-height: var(--welcome-pause-height, 2.75rem);
  padding: 0 var(--welcome-pause-pad, 1rem);
  border: var(--welcome-pause-border-width, 2px) solid var(--welcome-pause-border, CanvasText);
  border-radius: var(--welcome-pause-radius, 999px);
  background: var(--welcome-pause-bg, color-mix(in srgb, Canvas 88%, transparent));
  color: var(--welcome-pause-text, CanvasText);
  font-family: inherit;
  font-size: var(--welcome-pause-size, 0.875rem);
  font-weight: var(--welcome-pause-weight, 500);
  letter-spacing: var(--welcome-pause-tracking, normal);
  text-transform: var(--welcome-pause-transform, none);
  white-space: nowrap;
  cursor: pointer;
  opacity: var(--welcome-pause-rest-opacity, 1);
  -webkit-backdrop-filter: var(--welcome-pause-filter, blur(4px));
  backdrop-filter: var(--welcome-pause-filter, blur(4px));
  box-shadow: var(--welcome-pause-shadow, 0 8px 24px rgb(0 0 0 / 0.12));
  transition: var(--welcome-pause-transition, background-color 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s);
}
:where(.leit-pause__button:hover) {
  background: var(--welcome-pause-hover-bg, var(--welcome-pause-bg, color-mix(in srgb, Canvas 88%, transparent)));
  color: var(--welcome-pause-hover-text, var(--welcome-pause-text, CanvasText));
  border-color: var(--welcome-pause-hover-border, var(--welcome-pause-border, CanvasText));
  box-shadow: var(--welcome-pause-hover-shadow, var(--welcome-pause-shadow, 0 8px 24px rgb(0 0 0 / 0.12)));
}
:where(.leit-pause__button:focus-visible) {
  outline: var(--welcome-focus-width, 2px) solid var(--welcome-pause-focus, var(--welcome-focus, CanvasText));
  outline-offset: 2px;
}
:where(.leit-pause__icon) { width: var(--welcome-pause-icon, 0.95rem); height: var(--welcome-pause-icon, 0.95rem); fill: currentColor; flex-shrink: 0; }

/* The stow: a mini x on the button's top-right corner. Shown on hover and on
   keyboard focus where there is a pointer; always shown on touch and narrow
   screens, where there is no hover to find it by. */
:where(.leit-pause__stow) {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 2px solid var(--welcome-pause-stow-edge, Canvas);
  border-radius: var(--welcome-pause-stow-radius, 50%);
  background: var(--welcome-pause-stow-bg, CanvasText);
  color: var(--welcome-pause-stow-text, Canvas);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: var(--welcome-pause-transition, background-color 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s);
}
:where(.leit-pause__stow[hidden]) { display: none; }
:where(.leit-pause__stow svg) { width: 12px; height: 12px; }
:where(.leit-pause__dock:hover .leit-pause__stow, .leit-pause__dock:focus-within .leit-pause__stow) { opacity: 1; pointer-events: auto; }
@media (pointer: coarse), (max-width: 900px) {
  :where(.leit-pause__stow) { opacity: 1; pointer-events: auto; }
}
:where(.leit-pause__stow:hover) { background: var(--welcome-pause-stow-hover-bg, var(--welcome-pause-stow-bg, CanvasText)); }
:where(.leit-pause__stow:focus-visible) { outline: var(--welcome-focus-width, 2px) solid var(--welcome-pause-focus, var(--welcome-focus, CanvasText)); outline-offset: 2px; }

/* Stowed: a 29px tab of the button at the screen edge, per session. Tucked for
   keyboard focus: a 12px one, never remembered. Tucked, never hidden. */
:where(.leit-pause.is-stowed .leit-pause__dock) { transform: translateX(calc(100% + var(--welcome-pause-right, clamp(0.9rem, 2vw, 1.6rem)) - 29px)); }
:where(.leit-pause.is-yielding .leit-pause__dock) { transform: translateX(calc(100% + var(--welcome-pause-right, clamp(0.9rem, 2vw, 1.6rem)) - 12px)); }
:where(.leit-pause.is-stowed .leit-pause__dock:hover, .leit-pause.is-stowed .leit-pause__dock:focus-within) { transform: translateX(calc(100% + var(--welcome-pause-right, clamp(0.9rem, 2vw, 1.6rem)) - 39px)); }
:where(.leit-pause.is-yielding .leit-pause__dock:hover) { transform: translateX(calc(100% + var(--welcome-pause-right, clamp(0.9rem, 2vw, 1.6rem)) - 34px)); }
:where(.leit-pause.is-stowed .leit-pause__button, .leit-pause.is-yielding .leit-pause__button) { border-radius: var(--welcome-pause-radius, 999px) 0 0 var(--welcome-pause-radius, 999px); border-right: 0; }
/* Stowed, the glyph sits at the tab's optical centre (most of the tab is the
   rounded end), measured from inside the left border. */
:where(.leit-pause.is-stowed .leit-pause__icon) {
  position: absolute;
  top: 50%;
  left: 16px;
  transform: translate(-50%, -50%);
  transition: left var(--welcome-pause-ms, 0.3s) var(--welcome-pause-ease, cubic-bezier(0.16, 1, 0.3, 1));
}
:where(.leit-pause.is-stowed .leit-pause__dock:hover .leit-pause__icon, .leit-pause.is-stowed .leit-pause__dock:focus-within .leit-pause__icon) { left: 24px; }
:where(.leit-pause.is-stowed .leit-pause__label) { visibility: hidden; }
:where(.leit-pause.is-yielding .leit-pause__stow) { opacity: 0; pointer-events: none; }

/* SHORT WINDOWS GET THE ROUND BUTTON. 400% zoom leaves a window about 235px
   tall and the labelled pill took a fifth of it. The label stays in the tree,
   so the button's name is still the action. */
@media (max-height: 420px) {
  :where(.leit-pause[data-style="pill"] .leit-pause__button) { width: var(--welcome-pause-height, 2.75rem); padding: 0; justify-content: center; }
  :where(.leit-pause[data-style="pill"] .leit-pause__label) {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* The circle (pause.style "circle"): a quiet glyph, the label folding out on
   hover and keyboard focus. Collapsed, not hidden, so it stays the name. */
:where(.leit-pause[data-style="circle"] .leit-pause__button) {
  gap: 0;
  min-width: var(--welcome-circle-size, 32px);
  min-height: var(--welcome-circle-size, 32px);
  height: var(--welcome-circle-size, 32px);
  padding: 0 var(--welcome-circle-pad, 9px);
  border-width: var(--welcome-circle-border-width, 1px);
  border-color: var(--welcome-circle-border, var(--welcome-pause-border, CanvasText));
  background: var(--welcome-circle-bg, var(--welcome-pause-bg, color-mix(in srgb, Canvas 88%, transparent)));
  color: var(--welcome-circle-text, var(--welcome-pause-text, CanvasText));
  -webkit-backdrop-filter: var(--welcome-circle-filter, var(--welcome-pause-filter, blur(4px)));
  backdrop-filter: var(--welcome-circle-filter, var(--welcome-pause-filter, blur(4px)));
  box-shadow: var(--welcome-circle-shadow, none);
  font-size: var(--welcome-circle-text-size, 0.7rem);
  letter-spacing: var(--welcome-circle-tracking, 0.08em);
  text-transform: var(--welcome-circle-transform, uppercase);
  opacity: var(--welcome-circle-rest-opacity, 0.75);
}
:where(.leit-pause[data-style="circle"] .leit-pause__icon) { width: var(--welcome-circle-icon, 12px); height: var(--welcome-circle-icon, 12px); }
:where(.leit-pause[data-style="circle"] .leit-pause__label) {
  max-width: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-width var(--welcome-pause-ms, 0.25s) var(--welcome-pause-ease, cubic-bezier(0.16, 1, 0.3, 1)),
    opacity var(--welcome-pause-ms, 0.25s) var(--welcome-pause-ease, cubic-bezier(0.16, 1, 0.3, 1)),
    margin-left var(--welcome-pause-ms, 0.25s) var(--welcome-pause-ease, cubic-bezier(0.16, 1, 0.3, 1));
}
:where(.leit-pause[data-style="circle"] .leit-pause__button:hover, .leit-pause[data-style="circle"] .leit-pause__button:focus-visible) {
  opacity: 1;
  color: var(--welcome-circle-hover-text, var(--welcome-pause-hover-text, var(--welcome-pause-text, CanvasText)));
  border-color: var(--welcome-circle-hover-border, var(--welcome-pause-hover-border, var(--welcome-pause-border, CanvasText)));
  background: var(--welcome-circle-hover-bg, var(--welcome-circle-bg, var(--welcome-pause-bg, color-mix(in srgb, Canvas 88%, transparent))));
}
:where(.leit-pause[data-style="circle"] .leit-pause__button:hover .leit-pause__label, .leit-pause[data-style="circle"] .leit-pause__button:focus-visible .leit-pause__label) {
  max-width: 12em;
  margin-left: 8px;
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  :where(html:not([data-leit-motion~="forced"])) :where(.leit-pause, .leit-pause__dock, .leit-pause__button, .leit-pause__icon, .leit-pause__label) { transition: none; }
}
