/* ==========================================================================
   Home page: the infrastructure scene

   The big picture, told as the reader scrolls. The diagram stays in view on
   the right while the steps pass on the left; each step lights the part of
   the diagram it describes and sets it in motion. The last step zooms into
   one kernel, which opens into a diagram of the kernel as an operating
   system: hardware, Linux, and XCK built on it. The kernel chapter follows.

     .xh-scene          the section; clips the zoom without breaking sticky
     .xh-step           one step of the story
     .xh-infra          the diagram: one control plane, two of your clouds,
                        a pool of nodes in each, a kernel per project
     .xh-os             the operating-system diagram the zoom lands on
     [data-from="n"]    lit from step n onwards
     .is-now            the part the current step is about
     .is-sN             on the scene: step N has been reached

   home.js sets `data-armed` on the scene while it is driving it. Without the
   script, with reduced motion, or on a narrow screen, the diagram is drawn
   complete and in motion, and the steps read as an ordinary list.
   ========================================================================== */

.xh-scene {
  --xh-sec-bg: var(--xh-deep);
  --xh-z: 0;
  --xh-z2: 0;
  --xh-z3: 0;
  --xh-zf: 0;
  position: relative;
  padding: 0;
  overflow: clip;
  background: var(--xh-deep);
}

.xh .xh-scene + .xh-sec {
  border-top: 0;
}

.xh .xh-scene .xh-wrap {
  max-width: 66rem;
}

.xh .xh-scene__grid {
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(0, 8fr);
  gap: 2.6rem;
  align-items: start;
}

/* Steps -------------------------------------------------------------------- */

.xh .xh-scene__steps {
  position: relative;
  z-index: 2;
  padding: 3rem 0;
}

.xh .xh-step {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1.5rem 0;
  transition: opacity 0.45s ease;
}

.xh .xh-scene[data-armed] .xh-scene__steps {
  padding: 0;
}

.xh .xh-scene[data-armed] .xh-step {
  min-height: 68vh;
  padding: 2rem 0;
}

.xh .xh-scene[data-armed] .xh-step:first-child {
  min-height: 86vh;
}

.xh .xh-scene[data-armed] .xh-step:not(.is-active) {
  opacity: 0.28;
}

.xh .xh-scene[data-armed] .xh-step--zoom {
  min-height: 150vh;
  justify-content: flex-start;
  padding-top: 22vh;
}

.xh .xh-scene[data-armed] .xh-step--zoom.is-active {
  opacity: calc(1 - var(--xh-z2));
  transition: none;
}

/* Every step leaves as the zoom begins, so the screen is clear for what the
   kernel opens into. */
.xh .xh-scene.is-zooming .xh-step:not(.is-active) {
  opacity: calc(0.28 * (1 - var(--xh-z2)));
  transition: none;
}

/* Scroll length that keeps the operating-system diagram in view once the
   zoom has landed. It exists only while the scene is being driven. */
.xh .xh-scene__hold {
  display: none;
}

.xh .xh-scene[data-armed] .xh-scene__hold {
  display: block;
  height: 90vh;
}

.xh .xh-step__n {
  display: block;
  margin-bottom: 0.9rem;
  font-family: var(--md-code-font);
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.14em;
  color: var(--xh-teal-text);
}

.xh .xh-step__t {
  max-width: 17ch;
  font-size: 1.62rem;
  font-weight: 670;
  line-height: 1.14;
  letter-spacing: -0.03em;
  text-wrap: balance;
  color: var(--xh-fg);
}

.xh .xh-step__t em {
  font-style: normal;
  color: var(--xh-teal-text);
}

.xh .xh-step__d {
  max-width: 25rem;
  margin-top: 0.95rem;
  font-size: 0.84rem;
  line-height: 1.66;
  color: var(--xh-fg-2);
}

.xh .xh-step__d strong {
  font-weight: 620;
  color: var(--xh-fg);
}

.xh .xh-step .xh-list {
  max-width: 25rem;
  margin-top: 1.1rem;
}

/* Stage -------------------------------------------------------------------- */

.xh .xh-scene__stage {
  position: sticky;
  top: 2.9rem;
  z-index: 1;
  display: flex;
  align-items: center;
  height: calc(100vh - 2.9rem);
  padding: 1rem 0;
  container-type: inline-size;
}

/* Diagram ------------------------------------------------------------------
   Sized in em, and the em is a fixed fraction of the stage's own width: the
   picture is always the same number of em wide, so a label that fits its box
   on one screen fits it on every screen. A short screen makes the em smaller
   still, which only adds room.

   Boundaries, outermost first: your cloud (dashed), a Kubernetes cluster
   (solid), then the data plane node and the kernels it supervises. A pool is
   a name shared by nodes, drawn as a bracket under the clusters it spans.
   Every node and every kernel is the same size. The only things that move
   are the things that travel: a pull, an assignment, a run-plan, evidence. */

.xh .xh-infra {
  --xh-gap: 5.6em;
  --xh-cloud-pt: 1.35em;
  --xh-k8s-pt: 0.7em;
  --xh-k8s-px: 0.6em;
  --xh-k8s-gap: 0.7em;
  position: relative;
  width: 100%;
  font-size: min(1.86vh, 1.02vw);
  font-size: min(1.86vh, 1.8cqw);
  line-height: 1.4;
  letter-spacing: 0;
}

