/* ==========================================================================
   INFINITE CANVAS - SPATIAL COMMAND CENTER
   A 2D navigable space with mission control aesthetics
   ========================================================================== */

/* --------------------------------------------------------------------------
   Discovery Elements - Edge hints and tooltips
   -------------------------------------------------------------------------- */

.canvas-discovery-hint {
  position: fixed;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  opacity: 0.7;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

body.canvas-mode .canvas-discovery-hint {
  opacity: 0;
  pointer-events: none;
}

.discovery-arrow {
  width: 36px;
  height: 36px;
  border: 1.5px solid rgba(127, 245, 255, 0.5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  animation: pulseGlow 2.5s ease-in-out infinite;
}

.discovery-arrow::after {
  content: "→";
  font-size: 1rem;
  color: rgba(127, 245, 255, 0.9);
  animation: nudgeRight 1.8s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(127, 245, 255, 0.2); }
  50% { box-shadow: 0 0 20px 4px rgba(127, 245, 255, 0.15); }
}

@keyframes nudgeRight {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(3px); }
}

.discovery-text {
  writing-mode: vertical-rl;
  font-size: 0.65rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: rgba(127, 245, 255, 0.4);
  font-family: var(--font-family, system-ui);
}

/* Edge Glow */
.edge-glow {
  position: fixed;
  top: 0;
  right: 0;
  width: 120px;
  height: 100vh;
  z-index: 85;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
  background: linear-gradient(to left,
    rgba(127, 245, 255, 0.12) 0%,
    rgba(127, 245, 255, 0.04) 40%,
    transparent 100%
  );
}

.edge-glow.active {
  opacity: 1;
}

.edge-glow::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 2px;
  height: 100%;
  background: linear-gradient(to bottom,
    transparent 0%,
    rgba(127, 245, 255, 0.4) 15%,
    rgba(127, 245, 255, 0.7) 50%,
    rgba(127, 245, 255, 0.4) 85%,
    transparent 100%
  );
}

/* Tooltip */
.canvas-tooltip {
  position: fixed;
  right: 70px;
  top: 50%;
  transform: translateY(-50%) translateX(10px);
  z-index: 91;
  max-width: 200px;
  padding: 1rem;
  background: rgba(3, 7, 18, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(127, 245, 255, 0.25);
  border-radius: 10px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.canvas-tooltip.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%) translateX(0);
}

.canvas-tooltip::after {
  content: "";
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%) rotate(45deg);
  width: 10px;
  height: 10px;
  background: rgba(3, 7, 18, 0.95);
  border-right: 1px solid rgba(127, 245, 255, 0.25);
  border-top: 1px solid rgba(127, 245, 255, 0.25);
}

.canvas-tooltip h4 {
  font-size: 0.85rem;
  color: #7ff5ff;
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.canvas-tooltip p {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.75);
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.canvas-tooltip-dismiss {
  font-size: 0.65rem;
  color: rgba(127, 245, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* --------------------------------------------------------------------------
   Canvas Container
   -------------------------------------------------------------------------- */

#infinite-canvas {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              visibility 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--background-color, #000);
  overflow: hidden;
}

#infinite-canvas.active {
  pointer-events: auto;
  opacity: 1;
  visibility: visible;
}

.canvas-track {
  display: grid;
  grid-template-columns: repeat(4, 100vw);
  grid-template-rows: repeat(2, 100vh);
  width: max-content;
  height: max-content;
  will-change: transform;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
}

/* --------------------------------------------------------------------------
   Parallax Layers - Background, Content, Foreground
   -------------------------------------------------------------------------- */

.parallax-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  will-change: transform;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
  pointer-events: none;
}

.parallax-content {
  position: relative;
  z-index: 1;
  will-change: transform;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
}

.parallax-fg {
  position: absolute;
  z-index: 2;
  will-change: transform;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
  pointer-events: none;
}

/* Transition state - add during animation */
#infinite-canvas.transitioning .parallax-bg,
#infinite-canvas.transitioning .parallax-content,
#infinite-canvas.transitioning .parallax-fg {
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

/* --------------------------------------------------------------------------
   Canvas Sections - 2D Grid Layout
   -------------------------------------------------------------------------- */

