/** VarleyLabs homepage hero cube component (stacked below the hero copy).
    Load after global.css and home.css. Uses the global design tokens
    (--violet, --blue, --on-dark, --font-ui) so it stays in step with
    the rest of the site. */

/* ----------------------------------------------------------------------------
   Stacked hero — the original centred copy, cube beneath it, the
   hero-canvas stars behind both and the grid floor under the cube.
---------------------------------------------------------------------------- */

/* GUARD: something on the page (likely a script-added class or inline
   style) was applying a grouping property to the cube elements, which
   flattens 3D children. These out-rank class rules and inline styles. */
.cube-frame { perspective: 1100px !important; }

.cube,
.cubie {
  transform-style: preserve-3d !important;
  filter: none !important;
  opacity: 1 !important;
}

/* ----------------------------------------------------------------------------
   Cube component (self-contained; transparent background)
---------------------------------------------------------------------------- */
.cube-stage {
  /* Component tokens, mapped onto the site palette */
  --cube-size: clamp(230px, 28vw, 370px);
  --piece-gap: 5px;
  --face-base: #151934;
  --face-edge: rgba(215, 220, 255, 0.28);
  --accent-soft: #9d7bff;
  --tb-line: rgba(190, 198, 240, 0.22);
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  position: relative;
  margin-top: clamp(58px, 8vw, 104px);
  min-height: clamp(340px, 42vw, 520px);
  display: grid;
  place-items: center;
  isolation: isolate;
}

/* Drawn shadow: a dashed construction ellipse */
.cube-stage::after {
  content: "";
  position: absolute;
  width: calc(var(--cube-size) * 0.86);
  height: calc(var(--cube-size) * 0.22);
  bottom: 6%;
  border: 1px dashed rgba(190, 198, 240, 0.28);
  border-radius: 50%;
  background: rgba(5, 7, 18, 0.42);
  z-index: -1;
}

.cube-frame {
  width: var(--cube-size);
  height: var(--cube-size);
  display: grid;
  place-items: center;
  perspective: 1100px;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.cube-frame.is-dragging {
  cursor: grabbing;
}

.cube-frame:focus-visible {
  outline: 1px dashed var(--accent-soft);
  outline-offset: 14px;
}

.cube {
  --rx: -23deg;
  --ry: 36deg;
  position: relative;
  width: var(--cube-size);
  height: var(--cube-size);
  transform-style: preserve-3d;
  transform: rotateX(var(--rx)) rotateY(var(--ry));
  will-change: transform;
}

/* Never add filter/drop-shadow to .cube or anything inside the frame —
   `filter` is a grouping property and force-flattens preserve-3d
   children, collapsing the cube to a plane. */

.cubie {
  --size: calc((var(--cube-size) - (var(--piece-gap) * 2)) / 3);
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--size);
  height: var(--size);
  margin-left: calc(var(--size) / -2);
  margin-top: calc(var(--size) / -2);
  transform-style: preserve-3d;
  transform:
    translate3d(
      calc(var(--x) * (var(--size) + var(--piece-gap))),
      calc(var(--y) * (var(--size) + var(--piece-gap))),
      calc(var(--z) * (var(--size) + var(--piece-gap)))
    );
}

.face {
  position: absolute;
  inset: 0;
  border: 1px solid var(--face-edge);
  border-radius: 5px;
  backface-visibility: hidden;
  background:
    linear-gradient(150deg, rgba(180, 188, 255, 0.07), rgba(5, 6, 18, 0.55)),
    var(--face-base);
}

/* Each face reads its brightness from a cube-level variable that the
   JS updates a few times a second from the face's real angle to the
   key light. */
.face-front  { --lit: var(--lit-front, 0.45); }
.face-back   { --lit: var(--lit-back, 0.06); }
.face-right  { --lit: var(--lit-right, 0.2); }
.face-left   { --lit: var(--lit-left, 0.55); }
.face-top    { --lit: var(--lit-top, 0.8); }
.face-bottom { --lit: var(--lit-bottom, 0.06); }

