/*
 * The labels' x, y and z, one a line, in world units: a part each
 * (--debug-x, -y, -z), so a zero can be left out (unless all three are).
 * The style queries that do it compare numbers, so the positions are
 * registered as numbers (a calc() counts by its value). Browsers without
 * style queries show every value.
 */
@property --left {
  syntax: "<number>";
  inherits: true;
  initial-value: 0;
}
@property --top {
  syntax: "<number>";
  inherits: true;
  initial-value: 0;
}
@property --z {
  syntax: "<number>";
  inherits: true;
  initial-value: 0;
}
:root {
  --debug-x: "x: "counter(x);
  --debug-y: "\A y: "counter(y);
  --debug-z: "\A z: "counter(z);
}

/*
 * .zdepth (the X/Y/Z button) draws the schematic engineering-line overlay
 * (dashed borders) together with each layer's x/y/z readout (its --left,
 * --top and --z), and the tilted layer's rotation (--debug-rotation, set by
 * scene.js) — 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: x calc(var(--left)) y calc(var(--top)) z calc(var(--z));
    content: var(--debug-x) var(--debug-y) var(--debug-z);
    color: var(--color);
    border-bottom: 1px solid var(--color);
    font-family: "Montserrat", sans-serif;
    white-space: pre;
    font-size: 0.75rem;
    /* --col 1: a second column, for a label whose layer sits too close to
       the one above for three lines each */
    padding-left: calc(0.75rem + var(--col, 0) * 5em);
    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;
  }
  /* the tilted layer, always at 0, 0, 0: its rotation instead, once
     there is one (scene.js) */
  & .ground::after {
    content: var(--debug-rotation, var(--debug-x) var(--debug-y) var(--debug-z));
  }
  & .plaque::after {
    bottom: 60%;
  }
  & .outline::after {
    bottom: 55%;
    --col: 1;
    --x: 6;
    --y: 25;
  }
  & .inside::after {
    bottom: 50.4%;
    --x: 67;
    --y: 83;
  }
  & .podium.white::after {
    bottom: 45.3%;
    --col: 1;
    --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%;
    --col: 1;
    --x: 53;
    --y: 63;
  }

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

/* a zero left out, unless all three are */
@container style(--left: 0) {
  .zdepth :is(.root, .offset, .ground, .plaque, .outline, .inside, .podium, .text)::after {
    --debug-x: "";
  }
}
@container style(--top: 0) {
  .zdepth :is(.root, .offset, .ground, .plaque, .outline, .inside, .podium, .text)::after {
    --debug-y: "";
  }
}
@container style(--z: 0) {
  .zdepth :is(.root, .offset, .ground, .plaque, .outline, .inside, .podium, .text)::after {
    --debug-z: "";
  }
}
@container style(--left: 0) and style(--top: 0) and style(--z: 0) {
  .zdepth :is(.root, .offset, .ground, .plaque, .outline, .inside, .podium, .text)::after {
    --debug-x: "x: "counter(x);
    --debug-y: "\A y: "counter(y);
    --debug-z: "\A z: "counter(z);
  }
}

/*
 * 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 x, y and z (top-left-front corner), fading out with the
 * piece
 */
.zdepth .root.disassembled {
  & .outline::after,
  & .text::after {
    display: none;
  }

  & .ground .base::after {
    counter-reset: x var(--live-x) y var(--live-y) z var(--live-z);
    opacity: var(--fade, 1);
    /* moving: all three, always */
    --debug-x: "x: "counter(x);
    --debug-y: "\A y: "counter(y);
    --debug-z: "\A z: "counter(z);
  }
}

/* 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-x) var(--debug-y) var(--debug-z);
  color: var(--color);
  border-bottom: 1px solid var(--color);
  font-family: "Montserrat", sans-serif;
  white-space: pre;
  font-size: 0.75rem;
  padding-left: 0.75rem;
  text-shadow: 0px 0px 2px rgba(0, 0, 0, 0.4);
}
