.root {
  /* the logo square; every dimension below is a fraction of it, so it
     renders at full size from CSS alone, before (or without) JS */
  --logo-size: 100vmin;
  --u: calc(var(--logo-size) / 810); /* one world unit on the 810 grid */
  width: var(--logo-size);
  height: var(--logo-size);
  perspective: 800px;

  &,
  & * {
    transform-style: preserve-3d;
    box-sizing: content-box;
    --of: 810;
  }
}

.offset {
  width: 100%;
  height: 100%;
  --z: calc(var(--of) * -0.125);
  --depth: 0;
  transform: translateZ(calc(var(--z) * var(--u)));
}

/*
 * alternate static camera angles, for reference:
 *   original:       rotateX(-16.47deg) rotateY(40.68deg)
 *   normal:         rotateX(20deg) rotateY(20deg)
 *   front top:      rotateX(-65deg) rotateY(2deg)
 *   from top left:  rotateX(-34deg) rotateY(54deg)
 *   from top right: rotateX(-42.9deg) rotateY(-73.7deg)
 *   from right:     rotateX(-0.17deg) rotateY(-55deg)
 *   right edge:     rotateX(-0.475deg) rotateY(-18.525deg)
 *   from bottom left: rotateX(46deg) rotateY(45deg)
 */
.offset > .ground {
  position: relative;
  width: 100%;
  height: 100%;
  --z: 0;
  --depth: 0;
  /* head-on at rest (and without JS); the pointer tilts it from there */
  transform: none;
}

.ground * {
  position: absolute;
}
  .plaque,
  .outline,
  .text,
  .ground .base {
    width: 100%;
    height: 100%;
  }
  .inside,
  .outline,
  .text,
  .podium {
    transform: translateZ(calc(var(--u) * var(--z)));
  }

/*
 * every "base" element gets six faces (front/top/right/bottom/left/back),
 * positioned and sized from its --top/--left/--width/--height/--depth
 * custom properties, in world units on an --of (810) unit grid
 */
.base {
  & > .front,
  & > .back,
  & > .top,
  .outline > &,
  .text > & {
    top: calc(var(--u) * var(--top));
    left: calc(var(--u) * var(--left));
    width: calc(var(--u) * var(--width));
    height: calc(var(--u) * var(--height));
  }

  & > .back {
    transform: translateZ(calc(var(--u) * var(--depth) * -1)) rotateY(180deg);
  }

  & > .top {
    height: calc(var(--u) * var(--depth));
    transform-origin: top;
    transform: rotateX(90deg) translateY(calc(var(--u) * var(--depth) * -1));
  }

  & > .right {
    top: calc(var(--u) * var(--top));
    left: calc(var(--u) * (var(--left) + var(--width)));
    width: calc(var(--u) * var(--depth));
    height: calc(var(--u) * var(--height));
    transform-origin: left;
    transform: rotateY(90deg);
  }

  & > .bottom {
    top: calc(var(--u) * (var(--top) + var(--height)));
    left: calc(var(--u) * var(--left));
    width: calc(var(--u) * var(--width));
    height: calc(var(--u) * var(--depth));
    transform-origin: top;
    transform: rotateX(-90deg);
  }

  & > .left {
    top: calc(var(--u) * var(--top));
    left: calc(var(--u) * var(--left));
    width: calc(var(--u) * var(--depth));
    height: calc(var(--u) * var(--height));
    transform-origin: left;
    transform: rotateY(-90deg) translateX(calc(var(--u) * var(--depth) * -1));
  }
}

/*
 * .outline and .text wrap their .base children in an extra box (the
 * outline frame, the letterforms), so those children's faces are
 * repositioned relative to that wrapper instead of the world grid
 */
.outline .base,
.text .base {
  & > .front,
  & > .top,
  & > .back {
    top: 0;
    left: 0;
  }

  & > .right {
    height: 100%;
    top: 0;
    left: unset;
    right: 0;
    transform-origin: right;
    transform: rotateY(90deg) translateX(calc(var(--u) * var(--depth)));
  }

  & > .bottom {
    top: unset;
    bottom: 0;
    left: 0;
    width: 100%;
    height: calc(var(--u) * var(--depth));
    transform-origin: bottom;
    transform: rotateX(-90deg) translateY(calc(var(--u) * var(--depth)));
  }

  & > .left {
    top: 0;
    left: 0;
    height: 100%;
    transform-origin: left;
    transform: rotateY(-90deg) translateX(calc(var(--u) * var(--depth) * -1));
  }
}

/*
 * positional variables
 */
.plaque {
  --z: 0;
  --depth: calc(70 * var(--depth-scale, 1));

  &.base {
    --top: 0;
    --left: 0;
    --width: 810;
    --height: 810;

    & * {
      background-color: rgba(255, 255, 255, 0.25);
    }
  }
}

.inside {
  --top: 70;
  --left: 70;
  --width: 670;
  --height: 670;
  --z: calc(43 * var(--depth-scale, 1));
  --depth: calc(40 * var(--depth-scale, 1));

  & * {
    background-color: rgba(244, 244, 244, 0.5);
  }
}

