:root {
  --genome-live-color: #77e4cf;
}

body.cristallo-genome-v3 {
  background: #030609;
}

.cristallo-genome-v3 .scene-count {
  display: none;
}

.scene.cristallo-genome {
  position: relative;
  display: block;
  width: 100%;
  height: 94svh;
  min-height: 680px;
  isolation: isolate;
  overflow: hidden;
  color: #f4f7fb;
  background:
    linear-gradient(rgba(124, 216, 207, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124, 216, 207, 0.025) 1px, transparent 1px),
    #030609;
  background-size: 54px 54px;
  touch-action: pan-y;
}

.scene.cristallo-genome::before {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(90deg, rgba(3, 6, 9, 0.8) 0%, transparent 23%, transparent 77%, rgba(3, 6, 9, 0.72) 100%),
    linear-gradient(0deg, rgba(3, 6, 9, 0.9) 0%, transparent 22%, rgba(3, 6, 9, 0.18) 68%, rgba(3, 6, 9, 0.7) 100%);
  content: "";
  pointer-events: none;
}

.scene.cristallo-genome::after {
  position: absolute;
  inset: auto 0 0;
  z-index: 2;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--genome-live-color), transparent);
  box-shadow: 0 0 18px color-mix(in srgb, var(--genome-live-color) 55%, transparent);
  content: "";
  opacity: 0.7;
}

#cristallo-genome-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

#cristallo-genome-canvas.is-dragging {
  cursor: grabbing;
}

.genome-intro {
  position: absolute;
  top: calc(var(--header-height) + 34px);
  left: var(--page-pad);
  z-index: 4;
  width: min(320px, calc(100% - (var(--page-pad) * 2)));
  pointer-events: none;
  transition: opacity 500ms var(--ease), transform 500ms var(--ease);
}

.genome-intro p,
.genome-intro h1,
.genome-intro span {
  margin: 0;
  letter-spacing: 0;
}

.genome-intro p {
  color: var(--genome-live-color);
  font-family: var(--display);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.genome-intro h1 {
  max-width: 260px;
  margin-top: 10px;
  font-family: var(--display);
  font-size: clamp(22px, 2.2vw, 34px);
  font-weight: 650;
  line-height: 1.02;
}

.genome-intro span {
  display: block;
  margin-top: 12px;
  color: rgba(244, 247, 251, 0.54);
  font-size: 12px;
}

.cristallo-genome.has-focus .genome-intro {
  opacity: 0.34;
  transform: translateY(-5px);
}

.genome-node-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.genome-node {
  --node-color: #77e4cf;
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--node-color) 54%, transparent);
  border-radius: 50%;
  color: #f4f7fb;
  background: rgba(3, 6, 9, 0.68);
  box-shadow:
    inset 0 0 0 6px rgba(3, 6, 9, 0.78),
    0 0 0 1px rgba(255, 255, 255, 0.02),
    0 0 18px color-mix(in srgb, var(--node-color) 18%, transparent);
  transform: translate(-50%, -50%);
  cursor: pointer;
  pointer-events: auto;
  transition:
    width 220ms var(--ease),
    height 220ms var(--ease),
    border-color 220ms var(--ease),
    box-shadow 220ms var(--ease),
    opacity 220ms var(--ease);
}

.genome-node::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--node-color);
  box-shadow: 0 0 12px var(--node-color);
  content: "";
}

.genome-node strong {
  position: absolute;
  top: 50%;
  left: calc(100% + 12px);
  display: block;
  width: max-content;
  max-width: 150px;
  color: #f4f7fb;
  font-family: var(--display);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  text-align: left;
  text-transform: uppercase;
  opacity: 0;
  transform: translate3d(-5px, -50%, 0);
  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
  pointer-events: none;
}

.genome-node[data-label-side="left"] strong {
  right: calc(100% + 12px);
  left: auto;
  text-align: right;
}

.genome-node:is(:hover, :focus-visible, .is-active) {
  width: 52px;
  height: 52px;
  border-color: var(--node-color);
  box-shadow:
    inset 0 0 0 8px rgba(3, 6, 9, 0.76),
    0 0 0 1px color-mix(in srgb, var(--node-color) 65%, transparent),
    0 0 30px color-mix(in srgb, var(--node-color) 42%, transparent);
  outline: none;
}

.genome-node:is(:hover, :focus-visible, .is-active) strong {
  opacity: 1;
  transform: translate3d(0, -50%, 0);
}

.genome-node.is-distant {
  opacity: 0.33;
}

.genome-node.is-related {
  opacity: 1;
}

.genome-node[data-genome-node="katoying"],
.genome-node[data-genome-node="cristallo"],
.genome-node[data-genome-node="gliding"] {
  width: 50px;
  height: 50px;
}

.genome-focus {
  position: absolute;
  right: var(--page-pad);
  bottom: 74px;
  z-index: 7;
  width: min(390px, calc(100% - (var(--page-pad) * 2)));
  padding: 22px 0 0 24px;
  border-top: 1px solid color-mix(in srgb, var(--genome-live-color) 58%, transparent);
  border-left: 1px solid color-mix(in srgb, var(--genome-live-color) 36%, transparent);
  background: linear-gradient(135deg, rgba(3, 6, 9, 0.92), rgba(3, 6, 9, 0.58));
  backdrop-filter: blur(16px);
}

