:root {
  --bg: #000;
  --fg: rgba(255, 255, 255, 0.86);
  --fg-dim: rgba(255, 255, 255, 0.62);
  --panel: rgba(0, 0, 0, 0.5);
  --border: rgba(255, 255, 255, 0.12);
}

html,
body {
  height: 100%;
}

html {
  scrollbar-gutter: auto;
  background: var(--bg);
}

body {
  margin: 0;
  font-family: "DM Sans", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  overflow-x: hidden;
  overflow-y: hidden;
  opacity: 1;
  transition: opacity 220ms ease;
}

html.is-booting body {
  opacity: 0;
  pointer-events: none;
}

html.is-touch,
body.is-touch {
  overscroll-behavior: none;
}

body.is-touch {
  overflow-y: hidden;
  /* Keep touch scrolling available for the zoom description panel. */
  touch-action: pan-y;
}

#bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  background: #000;
  will-change: opacity;
}

#bg img {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  will-change: opacity, filter;
  /* Filter is driven continuously via JS vars (so grayscale + brightness stay in sync). */
  transition: none;
  filter: grayscale(var(--bg-gray, 0)) brightness(var(--bg-bright, 1)) contrast(var(--bg-contrast, 1));
}

#bg video {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  will-change: opacity, filter;
  opacity: 0;
  transition: opacity 240ms ease;
  filter: grayscale(var(--bg-gray, 0)) brightness(var(--bg-bright, 1)) contrast(var(--bg-contrast, 1));
}

#bg.is-page2-fit-landscape img,
#bg.is-page2-fit-landscape video {
  object-fit: contain;
  background: #000;
}

#bg video.is-ready {
  opacity: 1;
}

/* Zoom look is controlled by the CSS vars set in JS. */

#tone {
  position: fixed;
  inset: 0;
  /* Between DOM bg (0) and WebGL canvas (2): tones DOM bg without dimming cube gradients. */
  z-index: 1;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.3);
}

#tone::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.37;
  mix-blend-mode: multiply;
  /* 1px checkerboard (2px period), subtle brightness modulation. */
  background-image:
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.35) 0 1px,
      rgba(0, 0, 0, 0.10) 1px 2px
    ),
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.35) 0 1px,
      rgba(0, 0, 0, 0.10) 1px 2px
    );
  background-size: 2px 2px;
  background-position: 0 0, 1px 1px;
}

#app {
  position: fixed;
  inset: 0;
  z-index: 2;
}

#labels {
  position: fixed;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  color: rgba(255, 255, 255, 0.86);
  text-transform: lowercase;
  letter-spacing: 0.02em;
}

#zoom-content {
  position: fixed;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  opacity: 0;
  color: #fff;
  will-change: opacity;
  --zoom-t: 0;
  --zoom-head-t: 0;
  --zoom-body-t: 0;
  cursor: default;
}

#zoom-content .zoom-back {
  position: absolute;
  top: max(22px, calc(env(safe-area-inset-top) + 22px));
  left: max(22px, calc(env(safe-area-inset-left) + 22px));
  pointer-events: auto;
  opacity: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  font-family: "DM Sans", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  font-weight: 400;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  transition: opacity 160ms ease, color 160ms ease;
}

#labels .menu-toggle {
  position: absolute;
  top: max(22px, calc(env(safe-area-inset-top) + 22px));
  left: max(22px, calc(env(safe-area-inset-left) + 22px));
  z-index: 6;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  opacity: 1;
  transition: opacity 140ms ease, color 160ms ease;
}

#labels .menu-toggle *,
#labels .menu-toggle.is-open * {
  cursor: pointer;
}

#labels .menu-toggle:hover {
  color: rgba(255, 255, 255, 0.92);
}

#labels .menu-toggle:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.55);
  outline-offset: 3px;
}

#labels .menu-icon {
  position: relative;
  width: 22px;
  height: 2px;
  background: currentColor;
  transform-origin: center;
  transition: background-color 160ms ease;
  cursor: pointer;
}

#labels .menu-icon::before,
#labels .menu-icon::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: currentColor;
  transform-origin: center;
  transition: transform 220ms ease, top 220ms ease, opacity 180ms ease;
  cursor: pointer;
}

#labels .menu-icon::before {
  top: -7px;
}

#labels .menu-icon::after {
  top: 7px;
}

#labels .menu-toggle.is-open .menu-icon {
  background: transparent;
}

#labels .menu-toggle.is-open .menu-icon::before {
  top: 0;
  transform: rotate(45deg);
}

#labels .menu-toggle.is-open .menu-icon::after {
  top: 0;
  transform: rotate(-45deg);
}

.menu {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 50ms ease;
}

.menu.is-open {
  pointer-events: auto;
}