.xh .xh-infra__box {
  position: relative;
  border: 1px solid var(--xh-line);
  border-radius: 0.9em;
  background: var(--xh-bg-card);
  transition: opacity 0.55s ease, border-color 0.55s ease, box-shadow 0.55s ease,
              filter 0.55s ease;
}

.xh .xh-infra__cp {
  padding: 1.15em 1.35em 1.3em;
}

.xh .xh-infra__h {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2em 0.9em;
}

.xh .xh-infra__h b {
  font-size: 1.5em;
  font-weight: 670;
  letter-spacing: -0.022em;
  color: var(--xh-fg);
}

.xh .xh-infra__h span,
.xh .xh-infra__cap {
  display: block;
  font-family: var(--md-code-font);
  font-size: 0.78em;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--xh-fg-3);
}

.xh .xh-infra__cap b {
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--xh-fg);
}

.xh .xh-infra__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45em;
  margin-top: 0.9em;
}

.xh .xh-infra__tags span {
  padding: 0.46em 0.8em;
  border: 1px solid var(--xh-line);
  border-radius: 999px;
  background: var(--xh-bg);
  font-size: 0.9em;
  line-height: 1;
  white-space: nowrap;
  color: var(--xh-fg-2);
}

/* Between the control plane and your clouds: lines only. What each moving
   mark means is in the key under the picture. --------------------------------- */

.xh .xh-infra__gap {
  position: relative;
  height: var(--xh-gap);
}

/* A push that never arrives: it stops at the edge of your clouds. */
.xh .xh-infra__push {
  position: absolute;
  top: 0;
  bottom: 0.9em;
  left: 50%;
  width: 0;
  border-left: 2px dashed color-mix(in srgb, var(--xh-warn) 75%, transparent);
  transition: opacity 0.55s ease;
}

.xh .xh-infra__push::after {
  content: "\00d7";
  position: absolute;
  bottom: -1.05em;
  left: -1px;
  width: 1.6em;
  height: 1.6em;
  margin-left: -0.8em;
  border: 1.5px solid var(--xh-warn);
  border-radius: 50%;
  background: var(--xh-deep);
  font-size: 1.05em;
  font-weight: 600;
  line-height: 1.42em;
  text-align: center;
  color: var(--xh-warn);
}

/* Your clouds: the boundary nothing is pushed across ------------------------- */

.xh .xh-infra__clouds {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 2.2em;
}

.xh .xh-infra__cloud {
  position: relative;
  padding: var(--xh-cloud-pt) 1.1em 2.25em;
  border: 1.5px dashed color-mix(in srgb, var(--xh-teal) 50%, var(--xh-line));
  border-radius: 1.5em;
  background: color-mix(in srgb, var(--xh-teal) 4%, var(--xh-deep));
  transition: opacity 0.55s ease, border-color 0.55s ease, filter 0.55s ease,
              background-color 0.55s ease, box-shadow 0.55s ease;
}

/* Region labels sit along the lower edge of what they name, clear of the
   lanes that come in from the top. */
.xh .xh-infra__cloudh {
  position: absolute;
  bottom: 0.5em;
  left: 50%;
  display: flex;
  align-items: baseline;
  gap: 0.7em;
  font-family: var(--md-code-font);
  font-size: 0.8em;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--xh-fg-2);
  transform: translateX(-50%);
}

.xh .xh-infra__cloudh b {
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--xh-teal-text);
}

/* Kubernetes: the cluster a node and its kernels run in. A cloud holds one or
   more of them. */

.xh .xh-infra__k8ss {
  display: grid;
  grid-template-columns: repeat(var(--n, 1), minmax(0, 1fr));
  gap: var(--xh-k8s-gap);
}

.xh .xh-infra__k8s {
  position: relative;
  padding: var(--xh-k8s-pt) var(--xh-k8s-px) 1.85em;
  border: 1px solid color-mix(in srgb, var(--xh-fg-3) 55%, var(--xh-line));
  border-radius: 1.1em;
  background: color-mix(in srgb, var(--xh-bg) 70%, transparent);
  transition: opacity 0.55s ease, border-color 0.55s ease, filter 0.55s ease;
}

.xh .xh-infra__k8sh {
  position: absolute;
  right: 0;
  bottom: 0.5em;
  left: 0;
  font-family: var(--md-code-font);
  font-size: 0.68em;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--xh-fg-3);
}

/* A node, and a kernel: the same box, so neither outweighs the other. */

.xh .xh-infra__node,
.xh .xh-infra__k {
  padding: 0.7em 0.7em 0.78em;
}

.xh .xh-infra__node > b,
.xh .xh-infra__k > b {
  display: block;
  font-size: 0.98em;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
  color: var(--xh-fg);
}

.xh .xh-infra__k {
  border-color: color-mix(in srgb, var(--xh-teal) 62%, var(--xh-line));
  background: color-mix(in srgb, var(--xh-teal) 10%, var(--xh-bg-card));
}

.xh .xh-infra__k > b {
  color: var(--xh-teal-text);
}

/* A cluster whose one node supervises two kernels: its columns are as wide
   as a single-kernel cluster, so every box in the picture matches. */
.xh .xh-infra__k8s--two .xh-infra__node {
  width: calc((100% - var(--xh-k8s-gap) - 2 * var(--xh-k8s-px)) / 2);
  margin: 0 auto;
}

