/* ==========================================================================
   LAZZYENGINEER - 1:1 3D ISOMETRIC STAGE, CENTERED MATRIX & OBJECTS
   ========================================================================== */

.spatial-viewport {
  --grid-cell-size: 80px;
  --grid-cols: 34;
  --grid-rows: 34;
  --grid-width: 1px;
  --grid-border: var(--grid-width) solid var(--colors-gray4);
  --crosshair-size: calc(var(--grid-cell-size) / 4);
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
  touch-action: none;
  background: var(--colors-bg);
  perspective: 1200px;
  transform-style: preserve-3d;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color 300ms ease;
}

/* ── Top & Bottom HUD Elements ── */
.spatial-hud {
  position: fixed;
  z-index: 100;
  font-family: var(--fonts-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--colors-gray11);
  letter-spacing: -0.01em;
  pointer-events: none;
}

.spatial-hud.top-left {
  top: 28px;
  left: 32px;
}

.spatial-hud.top-right {
  top: 28px;
  right: 32px;
  cursor: pointer;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate(var(--mag-x, 0px), var(--mag-y, 0px));
  transition: transform 120ms ease;
}

.spatial-hud.top-right svg {
  width: 16px;
  height: 16px;
  fill: var(--colors-gray12);
  transition: transform 200ms ease;
}

.spatial-hud.top-right:hover svg {
  transform: scale(1.2);
}

.spatial-hud.bottom-left {
  bottom: 28px;
  left: 32px;
}

/* ── Screen Center Subtle Crosshair ── */
.screen-crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  pointer-events: none;
  z-index: 90;
  opacity: 0.4;
  color: var(--colors-gray10);
}

.screen-crosshair svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
}

/* ── 3D Isometric Matrix Stage Plane (Closer in Z-axis & Zoomed In) ── */
.spatial-matrix {
  position: absolute;
  top: 50%;
  left: 50%;
  width: calc(var(--grid-cols) * var(--grid-cell-size));
  height: calc(var(--grid-rows) * var(--grid-cell-size));
  transform-origin: center center;
  transform: translate(calc(-50% + var(--parallax-x, 0px)), calc(-50% + 100px + var(--parallax-y, 0px))) skewX(-48deg) skewY(14deg) scaleX(2) scale(0.33) translateZ(100px) rotateX(var(--rot-x, 0deg)) rotateY(var(--rot-y, 0deg));
  transition: opacity 500ms ease;
  will-change: transform;
  opacity: 1;
}

/* ── Grid Board Container ── */
.spatial-grid-board {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--grid-cols), var(--grid-cell-size));
  grid-template-rows: repeat(var(--grid-rows), var(--grid-cell-size));
  border-right: var(--grid-border);
  border-top: var(--grid-border);
}

.grid-cell {
  border: var(--grid-border);
  border-top: 0;
  border-right: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  width: var(--grid-cell-size);
  height: var(--grid-cell-size);
  position: relative;
  background: var(--colors-bg);
  transition: background-color 350ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 350ms ease;
  cursor: pointer;
}

/* Interactive Hover Color Trail */
.grid-cell.colored {
  background-color: var(--tile-color) !important;
  box-shadow: 0 0 16px var(--tile-color);
  z-index: 2;
}

.grid-subcell {
  transition: opacity 250ms ease-out;
}

.grid-subcell[data-index="1"] {
  border-right: var(--grid-border);
}

.grid-subcell[data-index="2"] {
  border-top: var(--grid-border);
  border-right: var(--grid-border);
}

.grid-subcell[data-index="3"] {
  border-top: var(--grid-border);
}

.grid-cell svg.crosshair {
  width: var(--crosshair-size);
  height: calc(var(--crosshair-size) + 1px);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0.35;
  stroke: var(--colors-gray8);
}

/* ── Giant Bold Letter Glyphs (LAZZY ENGINEER) ── */
.spatial-letter {
  position: absolute;
  left: calc(var(--col) * var(--grid-cell-size));
  top: calc(var(--row) * var(--grid-cell-size));
  width: var(--w, 140px);
  height: var(--h, 240px);
  z-index: 5;
  pointer-events: none;
  opacity: 1;
}

.spatial-letter svg {
  width: 100%;
  height: 100%;
  display: block;
}

.spatial-letter path {
  fill: var(--colors-highContrast);
}

/* ── 3D Scene / Portal Cards ── */
.spatial-card {
  position: absolute;
  left: calc(var(--col) * var(--grid-cell-size));
  top: calc(var(--row) * var(--grid-cell-size));
  width: calc(var(--span-col) * var(--grid-cell-size));
  height: calc(var(--span-row) * var(--grid-cell-size));
  z-index: 10;
  opacity: 1;
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transform: translateY(var(--float-y, 0px)) rotate(var(--float-rot, 0deg));
  transition: transform 250ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 250ms ease;
}

.spatial-card-inner {
  overflow: hidden;
  width: 100%;
  height: 100%;
  position: relative;
  background: var(--colors-gray2);
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  border: 1px solid var(--colors-gray5);
  box-shadow: 20px 36px 45px 0px rgba(0, 0, 0, 0.22);
  filter: grayscale(1) blur(0.0001px);
  transition: filter 350ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 250ms ease;
}

.spatial-card:hover {
  transform: translateY(calc(var(--float-y, 0px) - 12px)) scale(1.04) translateZ(20px);
  z-index: 30;
}

.spatial-card:hover .spatial-card-inner {
  filter: grayscale(0) drop-shadow(0 20px 30px rgba(0, 0, 0, 0.25));
  box-shadow: 36px 56px 70px 0px rgba(0, 0, 0, 0.38);
}

.spatial-card-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

html.light .theme-dark-only {
  display: none !important;
}

html.dark .theme-light-only {
  display: none !important;
}

/* ── Projected Anchor Overlay ── */
.spatial-anchor-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 50;
  pointer-events: none;
  transform: none;
  transform-style: flat;
}

.spatial-anchor {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 180ms ease, visibility 180ms ease;
}

.spatial-anchor.is-visible {
  opacity: 1;
  visibility: visible;
}

.spatial-anchor-line {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--line-length, 70px);
  height: 1px;
  background: var(--colors-gray12);
  transform-origin: 0 50%;
  transform: rotate(var(--line-angle, -32deg));
  opacity: 0.85;
  pointer-events: none;
}

.spatial-anchor-line::after {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--colors-gray12);
  transform: translate(50%, -50%);
}

.spatial-anchor-label {
  position: absolute;
  left: var(--label-x, 0px);
  top: var(--label-y, 0px);
  transform: translate(-50%, -50%);
  font-family: var(--fonts-mono);
  font-size: 14px;
  line-height: 1;
  font-weight: 600;
  color: var(--colors-gray12);
  white-space: nowrap;
  letter-spacing: -0.02em;
  pointer-events: none;
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: antialiased;
}

.spatial-anchor-label::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: var(--colors-gray12);
  transform: translateX(-50%);
}

/* ── Magnetic Buttons on Dock ── */
.dock-btn {
  transform: translate(var(--mag-x, 0px), var(--mag-y, 0px));
}

.copy-email-pill {
  transform: translate(var(--mag-x, 0px), var(--mag-y, 0px));
}