.menu .menu-inner {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  /* In landscape, keep the index close to center (symmetry: text left, cube right). */
  left: auto;
  right: calc(50% + 12px);
  width: min(44vw, 560px);
  max-width: calc(50vw - 24px);
  max-height: calc(100vh - max(120px, calc(env(safe-area-inset-top) + 120px)));
  overflow: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-right: 14px;
  text-align: right;
}

.menu .menu-inner::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.menu .menu-items {
  display: block;
}

.menu .menu-section {
  font-family: "DM Sans", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  font-size: 18px;
  margin: 18px 0 10px;
  color: rgba(255, 255, 255, 0.46);
}

.menu .menu-item {
  display: flex;
  width: 100%;
  align-items: baseline;
  justify-content: flex-end;
  gap: 12px;
  text-align: right;
  background: transparent;
  border: 0;
  padding: 8px 0;
  margin: 0;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.86);
  font-family: "DM Sans", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.menu .menu-item:hover {
  color: rgba(255, 255, 255, 0.98);
}


@media (max-aspect-ratio: 1/1) {
  .menu .menu-inner {
    top: max(74px, calc(env(safe-area-inset-top) + 74px));
    transform: none;
    left: max(22px, calc(env(safe-area-inset-left) + 22px));
    right: auto;
    width: calc(100vw - max(44px, calc(env(safe-area-inset-left) + env(safe-area-inset-right) + 44px)));
    max-width: none;
    max-height: calc(60vh - max(22px, calc(env(safe-area-inset-top) + 22px)));
    text-align: left;
  }

  .menu .menu-items {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 22px;
    row-gap: 2px;
    align-items: start;
  }

  .menu .menu-section {
    grid-column: 1 / -1;
    margin-top: 10px;
    margin-bottom: 4px;
  }

  .menu .menu-item {
    padding: 7px 0;
    font-size: 18px;
    justify-content: flex-start;
    text-align: left;
  }
}

#zoom-content .zoom-back:hover {
  color: rgba(255, 255, 255, 0.92);
}

#zoom-content .zoom-back:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.55);
  outline-offset: 3px;
}

#zoom-content .zoom-inner {
  position: absolute;
  left: 50%;
  top: 56%;
  transform: translateX(-50%);
  width: min(86vw, 820px);
  max-height: calc(100vh - 66% - 24px);
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  pointer-events: none;
  padding: 14px 8px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  --zoom-scroll-fade: 26px;
  -webkit-mask-image: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0%,
    rgba(0, 0, 0, 1) var(--zoom-scroll-fade),
    rgba(0, 0, 0, 1) calc(100% - var(--zoom-scroll-fade)),
    rgba(0, 0, 0, 0) 100%
  );
  mask-image: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0%,
    rgba(0, 0, 0, 1) var(--zoom-scroll-fade),
    rgba(0, 0, 0, 1) calc(100% - var(--zoom-scroll-fade)),
    rgba(0, 0, 0, 0) 100%
  );
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
}

#zoom-content.is-active .zoom-inner {
  pointer-events: auto;
}

#zoom-content .zoom-inner::-webkit-scrollbar {
  width: 0;
  height: 0;
}

#zoom-content .zoom-kicker {
  font-family: "DM Sans", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.12em;
  text-transform: lowercase;
  opacity: 1;
  margin-bottom: 10px;
  transform: translate3d(calc((1 - var(--zoom-head-t)) * -10vmin), 0, 0);
  will-change: transform;
}

#zoom-title {
  margin: 0 0 14px 0;
  font-family: "DM Sans", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  font-weight: 700;
  font-size: clamp(34px, 5vw, 62px);
  letter-spacing: 0.01em;
  line-height: 1.02;
  text-transform: lowercase;
  transform: translate3d(calc((1 - var(--zoom-head-t)) * -14vmin), 0, 0);
  will-change: transform;
}

#zoom-content .zoom-body {
  font-family: "DM Sans", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  font-weight: 400;
  font-size: clamp(14px, 1.6vw, 18px);
  line-height: 1.6;
  letter-spacing: 0.01em;
  color: #fff;
  transform: translate3d(calc((1 - var(--zoom-body-t)) * 14vmin), 0, 0);
  will-change: transform;
}

#zoom-content .zoom-body p {
  margin: 0 0 12px 0;
  color: #fff;
}

.label {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 820px);
  text-align: center;
  line-height: 1.1;
  font-family: "DM Sans", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

.label-top {
  top: max(28px, calc(env(safe-area-inset-top) + 28px));
  transform: translateX(-50%);
  position: absolute;
  display: block;
  height: clamp(30px, 4.1vw, 46px);
  --label-axis-offset: -10px; /* negative moves axis left */
}