.xh .xh-infra__k8s--two .xh-infra__rts {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: calc(var(--xh-k8s-gap) + 2 * var(--xh-k8s-px));
}

/* The lane a node opens to the control plane. It belongs to the node, and it
   is the only way anything crosses the cloud boundary. */

.xh .xh-infra__lane {
  position: absolute;
  bottom: 100%;
  left: 50%;
  width: 2px;
  height: calc(var(--xh-gap) + var(--xh-cloud-pt) + var(--xh-k8s-pt) + 3px);
  margin-left: -1px;
  background: var(--xh-line);
  transition: opacity 0.55s ease, background-color 0.55s ease;
}

/* The arrowhead points the way the connection is opened. */
.xh .xh-infra__lane::before {
  content: "";
  position: absolute;
  top: 0.1em;
  left: 50%;
  width: 0.68em;
  height: 0.68em;
  margin-left: -0.34em;
  border-top: 2px solid var(--xh-teal);
  border-left: 2px solid var(--xh-teal);
  transform: rotate(45deg);
}

.xh .xh-infra__lane.is-on,
.xh .xh-scene:not([data-armed]) .xh-infra__lane {
  background: color-mix(in srgb, var(--xh-teal) 60%, var(--xh-line));
}

/* What travels. */
.xh .xh-infra__lane > i,
.xh .xh-infra__link > i,
.xh .xh-infra__fork > i {
  position: absolute;
  left: 50%;
  width: 0.7em;
  height: 0.7em;
  margin-left: -0.35em;
  border-radius: 50%;
  background: var(--xr-teal-bright);
  box-shadow: 0 0 0 0.26em color-mix(in srgb, var(--xh-teal) 22%, transparent),
              0 0 1em color-mix(in srgb, var(--xh-teal) 75%, transparent);
  opacity: 0;
}

/* The signed assignment coming back: a document, not a dot. */
.xh .xh-infra__lane > i.xh-infra__env {
  width: 1.4em;
  height: 0.96em;
  margin-left: -0.7em;
  border: 1.5px solid var(--xr-teal-bright);
  border-radius: 0.2em;
  background: var(--xh-deep);
}

/* Evidence metadata going up: smaller, and only from step six. */
.xh .xh-infra__lane > i.xh-infra__ev {
  width: 0.46em;
  height: 0.46em;
  margin-left: -0.23em;
  box-shadow: none;
}

.xh .xh-infra__lane.is-on > i:not(.xh-infra__ev),
.xh .xh-scene:not([data-armed]) .xh-infra__lane > i:not(.xh-infra__ev) {
  animation: xh-go-up 5.2s cubic-bezier(0.45, 0, 0.25, 1) infinite;
  animation-delay: var(--d, 0s);
}

.xh .xh-infra__lane.is-on > i.xh-infra__env,
.xh .xh-scene:not([data-armed]) .xh-infra__lane > i.xh-infra__env {
  animation-name: xh-come-down;
}

.xh .xh-scene.is-s6 .xh-infra__lane > i.xh-infra__ev,
.xh .xh-scene:not([data-armed]) .xh-infra__lane > i.xh-infra__ev {
  animation: xh-rise 2.6s linear infinite;
  animation-delay: calc(var(--d, 0s) + 0.9s);
}

@keyframes xh-go-up {
  0%        { top: calc(100% - 0.8em); opacity: 0; }
  6%        { opacity: 1; }
  40%       { top: 0.5em; opacity: 1; }
  46%, 100% { top: 0.3em; opacity: 0; }
}

@keyframes xh-come-down {
  0%, 48%   { top: 0.3em; opacity: 0; }
  54%       { top: 0.5em; opacity: 1; }
  90%       { top: calc(100% - 1.2em); opacity: 1; }
  97%, 100% { top: calc(100% - 1em); opacity: 0; }
}

@keyframes xh-rise {
  0%        { top: calc(100% - 0.6em); opacity: 0; }
  12%       { opacity: 0.9; }
  84%       { top: 0.6em; opacity: 0.9; }
  94%, 100% { top: 0.4em; opacity: 0; }
}

/* From a node down to the kernels it supervises. */

.xh .xh-infra__link,
.xh .xh-infra__fork {
  position: relative;
  height: 2.7em;
  transition: opacity 0.55s ease;
}

.xh .xh-infra__link::before,
.xh .xh-infra__fork::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: var(--xh-line);
}

/* One node, two kernels: the line divides. */
.xh .xh-infra__fork::before {
  bottom: 50%;
}

.xh .xh-infra__fork::after {
  content: "";
  position: absolute;
  top: 50%;
  bottom: 0;
  left: calc((100% - var(--xh-k8s-gap) - 2 * var(--xh-k8s-px)) / 4);
  right: calc((100% - var(--xh-k8s-gap) - 2 * var(--xh-k8s-px)) / 4);
  margin: -1px -1px 0;
  border: 2px solid var(--xh-line);
  border-bottom: 0;
  border-radius: 0.5em 0.5em 0 0;
}

.xh .xh-scene.is-s5 .xh-infra__link::before,
.xh .xh-scene.is-s5 .xh-infra__fork::before,
.xh .xh-scene:not([data-armed]) .xh-infra__link::before,
.xh .xh-scene:not([data-armed]) .xh-infra__fork::before {
  background: color-mix(in srgb, var(--xh-teal) 60%, var(--xh-line));
}

