/* ═══════════════════════════════════════════════════════════════════════════
   CUBE NAVIGATION — PURE CSS 3D
   Hera · XOVEREIGN Technologies · White Crown Enterprises

   Kevin's navigation signature. `transform-style: preserve-3d` and six faces.
   No WebGL, no Three.js, no canvas, no Babylon — the whole cube is layout and
   transforms, so it costs nothing to render, survives page zoom, and every
   face stays a real focusable element in the accessibility tree.

   TWO INVARIANTS, both learned the hard way:

   A. NO FILTER ON A 3D ANCESTOR. `filter` / `backdrop-filter` establish a
      containing block that flattens `preserve-3d` for every descendant. The
      dock's frosted backdrop is therefore a SEPARATE, absolutely positioned,
      pointer-events:none sibling behind the deck — never a parent of it.

   B. TURNING THE CUBE MOVES THE ACCESSIBILITY STATE WITH IT. The face towards
      the viewer is `data-forward="true"`; the other five stay ordinary,
      reachable controls behind it. Never a silent focus trap, and never a set
      of five buttons a screen-reader user can hear but not act on.
   ═══════════════════════════════════════════════════════════════════════════ */

.xcube-dock {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.55);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* INVARIANT A: the blur lives here, a sibling BEHIND the deck, never above it
   in the tree. */
.xcube-dock-glass {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-color: rgba(4, 6, 15, 0.9);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
}

.xcube-dock-bar {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  padding: 4px 8px 0;
}

.xcube-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background-color: rgba(122, 162, 255, 0.07);
  color: var(--silver);
  font-size: var(--t-label);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.xcube-toggle:hover {
  background-color: rgba(122, 162, 255, 0.16);
  color: #fff;
  border-color: var(--blue-soft);
}
.xcube-toggle svg { width: 14px; height: 14px; flex: 0 0 auto; }

.xcube-deck {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(6px, 2vw, 26px);
  padding: 0 6px 6px;
}

.xcube-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.xcube-title {
  font-family: var(--mono);
  font-size: var(--t-label);
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--silver);
  line-height: 1.3;
  margin: 0;
}

.xcube-row { display: flex; align-items: center; gap: 0; }

/* 48 x 48. The stage clamp below subtracts 96px — the two arrows — so the cube
   shrinks to fit rather than the arrows being pushed off a narrow screen. */
.xcube-turn {
  display: grid;
  place-items: center;
  width: 48px;
  min-height: 48px;
  flex: 0 0 auto;
  border: 0;
  background: none;
  color: var(--silver);
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: color 0.2s var(--ease), background-color 0.2s var(--ease);
}
.xcube-turn:hover { color: #fff; background-color: rgba(122, 162, 255, 0.14); }
.xcube-turn svg { width: 18px; height: 18px; }

.xcube-stage {
  /* Capped at 96px rather than letting it grow with the viewport. The dock is
     persistent, so every pixel it takes is a pixel the document never gets
     back — at 116px the whole dock reached 284px tall, which is a third of a
     laptop screen given to navigation. */
  --xc-size: clamp(62px, calc(100vw - 190px), 96px);
  --xc-half: calc(var(--xc-size) / 2);
  position: relative;
  width: var(--xc-size);
  height: var(--xc-size);
  perspective: 640px;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.xcube {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform: rotateX(var(--xc-rx, 0deg)) rotateY(var(--xc-ry, 0deg));
  transition: transform 0.42s var(--ease-out);
}
.xcube.xcube-dragging { transition: none; will-change: transform; }

.xcube-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  text-align: center;
  font: inherit;
  color: var(--text);
  background-color: rgb(8, 12, 30);
  background-image: linear-gradient(150deg,
    color-mix(in srgb, var(--xc-accent, #7aa2ff) 20%, transparent) 0%,
    transparent 72%);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 0 22px rgba(0, 0, 0, 0.5);
  transition: box-shadow 0.3s var(--ease), border-color 0.3s var(--ease);
  cursor: pointer;
}

.xcube-face-1 { transform: translateZ(var(--xc-half)); }
.xcube-face-2 { transform: rotateY(90deg) translateZ(var(--xc-half)); }
.xcube-face-3 { transform: rotateY(180deg) translateZ(var(--xc-half)); }
.xcube-face-4 { transform: rotateY(-90deg) translateZ(var(--xc-half)); }
.xcube-face-5 { transform: rotateX(90deg) translateZ(var(--xc-half)); }
.xcube-face-6 { transform: rotateX(-90deg) translateZ(var(--xc-half)); }

.xcube-face[data-forward="true"] {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 0 26px color-mix(in srgb, var(--xc-accent, #7aa2ff) 55%, transparent),
    0 0 62px color-mix(in srgb, var(--xc-accent, #7aa2ff) 26%, transparent);
  border-color: color-mix(in srgb, var(--xc-accent, #7aa2ff) 80%, transparent);
}

.xcube-face[aria-current="true"], .xcube-face[aria-current="page"] {
  outline: 2px solid color-mix(in srgb, var(--xc-accent, #7aa2ff) 90%, white);
  outline-offset: -2px;
}

.xcube-face:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  box-shadow: none;
  z-index: 2;
}

.xcube-face-icon { width: 32%; height: 32%; max-width: 34px; max-height: 34px; flex: 0 0 auto; }

/* The tile label is decoration — .xcube-face carries the full name in its
   aria-label — so it may wrap and hyphenate freely. `hyphens: manual` is what
   honours the soft hyphens in the labels; without a break opportunity that
   FITS, the engine falls back to overflow-wrap and breaks mid-syllable. */
.xcube-face-name {
  color: rgba(255, 255, 255, 0.96);
  font-size: clamp(7px, 2.1vw, 9px);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.01em;
  max-width: 100%;
  max-height: 3.6em;
  overflow: hidden;
  hyphens: manual;
  -webkit-hyphens: manual;
  overflow-wrap: break-word;
}

.xcube-face-index {
  position: absolute;
  top: 4px;
  right: 6px;
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.75);
}

.xcube-counter {
  font-family: var(--mono);
  font-size: var(--t-label);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--silver);
  text-align: center;
  max-width: 230px;
  line-height: 1.2;
  /* Two lines are reserved so the dock does not resize as the cube turns
     between a one-line and a two-line face name — a dock that changes height
     under the pointer is a dock that moves the control away from the click. */
  min-height: 2.4em;
  margin: 0;
}

.xcube-dots { display: flex; gap: 0; justify-content: center; }

/* 26 x 48 — the 48px is carried on the vertical axis, see the TAP TARGETS
   note at the top of cosmic.css. */
.xcube-dot {
  width: 26px;
  min-width: 26px;
  height: 48px;
  min-height: 48px;
  padding: 0;
  border: 0;
  background: none;
  display: grid;
  place-items: center;
  border-radius: 11px;
  cursor: pointer;
}
.xcube-dot > span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: rgba(185, 198, 222, 0.42);
  transition: background-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.xcube-dot[data-current="true"] > span {
  background-color: var(--blue);
  transform: scale(1.55);
}
.xcube-dot:hover > span { background-color: #fff; }

@media (prefers-reduced-motion: reduce) {
  .xcube { transition: none; }
  .xcube-dot > span { transition: none; }
}
body.reduced-motion .xcube { transition: none; }