.label-bottom {
  bottom: max(76px, calc(env(safe-area-inset-bottom) + 76px));
  transform: translateX(-50%);
  font-weight: 500;
  font-size: clamp(18px, 2.1vw, 26px);
  color: rgba(255, 255, 255, 0.72);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}

.label-left {
  top: max(22px, calc(env(safe-area-inset-top) + 22px));
  left: calc(max(22px, calc(env(safe-area-inset-left) + 22px)) + 52px);
  right: auto;
  transform: none;
  width: auto;
  text-align: left;
  font-weight: 500;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.76);
  text-transform: none;
  letter-spacing: 0.04em;
}

.label-left .label-layer {
  left: 0;
  right: auto;
}

.label-right {
  top: 50%;
  left: auto;
  right: max(22px, calc(env(safe-area-inset-right) + 22px));
  transform: translateY(-50%);
  width: auto;
  text-align: right;
  font-weight: 500;
  font-size: clamp(18px, 2.2vw, 26px);
  color: rgba(255, 255, 255, 0.72);
  text-transform: none;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}

.label-right .label-layer {
  left: auto;
  right: 0;
}

.label-layer {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  opacity: 0;
  will-change: opacity;
}

.label-top .label-slot {
  position: relative;
  box-sizing: border-box;
  min-width: 0;
  height: 100%;
  white-space: nowrap;
}

.label-top .label-slot-left {
  position: absolute;
  top: 0;
  left: 0;
  right: calc(50% - var(--label-axis-offset));
  padding-right: 8px;
  height: 100%;
  text-align: right;
}

.label-top .label-slot-right {
  position: absolute;
  top: 0;
  left: 50%;
  right: 0;
  padding-left: 8px;
  height: 100%;
  text-align: left;
}

.label-top .label-slot .label-layer {
  position: absolute;
  inset: 0;
  display: block;
  display: flex;
  align-items: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.label-top .label-slot-left .label-layer {
  justify-content: flex-end;
}

.label-top .label-slot-right .label-layer {
  justify-content: flex-start;
}

.label-top #sectionA,
.label-top #sectionB {
  font-weight: 600;
  font-size: clamp(22px, 3.1vw, 38px);
  letter-spacing: 0.02em;
}

.label-top #subA,
.label-top #subB {
  font-weight: 500;
  color: rgba(255, 255, 255, 0.62);
  font-size: clamp(22px, 3.1vw, 38px);
  letter-spacing: 0.02em;
}

.label-top #subA::before,
.label-top #subB::before {
  content: "/ ";
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#scroll-spacer {
  height: 0;
}

body.is-touch #scroll-spacer {
  height: 0 !important;
}

#zoom-content.is-active .zoom-inner {
  touch-action: pan-y;
}

/* Contact button (right side, mirrors burger menu on left) */

#labels .contact-toggle {
  position: absolute;
  top: max(22px, calc(env(safe-area-inset-top) + 22px));
  right: max(22px, calc(env(safe-area-inset-right) + 22px));
  left: auto;
  z-index: 6;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  opacity: 1;
  transition: opacity 140ms ease, color 160ms ease;
}

#labels .contact-toggle:hover {
  color: rgba(255, 255, 255, 0.92);
}

#labels .contact-toggle:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.55);
  outline-offset: 3px;
}

.contact-icon {
  font-family: "DM Sans", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  font-weight: 600;
  font-size: 20px;
  line-height: 1;
}

/* Contact panel (mirrors menu, but on the left side of the cube) */

.contact {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 50ms ease;
}

.contact.is-open {
  pointer-events: auto;
}

.contact .contact-inner {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: auto;
  left: calc(50% + 12px);
  width: min(44vw, 560px);
  max-width: calc(50vw - 24px);
  padding-left: 14px;
  text-align: left;
}

.contact .contact-section {
  font-family: "DM Sans", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  font-size: 18px;
  margin: 18px 0 10px;
  color: rgba(255, 255, 255, 0.46);
}

.contact .contact-link {
  display: block;
  background: transparent;
  border: 0;
  padding: 8px 0;
  margin: 0;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.86);
  font-family: "DM Sans", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0.01em;
  text-decoration: none;
  text-transform: lowercase;
}

.contact .contact-link:hover {
  color: rgba(255, 255, 255, 0.98);
}

@media (max-aspect-ratio: 1/1) {
  .contact .contact-inner {
    top: auto;
    bottom: max(74px, calc(env(safe-area-inset-bottom) + 74px));
    transform: none;
    left: max(22px, calc(env(safe-area-inset-left) + 22px));
    right: auto;
    width: calc(100vw - max(44px, calc(env(safe-area-inset-left) + env(safe-area-inset-right) + 44px)));
    max-width: none;
    text-align: left;
  }

  .contact .contact-link {
    padding: 7px 0;
    font-size: 18px;
  }
}

/* UI removed (speed slider/debug) */