.xh .xh-scene.is-s5 .xh-infra__fork::after,
.xh .xh-scene:not([data-armed]) .xh-infra__fork::after {
  border-color: color-mix(in srgb, var(--xh-teal) 60%, var(--xh-line));
}

.xh .xh-scene.is-s5 .xh-infra__link > i,
.xh .xh-scene:not([data-armed]) .xh-infra__link > i {
  animation: xh-link-down 3.4s cubic-bezier(0.45, 0, 0.25, 1) infinite;
  animation-delay: var(--d, 0s);
}

.xh .xh-infra__fork > i:first-child { left: calc((100% - var(--xh-k8s-gap) - 2 * var(--xh-k8s-px)) / 4); }
.xh .xh-infra__fork > i:last-child  { left: calc(100% - (100% - var(--xh-k8s-gap) - 2 * var(--xh-k8s-px)) / 4); }

.xh .xh-scene.is-s5 .xh-infra__fork > i,
.xh .xh-scene:not([data-armed]) .xh-infra__fork > i {
  animation: xh-fork-down 3.4s cubic-bezier(0.45, 0, 0.25, 1) infinite;
  animation-delay: var(--d, 0s);
}

.xh .xh-infra__fork > i:last-child {
  animation-delay: calc(var(--d, 0s) + 1.2s) !important;
}

@keyframes xh-link-down {
  0%        { top: -0.2em; opacity: 0; }
  10%       { opacity: 1; }
  52%       { top: calc(100% - 0.65em); opacity: 1; }
  62%, 100% { top: calc(100% - 0.65em); opacity: 0; }
}

@keyframes xh-fork-down {
  0%        { top: calc(50% - 0.35em); opacity: 0; }
  10%       { opacity: 1; }
  42%       { top: calc(100% - 0.65em); opacity: 1; }
  52%, 100% { top: calc(100% - 0.65em); opacity: 0; }
}

.xh .xh-infra__rt {
  transition: opacity 0.55s ease, filter 0.55s ease;
}

/* A pool: one name shared by the nodes it groups. */

.xh .xh-infra__poolb {
  position: relative;
  height: 1.7em;
  margin: 0.55em 0.5em 0;
  transition: opacity 0.55s ease, filter 0.55s ease;
}

.xh .xh-infra__poolb::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 0.6em;
  border: 1px solid color-mix(in srgb, var(--xh-fg-3) 70%, var(--xh-line));
  border-top: 0;
  border-radius: 0 0 0.6em 0.6em;
}

.xh .xh-infra__poolb > span {
  position: absolute;
  top: 0;
  left: 50%;
  padding: 0 0.7em;
  background: color-mix(in srgb, var(--xh-teal) 4%, var(--xh-deep));
  font-family: var(--md-code-font);
  font-size: 0.76em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--xh-fg-3);
  transform: translateX(-50%);
}

.xh .xh-infra__poolb > span b {
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--xh-fg);
}

/* The systems you already run: bytes, secrets and payloads stay with them. */

.xh .xh-infra__sys {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4em;
  margin-top: 0.5em;
}

.xh .xh-infra__sysi {
  padding: 0.58em 0.3em;
  border: 1px solid var(--xh-line);
  border-radius: 0.7em;
  background: var(--xh-bg-card);
  font-size: 0.84em;
  line-height: 1.25;
  text-align: center;
  color: var(--xh-fg-2);
  transition: opacity 0.55s ease, border-color 0.55s ease, filter 0.55s ease,
              box-shadow 0.55s ease;
}

.xh .xh-infra__sysi b {
  display: block;
  font-weight: 620;
  color: var(--xh-fg);
}

/* The key: what each moving mark is, kept clear of the lanes. */

.xh .xh-infra__key {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5em 1.9em;
  margin-top: 1.5em;
  font-family: var(--md-code-font);
  font-size: 0.76em;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--xh-fg-2);
}

.xh .xh-infra__key > span {
  display: inline-flex;
  align-items: center;
  gap: 0.7em;
  transition: opacity 0.55s ease, filter 0.55s ease;
}

.xh .xh-infra__key i {
  flex: none;
  display: block;
  width: 0.92em;
  height: 0.92em;
  border-radius: 50%;
  background: var(--xr-teal-bright);
}

.xh .xh-infra__key i.is-env {
  width: 1.75em;
  height: 1.2em;
  border: 1.5px solid var(--xr-teal-bright);
  border-radius: 0.24em;
  background: none;
}

.xh .xh-infra__key i.is-ev {
  width: 0.56em;
  height: 0.56em;
}

.xh .xh-infra__key i.is-no {
  width: 1.5em;
  height: 1.5em;
  border: 1.5px solid var(--xh-warn);
  background: none;
  font-style: normal;
  font-weight: 600;
  line-height: 1.32em;
  letter-spacing: 0;
  text-align: center;
  color: var(--xh-warn);
}

/* Lit, dim, and in focus ----------------------------------------------------
   Everything inside your cloud is drawn as soon as the cloud is: clusters,
   nodes, kernels and your own systems. A part that is not glowing is still
   plainly there. Only what arrives later (a pull, a push that is refused,
   the note about evidence) waits for its step. */