.outline {
  --z: calc(23 * var(--depth-scale, 1));
  --depth: calc(20 * var(--depth-scale, 1));

  & .base * {
    background-color: rgba(68, 68, 68, 1);
  }

  & > .top,
  & > .bottom {
    --width: 790;
    --height: 50;
    --left: 10;
  }
  & > .top {
    --top: 10;
  }
  & > .bottom {
    --top: 750;
  }

  & > .right,
  & > .left {
    --width: 50;
    --height: 690;
    --top: 60;
  }
  & > .right {
    --left: 750;
  }
  & > .left {
    --left: 10;
  }
}

.podium.white {
  --top: 440;
  --left: 0;
  --width: 810;
  --height: 370;
  --z: calc(66 * var(--depth-scale, 1));
  --depth: calc(20 * var(--depth-scale, 1));

  & * {
    background-color: rgba(255, 255, 255, 1);
  }
}

.podium.gray {
  --top: 450;
  --left: 10;
  --width: 790;
  --height: 350;
  --z: calc(89 * var(--depth-scale, 1));
  --depth: calc(20 * var(--depth-scale, 1));

  & * {
    background-color: rgba(221, 221, 221, 1);
  }
}

.text.white {
  --z: calc(112 * var(--depth-scale, 1));
  --depth: calc(20 * var(--depth-scale, 1));

  & .base * {
    background-color: rgba(255, 255, 255, 1);
  }

  & .d1 { --top: 540; --left:  50; --width: 70; --height: 170; }
  & .d2 { --top: 540; --left: 120; --width: 30; --height:  70; }
  & .d3 { --top: 640; --left: 120; --width: 30; --height:  70; }
  & .d4 { --top:  60; --left: 150; --width: 70; --height: 650; }

  & .s1 { --top: 640; --left: 240; --width: 50; --height:  70; }
  & .s2 { --top: 540; --left: 290; --width: 70; --height: 170; }
  & .s3 { --top: 540; --left: 360; --width: 30; --height:  70; }

  & .u1 { --top: 540; --left: 390; --width: 70; --height: 170; }
  & .u2 { --top: 640; --left: 460; --width: 30; --height:  70; }
  & .u3 { --top: 540; --left: 490; --width: 70; --height: 170; }

  & .b1 { --top:  60; --left: 590; --width: 70; --height: 650; }
  & .b2 { --top: 540; --left: 660; --width: 30; --height:  70; }
  & .b3 { --top: 640; --left: 660; --width: 30; --height:  70; }
  & .b4 { --top: 540; --left: 690; --width: 70; --height: 170; }

  & .d4 .front, & .d4 .right, & .d4 .left, & .d4 .back,
  & .b1 .front, & .b1 .right, & .b1 .left, & .b1 .back {
    background: linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0) 0%,
      rgba(255, 255, 255, 1) 50%,
      rgba(255, 255, 255, 1) 100%
    );
  }
  & .d4 .top,
  & .b1 .top {
    background-color: transparent;
  }
  & .d4 .bottom,
  & .b1 .bottom {
    background-color: rgba(255, 255, 255, 1) !important;
  }

  & .back {
    box-shadow: 0 0 20px #444444;
  }
}

.text.black {
  --z: calc(135 * var(--depth-scale, 1));
  --depth: calc(20 * var(--depth-scale, 1));

  & .base * {
    background-color: rgba(0, 0, 0, 1);
  }

  & .d1 { --top: 550; --left:  60; --width: 50; --height: 150; }
  & .d2 { --top: 550; --left: 110; --width: 50; --height:  50; }
  & .d3 { --top: 650; --left: 110; --width: 50; --height:  50; }
  & .d4 { --top:  60; --left: 160; --width: 50; --height: 640; }

  & .s1 { --top: 650; --left: 250; --width: 50; --height:  50; }
  & .s2 { --top: 550; --left: 300; --width: 50; --height: 150; }
  & .s3 { --top: 550; --left: 350; --width: 50; --height:  50; }

  & .u1 { --top: 550; --left: 400; --width: 50; --height: 150; }
  & .u2 { --top: 650; --left: 450; --width: 50; --height:  50; }
  & .u3 { --top: 550; --left: 500; --width: 50; --height: 150; }

  & .b1 { --top:  60; --left: 600; --width: 50; --height: 640; }
  & .b2 { --top: 550; --left: 650; --width: 50; --height:  50; }
  & .b3 { --top: 650; --left: 650; --width: 50; --height:  50; }
  & .b4 { --top: 550; --left: 700; --width: 50; --height: 150; }

  & .d4 .front, & .d4 .right, & .d4 .left, & .d4 .back,
  & .b1 .front, & .b1 .right, & .b1 .left, & .b1 .back {
    background: linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0) 0%,
      rgba(0, 0, 0, 1) 50%,
      rgba(0, 0, 0, 1) 100%
    );
  }
  & .d4 .top,
  & .b1 .top {
    background-color: transparent;
  }
  & .d4 .bottom,
  & .b1 .bottom {
    background-color: rgba(0, 0, 0, 1) !important;
  }
}

/*
 * disassembly (js/explode.js): each piece moves with the individual
 * `translate` property, which composes with the transform its layer
 * already has. Fading goes on the faces, not the piece: opacity below 1
 * on a preserve-3d element flattens it into its own plane.
 */
.logo-js .root {
  cursor: pointer;
}
.ground .base > * {
  opacity: var(--fade, 1);
}
