:root {
  --debug-label: "z: "counter(z)", depth: "counter(d);
}

/*
 * .zdepth draws the schematic engineering-line overlay (dashed borders)
 * together with each layer's z/depth readout — one unified view, no
 * separate "show class names instead" mode.
 */
.zdepth {
  & .root {
    --color: rgba(0, 0, 0, 0.7);
    --z: 0;
    --depth: 0; /* .root sits outside the --z/--depth grid entirely; 0/0 marks it as the coordinate origin */
  }
  & .offset {
    --color: rgba(255, 136, 0, 0.7);
  }
  & .ground,
  & .plaque {
    --color: hsla(120, 100%, 50%, 0.7);
  }
  & .outline {
    --color: hsla(165, 100%, 50%, 0.7);
  }
  & .inside {
    --color: hsla(210, 100%, 50%, 0.7);
  }
  & .podium.white {
    --color: hsla(255, 100%, 50%, 0.7);
  }
  & .podium.gray {
    --color: hsla(300, 100%, 50%, 0.7);
  }
  & .text.white {
    --color: hsla(345, 100%, 50%, 0.7);
  }
  & .text.black {
    --color: hsla(30, 100%, 50%, 0.7);
  }

  & .root,
  & .offset,
  & .plaque,
  & .outline,
  & .inside .front,
  & .podium .front,
  & .text {
    margin: -1px;
    border: 1px dashed var(--color);
    color: var(--color);
  }

  & .root::after,
  & .offset::after,
  & .ground::after,
  & .plaque::after,
  & .outline::after,
  & .inside::after,
  & .podium::after,
  & .text::after {
    position: absolute;
    display: block;
    left: 100%;
    counter-reset: z var(--z) d var(--depth);
    content: var(--debug-label);
    color: var(--color);
    border-bottom: 1px solid var(--color);
    font-family: "Montserrat", sans-serif;
    white-space: nowrap;
    font-size: 0.75rem;
    padding-left: 0.75rem;
    text-shadow: 0px 0px 2px rgba(0, 0, 0, 0.4);
  }

  & .root::after,
  & .offset::after,
  & .ground::after {
    left: auto;
    right: 100%;
    border-top: unset;
    border-bottom: 1px solid var(--color);
    padding-left: unset;
    padding-right: 0.75rem;
  }

  & .root::after,
  & .offset::after,
  & .ground::after {
    bottom: 0;
  }
  & .plaque::after {
    bottom: 60%;
  }
  & .outline::after {
    bottom: 55%;
    --x: 6;
    --y: 25;
  }
  & .inside::after {
    bottom: 50.4%;
    --x: 67;
    --y: 83;
  }
  & .podium.white::after {
    bottom: 45.3%;
    --x: -4;
    --y: 10;
  }
  & .podium.gray::after {
    bottom: 44.1%;
    --x: 8;
    --y: 20;
  }
  & .text.white::after {
    bottom: 32.3%;
    --x: 42;
    --y: 54;
  }
  & .text.black::after {
    bottom: 31.3%;
    --x: 53;
    --y: 63;
  }

  & .inside::after,
  & .podium::after {
    padding-left: calc(var(--y) * var(--u));
    left: calc(100% - var(--x) * var(--u));
  }
}

/*
 * while the logo is disassembled (js/explode.js), the layers' labels
 * would stay where the layers started, so each piece carries its own,
 * with its live z (front face) and depth, fading out with the piece
 */
.zdepth .root.disassembled {
  & .outline::after,
  & .text::after {
    display: none;
  }

  & .ground .base::after {
    counter-reset: z var(--live-z) d var(--live-depth);
    opacity: var(--fade, 1);
  }
}

/* the label itself, for the pieces that have no layer label to reuse (the
   outline's bars, the letters' strokes); :where() keeps it from overriding
   the placement of the layer pieces' labels (plaque, inside, podiums) */
:where(.zdepth .root.disassembled .ground .base)::after {
  position: absolute;
  display: block;
  left: 100%;
  content: var(--debug-label);
  color: var(--color);
  border-bottom: 1px solid var(--color);
  font-family: "Montserrat", sans-serif;
  white-space: nowrap;
  font-size: 0.75rem;
  padding-left: 0.75rem;
  text-shadow: 0px 0px 2px rgba(0, 0, 0, 0.4);
}