.xh .xh-scene[data-armed] [data-from]:not(.is-on) {
  opacity: 0.22;
  filter: saturate(0);
}

.xh .xh-scene[data-armed] .xh-infra__box.is-now,
.xh .xh-scene[data-armed] .xh-infra__sysi.is-now,
.xh .xh-scene[data-armed] .xh-infra__rt.is-now .xh-infra__k {
  border-color: var(--xh-teal);
  box-shadow: 0 0 0 0.26em color-mix(in srgb, var(--xh-teal) 13%, transparent),
              0 1.4em 3.6em -1.5em color-mix(in srgb, var(--xh-teal) 85%, transparent);
}

.xh .xh-scene[data-armed] .xh-infra__cloud.is-now,
.xh .xh-scene[data-armed] .xh-infra__k8s.is-now {
  border-color: var(--xh-teal);
}

/* Step four is about a side, not a box: the whole of your cloud lights, and
   everything in it lights the same way, the kernels with the rest. */
.xh .xh-scene[data-armed][data-step="4"] .xh-infra__cloud {
  border-style: solid;
  border-color: var(--xh-teal);
  background: color-mix(in srgb, var(--xh-teal) 9%, var(--xh-deep));
  box-shadow: 0 0 0 0.3em color-mix(in srgb, var(--xh-teal) 11%, transparent),
              0 1.8em 4.6em -1.8em color-mix(in srgb, var(--xh-teal) 80%, transparent);
}

.xh .xh-scene[data-armed][data-step="4"] .xh-infra__cloud .xh-infra__box,
.xh .xh-scene[data-armed][data-step="4"] .xh-infra__cloud .xh-infra__sysi,
.xh .xh-scene[data-armed][data-step="4"] .xh-infra__cloud .xh-infra__k8s {
  border-color: color-mix(in srgb, var(--xh-teal) 80%, var(--xh-line));
}

.xh .xh-scene[data-armed][data-step="4"] .xh-infra__poolb > span {
  background: color-mix(in srgb, var(--xh-teal) 9%, var(--xh-deep));
}

/* Zoom: everything but one kernel leaves; that kernel takes the screen -------
   The kernel comes forward first, brighter and with light round it, while
   the rest goes; it stays lit as it grows, and opens only after that. */

.xh .xh-scene.is-zooming .xh-infra {
  will-change: transform;
}

.xh .xh-scene.is-zooming [data-fade] {
  opacity: calc(1 - var(--xh-z2)) !important;
  transition: none;
}

.xh .xh-scene.is-zooming .xh-infra__cloud,
.xh .xh-scene.is-zooming .xh-infra__k8s {
  border-color: color-mix(in srgb, var(--xh-teal) calc((1 - var(--xh-z2)) * 50%), transparent);
  background: none;
  transition: none;
}

.xh .xh-scene.is-zooming .xh-infra__cloudh,
.xh .xh-scene.is-zooming .xh-infra__k8sh {
  opacity: calc(1 - var(--xh-z2));
}

.xh .xh-scene.is-zooming [data-xh-zoom] {
  border-color: color-mix(in srgb, var(--xh-teal-2) calc((1 - var(--xh-z3)) * 100%), transparent);
  background: color-mix(in srgb, var(--xh-deep) calc(var(--xh-z3) * 100%),
              color-mix(in srgb, var(--xh-teal) calc(10% + var(--xh-zf) * 14%), var(--xh-bg-card)));
  box-shadow: 0 0 0 calc(var(--xh-zf) * 0.22em)
                color-mix(in srgb, var(--xh-teal) calc((1 - var(--xh-z3)) * 26%), transparent),
              0 0 calc(var(--xh-zf) * 3.4em) calc(var(--xh-zf) * 0.3em)
                color-mix(in srgb, var(--xh-teal) calc((1 - var(--xh-z3)) * 50%), transparent) !important;
  transition: none;
}

.xh .xh-scene.is-zooming [data-xh-zoom] > * {
  opacity: calc(1 - var(--xh-z3));
}

/* ==========================================================================
   The operating-system diagram: what the zoom lands on

   The kernel the reader zoomed into opens into this picture: one operating
   system, drawn the way an operating system is drawn. From the machine up:

     hardware             the machine, under the system
     the kernel stack     one block, its layers bound together:
                            Linux, the hardware and machine kernel
                            the XCK nucleus host, stitched directly onto it
                            the XCK nucleus core, the kernel for agentic
                            authority
                            enforcement, evidence and scoring, which are
                            first class in the kernel and act on every action
                            the syscall surface, where applications enter
     cell monitors        the trusted guest boundary, one per cell
     the typed boundary   the one line calls cross
     cells                where agents and blocks run, untrusted

   Linux is inside the frame, as the base layer of the kernel stack. It is
   never drawn as a separate box that XCK sits on: XCK is a kernel built for
   Linux, and the two make one system.

   While the scene is driven, the panel is pinned over the stage and home.js
   keeps the diagram's XCK frame exactly over the kernel box as it grows, so
   one becomes the other. Otherwise the diagram is an ordinary block under
   the steps, drawn complete.
   ========================================================================== */

/* The panel follows the steps and the stage in the page. While the scene is
   driven it shares their grid cell instead, pinned over them for the whole
   of the scene. */
.xh .xh-scene .xh-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.xh .xh-scene__os {
  margin: 3rem 0 4rem;
  container-type: inline-size;
  pointer-events: none;
}