.genome-focus[hidden] {
  display: none;
}

.genome-focus-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
}

.genome-focus-kicker,
.genome-focus-path,
.genome-focus-copy,
.genome-focus h2 {
  margin: 0;
  letter-spacing: 0;
}

.genome-focus-kicker {
  color: var(--genome-live-color);
  font-family: var(--display);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}

.genome-focus h2 {
  margin-top: 7px;
  font-family: var(--display);
  font-size: 25px;
  font-weight: 650;
  line-height: 1;
}

.genome-focus-close {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(244, 247, 251, 0.2);
  border-radius: 50%;
  color: #f4f7fb;
  background: rgba(3, 6, 9, 0.68);
  cursor: pointer;
}

.genome-focus-copy {
  max-width: 330px;
  margin-top: 14px;
  color: rgba(244, 247, 251, 0.7);
  font-size: 13px;
  line-height: 1.55;
}

.genome-focus-path {
  margin-top: 16px;
  overflow: hidden;
  color: rgba(244, 247, 251, 0.42);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 9px;
  line-height: 1.4;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.genome-enter {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  margin-top: 18px;
  padding: 0 18px;
  border: 1px solid color-mix(in srgb, var(--genome-live-color) 62%, transparent);
  color: #f4f7fb;
  font-family: var(--display);
  font-size: 11px;
  text-decoration: none;
  background: color-mix(in srgb, var(--genome-live-color) 10%, rgba(3, 6, 9, 0.82));
  transition: background-color 180ms var(--ease), color 180ms var(--ease);
}

.genome-enter:hover,
.genome-enter:focus-visible {
  color: #030609;
  background: var(--genome-live-color);
  outline: none;
}

.genome-controls {
  position: absolute;
  bottom: 30px;
  left: var(--page-pad);
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 8px;
}

.genome-controls button {
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(244, 247, 251, 0.18);
  border-radius: 50%;
  color: rgba(244, 247, 251, 0.78);
  background: rgba(3, 6, 9, 0.7);
  font-size: 17px;
  cursor: pointer;
  transition: border-color 180ms var(--ease), color 180ms var(--ease);
}

.genome-controls button:hover,
.genome-controls button:focus-visible {
  border-color: var(--genome-live-color);
  color: var(--genome-live-color);
  outline: none;
}

.genome-status {
  position: absolute;
  bottom: 40px;
  left: 50%;
  z-index: 4;
  margin: 0;
  color: rgba(244, 247, 251, 0.36);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 9px;
  letter-spacing: 0;
  text-transform: uppercase;
  transform: translateX(-50%);
  pointer-events: none;
}

.genome-status span {
  color: var(--genome-live-color);
}

.genome-outer-trace {
  position: absolute;
  right: var(--page-pad);
  bottom: 34px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: rgba(244, 247, 251, 0.52);
  font-family: var(--display);
  font-size: 10px;
  font-weight: 700;
  text-decoration: none;
  text-transform: uppercase;
}

.genome-outer-trace span {
  color: var(--genome-live-color);
  font-size: 17px;
}

.genome-outer-trace:hover,
.genome-outer-trace:focus-visible {
  color: #f4f7fb;
  outline: none;
}

@media (max-width: 760px) {
  .scene.cristallo-genome {
    height: 92svh;
    min-height: 610px;
  }

  .genome-intro {
    top: calc(var(--header-height) + 18px);
    left: 20px;
    width: 230px;
  }

  .genome-intro h1 {
    max-width: 210px;
    font-size: 23px;
  }

  .genome-intro span {
    font-size: 10px;
  }

  .genome-node {
    width: 34px;
    height: 34px;
    box-shadow:
      inset 0 0 0 5px rgba(3, 6, 9, 0.78),
      0 0 14px color-mix(in srgb, var(--node-color) 18%, transparent);
  }

  .genome-node[data-genome-node="katoying"],
  .genome-node[data-genome-node="cristallo"],
  .genome-node[data-genome-node="gliding"] {
    width: 40px;
    height: 40px;
  }

  .genome-node:is(:hover, :focus-visible, .is-active) {
    width: 44px;
    height: 44px;
  }

  .genome-node strong {
    left: calc(100% + 8px);
    max-width: 100px;
    font-size: 9px;
  }

  .genome-node[data-label-side="left"] strong {
    right: calc(100% + 8px);
  }

  .genome-focus {
    right: 18px;
    bottom: 70px;
    width: calc(100% - 36px);
    padding: 17px 0 0 18px;
  }

  .genome-focus h2 {
    font-size: 21px;
  }

  .genome-focus-copy {
    max-width: calc(100% - 20px);
    font-size: 12px;
  }

  .genome-focus-path {
    max-width: calc(100% - 20px);
  }

  .genome-controls {
    bottom: 22px;
    left: 18px;
  }

  .genome-controls button {
    width: 34px;
    height: 34px;
  }

  .genome-status {
    display: none;
  }

  .genome-outer-trace {
    right: 18px;
    bottom: 26px;
    font-size: 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .genome-intro,
  .genome-node,
  .genome-node strong,
  .genome-enter,
  .genome-controls button {
    transition: none;
  }
}
