/* Canopy page structure: one-viewport sections, a vertical dial and replayable reveals.
   Everything is scoped to html[data-cx], so they only apply to pages built with canopy-stack.mjs. */
html[data-cx] {
  --cx-ease: cubic-bezier(.16, 1, .3, 1);
}
/* The page frame draws rails at fixed document positions, which no longer match the taller panels. */
html[data-cx] .canopy-page-frame { display: none; }

html[data-cx] #main { position: relative; z-index: 1; background: #fff; }

/* Each panel fills at least one viewport and scrolls normally; the pager moves between them. */
html[data-cx] .cx-panel {
  position: relative;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: clip;
  background: #fff;
}
html[data-cx] .cx-panel[data-cx-tone="paper"] { background: var(--paper); }
html[data-cx] .cx-panel[data-cx-tone="dark"] { background: var(--charcoal); }
/* Fill the whole panel with the section colour, not only the section box. */
html[data-cx] .cx-panel > .closing { flex: 1; display: grid; align-content: center; }
html[data-cx] .cx-panel > #how-it-works { flex: 1; }

/* Replayable reveals: elements enter from the side they were scrolled in from, every time. */
html[data-cx][data-cx-motion] [data-cx-reveal] {
  transition: opacity .9s var(--cx-ease), translate 1s var(--cx-ease), filter .9s var(--cx-ease);
  transition-delay: calc(var(--cx-i, 0) * 70ms);
}
html[data-cx][data-cx-motion] [data-cx-reveal]:not(.cx-in) {
  opacity: 0;
  translate: 0 calc(var(--cx-from, 1) * 56px);
  filter: blur(8px);
  transition-delay: 0ms;
}
html[data-cx][data-cx-motion] [data-cx-reveal="soft"]:not(.cx-in) { filter: none; translate: 0 calc(var(--cx-from, 1) * 36px); }

/* Vertical dial: a quiet ruler on the right edge. One long tick per section, short ticks between.
   Ticks near the pointer grow and their names fade in; a marker glides with the page. */
.cx-dial {
  --cx-gap: 30px;
  position: fixed;
  z-index: 40;
  right: clamp(12px, 1.6vw, 26px);
  top: 50%;
  width: 56px;
  height: calc(var(--n, 10) * var(--cx-gap) + 32px);
  translate: 0 -50%;
  color: #101114;
  font: 500 13px/1 Inter, system-ui, sans-serif;
  letter-spacing: -.01em;
  -webkit-user-select: none;
  user-select: none;
  transition: color .4s;
}
.cx-dial-ruler { position: absolute; inset: 16px 0; filter: drop-shadow(0 0 1px rgb(255 255 255 / .7)); }
.cx-dial-tick {
  position: absolute;
  right: 0;
  top: calc(var(--at) * var(--cx-gap));
  width: 8px;
  height: 1.5px;
  margin-top: -.75px;
  border-radius: 2px;
  background: currentColor;
  opacity: calc(.22 + var(--near, 0) * .5);
  transform: scaleX(calc(1 + var(--near, 0) * 1.6));
  transform-origin: 100% 50%;
  transition: transform .35s var(--cx-ease), opacity .35s;
}
.cx-dial-item {
  position: absolute;
  right: 0;
  top: calc(var(--at) * var(--cx-gap));
  width: 56px;
  height: var(--cx-gap);
  margin-top: calc(var(--cx-gap) / -2);
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
}
.cx-dial-item .cx-dial-tick { top: 50%; width: 16px; opacity: calc(.45 + var(--near, 0) * .55); }
.cx-dial-item[aria-current="true"] .cx-dial-tick { opacity: 1; }
.cx-dial-label {
  position: absolute;
  right: calc(100% + 4px);
  top: 50%;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
  background: rgb(255 255 255 / .82);
  border: 1px solid rgb(41 42 45 / .08);
  box-shadow: 0 8px 22px -14px rgb(20 24 32 / .5);
  -webkit-backdrop-filter: blur(14px) saturate(1.5);
  backdrop-filter: blur(14px) saturate(1.5);
  opacity: calc(var(--near, 0) * var(--near, 0));
  translate: calc((1 - var(--near, 0)) * 10px) -50%;
  scale: calc(.92 + var(--near, 0) * .08);
  transform-origin: 100% 50%;
  transition: opacity .3s, translate .4s var(--cx-ease), scale .4s var(--cx-ease);
}
.cx-dial-label b { font-weight: 500; font-size: 11px; color: #8a8e97; font-variant-numeric: tabular-nums; }
.cx-dial-item[aria-current="true"] .cx-dial-label { font-weight: 600; }
.cx-dial-item[aria-current="true"] .cx-dial-label b { color: #07525b; }
/* After a section change the current name shows for a moment, then fades. */
.cx-dial[data-announce]:not([data-hover]) .cx-dial-item[aria-current="true"] { --near: 1; }
.cx-dial-item:focus-visible { outline: none; }
.cx-dial-item:focus-visible .cx-dial-label { outline: 2px solid #07525b; outline-offset: 2px; }
/* The marker: a short bar with a lime bead that glides along the ruler with the page. */
.cx-dial-needle {
  position: absolute;
  right: 0;
  top: 16px;
  width: 26px;
  height: 2px;
  margin-top: -1px;
  border-radius: 2px;
  background: currentColor;
  pointer-events: none;
  will-change: transform;
}
.cx-dial-needle::before {
  content: "";
  position: absolute;
  left: -4px;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -3.5px;
  border-radius: 50%;
  background: #64f5ff;
  box-shadow: 0 0 0 2px currentColor, 0 0 12px rgb(100 245 255 / .8);
}
/* Over the dark workflow panel and the footer the ruler turns light. */
.cx-dial[data-dark] { color: #eef0f3; }
.cx-dial[data-dark] .cx-dial-ruler { filter: none; }
.cx-dial[data-dark] .cx-dial-label { background: rgb(22 23 26 / .78); border-color: rgb(255 255 255 / .12); }
.cx-dial[data-dark] .cx-dial-label b { color: #9aa0aa; }
.cx-dial[data-dark] .cx-dial-item[aria-current="true"] .cx-dial-label b { color: #64f5ff; }
.cx-dial[data-dark] .cx-dial-item:focus-visible .cx-dial-label { outline-color: #64f5ff; }
.cx-dial[data-dark] .cx-dial-needle::before { box-shadow: 0 0 0 2px #0d0e10, 0 0 12px rgb(100 245 255 / .8); }
body.pd-is-maximized .cx-dial { display: none; }

@media (max-width: 760px) {
  .cx-dial { --cx-gap: 22px; right: 6px; width: 40px; }
  .cx-dial-item { width: 40px; }
  .cx-dial-needle { width: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .cx-dial-tick, .cx-dial-label, .cx-dial { transition: none; }
}