.xh .xh-scene[data-armed] .xh-scene__grid {
  grid-area: 1 / 1;
}

.xh .xh-scene[data-armed] .xh-scene__os {
  grid-area: 1 / 1;
  position: sticky;
  top: 2.9rem;
  z-index: 3;
  display: flex;
  align-items: center;
  align-self: start;
  height: calc(100vh - 2.9rem);
  margin: 0;
}

.xh .xh-os {
  --xh-os-bg: color-mix(in srgb, var(--xh-teal) 7%, var(--xh-deep));
  position: relative;
  width: 100%;
  max-width: 68em;
  margin: 0 auto;
  font-size: min(1.8vh, 1.25vw);
  font-size: min(1.8vh, 1.47cqw);
  line-height: 1.4;
  letter-spacing: 0;
}

.xh .xh-scene[data-armed] .xh-os {
  opacity: var(--xh-o, 0);
}

.xh .xh-scene.is-zooming .xh-os {
  will-change: transform, opacity;
}

/* XCK: the frame the kernel box turns into. */

.xh .xh-os__xck {
  position: relative;
  padding: 0.85em 1.2em 1.05em;
  border: 1.5px solid color-mix(in srgb, var(--xh-teal) 78%, var(--xh-line));
  border-radius: 1.3em;
  background: var(--xh-os-bg);
  box-shadow: 0 0 0 0.35em color-mix(in srgb, var(--xh-teal) 9%, transparent),
              0 2em 6em -2.6em color-mix(in srgb, var(--xh-teal) 85%, transparent);
}

.xh .xh-os__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.1em 1em;
}

.xh .xh-os__head > b {
  font-size: 1.95em;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--xh-teal-text);
}

.xh .xh-os__head > span,
.xh .xh-os__head > i,
.xh .xh-os__bandh,
.xh .xh-os__sub {
  font-family: var(--md-code-font);
  font-size: 0.72em;
  font-style: normal;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--xh-fg-2);
}

.xh .xh-os__head > i {
  margin-left: auto;
  color: var(--xh-fg-3);
}

.xh .xh-os__head > i b {
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--xh-fg);
}

/* The two sides of the boundary. */

.xh .xh-os__band {
  margin-top: 0.6em;
}

.xh .xh-os__bandh {
  display: block;
  margin-bottom: 0.45em;
  color: var(--xh-fg-3);
}

.xh .xh-os__bandh b {
  margin-left: 0.7em;
  font-weight: 700;
}

.xh .xh-os__band--guest .xh-os__bandh b { color: var(--xh-warn); }
.xh .xh-os__band--kernel .xh-os__bandh b { color: var(--xh-teal-text); }

.xh .xh-os__cols {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1em;
}

/* A cell: untrusted guest code, held by the kernel. */
.xh .xh-os__cell {
  padding: 0.5em 0.8em 0.58em;
  border: 1px dashed color-mix(in srgb, var(--xh-warn) 45%, var(--xh-line));
  border-radius: 0.8em;
  background: color-mix(in srgb, var(--xh-bg) 60%, transparent);
}

.xh .xh-os__cell > b > span {
  margin-right: 0.8em;
  font-family: var(--md-code-font);
  font-size: 0.66em;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--xh-fg-3);
}

.xh .xh-os__cell > b,
.xh .xh-os__mon > b {
  display: block;
  font-size: 1.02em;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--xh-fg);
}

.xh .xh-os__cell > em,
.xh .xh-os__mon > em {
  display: block;
  margin-top: 0.1em;
  font-size: 0.8em;
  font-style: normal;
  line-height: 1.35;
  color: var(--xh-fg-2);
}

/* The typed boundary: one line across the whole of XCK. Calls cross it on
   the wires, through a monitor, and nowhere else. */

.xh .xh-os__edge {
  position: relative;
  height: 2.7em;
}

.xh .xh-os__edge > .xh-os__cols {
  position: absolute;
  inset: 0;
}

.xh .xh-os__wire {
  position: relative;
  justify-self: center;
  width: 2px;
  height: 100%;
  background: color-mix(in srgb, var(--xh-teal) 55%, var(--xh-line));
}

/* The middle crossing sits behind the boundary's label. */
.xh .xh-os__wire--behind {
  visibility: hidden;
}

.xh .xh-os__edgeline {
  position: absolute;
  top: 50%;
  right: -1.2em;
  left: -1.2em;
  height: 2px;
  margin-top: -1px;
  background: var(--xh-line);
}

.xh .xh-os__edgeline::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
              var(--xr-teal) 0,
              var(--xr-teal-bright) 50%,
              var(--xr-teal) 100%);
  transform-origin: center;
}

.xh .xh-os__edgeh {
  position: absolute;
  top: 50%;
  left: 50%;
  padding: 0.3em 1em;
  border-radius: 999px;
  background: var(--xh-os-bg);
  font-family: var(--md-code-font);
  font-size: 0.72em;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.1em;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--xh-teal-text);
  transform: translate(-50%, -50%);
}

.xh .xh-os__edgeh b {
  margin-left: 1em;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--xh-fg-2);
}

/* The trusted side: a monitor in front of every cell, then the nucleus. */