.canvas-section {
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Grid positions */
.canvas-section[data-section="home"]     { grid-area: 1 / 1; }
.canvas-section[data-section="about"]    { grid-area: 1 / 2; }
.canvas-section[data-section="services"] { grid-area: 1 / 3; }
.canvas-section[data-section="blog"]     { grid-area: 1 / 4; }
.canvas-section[data-section="careers"]  { grid-area: 2 / 1; }
.canvas-section[data-section="contact"]  { grid-area: 2 / 2; }
.canvas-section[data-section="lab"]      { grid-area: 2 / 3; }
.canvas-section[data-section="brand"]    { grid-area: 2 / 4; }

/* Section backgrounds */
.canvas-section[data-section="home"] {
  background: radial-gradient(ellipse at 30% 20%, rgba(127, 245, 255, 0.08) 0%, transparent 50%), var(--carbon-fiber-bg, #000);
}
.canvas-section[data-section="about"] {
  background: radial-gradient(ellipse at 70% 30%, rgba(246, 173, 85, 0.06) 0%, transparent 50%), var(--carbon-fiber-bg, #000);
}
.canvas-section[data-section="services"] {
  background: radial-gradient(ellipse at 50% 70%, rgba(68, 255, 178, 0.06) 0%, transparent 50%), var(--carbon-fiber-bg, #000);
}
.canvas-section[data-section="blog"] {
  background: radial-gradient(ellipse at 20% 60%, rgba(127, 245, 255, 0.05) 0%, transparent 50%), var(--carbon-fiber-bg, #000);
}
.canvas-section[data-section="careers"] {
  background: radial-gradient(ellipse at 80% 40%, rgba(246, 173, 85, 0.05) 0%, transparent 50%), var(--carbon-fiber-bg, #000);
}
.canvas-section[data-section="contact"] {
  background: radial-gradient(ellipse at 50% 50%, rgba(68, 255, 178, 0.06) 0%, transparent 50%), var(--carbon-fiber-bg, #000);
}
.canvas-section[data-section="lab"] {
  background: radial-gradient(ellipse at 50% 50%, rgba(127, 245, 255, 0.05) 0%, transparent 58%), var(--carbon-fiber-bg, #000);
}
.canvas-section[data-section="brand"] {
  background: radial-gradient(ellipse at 30% 70%, rgba(127, 245, 255, 0.04) 0%, transparent 50%), var(--carbon-fiber-bg, #000);
}

/* Section divider lines */
.canvas-section::after {
  content: "";
  position: absolute;
  top: 8%;
  right: 0;
  width: 1px;
  height: 84%;
  background: linear-gradient(to bottom,
    transparent 0%,
    rgba(127, 245, 255, 0.2) 15%,
    rgba(127, 245, 255, 0.35) 50%,
    rgba(127, 245, 255, 0.2) 85%,
    transparent 100%
  );
  pointer-events: none;
}

.canvas-section::before {
  content: "";
  position: absolute;
  left: 8%;
  bottom: 0;
  width: 84%;
  height: 1px;
  background: linear-gradient(to right,
    transparent 0%,
    rgba(127, 245, 255, 0.15) 15%,
    rgba(127, 245, 255, 0.25) 50%,
    rgba(127, 245, 255, 0.15) 85%,
    transparent 100%
  );
  pointer-events: none;
}

/* Last column - no right border */
.canvas-section[data-section="blog"]::after,
.canvas-section[data-section="brand"]::after {
  display: none;
}

/* Last row - no bottom border */
.canvas-section[data-section="careers"]::before,
.canvas-section[data-section="contact"]::before,
.canvas-section[data-section="lab"]::before,
.canvas-section[data-section="brand"]::before {
  display: none;
}

/* Section label - now a parallax foreground element */
.canvas-section-label {
  position: absolute;
  top: 90px;
  left: 2rem;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.9rem 0.4rem 0.6rem;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(127, 245, 255, 0.25);
  border-radius: 6px;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #7ff5ff;
  pointer-events: none;
}

.canvas-section-label.parallax-fg {
  will-change: transform;
  backface-visibility: hidden;
}

.canvas-section-label::before {
  content: "";
  width: 6px;
  height: 6px;
  background: #7ff5ff;
  border-radius: 50%;
  box-shadow: 0 0 8px #7ff5ff;
  animation: labelPulse 2s ease-in-out infinite;
}

@keyframes labelPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Section inner content */
.canvas-section-inner {
  flex: 1;
  padding: 130px 3rem 3rem;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Direction indicators */
.canvas-scroll-cue {
  position: absolute;
  bottom: 1.5rem;
  right: 2rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.3);
}

.canvas-scroll-cue::after {
  content: "→";
  font-size: 1rem;
  animation: cueNudge 2s ease-in-out infinite;
}

@keyframes cueNudge {
  0%, 100% { transform: translateX(0); opacity: 0.3; }
  50% { transform: translateX(5px); opacity: 0.6; }
}

/* --------------------------------------------------------------------------
   Canvas Navigation
   -------------------------------------------------------------------------- */

.canvas-nav {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 150;
  display: flex;
  gap: 2px;
  padding: 4px;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(127, 245, 255, 0.15);
  border-radius: 8px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

body.canvas-mode .canvas-nav {
  opacity: 1;
  visibility: visible;
}

.canvas-nav-link {
  padding: 0.45rem 0.85rem;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
  background: transparent;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.canvas-nav-link:hover {
  color: #fff;
  background: rgba(127, 245, 255, 0.1);
}

.canvas-nav-link.active {
  color: #7ff5ff;
  background: rgba(127, 245, 255, 0.12);
}

/* Exit button */
.canvas-exit {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 150;
  padding: 0.5rem 1rem;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  font-family: inherit;
}

body.canvas-mode .canvas-exit {
  opacity: 1;
  visibility: visible;
}

.canvas-exit:hover {
  color: #7ff5ff;
  border-color: rgba(127, 245, 255, 0.4);
  background: rgba(127, 245, 255, 0.08);
}

/* --------------------------------------------------------------------------
   Minimap
   -------------------------------------------------------------------------- */

#canvas-minimap {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  z-index: 150;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 1.2rem;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(127, 245, 255, 0.2);
  border-radius: 10px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#canvas-minimap.visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.minimap-label {
  font-size: 0.6rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.4);
}

.minimap-track {
  width: 240px;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.minimap-progress {
  height: 100%;
  background: linear-gradient(90deg, #7ff5ff, #44ffb2);
  border-radius: 3px;
  transition: width 0.15s ease-out;
  box-shadow: 0 0 10px rgba(127, 245, 255, 0.5);
}

.minimap-dots {
  display: flex;
  gap: 0.5rem;
}

.minimap-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
}

.minimap-dot:hover {
  background: rgba(127, 245, 255, 0.4);
  border-color: #7ff5ff;
  transform: scale(1.15);
}

.minimap-dot.active {
  background: #7ff5ff;
  border-color: #7ff5ff;
  box-shadow: 0 0 8px rgba(127, 245, 255, 0.7);
}

/* --------------------------------------------------------------------------
   Keyboard Hint
   -------------------------------------------------------------------------- */

.keyboard-hint {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 140;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.7rem;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.4);
  opacity: 0;
  transition: opacity 0.3s ease;
}

body.canvas-mode .keyboard-hint {
  opacity: 1;
}

.keyboard-hint kbd {
  padding: 0.15rem 0.35rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  font-family: inherit;
  font-size: 0.55rem;
}

/* --------------------------------------------------------------------------
   Canvas Mode - Body States
   -------------------------------------------------------------------------- */

body.canvas-mode {
  overflow: hidden;
}

body.canvas-mode .site-header {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

body.canvas-mode .page-shell {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1024px) {
  .canvas-section-inner {
    padding: 110px 2rem 2rem;
  }

  .minimap-track {
    width: 180px;
  }
}

@media (max-width: 768px) {
  /* Disable canvas on mobile */
  #infinite-canvas,
  .canvas-discovery-hint,
  .edge-glow,
  .canvas-tooltip,
  .canvas-nav,
  .canvas-exit,
  #canvas-minimap,
  .keyboard-hint {
    display: none !important;
  }
}

/* --------------------------------------------------------------------------
   Reduced Motion
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .discovery-arrow,
  .discovery-arrow::after,
  .canvas-section-label::before,
  .canvas-scroll-cue::after {
    animation: none;
  }

  .canvas-track {
    transition: transform 0.2s ease;
  }
}