/* Shadow side is hatched, the way a drawing shades. The opacity
   transition lets the compositor fade between the ~6Hz lighting
   updates so faces are never repainted mid-spin. (The global
   reduced-motion rule removes the transition, which is fine — the
   cube is paused for those users anyway.) */
.face::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: calc((1 - var(--lit, 0.4)) * 0.55);
  transition: opacity 220ms linear;
  background: repeating-linear-gradient(45deg, rgba(2, 3, 12, 0.85) 0 1px, transparent 1px 5px);
}

/* Lit side gets a pale wash with the brand violet in its tail */
.face::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: var(--lit, 0.35);
  transition: opacity 220ms linear;
  background:
    linear-gradient(150deg,
      rgba(238, 236, 255, 0.4),
      rgba(196, 196, 255, 0.12) 55%,
      rgba(118, 80, 232, 0.08));
}

/* Interior faces are only glimpsed through the piece gaps: flat paint,
   no lighting layers, so per-frame updates never touch them. */
.face-plain {
  border-color: rgba(215, 220, 255, 0.12);
  background: #0a0d1f;
}

.face-plain::before,
.face-plain::after {
  content: none;
}

.face-front  { transform: rotateY(0deg) translateZ(calc(var(--size) / 2)); }
.face-back   { transform: rotateY(180deg) translateZ(calc(var(--size) / 2)); }
.face-right  { transform: rotateY(90deg) translateZ(calc(var(--size) / 2)); }
.face-left   { transform: rotateY(-90deg) translateZ(calc(var(--size) / 2)); }
.face-top    { transform: rotateX(90deg) translateZ(calc(var(--size) / 2)); }
.face-bottom { transform: rotateX(-90deg) translateZ(calc(var(--size) / 2)); }

.cubie[data-z="1"][data-x="0"][data-y="0"] .face-front::before {
  content: "VL";
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 1;
  color: var(--accent-soft);
  background: none;
  font-family: var(--font-mono);
  font-size: calc(var(--size) * 0.26);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-shadow: 0 0 22px rgba(118, 80, 232, 0.5);
}

/* Figure caption with dimension-style rule lines */
.interaction-hint {
  position: absolute;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0;
  color: rgba(var(--on-dark), 0.55);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.interaction-hint::before,
.interaction-hint::after {
  content: "";
  width: 42px;
  height: 1px;
  background: var(--tb-line);
}

/* Live title block, like the corner of an engineering drawing */
.title-block {
  position: absolute;
  right: 0;
  bottom: 8%;
  min-width: 192px;
  border: 1px solid var(--tb-line);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(10, 12, 26, 0.78);
  color: rgba(var(--on-dark), 0.6);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.04em;
}

.tb-row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 7px 12px;
  border-top: 1px solid rgba(190, 198, 240, 0.14);
}

.tb-row:first-child {
  border-top: 0;
  color: #fff;
  letter-spacing: 0.12em;
}

.tb-row span:last-child {
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.tb-row #readoutState {
  color: var(--accent-soft);
}

/* ----------------------------------------------------------------------------
   Responsive
---------------------------------------------------------------------------- */
@media (max-width: 1080px) {
  .title-block {
    right: -2%;
    bottom: 2%;
  }
}

@media (max-width: 920px) {
  .cube-stage {
    --cube-size: clamp(210px, 56vw, 320px);
    min-height: 0;
    padding-bottom: 6px;
  }

  .cube-stage::after {
    bottom: auto;
    top: calc(var(--cube-size) * 0.94);
  }

  .interaction-hint {
    position: static;
    justify-content: center;
    margin-top: 30px;
  }

  .title-block {
    position: static;
    justify-self: center;
    margin-top: 12px;
    min-width: 226px;
  }
}

@media (max-width: 767px) {
  /* The cube is a desktop/tablet flourish. On phones it crowds the hero,
     so remove the whole component and let the offer stay front and centre. */
  .cube-stage {
    display: none;
  }
}