.xh .xh-os__mon {
  padding: 0.42em 0.8em 0.5em;
  border: 1px solid color-mix(in srgb, var(--xh-teal) 50%, var(--xh-line));
  border-radius: 0.8em;
  background: var(--xh-bg-card);
}

.xh .xh-os__cols--wires {
  height: 1.1em;
}

.xh .xh-os__nuc {
  border: 1px solid color-mix(in srgb, var(--xh-teal) 70%, var(--xh-line));
  border-radius: 0.9em;
  background: color-mix(in srgb, var(--xh-teal) 12%, var(--xh-bg-card));
}

.xh .xh-os__layer {
  padding: 0.55em 0.9em 0.65em;
}

.xh .xh-os__layer + .xh-os__layer {
  border-top: 1px solid color-mix(in srgb, var(--xh-teal) 35%, var(--xh-line));
}

.xh .xh-os__layerh {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.1em 0.9em;
  margin-bottom: 0.4em;
}

.xh .xh-os__layerh > b {
  font-size: 1.06em;
  font-weight: 670;
  letter-spacing: -0.012em;
  color: var(--xh-teal-text);
}

.xh .xh-os__nuc {
  overflow: hidden;
}

/* A layer told in one line: its name, what it is, and what it handles. */
.xh .xh-os__layer--flat {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.9em;
  padding: 0.45em 0.9em 0.5em;
}

.xh .xh-os__layer--flat > b {
  font-size: 1.06em;
  font-weight: 670;
  letter-spacing: -0.012em;
  color: var(--xh-teal-text);
}

.xh .xh-os__layer--flat > .xh-os__prims {
  flex: 1 1 auto;
}

/* The syscall surface: the top of the kernel, where an application's request
   enters it. */
.xh .xh-os__layer--sys {
  background: color-mix(in srgb, var(--xh-teal) 22%, var(--xh-bg-card));
}

.xh .xh-os__layer--sys > .xh-os__prims {
  color: var(--xh-fg);
}

/* First-class functions: a name, and what it is made of. */
.xh .xh-os__tiles--two > span {
  flex-direction: column;
  min-height: 3em;
  border-color: color-mix(in srgb, var(--xh-teal) 45%, var(--xh-line));
  color: var(--xh-fg-2);
}

.xh .xh-os__tiles--two > span > b {
  font-family: var(--md-text-font);
  font-size: 1.3em;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--xh-fg);
}

/* Linux: the base layer of the same block. Neutral where XCK is teal, and
   stitched to the nucleus host across the line between them, because the
   host is built directly onto it. */
.xh .xh-os__layer--linux {
  position: relative;
  background: var(--xh-bg-card);
}

.xh .xh-os__layer--linux::before {
  content: "";
  position: absolute;
  top: -0.36em;
  right: 0.9em;
  left: 0.9em;
  height: 0.72em;
  background: repeating-linear-gradient(90deg,
              color-mix(in srgb, var(--xh-teal) 75%, var(--xh-line)) 0,
              color-mix(in srgb, var(--xh-teal) 75%, var(--xh-line)) 2px,
              transparent 2px, transparent 1.15em);
}

.xh .xh-os__layer--linux > b {
  color: var(--xh-fg);
}

.xh .xh-os__prims {
  margin: 0;
  font-family: var(--md-code-font);
  font-size: 0.76em;
  line-height: 1.5;
  color: var(--xh-fg-2);
}

/* Subsystems: drawn as blocks, the way a kernel map is drawn. */
.xh .xh-os__tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.4em;
}

.xh .xh-os__tiles > span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.1em;
  padding: 0.25em 0.5em;
  border: 1px solid var(--xh-line);
  border-radius: 0.45em;
  background: var(--xh-bg);
  font-family: var(--md-code-font);
  font-size: 0.72em;
  line-height: 1.25;
  text-align: center;
  color: var(--xh-fg);
}

/* Under the system: the hardware. */

.xh .xh-os__slab {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15em 1.1em;
  margin-top: 0.45em;
  padding: 0.5em 1.2em 0.6em;
  border: 1px solid var(--xh-line);
  border-radius: 0.9em;
  background: var(--xh-bg-card);
}

.xh .xh-os__slab > b {
  font-size: 1.12em;
  font-weight: 660;
  letter-spacing: -0.012em;
  color: var(--xh-fg);
}

.xh .xh-os__slab > p {
  flex: 1 1 auto;
  margin: 0;
  font-family: var(--md-code-font);
  font-size: 0.74em;
  line-height: 1.55;
  color: var(--xh-fg-2);
}

.xh .xh-os__slab--hw {
  border-style: solid;
  background:
    repeating-linear-gradient(135deg,
      color-mix(in srgb, var(--xh-line) 60%, transparent) 0,
      color-mix(in srgb, var(--xh-line) 60%, transparent) 1px,
      transparent 1px, transparent 7px),
    var(--xh-bg);
}

.xh .xh-os__slab--hw > b {
  color: var(--xh-fg-2);
}

/* What moves: one call, from a cell down through its monitor into the
   nucleus, and from the nucleus up through another monitor into another
   cell. Execution crosses the boundary through the kernel, both ways. */

.xh .xh-os__wire > i {
  position: absolute;
  left: 50%;
  width: 0.62em;
  height: 0.62em;
  margin-left: -0.31em;
  border-radius: 50%;
  background: var(--xr-teal-bright);
  box-shadow: 0 0 0 0.24em color-mix(in srgb, var(--xh-teal) 22%, transparent),
              0 0 0.9em color-mix(in srgb, var(--xh-teal) 75%, transparent);
  opacity: 0;
}

.xh .xh-scene.is-os .xh-os__wire--a > i,
.xh .xh-scene:not([data-armed]) .xh-os__wire--a > i { animation: xh-os-a 6.4s linear infinite; }
.xh .xh-scene.is-os .xh-os__wire--b > i,
.xh .xh-scene:not([data-armed]) .xh-os__wire--b > i { animation: xh-os-b 6.4s linear infinite; }
.xh .xh-scene.is-os .xh-os__wire--c > i,
.xh .xh-scene:not([data-armed]) .xh-os__wire--c > i { animation: xh-os-c 6.4s linear infinite; }
.xh .xh-scene.is-os .xh-os__wire--d > i,
.xh .xh-scene:not([data-armed]) .xh-os__wire--d > i { animation: xh-os-d 6.4s linear infinite; }

@keyframes xh-os-a {
  0%        { top: -0.3em; opacity: 0; }
  2%        { opacity: 1; }
  16%       { top: calc(100% - 0.3em); opacity: 1; }
  19%, 100% { top: calc(100% - 0.3em); opacity: 0; }
}

@keyframes xh-os-b {
  0%, 21%   { top: -0.3em; opacity: 0; }
  23%       { opacity: 1; }
  31%       { top: calc(100% - 0.3em); opacity: 1; }
  34%, 100% { top: calc(100% - 0.3em); opacity: 0; }
}

@keyframes xh-os-c {
  0%, 47%   { top: calc(100% - 0.3em); opacity: 0; }
  49%       { opacity: 1; }
  57%       { top: -0.3em; opacity: 1; }
  60%, 100% { top: -0.3em; opacity: 0; }
}

@keyframes xh-os-d {
  0%, 62%   { top: calc(100% - 0.3em); opacity: 0; }
  64%       { opacity: 1; }
  78%       { top: -0.3em; opacity: 1; }
  81%, 100% { top: -0.3em; opacity: 0; }
}

/* Landing: once the kernel has opened, the strata light from the machine
   upwards, and the boundary line fills from its centre. */

.xh .xh-scene[data-armed] .xh-os [data-os] {
  opacity: 0.32;
  transition: opacity 0.6s ease;
}

.xh .xh-scene[data-armed].is-os .xh-os [data-os] {
  opacity: 1;
  transition-delay: calc(var(--n, 0) * 150ms);
}

.xh .xh-scene[data-armed] .xh-os__edgeline::after {
  transform: scaleX(0);
  transition: transform 1.3s cubic-bezier(0.45, 0, 0.2, 1);
}

.xh .xh-scene[data-armed].is-os .xh-os__edgeline::after {
  transform: scaleX(1);
  transition-delay: 0.75s;
}

/* Narrow screens: the picture first, complete, then the steps ---------------- */

@media screen and (max-width: 60em) {
  .xh-scene {
    padding: 3.4rem 0;
  }

  .xh .xh-scene__grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.6rem;
  }

  .xh .xh-scene__stage {
    position: static;
    order: -1;
    height: auto;
    padding: 0;
  }

  .xh .xh-infra {
    font-size: 1.55vw;
    font-size: 1.8cqw;
  }

  .xh .xh-scene__steps {
    padding: 0;
  }

  .xh .xh-step__t {
    font-size: 1.3rem;
  }

  .xh .xh-scene__os {
    margin: 2.2rem 0 0;
  }

  .xh .xh-os {
    font-size: 1.47cqw;
  }
}

@media screen and (max-width: 38em) {
  /* One cloud to a row, so the picture is half as many em wide. */
  .xh .xh-infra {
    font-size: 2.9vw;
    font-size: 3.1cqw;
  }

  .xh .xh-infra__clouds {
    grid-template-columns: minmax(0, 1fr);
    gap: 2.4em;
  }

  /* The second cloud's lane would cross the first cloud. */
  .xh .xh-infra__lane[data-cloud="b"] {
    display: none;
  }

  /* The operating-system diagram keeps its strata and lets its text wrap. */
  .xh .xh-os {
    max-width: none;
    font-size: 3.2vw;
    font-size: 3.5cqw;
  }

  .xh .xh-os__xck {
    padding: 0.9em 0.8em 0.9em;
  }

  .xh .xh-os__edgeline {
    right: -0.8em;
    left: -0.8em;
  }

  .xh .xh-os__cols {
    gap: 0.5em;
  }

  .xh .xh-os__edge {
    height: 4.6em;
  }

  .xh .xh-os__edgeh {
    white-space: normal;
    width: 62%;
    border-radius: 0.8em;
  }

  .xh .xh-os__edgeh b {
    display: block;
    margin: 0.15em 0 0;
  }

  .xh .xh-os__tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .xh .xh-os__head > i {
    margin-left: 0;
  }


}

@media (prefers-reduced-motion: reduce) {
  .xh .xh-infra__lane > i,
  .xh .xh-infra__link > i,
  .xh .xh-infra__fork > i,
  .xh .xh-os__wire > i {
    animation: none !important;
  }
}

@media print {
  .xh .xh-scene__stage {
    position: static;
    height: auto;
  }
}
